Commit 8137c094 authored by Alasdair Sinclair's avatar Alasdair Sinclair Committed by Alexandre Julliard

msvcrt: If we're at EOF in the buffer and we have pattern %n in format string we…

msvcrt: If we're at EOF in the buffer and we have pattern %n in format string we should not count the EOF in the total.
parent 9d70a6ee
......@@ -415,7 +415,7 @@ _FUNCTION_ {
case 'n': {
if (!suppress) {
int*n = va_arg(ap, int*);
*n = consumed - (nch!=_EOF_);
*n = consumed - 1;
}
/* This is an odd one: according to the standard,
* "Execution of a %n directive does not increment the
......
......@@ -162,6 +162,12 @@ static void test_sscanf( void )
ok(strcmp(buffer1,"def")==0, "Second %%s read incorrectly: %s\n", buffer1);
ok(number_so_far==6, "%%n yielded wrong result: %d\n", number_so_far);
ok(ret == 2, "%%n shouldn't count as a conversion: %d\n", ret);
/* Check where %n matches to EOF in buffer */
strcpy(buffer, "3:45");
ret = sscanf(buffer, "%d:%d%n", &hour, &min, &number_so_far);
ok(ret == 2, "Wrong number of arguments read: %d\n", ret);
ok(number_so_far == 4, "%%n yielded wrong result: %d\n", number_so_far);
}
START_TEST(scanf)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment