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 <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-09-18 13:49:11 +02:00
parent c63330d9e9
commit 32fec77420
3 changed files with 2 additions and 45 deletions

View File

@ -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

View File

@ -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 */

View File

@ -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;
}