Out of curiosity I tried to configure mingw-w64 for crtdll.dll and run the
tests. Something strange happens in tests for mbrlen, mbrtowc and mbsrtowcs
functions.
First, it seems that crtdll's setlocale() does not allow string which specify
ACP/OCP instead of actual code page (it's not a big issue, I'll send a patch in
coming days). Second, something seems to be wrong with crtdll's isleadbyte().
For mbrlen's test, the failing assertion was
```
assert (mbrlen ((char *) Multibyte, 1, &state) == (size_t) -2);
```
It seems to me that the issue may come from line 78 in mbrtowc.c:
```
} else if (mb_cur_max == 2 && isleadbyte (mbs[0])) {
```
Here mbs[0] is passed to isleadbyte(). If value of mbs[0] is outside of range
[0,127] (as all lead bytes are), it will be sign-extended. This seems to be the
source of the issue. I tried re-run tests after adding a cast to `unsigned
char` and it seems to fix it.
I tried configuring and running tests with msvcrt20.dll and they pass. I do not
have msvcrt10.dll to run tests with it. It would be helpful if anyone could run
tests with crtdll.dll and msvcrt10.dll to see how they behave.
If the issue is sign-extended input to isleadbyte(), it is fixable by a simple
patch with cast to `unsigned char`. If issue is indeed in crtdll's
isleadbyte(), I suggest we replace it by emu.
- Kirill Makurin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public