vt: fix utf-8 bug: re-load 'current state' after processing a utf8 byte

This commit is contained in:
Daniel Eklöf 2019-06-18 21:55:18 +02:00
parent a27868cd9f
commit b8017a36de
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

5
vt.c
View file

@ -187,6 +187,7 @@ action(struct terminal *term, enum action action, uint8_t c)
//LOG_DBG("print: UTF8: %.*s", (int)term->vt.utf8.idx, term->vt.utf8.data);
memcpy(cell->c, term->vt.utf8.data, term->vt.utf8.idx);
cell->c[term->vt.utf8.idx] = '\0';
memset(&term->vt.utf8, 0, sizeof(term->vt.utf8));
} else {
//LOG_DBG("print: ASCII: %c", c);
cell->c[0] = c;
@ -288,10 +289,14 @@ vt_from_slave(struct terminal *term, const uint8_t *data, size_t len)
if (current_state == STATE_UTF8) {
if (!process_utf8(term, data[i]))
abort();
current_state = term->vt.state;
if (current_state == STATE_UTF8)
continue;
if (!action(term, ACTION_PRINT, 0))
abort();
continue;
}