aboutsummaryrefslogtreecommitdiff
path: root/sam.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-11-16 22:32:43 +0100
committerMarc André Tanner <mat@brain-dump.org>2016-11-16 22:32:43 +0100
commit4a6df4bceaf76d4ed727ddf3510d69f65484324c (patch)
tree4c774629d3fc443669c26810bbe31bd4abcd4428 /sam.c
parent750ccf88ea5976fe2c99f2b2c7b9f52430c6a4d1 (diff)
downloadvis-4a6df4bceaf76d4ed727ddf3510d69f65484324c.tar.gz
vis-4a6df4bceaf76d4ed727ddf3510d69f65484324c.tar.xz
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.
Diffstat (limited to 'sam.c')
-rw-r--r--sam.c5
1 files changed, 2 insertions, 3 deletions
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;
}