diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-11-16 22:32:43 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-11-16 22:32:43 +0100 |
| commit | 4a6df4bceaf76d4ed727ddf3510d69f65484324c (patch) | |
| tree | 4c774629d3fc443669c26810bbe31bd4abcd4428 | |
| parent | 750ccf88ea5976fe2c99f2b2c7b9f52430c6a4d1 (diff) | |
| download | vis-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.
| -rw-r--r-- | sam.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -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; } |
