projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
define NULL as nullptr when used in C++11 or later
[musl]
/
src
/
internal
/
intscan.c
diff --git
a/src/internal/intscan.c
b/src/internal/intscan.c
index
d65fc45
..
a4a5ae8
100644
(file)
--- a/
src/internal/intscan.c
+++ b/
src/internal/intscan.c
@@
-1,5
+1,6
@@
#include <limits.h>
#include <errno.h>
#include <limits.h>
#include <errno.h>
+#include <ctype.h>
#include "shgetc.h"
/* Lookup table for digit values. -1==255>=36 -> invalid */
#include "shgetc.h"
/* Lookup table for digit values. -1==255>=36 -> invalid */
@@
-28,11
+29,11
@@
unsigned long long __intscan(FILE *f, unsigned base, int pok, unsigned long long
int c, neg=0;
unsigned x;
unsigned long long y;
int c, neg=0;
unsigned x;
unsigned long long y;
- if (base > 36) {
+ if (base > 36
|| base == 1
) {
errno = EINVAL;
return 0;
}
errno = EINVAL;
return 0;
}
-
c = shgetc(f
);
+
while (isspace((c=shgetc(f)))
);
if (c=='+' || c=='-') {
neg = -(c=='-');
c = shgetc(f);
if (c=='+' || c=='-') {
neg = -(c=='-');
c = shgetc(f);
@@
-82,6
+83,7
@@
unsigned long long __intscan(FILE *f, unsigned base, int pok, unsigned long long
for (; val[c]<base; c=shgetc(f));
errno = ERANGE;
y = lim;
for (; val[c]<base; c=shgetc(f));
errno = ERANGE;
y = lim;
+ if (lim&1) neg = 0;
}
done:
shunget(f);
}
done:
shunget(f);