From d3fd192523db544e6005051f224a2d7bafabedd9 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 14 Jul 2011 01:12:05 -0400 Subject: [PATCH] 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. --- src/stdlib/wcstoimax.c | 3 +-- src/stdlib/wcstoumax.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/stdlib/wcstoimax.c b/src/stdlib/wcstoimax.c index b83206b7..50647f62 100644 --- a/src/stdlib/wcstoimax.c +++ b/src/stdlib/wcstoimax.c @@ -7,7 +7,6 @@ intmax_t wcstoimax(const wchar_t *s, wchar_t **p, int base) { struct intparse ip = {0}; - unsigned char tmp; 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++); 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) *p = (wchar_t *)s; diff --git a/src/stdlib/wcstoumax.c b/src/stdlib/wcstoumax.c index e30b0638..af7ba3dc 100644 --- a/src/stdlib/wcstoumax.c +++ b/src/stdlib/wcstoumax.c @@ -8,7 +8,6 @@ uintmax_t wcstoumax(const wchar_t *s, wchar_t **p, int base) { struct intparse ip = {0}; - unsigned char tmp; 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++); 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) *p = (wchar_t *)s; -- 2.20.1