bug-bash
[Top][All Lists]
Advanced

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

Re: all invisible characters are attributed to the first line


From: Aron Griffis
Subject: Re: all invisible characters are attributed to the first line
Date: Mon, 2 Aug 2004 18:22:39 -0400
User-agent: Mutt/1.5.6i

Chet Ramey wrote:[Mon Aug 02 2004, 05:13:29PM EDT]
> I haven't looked closely at this yet, but in looking at the proposed
> patch I can't see how this will change anything.  

You're right.  Sorry, I hacked that up too quickly. :-(

> Even if the
> offending statement is executed only after a visible character is
> processed, it will still perform far more assignments than wanted.  As
> long as there are visible characters after invisible ones, the wrong
> value will still be assigned to invfl. 
> 
> What you want is to ensure that the assignment is only executed once, the
> first time the character count exceeds the screen width.  A flag variable
> seems the most appropriate way to do that.

How about this instead?  Whenever ninvis is incremented, it is also
assigned to invfl if we haven't wrapped yet.  I believe this is the
same as what the original code was trying to achieve.  Additionally
this gets rid of special case code by doing the assignment in only one
place.

I'm not trying to ignore your suggestion to use a flag, but this patch
seems to be correct and doesn't need it.  If you would prefer it coded
a different way, I will pursue that.

I tested this using the following and hitting up-arrow enter a lot of
times.  This generates a successively longer and longer PS1 including
invisible characters.

    ((i++)); PS1='\[\033[0m\]'; for ((j = 0; j < i; j++)); do \
        PS1=${PS1}$((j % 10)); PS1=${PS1}'\[\033[0m\]'; done

Regards,
Aron

--- bash-3.0/lib/readline/display.c     2004-05-27 22:57:51.000000000 -0400
+++ bash-3.0.agriffis/lib/readline/display.c    2004-08-02 17:43:02.000000000 
-0400
@@ -258,23 +258,21 @@
 #endif
            {
              *r++ = *p;
                rl++;                   /* visible length byte counter */
              else
-               ninvis++;               /* invisible chars byte counter */
+               {
+                 ninvis++;             /* invisible chars byte counter */
+                 if (rl < _rl_screenwidth)
+                   invfl = ninvis;
+               }
            }
 
-         if (rl >= _rl_screenwidth)
-           invfl = ninvis;
-
          if (ignoring == 0)
            physchars++;
        }
     }
 
-  if (rl < _rl_screenwidth)
-    invfl = ninvis;
-
   *r = '\0';
   if (lp)
     *lp = rl;




reply via email to

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