From 32fec774203179e093ded0e47524a6cd361999bd Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Tue, 18 Sep 2012 13:49:11 +0200 Subject: [PATCH] tsm: unicode: remove tsm_symbol_get_u8() This is no longer used. You should first retrieve the UCS4 string and then use the UCS4 to U8 conversion helpers instead. All users have already been converted so we can remove this helper safely. Signed-off-by: David Herrmann --- src/tsm_unicode.c | 36 ------------------------------------ src/tsm_unicode.h | 3 --- src/vte.c | 8 ++------ 3 files changed, 2 insertions(+), 45 deletions(-) diff --git a/src/tsm_unicode.c b/src/tsm_unicode.c index 025a80f..f99cb70 100644 --- a/src/tsm_unicode.c +++ b/src/tsm_unicode.c @@ -97,7 +97,6 @@ */ const tsm_symbol_t tsm_symbol_default = 0; -static const char default_u8[] = { 0 }; struct tsm_symbol_table { unsigned long ref; @@ -322,41 +321,6 @@ err_id: return sym; } -const char *tsm_symbol_get_u8(struct tsm_symbol_table *tbl, - tsm_symbol_t sym, size_t *size) -{ - const uint32_t *ucs4; - char *val; - size_t i, pos, len; - - ucs4 = tsm_symbol_get(tbl, &sym, &len); - val = malloc(4 * len); - if (!val) - goto err_out; - - pos = 0; - for (i = 0; i < len; ++i) - pos += tsm_ucs4_to_utf8(ucs4[i], &val[pos]); - - if (!pos) - goto err_out; - - if (size) - *size = pos; - return val; - -err_out: - if (size) - *size = sizeof(default_u8); - return default_u8; -} - -void tsm_symbol_free_u8(const char *s) -{ - if (s != default_u8) - free((void*)s); -} - /* * Convert UCS4 character to UTF-8. This creates one of: * 0xxxxxxx diff --git a/src/tsm_unicode.h b/src/tsm_unicode.h index 74858d8..07633e1 100644 --- a/src/tsm_unicode.h +++ b/src/tsm_unicode.h @@ -59,9 +59,6 @@ tsm_symbol_t tsm_symbol_append(struct tsm_symbol_table *tbl, tsm_symbol_t sym, uint32_t ucs4); const uint32_t *tsm_symbol_get(struct tsm_symbol_table *tbl, tsm_symbol_t *sym, size_t *size); -const char *tsm_symbol_get_u8(struct tsm_symbol_table *tbl, - tsm_symbol_t sym, size_t *size); -void tsm_symbol_free_u8(const char *s); /* ucs4 to utf8 converter */ diff --git a/src/vte.c b/src/vte.c index b4b48bc..b5c02ba 100644 --- a/src/vte.c +++ b/src/vte.c @@ -2126,10 +2126,8 @@ void kmscon_vte_input(struct kmscon_vte *vte, const char *u8, size_t len) bool kmscon_vte_handle_keyboard(struct kmscon_vte *vte, uint32_t keysym, unsigned int mods, uint32_t unicode) { - tsm_symbol_t sym; - char val; + char val, u8[4]; size_t len; - const char *u8; /* MOD1 (mostly labeled 'Alt') prepends an escape character to every * input that is sent by a key. @@ -2621,10 +2619,8 @@ bool kmscon_vte_handle_keyboard(struct kmscon_vte *vte, uint32_t keysym, } vte_write_raw(vte, &val, 1); } else { - sym = tsm_symbol_make(unicode); - u8 = tsm_symbol_get_u8(NULL, sym, &len); + len = tsm_ucs4_to_utf8(tsm_symbol_make(unicode), u8); vte_write_raw(vte, u8, len); - tsm_symbol_free_u8(u8); } return true; }