small fix for *scanf
Mehmet YASAR
myasar at free.fr
Thu Jan 9 16:11:01 CST 2003
Hi,
This patch fixes a bug in *scanf : when there is no data is the stream
*scanf should return EOF not 0 (tested with fscanf and sscanf).
Changelog :
- return EOF when stream is empty
- conformance test updated
Mehmet
-------------- next part --------------
diff -ur CVS/wine/dlls/msvcrt/scanf.h wine/wine2/dlls/msvcrt/scanf.h
--- CVS/wine/dlls/msvcrt/scanf.h Fri Dec 20 11:40:07 2002
+++ wine/wine2/dlls/msvcrt/scanf.h Thu Jan 9 22:40:31 2003
@@ -90,6 +90,8 @@
#endif /* CONSOLE */
#endif /* WIDE_SCANF */
nch = _GETC_(file);
+ if (nch == _EOF_) return _EOF_;
+
va_start(ap, format);
while (*format) {
/* a whitespace character in the format string causes scanf to read,
Only in wine/wine2/dlls/msvcrt: scanf.o
Only in wine/wine2/dlls/msvcrt/tests: msvcrt_test.exe.spec.o
diff -ur CVS/wine/dlls/msvcrt/tests/scanf.c wine/wine2/dlls/msvcrt/tests/scanf.c
--- CVS/wine/dlls/msvcrt/tests/scanf.c Fri Dec 20 11:40:07 2002
+++ wine/wine2/dlls/msvcrt/tests/scanf.c Thu Jan 9 22:55:28 2003
@@ -26,8 +26,14 @@
{
char buffer[100];
char format[20];
- int result;
+ int result, ret;
+ /* check EOF */
+ strcpy(buffer,"");
+ ret = sscanf(buffer, "%d", &result);
+ ok( ret == EOF,"sscanf returns %x instead of %x", ret, EOF );
+
+ /* check %x */
strcpy(buffer,"0x519");
ok( sscanf(buffer, "%x", &result) == 1, "sscanf failed" );
ok( result == 0x519,"sscanf reads %x instead of %x", result, 0x519 );
Only in wine/wine2/dlls/msvcrt/tests: scanf.c~
More information about the wine-patches
mailing list