From 79e7a4bbf7055e33b346564db769f03e85f98988 Mon Sep 17 00:00:00 2001
From: Vicent Marti <tanoku@gmail.com>
Date: Wed, 10 Sep 2014 19:40:40 +0200
Subject: Improve invalid UTF8 codepoint skipping

---
 src/utf8.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'src')

diff --git a/src/utf8.c b/src/utf8.c
index 1b0224b..6b34831 100644
--- a/src/utf8.c
+++ b/src/utf8.c
@@ -79,14 +79,14 @@ void utf8proc_detab(strbuf *ob, const uint8_t *line, size_t size)
 		} else {
 			int charlen = utf8proc_charlen(line + i, size - i);
 
-			if (charlen < 0) {
-				encode_unknown(ob);
-				i++;
-			} else {
+			if (charlen >= 0) {
 				strbuf_put(ob, line + i, charlen);
-				i += charlen;
+			} else {
+				encode_unknown(ob);
+				charlen = -charlen;
 			}
 
+			i += charlen;
 			tab += 1;
 		}
 	}
-- 
cgit v1.2.3