Fix some sscanf cases and testcase to get wxtide32.exe running.

This commit is contained in:
Uwe Bonnes 2003-05-13 23:38:46 +00:00 committed by Alexandre Julliard
parent 5d6f328e0d
commit 29c7e32f83
2 changed files with 21 additions and 8 deletions

View File

@ -4,7 +4,7 @@
*
* Copyright 1996,1998 Marcus Meissner
* Copyright 1996 Jukka Iivonen
* Copyright 1997,2000 Uwe Bonnes
* Copyright 1997,2000, 2003 Uwe Bonnes
* Copyright 2000 Jon Griffiths
* Copyright 2002 Daniel Gudbjartsson
*
@ -82,12 +82,12 @@ int _FUNCTION_ {
if (!*format) return 0;
#ifndef WIDE_SCANF
#ifdef CONSOLE
WARN("(\"%s\"): semi-stub\n", format);
WARN("(%s): semi-stub\n", debugstr_a(format));
#else /* CONSOLE */
#ifdef STRING
WARN("%s (\"%s\"): semi-stub\n", file, format);
WARN("%s (%s): semi-stub\n", file, debugstr_a(format));
#else /* STRING */
WARN("%p (\"%s\"): semi-stub\n", file, format);
WARN("%p (%s): semi-stub\n", file, debugstr_a(format));
#endif /* STRING */
#endif /* CONSOLE */
#endif /* WIDE_SCANF */
@ -260,7 +260,7 @@ int _FUNCTION_ {
}
/* get first digit. */
if (!_ISDIGIT_(nch)) break;
cur = (nch - '0') * (negative ? -1 : 1);
cur = (nch - '0');
nch = _GETC_(file);
if (width>0) width--;
/* read until no more digits */
@ -409,8 +409,8 @@ int _FUNCTION_ {
#else /* WIDE_SCANF */
*c = nch;
#endif /* WIDE_SCANF */
st = 1;
}
st = 1;
nch = _GETC_(file);
}
break;
@ -422,9 +422,9 @@ int _FUNCTION_ {
#else /* WIDE_SCANF */
*c = _CONVERT_(nch);
#endif /* WIDE_SCANF */
st = 1;
}
nch = _GETC_(file);
st = 1;
}
break;
case 'n': {

View File

@ -24,9 +24,12 @@
static void test_sscanf( void )
{
char buffer[100];
char buffer[100], buffer1[100];
char format[20];
int result, ret;
float res1= -82.6267, res2= 27.76, res11, res12;
char pname[]=" St. Petersburg, Florida\n";
/* check EOF */
strcpy(buffer,"");
@ -51,6 +54,16 @@ static void test_sscanf( void )
strcpy(format,"%\"%%%d%@"); /* work around gcc format check */
ok( sscanf(buffer, format, &result) == 1, "sscanf failed" );
ok( result == 12, "sscanf reads %x instead of %x", result, 12 );
/*Check float */
ret = sprintf(buffer,"%f %f",res1, res2);
ret = sscanf(buffer,"%f%f",&res11, &res12);
ok( (res11 == res1) && (res12 == res2), "Error reading floats");
ret = sprintf(buffer," %s", pname);
ret = sscanf(buffer,"%*c%[^\n]",buffer1);
ok( ret = 1, "Error with format \"%s\"","%*c%[^\n]");
ok( strncmp(pname,buffer1,strlen(buffer1)) == 0, "Error with \"%s\" \"%s\"",pname, buffer1);
}