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:
parent
62ea59774b
commit
7695433c05
|
@ -197,14 +197,14 @@ _FUNCTION_ {
|
||||||
format++;
|
format++;
|
||||||
suppress=1;
|
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) */
|
/* read prefix (if any) */
|
||||||
while (!prefix_finished) {
|
while (!prefix_finished) {
|
||||||
|
/* look for width specification */
|
||||||
|
while (_ISDIGIT_(*format)) {
|
||||||
|
width *= 10;
|
||||||
|
width += *format++ - '0';
|
||||||
|
}
|
||||||
|
|
||||||
switch(*format) {
|
switch(*format) {
|
||||||
case 'h': h_prefix++; break;
|
case 'h': h_prefix++; break;
|
||||||
case 'l':
|
case 'l':
|
||||||
|
@ -228,6 +228,7 @@ _FUNCTION_ {
|
||||||
}
|
}
|
||||||
if (!prefix_finished) format++;
|
if (!prefix_finished) format++;
|
||||||
}
|
}
|
||||||
|
if (width==0) width=-1; /* no width spec seen */
|
||||||
/* read type */
|
/* read type */
|
||||||
switch(*format) {
|
switch(*format) {
|
||||||
case 'p':
|
case 'p':
|
||||||
|
|
|
@ -205,6 +205,30 @@ static void test_sscanf( void )
|
||||||
ok(ret == 1, "Wrong number of arguments read: %d\n", ret);
|
ok(ret == 1, "Wrong number of arguments read: %d\n", ret);
|
||||||
ok(result == 0xdead614e, "Wrong number read (%x)\n", result);
|
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;
|
result = 0xdeadbeef;
|
||||||
ret = p_sscanf(buffer, "%hhd", &result);
|
ret = p_sscanf(buffer, "%hhd", &result);
|
||||||
ok(ret == 1, "Wrong number of arguments read: %d\n", ret);
|
ok(ret == 1, "Wrong number of arguments read: %d\n", ret);
|
||||||
|
|
Loading…
Reference in New Issue