about summary refs log tree commit diff
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)
 
 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;
-	static const char *delim = " ";
-	int tl, sl, rv = 0;
+	int rv = 0;
 
 	/* favor legacy setting */
 	if (atoi(str))
 		return 1;
-	for (;;) {
-		str += strspn(str, delim);
-		tl = strcspn(str, delim);
-		if (!tl)
-			break;
+
+	string_list_split(&tokens, str, ' ', -1);
+	string_list_remove_empty_items(&tokens, 0);
+
+	for_each_string_list_item(item, &tokens) {
 		for (f = cgit_snapshot_formats; f->suffix; f++) {
-			sl = strlen(f->suffix);
-			if ((tl == sl && !strncmp(f->suffix, str, tl)) ||
-			   (tl == sl - 1 && !strncmp(f->suffix + 1, str, tl - 1))) {
+			if (!strcmp(item->string, f->suffix) ||
+			    !strcmp(item->string, f->suffix + 1)) {
 				rv |= f->bit;
 				break;
 			}
 		}
-		str += tl;
 	}
+
+	string_list_clear(&tokens, 0);
 	return rv;
 }
 
b1&follow=1'>Use getopts in shell scriptsJune McEnroe 2020-02-27Style %T outside of Rs in italicJune McEnroe 2020-02-26Add Fierce Femmes and Notorious LiarsJune McEnroe 2020-02-23Add This Is How You Lose the Time WarJune McEnroe 2020-02-22Add See Ya LaterJune McEnroe 2020-02-20Remove wiki scriptJune McEnroe 2020-02-19Add The Obelisk GateJune McEnroe 2020-02-17Add Four Tet — HandsJune McEnroe 2020-02-12Simplify macOS notify-sendJune McEnroe 2020-02-12Add imbox and notemap to pageJune McEnroe 2020-02-12Collapse simple linksJune McEnroe 2020-02-12Move catgirl up the pageJune McEnroe 2020-02-12Update catgirl pty grabJune McEnroe 2020-02-12Link to cgit /about pages where appropriateJune McEnroe 2020-02-11Separate LINKS from BINS for html to workJune McEnroe 2020-02-11Add margin to Bl-bullet itemsJune McEnroe 2020-02-10Match URLs inside parens or with paired parens insideJune McEnroe 2020-02-10Duplicate effective URL before passing it back to curlJune McEnroe 2020-02-09Add To Be Taught, If FortunateJune McEnroe 2020-02-04Add The Future of Another TimelineJune McEnroe 2020-01-31Reorganize the Makefile for the umpteenth timeJune McEnroe 2020-01-28Change scout sensitivity to 1.4June McEnroe 2020-01-28Import shows.txtJune McEnroe