Fossil SCM

Latest upstream pikchr.c to enable HTML entities which contain digits.

stephan 2022-06-14 17:42 trunk
Commit b1ffe209f3c40ed1b6d2a9c398e2780da8bdf0716bde304d874eec52968f67a4
+8 -4
--- extsrc/pikchr.c
+++ extsrc/pikchr.c
@@ -4538,11 +4538,12 @@
45384538
/*
45394539
** Given a string and its length, returns true if the string begins
45404540
** with a construct which syntactically matches an HTML entity escape
45414541
** sequence (without checking for whether it's a known entity). Always
45424542
** returns false if zText[0] is false or n<4. Entities match the
4543
-** equivalent of the regexes `&#[0-9]+;` and `&[a-zA-Z]+;`.
4543
+** equivalent of the regexes `&#[0-9]{2,};` and
4544
+** `&[a-zA-Z][a-zA-Z0-9]+;`.
45444545
*/
45454546
static int pik_isentity(char const * zText, int n){
45464547
int i = 0;
45474548
if( n<4 || '&'!=zText[0] ) return 0;
45484549
n--;
@@ -4551,15 +4552,18 @@
45514552
zText++;
45524553
n--;
45534554
for(i=0; i<n; i++){
45544555
if( i>1 && ';'==zText[i] ) return 1;
45554556
else if( zText[i]<'0' || zText[i]>'9' ) return 0;
4557
+ /* Note that &#nn; values nn<32d are not legal entities. */
45564558
}
45574559
}else{
4558
- for( i=0; i<n; i++ ){
4560
+ for(i=0; i<n; i++){
45594561
if( i>1 && ';'==zText[i] ) return 1;
4560
- else if( zText[i]<'A' || zText[i]>'z'
4562
+ else if( i>0 && zText[i]>='0' && zText[i]<='9' ){
4563
+ continue;
4564
+ }else if( zText[i]<'A' || zText[i]>'z'
45614565
|| (zText[i]>'Z' && zText[i]<'a') ) return 0;
45624566
}
45634567
}
45644568
return 0;
45654569
}
@@ -8127,6 +8131,6 @@
81278131
81288132
81298133
#endif /* PIKCHR_TCL */
81308134
81318135
8132
-#line 8157 "pikchr.c"
8136
+#line 8161 "pikchr.c"
81338137
--- extsrc/pikchr.c
+++ extsrc/pikchr.c
@@ -4538,11 +4538,12 @@
4538 /*
4539 ** Given a string and its length, returns true if the string begins
4540 ** with a construct which syntactically matches an HTML entity escape
4541 ** sequence (without checking for whether it's a known entity). Always
4542 ** returns false if zText[0] is false or n<4. Entities match the
4543 ** equivalent of the regexes `&#[0-9]+;` and `&[a-zA-Z]+;`.
 
4544 */
4545 static int pik_isentity(char const * zText, int n){
4546 int i = 0;
4547 if( n<4 || '&'!=zText[0] ) return 0;
4548 n--;
@@ -4551,15 +4552,18 @@
4551 zText++;
4552 n--;
4553 for(i=0; i<n; i++){
4554 if( i>1 && ';'==zText[i] ) return 1;
4555 else if( zText[i]<'0' || zText[i]>'9' ) return 0;
 
4556 }
4557 }else{
4558 for( i=0; i<n; i++ ){
4559 if( i>1 && ';'==zText[i] ) return 1;
4560 else if( zText[i]<'A' || zText[i]>'z'
 
 
4561 || (zText[i]>'Z' && zText[i]<'a') ) return 0;
4562 }
4563 }
4564 return 0;
4565 }
@@ -8127,6 +8131,6 @@
8127
8128
8129 #endif /* PIKCHR_TCL */
8130
8131
8132 #line 8157 "pikchr.c"
8133
--- extsrc/pikchr.c
+++ extsrc/pikchr.c
@@ -4538,11 +4538,12 @@
4538 /*
4539 ** Given a string and its length, returns true if the string begins
4540 ** with a construct which syntactically matches an HTML entity escape
4541 ** sequence (without checking for whether it's a known entity). Always
4542 ** returns false if zText[0] is false or n<4. Entities match the
4543 ** equivalent of the regexes `&#[0-9]{2,};` and
4544 ** `&[a-zA-Z][a-zA-Z0-9]+;`.
4545 */
4546 static int pik_isentity(char const * zText, int n){
4547 int i = 0;
4548 if( n<4 || '&'!=zText[0] ) return 0;
4549 n--;
@@ -4551,15 +4552,18 @@
4552 zText++;
4553 n--;
4554 for(i=0; i<n; i++){
4555 if( i>1 && ';'==zText[i] ) return 1;
4556 else if( zText[i]<'0' || zText[i]>'9' ) return 0;
4557 /* Note that &#nn; values nn<32d are not legal entities. */
4558 }
4559 }else{
4560 for(i=0; i<n; i++){
4561 if( i>1 && ';'==zText[i] ) return 1;
4562 else if( i>0 && zText[i]>='0' && zText[i]<='9' ){
4563 continue;
4564 }else if( zText[i]<'A' || zText[i]>'z'
4565 || (zText[i]>'Z' && zText[i]<'a') ) return 0;
4566 }
4567 }
4568 return 0;
4569 }
@@ -8127,6 +8131,6 @@
8131
8132
8133 #endif /* PIKCHR_TCL */
8134
8135
8136 #line 8161 "pikchr.c"
8137
--- extsrc/pikchr.wasm
+++ extsrc/pikchr.wasm
cannot compute difference between binary files
11
--- extsrc/pikchr.wasm
+++ extsrc/pikchr.wasm
0 annot compute difference between binary files
1
--- extsrc/pikchr.wasm
+++ extsrc/pikchr.wasm
0 annot compute difference between binary files
1

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button