math: tanh.c cleanup similar to sinh, cosh
[musl] / src / internal / intscan.c
index a00f2cc..69350ef 100644 (file)
@@ -1,5 +1,6 @@
 #include <limits.h>
 #include <errno.h>
+#include <ctype.h>
 #include "shgetc.h"
 
 /* Lookup table for digit values. -1==255>=36 -> invalid */
@@ -32,7 +33,7 @@ unsigned long long __intscan(FILE *f, unsigned base, int pok, unsigned long long
                errno = EINVAL;
                return 0;
        }
-       c = shgetc(f);
+       while (isspace((c=shgetc(f))));
        if (c=='+' || c=='-') {
                neg = -(c=='-');
                c = shgetc(f);
@@ -54,6 +55,7 @@ unsigned long long __intscan(FILE *f, unsigned base, int pok, unsigned long long
        } else {
                if (base == 0) base = 10;
                if (val[c] >= base) {
+                       shunget(f);
                        shlim(f, 0);
                        errno = EINVAL;
                        return 0;