From 30f37feb57878fb096271d1938853753ad98576a Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Fri, 13 Sep 2013 07:44:45 +0000 Subject: [PATCH] clean up the UTF8 API in libgu --- src/runtime/c/gu/out.c | 4 ++-- src/runtime/c/gu/utf8.c | 41 +---------------------------------------- src/runtime/c/gu/utf8.h | 16 ++-------------- 3 files changed, 5 insertions(+), 56 deletions(-) diff --git a/src/runtime/c/gu/out.c b/src/runtime/c/gu/out.c index 711aac4fd..36d523c44 100644 --- a/src/runtime/c/gu/out.c +++ b/src/runtime/c/gu/out.c @@ -253,7 +253,7 @@ gu_putc(char c, GuOut* out, GuExn* err); void gu_puts(const char* str, GuOut* out, GuExn* err) { - gu_str_out_utf8(str, out, err); + gu_out_bytes(out, (const uint8_t*) str, strlen(str), err); } void @@ -261,7 +261,7 @@ gu_vprintf(const char* fmt, va_list args, GuOut* out, GuExn* err) { GuPool* tmp_pool = gu_local_pool(); char* str = gu_vasprintf(fmt, args, tmp_pool); - gu_str_out_utf8(str, out, err); + gu_out_bytes(out, (const uint8_t*) str, strlen(str), err); gu_pool_free(tmp_pool); } diff --git a/src/runtime/c/gu/utf8.c b/src/runtime/c/gu/utf8.c index 0c24ef20e..7d1de584e 100644 --- a/src/runtime/c/gu/utf8.c +++ b/src/runtime/c/gu/utf8.c @@ -97,25 +97,8 @@ gu_advance_utf8(GuUCS ucs, uint8_t* buf) } } -char -gu_in_utf8_char_(GuIn* in, GuExn* err) -{ - return gu_ucs_char(gu_in_utf8(in, err), err); -} - -char -gu_in_utf8_char(GuIn* in, GuExn* err) -{ - int i = gu_in_peek_u8(in); - if (i >= 0 && i < 0x80) { - gu_in_consume(in, 1); - return (char) i; - } - return gu_in_utf8_char_(in, err); -} - void -gu_out_utf8_long_(GuUCS ucs, GuOut* out, GuExn* err) +gu_out_utf8_(GuUCS ucs, GuOut* out, GuExn* err) { uint8_t buf[4]; size_t sz = gu_advance_utf8(ucs, buf); @@ -173,27 +156,5 @@ gu_utf32_out_utf8_buffered_(const GuUCS* src, size_t len, GuOut* out, return src_i; } -size_t -gu_utf32_out_utf8(const GuUCS* src, size_t len, GuOut* out, GuExn* err) -{ - if (gu_out_is_buffered(out)) { - return gu_utf32_out_utf8_buffered_(src, len, out, err); - } - for (size_t i = 0; i < len; i++) { - gu_out_utf8(src[i], out, err); - if (!gu_ok(err)) { - return i; - } - } - return len; - -} - extern inline GuUCS gu_in_utf8(GuIn* in, GuExn* err); - -void -gu_str_out_utf8(const char* str, GuOut* out, GuExn* err) -{ - gu_out_bytes(out, (const uint8_t*) str, strlen(str), err); -} diff --git a/src/runtime/c/gu/utf8.h b/src/runtime/c/gu/utf8.h index 410010c3f..7cf42d56a 100644 --- a/src/runtime/c/gu/utf8.h +++ b/src/runtime/c/gu/utf8.h @@ -17,13 +17,6 @@ gu_in_utf8(GuIn* in, GuExn* err) return gu_in_utf8_(in, err); } - -char -gu_in_utf8_char(GuIn* in, GuExn* err); - -void -gu_out_utf8_long_(GuUCS ucs, GuOut* out, GuExn* err); - inline void gu_out_utf8(GuUCS ucs, GuOut* out, GuExn* err) { @@ -31,17 +24,12 @@ gu_out_utf8(GuUCS ucs, GuOut* out, GuExn* err) if (GU_LIKELY(ucs < 0x80)) { gu_out_u8(out, ucs, err); } else { - gu_out_utf8_long_(ucs, out, err); + extern void gu_out_utf8_(GuUCS ucs, GuOut* out, GuExn* err); + gu_out_utf8_(ucs, out, err); } } -size_t -gu_utf32_out_utf8(const GuUCS* src, size_t len, GuOut* out, GuExn* err); - GuUCS gu_utf8_decode(const uint8_t** utf8); -void -gu_str_out_utf8(const char* str, GuOut* out, GuExn* err); - #endif // GU_UTF8_H_