aboutsummaryrefslogtreecommitdiff
path: root/shared.c
diff refs
from: back
to: back
| flip
diff options
context:
space:
mode:
Diffstat (limited to 'shared.c')
-rw-r--r--shared.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/shared.c b/shared.c
index 01197f1..1f6310a 100644
--- a/shared.c
+++ b/shared.c
@@ -404,29 +404,28 @@ void cgit_diff_commit(struct commit *commit, filepair_fn fn, const char *prefix)
int cgit_parse_snapshots_mask(const char *str)
{
- struct string_list tokens = STRING_LIST_INIT_DUP;
- struct string_list_item *item;
const struct cgit_snapshot_format *f;
- int rv = 0;
+ static const char *delim = " ";
+ int tl, sl, rv = 0;
/* favor legacy setting */
if (atoi(str))
return 1;
-
- string_list_split(&tokens, str, ' ', -1);
- string_list_remove_empty_items(&tokens, 0);
-
- for_each_string_list_item(item, &tokens) {
+ for (;;) {
+ str += strspn(str, delim);
+ tl = strcspn(str, delim);
+ if (!tl)
+ break;
for (f = cgit_snapshot_formats; f->suffix; f++) {
- if (!strcmp(item->string, f->suffix) ||
- !strcmp(item->string, f->suffix + 1)) {
+ sl = strlen(f->suffix);
+ if ((tl == sl && !strncmp(f->suffix, str, tl)) ||
+ (tl == sl - 1 && !strncmp(f->suffix + 1, str, tl - 1))) {
rv |= f->bit;
break;
}
}
+ str += tl;
}
-
- string_list_clear(&tokens, 0);
return rv;
}