bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug #26512 (C_NORM unused)


From: Pádraig Brady
Subject: Re: bug #26512 (C_NORM unused)
Date: Tue, 16 Feb 2010 10:10:16 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20100111 Thunderbird/3.0.1

On 16/02/10 01:00, Pádraig Brady wrote:
On 15/02/10 20:05, Moritz Orbach wrote:
Hello all,

attached is a patch for bug #26512
http://savannah.gnu.org/bugs/index.php?26512

Is it correct? make distcheck still passes all tests. There's a
seemingly useless C_RESET at every end of line, just before the next
color sequence at the start of the next line -- but that's the same
behaviour as "ls -x" before the patch, so maybe it is needed?

Could you please incorporate this into the next release?

The change in behaviour was introduced with the following commit.
C_NORM was
unused since then.

commit 483297d5ddaea930d61da1da9c3f052cbd3c3810
Author: Ed Avis<address@hidden>
Date: Tue Feb 12 12:22:35 2008 +0100

You're right, the following should show bold/bright text:

LS_COLORS=no=1 ls -l --color

Also, "no" being configurable is alluded to in:
dircolors -p | grep NORMAL

The patch looks sensible at first glance.
I'll test it thoroughly tomorrow morning and check it in.

I reworked it a bit as follows.
This changes things so that NORMAL is not cumulative with other attributes.
I think that is what users would prefer.
I also changed it so that attributes are reset if the last entry is a normal 
file.
Tested with:

$ LS_COLORS=no=7      ./ls -l --color yes yes.c
$ LS_COLORS=no=7      ./ls -x --color yes yes.c
$ LS_COLORS=no=7:fi=0 ./ls -l --color yes yes.c
$ LS_COLORS=no=7:fi=1 ./ls -l --color yes yes.c
$ LS_COLORS=no=7:fi=  ./ls -l --color yes yes.c

cheers,
Pádraig.

diff --git a/src/ls.c b/src/ls.c
index 680679a..f8f11b8 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1149,6 +1149,17 @@ restore_default_color (void)
   put_indicator (&color_indicator[C_RIGHT]);
 }

+static void
+set_normal_color (void)
+{
+  if (is_colored (C_NORM))
+    {
+      put_indicator (&color_indicator[C_LEFT]);
+      put_indicator (&color_indicator[C_NORM]);
+      put_indicator (&color_indicator[C_RIGHT]);
+    }
+}
+
 /* An ordinary signal was received; arrange for the program to exit.  */

 static void
@@ -3444,6 +3455,8 @@ print_current_files (void)
     case long_format:
       for (i = 0; i < cwd_n_used; i++)
         {
+          if (print_with_color)
+            set_normal_color ();
           print_long_format (sorted_file[i]);
           DIRED_PUTCHAR ('\n');
         }
@@ -4004,7 +4017,9 @@ print_name_with_quoting (const struct fileinfo *f,
   const char* name = symlink_target ? f->linkname : f->name;

   bool used_color_this_time
-    = (print_with_color && print_color_indicator (f, symlink_target));
+    = (print_with_color
+        && (print_color_indicator (f, symlink_target)
+            || is_colored (C_NORM)));

   if (stack)
     PUSH_CURRENT_DIRED_POS (stack);
@@ -4048,6 +4063,9 @@ print_file_name_and_frills (const struct fileinfo *f, 
size_t start_col)
 {
   char buf[MAX (LONGEST_HUMAN_READABLE + 1, INT_BUFSIZE_BOUND (uintmax_t))];

+  if (print_with_color)
+    set_normal_color ();
+
   if (print_inode)
     printf ("%*s ", format == with_commas ? 0 : inode_number_width,
             format_inode (buf, sizeof buf, f));
@@ -4218,6 +4236,9 @@ print_color_indicator (const struct fileinfo *f, bool 
symlink_target)
       = ext ? &(ext->seq) : &color_indicator[type];
     if (s->string != NULL)
       {
+        /* Need to reset so not dealing with attribute combinations */
+        if (is_colored (C_NORM))
+          restore_default_color ();
         put_indicator (&color_indicator[C_LEFT]);
         put_indicator (s);
         put_indicator (&color_indicator[C_RIGHT]);
(END)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]