diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2012-03-17 00:55:07 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2012-03-17 00:55:07 -0700 |
commit | 302c1d3aeb9e05c3d2888529589217292f7e1c02 (patch) | |
tree | cd1001a4945dd1a8caf0db348139ffdcab4f67f0 | |
parent | 18466ee1380682028364ac690a8745caf156d353 (diff) | |
download | txr-302c1d3aeb9e05c3d2888529589217292f7e1c02.tar.gz txr-302c1d3aeb9e05c3d2888529589217292f7e1c02.tar.bz2 txr-302c1d3aeb9e05c3d2888529589217292f7e1c02.zip |
* filter.c (digit_value): static function moved.
(html_hex_continue): Use digit_value instead of hex digits string
literal.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | filter.c | 26 |
2 files changed, 18 insertions, 14 deletions
@@ -1,3 +1,9 @@ +2012-03-17 Kaz Kylheku <kaz@kylheku.com> + + * filter.c (digit_value): static function moved. + (html_hex_continue): Use digit_value instead of hex digits string + literal. + 2012-03-16 Kaz Kylheku <kaz@kylheku.com> * lib.c (do_chain): More useful behavior. The first @@ -523,10 +523,19 @@ static struct filter_pair from_html_table[] = { { 0, 0 } }; -static val html_hex_continue(val hexlist, val ch) +static int digit_value(int digit) { - static const wchar_t *hexdigs = L"0123456789ABCDEF"; + if (digit >= '0' && digit <= '9') + return digit - '0'; + if (digit >= 'A' && digit <= 'F') + return digit - 'A' + 10; + if (digit >= 'a' && digit <= 'f') + return digit - 'a' + 10; + internal_error("bad digit"); +} +static val html_hex_continue(val hexlist, val ch) +{ if (iswxdigit(c_chr(ch))) { return func_f1(cons(ch, hexlist), html_hex_continue); } if (eq(ch, chr(';'))) { @@ -538,7 +547,7 @@ static val html_hex_continue(val hexlist, val ch) for (iter = nreverse(hexlist); iter; iter = cdr(iter)) { val hexch = car(iter); - int val = wcschr(hexdigs, towupper(c_chr(hexch))) - hexdigs; + int val = digit_value(c_chr(hexch)); out[0] <<= 4; out[0] |= val; } @@ -602,17 +611,6 @@ val url_encode(val str) return get_string_from_stream(out); } -static int digit_value(int digit) -{ - if (digit >= '0' && digit <= '9') - return digit - '0'; - if (digit >= 'A' && digit <= 'F') - return digit - 'A' + 10; - if (digit >= 'a' && digit <= 'f') - return digit - 'a' + 10; - internal_error("bad digit"); -} - val url_decode(val str) { val in = make_string_input_stream(str); |