[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: wbswidth: portability to cygwin
From: |
Akim Demaille |
Subject: |
Re: wbswidth: portability to cygwin |
Date: |
Sat, 2 May 2020 17:20:11 +0200 |
Dear gnulibers,
Denis reported a failure in Bison's test suite which is related to the handling
of mb chars on Cygwin (https://lists.gnu.org/r/bug-bison/2020-05/msg00003.html).
Bruno fixed a similar issue (on the same test case actually) on Solaris some
time ago, and demonstrated it with the following program. Please find below
the result on Denis' machine. The part with wcwidth is probably useless, as
the results are certainly coming from the degradation of the values of the
large integral numbers.
I have no idea what are the next steps. AFAICT from the gnulib documentation,
wchar.h's replacement should work properly on Cygwin, but I don't know if
mbswidth is expected to work. The test Denis ran below was indeed using
gnulib's wchar.h.
Cheers!
> Le 2 mai 2020 à 12:04, Denis Excoffier <address@hidden> a écrit :
>
>> On 2020-05-02 07:23, Akim Demaille wrote:
>>
>> #include <config.h>
>> #include <stdio.h>
>> #include <locale.h>
>> #include <wchar.h>
>> #include "mbswidth.h"
>> int main ()
>> {
>> setlocale (LC_ALL, "en_US.UTF-8");
>> printf ("%d\n", (int) mbswidth ("{∇⃗×𝐸⃗ = -∂𝐵⃗/∂t}",0)); // 14 vs 17
>> printf ("%d\n", wcwidth (0x2207)); // 1 vs. 2
>> printf ("%d\n", wcwidth (0x20D7)); // 0
>> printf ("%d\n", wcwidth (0x00D7)); // 1
>> printf ("%d\n", wcwidth (0x1D438)); // 1
>> printf ("%d\n", wcwidth (0x2202)); // 1 vs. 2
>> printf ("%d\n", wcwidth (0x1D435)); // 1
>> }
>>
>> I suggest that you put it in your bison directory, and compile it this way:
>>
>>> $ gcc foo.c -I _build/g9d/lib -I lib -L _build/g9d/lib -lbison
>>
>>
>> (_build/g9d is my build tree)
>>
>> FTR, I have:
>>
>>> $ ./a.out
>>> 14
>>> 1
>>> 0
>>> 1
>>> 1
>>> 1
>>> 1
>>
>
> On cygwin:
>
> % uname -sro
> CYGWIN_NT-10.0-17763 3.1.5-340.x86_64.snap Cygwin
> % gcc --version
> gcc (GCC) 9.3.0
> Copyright (C) 2019 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> % gcc -o foo1 foo1.c -I /tmp/lcl/tmp/bison/bison-3.5.91 -I lib -L
> /tmp/lcl/tmp/bison/bison-3.5.91 -L lib -l bison
> foo1.c: In function 'main':
> foo1.c:13:27: warning: unsigned conversion from 'int' to 'wchar_t’ {aka
> ‘const short unsigned int’} changes value from '119864' to '54328'
> [-Woverflow]
> 13 | printf ("%d\n", wcwidth (0x1D438)); // 1
> | ^~~~~~~
> foo1.c:15:27: warning: unsigned conversion from 'int' to 'wchar_t’ {aka
> ‘const short unsigned int’} changes value from '119861' to '54325'
> [-Woverflow]
> 15 | printf ("%d\n", wcwidth (0x1D435)); // 1
> | ^~~~~~~
> % ./foo1
> 16
> 1
> 0
> 1
> 2
> 1
> 2
> %
>
> Hope this helps,
>
> Denis Excoffier.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: wbswidth: portability to cygwin,
Akim Demaille <=