Subject: bug#15527: Failing test spencer1-locale for grep 2.14 on Solaris

From: Dagobert Michelsen <[email-masked]>
Date: Wed, 16 Oct 2013 17:08:11 +0200

Hi Jim,

Am 16.10.2013 um 16:50 schrieb Jim Meyering <[email-masked]>:
> On Wed, Oct 16, 2013 at 6:49 AM, Dagobert Michelsen <[email-masked]> wrote:
>> Cool, thanks for digging this out! Can you please tell me which
>> invocation of wcscoll fails? I would then open a call at Oracle
>> about the issue.
> 
> Sure.  Here's a snippet from my debugging session.
> This shows that \002 collates *after* \003 in that locale:
> You can see I couldn't believe my eyes, so printed the offending
> wcscoll expression twice :-)
> 
> 2770        /* Build the table for single byte characters.  */
> 2771        for (wc = 0; wc < SBC_MAX; ++wc)
> 2772          {
> 2773            cmp_buf[2] = wc;
> 2774            if (wcscoll (cmp_buf, cmp_buf + 2) <= 0
> 2775                && wcscoll (cmp_buf + 2, cmp_buf + 4) <= 0)
> 2776              bitset_set (sbcset, wc);
> 2777          }
> 2778      }
> (gdb) p wcscoll (cmp_buf + 2, cmp_buf + 4)
> $27 = 3
> (gdb) p cmp_buf+2
> $28 = 0xffbff2f8 L"\002"
> (gdb) p cmp_buf+4
> $29 = 0xffbff300 L"\003"
> (gdb) p wcscoll (cmp_buf + 2, cmp_buf + 4)
> $30 = 3

I don't have too many experience with wide chars, but I fail to isolate the error:

> dam@unstable10s [unstable10s]:/home/dam/tmp/wcscoll > cat wcscoll-error.c                    
> 
> #include <stdio.h>
> #include <wchar.h>
> 
> main() {
>   printf( "Result: %d\n", wcscoll( L"\002", L"\003" ) );
> }
> dam@unstable10s [unstable10s]:/home/dam/tmp/wcscoll > gcc -o wcscoll-error wcscoll-error.c 
> dam@unstable10s [unstable10s]:/home/dam/tmp/wcscoll > ./wcscoll-error 
> Result: -1
> zsh: 2791 exit 184   ./wcscoll-error
> dam@unstable10s [unstable10s]:/home/dam/tmp/wcscoll > LC_COLLATE=ru_RU.KOI8-R ./wcscoll-error        
> Result: -1
> zsh: 2809 exit 184   LC_COLLATE=ru_RU.KOI8-R ./wcscoll-error

This is most certainly something really stupid, so I apologize beforehand :-)

Best regards

  -- Dago

-- 
"You don't become great by trying to be great, you become great by wanting to do something,
and then doing it so hard that you become great in the process." - xkcd #896