Re: [Mingw-w64-public] Inconsistent behavior of btowc with "C" locale

2025-06-06 Thread LIU Hao
在 2025-6-7 00:07, Kirill Makurin 写道: I just tested return values of UCRT's wctob in "C" locale for input in range [128,255] and it seems to do the same thing as btowc. For other locales it does best-fit conversion (when it can't convert losslessly), this why I come up with using 20127, so we w

Re: [Mingw-w64-public] Inconsistent behavior of btowc with "C" locale

2025-06-06 Thread Kirill Makurin
Oh, you are right, it does sign-extend the result. I see that declarations of `btowc` and `wctob` in wchar.h do not have `_CRTIMP`. Does it mean they just need to be removed from import libraries? It also seems my second patch is no longer needed. - Kirill Makurin _

Re: [Mingw-w64-public] Inconsistent behavior of btowc with "C" locale

2025-06-06 Thread Kirill Makurin
Using range check will prevent best-fit conversion. I think it would be preferrable in this case. - Kirill Makurin From: Kirill Makurin Sent: Saturday, June 7, 2025 1:02 AM To: LIU Hao ; mingw-w64-public Subject: Re: [Mingw-w64-public] Inconsistent behavior of

Re: [Mingw-w64-public] Inconsistent behavior of btowc with "C" locale

2025-06-06 Thread Kirill Makurin
Yes, there should be "<=". I just tested return values of UCRT's wctob in "C" locale for input in range [128,255] and it seems to do the same thing as btowc. For other locales it does best-fit conversion (when it can't convert losslessly), this why I come up with using 20127, so we would perfor

Re: [Mingw-w64-public] Inconsistent behavior of btowc with "C" locale

2025-06-06 Thread LIU Hao
在 2025-6-6 20:31, Kirill Makurin 写道: diff --git a/mingw-w64-crt/misc/btowc.c b/mingw-w64-crt/misc/btowc.c index c8fbd8e74..e203bbc44 100644 --- a/mingw-w64-crt/misc/btowc.c +++ b/mingw-w64-crt/misc/btowc.c @@ -15,14 +15,18 @@ wint_t btowc (int c)  ... ... + unsigned cp = ___lc_codepage_func(); +

Re: [Mingw-w64-public] Inconsistent behavior of btowc with "C" locale

2025-06-06 Thread Kirill Makurin
I have updated my initial patch, if you're OK with it. There is second patch which should add emulation of btowc and wctob for msvcrt.dll. I have not tested it, sorry for that. - Kirill Makurin From: Kirill Makurin Sent: Friday, June 6, 2025 6:47 PM To: lh_mo...

Re: [Mingw-w64-public] Inconsistent behavior of btowc with "C" locale

2025-06-06 Thread Kirill Makurin
I can update patch I initially attached to: For btowc, check for value to be in range [0,255] instead of [0,127]. For wctob, remove range check and use code page 20127 (ASCII) for conversion (so it matches CRT's best-fit behavior). - Kirill Makurin From: LIU H

[Mingw-w64-public] winpthreads: do not expose IN_WINPTHREAD in public header files

2025-06-06 Thread Kirill Makurin
See commit message. I have a question. What do you think about adding .pc (pkg-config) file for winpthreads? There is also a problematic interaction between pthread_compat.h and autoconf's AC_TYPE_PID_T. With MSVC, this check will fail and it will ``` #define pid_t ... ``` If pthread_compat.h