From c38b9be6a4110da99c45ede3a118c49e790beee9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 31 May 2020 12:41:07 +0200 Subject: [PATCH] vt: utf8: don't need one entry action for each UTF8 variant --- vt.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/vt.c b/vt.c index d80a7d86..6472d173 100644 --- a/vt.c +++ b/vt.c @@ -503,24 +503,10 @@ action_put(struct terminal *term, uint8_t c) } static void -action_utf8_2_entry(struct terminal *term, uint8_t c) +action_utf8_entry(struct terminal *term, uint8_t c) { - term->vt.utf8.idx = 0; - term->vt.utf8.data[term->vt.utf8.idx++] = c; -} - -static void -action_utf8_3_entry(struct terminal *term, uint8_t c) -{ - term->vt.utf8.idx = 0; - term->vt.utf8.data[term->vt.utf8.idx++] = c; -} - -static void -action_utf8_4_entry(struct terminal *term, uint8_t c) -{ - term->vt.utf8.idx = 0; - term->vt.utf8.data[term->vt.utf8.idx++] = c; + term->vt.utf8.data[0] = c; + term->vt.utf8.idx = 1; } static void @@ -698,9 +684,9 @@ state_ground_switch(struct terminal *term, uint8_t data) case 0x20 ... 0x7f: action_print(term, data); return STATE_GROUND; - case 0xc0 ... 0xdf: action_utf8_2_entry(term, data); return STATE_UTF8_COLLECT_1; - case 0xe0 ... 0xef: action_utf8_3_entry(term, data); return STATE_UTF8_COLLECT_2; - case 0xf0 ... 0xf7: action_utf8_4_entry(term, data); return STATE_UTF8_COLLECT_3; + case 0xc0 ... 0xdf: action_utf8_entry(term, data); return STATE_UTF8_COLLECT_1; + case 0xe0 ... 0xef: action_utf8_entry(term, data); return STATE_UTF8_COLLECT_2; + case 0xf0 ... 0xf7: action_utf8_entry(term, data); return STATE_UTF8_COLLECT_3; /* Anywhere */ case 0x18: action_execute(term, data); return STATE_GROUND;