summaryrefslogtreecommitdiffstats
path: root/lib/libc/stdio/vfwscanf.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdio/vfwscanf.c')
-rw-r--r--lib/libc/stdio/vfwscanf.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/lib/libc/stdio/vfwscanf.c b/lib/libc/stdio/vfwscanf.c
index 7723bc5..990555c 100644
--- a/lib/libc/stdio/vfwscanf.c
+++ b/lib/libc/stdio/vfwscanf.c
@@ -542,15 +542,9 @@ literal:
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 @@ literal:
#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) {
OpenPOWER on IntegriCloud