diff options
author | Rich Felker <dalias@aerifal.cx> | 2011-07-14 22:11:00 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2011-07-14 22:11:00 -0400 |
commit | 47d027ee1a44829819c345287623fe75374893ab (patch) | |
tree | 6a44b7e7c915496ea8bbefa66c91c4db5e97afa0 /src/stdlib/wcstoumax.c | |
parent | d3fd192523db544e6005051f224a2d7bafabedd9 (diff) | |
download | musl-47d027ee1a44829819c345287623fe75374893ab.tar.gz musl-47d027ee1a44829819c345287623fe75374893ab.tar.xz musl-47d027ee1a44829819c345287623fe75374893ab.zip |
fix various bugs in new integer parser framework
1. my interpretation of subject sequence definition was wrong. adjust parser to conform to the standard. 2. some code for handling tail overflow case was missing (forgot to finish writing it). 3. typo (= instead of ==) caused ERANGE to wrongly behave like EINVAL
Diffstat (limited to 'src/stdlib/wcstoumax.c')
-rw-r--r-- | src/stdlib/wcstoumax.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/stdlib/wcstoumax.c b/src/stdlib/wcstoumax.c index af7ba3dc..cee5ff7f 100644 --- a/src/stdlib/wcstoumax.c +++ b/src/stdlib/wcstoumax.c @@ -7,6 +7,7 @@ uintmax_t wcstoumax(const wchar_t *s, wchar_t **p, int base) { + const wchar_t *s1 = s; struct intparse ip = {0}; if (p) *p = (wchar_t *)s; @@ -22,11 +23,11 @@ uintmax_t wcstoumax(const wchar_t *s, wchar_t **p, int base) for (; __intparse(&ip, (char[]){(*s&-(*s<128U))}, 1); s++); if (p && ip.err != EINVAL) - *p = (wchar_t *)s; + *p = (wchar_t *)s1 + ip.cnt; if (ip.err) { errno = ip.err; - if (ip.err = EINVAL) return 0; + if (ip.err == EINVAL) return 0; return UINTMAX_MAX; } |