From fee983d9fce89fbdcf7d12aed0caab2bd350c204 Mon Sep 17 00:00:00 2001 From: Emanuele Giaquinta Date: Sun, 9 Mar 2008 16:41:20 +0000 Subject: [PATCH] Replace usage of get_utf8_char with g_utf8_get_char_validated. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4742 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/fe-text/term-terminfo.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c index 4b8d7938..f364e76b 100644 --- a/src/fe-text/term-terminfo.c +++ b/src/fe-text/term-terminfo.c @@ -555,18 +555,19 @@ void term_stop(void) static int input_utf8(const unsigned char *buffer, int size, unichar *result) { - const unsigned char *end = buffer; + unichar c = g_utf8_get_char_validated(buffer, size); - switch (get_utf8_char(&end, size, result)) { - case -2: + switch (c) { + case (unichar)-1: /* not UTF8 - fallback to 8bit ascii */ *result = *buffer; return 1; - case -1: + case (unichar)-2: /* need more data */ return -1; default: - return (int) (end-buffer)+1; + *result = c; + return g_utf8_skip[*buffer]; } }