Преглед на файлове

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.
Rich Felker преди 13 години
родител
ревизия
d3fd192523
променени са 2 файла, в които са добавени 2 реда и са изтрити 4 реда
  1. 1 2
      src/stdlib/wcstoimax.c
  2. 1 2
      src/stdlib/wcstoumax.c

+ 1 - 2
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;

+ 1 - 2
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;