Enlightenment CVS committal
Author : raster
Project : e17
Module : libs/evas
Dir : e17/libs/evas/src/lib/engines/common
Modified Files:
evas_font_main.c
Log Message:
evas utf8 patch broke e17's about box. revert
===================================================================
RCS file: /cvs/e/e17/libs/evas/src/lib/engines/common/evas_font_main.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -3 -r1.25 -r1.26
--- evas_font_main.c 31 Oct 2006 23:43:06 -0000 1.25
+++ evas_font_main.c 1 Nov 2006 12:56:12 -0000 1.26
@@ -120,34 +120,34 @@
* the decoded code point at iindex offset, and advances iindex
* to the next code point after this.
*
- * Returns 0 to indicate there is no next char
+ * Returns 0 to indicate an error (e.g. invalid UTF8)
*/
- int index = *iindex, len, r;
+ int index = *iindex, r;
unsigned char d, d2, d3, d4;
d = buf[index++];
if (!d)
return 0;
-
- while (buf[index] && ((buf[index] & 0xc0) == 0x80))
- index++;
- len = index - *iindex;
-
- if (len == 1)
- r = d;
- else if (len == 2)
+ if (d < 0x80)
{
- /* 2 bytes */
- d2 = buf[*iindex + 1];
+ *iindex = index;
+ return d;
+ }
+ if ((d & 0xe0) == 0xc0)
+ {
+ /* 2 byte */
+ if (((d2 = buf[index++]) & 0xc0) != 0x80)
+ return 0;
r = d & 0x1f; /* copy lower 5 */
r <<= 6;
r |= (d2 & 0x3f); /* copy lower 6 */
}
- else if (len == 3)
+ else if ((d & 0xf0) == 0xe0)
{
- /* 3 bytes */
- d2 = buf[*iindex + 1];
- d3 = buf[*iindex + 2];
+ /* 3 byte */
+ if (((d2 = buf[index++]) & 0xc0) != 0x80 ||
+ ((d3 = buf[index++]) & 0xc0) != 0x80)
+ return 0;
r = d & 0x0f; /* copy lower 4 */
r <<= 6;
r |= (d2 & 0x3f);
@@ -156,10 +156,11 @@
}
else
{
- /* 4 bytes */
- d2 = buf[*iindex + 1];
- d3 = buf[*iindex + 2];
- d4 = buf[*iindex + 3];
+ /* 4 byte */
+ if (((d2 = buf[index++]) & 0xc0) != 0x80 ||
+ ((d3 = buf[index++]) & 0xc0) != 0x80 ||
+ ((d4 = buf[index++]) & 0xc0) != 0x80)
+ return 0;
r = d & 0x0f; /* copy lower 4 */
r <<= 6;
r |= (d2 & 0x3f);
@@ -168,7 +169,6 @@
r <<= 6;
r |= (d4 & 0x3f);
}
-
*iindex = index;
return r;
}
@@ -177,37 +177,37 @@
evas_common_font_utf8_get_prev(unsigned char *buf, int *iindex)
{
/* Reads UTF8 bytes from @buf, starting at [EMAIL PROTECTED] and returns
- * the decoded code point at iindex offset, and advances iindex
- * to the prev code point after this.
+ * the decoded code point at iindex offset, and advances iidnex
+ * to the next code point after this.
*
- * Returns 0 to indicate there is no prev char
+ * Returns 0 to indicate an error (e.g. invalid UTF8)
*/
- int index = *iindex, len, r;
+ int index = *iindex, r, istart = *iindex;
unsigned char d, d2, d3, d4;
- if (iindex <= 0)
- return 0;
- d = buf[index--];
-
- while ((index >= 0) && ((buf[index] & 0xc0) == 0x80))
- index--;
- len = index - *iindex;
-
- if (len == 1)
- r = d;
- else if (len == 2)
+ d = buf[index++];
+ if (d < 0x80)
+ {
+ r = d;
+ }
+ else if ((d & 0xe0) == 0xc0)
{
- /* 2 bytes */
- d2 = buf[*iindex + 1];
+ /* 2 byte */
+ d2 = buf[index++];
+ if ((d2 & 0xc0) != 0x80)
+ return 0;
r = d & 0x1f; /* copy lower 5 */
r <<= 6;
r |= (d2 & 0x3f); /* copy lower 6 */
}
- else if (len == 3)
+ else if ((d & 0xf0) == 0xe0)
{
- /* 3 bytes */
- d2 = buf[*iindex + 1];
- d3 = buf[*iindex + 2];
+ /* 3 byte */
+ d2 = buf[index++];
+ d3 = buf[index++];
+ if ((d2 & 0xc0) != 0x80 ||
+ (d3 & 0xc0) != 0x80)
+ return 0;
r = d & 0x0f; /* copy lower 4 */
r <<= 6;
r |= (d2 & 0x3f);
@@ -216,10 +216,14 @@
}
else
{
- /* 4 bytes */
- d2 = buf[*iindex + 1];
- d3 = buf[*iindex + 2];
- d4 = buf[*iindex + 3];
+ /* 4 byte */
+ d2 = buf[index++];
+ d3 = buf[index++];
+ d4 = buf[index++];
+ if ((d2 & 0xc0) != 0x80 ||
+ (d3 & 0xc0) != 0x80 ||
+ (d4 & 0xc0) != 0x80)
+ return 0;
r = d & 0x0f; /* copy lower 4 */
r <<= 6;
r |= (d2 & 0x3f);
@@ -228,8 +232,30 @@
r <<= 6;
r |= (d4 & 0x3f);
}
-
- *iindex = index;
+ if (istart > 0)
+ {
+ index = istart - 1;
+ d = buf[index];
+ if (!(d & 0x80))
+ *iindex = index;
+ else
+ {
+ while (index > 0)
+ {
+ index--;
+ d = buf[index];
+ if ((d & 0xc0) != 0x80)
+ {
+ *iindex = index;
+ return r;
+ }
+ }
+ }
+ }
+ else
+ {
+ *iindex = -1;
+ }
return r;
}
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs