[Commit] jove insert.c,1.9,1.10 stdio.c,1.1.1.1,1.2
Keith Packard
commit at keithp.com
Sun Apr 2 20:41:40 PDT 2006
Committed by: keithp
Update of /local/src/CVS/jove
In directory home.keithp.com:/tmp/cvs-serv20400
Modified Files:
insert.c stdio.c
Log Message:
Validate UTF-8 sequences, add sqrt to compose
Index: insert.c
===================================================================
RCS file: /local/src/CVS/jove/insert.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- insert.c 20 Dec 2004 01:13:39 -0000 1.9
+++ insert.c 3 Apr 2006 03:41:37 -0000 1.10
@@ -491,7 +491,7 @@
/* Mathematical operators */
"V-:âdi:â E:â/E:â /:âsq:âoo:âin:â«~~:â/=:â <=:â¤>=:⥠-:â ~:â¼ |:â£/|:â¤||:â¥=~:â~=:â"
/* Geometric Shapes */
-"<>:â"
+"<>:â\\/:â"
/* Miscellaneous Symbols */
":(:â¹:):âº"
/* Alphabetic Presentation Forms */
Index: stdio.c
===================================================================
RCS file: /local/src/CVS/jove/stdio.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- stdio.c 10 Mar 2001 12:23:12 -0000 1.1.1.1
+++ stdio.c 3 Apr 2006 03:41:38 -0000 1.2
@@ -32,6 +32,8 @@
register char *cp = buf;
register int c;
char *endp = buf + max - 1;
+ char *high = 0;
+ int nutf8;
while (((c = getc(fp)) != EOF) && (c != '\n')) {
io_chars++;
@@ -43,8 +45,41 @@
add_mess(" [Line too long]");
cp++;
} else if (cp < endp)
+ {
+ if (high)
+ {
+ if ((c & 0xc0) != 0x80)
+ {
+ add_mess (" [Invalid UTF-8 sequence]");
+ cp = high;
+ high = 0;
+ nutf8 = 0;
+ continue;
+ }
+ if (--nutf8 == 0)
+ high = 0;
+ }
+ else if ((c & 0xc0) == 0xc0)
+ {
+ int m = 0x20;
+
+ high = cp;
+ nutf8 = 1;
+ while ((c & m))
+ {
+ nutf8++;
+ m >>= 1;
+ }
+ }
*cp++ = c;
+ }
+ }
+ if (high)
+ {
+ add_mess (" [Invalid UTF-8 sequence]");
+ cp = high;
}
+
*cp = '\0';
if (c == EOF) {
if (cp != buf)
More information about the Commit
mailing list