summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--filter.c26
2 files changed, 18 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 59c2e55a..43853836 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/filter.c b/filter.c
index d14ef436..94423a7b 100644
--- a/filter.c
+++ b/filter.c
@@ -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);