| @@ -1,78 +1,100 @@ | | | @@ -1,78 +1,100 @@ |
1 | $NetBSD: patch-ac,v 1.3 1998/12/28 22:13:05 marc Exp $ | | 1 | $NetBSD: patch-ac,v 1.4 2011/01/02 14:46:39 obache Exp $ |
2 | | | 2 | |
3 | --- ls.c.orig Sat Dec 21 18:40:58 1996 | | 3 | --- ls.c.orig 1996-12-21 23:40:58.000000000 +0000 |
4 | +++ ls.c Mon Dec 28 17:10:04 1998 | | 4 | +++ ls.c |
5 | @@ -59,6 +59,8 @@ | | 5 | @@ -59,12 +59,18 @@ static char const sccsid[] = "@(#)ls.c 8 |
6 | #include <string.h> | | 6 | #include <string.h> |
7 | #include <unistd.h> | | 7 | #include <unistd.h> |
8 | #include <locale.h> | | 8 | #include <locale.h> |
9 | +#include <pwd.h> | | 9 | +#include <pwd.h> |
10 | +#include <grp.h> | | 10 | +#include <grp.h> |
11 | | | 11 | |
12 | #include "ls.h" | | 12 | #include "ls.h" |
13 | #include "extern.h" | | 13 | #include "extern.h" |
14 | @@ -94,6 +96,7 @@ | | 14 | |
| | | 15 | static void display __P((FTSENT *, FTSENT *)); |
| | | 16 | +#ifdef __DragonFly__ |
| | | 17 | +static int mastercmp __P((const FTSENT * const *, const FTSENT * const *)); |
| | | 18 | +#else |
| | | 19 | static int mastercmp __P((const FTSENT **, const FTSENT **)); |
| | | 20 | +#endif |
| | | 21 | static void traverse __P((int, char **, int)); |
| | | 22 | |
| | | 23 | static void (*printfcn) __P((DISPLAY *)); |
| | | 24 | @@ -94,6 +100,7 @@ int f_statustime; /* use time of last m |
15 | int f_dirname; /* if precede with directory name */ | | 25 | int f_dirname; /* if precede with directory name */ |
16 | int f_timesort; /* sort by time vice name */ | | 26 | int f_timesort; /* sort by time vice name */ |
17 | int f_type; /* add type character for non-regular files */ | | 27 | int f_type; /* add type character for non-regular files */ |
18 | +int f_color; /* add type in color for non-regular files */ | | 28 | +int f_color; /* add type in color for non-regular files */ |
19 | #ifndef BSD4_4_LITE | | 29 | #ifndef BSD4_4_LITE |
20 | int f_whiteout; /* show whiteout entries */ | | 30 | int f_whiteout; /* show whiteout entries */ |
21 | #endif | | 31 | #endif |
22 | @@ -135,9 +138,9 @@ | | 32 | @@ -135,9 +142,9 @@ main(argc, argv) |
23 | | | 33 | |
24 | fts_options = FTS_PHYSICAL; | | 34 | fts_options = FTS_PHYSICAL; |
25 | #ifdef BSD4_4_LITE | | 35 | #ifdef BSD4_4_LITE |
26 | - while ((ch = getopt(argc, argv, "1ACFLRTacdfgikloqrstu")) != EOF) { | | 36 | - while ((ch = getopt(argc, argv, "1ACFLRTacdfgikloqrstu")) != EOF) { |
27 | + while ((ch = getopt(argc, argv, "1ACFGLRTacdfgikloqrstu")) != EOF) { | | 37 | + while ((ch = getopt(argc, argv, "1ACFGLRTacdfgikloqrstu")) != EOF) { |
28 | #else | | 38 | #else |
29 | - while ((ch = getopt(argc, argv, "1ACFLRTWacdfgikloqrstu")) != EOF) { | | 39 | - while ((ch = getopt(argc, argv, "1ACFLRTWacdfgikloqrstu")) != EOF) { |
30 | + while ((ch = getopt(argc, argv, "1ACFGLRTWacdfgikloqrstu")) != EOF) { | | 40 | + while ((ch = getopt(argc, argv, "1ACFGLRTWacdfgikloqrstu")) != EOF) { |
31 | #endif | | 41 | #endif |
32 | switch (ch) { | | 42 | switch (ch) { |
33 | /* | | 43 | /* |
34 | @@ -168,6 +171,10 @@ | | 44 | @@ -168,6 +175,10 @@ main(argc, argv) |
35 | case 'F': | | 45 | case 'F': |
36 | f_type = 1; | | 46 | f_type = 1; |
37 | break; | | 47 | break; |
38 | + case 'G': | | 48 | + case 'G': |
39 | + if (isatty(STDOUT_FILENO)) | | 49 | + if (isatty(STDOUT_FILENO)) |
40 | + f_color = 1; | | 50 | + f_color = 1; |
41 | + break; | | 51 | + break; |
42 | case 'L': | | 52 | case 'L': |
43 | fts_options &= ~FTS_PHYSICAL; | | 53 | fts_options &= ~FTS_PHYSICAL; |
44 | fts_options |= FTS_LOGICAL; | | 54 | fts_options |= FTS_LOGICAL; |
45 | @@ -228,18 +235,21 @@ | | 55 | @@ -228,18 +239,21 @@ main(argc, argv) |
46 | argc -= optind; | | 56 | argc -= optind; |
47 | argv += optind; | | 57 | argv += optind; |
48 | | | 58 | |
49 | + parsecolors(getenv("LSCOLORS")); | | 59 | + parsecolors(getenv("LSCOLORS")); |
50 | + | | 60 | + |
51 | /* | | 61 | /* |
52 | * If not -F, -i, -l, -s or -t options, don't require stat | | 62 | * If not -F, -i, -l, -s or -t options, don't require stat |
53 | * information. | | 63 | * information. |
54 | */ | | 64 | */ |
55 | - if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type) | | 65 | - if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type) |
56 | + if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type | | 66 | + if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type |
57 | + && !f_color) | | 67 | + && !f_color) |
58 | fts_options |= FTS_NOSTAT; | | 68 | fts_options |= FTS_NOSTAT; |
59 | | | 69 | |
60 | /* | | 70 | /* |
61 | * If not -F, -d or -l options, follow any symbolic links listed on | | 71 | * If not -F, -d or -l options, follow any symbolic links listed on |
62 | * the command line. | | 72 | * the command line. |
63 | */ | | 73 | */ |
64 | - if (!f_longform && !f_listdir && !f_type) | | 74 | - if (!f_longform && !f_listdir && !f_type) |
65 | + if (!f_longform && !f_listdir && !f_type && !f_color) | | 75 | + if (!f_longform && !f_listdir && !f_type && !f_color) |
66 | fts_options |= FTS_COMFOLLOW; | | 76 | fts_options |= FTS_COMFOLLOW; |
67 | | | 77 | |
68 | #ifndef BSD4_4_LITE | | 78 | #ifndef BSD4_4_LITE |
69 | @@ -384,7 +394,8 @@ | | 79 | @@ -384,7 +398,8 @@ display(p, list) |
70 | u_long btotal, maxblock, maxinode, maxlen, maxnlink; | | 80 | u_long btotal, maxblock, maxinode, maxlen, maxnlink; |
71 | int bcfile, flen, glen, ulen, maxflags, maxgroup, maxuser; | | 81 | int bcfile, flen, glen, ulen, maxflags, maxgroup, maxuser; |
72 | int entries, needstats; | | 82 | int entries, needstats; |
73 | - char *user, *group, *flags, buf[20]; /* 32 bits == 10 digits */ | | 83 | - char *user, *group, *flags, buf[20]; /* 32 bits == 10 digits */ |
74 | + const char *user, *group; | | 84 | + const char *user, *group; |
75 | + char *flags, buf[20]; /* 32 bits == 10 digits */ | | 85 | + char *flags, buf[20]; /* 32 bits == 10 digits */ |
76 | | | 86 | |
77 | /* | | 87 | /* |
78 | * If list is NULL there are two possibilities: that the parent | | 88 | * If list is NULL there are two possibilities: that the parent |
| | | 89 | @@ -521,7 +536,11 @@ display(p, list) |
| | | 90 | */ |
| | | 91 | static int |
| | | 92 | mastercmp(a, b) |
| | | 93 | +#ifdef __DragonFly__ |
| | | 94 | + const FTSENT * const *a, * const *b; |
| | | 95 | +#else |
| | | 96 | const FTSENT **a, **b; |
| | | 97 | +#endif |
| | | 98 | { |
| | | 99 | int a_info, b_info; |
| | | 100 | |