Fossil SCM

Enhancements to the test-glob command for better testing of the setting globber.

drh 2013-03-06 20:50 UTC globListRefactor
Commit ad44353d9056c9c710075539d4a25e4a83a1e49e
1 file changed +17 -4
+17 -4
--- src/glob.c
+++ src/glob.c
@@ -248,19 +248,32 @@
248248
/*
249249
** COMMAND: test-glob
250250
**
251251
** Usage: %fossil test-glob PATTERN STRING...
252252
**
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.
255260
*/
256261
void glob_test_cmd(void){
257262
Glob *pGlob;
258263
int i;
264
+ char *zPattern;
259265
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);
262275
for(i=0; i<pGlob->nPattern; i++){
263276
fossil_print("pattern[%d] = [%s]\n", i, pGlob->azPattern[i]);
264277
}
265278
for(i=3; i<g.argc; i++){
266279
fossil_print("%d %s\n", glob_match(pGlob, g.argv[i]), g.argv[i]);
267280
--- 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

Keyboard Shortcuts

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