aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-01-13 17:02:38 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-01-13 17:02:38 +0100
commit53638e37fea793ce4bda93094b7103a716613181 (patch)
tree67a0bf98cc99ed257f74d272f90290be8620ba49
parent104df30ff09cb14e2806f3089dde4ade62d29604 (diff)
downloadvis-53638e37fea793ce4bda93094b7103a716613181.tar.gz
vis-53638e37fea793ce4bda93094b7103a716613181.tar.xz
sam: allow empty text specifiers
Before the i, a, c commands would fail when given an empty text //.
-rw-r--r--sam.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sam.c b/sam.c
index 70dc6c9..3ddd146 100644
--- a/sam.c
+++ b/sam.c
@@ -572,8 +572,11 @@ static char *parse_delimited(const char **s, int type) {
static char *parse_text(const char **s) {
skip_spaces(s);
- if (**s != '\n')
- return parse_delimited(s, CMD_TEXT);
+ if (**s != '\n') {
+ const char *before = *s;
+ char *text = parse_delimited(s, CMD_TEXT);
+ return (!text && *s != before) ? strdup("") : text;
+ }
Buffer buf;
buffer_init(&buf);