> Le 2 mai 2020 à 12:04, Denis Excoffier <bug-...@denis-excoffier.org> a écrit :
>
>> On 2020-05-02 07:23, Akim Demaille wrote:
>>
>> Hi Dennis!
> You mean Denis i suppose...
Yes, sorry about that :(
>> #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,
Great, thanks!