bug-bash
[Top][All Lists]
Advanced

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

Re: bash-3.2 multibyte behavior on Solaris


From: Chet Ramey
Subject: Re: bash-3.2 multibyte behavior on Solaris
Date: Sat, 27 Jun 2009 14:21:58 -0400
User-agent: Thunderbird 2.0.0.22 (Macintosh/20090605)

Jan Hnatek wrote:
> 
> Chet Ramey wrote:
>> So what does the Solaris mbrtowc return in this case?  The flow of that
>> particular section of code isn't that great (bash-4.0 is better), but it
>> seems to me that point can only increase.  If mbrtowc returns -2, the
>> loop won't be entered at all.
> 
> I've checked it and looks to do the following
> (correct me if I'm wrong):
> - tmp is unsigned
> - mbrtowc returns -2
> - tmp > 0 is true and loop is entered

Sure, but tmp is unsigned.  It must be integer promotion happening
that I overlooked.

Try the bash-4.0/readline-6.0 version of the code, which I've attached.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/
*** bash-3.2-patched/lib/readline/mbutil.c      2009-06-16 11:26:50.000000000 
-0400
--- bash-4.0-patched/lib/readline/mbutil.c      2009-01-04 14:32:33.000000000 
-0500
***************
*** 132,141 ****
      {
        tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
!       while (tmp > 0 && wcwidth (wc) == 0)
        {
          point += tmp;
          tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
-         if (MB_NULLWCH (tmp) || MB_INVALIDCH (tmp))
-           break;
        }
      }
--- 130,137 ----
      {
        tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
!       while (MB_NULLWCH (tmp) == 0 && MB_INVALIDCH (tmp) == 0 && wcwidth (wc) 
== 0)
        {
          point += tmp;
          tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
        }
      }

reply via email to

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