Fossil SCM
Enhancements to the test-glob command for better testing of the setting globber.
Commit
ad44353d9056c9c710075539d4a25e4a83a1e49e
Parent
1b6c39c1aa493aa…
1 file changed
+17
-4
+17
-4
| --- src/glob.c | ||
| +++ src/glob.c | ||
| @@ -248,19 +248,32 @@ | ||
| 248 | 248 | /* |
| 249 | 249 | ** COMMAND: test-glob |
| 250 | 250 | ** |
| 251 | 251 | ** Usage: %fossil test-glob PATTERN STRING... |
| 252 | 252 | ** |
| 253 | -** PATTERN is a comma-separated list of glob patterns. Show which of | |
| 254 | -** the STRINGs that follow match the PATTERN. | |
| 253 | +** PATTERN is a comma- and whitespace-separated list of optionally | |
| 254 | +** quoted glob patterns. Show which of the STRINGs that follow match | |
| 255 | +** the PATTERN. | |
| 256 | +** | |
| 257 | +** If PATTERN begins with "@" the the rest of the pattern is understood | |
| 258 | +** to be a setting name (such as binary-glob, crln-glob, or encoding-glob) | |
| 259 | +** and the value of that setting is used as the actually glob pattern. | |
| 255 | 260 | */ |
| 256 | 261 | void glob_test_cmd(void){ |
| 257 | 262 | Glob *pGlob; |
| 258 | 263 | int i; |
| 264 | + char *zPattern; | |
| 259 | 265 | if( g.argc<4 ) usage("PATTERN STRING ..."); |
| 260 | - fossil_print("SQL expression: %s\n", glob_expr("x", g.argv[2])); | |
| 261 | - pGlob = glob_create(g.argv[2]); | |
| 266 | + zPattern = g.argv[2]; | |
| 267 | + if( zPattern[0]=='@' ){ | |
| 268 | + db_find_and_open_repository(OPEN_ANY_SCHEMA,0); | |
| 269 | + zPattern = db_get(zPattern+1, 0); | |
| 270 | + if( zPattern==0 ) fossil_fatal("no such setting: %s", g.argv[2]+1); | |
| 271 | + fossil_print("GLOB pattern: %s\n", zPattern); | |
| 272 | + } | |
| 273 | + fossil_print("SQL expression: %s\n", glob_expr("x", zPattern)); | |
| 274 | + pGlob = glob_create(zPattern); | |
| 262 | 275 | for(i=0; i<pGlob->nPattern; i++){ |
| 263 | 276 | fossil_print("pattern[%d] = [%s]\n", i, pGlob->azPattern[i]); |
| 264 | 277 | } |
| 265 | 278 | for(i=3; i<g.argc; i++){ |
| 266 | 279 | fossil_print("%d %s\n", glob_match(pGlob, g.argv[i]), g.argv[i]); |
| 267 | 280 |
| --- src/glob.c | |
| +++ src/glob.c | |
| @@ -248,19 +248,32 @@ | |
| 248 | /* |
| 249 | ** COMMAND: test-glob |
| 250 | ** |
| 251 | ** Usage: %fossil test-glob PATTERN STRING... |
| 252 | ** |
| 253 | ** PATTERN is a comma-separated list of glob patterns. Show which of |
| 254 | ** the STRINGs that follow match the PATTERN. |
| 255 | */ |
| 256 | void glob_test_cmd(void){ |
| 257 | Glob *pGlob; |
| 258 | int i; |
| 259 | if( g.argc<4 ) usage("PATTERN STRING ..."); |
| 260 | fossil_print("SQL expression: %s\n", glob_expr("x", g.argv[2])); |
| 261 | pGlob = glob_create(g.argv[2]); |
| 262 | for(i=0; i<pGlob->nPattern; i++){ |
| 263 | fossil_print("pattern[%d] = [%s]\n", i, pGlob->azPattern[i]); |
| 264 | } |
| 265 | for(i=3; i<g.argc; i++){ |
| 266 | fossil_print("%d %s\n", glob_match(pGlob, g.argv[i]), g.argv[i]); |
| 267 |
| --- src/glob.c | |
| +++ src/glob.c | |
| @@ -248,19 +248,32 @@ | |
| 248 | /* |
| 249 | ** COMMAND: test-glob |
| 250 | ** |
| 251 | ** Usage: %fossil test-glob PATTERN STRING... |
| 252 | ** |
| 253 | ** PATTERN is a comma- and whitespace-separated list of optionally |
| 254 | ** quoted glob patterns. Show which of the STRINGs that follow match |
| 255 | ** the PATTERN. |
| 256 | ** |
| 257 | ** If PATTERN begins with "@" the the rest of the pattern is understood |
| 258 | ** to be a setting name (such as binary-glob, crln-glob, or encoding-glob) |
| 259 | ** and the value of that setting is used as the actually glob pattern. |
| 260 | */ |
| 261 | void glob_test_cmd(void){ |
| 262 | Glob *pGlob; |
| 263 | int i; |
| 264 | char *zPattern; |
| 265 | if( g.argc<4 ) usage("PATTERN STRING ..."); |
| 266 | zPattern = g.argv[2]; |
| 267 | if( zPattern[0]=='@' ){ |
| 268 | db_find_and_open_repository(OPEN_ANY_SCHEMA,0); |
| 269 | zPattern = db_get(zPattern+1, 0); |
| 270 | if( zPattern==0 ) fossil_fatal("no such setting: %s", g.argv[2]+1); |
| 271 | fossil_print("GLOB pattern: %s\n", zPattern); |
| 272 | } |
| 273 | fossil_print("SQL expression: %s\n", glob_expr("x", zPattern)); |
| 274 | pGlob = glob_create(zPattern); |
| 275 | for(i=0; i<pGlob->nPattern; i++){ |
| 276 | fossil_print("pattern[%d] = [%s]\n", i, pGlob->azPattern[i]); |
| 277 | } |
| 278 | for(i=3; i<g.argc; i++){ |
| 279 | fossil_print("%d %s\n", glob_match(pGlob, g.argv[i]), g.argv[i]); |
| 280 |