summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-03-23 06:22:17 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-03-23 06:22:17 -0700
commita8440a58be20cd8bcfa78b74ed39e5cffcbc0f30 (patch)
tree17c7de237bda356eeff90fe623e51dd1a83adb72
parent8f57057a347cd20a3a04156ca1caa810509e6e09 (diff)
downloadtxr-a8440a58be20cd8bcfa78b74ed39e5cffcbc0f30.tar.gz
txr-a8440a58be20cd8bcfa78b74ed39e5cffcbc0f30.tar.bz2
txr-a8440a58be20cd8bcfa78b74ed39e5cffcbc0f30.zip
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.
-rw-r--r--arith.c6
1 files 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)