From a8440a58be20cd8bcfa78b74ed39e5cffcbc0f30 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 23 Mar 2016 06:22:17 -0700 Subject: Fix ctype.h functions misapplied to wide characters. * arith.c (tofloat): The isdigit here should be iswdigit. Use '0' to '9' range check. (toint): Replace accidental isalpha and toupper with iswalpha and towupper. --- arith.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arith.c b/arith.c index ecb3e03e..1083c9f9 100644 --- a/arith.c +++ b/arith.c @@ -2229,7 +2229,7 @@ val tofloat(val obj) case TAG_CHR: { cnum ch = c_num(obj); - if (isdigit(ch)) + if (ch >= '0' && ch <= '9') return flo(ch - '0'); return nil; } @@ -2268,8 +2268,8 @@ val toint(val obj, val base) if (ch >= '0' && ch <= '9') return num(ch - '0'); - if (isalpha(ch)) { - cnum n = 10 + toupper(ch) - 'A'; + if (iswalpha(ch)) { + cnum n = 10 + towupper(ch) - 'A'; cnum b = c_num(default_arg(base, num_fast(10))); if (n < b) -- cgit v1.2.3