diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2013-09-13 08:12:19 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2013-09-13 08:12:19 +0000 |
| commit | 4d8ed02f6d091eb5e45c87a9b355d22298e4551b (patch) | |
| tree | a9ef975e776365718eac1b9666a9acc78d34d29a /src/runtime/c/gu | |
| parent | c469ae9091fb830f0aae1b9abf8ee174a0ac0012 (diff) | |
more UTF8 cleanup
Diffstat (limited to 'src/runtime/c/gu')
| -rw-r--r-- | src/runtime/c/gu/utf8.c | 45 |
1 files changed, 5 insertions, 40 deletions
diff --git a/src/runtime/c/gu/utf8.c b/src/runtime/c/gu/utf8.c index 7d1de584e..38eb91a9f 100644 --- a/src/runtime/c/gu/utf8.c +++ b/src/runtime/c/gu/utf8.c @@ -72,7 +72,10 @@ fail: return 0; } -size_t +extern inline void +gu_out_utf8(GuUCS ucs, GuOut* out, GuExn* err); + +static size_t gu_advance_utf8(GuUCS ucs, uint8_t* buf) { gu_require(gu_ucs_valid(ucs)); @@ -97,6 +100,7 @@ gu_advance_utf8(GuUCS ucs, uint8_t* buf) } } + void gu_out_utf8_(GuUCS ucs, GuOut* out, GuExn* err) { @@ -117,44 +121,5 @@ gu_out_utf8_(GuUCS ucs, GuOut* out, GuExn* err) } } -extern inline void -gu_out_utf8(GuUCS ucs, GuOut* out, GuExn* err); - -static size_t -gu_utf32_out_utf8_buffered_(const GuUCS* src, size_t len, GuOut* out, - GuExn* err) -{ - size_t src_i = 0; - while (src_i < len) { - size_t dst_sz; - uint8_t* dst = gu_out_begin_span(out, len - src_i, &dst_sz, err); - if (!gu_ok(err)) { - return src_i; - } - if (!dst) { - gu_out_utf8(src[src_i], out, err); - if (!gu_ok(err)) { - return src_i; - } - src_i++; - break; - } - size_t dst_i = 0; - while (true) { - size_t safe = (dst_sz - dst_i) / 4; - size_t end = GU_MIN(len, src_i + safe); - if (end == src_i) { - break; - } - do { - GuUCS ucs = src[src_i++]; - dst_i += gu_advance_utf8(ucs, &dst[dst_i]); - } while (src_i < end); - } - gu_out_end_span(out, dst_i); - } - return src_i; -} - extern inline GuUCS gu_in_utf8(GuIn* in, GuExn* err); |
