From e05a39e67e5259263ecc4955f3efa8724d887e90 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 13 Aug 2014 06:55:07 -0700 Subject: Fix regression in previous change: we must match a compound text element whole, and not break it up. * match.c (search_match): Take a spec argument. (h_var): Turn a text element into a one-element spec and process with search_match. * txr.1: Updated text about matching of variables followed by a directive or function, and about consecutive variables via directive. --- match.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'match.c') diff --git a/match.c b/match.c index fe6a918f..67d917ea 100644 --- a/match.c +++ b/match.c @@ -450,9 +450,8 @@ static void consume_prefix(match_line_ctx *c) } -static val search_match(match_line_ctx *c, val from_end) +static val search_match(match_line_ctx *c, val from_end, val spec) { - val spec = c->specline; val pos = from_end ? length_str(c->dataline) : c->pos; val step = from_end ? negone : one; @@ -640,11 +639,17 @@ static val h_var(match_line_ctx *c) return repeat_spec_k; } } else if (op == text_s) { - /* Clumped texts: break out the first one. */ - val text_elem = rlcp(second(next), c->specline); - val rest_texts = cons(text_s, rest(rest(next))); - c->specline = cons(elem, cons(text_elem, - cons(rest_texts, rest(c->specline)))); + val text_only_spec = cons(next, nil); + val find = search_match(c, modifier, text_only_spec); + val fpos = car(find); + if (!find) { + LOG_MISMATCH("var delimiting text compound"); + return nil; + } + LOG_MATCH("var delimiting text compound", fpos); + if (sym) + c->bindings = acons(sym, sub_str(c->dataline, c->pos, fpos), c->bindings); + c->pos = fpos; return repeat_spec_k; } else if (consp(op) || stringp(op)) { cons_bind (find, len, search_str_tree(c->dataline, next, c->pos, modifier)); @@ -656,7 +661,7 @@ static val h_var(match_line_ctx *c) c->bindings = acons(sym, sub_str(c->dataline, c->pos, find), c->bindings); c->pos = plus(find, len); } else { - val find = search_match(c, modifier); + val find = search_match(c, modifier, c->specline); val fpos = car(find); if (!find) { LOG_MISMATCH("var delimiting spec"); -- cgit v1.2.3