From 4a6df4bceaf76d4ed727ddf3510d69f65484324c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 16 Nov 2016 22:32:43 +0100 Subject: sam: support an empty regex as an alias for the most recently used one As in sam if an empty regex // is provided we substitute in the most recently used one. 0/regexp/// Will match the second occurrence in the fie. --- sam.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sam.c') diff --git a/sam.c b/sam.c index 0dfb2d6..b52a5ee 100644 --- a/sam.c +++ b/sam.c @@ -386,6 +386,7 @@ const char *sam_error(enum SamError err) { [SAM_ERR_UNMATCHED_BRACE] = "Unmatched `}'", [SAM_ERR_REGEX] = "Bad regular expression", [SAM_ERR_TEXT] = "Bad text", + [SAM_ERR_SHELL] = "Shell command expected", [SAM_ERR_COMMAND] = "Unknown command", [SAM_ERR_EXECUTE] = "Error executing command", }; @@ -522,9 +523,7 @@ static char *parse_cmdname(const char **s) { static Regex *parse_regex(Vis *vis, const char **s) { char *pattern = parse_delimited(s, CMD_REGEX); - if (!pattern) - return NULL; - Regex *regex = vis_regex(vis, *pattern ? pattern : NULL); + Regex *regex = vis_regex(vis, pattern); free(pattern); return regex; } -- cgit v1.2.3