summaryrefslogtreecommitdiff
path: root/src/fl_utf.c
diff options
context:
space:
mode:
authorMatthias Melcher <fltk@matthiasm.com>2010-11-06 14:29:12 +0000
committerMatthias Melcher <fltk@matthiasm.com>2010-11-06 14:29:12 +0000
commit8ae745f5b3b868abba4ce394e3e298306d9f3261 (patch)
treeda9046cd2faf26ee7a07526abc811a8dfac40807 /src/fl_utf.c
parentd1a09ad73c18d321c56c050a2352d29ef22068d3 (diff)
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
Diffstat (limited to 'src/fl_utf.c')
-rw-r--r--src/fl_utf.c6
1 files changed, 3 insertions, 3 deletions
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: */