Fix two incorrect uses of sizeof: we need to divide the size of the buffer
by sizeof(wchar_t) to get the number of wide characters it contains. Remove the !hardway micro-optimisation from the CT_INT case to avoid having to fix it for wide characters.
This commit is contained in:
parent
b5c3fe0098
commit
4ea76cb195
@ -542,15 +542,9 @@ again: c = *fmt++;
|
||||
|
||||
case CT_INT:
|
||||
/* scan an integer as if by the conversion function */
|
||||
#ifdef hardway
|
||||
if (width == 0 || width > sizeof(buf) - 1)
|
||||
width = sizeof(buf) - 1;
|
||||
#else
|
||||
/* size_t is unsigned, hence this optimisation */
|
||||
if (--width > sizeof(buf) - 2)
|
||||
width = sizeof(buf) - 2;
|
||||
width++;
|
||||
#endif
|
||||
if (width == 0 || width > sizeof(buf) /
|
||||
sizeof(*buf) - 1)
|
||||
width = sizeof(buf) / sizeof(*buf) - 1;
|
||||
flags |= SIGNOK | NDIGITS | NZDIGITS;
|
||||
for (p = buf; width; width--) {
|
||||
c = __fgetwc(fp);
|
||||
@ -692,8 +686,9 @@ again: c = *fmt++;
|
||||
#ifdef FLOATING_POINT
|
||||
case CT_FLOAT:
|
||||
/* scan a floating point number as if by strtod */
|
||||
if (width == 0 || width > sizeof(buf) - 1)
|
||||
width = sizeof(buf) - 1;
|
||||
if (width == 0 || width > sizeof(buf) /
|
||||
sizeof(*buf) - 1)
|
||||
width = sizeof(buf) / sizeof(*buf) - 1;
|
||||
if ((width = parsefloat(fp, buf, buf + width)) == 0)
|
||||
goto match_failure;
|
||||
if ((flags & SUPPRESS) == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user