Fossil SCM
Add 'glob_match' command to TH1.
Commit
62f1f484f6e27ed57a956f9ffa661544e3e06f78
Parent
54b0567cdaaa87e…
5 files changed
+46
+73
-2
+73
-2
+9
+9
+46
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -1324,10 +1324,55 @@ | ||
| 1324 | 1324 | Th_Trace("[setting %s%#h] => %d<br />\n", strict ? "strict " : "", |
| 1325 | 1325 | argl[nArg], argv[nArg], rc); |
| 1326 | 1326 | } |
| 1327 | 1327 | return rc; |
| 1328 | 1328 | } |
| 1329 | + | |
| 1330 | +/* | |
| 1331 | +** TH1 command: glob_match ?-one? ?--? patternList string | |
| 1332 | +** | |
| 1333 | +** Checks the string against the specified glob pattern -OR- list of glob | |
| 1334 | +** patterns and returns non-zero if there is a match. | |
| 1335 | +*/ | |
| 1336 | +#define GLOB_MATCH_WRONGNUMARGS "glob_match ?-one? ?--? patternList string" | |
| 1337 | +static int globMatchCmd( | |
| 1338 | + Th_Interp *interp, | |
| 1339 | + void *p, | |
| 1340 | + int argc, | |
| 1341 | + const char **argv, | |
| 1342 | + int *argl | |
| 1343 | +){ | |
| 1344 | + int rc; | |
| 1345 | + int one = 0; | |
| 1346 | + int nArg = 1; | |
| 1347 | + Glob *pGlob = 0; | |
| 1348 | + if( argc<3 || argc>5 ){ | |
| 1349 | + return Th_WrongNumArgs(interp, GLOB_MATCH_WRONGNUMARGS); | |
| 1350 | + } | |
| 1351 | + if( fossil_strcmp(argv[nArg], "-one")==0 ){ | |
| 1352 | + one = 1; nArg++; | |
| 1353 | + } | |
| 1354 | + if( fossil_strcmp(argv[nArg], "--")==0 ) nArg++; | |
| 1355 | + if( nArg+2!=argc ){ | |
| 1356 | + return Th_WrongNumArgs(interp, GLOB_MATCH_WRONGNUMARGS); | |
| 1357 | + } | |
| 1358 | + if( one ){ | |
| 1359 | + Th_SetResultInt(interp, sqlite3_strglob(argv[nArg], argv[nArg+1])==0); | |
| 1360 | + rc = TH_OK; | |
| 1361 | + }else{ | |
| 1362 | + pGlob = glob_create(argv[nArg]); | |
| 1363 | + if( pGlob ){ | |
| 1364 | + Th_SetResultInt(interp, glob_match(pGlob, argv[nArg+1])); | |
| 1365 | + rc = TH_OK; | |
| 1366 | + }else{ | |
| 1367 | + Th_SetResult(interp, "unable to create glob from pattern list", -1); | |
| 1368 | + rc = TH_ERROR; | |
| 1369 | + } | |
| 1370 | + glob_free(pGlob); | |
| 1371 | + } | |
| 1372 | + return rc; | |
| 1373 | +} | |
| 1329 | 1374 | |
| 1330 | 1375 | /* |
| 1331 | 1376 | ** TH1 command: regexp ?-nocase? ?--? exp string |
| 1332 | 1377 | ** |
| 1333 | 1378 | ** Checks the string against the specified regular expression and returns |
| @@ -1553,10 +1598,11 @@ | ||
| 1553 | 1598 | {"combobox", comboboxCmd, 0}, |
| 1554 | 1599 | {"date", dateCmd, 0}, |
| 1555 | 1600 | {"decorate", wikiCmd, (void*)&aFlags[2]}, |
| 1556 | 1601 | {"enable_output", enableOutputCmd, 0}, |
| 1557 | 1602 | {"getParameter", getParameterCmd, 0}, |
| 1603 | + {"glob_match", globMatchCmd, 0}, | |
| 1558 | 1604 | {"globalState", globalStateCmd, 0}, |
| 1559 | 1605 | {"httpize", httpizeCmd, 0}, |
| 1560 | 1606 | {"hascap", hascapCmd, (void*)&zeroInt}, |
| 1561 | 1607 | {"hasfeature", hasfeatureCmd, 0}, |
| 1562 | 1608 | {"html", putsCmd, (void*)&aFlags[0]}, |
| 1563 | 1609 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -1324,10 +1324,55 @@ | |
| 1324 | Th_Trace("[setting %s%#h] => %d<br />\n", strict ? "strict " : "", |
| 1325 | argl[nArg], argv[nArg], rc); |
| 1326 | } |
| 1327 | return rc; |
| 1328 | } |
| 1329 | |
| 1330 | /* |
| 1331 | ** TH1 command: regexp ?-nocase? ?--? exp string |
| 1332 | ** |
| 1333 | ** Checks the string against the specified regular expression and returns |
| @@ -1553,10 +1598,11 @@ | |
| 1553 | {"combobox", comboboxCmd, 0}, |
| 1554 | {"date", dateCmd, 0}, |
| 1555 | {"decorate", wikiCmd, (void*)&aFlags[2]}, |
| 1556 | {"enable_output", enableOutputCmd, 0}, |
| 1557 | {"getParameter", getParameterCmd, 0}, |
| 1558 | {"globalState", globalStateCmd, 0}, |
| 1559 | {"httpize", httpizeCmd, 0}, |
| 1560 | {"hascap", hascapCmd, (void*)&zeroInt}, |
| 1561 | {"hasfeature", hasfeatureCmd, 0}, |
| 1562 | {"html", putsCmd, (void*)&aFlags[0]}, |
| 1563 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -1324,10 +1324,55 @@ | |
| 1324 | Th_Trace("[setting %s%#h] => %d<br />\n", strict ? "strict " : "", |
| 1325 | argl[nArg], argv[nArg], rc); |
| 1326 | } |
| 1327 | return rc; |
| 1328 | } |
| 1329 | |
| 1330 | /* |
| 1331 | ** TH1 command: glob_match ?-one? ?--? patternList string |
| 1332 | ** |
| 1333 | ** Checks the string against the specified glob pattern -OR- list of glob |
| 1334 | ** patterns and returns non-zero if there is a match. |
| 1335 | */ |
| 1336 | #define GLOB_MATCH_WRONGNUMARGS "glob_match ?-one? ?--? patternList string" |
| 1337 | static int globMatchCmd( |
| 1338 | Th_Interp *interp, |
| 1339 | void *p, |
| 1340 | int argc, |
| 1341 | const char **argv, |
| 1342 | int *argl |
| 1343 | ){ |
| 1344 | int rc; |
| 1345 | int one = 0; |
| 1346 | int nArg = 1; |
| 1347 | Glob *pGlob = 0; |
| 1348 | if( argc<3 || argc>5 ){ |
| 1349 | return Th_WrongNumArgs(interp, GLOB_MATCH_WRONGNUMARGS); |
| 1350 | } |
| 1351 | if( fossil_strcmp(argv[nArg], "-one")==0 ){ |
| 1352 | one = 1; nArg++; |
| 1353 | } |
| 1354 | if( fossil_strcmp(argv[nArg], "--")==0 ) nArg++; |
| 1355 | if( nArg+2!=argc ){ |
| 1356 | return Th_WrongNumArgs(interp, GLOB_MATCH_WRONGNUMARGS); |
| 1357 | } |
| 1358 | if( one ){ |
| 1359 | Th_SetResultInt(interp, sqlite3_strglob(argv[nArg], argv[nArg+1])==0); |
| 1360 | rc = TH_OK; |
| 1361 | }else{ |
| 1362 | pGlob = glob_create(argv[nArg]); |
| 1363 | if( pGlob ){ |
| 1364 | Th_SetResultInt(interp, glob_match(pGlob, argv[nArg+1])); |
| 1365 | rc = TH_OK; |
| 1366 | }else{ |
| 1367 | Th_SetResult(interp, "unable to create glob from pattern list", -1); |
| 1368 | rc = TH_ERROR; |
| 1369 | } |
| 1370 | glob_free(pGlob); |
| 1371 | } |
| 1372 | return rc; |
| 1373 | } |
| 1374 | |
| 1375 | /* |
| 1376 | ** TH1 command: regexp ?-nocase? ?--? exp string |
| 1377 | ** |
| 1378 | ** Checks the string against the specified regular expression and returns |
| @@ -1553,10 +1598,11 @@ | |
| 1598 | {"combobox", comboboxCmd, 0}, |
| 1599 | {"date", dateCmd, 0}, |
| 1600 | {"decorate", wikiCmd, (void*)&aFlags[2]}, |
| 1601 | {"enable_output", enableOutputCmd, 0}, |
| 1602 | {"getParameter", getParameterCmd, 0}, |
| 1603 | {"glob_match", globMatchCmd, 0}, |
| 1604 | {"globalState", globalStateCmd, 0}, |
| 1605 | {"httpize", httpizeCmd, 0}, |
| 1606 | {"hascap", hascapCmd, (void*)&zeroInt}, |
| 1607 | {"hasfeature", hasfeatureCmd, 0}, |
| 1608 | {"html", putsCmd, (void*)&aFlags[0]}, |
| 1609 |
+73
-2
| --- test/th1.test | ||
| +++ test/th1.test | ||
| @@ -857,12 +857,12 @@ | ||
| 857 | 857 | # NOTE: This test may fail if the command names do not always come |
| 858 | 858 | # out in a deterministic order from TH1. |
| 859 | 859 | # |
| 860 | 860 | fossil test-th-eval "info commands" |
| 861 | 861 | test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\ |
| 862 | -enable_output uplevel http expr utime styleFooter catch if tclReady\ | |
| 863 | -searchable reinitialize combobox lindex query html anoncap randhex\ | |
| 862 | +enable_output uplevel http expr glob_match utime styleFooter catch if\ | |
| 863 | +tclReady searchable reinitialize combobox lindex query html anoncap randhex\ | |
| 864 | 864 | llength for set break regexp styleHeader puts return checkout decorate\ |
| 865 | 865 | artifact trace wiki proc hascap globalState continue getParameter\ |
| 866 | 866 | hasfeature setting lsearch breakpoint upvar render repository string unset\ |
| 867 | 867 | setParameter list error info rename anycap httpize}} |
| 868 | 868 | |
| @@ -941,5 +941,76 @@ | ||
| 941 | 941 | |
| 942 | 942 | ############################################################################### |
| 943 | 943 | |
| 944 | 944 | fossil test-th-eval "lsearch \"\{aa b c\" a" |
| 945 | 945 | test th1-lsearch-10 {$RESULT eq "TH_ERROR: Expected list, got: \"\{aa b c\""} |
| 946 | + | |
| 947 | +############################################################################### | |
| 948 | + | |
| 949 | +fossil test-th-eval "glob_match" | |
| 950 | +test th1-glob-match-1 {$RESULT eq \ | |
| 951 | +{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 952 | + | |
| 953 | +############################################################################### | |
| 954 | + | |
| 955 | +fossil test-th-eval "glob_match -one" | |
| 956 | +test th1-glob-match-2 {$RESULT eq \ | |
| 957 | +{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 958 | + | |
| 959 | +############################################################################### | |
| 960 | + | |
| 961 | +fossil test-th-eval "glob_match --" | |
| 962 | +test th1-glob-match-3 {$RESULT eq \ | |
| 963 | +{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 964 | + | |
| 965 | +############################################################################### | |
| 966 | + | |
| 967 | +fossil test-th-eval "glob_match -one --" | |
| 968 | +test th1-glob-match-4 {$RESULT eq \ | |
| 969 | +{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 970 | + | |
| 971 | +############################################################################### | |
| 972 | + | |
| 973 | +fossil test-th-eval "glob_match -one -- 1" | |
| 974 | +test th1-glob-match-5 {$RESULT eq \ | |
| 975 | +{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 976 | + | |
| 977 | +############################################################################### | |
| 978 | + | |
| 979 | +fossil test-th-eval "glob_match -one -- 1 2 3" | |
| 980 | +test th1-glob-match-6 {$RESULT eq \ | |
| 981 | +{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 982 | + | |
| 983 | +############################################################################### | |
| 984 | + | |
| 985 | +fossil test-th-eval {list [glob_match a A] [glob_match A a]} | |
| 986 | +test th1-glob-match-7 {$RESULT eq "0 0"} | |
| 987 | + | |
| 988 | +############################################################################### | |
| 989 | + | |
| 990 | +fossil test-th-eval {list [glob_match a,b a] [glob_match a,b b]} | |
| 991 | +test th1-glob-match-8 {$RESULT eq "1 2"} | |
| 992 | + | |
| 993 | +############################################################################### | |
| 994 | + | |
| 995 | +fossil test-th-eval {list [glob_match -one a,b a] [glob_match -one a,b b]} | |
| 996 | +test th1-glob-match-9 {$RESULT eq "0 0"} | |
| 997 | + | |
| 998 | +############################################################################### | |
| 999 | + | |
| 1000 | +fossil test-th-eval {list [glob_match -one a,b a,b] [glob_match -one a b,a]} | |
| 1001 | +test th1-glob-match-10 {$RESULT eq "1 0"} | |
| 1002 | + | |
| 1003 | +############################################################################### | |
| 1004 | + | |
| 1005 | +fossil test-th-eval {list [glob_match a*c abc] [glob_match abc a*c]} | |
| 1006 | +test th1-glob-match-11 {$RESULT eq "1 0"} | |
| 1007 | + | |
| 1008 | +############################################################################### | |
| 1009 | + | |
| 1010 | +fossil test-th-eval {list [glob_match a?c abc] [glob_match abc a?c]} | |
| 1011 | +test th1-glob-match-12 {$RESULT eq "1 0"} | |
| 1012 | + | |
| 1013 | +############################################################################### | |
| 1014 | + | |
| 1015 | +fossil test-th-eval {list [glob_match {a[bd]c} abc] [glob_match abc {a[bd]c}]} | |
| 1016 | +test th1-glob-match-13 {$RESULT eq "1 0"} | |
| 946 | 1017 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -857,12 +857,12 @@ | |
| 857 | # NOTE: This test may fail if the command names do not always come |
| 858 | # out in a deterministic order from TH1. |
| 859 | # |
| 860 | fossil test-th-eval "info commands" |
| 861 | test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\ |
| 862 | enable_output uplevel http expr utime styleFooter catch if tclReady\ |
| 863 | searchable reinitialize combobox lindex query html anoncap randhex\ |
| 864 | llength for set break regexp styleHeader puts return checkout decorate\ |
| 865 | artifact trace wiki proc hascap globalState continue getParameter\ |
| 866 | hasfeature setting lsearch breakpoint upvar render repository string unset\ |
| 867 | setParameter list error info rename anycap httpize}} |
| 868 | |
| @@ -941,5 +941,76 @@ | |
| 941 | |
| 942 | ############################################################################### |
| 943 | |
| 944 | fossil test-th-eval "lsearch \"\{aa b c\" a" |
| 945 | test th1-lsearch-10 {$RESULT eq "TH_ERROR: Expected list, got: \"\{aa b c\""} |
| 946 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -857,12 +857,12 @@ | |
| 857 | # NOTE: This test may fail if the command names do not always come |
| 858 | # out in a deterministic order from TH1. |
| 859 | # |
| 860 | fossil test-th-eval "info commands" |
| 861 | test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\ |
| 862 | enable_output uplevel http expr glob_match utime styleFooter catch if\ |
| 863 | tclReady searchable reinitialize combobox lindex query html anoncap randhex\ |
| 864 | llength for set break regexp styleHeader puts return checkout decorate\ |
| 865 | artifact trace wiki proc hascap globalState continue getParameter\ |
| 866 | hasfeature setting lsearch breakpoint upvar render repository string unset\ |
| 867 | setParameter list error info rename anycap httpize}} |
| 868 | |
| @@ -941,5 +941,76 @@ | |
| 941 | |
| 942 | ############################################################################### |
| 943 | |
| 944 | fossil test-th-eval "lsearch \"\{aa b c\" a" |
| 945 | test th1-lsearch-10 {$RESULT eq "TH_ERROR: Expected list, got: \"\{aa b c\""} |
| 946 | |
| 947 | ############################################################################### |
| 948 | |
| 949 | fossil test-th-eval "glob_match" |
| 950 | test th1-glob-match-1 {$RESULT eq \ |
| 951 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 952 | |
| 953 | ############################################################################### |
| 954 | |
| 955 | fossil test-th-eval "glob_match -one" |
| 956 | test th1-glob-match-2 {$RESULT eq \ |
| 957 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 958 | |
| 959 | ############################################################################### |
| 960 | |
| 961 | fossil test-th-eval "glob_match --" |
| 962 | test th1-glob-match-3 {$RESULT eq \ |
| 963 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 964 | |
| 965 | ############################################################################### |
| 966 | |
| 967 | fossil test-th-eval "glob_match -one --" |
| 968 | test th1-glob-match-4 {$RESULT eq \ |
| 969 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 970 | |
| 971 | ############################################################################### |
| 972 | |
| 973 | fossil test-th-eval "glob_match -one -- 1" |
| 974 | test th1-glob-match-5 {$RESULT eq \ |
| 975 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 976 | |
| 977 | ############################################################################### |
| 978 | |
| 979 | fossil test-th-eval "glob_match -one -- 1 2 3" |
| 980 | test th1-glob-match-6 {$RESULT eq \ |
| 981 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 982 | |
| 983 | ############################################################################### |
| 984 | |
| 985 | fossil test-th-eval {list [glob_match a A] [glob_match A a]} |
| 986 | test th1-glob-match-7 {$RESULT eq "0 0"} |
| 987 | |
| 988 | ############################################################################### |
| 989 | |
| 990 | fossil test-th-eval {list [glob_match a,b a] [glob_match a,b b]} |
| 991 | test th1-glob-match-8 {$RESULT eq "1 2"} |
| 992 | |
| 993 | ############################################################################### |
| 994 | |
| 995 | fossil test-th-eval {list [glob_match -one a,b a] [glob_match -one a,b b]} |
| 996 | test th1-glob-match-9 {$RESULT eq "0 0"} |
| 997 | |
| 998 | ############################################################################### |
| 999 | |
| 1000 | fossil test-th-eval {list [glob_match -one a,b a,b] [glob_match -one a b,a]} |
| 1001 | test th1-glob-match-10 {$RESULT eq "1 0"} |
| 1002 | |
| 1003 | ############################################################################### |
| 1004 | |
| 1005 | fossil test-th-eval {list [glob_match a*c abc] [glob_match abc a*c]} |
| 1006 | test th1-glob-match-11 {$RESULT eq "1 0"} |
| 1007 | |
| 1008 | ############################################################################### |
| 1009 | |
| 1010 | fossil test-th-eval {list [glob_match a?c abc] [glob_match abc a?c]} |
| 1011 | test th1-glob-match-12 {$RESULT eq "1 0"} |
| 1012 | |
| 1013 | ############################################################################### |
| 1014 | |
| 1015 | fossil test-th-eval {list [glob_match {a[bd]c} abc] [glob_match abc {a[bd]c}]} |
| 1016 | test th1-glob-match-13 {$RESULT eq "1 0"} |
| 1017 |
+73
-2
| --- test/th1.test | ||
| +++ test/th1.test | ||
| @@ -857,12 +857,12 @@ | ||
| 857 | 857 | # NOTE: This test may fail if the command names do not always come |
| 858 | 858 | # out in a deterministic order from TH1. |
| 859 | 859 | # |
| 860 | 860 | fossil test-th-eval "info commands" |
| 861 | 861 | test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\ |
| 862 | -enable_output uplevel http expr utime styleFooter catch if tclReady\ | |
| 863 | -searchable reinitialize combobox lindex query html anoncap randhex\ | |
| 862 | +enable_output uplevel http expr glob_match utime styleFooter catch if\ | |
| 863 | +tclReady searchable reinitialize combobox lindex query html anoncap randhex\ | |
| 864 | 864 | llength for set break regexp styleHeader puts return checkout decorate\ |
| 865 | 865 | artifact trace wiki proc hascap globalState continue getParameter\ |
| 866 | 866 | hasfeature setting lsearch breakpoint upvar render repository string unset\ |
| 867 | 867 | setParameter list error info rename anycap httpize}} |
| 868 | 868 | |
| @@ -941,5 +941,76 @@ | ||
| 941 | 941 | |
| 942 | 942 | ############################################################################### |
| 943 | 943 | |
| 944 | 944 | fossil test-th-eval "lsearch \"\{aa b c\" a" |
| 945 | 945 | test th1-lsearch-10 {$RESULT eq "TH_ERROR: Expected list, got: \"\{aa b c\""} |
| 946 | + | |
| 947 | +############################################################################### | |
| 948 | + | |
| 949 | +fossil test-th-eval "glob_match" | |
| 950 | +test th1-glob-match-1 {$RESULT eq \ | |
| 951 | +{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 952 | + | |
| 953 | +############################################################################### | |
| 954 | + | |
| 955 | +fossil test-th-eval "glob_match -one" | |
| 956 | +test th1-glob-match-2 {$RESULT eq \ | |
| 957 | +{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 958 | + | |
| 959 | +############################################################################### | |
| 960 | + | |
| 961 | +fossil test-th-eval "glob_match --" | |
| 962 | +test th1-glob-match-3 {$RESULT eq \ | |
| 963 | +{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 964 | + | |
| 965 | +############################################################################### | |
| 966 | + | |
| 967 | +fossil test-th-eval "glob_match -one --" | |
| 968 | +test th1-glob-match-4 {$RESULT eq \ | |
| 969 | +{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 970 | + | |
| 971 | +############################################################################### | |
| 972 | + | |
| 973 | +fossil test-th-eval "glob_match -one -- 1" | |
| 974 | +test th1-glob-match-5 {$RESULT eq \ | |
| 975 | +{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 976 | + | |
| 977 | +############################################################################### | |
| 978 | + | |
| 979 | +fossil test-th-eval "glob_match -one -- 1 2 3" | |
| 980 | +test th1-glob-match-6 {$RESULT eq \ | |
| 981 | +{TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} | |
| 982 | + | |
| 983 | +############################################################################### | |
| 984 | + | |
| 985 | +fossil test-th-eval {list [glob_match a A] [glob_match A a]} | |
| 986 | +test th1-glob-match-7 {$RESULT eq "0 0"} | |
| 987 | + | |
| 988 | +############################################################################### | |
| 989 | + | |
| 990 | +fossil test-th-eval {list [glob_match a,b a] [glob_match a,b b]} | |
| 991 | +test th1-glob-match-8 {$RESULT eq "1 2"} | |
| 992 | + | |
| 993 | +############################################################################### | |
| 994 | + | |
| 995 | +fossil test-th-eval {list [glob_match -one a,b a] [glob_match -one a,b b]} | |
| 996 | +test th1-glob-match-9 {$RESULT eq "0 0"} | |
| 997 | + | |
| 998 | +############################################################################### | |
| 999 | + | |
| 1000 | +fossil test-th-eval {list [glob_match -one a,b a,b] [glob_match -one a b,a]} | |
| 1001 | +test th1-glob-match-10 {$RESULT eq "1 0"} | |
| 1002 | + | |
| 1003 | +############################################################################### | |
| 1004 | + | |
| 1005 | +fossil test-th-eval {list [glob_match a*c abc] [glob_match abc a*c]} | |
| 1006 | +test th1-glob-match-11 {$RESULT eq "1 0"} | |
| 1007 | + | |
| 1008 | +############################################################################### | |
| 1009 | + | |
| 1010 | +fossil test-th-eval {list [glob_match a?c abc] [glob_match abc a?c]} | |
| 1011 | +test th1-glob-match-12 {$RESULT eq "1 0"} | |
| 1012 | + | |
| 1013 | +############################################################################### | |
| 1014 | + | |
| 1015 | +fossil test-th-eval {list [glob_match {a[bd]c} abc] [glob_match abc {a[bd]c}]} | |
| 1016 | +test th1-glob-match-13 {$RESULT eq "1 0"} | |
| 946 | 1017 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -857,12 +857,12 @@ | |
| 857 | # NOTE: This test may fail if the command names do not always come |
| 858 | # out in a deterministic order from TH1. |
| 859 | # |
| 860 | fossil test-th-eval "info commands" |
| 861 | test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\ |
| 862 | enable_output uplevel http expr utime styleFooter catch if tclReady\ |
| 863 | searchable reinitialize combobox lindex query html anoncap randhex\ |
| 864 | llength for set break regexp styleHeader puts return checkout decorate\ |
| 865 | artifact trace wiki proc hascap globalState continue getParameter\ |
| 866 | hasfeature setting lsearch breakpoint upvar render repository string unset\ |
| 867 | setParameter list error info rename anycap httpize}} |
| 868 | |
| @@ -941,5 +941,76 @@ | |
| 941 | |
| 942 | ############################################################################### |
| 943 | |
| 944 | fossil test-th-eval "lsearch \"\{aa b c\" a" |
| 945 | test th1-lsearch-10 {$RESULT eq "TH_ERROR: Expected list, got: \"\{aa b c\""} |
| 946 |
| --- test/th1.test | |
| +++ test/th1.test | |
| @@ -857,12 +857,12 @@ | |
| 857 | # NOTE: This test may fail if the command names do not always come |
| 858 | # out in a deterministic order from TH1. |
| 859 | # |
| 860 | fossil test-th-eval "info commands" |
| 861 | test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\ |
| 862 | enable_output uplevel http expr glob_match utime styleFooter catch if\ |
| 863 | tclReady searchable reinitialize combobox lindex query html anoncap randhex\ |
| 864 | llength for set break regexp styleHeader puts return checkout decorate\ |
| 865 | artifact trace wiki proc hascap globalState continue getParameter\ |
| 866 | hasfeature setting lsearch breakpoint upvar render repository string unset\ |
| 867 | setParameter list error info rename anycap httpize}} |
| 868 | |
| @@ -941,5 +941,76 @@ | |
| 941 | |
| 942 | ############################################################################### |
| 943 | |
| 944 | fossil test-th-eval "lsearch \"\{aa b c\" a" |
| 945 | test th1-lsearch-10 {$RESULT eq "TH_ERROR: Expected list, got: \"\{aa b c\""} |
| 946 | |
| 947 | ############################################################################### |
| 948 | |
| 949 | fossil test-th-eval "glob_match" |
| 950 | test th1-glob-match-1 {$RESULT eq \ |
| 951 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 952 | |
| 953 | ############################################################################### |
| 954 | |
| 955 | fossil test-th-eval "glob_match -one" |
| 956 | test th1-glob-match-2 {$RESULT eq \ |
| 957 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 958 | |
| 959 | ############################################################################### |
| 960 | |
| 961 | fossil test-th-eval "glob_match --" |
| 962 | test th1-glob-match-3 {$RESULT eq \ |
| 963 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 964 | |
| 965 | ############################################################################### |
| 966 | |
| 967 | fossil test-th-eval "glob_match -one --" |
| 968 | test th1-glob-match-4 {$RESULT eq \ |
| 969 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 970 | |
| 971 | ############################################################################### |
| 972 | |
| 973 | fossil test-th-eval "glob_match -one -- 1" |
| 974 | test th1-glob-match-5 {$RESULT eq \ |
| 975 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 976 | |
| 977 | ############################################################################### |
| 978 | |
| 979 | fossil test-th-eval "glob_match -one -- 1 2 3" |
| 980 | test th1-glob-match-6 {$RESULT eq \ |
| 981 | {TH_ERROR: wrong # args: should be "glob_match ?-one? ?--? patternList string"}} |
| 982 | |
| 983 | ############################################################################### |
| 984 | |
| 985 | fossil test-th-eval {list [glob_match a A] [glob_match A a]} |
| 986 | test th1-glob-match-7 {$RESULT eq "0 0"} |
| 987 | |
| 988 | ############################################################################### |
| 989 | |
| 990 | fossil test-th-eval {list [glob_match a,b a] [glob_match a,b b]} |
| 991 | test th1-glob-match-8 {$RESULT eq "1 2"} |
| 992 | |
| 993 | ############################################################################### |
| 994 | |
| 995 | fossil test-th-eval {list [glob_match -one a,b a] [glob_match -one a,b b]} |
| 996 | test th1-glob-match-9 {$RESULT eq "0 0"} |
| 997 | |
| 998 | ############################################################################### |
| 999 | |
| 1000 | fossil test-th-eval {list [glob_match -one a,b a,b] [glob_match -one a b,a]} |
| 1001 | test th1-glob-match-10 {$RESULT eq "1 0"} |
| 1002 | |
| 1003 | ############################################################################### |
| 1004 | |
| 1005 | fossil test-th-eval {list [glob_match a*c abc] [glob_match abc a*c]} |
| 1006 | test th1-glob-match-11 {$RESULT eq "1 0"} |
| 1007 | |
| 1008 | ############################################################################### |
| 1009 | |
| 1010 | fossil test-th-eval {list [glob_match a?c abc] [glob_match abc a?c]} |
| 1011 | test th1-glob-match-12 {$RESULT eq "1 0"} |
| 1012 | |
| 1013 | ############################################################################### |
| 1014 | |
| 1015 | fossil test-th-eval {list [glob_match {a[bd]c} abc] [glob_match abc {a[bd]c}]} |
| 1016 | test th1-glob-match-13 {$RESULT eq "1 0"} |
| 1017 |
+9
| --- www/th1.md | ||
| +++ www/th1.md | ||
| @@ -130,10 +130,11 @@ | ||
| 130 | 130 | * combobox |
| 131 | 131 | * date |
| 132 | 132 | * decorate |
| 133 | 133 | * enable_output |
| 134 | 134 | * getParameter |
| 135 | + * glob_match | |
| 135 | 136 | * globalState |
| 136 | 137 | * hascap |
| 137 | 138 | * hasfeature |
| 138 | 139 | * html |
| 139 | 140 | * htmlize |
| @@ -245,10 +246,18 @@ | ||
| 245 | 246 | * getParameter NAME ?DEFAULT? |
| 246 | 247 | |
| 247 | 248 | Returns the value of the specified query parameter or the specified |
| 248 | 249 | default value when there is no matching query parameter. |
| 249 | 250 | |
| 251 | +<a name="glob_match"></a>TH1 glob_match Command | |
| 252 | +----------------------------------------------- | |
| 253 | + | |
| 254 | + * glob_match ?-one? ?--? patternList string | |
| 255 | + | |
| 256 | +Checks the string against the specified glob pattern -OR- list of glob | |
| 257 | +patterns and returns non-zero if there is a match. | |
| 258 | + | |
| 250 | 259 | <a name="globalState"></a>TH1 globalState Command |
| 251 | 260 | ------------------------------------------------- |
| 252 | 261 | |
| 253 | 262 | * globalState NAME ?DEFAULT? |
| 254 | 263 | |
| 255 | 264 |
| --- www/th1.md | |
| +++ www/th1.md | |
| @@ -130,10 +130,11 @@ | |
| 130 | * combobox |
| 131 | * date |
| 132 | * decorate |
| 133 | * enable_output |
| 134 | * getParameter |
| 135 | * globalState |
| 136 | * hascap |
| 137 | * hasfeature |
| 138 | * html |
| 139 | * htmlize |
| @@ -245,10 +246,18 @@ | |
| 245 | * getParameter NAME ?DEFAULT? |
| 246 | |
| 247 | Returns the value of the specified query parameter or the specified |
| 248 | default value when there is no matching query parameter. |
| 249 | |
| 250 | <a name="globalState"></a>TH1 globalState Command |
| 251 | ------------------------------------------------- |
| 252 | |
| 253 | * globalState NAME ?DEFAULT? |
| 254 | |
| 255 |
| --- www/th1.md | |
| +++ www/th1.md | |
| @@ -130,10 +130,11 @@ | |
| 130 | * combobox |
| 131 | * date |
| 132 | * decorate |
| 133 | * enable_output |
| 134 | * getParameter |
| 135 | * glob_match |
| 136 | * globalState |
| 137 | * hascap |
| 138 | * hasfeature |
| 139 | * html |
| 140 | * htmlize |
| @@ -245,10 +246,18 @@ | |
| 246 | * getParameter NAME ?DEFAULT? |
| 247 | |
| 248 | Returns the value of the specified query parameter or the specified |
| 249 | default value when there is no matching query parameter. |
| 250 | |
| 251 | <a name="glob_match"></a>TH1 glob_match Command |
| 252 | ----------------------------------------------- |
| 253 | |
| 254 | * glob_match ?-one? ?--? patternList string |
| 255 | |
| 256 | Checks the string against the specified glob pattern -OR- list of glob |
| 257 | patterns and returns non-zero if there is a match. |
| 258 | |
| 259 | <a name="globalState"></a>TH1 globalState Command |
| 260 | ------------------------------------------------- |
| 261 | |
| 262 | * globalState NAME ?DEFAULT? |
| 263 | |
| 264 |
+9
| --- www/th1.md | ||
| +++ www/th1.md | ||
| @@ -130,10 +130,11 @@ | ||
| 130 | 130 | * combobox |
| 131 | 131 | * date |
| 132 | 132 | * decorate |
| 133 | 133 | * enable_output |
| 134 | 134 | * getParameter |
| 135 | + * glob_match | |
| 135 | 136 | * globalState |
| 136 | 137 | * hascap |
| 137 | 138 | * hasfeature |
| 138 | 139 | * html |
| 139 | 140 | * htmlize |
| @@ -245,10 +246,18 @@ | ||
| 245 | 246 | * getParameter NAME ?DEFAULT? |
| 246 | 247 | |
| 247 | 248 | Returns the value of the specified query parameter or the specified |
| 248 | 249 | default value when there is no matching query parameter. |
| 249 | 250 | |
| 251 | +<a name="glob_match"></a>TH1 glob_match Command | |
| 252 | +----------------------------------------------- | |
| 253 | + | |
| 254 | + * glob_match ?-one? ?--? patternList string | |
| 255 | + | |
| 256 | +Checks the string against the specified glob pattern -OR- list of glob | |
| 257 | +patterns and returns non-zero if there is a match. | |
| 258 | + | |
| 250 | 259 | <a name="globalState"></a>TH1 globalState Command |
| 251 | 260 | ------------------------------------------------- |
| 252 | 261 | |
| 253 | 262 | * globalState NAME ?DEFAULT? |
| 254 | 263 | |
| 255 | 264 |
| --- www/th1.md | |
| +++ www/th1.md | |
| @@ -130,10 +130,11 @@ | |
| 130 | * combobox |
| 131 | * date |
| 132 | * decorate |
| 133 | * enable_output |
| 134 | * getParameter |
| 135 | * globalState |
| 136 | * hascap |
| 137 | * hasfeature |
| 138 | * html |
| 139 | * htmlize |
| @@ -245,10 +246,18 @@ | |
| 245 | * getParameter NAME ?DEFAULT? |
| 246 | |
| 247 | Returns the value of the specified query parameter or the specified |
| 248 | default value when there is no matching query parameter. |
| 249 | |
| 250 | <a name="globalState"></a>TH1 globalState Command |
| 251 | ------------------------------------------------- |
| 252 | |
| 253 | * globalState NAME ?DEFAULT? |
| 254 | |
| 255 |
| --- www/th1.md | |
| +++ www/th1.md | |
| @@ -130,10 +130,11 @@ | |
| 130 | * combobox |
| 131 | * date |
| 132 | * decorate |
| 133 | * enable_output |
| 134 | * getParameter |
| 135 | * glob_match |
| 136 | * globalState |
| 137 | * hascap |
| 138 | * hasfeature |
| 139 | * html |
| 140 | * htmlize |
| @@ -245,10 +246,18 @@ | |
| 246 | * getParameter NAME ?DEFAULT? |
| 247 | |
| 248 | Returns the value of the specified query parameter or the specified |
| 249 | default value when there is no matching query parameter. |
| 250 | |
| 251 | <a name="glob_match"></a>TH1 glob_match Command |
| 252 | ----------------------------------------------- |
| 253 | |
| 254 | * glob_match ?-one? ?--? patternList string |
| 255 | |
| 256 | Checks the string against the specified glob pattern -OR- list of glob |
| 257 | patterns and returns non-zero if there is a match. |
| 258 | |
| 259 | <a name="globalState"></a>TH1 globalState Command |
| 260 | ------------------------------------------------- |
| 261 | |
| 262 | * globalState NAME ?DEFAULT? |
| 263 | |
| 264 |