aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--shared.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/shared.c b/shared.c
index 1f6310a..01197f1 100644
--- a/shared.c
+++ b/shared.c
@@ -404,28 +404,29 @@ void cgit_diff_commit(struct commit *commit, filepair_fn fn, const char *prefix)
404 404
405int cgit_parse_snapshots_mask(const char *str) 405int cgit_parse_snapshots_mask(const char *str)
406{ 406{
407 struct string_list tokens = STRING_LIST_INIT_DUP;
408 struct string_list_item *item;
407 const struct cgit_snapshot_format *f; 409 const struct cgit_snapshot_format *f;
408 static const char *delim = " "; 410 int rv = 0;
409 int tl, sl, rv = 0;
410 411
411 /* favor legacy setting */ 412 /* favor legacy setting */
412 if (atoi(str)) 413 if (atoi(str))
413 return 1; 414 return 1;
414 for (;;) { 415
415 str += strspn(str, delim); 416 string_list_split(&tokens, str, ' ', -1);
416 tl = strcspn(str, delim); 417 string_list_remove_empty_items(&tokens, 0);
417 if (!tl) 418
418 break; 419 for_each_string_list_item(item, &tokens) {
419 for (f = cgit_snapshot_formats; f->suffix; f++) { 420 for (f = cgit_snapshot_formats; f->suffix; f++) {
420 sl = strlen(f->suffix); 421 if (!strcmp(item->string, f->suffix) ||
421 if ((tl == sl && !strncmp(f->suffix, str, tl)) || 422 !strcmp(item->string, f->suffix + 1)) {
422 (tl == sl - 1 && !strncmp(f->suffix + 1, str, tl - 1))) {
423 rv |= f->bit; 423 rv |= f->bit;
424 break; 424 break;
425 } 425 }
426 } 426 }
427 str += tl;
428 } 427 }
428
429 string_list_clear(&tokens, 0);
429 return rv; 430 return rv;
430} 431}
431 432