summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-12-07 09:14:03 -0800
committerKaz Kylheku <kaz@kylheku.com>2011-12-07 09:14:03 -0800
commit35b83a9039898856776d1237a151f29cbce28a2f (patch)
tree9058ca6976feb557312d6d0da76d2cc913bad95e
parent46dea2737dcd5d74585878459999f230f2d002bc (diff)
downloadtxr-35b83a9039898856776d1237a151f29cbce28a2f.tar.gz
txr-35b83a9039898856776d1237a151f29cbce28a2f.tar.bz2
txr-35b83a9039898856776d1237a151f29cbce28a2f.zip
* eval.c (eval_init): New functions registered as intrinsics.
* lib.c (chr_toupper, chr_tolower): New functions. * lib.h (chr_toupper, chr_tolower): New functions declared.
-rw-r--r--ChangeLog8
-rw-r--r--eval.c2
-rw-r--r--lib.c10
-rw-r--r--lib.h2
4 files changed, 22 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 4dc6b703..2f5b89a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2011-12-07 Kaz Kylheku <kaz@kylheku.com>
+ * eval.c (eval_init): New functions registered as intrinsics.
+
+ * lib.c (chr_toupper, chr_tolower): New functions.
+
+ * lib.h (chr_toupper, chr_tolower): New functions declared.
+
+2011-12-07 Kaz Kylheku <kaz@kylheku.com>
+
* parser.l: In the CHRLIT state, return a nonblank character as an
IDENT token. This allows for character literals like #\$.
diff --git a/eval.c b/eval.c
index f54795aa..2f03b91f 100644
--- a/eval.c
+++ b/eval.c
@@ -1199,6 +1199,8 @@ void eval_init(void)
reg_fun(intern(lit("chr-isspace"), user_package), func_n1(chr_isspace));
reg_fun(intern(lit("chr-isupper"), user_package), func_n1(chr_isupper));
reg_fun(intern(lit("chr-isxdigit"), user_package), func_n1(chr_isxdigit));
+ reg_fun(intern(lit("chr-toupper"), user_package), func_n1(chr_toupper));
+ reg_fun(intern(lit("chr-tolower"), user_package), func_n1(chr_tolower));
reg_fun(intern(lit("chr-str"), user_package), func_n2(chr_str));
reg_fun(intern(lit("chr-str-set"), user_package), func_n3(chr_str_set));
reg_fun(intern(lit("span-str"), user_package), func_n2(span_str));
diff --git a/lib.c b/lib.c
index 82ab73a1..21e068cc 100644
--- a/lib.c
+++ b/lib.c
@@ -1528,6 +1528,16 @@ val chr_isxdigit(val ch)
return c_true(iswxdigit(c_chr(ch)));
}
+val chr_toupper(val ch)
+{
+ return chr(towupper(c_chr(ch)));
+}
+
+val chr_tolower(val ch)
+{
+ return chr(towlower(c_chr(ch)));
+}
+
val chr_str(val str, val index)
{
bug_unless (length_str_gt(str, index));
diff --git a/lib.h b/lib.h
index 776f1221..b5e1a15f 100644
--- a/lib.h
+++ b/lib.h
@@ -407,6 +407,8 @@ val chr_ispunct(val ch);
val chr_isspace(val ch);
val chr_isupper(val ch);
val chr_isxdigit(val ch);
+val chr_toupper(val ch);
+val chr_tolower(val ch);
val chr_str(val str, val index);
val chr_str_set(val str, val index, val chr);
val span_str(val str, val set);