From c9589217a057869582aa6a5ec1dbd048a525455e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 24 Nov 2009 15:34:11 -0800 Subject: Changes to make the code portable to C++ compilers, which can be taken advantage of for better diagnostics. --- utf8.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'utf8.c') diff --git a/utf8.c b/utf8.c index eedd503d..c5c76761 100644 --- a/utf8.c +++ b/utf8.c @@ -80,8 +80,8 @@ size_t utf8_from_uc(wchar_t *wdst, const unsigned char *src) case utf8_more3: if (ch >= 0x80 && ch < 0xc0) { wch <<= 6; - wch |= (ch & 0x3f); - if (--state == utf8_init) { + state = (enum utf8_state) (state - 1); + if (state == utf8_init) { if (wdst) *wdst++ = wch; nchar++; @@ -261,7 +261,8 @@ wint_t utf8_decode(utf8_decoder_t *ud, int (*get)(void *ctx), void *ctx) if (ch >= 0x80 && ch < 0xc0) { ud->wch <<= 6; ud->wch |= (ch & 0x3f); - if (--ud->state == utf8_init) { + ud->state = (enum utf8_state) (ud->state - 1); + if (ud->state == utf8_init) { ud->back = ud->tail; return ud->wch; } -- cgit v1.2.3