[PATCH] msvcrt: Fix the btowc() function.

Piotr Caban piotr.caban at gmail.com
Mon Jan 27 06:57:25 CST 2020


Hi Chip,

On 1/27/20 3:13 AM, Chip Davis wrote:
> +    if(!get_locinfo()->lc_codepage)
> +        return c & 255;
> +    if(!MultiByteToWideChar(get_locinfo()->lc_codepage,
> +                MB_ERR_INVALID_CHARS, (LPCSTR)&letter, 1, &ret, 1))
> +        return MSVCRT_WEOF;
Please also add handling for c == EOF, it doesn't work correctly now.

> +static void test_btowc(void)
> +{
> +    wint_t ret;
> +    int cp = _getmbcp();
> +
> +    if(!p_btowc || !setlocale(LC_ALL, "chinese-traditional")) {
> +        win_skip("Skipping btowc tests\n");
> +        return;
> +    }
> +
> +    ret = p_btowc(0x61);
> +    ok(ret == 0x61, "ret = %x\n", ret);
> +
> +    ret = p_btowc(0x81);
> +    ok(ret == WEOF, "ret = %x\n", ret);
> +
> +    ret = p_btowc(0xe0);
> +    ok(ret == WEOF, "ret = %x\n", ret);
> +
> +    _setmbcp(1250);
It looks like you're trying to test different codepages here. The 
function uses lc_codepage, the _setmbcp function changes mbcodepage.

Thanks,
Piotr



More information about the wine-devel mailing list