diff options
author | frueauf <frueauf@pkgsrc.org> | 1998-05-21 14:06:37 +0000 |
---|---|---|
committer | frueauf <frueauf@pkgsrc.org> | 1998-05-21 14:06:37 +0000 |
commit | bb5cd561d5722a90da8c833d39b509bb20326054 (patch) | |
tree | 1f7cc8003a1a3644128d72362a0933626e2630cc /misc | |
parent | a1a5c8b6e88ce3a5b343c78e4c14496227c61622 (diff) | |
download | pkgsrc-bb5cd561d5722a90da8c833d39b509bb20326054.tar.gz |
Handle MANZ case better and split the big patch file into one patch
per file for better maintainance.
Diffstat (limited to 'misc')
-rw-r--r-- | misc/colorls/Makefile | 6 | ||||
-rw-r--r-- | misc/colorls/patches/patch-aa | 377 | ||||
-rw-r--r-- | misc/colorls/patches/patch-ab | 141 | ||||
-rw-r--r-- | misc/colorls/patches/patch-ac | 66 | ||||
-rw-r--r-- | misc/colorls/patches/patch-ad | 10 | ||||
-rw-r--r-- | misc/colorls/patches/patch-ae | 182 |
6 files changed, 386 insertions, 396 deletions
diff --git a/misc/colorls/Makefile b/misc/colorls/Makefile index c1cd6f29c90..80179144add 100644 --- a/misc/colorls/Makefile +++ b/misc/colorls/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.6 1998/04/20 11:56:27 frueauf Exp $ +# $NetBSD: Makefile,v 1.7 1998/05/21 14:06:37 frueauf Exp $ # FreeBSD Id: Makefile,v 1.13 1997/04/30 03:18:06 asami Exp # @@ -12,8 +12,8 @@ MAINTAINER= packages@netbsd.org WRKSRC= ${WRKDIR}/ls -MAN1= colorls.1 -CAT1= colorls.0 +# Do not list MAN/CAT pages here. It will confuse if MANZ is set. +# The pkg uses BSD-style-Makefiles itself, so it does the right thing. pre-patch: ${CP} ${WRKSRC}/ls.1 ${WRKSRC}/colorls.1 diff --git a/misc/colorls/patches/patch-aa b/misc/colorls/patches/patch-aa index 5f3c27c7fe4..90d36f5930a 100644 --- a/misc/colorls/patches/patch-aa +++ b/misc/colorls/patches/patch-aa @@ -1,381 +1,14 @@ ---- ./ls.c.org Wed Mar 8 02:14:11 1995 -+++ ./ls.c Wed Mar 8 02:17:10 1995 -@@ -93,6 +93,7 @@ - int f_dirname; /* if precede with directory name */ - int f_timesort; /* sort by time vice name */ - int f_type; /* add type character for non-regular files */ -+int f_color; /* add type in color for non-regular files */ - #ifndef BSD4_4_LITE - int f_whiteout; /* show whiteout entries */ - #endif -@@ -135,9 +136,9 @@ - - fts_options = FTS_PHYSICAL; - #ifdef BSD4_4_LITE -- while ((ch = getopt(argc, argv, "1ACFLRTacdfgikloqrstu")) != EOF) { -+ while ((ch = getopt(argc, argv, "1ACFGLRTacdfgikloqrstu")) != EOF) { - #else -- while ((ch = getopt(argc, argv, "1ACFLRTWacdfgikloqrstu")) != EOF) { -+ while ((ch = getopt(argc, argv, "1ACFGLRTWacdfgikloqrstu")) != EOF) { - #endif - switch (ch) { - /* -@@ -152,6 +153,9 @@ - case 'F': - f_type = 1; - break; -+ case 'G': -+ f_color = 1; -+ break; - case 'L': - fts_options &= ~FTS_PHYSICAL; - fts_options |= FTS_LOGICAL; -@@ -207,18 +211,21 @@ - argc -= optind; - argv += optind; - -+ parsecolors(getenv("LSCOLORS")); -+ - /* - * If not -F, -i, -l, -s or -t options, don't require stat - * information. - */ -- if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type) -+ if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type -+ && !f_color) - fts_options |= FTS_NOSTAT; - - /* - * If not -F, -d or -l options, follow any symbolic links listed on - * the command line. - */ -- if (!f_longform && !f_listdir && !f_type) -+ if (!f_longform && !f_listdir && !f_type && !f_color) - fts_options |= FTS_COMFOLLOW; - - #ifndef BSD4_4_LITE ---- ./ls.h.org Wed Mar 8 02:14:11 1995 -+++ ./ls.h Wed Mar 8 02:17:11 1995 -@@ -49,6 +49,7 @@ - extern int f_size; /* list size in short listing */ - extern int f_statustime; /* use time of last mode change */ - extern int f_type; /* add type character for non-regular files */ -+extern int f_color; /* add type in color for non-regular files */ - - typedef struct { - FTSENT *list; ---- ./print.c.org Wed Mar 8 02:14:11 1995 -+++ ./print.c Wed Mar 8 02:17:11 1995 -@@ -66,6 +66,26 @@ - - #define IS_NOPRINT(p) ((p)->fts_number == NO_PRINT) - -+/* Most of these are taken from <sys/stat.h> */ -+typedef enum Colors { -+ C_DIR, /* directory */ -+ C_LNK, /* symbolic link */ -+ C_SOCK, /* socket */ -+ C_FIFO, /* pipe */ -+ C_EXEC, /* executable */ -+ C_BLK, /* block special */ -+ C_CHR, /* character special */ -+ C_SUID, /* setuid executable */ -+ C_SGID, /* setgid executable */ -+ C_WSDIR, /* directory writeble to others, with sticky bit */ -+ C_WDIR, /* directory writeble to others, without sticky bit */ -+ C_NUMCOLORS /* just a place-holder */ -+} Colors ; -+ -+char *defcolors = "4x5x2x3x1x464301060203"; -+ -+static int colors[C_NUMCOLORS][2]; -+ - void - printscol(dp) - DISPLAY *dp; -@@ -122,10 +142,14 @@ - printtime(sp->st_ctime); - else - printtime(sp->st_mtime); -+ if (f_color) -+ (void)colortype(sp->st_mode); - (void)printf("%s", p->fts_name); - if (f_type) - (void)printtype(sp->st_mode); -- if (S_ISLNK(sp->st_mode)) -+ if (f_color) -+ (void)printf("\033[m"); -+ if (S_ISLNK(sp->st_mode)) - printlink(p); - (void)putchar('\n'); - } -@@ -190,10 +214,22 @@ - dp->s_block); - if ((base += numrows) >= num) - break; -- while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) <= endcol){ -- (void)putchar('\t'); -- chcnt = cnt; -- } -+ -+ /* -+ * some terminals get confused if we mix tabs -+ * with color sequences -+ */ -+ if (f_color) -+ while ((cnt = (chcnt + 1)) <= endcol) { -+ (void)putchar(' '); -+ chcnt = cnt; -+ } -+ else -+ while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) -+ <= endcol) { -+ (void)putchar('\t'); -+ chcnt = cnt; -+ } - endcol += colwidth; - } - (void)putchar('\n'); -@@ -217,9 +241,13 @@ - if (f_size) - chcnt += printf("%*qd ", - (int)sizefield, howmany(sp->st_blocks, blocksize)); -+ if (f_color) -+ (void)colortype(sp->st_mode); - chcnt += printf("%s", p->fts_name); - if (f_type) - chcnt += printtype(sp->st_mode); -+ if (f_color) -+ printf("\033[m"); - return (chcnt); - } - -@@ -274,6 +302,95 @@ - return (0); - } - -+void -+printcolor(c) -+ Colors c; -+{ -+ printf("\033["); -+ if (colors[c][0] != -1) { -+ printf("3%d", colors[c][0]); -+ if (colors[c][1] != -1) -+ printf(";"); -+ } -+ if (colors[c][1] != -1) -+ printf("4%d", colors[c][1]); -+ printf("m"); -+} -+ -+colortype(mode) -+ mode_t mode; -+{ -+ switch(mode & S_IFMT) { -+ case S_IFDIR: -+ if (mode & S_IWOTH) -+ if (mode & S_ISTXT) -+ printcolor(C_WSDIR); -+ else -+ printcolor(C_WDIR); -+ else -+ printcolor(C_DIR); -+ return(1); -+ case S_IFLNK: -+ printcolor(C_LNK); -+ return(1); -+ case S_IFSOCK: -+ printcolor(C_SOCK); -+ return(1); -+ case S_IFIFO: -+ printcolor(C_FIFO); -+ return(1); -+ case S_IFBLK: -+ printcolor(C_BLK); -+ return(1); -+ case S_IFCHR: -+ printcolor(C_CHR); -+ return(1); -+ } -+ if (mode & (S_IXUSR | S_IXGRP | S_IXOTH)) { -+ if (mode & S_ISUID) -+ printcolor(C_SUID); -+ else if (mode & S_ISGID) -+ printcolor(C_SGID); -+ else -+ printcolor(C_EXEC); -+ return(1); -+ } -+ return(0); -+} -+ -+void -+parsecolors(cs) -+char *cs; -+{ -+ int i, j, len; -+ char c[2]; -+ if (cs == NULL) cs = ""; /* LSCOLORS not set */ -+ len = strlen(cs); -+ for (i = 0 ; i < C_NUMCOLORS ; i++) { -+ if (len <= 2*i) { -+ c[0] = defcolors[2*i]; -+ c[1] = defcolors[2*i+1]; -+ } -+ else { -+ c[0] = cs[2*i]; -+ c[1] = cs[2*i+1]; -+ } -+ for (j = 0 ; j < 2 ; j++) { -+ if ((c[j] < '0' || c[j] > '7') && -+ tolower(c[j]) != 'x') { -+ fprintf(stderr, -+ "error: invalid character '%c' in LSCOLORS env var\n", -+ c[j]); -+ c[j] = defcolors[2*i+j]; -+ } -+ if (c[j] == 'x') -+ colors[i][j] = -1; -+ else -+ colors[i][j] = c[j]-'0'; -+ } -+ } -+} -+ - static void - printlink(p) - FTSENT *p; ---- ./Makefile.org Wed Mar 8 02:14:10 1995 -+++ ./Makefile Wed Mar 8 02:20:01 1995 -@@ -1,7 +1,9 @@ +--- Makefile.orig Sat Sep 24 04:55:51 1994 ++++ Makefile Thu May 21 15:44:37 1998 +@@ -1,7 +1,10 @@ # @(#)Makefile 8.1 (Berkeley) 6/2/93 - # Makefile,v 1.2 1994/09/24 02:55:51 davidg Exp + # $Id: patch-aa,v 1.3 1998/05/21 14:06:37 frueauf Exp $ -PROG= ls +PROG= colorls SRCS= cmp.c stat_flags.c ls.c print.c util.c +BINDIR= ${PREFIX}/bin +MANDIR= ${PREFIX}/man ++MANINSTALL= catinstall maninstall .include <bsd.prog.mk> ---- ./colorls.1.org Wed Mar 8 02:14:10 1995 -+++ ./colorls.1 Wed Mar 8 02:17:10 1995 -@@ -36,16 +36,24 @@ - .\" ls.1,v 1.3 1994/09/24 02:55:53 davidg Exp - .\" - .Dd July 29, 1994 --.Dt LS 1 -+.Dt COLORLS 1 - .Os - .Sh NAME --.Nm ls --.Nd list directory contents -+.Nm colorls -+.Nd list directory contents in color - .Sh SYNOPSIS --.Nm ls --.Op Fl ACFLRTWacdfiloqrstu1 -+.Nm colorls -+.Op Fl ACFGLRTWacdfiloqrstu1 - .Op Ar file ... - .Sh DESCRIPTION -+(Note: This man page describes the color version of the program. To -+minimize the differences from the original, the program is referred to -+as -+.Nm ls -+in this manual. The new option -+.Fl G -+is for color display.) -+.Pp - For each operand that names a - .Ar file - of a type other than -@@ -87,6 +95,12 @@ - a percent sign (%) after each whiteout, - and a vertical bar (|) after each that is a - .Tn FIFO . -+.It Fl G -+Use ANSI color sequences to distinguish file types. (See -+.Ev LSCOLORS -+below.) In addition to those mentioned above in -+.Fl F , -+some extra attributes (setuid bit set, etc.) are also displayed. - .It Fl L - If argument is a symbolic link, list the file or directory the link references - rather than the link itself. -@@ -314,6 +328,74 @@ - See - .Xr environ 7 - for more information. -+.It LSCOLORS -+The value of this variable describes what color to use for which -+attribute when the color output -+.Pq Fl G -+is specified. This string is a concatenation of pairs of the format -+.Sy fb , -+where -+.Sy f -+is the foreground color and -+.Sy b -+is the background color. -+.Pp -+The color designators are as follows: -+.Pp -+.Bl -tag -width 4n -offset indent -compact -+.It Sy 0 -+black -+.It Sy 1 -+red -+.It Sy 2 -+green -+.It Sy 3 -+yellow -+.It Sy 4 -+blue -+.It Sy 5 -+magenta -+.It Sy 6 -+cyan -+.It Sy 7 -+white -+.It Sy x -+default foreground or background -+.El -+.Pp -+(Note: the above are standard ANSI colors. The actual display may -+differ depending on the color capabilities of your terminal.) -+.Pp -+The order of the attributes are as follows: -+.Pp -+.Bl -enum -offset indent -compact -+.It -+directory -+.It -+symbolic link -+.It -+socket -+.It -+pipe -+.It -+executable -+.It -+block special -+.It -+character special -+.It -+executable with setuid bit set -+.It -+executable with setgid bit set -+.It -+directory writable to others, with sticky bit -+.It -+directory writable to others, without sticky bit -+.El -+.Pp -+The default is "4x5x2x3x1x464301060203", i.e., blue foreground and -+default background for regular directories, black foreground and red -+background for setuid executables, etc. - .El - .Sh COMPATIBILITY - The group field is now automatically included in the long listing for diff --git a/misc/colorls/patches/patch-ab b/misc/colorls/patches/patch-ab index 058bc7b15f0..cc5197bd55e 100644 --- a/misc/colorls/patches/patch-ab +++ b/misc/colorls/patches/patch-ab @@ -1,21 +1,120 @@ ---- ls.c.orig Tue May 5 01:15:09 1998 -+++ ls.c Tue May 5 01:16:24 1998 -@@ -59,6 +59,8 @@ - #include <string.h> - #include <unistd.h> - #include <locale.h> -+#include <pwd.h> -+#include <grp.h> - - #include "ls.h" - #include "extern.h" -@@ -170,7 +172,8 @@ - f_type = 1; - break; - case 'G': -- f_color = 1; -+ if (isatty(STDOUT_FILENO)) -+ f_color = 1; - break; - case 'L': - fts_options &= ~FTS_PHYSICAL; +--- colorls.1.orig Thu May 21 15:42:07 1998 ++++ colorls.1 Thu May 21 15:42:09 1998 +@@ -36,16 +36,24 @@ + .\" $Id: patch-ab,v 1.3 1998/05/21 14:06:37 frueauf Exp $ + .\" + .Dd July 29, 1994 +-.Dt LS 1 ++.Dt COLORLS 1 + .Os + .Sh NAME +-.Nm ls +-.Nd list directory contents ++.Nm colorls ++.Nd list directory contents in color + .Sh SYNOPSIS +-.Nm ls +-.Op Fl ACFLRTWacdfiloqrstu1 ++.Nm colorls ++.Op Fl ACFGLRTWacdfiloqrstu1 + .Op Ar file ... + .Sh DESCRIPTION ++(Note: This man page describes the color version of the program. To ++minimize the differences from the original, the program is referred to ++as ++.Nm ls ++in this manual. The new option ++.Fl G ++is for color display.) ++.Pp + For each operand that names a + .Ar file + of a type other than +@@ -87,6 +95,12 @@ + a percent sign (%) after each whiteout, + and a vertical bar (|) after each that is a + .Tn FIFO . ++.It Fl G ++Use ANSI color sequences to distinguish file types. (See ++.Ev LSCOLORS ++below.) In addition to those mentioned above in ++.Fl F , ++some extra attributes (setuid bit set, etc.) are also displayed. + .It Fl L + If argument is a symbolic link, list the file or directory the link references + rather than the link itself. +@@ -318,6 +332,74 @@ + See + .Xr environ 7 + for more information. ++.It LSCOLORS ++The value of this variable describes what color to use for which ++attribute when the color output ++.Pq Fl G ++is specified. This string is a concatenation of pairs of the format ++.Sy fb , ++where ++.Sy f ++is the foreground color and ++.Sy b ++is the background color. ++.Pp ++The color designators are as follows: ++.Pp ++.Bl -tag -width 4n -offset indent -compact ++.It Sy 0 ++black ++.It Sy 1 ++red ++.It Sy 2 ++green ++.It Sy 3 ++yellow ++.It Sy 4 ++blue ++.It Sy 5 ++magenta ++.It Sy 6 ++cyan ++.It Sy 7 ++white ++.It Sy x ++default foreground or background ++.El ++.Pp ++(Note: the above are standard ANSI colors. The actual display may ++differ depending on the color capabilities of your terminal.) ++.Pp ++The order of the attributes are as follows: ++.Pp ++.Bl -enum -offset indent -compact ++.It ++directory ++.It ++symbolic link ++.It ++socket ++.It ++pipe ++.It ++executable ++.It ++block special ++.It ++character special ++.It ++executable with setuid bit set ++.It ++executable with setgid bit set ++.It ++directory writable to others, with sticky bit ++.It ++directory writable to others, without sticky bit ++.El ++.Pp ++The default is "4x5x2x3x1x464301060203", i.e., blue foreground and ++default background for regular directories, black foreground and red ++background for setuid executables, etc. + .El + .Sh COMPATIBILITY + The group field is now automatically included in the long listing for diff --git a/misc/colorls/patches/patch-ac b/misc/colorls/patches/patch-ac new file mode 100644 index 00000000000..af72db9a8f2 --- /dev/null +++ b/misc/colorls/patches/patch-ac @@ -0,0 +1,66 @@ +--- ls.c-orig Thu May 21 15:41:32 1998 ++++ ls.c Thu May 21 15:42:09 1998 +@@ -59,6 +59,8 @@ + #include <string.h> + #include <unistd.h> + #include <locale.h> ++#include <pwd.h> ++#include <grp.h> + + #include "ls.h" + #include "extern.h" +@@ -94,6 +96,7 @@ + int f_dirname; /* if precede with directory name */ + int f_timesort; /* sort by time vice name */ + int f_type; /* add type character for non-regular files */ ++int f_color; /* add type in color for non-regular files */ + #ifndef BSD4_4_LITE + int f_whiteout; /* show whiteout entries */ + #endif +@@ -135,9 +138,9 @@ + + fts_options = FTS_PHYSICAL; + #ifdef BSD4_4_LITE +- while ((ch = getopt(argc, argv, "1ACFLRTacdfgikloqrstu")) != EOF) { ++ while ((ch = getopt(argc, argv, "1ACFGLRTacdfgikloqrstu")) != EOF) { + #else +- while ((ch = getopt(argc, argv, "1ACFLRTWacdfgikloqrstu")) != EOF) { ++ while ((ch = getopt(argc, argv, "1ACFGLRTWacdfgikloqrstu")) != EOF) { + #endif + switch (ch) { + /* +@@ -168,6 +171,10 @@ + case 'F': + f_type = 1; + break; ++ case 'G': ++ if (isatty(STDOUT_FILENO)) ++ f_color = 1; ++ break; + case 'L': + fts_options &= ~FTS_PHYSICAL; + fts_options |= FTS_LOGICAL; +@@ -228,18 +235,21 @@ + argc -= optind; + argv += optind; + ++ parsecolors(getenv("LSCOLORS")); ++ + /* + * If not -F, -i, -l, -s or -t options, don't require stat + * information. + */ +- if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type) ++ if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type ++ && !f_color) + fts_options |= FTS_NOSTAT; + + /* + * If not -F, -d or -l options, follow any symbolic links listed on + * the command line. + */ +- if (!f_longform && !f_listdir && !f_type) ++ if (!f_longform && !f_listdir && !f_type && !f_color) + fts_options |= FTS_COMFOLLOW; + + #ifndef BSD4_4_LITE diff --git a/misc/colorls/patches/patch-ad b/misc/colorls/patches/patch-ad new file mode 100644 index 00000000000..4e9c1de4964 --- /dev/null +++ b/misc/colorls/patches/patch-ad @@ -0,0 +1,10 @@ +--- ls.h.orig Sun Dec 22 00:40:58 1996 ++++ ls.h Thu May 21 15:42:08 1998 +@@ -54,6 +54,7 @@ + extern int f_size; /* list size in short listing */ + extern int f_statustime; /* use time of last mode change */ + extern int f_type; /* add type character for non-regular files */ ++extern int f_color; /* add type in color for non-regular files */ + + typedef struct { + FTSENT *list; diff --git a/misc/colorls/patches/patch-ae b/misc/colorls/patches/patch-ae new file mode 100644 index 00000000000..08cc8a6bd2c --- /dev/null +++ b/misc/colorls/patches/patch-ae @@ -0,0 +1,182 @@ +--- print.c.orig Sun Dec 22 00:40:58 1996 ++++ print.c Thu May 21 15:42:08 1998 +@@ -64,6 +64,26 @@ + + #define IS_NOPRINT(p) ((p)->fts_number == NO_PRINT) + ++/* Most of these are taken from <sys/stat.h> */ ++typedef enum Colors { ++ C_DIR, /* directory */ ++ C_LNK, /* symbolic link */ ++ C_SOCK, /* socket */ ++ C_FIFO, /* pipe */ ++ C_EXEC, /* executable */ ++ C_BLK, /* block special */ ++ C_CHR, /* character special */ ++ C_SUID, /* setuid executable */ ++ C_SGID, /* setgid executable */ ++ C_WSDIR, /* directory writeble to others, with sticky bit */ ++ C_WDIR, /* directory writeble to others, without sticky bit */ ++ C_NUMCOLORS /* just a place-holder */ ++} Colors ; ++ ++char *defcolors = "4x5x2x3x1x464301060203"; ++ ++static int colors[C_NUMCOLORS][2]; ++ + void + printscol(dp) + DISPLAY *dp; +@@ -124,10 +144,14 @@ + printtime(sp->st_ctime); + else + printtime(sp->st_mtime); ++ if (f_color) ++ (void)colortype(sp->st_mode); + (void)printf("%s", p->fts_name); + if (f_type) + (void)printtype(sp->st_mode); +- if (S_ISLNK(sp->st_mode)) ++ if (f_color) ++ (void)printf("\033[m"); ++ if (S_ISLNK(sp->st_mode)) + printlink(p); + (void)putchar('\n'); + } +@@ -190,10 +214,22 @@ + dp->s_block); + if ((base += numrows) >= num) + break; +- while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) <= endcol){ +- (void)putchar('\t'); +- chcnt = cnt; +- } ++ ++ /* ++ * some terminals get confused if we mix tabs ++ * with color sequences ++ */ ++ if (f_color) ++ while ((cnt = (chcnt + 1)) <= endcol) { ++ (void)putchar(' '); ++ chcnt = cnt; ++ } ++ else ++ while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) ++ <= endcol) { ++ (void)putchar('\t'); ++ chcnt = cnt; ++ } + endcol += colwidth; + } + (void)putchar('\n'); +@@ -219,9 +255,13 @@ + if (f_size) + chcnt += printf("%*qd ", + (int)sizefield, howmany(sp->st_blocks, blocksize)); ++ if (f_color) ++ (void)colortype(sp->st_mode); + chcnt += printf("%s", p->fts_name); + if (f_type) + chcnt += printtype(sp->st_mode); ++ if (f_color) ++ printf("\033[m"); + return (chcnt); + } + +@@ -281,6 +321,95 @@ + return (0); + } + ++void ++printcolor(c) ++ Colors c; ++{ ++ printf("\033["); ++ if (colors[c][0] != -1) { ++ printf("3%d", colors[c][0]); ++ if (colors[c][1] != -1) ++ printf(";"); ++ } ++ if (colors[c][1] != -1) ++ printf("4%d", colors[c][1]); ++ printf("m"); ++} ++ ++colortype(mode) ++ mode_t mode; ++{ ++ switch(mode & S_IFMT) { ++ case S_IFDIR: ++ if (mode & S_IWOTH) ++ if (mode & S_ISTXT) ++ printcolor(C_WSDIR); ++ else ++ printcolor(C_WDIR); ++ else ++ printcolor(C_DIR); ++ return(1); ++ case S_IFLNK: ++ printcolor(C_LNK); ++ return(1); ++ case S_IFSOCK: ++ printcolor(C_SOCK); ++ return(1); ++ case S_IFIFO: ++ printcolor(C_FIFO); ++ return(1); ++ case S_IFBLK: ++ printcolor(C_BLK); ++ return(1); ++ case S_IFCHR: ++ printcolor(C_CHR); ++ return(1); ++ } ++ if (mode & (S_IXUSR | S_IXGRP | S_IXOTH)) { ++ if (mode & S_ISUID) ++ printcolor(C_SUID); ++ else if (mode & S_ISGID) ++ printcolor(C_SGID); ++ else ++ printcolor(C_EXEC); ++ return(1); ++ } ++ return(0); ++} ++ ++void ++parsecolors(cs) ++char *cs; ++{ ++ int i, j, len; ++ char c[2]; ++ if (cs == NULL) cs = ""; /* LSCOLORS not set */ ++ len = strlen(cs); ++ for (i = 0 ; i < C_NUMCOLORS ; i++) { ++ if (len <= 2*i) { ++ c[0] = defcolors[2*i]; ++ c[1] = defcolors[2*i+1]; ++ } ++ else { ++ c[0] = cs[2*i]; ++ c[1] = cs[2*i+1]; ++ } ++ for (j = 0 ; j < 2 ; j++) { ++ if ((c[j] < '0' || c[j] > '7') && ++ tolower(c[j]) != 'x') { ++ fprintf(stderr, ++ "error: invalid character '%c' in LSCOLORS env var\n", ++ c[j]); ++ c[j] = defcolors[2*i+j]; ++ } ++ if (c[j] == 'x') ++ colors[i][j] = -1; ++ else ++ colors[i][j] = c[j]-'0'; ++ } ++ } ++} ++ + static void + printlink(p) + FTSENT *p; |