Alasdair Sinclair : 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 .
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Jan 17 05:21:32 CST 2007
Module: wine
Branch: master
Commit: 8137c094fdf37e9d101e52f114103bda55c5b3ac
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8137c094fdf37e9d101e52f114103bda55c5b3ac
Author: Alasdair Sinclair <alasdairs at dsl.pipex.com>
Date: Wed Jan 17 04:14:27 2007 +0000
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.
---
dlls/msvcrt/scanf.h | 2 +-
dlls/msvcrt/tests/scanf.c | 6 ++++++
2 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/dlls/msvcrt/scanf.h b/dlls/msvcrt/scanf.h
index 139f142..7fe3cc4 100644
--- a/dlls/msvcrt/scanf.h
+++ b/dlls/msvcrt/scanf.h
@@ -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
diff --git a/dlls/msvcrt/tests/scanf.c b/dlls/msvcrt/tests/scanf.c
index 71e6e22..65bea46 100644
--- a/dlls/msvcrt/tests/scanf.c
+++ b/dlls/msvcrt/tests/scanf.c
@@ -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)
More information about the wine-cvs
mailing list