fix wcsto[iu]max with high characters

stopping without letting the parser see a stop character prevented
getting a result. so treat all high chars as the null character and
pass them into the parser.

also eliminated ugly tmp var using compound literals.
This commit is contained in:
Rich Felker 2011-07-14 01:12:05 -04:00
parent ecc9c5fcfa
commit d3fd192523
2 changed files with 2 additions and 4 deletions

View File

@ -7,7 +7,6 @@
intmax_t wcstoimax(const wchar_t *s, wchar_t **p, int base) intmax_t wcstoimax(const wchar_t *s, wchar_t **p, int base)
{ {
struct intparse ip = {0}; struct intparse ip = {0};
unsigned char tmp;
if (p) *p = (wchar_t *)s; if (p) *p = (wchar_t *)s;
@ -19,7 +18,7 @@ intmax_t wcstoimax(const wchar_t *s, wchar_t **p, int base)
for (; iswspace(*s); s++); for (; iswspace(*s); s++);
ip.base = base; ip.base = base;
for (; *s<256 && (tmp=*s, __intparse(&ip, &tmp, 1)); s++); for (; __intparse(&ip, (char[]){(*s&-(*s<128U))}, 1); s++);
if (p && ip.err != EINVAL) if (p && ip.err != EINVAL)
*p = (wchar_t *)s; *p = (wchar_t *)s;

View File

@ -8,7 +8,6 @@
uintmax_t wcstoumax(const wchar_t *s, wchar_t **p, int base) uintmax_t wcstoumax(const wchar_t *s, wchar_t **p, int base)
{ {
struct intparse ip = {0}; struct intparse ip = {0};
unsigned char tmp;
if (p) *p = (wchar_t *)s; if (p) *p = (wchar_t *)s;
@ -20,7 +19,7 @@ uintmax_t wcstoumax(const wchar_t *s, wchar_t **p, int base)
for (; iswspace(*s); s++); for (; iswspace(*s); s++);
ip.base = base; ip.base = base;
for (; *s<256 && (tmp=*s, __intparse(&ip, &tmp, 1)); s++); for (; __intparse(&ip, (char[]){(*s&-(*s<128U))}, 1); s++);
if (p && ip.err != EINVAL) if (p && ip.err != EINVAL)
*p = (wchar_t *)s; *p = (wchar_t *)s;