From f9bcbd884bb1cd60144f13df3de00516b731827c Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 27 Dec 2021 07:36:01 -0800 Subject: txr: do not ignore regex in positive match. * match.c (h_var): Refactor the logic here a bit. Without regard for whether the variable has a value, we dispatch the regex, fixed field and function cases. These handle the binding against the existing value. Then before all other cases, we check for the existing value and convert that to a literal text match. The effect of this is that now the regular expression is processed even if the variable has a value. * tests/010/span-var.txr: Last two test cases hardened a bit so they cannot fall through to a successful exit, if they invoke the wrong case. This is not related to this change. New test cases for regex span. * txr.1: Updated documentation and compatibility notes. --- tests/010/span-var.txr | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/010/span-var.txr b/tests/010/span-var.txr index b7142b79..036acc6a 100644 --- a/tests/010/span-var.txr +++ b/tests/010/span-var.txr @@ -17,12 +17,23 @@ @(bind d ("d")) @(cases) @ {d (fun "x" "a")} +@ {require (not "get here")} @(or) @ (require "get here") @(end) @(next :string "ab") @(cases) @ {d (fun2 "x" "a")} +@ {require (not "get here")} @(or) @ (require "get here") @(end) +@(bind n "123") +@(next :string "123456") +@(cases) +@ {n /\d+/} +@ {require (not "get here")} +@(or) +@ {m /\d+/} +@ (require (equal m "123456")) +@(end) -- cgit v1.2.3