msvcrt: Support mixing length and width in scanf format.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45967
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2019-12-06 15:57:09 +01:00 committed by Alexandre Julliard
parent 62ea59774b
commit 7695433c05
2 changed files with 31 additions and 6 deletions

View file

@ -197,14 +197,14 @@ _FUNCTION_ {
format++;
suppress=1;
}
/* look for width specification */
while (_ISDIGIT_(*format)) {
width*=10;
width+=*format++ - '0';
}
if (width==0) width=-1; /* no width spec seen */
/* read prefix (if any) */
while (!prefix_finished) {
/* look for width specification */
while (_ISDIGIT_(*format)) {
width *= 10;
width += *format++ - '0';
}
switch(*format) {
case 'h': h_prefix++; break;
case 'l':
@ -228,6 +228,7 @@ _FUNCTION_ {
}
if (!prefix_finished) format++;
}
if (width==0) width=-1; /* no width spec seen */
/* read type */
switch(*format) {
case 'p':

View file

@ -205,6 +205,30 @@ static void test_sscanf( void )
ok(ret == 1, "Wrong number of arguments read: %d\n", ret);
ok(result == 0xdead614e, "Wrong number read (%x)\n", result);
result = 0xdeadbeef;
strcpy(buffer,"12345678");
ret = p_sscanf(buffer, "%02hd", &result);
ok(ret == 1, "Wrong number of arguments read: %d\n", ret);
ok(result == 0xdead000c, "Wrong number read (%x)\n", result);
result = 0xdeadbeef;
strcpy(buffer,"12345678");
ret = p_sscanf(buffer, "%h02d", &result);
ok(ret == 1, "Wrong number of arguments read: %d\n", ret);
ok(result == 0xdead000c, "Wrong number read (%x)\n", result);
result = 0xdeadbeef;
strcpy(buffer,"12345678");
ret = p_sscanf(buffer, "%000h02d", &result);
ok(ret == 1, "Wrong number of arguments read: %d\n", ret);
ok(result == 0xdead000c, "Wrong number read (%x)\n", result);
result = 0xdeadbeef;
strcpy(buffer,"12345678");
ret = p_sscanf(buffer, "%2h0d", &result);
ok(ret == 1, "Wrong number of arguments read: %d\n", ret);
ok(result == 0xdead614e, "Wrong number read (%x)\n", result);
result = 0xdeadbeef;
ret = p_sscanf(buffer, "%hhd", &result);
ok(ret == 1, "Wrong number of arguments read: %d\n", ret);