Fossil SCM

Add 'double' and 'integer' classes to the 'string is' command in TH1.

mistachkin 2015-07-15 00:54 trunk
Commit 5e9c7a4a7844e3515e2324464f859db975c25b4b
+14 -1
--- src/th_lang.c
+++ src/th_lang.c
@@ -736,17 +736,30 @@
736736
iRes = 0;
737737
}
738738
}
739739
740740
return Th_SetResultInt(interp, iRes);
741
+ }else if( argl[2]==6 && 0==memcmp(argv[2], "double", 6) ){
742
+ double fVal;
743
+ if( Th_ToDouble(interp, argv[3], argl[3], &fVal)==TH_OK ){
744
+ return Th_SetResultInt(interp, 1);
745
+ }
746
+ return Th_SetResultInt(interp, 0);
747
+ }else if( argl[2]==7 && 0==memcmp(argv[2], "integer", 7) ){
748
+ int iVal;
749
+ if( Th_ToInt(interp, argv[3], argl[3], &iVal)==TH_OK ){
750
+ return Th_SetResultInt(interp, 1);
751
+ }
752
+ return Th_SetResultInt(interp, 0);
741753
}else if( argl[2]==4 && 0==memcmp(argv[2], "list", 4) ){
742754
if( Th_SplitList(interp, argv[3], argl[3], 0, 0, 0)==TH_OK ){
743755
return Th_SetResultInt(interp, 1);
744756
}
745757
return Th_SetResultInt(interp, 0);
746758
}else{
747
- Th_ErrorMessage(interp, "Expected alnum or list, got:", argv[2], argl[2]);
759
+ Th_ErrorMessage(interp,
760
+ "Expected alnum, double, integer, or list, got:", argv[2], argl[2]);
748761
return TH_ERROR;
749762
}
750763
}
751764
752765
/*
753766
--- src/th_lang.c
+++ src/th_lang.c
@@ -736,17 +736,30 @@
736 iRes = 0;
737 }
738 }
739
740 return Th_SetResultInt(interp, iRes);
 
 
 
 
 
 
 
 
 
 
 
 
741 }else if( argl[2]==4 && 0==memcmp(argv[2], "list", 4) ){
742 if( Th_SplitList(interp, argv[3], argl[3], 0, 0, 0)==TH_OK ){
743 return Th_SetResultInt(interp, 1);
744 }
745 return Th_SetResultInt(interp, 0);
746 }else{
747 Th_ErrorMessage(interp, "Expected alnum or list, got:", argv[2], argl[2]);
 
748 return TH_ERROR;
749 }
750 }
751
752 /*
753
--- src/th_lang.c
+++ src/th_lang.c
@@ -736,17 +736,30 @@
736 iRes = 0;
737 }
738 }
739
740 return Th_SetResultInt(interp, iRes);
741 }else if( argl[2]==6 && 0==memcmp(argv[2], "double", 6) ){
742 double fVal;
743 if( Th_ToDouble(interp, argv[3], argl[3], &fVal)==TH_OK ){
744 return Th_SetResultInt(interp, 1);
745 }
746 return Th_SetResultInt(interp, 0);
747 }else if( argl[2]==7 && 0==memcmp(argv[2], "integer", 7) ){
748 int iVal;
749 if( Th_ToInt(interp, argv[3], argl[3], &iVal)==TH_OK ){
750 return Th_SetResultInt(interp, 1);
751 }
752 return Th_SetResultInt(interp, 0);
753 }else if( argl[2]==4 && 0==memcmp(argv[2], "list", 4) ){
754 if( Th_SplitList(interp, argv[3], argl[3], 0, 0, 0)==TH_OK ){
755 return Th_SetResultInt(interp, 1);
756 }
757 return Th_SetResultInt(interp, 0);
758 }else{
759 Th_ErrorMessage(interp,
760 "Expected alnum, double, integer, or list, got:", argv[2], argl[2]);
761 return TH_ERROR;
762 }
763 }
764
765 /*
766
+66 -1
--- test/th1.test
+++ test/th1.test
@@ -1035,11 +1035,11 @@
10351035
10361036
###############################################################################
10371037
10381038
fossil test-th-eval {string is other 123}
10391039
test th1-string-is-4 {$RESULT eq \
1040
-"TH_ERROR: Expected alnum or list, got: other"}
1040
+"TH_ERROR: Expected alnum, double, integer, or list, got: other"}
10411041
10421042
###############################################################################
10431043
10441044
fossil test-th-eval {string is alnum 123}
10451045
test th1-string-is-5 {$RESULT eq "1"}
@@ -1106,5 +1106,70 @@
11061106
11071107
###############################################################################
11081108
11091109
fossil test-th-eval {string is list "1 2 3 \{\{\}"}
11101110
test th1-string-is-18 {$RESULT eq "0"}
1111
+
1112
+###############################################################################
1113
+
1114
+fossil test-th-eval {string is double 123}
1115
+test th1-string-is-19 {$RESULT eq "1"}
1116
+
1117
+###############################################################################
1118
+
1119
+fossil test-th-eval {string is double 123.456}
1120
+test th1-string-is-20 {$RESULT eq "1"}
1121
+
1122
+###############################################################################
1123
+
1124
+fossil test-th-eval {string is double 123abc}
1125
+test th1-string-is-21 {$RESULT eq "0"}
1126
+
1127
+###############################################################################
1128
+
1129
+fossil test-th-eval {string is double 123_456}
1130
+test th1-string-is-22 {$RESULT eq "0"}
1131
+
1132
+###############################################################################
1133
+
1134
+fossil test-th-eval {string is integer 123}
1135
+test th1-string-is-23 {$RESULT eq "1"}
1136
+
1137
+###############################################################################
1138
+
1139
+fossil test-th-eval {string is integer 123.456}
1140
+test th1-string-is-24 {$RESULT eq "0"}
1141
+
1142
+###############################################################################
1143
+
1144
+fossil test-th-eval {string is integer 123abc}
1145
+test th1-string-is-25 {$RESULT eq "0"}
1146
+
1147
+###############################################################################
1148
+
1149
+fossil test-th-eval {string is integer 0b11001001}
1150
+test th1-string-is-26 {$RESULT eq "1"}
1151
+
1152
+###############################################################################
1153
+
1154
+fossil test-th-eval {string is integer 0b11001002}
1155
+test th1-string-is-27 {$RESULT eq "0"}
1156
+
1157
+###############################################################################
1158
+
1159
+fossil test-th-eval {string is integer 0o777}
1160
+test th1-string-is-28 {$RESULT eq "1"}
1161
+
1162
+###############################################################################
1163
+
1164
+fossil test-th-eval {string is integer 0o778}
1165
+test th1-string-is-29 {$RESULT eq "0"}
1166
+
1167
+###############################################################################
1168
+
1169
+fossil test-th-eval {string is integer 0xC0DEF00D}
1170
+test th1-string-is-30 {$RESULT eq "1"}
1171
+
1172
+###############################################################################
1173
+
1174
+fossil test-th-eval {string is integer 0xC0DEF00Z}
1175
+test th1-string-is-31 {$RESULT eq "0"}
11111176
--- test/th1.test
+++ test/th1.test
@@ -1035,11 +1035,11 @@
1035
1036 ###############################################################################
1037
1038 fossil test-th-eval {string is other 123}
1039 test th1-string-is-4 {$RESULT eq \
1040 "TH_ERROR: Expected alnum or list, got: other"}
1041
1042 ###############################################################################
1043
1044 fossil test-th-eval {string is alnum 123}
1045 test th1-string-is-5 {$RESULT eq "1"}
@@ -1106,5 +1106,70 @@
1106
1107 ###############################################################################
1108
1109 fossil test-th-eval {string is list "1 2 3 \{\{\}"}
1110 test th1-string-is-18 {$RESULT eq "0"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1111
--- test/th1.test
+++ test/th1.test
@@ -1035,11 +1035,11 @@
1035
1036 ###############################################################################
1037
1038 fossil test-th-eval {string is other 123}
1039 test th1-string-is-4 {$RESULT eq \
1040 "TH_ERROR: Expected alnum, double, integer, or list, got: other"}
1041
1042 ###############################################################################
1043
1044 fossil test-th-eval {string is alnum 123}
1045 test th1-string-is-5 {$RESULT eq "1"}
@@ -1106,5 +1106,70 @@
1106
1107 ###############################################################################
1108
1109 fossil test-th-eval {string is list "1 2 3 \{\{\}"}
1110 test th1-string-is-18 {$RESULT eq "0"}
1111
1112 ###############################################################################
1113
1114 fossil test-th-eval {string is double 123}
1115 test th1-string-is-19 {$RESULT eq "1"}
1116
1117 ###############################################################################
1118
1119 fossil test-th-eval {string is double 123.456}
1120 test th1-string-is-20 {$RESULT eq "1"}
1121
1122 ###############################################################################
1123
1124 fossil test-th-eval {string is double 123abc}
1125 test th1-string-is-21 {$RESULT eq "0"}
1126
1127 ###############################################################################
1128
1129 fossil test-th-eval {string is double 123_456}
1130 test th1-string-is-22 {$RESULT eq "0"}
1131
1132 ###############################################################################
1133
1134 fossil test-th-eval {string is integer 123}
1135 test th1-string-is-23 {$RESULT eq "1"}
1136
1137 ###############################################################################
1138
1139 fossil test-th-eval {string is integer 123.456}
1140 test th1-string-is-24 {$RESULT eq "0"}
1141
1142 ###############################################################################
1143
1144 fossil test-th-eval {string is integer 123abc}
1145 test th1-string-is-25 {$RESULT eq "0"}
1146
1147 ###############################################################################
1148
1149 fossil test-th-eval {string is integer 0b11001001}
1150 test th1-string-is-26 {$RESULT eq "1"}
1151
1152 ###############################################################################
1153
1154 fossil test-th-eval {string is integer 0b11001002}
1155 test th1-string-is-27 {$RESULT eq "0"}
1156
1157 ###############################################################################
1158
1159 fossil test-th-eval {string is integer 0o777}
1160 test th1-string-is-28 {$RESULT eq "1"}
1161
1162 ###############################################################################
1163
1164 fossil test-th-eval {string is integer 0o778}
1165 test th1-string-is-29 {$RESULT eq "0"}
1166
1167 ###############################################################################
1168
1169 fossil test-th-eval {string is integer 0xC0DEF00D}
1170 test th1-string-is-30 {$RESULT eq "1"}
1171
1172 ###############################################################################
1173
1174 fossil test-th-eval {string is integer 0xC0DEF00Z}
1175 test th1-string-is-31 {$RESULT eq "0"}
1176
--- www/changes.wiki
+++ www/changes.wiki
@@ -7,11 +7,12 @@
77
* Add minimal <nowiki>[lsearch]</nowiki> command to TH1. Only exact
88
case-sensitive matching is supported.
99
* Add the <nowiki>[glob_match]</nowiki> command to TH1.
1010
* Add the <nowiki>[tclIsSafe] and [tclMakeSafe]</nowiki> TH1 commands to
1111
the Tcl integration subsystem.
12
- * Add 'list' class to the <nowiki>[string is]</nowiki> command in TH1.
12
+ * Add 'double', 'integer', and 'list' classes to the
13
+ <nowiki>[string is]</nowiki> command in TH1.
1314
* Update internal Unicode character tables, used in regular expression
1415
handling, from version 7.0 to 8.0.
1516
1617
<h2>Changes for Version 1.33 (2015-05-23)</h2>
1718
* Improved fork detection on [/help?cmd=update|fossil update],
1819
--- www/changes.wiki
+++ www/changes.wiki
@@ -7,11 +7,12 @@
7 * Add minimal <nowiki>[lsearch]</nowiki> command to TH1. Only exact
8 case-sensitive matching is supported.
9 * Add the <nowiki>[glob_match]</nowiki> command to TH1.
10 * Add the <nowiki>[tclIsSafe] and [tclMakeSafe]</nowiki> TH1 commands to
11 the Tcl integration subsystem.
12 * Add 'list' class to the <nowiki>[string is]</nowiki> command in TH1.
 
13 * Update internal Unicode character tables, used in regular expression
14 handling, from version 7.0 to 8.0.
15
16 <h2>Changes for Version 1.33 (2015-05-23)</h2>
17 * Improved fork detection on [/help?cmd=update|fossil update],
18
--- www/changes.wiki
+++ www/changes.wiki
@@ -7,11 +7,12 @@
7 * Add minimal <nowiki>[lsearch]</nowiki> command to TH1. Only exact
8 case-sensitive matching is supported.
9 * Add the <nowiki>[glob_match]</nowiki> command to TH1.
10 * Add the <nowiki>[tclIsSafe] and [tclMakeSafe]</nowiki> TH1 commands to
11 the Tcl integration subsystem.
12 * Add 'double', 'integer', and 'list' classes to the
13 <nowiki>[string is]</nowiki> command in TH1.
14 * Update internal Unicode character tables, used in regular expression
15 handling, from version 7.0 to 8.0.
16
17 <h2>Changes for Version 1.33 (2015-05-23)</h2>
18 * Improved fork detection on [/help?cmd=update|fossil update],
19

Keyboard Shortcuts

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