From 8ae745f5b3b868abba4ce394e3e298306d9f3261 Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sat, 6 Nov 2010 14:29:12 +0000 Subject: UTF8 Text Display and Editor: added tons of tests for utf8 alignment, fixed a bunch of methods that did not understand utf8. Still lots of places to visit. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7800 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/fl_utf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/fl_utf.c') diff --git a/src/fl_utf.c b/src/fl_utf.c index 64d715261..b30ca82c4 100644 --- a/src/fl_utf.c +++ b/src/fl_utf.c @@ -151,7 +151,7 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len) } else if (c < 0xc2) { goto FAIL; } - if (p+1 >= end || (p[1]&0xc0) != 0x80) goto FAIL; + if ( (end && p+1 >= end) || (p[1]&0xc0) != 0x80) goto FAIL; if (c < 0xe0) { if (len) *len = 2; return @@ -173,7 +173,7 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len) #endif } else if (c < 0xf0) { UTF8_3: - if (p+2 >= end || (p[2]&0xc0) != 0x80) goto FAIL; + if ( (end && p+2 >= end) || (p[2]&0xc0) != 0x80) goto FAIL; if (len) *len = 3; return ((p[0] & 0x0f) << 12) + @@ -184,7 +184,7 @@ unsigned fl_utf8decode(const char* p, const char* end, int* len) goto UTF8_4; } else if (c < 0xf4) { UTF8_4: - if (p+3 >= end || (p[2]&0xc0) != 0x80 || (p[3]&0xc0) != 0x80) goto FAIL; + if ( (end && p+3 >= end) || (p[2]&0xc0) != 0x80 || (p[3]&0xc0) != 0x80) goto FAIL; if (len) *len = 4; #if STRICT_RFC3629 /* RFC 3629 says all codes ending in fffe or ffff are illegal: */ -- cgit v1.2.3