Fossil SCM

Fix interpretation of '+' or '-' as valid integers. Noted on ML by Sergei Gavrikov. Thanks!

jan.nijtmans 2015-04-01 08:52 trunk
Commit 4ae42e363c585f785416448cffd35d58a7dfc170
1 file changed +14 -16
+14 -16
--- src/th.c
+++ src/th.c
@@ -2646,28 +2646,26 @@
26462646
26472647
if( n<0 ){
26482648
n = th_strlen(z);
26492649
}
26502650
2651
- if( n>0 && (z[0]=='-' || z[0]=='+') ){
2651
+ if( n>1 && (z[0]=='-' || z[0]=='+') ){
26522652
i = 1;
26532653
}
2654
- if( n>2 ){
2655
- if( z[i]=='0' ){
2656
- if( z[i+1]=='x' || z[i+1]=='X' ){
2657
- i += 2;
2658
- base = 16;
2659
- isdigit = th_ishexdig;
2660
- }else if( z[i+1]=='o' || z[i+1]=='O' ){
2661
- i += 2;
2662
- base = 8;
2663
- isdigit = th_isoctdig;
2664
- }else if( z[i+1]=='b' || z[i+1]=='B' ){
2665
- i += 2;
2666
- base = 2;
2667
- isdigit = th_isbindig;
2668
- }
2654
+ if( n>2 && z[i]=='0'){
2655
+ if( z[i+1]=='x' || z[i+1]=='X' ){
2656
+ i += 2;
2657
+ base = 16;
2658
+ isdigit = th_ishexdig;
2659
+ }else if( z[i+1]=='o' || z[i+1]=='O' ){
2660
+ i += 2;
2661
+ base = 8;
2662
+ isdigit = th_isoctdig;
2663
+ }else if( z[i+1]=='b' || z[i+1]=='B' ){
2664
+ i += 2;
2665
+ base = 2;
2666
+ isdigit = th_isbindig;
26692667
}
26702668
}
26712669
for(; i<n; i++){
26722670
char c = z[i];
26732671
if( !isdigit(c) ){
26742672
--- src/th.c
+++ src/th.c
@@ -2646,28 +2646,26 @@
2646
2647 if( n<0 ){
2648 n = th_strlen(z);
2649 }
2650
2651 if( n>0 && (z[0]=='-' || z[0]=='+') ){
2652 i = 1;
2653 }
2654 if( n>2 ){
2655 if( z[i]=='0' ){
2656 if( z[i+1]=='x' || z[i+1]=='X' ){
2657 i += 2;
2658 base = 16;
2659 isdigit = th_ishexdig;
2660 }else if( z[i+1]=='o' || z[i+1]=='O' ){
2661 i += 2;
2662 base = 8;
2663 isdigit = th_isoctdig;
2664 }else if( z[i+1]=='b' || z[i+1]=='B' ){
2665 i += 2;
2666 base = 2;
2667 isdigit = th_isbindig;
2668 }
2669 }
2670 }
2671 for(; i<n; i++){
2672 char c = z[i];
2673 if( !isdigit(c) ){
2674
--- src/th.c
+++ src/th.c
@@ -2646,28 +2646,26 @@
2646
2647 if( n<0 ){
2648 n = th_strlen(z);
2649 }
2650
2651 if( n>1 && (z[0]=='-' || z[0]=='+') ){
2652 i = 1;
2653 }
2654 if( n>2 && z[i]=='0'){
2655 if( z[i+1]=='x' || z[i+1]=='X' ){
2656 i += 2;
2657 base = 16;
2658 isdigit = th_ishexdig;
2659 }else if( z[i+1]=='o' || z[i+1]=='O' ){
2660 i += 2;
2661 base = 8;
2662 isdigit = th_isoctdig;
2663 }else if( z[i+1]=='b' || z[i+1]=='B' ){
2664 i += 2;
2665 base = 2;
2666 isdigit = th_isbindig;
 
 
2667 }
2668 }
2669 for(; i<n; i++){
2670 char c = z[i];
2671 if( !isdigit(c) ){
2672

Keyboard Shortcuts

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