Strange sscanf results
Posted: Sun Nov 20, 2005 11:03 pm
I've been getting some strange sscanf results from ps2sdk (in libc.a), which I think is a bug.
The following snippet should return 3 (the amount of allocations done) but instead its returning 5 (the amount of conversions done).
I believe in xscanf.c in ps2sdk\ee\libc\src where it increments the nconvs after the nextconv tag it needs to check flags for not having FLSTAR set.
its probably easier to show it.
this needs to change at line 559...
to something like this...
I don't mind updating the repository if no one has any objections. If any one thinks it can be done better, comment away.
Orfax.
The following snippet should return 3 (the amount of allocations done) but instead its returning 5 (the amount of conversions done).
Code: Select all
res = sscanf(str, "%s%d%d%*d%*c", s1, &n1, &n2);
its probably easier to show it.
this needs to change at line 559...
Code: Select all
#if SCANF_LEVEL >= SCANF_FLT
nextconv:
#endif
flags = 0;
if (clen > olen)
nconvs++;
else if (c != 'n' || i == EOF)
/*
* If one conversion failed completely,
* punt.
*/
goto leave;
to something like this...
Code: Select all
#if SCANF_LEVEL >= SCANF_FLT
nextconv:
#endif
if (clen > olen && !(flags & FLSTAR)) {
flags = 0;
nconvs++;
}
else if (c != 'n' || i == EOF) {
/*
* If one conversion failed completely,
* punt.
*/
flags = 0;
goto leave;
}
else
flags = 0;
Orfax.