diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | filter.c | 82 | ||||
-rw-r--r-- | utf8.c | 122 |
3 files changed, 107 insertions, 102 deletions
@@ -1,3 +1,8 @@ +2013-08-09 Kaz Kylheku <kaz@kylheku.com> + + * filter.c, utf8.c: Tabs changed to spaces. For some reason, filter.c + used 4 space tabs and utf8.c used 8 space tabs, inconsistently. + 2013-07-13 Kaz Kylheku <kaz@kylheku.com> Version 67 @@ -153,7 +153,7 @@ val get_filter(val spec) val filter_list = mapcar(func_n1(get_filter), spec); if (memqual(nil, filter_list)) - return nil; + return nil; return curry_12_2(func_n2(compound_filter), filter_list); } @@ -237,29 +237,29 @@ val filter_string_tree(val filter, val obj) { switch (type(obj)) { case NIL: - return nil; + return nil; case CONS: - return mapcar(curry_12_2(func_n2(filter_string_tree), filter), obj); + return mapcar(curry_12_2(func_n2(filter_string_tree), filter), obj); default: - { - val type = typeof(filter); - - if (eq(type, null)) - return obj; - if (eq(type, hash_s) || eq(type, cons_s)) - return trie_filter_string(filter, obj); - else if (type == fun_s) - return funcall1(filter, obj); - return obj; - uw_throwf(error_s, lit("filter_string: invalid filter ~a"), filter, nao); - } + { + val type = typeof(filter); + + if (eq(type, null)) + return obj; + if (eq(type, hash_s) || eq(type, cons_s)) + return trie_filter_string(filter, obj); + else if (type == fun_s) + return funcall1(filter, obj); + return obj; + uw_throwf(error_s, lit("filter_string: invalid filter ~a"), filter, nao); + } } } val filter_equal(val lfilt, val rfilt, val left, val right) { return equal(filter_string_tree(lfilt, left), - filter_string_tree(rfilt, right)); + filter_string_tree(rfilt, right)); } val register_filter(val sym, val table) @@ -276,7 +276,7 @@ static struct filter_pair to_html_table[] = { }; static struct filter_pair from_html_table[] = { - { wli("""), wli("\"") }, + { wli("""), wli("\"") }, { wli("&"), wli("&") }, { wli("'"), wli("'") }, { wli("<"), wli("<") }, @@ -535,11 +535,11 @@ static struct filter_pair from_html_table[] = { static int digit_value(int digit) { if (digit >= '0' && digit <= '9') - return digit - '0'; + return digit - '0'; if (digit >= 'A' && digit <= 'F') - return digit - 'A' + 10; + return digit - 'A' + 10; if (digit >= 'a' && digit <= 'f') - return digit - 'a' + 10; + return digit - 'a' + 10; internal_error("bad digit"); } @@ -611,9 +611,9 @@ val url_encode(val str, val space_plus) while ((ch = get_byte(in_byte)) != nil) { int c = c_num(ch); - if (space_plus && c == ' ') - put_char(chr('+'), out); - else if (is_url_reserved(c)) + if (space_plus && c == ' ') + put_char(chr('+'), out); + else if (is_url_reserved(c)) format(out, lit("%~1X~1X"), num_fast(c >> 4), num_fast(c & 0xf), nao); else put_char(chr_num(ch), out); @@ -635,27 +635,27 @@ val url_decode(val str, val space_plus) val ch3 = get_char(in); if (ch2 && ch3 && chr_isxdigit(ch2) && chr_isxdigit(ch3)) { - int byte = digit_value(c_num(ch2)) << 4 | digit_value(c_num(ch3)); - put_byte(num_fast(byte), out); + int byte = digit_value(c_num(ch2)) << 4 | digit_value(c_num(ch3)); + put_byte(num_fast(byte), out); } else { - put_char(ch, out); - if (!ch2) - break; - put_char(ch2, out); - if (!ch3) - break; - put_char(ch3, out); + put_char(ch, out); + if (!ch2) + break; + put_char(ch2, out); + if (!ch3) + break; + put_char(ch3, out); } - continue; + continue; } - if (space_plus && ch == chr('+')) { - put_char(chr(' '), out); - continue; - } - if (!ch) - break; - - put_char(ch, out); + if (space_plus && ch == chr('+')) { + put_char(chr(' '), out); + continue; + } + if (!ch) + break; + + put_char(ch, out); } return get_string_from_stream(out); @@ -42,7 +42,7 @@ static void conversion_error(void) { uw_throw(range_error_s, - lit("encountered utf-8 character that needs full unicode support")); + lit("encountered utf-8 character that needs full unicode support")); } #endif @@ -75,34 +75,34 @@ size_t utf8_from_uc(wchar_t *wdst, const unsigned char *src) if (wdst) *wdst++ = ch; nchar++; - break; + break; case 0xC: case 0xD: state = utf8_more1; wch = (ch & 0x1F); - wch_min = 0x80; - break; + wch_min = 0x80; + break; case 0xE: state = utf8_more2; wch = (ch & 0xF); - wch_min = 0x800; - break; + wch_min = 0x800; + break; case 0xF: #ifdef FULL_UNICODE - if (ch < 0xF5) { - state = utf8_more3; - wch = (ch & 0x7); - wch_min = 0x10000; - break; - } - /* fallthrough */ + if (ch < 0xF5) { + state = utf8_more3; + wch = (ch & 0x7); + wch_min = 0x10000; + break; + } + /* fallthrough */ #else - conversion_error(); + conversion_error(); #endif default: if (wdst) *wdst++ = 0xDC00 | ch; nchar++; - break; + break; } backtrack = src; break; @@ -114,18 +114,18 @@ size_t utf8_from_uc(wchar_t *wdst, const unsigned char *src) wch |= (ch & 0x3F); state = (enum utf8_state) (state - 1); if (state == utf8_init) { - if (wch < wch_min || - (wch <= 0xFFFF && (wch & 0xFF00) == 0xDC00) || - (wch > 0x10FFFF)) - { - src = backtrack; - if (wdst) - *wdst++ = 0xDC00 | *src; - } else { - if (wdst) - *wdst++ = wch; - } - nchar++; + if (wch < wch_min || + (wch <= 0xFFFF && (wch & 0xFF00) == 0xDC00) || + (wch > 0x10FFFF)) + { + src = backtrack; + if (wdst) + *wdst++ = 0xDC00 | *src; + } else { + if (wdst) + *wdst++ = wch; + } + nchar++; } } else { src = backtrack; @@ -166,16 +166,16 @@ size_t utf8_to_uc(unsigned char *dst, const wchar_t *wsrc) } } else if (wch < 0x10000) { if ((wch & 0xFF00) == 0xDC00) { - nbyte += 1; - if (dst) - *dst++ = (wch & 0xFF); + nbyte += 1; + if (dst) + *dst++ = (wch & 0xFF); } else { - nbyte += 3; - if (dst) { - *dst++ = 0xE0 | (wch >> 12); - *dst++ = 0x80 | ((wch >> 6) & 0x3F); - *dst++ = 0x80 | (wch & 0x3F); - } + nbyte += 3; + if (dst) { + *dst++ = 0xE0 | (wch >> 12); + *dst++ = 0x80 | ((wch >> 6) & 0x3F); + *dst++ = 0x80 | (wch & 0x3F); + } } } else if (wch < 0x110000) { nbyte += 4; @@ -242,8 +242,8 @@ int utf8_encode(wchar_t wch, int (*put)(int ch, mem_t *ctx), mem_t *ctx) return put(wch & 0xFF, ctx); } else { return put(0xE0 | (wch >> 12), ctx) && - put(0x80 | ((wch >> 6) & 0x3F), ctx) && - put(0x80 | (wch & 0x3F), ctx); + put(0x80 | ((wch >> 6) & 0x3F), ctx) && + put(0x80 | (wch & 0x3F), ctx); } } else if (wch < 0x110000) { return put(0xF0 | (wch >> 18), ctx) && @@ -297,24 +297,24 @@ wint_t utf8_decode(utf8_decoder_t *ud, int (*get)(mem_t *ctx), mem_t *ctx) case 0xC: case 0xD: ud->state = utf8_more1; ud->wch = (ch & 0x1F); - ud->wch_min = 0x80; - break; + ud->wch_min = 0x80; + break; case 0xE: ud->state = utf8_more2; ud->wch = (ch & 0xF); - ud->wch_min = 0x800; - break; + ud->wch_min = 0x800; + break; case 0xF: #ifdef FULL_UNICODE - if (ch < 0xF5) { - ud->state = utf8_more3; - ud->wch = (ch & 0x7); - ud->wch_min = 0x100000; - break; - } - /* fallthrough */ + if (ch < 0xF5) { + ud->state = utf8_more3; + ud->wch = (ch & 0x7); + ud->wch_min = 0x100000; + break; + } + /* fallthrough */ #else - conversion_error(); + conversion_error(); #endif default: ud->back = ud->tail; @@ -329,17 +329,17 @@ wint_t utf8_decode(utf8_decoder_t *ud, int (*get)(mem_t *ctx), mem_t *ctx) ud->wch |= (ch & 0x3F); ud->state = (enum utf8_state) (ud->state - 1); if (ud->state == utf8_init) { - if (ud->wch < ud->wch_min || - (ud->wch <= 0xFFFF && (ud->wch & 0xFF00) == 0xDC00) || - (ud->wch > 0x10FFFF)) - { - wchar_t wch = 0xDC00 | ud->buf[ud->back]; - ud->tail = ud->back = (ud->back + 1) % 8; - return wch; - } else { - ud->back = ud->tail; - return ud->wch; - } + if (ud->wch < ud->wch_min || + (ud->wch <= 0xFFFF && (ud->wch & 0xFF00) == 0xDC00) || + (ud->wch > 0x10FFFF)) + { + wchar_t wch = 0xDC00 | ud->buf[ud->back]; + ud->tail = ud->back = (ud->back + 1) % 8; + return wch; + } else { + ud->back = ud->tail; + return ud->wch; + } } } else { wchar_t wch = 0xDC00 | ud->buf[ud->back]; |