From 964189735954a9e89ad507c68c20423fe02eaccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 12 Apr 2017 17:39:51 +0200 Subject: sam: distinguish between empty // and no regex --- sam.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sam.c') diff --git a/sam.c b/sam.c index e2e1667..1991c9e 100644 --- a/sam.c +++ b/sam.c @@ -550,7 +550,7 @@ static char *parse_until(const char **s, const char *until, const char *escchars static char *parse_delimited(const char **s, int type) { char delim[2] = { **s, '\0' }; - if (!delim[0]) + if (!delim[0] || isspace((unsigned char)delim[0])) return NULL; (*s)++; char *chunk = parse_until(s, delim, NULL, type); @@ -624,7 +624,10 @@ static char *parse_cmdname(const char **s) { } static Regex *parse_regex(Vis *vis, const char **s) { + const char *before = *s; char *pattern = parse_delimited(s, CMD_REGEX); + if (!pattern && *s == before) + return NULL; Regex *regex = vis_regex(vis, pattern); free(pattern); return regex; -- cgit v1.2.3