On 10 Mar 2000, Jim Meyering wrote:

> Thanks for the patch.
> Would you please make a few changes and send new diffs?

Please see below...

Best wishes,

Alan

---------------------------------------------------------------------------

diff -r -u fileutils-4.0q/ChangeLog fileutils-4.0q.LINKCOLOR/ChangeLog
--- fileutils-4.0q/ChangeLog    Sun Feb 27 18:53:49 2000
+++ fileutils-4.0q.LINKCOLOR/ChangeLog  Fri Mar 10 16:09:29 2000
@@ -1,3 +1,9 @@
+2000-03-10  Alan Iwi <[EMAIL PROTECTED]>
+
+       * src/ls.c: Add support for "ln=target" in the LS_COLORS variable,
+                   to colorize links as for the file/directory pointed to.
+       * src/dircolors.hin: added a few words of documentation of the above.
+
 2000-02-27  Jim Meyering  <[EMAIL PROTECTED]>
 
        * Version 4.0q.
diff -r -u fileutils-4.0q/src/dircolors.hin fileutils-4.0q.LINKCOLOR/src/dircolors.hin
--- fileutils-4.0q/src/dircolors.hin    Sun Nov  7 20:28:41 1999
+++ fileutils-4.0q.LINKCOLOR/src/dircolors.hin  Fri Mar 10 16:03:41 2000
@@ -37,7 +37,8 @@
 NORMAL 00      # global default, although everything should be something.
 FILE 00        # normal file
 DIR 01;34      # directory
-LINK 01;36     # symbolic link
+LINK 01;36     # symbolic link.  (If you set this to 'target' instead of a
+               # numerical value, the color is as for the file pointed to.)
 FIFO 40;33     # pipe
 SOCK 01;35     # socket
 DOOR 01;35     # door
diff -r -u fileutils-4.0q/src/ls.c fileutils-4.0q.LINKCOLOR/src/ls.c
--- fileutils-4.0q/src/ls.c     Sun Dec 19 10:15:27 1999
+++ fileutils-4.0q.LINKCOLOR/src/ls.c   Fri Mar 10 16:12:59 2000
@@ -297,6 +297,17 @@
 
 static int files_index;
 
+/* Nonzero means in a color listing don't treat symlinks (non-orphaned) 
+   specially.  Gets set when ":ln=target:" appears in LS_COLORS. */
+
+static int no_special_link_color;
+
+/* mode of appropriate file for colorization */
+#define FILE_OR_LINK_MODE(file) \
+    ((no_special_link_color && (file)->linkok) \
+    ? (file)->linkmode: (file)->stat.st_mode)
+
+
 /* Record of one pending directory waiting to be listed.  */
 
 struct pending
@@ -1588,6 +1599,9 @@
        }
       print_with_color = 0;
     }
+
+  if (!strncmp(color_indicator[C_LINK].string,"target",6))
+      no_special_link_color=1;
 }
 
 /* Request that the directory named `name' have its contents listed later.
@@ -2383,7 +2397,7 @@
 
   DIRED_INDENT ();
   DIRED_FPUTS (buf, stdout, p - buf);
-  print_name_with_quoting (f->name, f->stat.st_mode, f->linkok,
+  print_name_with_quoting (f->name,FILE_OR_LINK_MODE(f),f->linkok,
                           &dired_obstack);
 
   if (f->filetype == symbolic_link)
@@ -2482,7 +2496,7 @@
            human_readable ((uintmax_t) ST_NBLOCKS (f->stat), buf,
                            ST_NBLOCKSIZE, output_block_size));
 
-  print_name_with_quoting (f->name, f->stat.st_mode, f->linkok, NULL);
+  print_name_with_quoting (f->name, FILE_OR_LINK_MODE(f), f->linkok, NULL);
 
   if (indicator_style != none)
     print_type_indicator (f->stat.st_mode);

Reply via email to