diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-01-04 20:33:14 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-01-04 20:33:14 -0800 |
commit | 66dae5a4d72765c80d5cd97f5f16a4d095d79f2f (patch) | |
tree | 279d050457fbbfcd291e1160c52c4e5bb1d7d899 /lib.c | |
parent | 11ac283d7eda2bac2f19d62d014043f66c8de84c (diff) | |
download | txr-66dae5a4d72765c80d5cd97f5f16a4d095d79f2f.tar.gz txr-66dae5a4d72765c80d5cd97f5f16a4d095d79f2f.tar.bz2 txr-66dae5a4d72765c80d5cd97f5f16a4d095d79f2f.zip |
Revert chr-isdigit/isxdigit, provide new functions.
It was a mistake to change the semantics of the return value
of chr-isdigit and chr-isdigit. It breaks code like
[partition-by chr-isdigit ...]. The behavior of chr-isdigit
and chr-isxdigit is restored to returning t and nil. New
chr-digit and chr-xdigit functions are introduced for
returning the digit value or nil.
* eval.c (eval_init): Register chr-digit and chr-xdigit
intrinsics.
* lib.c (chr_isdigit, chr_isxdigit): Restore old behavior.
(chr_digit, chr_xdigit): New functions.
* lib.h (chr_digit, chr_xdigit): Declared.
* txr.1: Everything documented.
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -4025,6 +4025,11 @@ val chr_iscntrl(val ch) val chr_isdigit(val ch) { + return if2(iswdigit(c_chr(ch)), t); +} + +val chr_digit(val ch) +{ return if2(iswdigit(c_chr(ch)), minus(ch, chr('0'))); } @@ -4070,6 +4075,11 @@ val chr_isupper(val ch) val chr_isxdigit(val ch) { + return tnil(iswxdigit(c_chr(ch))); +} + +val chr_xdigit(val ch) +{ wchar_t cc = c_chr(ch); if ('0' <= cc && cc <= '9') |