msvcrt: Update source pointer in wcsrtombs in C locale.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50698
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 3dca00f1dd)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
This commit is contained in:
Bernhard Kölbl 2021-03-02 12:09:32 +01:00 committed by Michael Stefaniuc
parent 780b202907
commit 3224e39044
2 changed files with 19 additions and 0 deletions

View File

@ -2094,6 +2094,22 @@ static void test_mbstowcs(void)
ok(ret == 0, "wcstombs did not return 0, got %d\n", (int)ret); ok(ret == 0, "wcstombs did not return 0, got %d\n", (int)ret);
ok(!mOut[0], "mOut = %s\n", mOut); ok(!mOut[0], "mOut = %s\n", mOut);
if(pwcsrtombs) {
pwstr = wSimple;
err = -3;
ret = pwcsrtombs(mOut, &pwstr, 4, &err);
ok(ret == 4, "wcsrtombs did not return 4\n");
ok(err == 0, "err = %d\n", err);
ok(pwstr == wSimple+4, "pwstr = %p (wszSimple = %p)\n", pwstr, wSimple);
ok(!memcmp(mOut, mSimple, ret), "mOut = %s\n", mOut);
pwstr = wSimple;
ret = pwcsrtombs(mOut, &pwstr, 5, NULL);
ok(ret == 4, "wcsrtombs did not return 4\n");
ok(pwstr == NULL, "pwstr != NULL\n");
ok(!memcmp(mOut, mSimple, sizeof(mSimple)), "mOut = %s\n", mOut);
}
if(!setlocale(LC_ALL, "Japanese_Japan.932")) { if(!setlocale(LC_ALL, "Japanese_Japan.932")) {
win_skip("Japanese_Japan.932 locale not available\n"); win_skip("Japanese_Japan.932 locale not available\n");
return; return;

View File

@ -610,6 +610,9 @@ static size_t wcsrtombs_l(char *mbstr, const wchar_t **wcstr,
mbstr[i] = (*wcstr)[i]; mbstr[i] = (*wcstr)[i];
if(!(*wcstr)[i]) break; if(!(*wcstr)[i]) break;
} }
if(i < count) *wcstr = NULL;
else *wcstr += i;
return i; return i;
} }