* Color/8-bit/unified patch to GNU ls 3.8.3
@ 1993-10-12 23:12 H. Peter Anvin
0 siblings, 0 replies; only message in thread
From: H. Peter Anvin @ 1993-10-12 23:12 UTC (permalink / raw)
Here is yet another version of mine and Dennis' color-ls patch. This
one is for GNU fileutils-3.8.3.tar.gz as available on
alpha.gnu.mit.edu in /gnu.
This patch also contains, apart from colorization:
1. A -e option as a synonym to --full-name after -f was changed;
2. ls, dir and vdir are unified into one binary;
3. 8 bit ISO-8859 support.
To unpack:
Get fileutils-3.8.3.tar.gz
Save this message to color-ls-3.8.3.patch
zcat fileutils-3.8.3.tar.gz | tar xvvf -
patch -p0 < color-ls-3.8.3.patch
diff --recursive -c orig/fileutils-3.8.3/man/ls.1 fileutils-3.8.3/man/ls.1
*** orig/fileutils-3.8.3/man/ls.1 Fri May 21 17:28:58 1993
--- fileutils-3.8.3/man/ls.1 Tue Oct 12 17:18:28 1993
***************
*** 3,17 ****
ls, dir, vdir \- list contents of directories
.SH SYNOPSIS
.B ls
! [\-abcdfgiklmnpqrstuxABCFGLNQRSUX1] [\-w cols] [\-T cols] [\-I pattern]
! [\-\-all] [\-\-escape] [\-\-directory] [\-\-inode] [\-\-kilobytes]
! [\-\-numeric-uid-gid] [--no-group] [\-\-hide-control-chars] [\-\-reverse]
[\-\-size] [\-\-width=cols] [\-\-tabsize=cols] [\-\-almost-all]
! [\-\-ignore-backups] [\-\-classify] [\-\-file-type] [\-\-full-time]
! [\-\-ignore=pattern] [\-\-dereference] [\-\-literal] [\-\-quote-name]
! [\-\-recursive] [\-\-sort={none,time,size,extension}]
[\-\-format={long,verbose,commas,across,vertical,single-column}]
! [\-\-time={atime,access,use,ctime,status}] [\-\-help] [\-\-version] [path...]
.SH DESCRIPTION
This manual page
documents the GNU version of
--- 3,20 ----
ls, dir, vdir \- list contents of directories
.SH SYNOPSIS
.B ls
! [\-abcdefgiklmnopqrstuxABCFGLNQRSUX178] [\-w\ cols] [\-T\ cols] [\-I\ pattern]
! [\-\-directory] [\-\-all] [\-\-escape] [\-\-inode] [\-\-kilobytes]
! [\-\-no-group] [\-\-numeric-uid-gid] [\-\-hide-control-chars] [\-\-reverse]
[\-\-size] [\-\-width=cols] [\-\-tabsize=cols] [\-\-almost-all]
! [\-\-ignore-backups] [\-\-classify] [\-\-ignore=pattern]
! [\-\-full-time] [\-\-literal] [\-\-dereference] [\-\-quote-name]
! [\-\-file-type] [\-\-recursive] [\-\-sort={none,time,size,extension}]
[\-\-format={long,verbose,commas,across,vertical,single-column}]
! [\-\-time={atime,access,use,ctime,status}]
! [\-\-color] [\-\-colour] [\-\-7bit] [\-\-8bit]
! [\-\-help] [\-\-version]
! [path...]
.SH DESCRIPTION
This manual page
documents the GNU version of
***************
*** 49,54 ****
--- 52,61 ----
.I "\-d, \-\-directory"
List directories like other files, rather than listing their contents.
.TP
+ .I "\-e, \-\-full-time"
+ List times in full, rather than using the standard abbreviation
+ heuristics.
+ .TP
.I "\-f"
Do not sort directory contents; list them in whatever order they are
stored on the disk.
***************
*** 62,71 ****
and
.I \-t.
.TP
- .I "\-\-full-time"
- List times in full, rather than using the standard abbreviation
- heuristics.
- .TP
.I \-g
Ignored; for Unix compatibility.
.TP
--- 69,74 ----
***************
*** 74,80 ****
.TP
.I "\-k, \-\-kilobytes"
If file sizes are being listed, print them in kilobytes. This
! overrides the environment variable POSIXLY_CORRECT.
.TP
.I "\-l, \-\-format=long, \-\-format=verbose"
In addition to the name of each file, print the file type,
--- 77,84 ----
.TP
.I "\-k, \-\-kilobytes"
If file sizes are being listed, print them in kilobytes. This
! overrides the environment variable
! .BR POSIXLY_CORRECT .
.TP
.I "\-l, \-\-format=long, \-\-format=verbose"
In addition to the name of each file, print the file type,
***************
*** 91,96 ****
--- 95,104 ----
.I "\-n, \-\-numeric-uid-gid"
List the numeric UID and GID instead of the names.
.TP
+ .I "\-o, \-\-color, \-\-colour"
+ Colorize the names of files using ISO 6429 (ANSI) color control
+ sequences, depending on the type of file. See `COLOR PRINTING' below.
+ .TP
.I \-p
Append a character to each file name indicating the file type.
.TP
***************
*** 102,108 ****
.TP
.I "\-s, \-\-size"
Print the size of each file in 1K blocks to the left of the file name.
! If the environment variable POSIXLY_CORRECT is set, 512-byte blocks
are used instead.
.TP
.I "\-t, \-\-sort=time"
--- 110,118 ----
.TP
.I "\-s, \-\-size"
Print the size of each file in 1K blocks to the left of the file name.
! If the environment variable
! .B POSIXLY_CORRECT
! is set, 512-byte blocks
are used instead.
.TP
.I "\-t, \-\-sort=time"
***************
*** 179,184 ****
--- 189,203 ----
.I "\-1, \-\-format=single-column"
List one file per line.
.TP
+ .I "\-7, \-\-7bit"
+ Treat all character outside the ASCII (ISO 646) set (0x20-0x7E) as
+ nonprintable control characters.
+ .TP
+ .I "\-8, \-\-8bit"
+ Treat all characters from the 8-bit ISO 8859 character sets
+ (0x20-0x7E, 0xA1-0xFF) as printable. This includes ASCII as a subset.
+ This is the default unless overridden at compile time.
+ .TP
.I "\-w, \-\-width cols"
Assume the screen is
.I cols
***************
*** 204,209 ****
--- 223,278 ----
.TP
.I "\-\-version"
Print version information on standard error then exit.
+ .SS COLOR PRINTING
+ When using the
+ .I \-o
+ option, this version of
+ .B ls
+ will colorize the file names printed according to the type of file.
+ .PP
+ You can override the default colors by defining the environment
+ variable
+ .B LS_COLORS
+ (or
+ .BR LS_COLOURS );
+ this should be a comma-separated
+ list of codes that will be inserted into a color escape sequence (type
+ `m'). The sequences are, in order: plaintext, normal file, directory,
+ symbolic link, FIFO, socket, block device, character device, and
+ executable file. The first sequence (plaintext) is the one applied to
+ the end of each file name in order to restore normal text output.
+ This is usually, but not always, a zero (0).
+ .PP
+ A single color sequence is composed of numerical commands separated by
+ semicolons. The most common commands are:
+ .nf
+ 0 to restore default color
+ 1 for brighter colors
+ 4 for underlined text
+ 5 for flashing text
+ 30 for black foreground
+ 31 for red foreground
+ 32 for green foreground
+ 33 for yellow (or brown) foreground
+ 34 for blue foreground
+ 35 for purple foreground
+ 36 for cyan foreground
+ 37 for white (or gray) foreground
+ 40 for black background
+ 41 for red background
+ 42 for green background
+ 43 for yellow (or brown) background
+ 44 for blue background
+ 45 for purple background
+ 46 for cyan background
+ 47 for white (or gray) background
+ .fi
+ .PP
+ Not all commands work on all systems or display devices.
+ .PP
+ The default value for
+ .B LS_COLORS
+ is `0,0,32,36,31,33,44;37,44;37,35'.
.SH BUGS
On BSD systems, the
.I \-s
***************
*** 214,216 ****
--- 283,294 ----
HP-UX
.B ls
program.
+ .PP
+ Colorization and character set selection should be more system independent.
+ Using the
+ .I -o
+ option disables the use of the tab character for
+ column spacing unless the
+ .I \-T
+ option is used; apparently some systems do not like tabs and color
+ codes in conjunction.
diff --recursive -c orig/fileutils-3.8.3/src/Makefile.in fileutils-3.8.3/src/Makefile.in
*** orig/fileutils-3.8.3/src/Makefile.in Thu Aug 26 22:55:47 1993
--- fileutils-3.8.3/src/Makefile.in Tue Oct 12 17:13:42 1993
***************
*** 39,45 ****
DISTFILES = Makefile.in cp.h ls.h version.h $(SOURCES)
! PROGS = chgrp chown chmod cp dd du ginstall ln dir vdir ls mkdir \
mkfifo mknod mv rm rmdir touch @PROGS@
all: $(PROGS) $(LIBPROGS)
--- 39,45 ----
DISTFILES = Makefile.in cp.h ls.h version.h $(SOURCES)
! PROGS = chgrp chown chmod cp dd du ginstall ln ls mkdir \
mkfifo mknod mv rm rmdir touch @PROGS@
all: $(PROGS) $(LIBPROGS)
***************
*** 53,59 ****
--- 53,61 ----
./ginstall -o root -m 4755 $(LIBPROGS) $(libdir); fi
for f in $(PROGS); do ./ginstall $$f $(bindir)/$(binprefix)$$f; done
cd $(bindir); \
+ ./$(binprefix)ln -f $(binprefix)ls dir; \
./$(binprefix)ln -f $(binprefix)dir d; \
+ ./$(binprefix)ln -f $(binprefix)ls vdir; \
./$(binprefix)ln -f $(binprefix)vdir v; \
./$(binprefix)mv -f $(binprefix)ginstall $(binprefix)install
***************
*** 105,113 ****
df: df.o
$(CC) $(LDFLAGS) -o $@ df.o ../lib/libfu.a version.o $(LIBS)
! dir: ls.o ls-dir.o
! $(CC) $(LDFLAGS) -o $@ ls.o ls-dir.o ../lib/libfu.a version.o $(LIBS)
du: du.o
$(CC) $(LDFLAGS) -o $@ du.o ../lib/libfu.a version.o $(LIBS)
--- 107,118 ----
df: df.o
$(CC) $(LDFLAGS) -o $@ df.o ../lib/libfu.a version.o $(LIBS)
! #dir: ls.o ls-dir.o
! # $(CC) $(LDFLAGS) -o $@ ls.o ls-dir.o ../lib/libfu.a version.o $(LIBS)
+ dir: ls ln
+ ./ln -f ls dir
+
du: du.o
$(CC) $(LDFLAGS) -o $@ du.o ../lib/libfu.a version.o $(LIBS)
***************
*** 144,151 ****
touch: touch.o
$(CC) $(LDFLAGS) -o $@ touch.o ../lib/libfu.a version.o $(LIBS)
! vdir: ls.o ls-vdir.o
! $(CC) $(LDFLAGS) -o $@ ls.o ls-vdir.o ../lib/libfu.a version.o $(LIBS)
# Tell versions [3.59,3.63) of GNU make not to export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
--- 149,159 ----
touch: touch.o
$(CC) $(LDFLAGS) -o $@ touch.o ../lib/libfu.a version.o $(LIBS)
! #vdir: ls.o ls-vdir.o
! # $(CC) $(LDFLAGS) -o $@ ls.o ls-vdir.o ../lib/libfu.a version.o $(LIBS)
!
! vdir: ls ln
! ./ln ls vdir
# Tell versions [3.59,3.63) of GNU make not to export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
diff --recursive -c orig/fileutils-3.8.3/src/ls.c fileutils-3.8.3/src/ls.c
*** orig/fileutils-3.8.3/src/ls.c Thu Aug 26 21:46:55 1993
--- fileutils-3.8.3/src/ls.c Tue Oct 12 17:08:03 1993
***************
*** 32,37 ****
--- 32,81 ----
/* Written by Richard Stallman and David MacKenzie. */
+ /* Colour and 8-bit support by Dennis Flaherty <dflahert@chekov.helios.nd.edu>
+ and Peter Anvin <hpa@nwu.edu> based on original patches by Greg Lee
+ <lee@uhunix.uhcc.hawaii.edu>.
+
+ Comments about desirable extensions to the colour support greatly
+ appreciated. We are trying to settle on something we can send to the
+ FSF before fileutils-3.9.
+
+ HISTORY:
+
+ Mar 1992: Greg Lee <lee@uhunix.uhcc.hawaii.edu>
+ Original color-ls patch. Displayed the ansi color escape
+ sequences unless '-f' option was used, or if long format was
+ specified. Posted to comp.os.linux.
+ Apr 1992: Dennis Flaherty <dflahert@chekov.helios.nd.edu>
+ Expanded color-ls patch to display color anytime a filename was
+ displayed, including long format and targets of links in long
+ format. Changed color scheme, added colors for block and
+ character devices. Posted to c.o.l. and sent to H.J. Lu.
+ Dec 1992: Peter Anvin <hpa@nwu.edu>
+ Implemented flexible macros that could be #defined to set color
+ scheme, used Flaherty's color scheme as default. Macro for
+ setting default behavior of color display, '-f' toggles. Added
+ option for 8-bit ISO filenames. Added long-name options.
+ May 1993: Dennis Flaherty <dflahert@chekov.helios.nd.edu>
+ Incorporated Anvin's and Flaherty's changes into new
+ fileutils-3.5. Fixed "target of link in long format" coloring
+ again. Due to conflict with new '-f' or '--full-time' option,
+ color-ls option changed to '-o'. Always defaults to no color,
+ always supports 8-bit ISO filenames. Added LS_COLOR environment
+ variable to customize colour settings.
+ May 1993: Peter Anvin <hpa@nwu.edu>
+ Restored command line option '-7' or '-8' to select 7-bit or
+ 8-bit mode. Added compile-time option to make 7 bits the
+ default. Made the format of LS_COLOR more general. Added
+ '-e' short option for '--full-time' since GNU decided to go
+ with UNIX compatibility for the '-f' option. Updated man pages.
+ Jun 1993: Peter Anvin <hpa@nwu.edu>
+ Patch against new fileutils-3.8. Posted to comp.os.linux.announce.
+ Oct 1993: Peter Anvin <hpa@nwu.edu>
+ Patch against fileutils-3.8.3. Merged `ls', `dir' and `vdir' into
+ one binary while I was at it.
+ */
+
#ifdef _AIX
#pragma alloca
#endif
***************
*** 108,113 ****
--- 152,158 ----
static void print_many_per_line ();
static void print_name_with_quoting ();
static void print_type_indicator ();
+ static void print_color_indicator ();
static void print_with_commas ();
static void queue_directory ();
static void sort_files ();
***************
*** 216,222 ****
static enum time_type time_type;
! /* print the full time, otherwise the standard unix heuristics. */
int full_time;
--- 261,267 ----
static enum time_type time_type;
! /* print the full time, otherwise the standard unix heuristics. -e */
int full_time;
***************
*** 274,279 ****
--- 319,350 ----
static enum indicator_style indicator_style;
+ /* Nonzero means use colors for types if we are using the -o option. An
+ empty string "" means ignore this category. */
+
+ int print_with_color;
+
+ #define COLORWRAPPER "\33[%sm" /* How to print in color */
+ #define MAXCOLORLEN 16 /* Max # of characters in a color sequence */
+
+ enum { C_NORMAL, C_FILE, C_DIR, C_LINK, C_FIFO, C_SOCK,
+ C_BLK, C_CHR, C_EXEC };
+
+ #define LASTCOLOR C_EXEC
+
+ char indicator_color[][MAXCOLORLEN] =
+ { /* default, default, green, cyan, red, yellow, white-on-blue,
+ white-on-blue, purple */
+ "0", "0", "32", "36", "31", "33", "44;37", "44;37", "35" };
+
+ /* Nonzero means print using ISO 8859 characters. The default is specified
+ here as well. -8 enables, -7 disables. */
+
+ int print_iso8859;
+ #ifndef DEFAULT_ISO8859
+ #define DEFAULT_ISO8859 1
+ #endif
+
/* Nonzero means mention the inode number of each file. -i */
static int print_inode;
***************
*** 369,375 ****
{"all", no_argument, 0, 'a'},
{"escape", no_argument, 0, 'b'},
{"directory", no_argument, 0, 'd'},
! {"full-time", no_argument, &full_time, 1},
{"inode", no_argument, 0, 'i'},
{"kilobytes", no_argument, 0, 'k'},
{"numeric-uid-gid", no_argument, 0, 'n'},
--- 440,446 ----
{"all", no_argument, 0, 'a'},
{"escape", no_argument, 0, 'b'},
{"directory", no_argument, 0, 'd'},
! {"full-time", no_argument, 0, 'e'},
{"inode", no_argument, 0, 'i'},
{"kilobytes", no_argument, 0, 'k'},
{"numeric-uid-gid", no_argument, 0, 'n'},
***************
*** 393,398 ****
--- 464,473 ----
{"time", required_argument, 0, 11},
{"help", no_argument, &show_help, 1},
{"version", no_argument, &show_version, 1},
+ {"color", no_argument, 0, 'o'},
+ {"colour", no_argument, 0, 'o'},
+ {"7bit", no_argument, 0, '7'},
+ {"8bit", no_argument, 0, '8'},
{0, 0, 0, 0}
};
***************
*** 458,464 ****
format_needs_stat = sort_type == sort_time || sort_type == sort_size
|| format == long_format
|| trace_links || trace_dirs || indicator_style != none
! || print_block_size || print_inode;
nfiles = 100;
files = (struct file *) xmalloc (sizeof (struct file) * nfiles);
--- 533,539 ----
format_needs_stat = sort_type == sort_time || sort_type == sort_size
|| format == long_format
|| trace_links || trace_dirs || indicator_style != none
! || print_block_size || print_inode || print_with_color;
nfiles = 100;
files = (struct file *) xmalloc (sizeof (struct file) * nfiles);
***************
*** 527,532 ****
--- 602,659 ----
/* initialize all switches to default settings */
+ /* program_name is advertised as being the program name without
+ any leading path, but that doesn't seem to be the case. Get the
+ first character of the actual program name. */
+
+ #if defined(STDC_HEADERS) || defined(HAVE_STRING_H)
+ p = strrchr(program_name,'/');
+ #else
+ {
+ /* Lame version of strrchr() for lame systems */
+
+ register char *q;
+
+ p = NULL;
+ for ( q = program_name ; *q ; q++ )
+ {
+ if ( *q == '/' )
+ p = q;
+ }
+ }
+ #endif
+
+ if ( p )
+ p++; /* Get character after last / */
+ else
+ p = program_name; /* Get first character */
+
+ switch(*p)
+ {
+ case 'D':
+ case 'd':
+ /* This is for the 'dir' program. */
+ ls_mode = LS_MULTI_COL;
+ break;
+
+ case 'V':
+ case 'v':
+ /* This is for the 'vdir' program. */
+ ls_mode = LS_LONG_FORMAT;
+ break;
+
+ case 'L':
+ case 'l':
+ /* This is for the `ls' program. */
+ ls_mode = LS_LS;
+ break;
+
+ default:
+ /* Use default, depending on whenether linked with ls-ls.o,
+ ls-dir.o or ls-vdir.o */
+ break;
+ }
+
switch (ls_mode)
{
case LS_MULTI_COL:
***************
*** 575,580 ****
--- 702,709 ----
really_all_files = 0;
ignore_patterns = 0;
quote_as_string = 0;
+ print_with_color = 0;
+ print_iso8859 = DEFAULT_ISO8859;
p = getenv ("COLUMNS");
line_length = p ? atoi (p) : 80;
***************
*** 591,597 ****
p = getenv ("TABSIZE");
tabsize = p ? atoi (p) : 8;
! while ((c = getopt_long (argc, argv, "abcdfgiklmnpqrstuw:xABCFGI:LNQRST:UX1",
long_options, (int *) 0)) != EOF)
{
switch (c)
--- 720,729 ----
p = getenv ("TABSIZE");
tabsize = p ? atoi (p) : 8;
! if ( tabsize == 0 )
! tabsize = line_length; /* Never use tabs if tabsize == 0 */
!
! while ((c = getopt_long (argc, argv, "abcdefgiklmnopqrstuw:xABCFGI:LNQRST:UX178",
long_options, (int *) 0)) != EOF)
{
switch (c)
***************
*** 617,622 ****
--- 749,758 ----
immediate_dirs = 1;
break;
+ case 'e':
+ full_time = 1;
+ break;
+
case 'f':
/* Same as enabling -a -U and disabling -l -s. */
all_files = 1;
***************
*** 652,657 ****
--- 788,803 ----
numeric_users = 1;
break;
+ case 'o':
+ {
+ print_with_color = 1;
+ tabsize = line_length; /* Some systems don't seem to like
+ combining tabs and color codes. Don't
+ use unless explicitly given on command
+ line. */
+ }
+ break;
+
case 'p':
indicator_style = not_programs;
break;
***************
*** 753,758 ****
--- 899,912 ----
format = one_per_line;
break;
+ case '7':
+ print_iso8859 = 0;
+ break;
+
+ case '8':
+ print_iso8859 = 1;
+ break;
+
case 10: /* +sort */
i = argmatch (optarg, sort_args);
if (i < 0)
***************
*** 788,793 ****
--- 942,971 ----
}
}
+ if ( print_with_color )
+ {
+ if ( (p = getenv("LS_COLORS")) || (p = getenv("LS_COLOURS")) )
+ {
+ register char *q;
+
+ q = xmalloc(strlen(p)+1); /* Can't modify a getenv() string */
+ strcpy(q,p);
+
+ p = strtok(q, ",");
+
+ for ( i = C_NORMAL ; i <= LASTCOLOR && p ; i++ )
+ {
+ if ( strlen(p) < MAXCOLORLEN )
+ strcpy(indicator_color[i],p);
+
+ p = strtok(NULL, ",");
+ }
+
+
+ free(q);
+ }
+ }
+
return optind;
}
\f
***************
*** 1003,1009 ****
they won't be traced and when no indicator is needed. */
if (linkpath
&& ((explicit_arg && format != long_format)
! || indicator_style != none)
&& stat (linkpath, &linkstats) == 0)
{
/* Symbolic links to directories that are mentioned on the
--- 1181,1187 ----
they won't be traced and when no indicator is needed. */
if (linkpath
&& ((explicit_arg && format != long_format)
! || indicator_style != none || print_with_color)
&& stat (linkpath, &linkstats) == 0)
{
/* Symbolic links to directories that are mentioned on the
***************
*** 1471,1477 ****
--- 1649,1659 ----
printf ("%s ", full_time ? timebuf : timebuf + 4);
+ if (print_with_color)
+ print_color_indicator (f->stat.st_mode);
print_name_with_quoting (f->name);
+ if (print_with_color)
+ printf (COLORWRAPPER, indicator_color[C_NORMAL]);
if (f->filetype == symbolic_link)
{
***************
*** 1478,1484 ****
--- 1660,1670 ----
if (f->linkname)
{
fputs (" -> ", stdout);
+ if (print_with_color)
+ print_color_indicator (f->linkmode);
print_name_with_quoting (f->linkname);
+ if (print_with_color)
+ printf (COLORWRAPPER, indicator_color[C_NORMAL]);
if (indicator_style != none)
print_type_indicator (f->linkmode);
}
***************
*** 1535,1541 ****
break;
default:
! if (c > 040 && c < 0177)
putchar (c);
else
printf ("\\%03o", (unsigned int) c);
--- 1721,1728 ----
break;
default:
! if ( (c >= 0x20 && c <= 0x7E) ||
! (print_iso8859 && c >= 0xA1 && c <= 0xFF) )
putchar (c);
else
printf ("\\%03o", (unsigned int) c);
***************
*** 1543,1549 ****
}
else
{
! if (c >= 040 && c < 0177)
putchar (c);
else if (!qmark_funny_chars)
putchar (c);
--- 1730,1737 ----
}
else
{
! if ( (c >= 0x20 && c <= 0x7E) ||
! (print_iso8859 && c >= 0xA1 && c <= 0xFF) )
putchar (c);
else if (!qmark_funny_chars)
putchar (c);
***************
*** 1572,1578 ****
--- 1760,1770 ----
(unsigned) convert_blocks (ST_NBLOCKS (f->stat),
kilobyte_blocks));
+ if (print_with_color)
+ print_color_indicator (f->stat.st_mode);
print_name_with_quoting (f->name);
+ if (print_with_color)
+ printf (COLORWRAPPER, indicator_color[C_NORMAL]);
if (indicator_style != none)
print_type_indicator (f->stat.st_mode);
***************
*** 1605,1616 ****
putchar ('*');
}
static int
length_of_file_name_and_frills (f)
struct file *f;
{
register char *p = f->name;
! register char c;
register int len = 0;
if (print_inode)
--- 1797,1851 ----
putchar ('*');
}
+ static void
+ print_color_indicator (mode)
+ unsigned int mode;
+ {
+ int i;
+ int shi; /* Bits to shift mode */
+ int type = C_FILE;
+
+ if (S_ISDIR (mode) && *indicator_color[C_DIR])
+ type = C_DIR;
+
+ #ifdef S_ISLNK
+ else if (S_ISLNK (mode) && *indicator_color[C_LINK])
+ type = C_LINK;
+ #endif
+
+ #ifdef S_ISFIFO
+ else if (S_ISFIFO (mode) && *indicator_color[C_FIFO])
+ type = C_FIFO;
+ #endif
+
+ #ifdef S_ISSOCK
+ else if (S_ISSOCK (mode) && *indicator_color[C_SOCK])
+ type = C_SOCK;
+ #endif
+
+ #ifdef S_ISBLK
+ else if (S_ISBLK (mode) && *indicator_color[C_BLK])
+ type = C_BLK;
+ #endif
+
+ #ifdef S_ISCHR
+ else if (S_ISCHR (mode) && *indicator_color[C_CHR])
+ type = C_CHR;
+ #endif
+
+ if ( type == C_FILE && (mode & (S_IEXEC|S_IEXEC>>3|S_IEXEC>>6)) )
+ type = C_EXEC;
+
+ if (*indicator_color[type])
+ printf (COLORWRAPPER, indicator_color[type]);
+ }
+
static int
length_of_file_name_and_frills (f)
struct file *f;
{
register char *p = f->name;
! register unsigned char c;
register int len = 0;
if (print_inode)
***************
*** 1646,1652 ****
break;
default:
! if (c >= 040 && c < 0177)
len += 1;
else
len += 4;
--- 1881,1888 ----
break;
default:
! if ( (c >= 0x20 && c <= 0x7E) ||
! (print_iso8859 && c >= 0xA1 && c <= 0xFF) )
len += 1;
else
len += 4;
***************
*** 1867,1882 ****
usage ()
{
fprintf (stderr, "\
! Usage: %s [-abcdgiklmnpqrstuxABCFGLNQRSUX1] [-w cols] [-T cols] [-I pattern]\n\
! [--all] [--escape] [--directory] [--inode] [--kilobytes] [--literal]\n\
! [--numeric-uid-gid] [--hide-control-chars] [--reverse] [--size]\n\
! [--width=cols] [--tabsize=cols] [--almost-all] [--ignore-backups]\n",
program_name);
fprintf (stderr, "\
[--classify] [--file-type] [--ignore=pattern] [--dereference]\n\
[--quote-name] [--recursive] [--sort={none,time,size,extension}]\n\
[--format={long,verbose,commas,across,vertical,single-column}]\n\
! [--time={atime,access,use,ctime,status}] [--no-group]\n\
! [--help] [--version] [path...]\n");
exit (1);
}
--- 2103,2119 ----
usage ()
{
fprintf (stderr, "\
! Usage: %s [-abcdfgiklmnopqrstuxABCFGLNQRSUX178] [-w cols] [-T cols]\n\
! [-I pattern] [--all] [--escape] [--directory] [--inode] [--kilobytes]\n\
! [--literal] [--numeric-uid-gid] [--hide-control-chars] [--reverse]\n\
! [--size] [--width=cols] [--tabsize=cols] [--almost-all] [--no-group]\n",
program_name);
fprintf (stderr, "\
[--classify] [--file-type] [--ignore=pattern] [--dereference]\n\
[--quote-name] [--recursive] [--sort={none,time,size,extension}]\n\
[--format={long,verbose,commas,across,vertical,single-column}]\n\
! [--time={atime,access,use,ctime,status}] [--ignore-backups]\n\
! [--full-time] [--colo[u]r] [--help] [--version] [--%cbit] [path...]\n",
! DEFAULT_ISO8859 ? '7' : '8');
exit (1);
}
--
This message was sent from a system running Linux, the freeware UNIX
clone. Get yours from tsx-11.mit.edu or sunsite.unc.edu.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1993-10-12 23:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1993-10-12 23:12 Color/8-bit/unified patch to GNU ls 3.8.3 H. Peter Anvin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox