vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 4036cbe92d8a39fdb568f8cdf98f5c8c71cedfab parent cc91a78de0f85b1eb82858d024d780a650a8bde0 Author: Marc André Tanner <mat@brain-dump.org> Date: Sun, 13 Mar 2016 13:33:07 +0100 sam: fix parsing of , compound address In a command like ,x/pattern the comma should default to the whole file. Diffstat:
| M | sam.c | | | 7 | ++----- |
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/sam.c b/sam.c @@ -315,8 +315,6 @@ static Address *address_parse_simple(Vis *vis, const char **s, enum SamError *er static Address *address_parse_compound(Vis *vis, const char **s, enum SamError *err) { Address addr = { 0 }, *left = address_parse_simple(vis, s, err), *right = NULL; - if (!left) - return NULL; skip_spaces(s); addr.type = **s; switch (addr.type) { @@ -324,9 +322,8 @@ static Address *address_parse_compound(Vis *vis, const char **s, enum SamError * case ';': /* a1;a2 */ (*s)++; right = address_parse_compound(vis, s, err); - if (!right || ((right->type == ',' || right->type == ';') && !right->left)) { - if (right) - *err = SAM_ERR_ADDRESS; + if (right && (right->type == ',' || right->type == ';') && !right->left) { + *err = SAM_ERR_ADDRESS; goto fail; } break;