summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-10-03 07:34:44 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-10-03 08:35:02 -0700
commit090f4dee78f7a7239ebd515993412f9505001fa9 (patch)
treec8d9bd28101968b1d37e1d28f949941d34a3a034
parent54f09626d4a93296f002ed5956de008fb59a200b (diff)
downloadtxr-090f4dee78f7a7239ebd515993412f9505001fa9.tar.gz
txr-090f4dee78f7a7239ebd515993412f9505001fa9.tar.bz2
txr-090f4dee78f7a7239ebd515993412f9505001fa9.zip
* match.c (h_var): Fix regression introduced in 2014-08-11
commit. The incompleteness of that change broke the case of an unbound variable followed by a bound variable. The value of the second variable was still being wrapped in the old complicated representation before being pushed to the front of the spec. * txr.1: Replace bogus text which says that variables are not bound to regexes, and so regex matches from variable substitutions do not arise. This works fine after this change.
-rw-r--r--ChangeLog12
-rw-r--r--match.c7
-rw-r--r--txr.120
3 files changed, 33 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 2c16a653..d75b535a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2014-10-03 Kaz Kylheku <kaz@kylheku.com>
+ * match.c (h_var): Fix regression introduced in 2014-08-11
+ commit. The incompleteness of that change broke the case of an unbound
+ variable followed by a bound variable. The value of the
+ second variable was still being wrapped in the old complicated
+ representation before being pushed to the front of the spec.
+
+ * txr.1: Replace bogus text which says that variables are not
+ bound to regexes, and so regex matches from variable substitutions
+ do not arise. This works fine after this change.
+
+2014-10-03 Kaz Kylheku <kaz@kylheku.com>
+
* Makefile: rules that rely on values from config.make
now have config.make as a prerequisite.
diff --git a/match.c b/match.c
index ce21d66a..df25c6eb 100644
--- a/match.c
+++ b/match.c
@@ -632,10 +632,9 @@ static val h_var(match_line_ctx *c)
} else if (!pair) {
sem_error(elem, lit("consecutive unbound variables"), nao);
} else {
- /* Re-generate a new spec with an edited version of
- the element we just processed, and repeat. */
- val new_elem = list(var_s, sym, cdr(pair), modifier, nao);
- c->specline = cons(elem, cons(new_elem, rest(c->specline)));
+ /* Re-generate a new spec in which the next variable
+ is replaced by its value, and repeat. */
+ c->specline = cons(elem, cons(cdr(pair), rest(c->specline)));
return repeat_spec_k;
}
} else if (op == text_s) {
diff --git a/txr.1 b/txr.1
index c63ec922..db133137 100644
--- a/txr.1
+++ b/txr.1
@@ -1441,8 +1441,24 @@ seems to have dubious value).
An unbound variable may be followed by one which is bound. The bound
variable is replaced by the text which it denotes, and the logic proceeds
-accordingly. Variables are never bound to regular expressions, so
-the regular expression match does not arise in this case.
+accordingly.
+
+It is possible for a variable to be bound to a regular expression.
+If
+.code x
+is an unbound variable and
+.code y
+is bound to a regular expression
+.codn RE ,
+then
+.code @x@y
+means
+.codn @x@/RE/ .
+A variable
+.code v
+can be bound to a regular expression using, for example,
+.codn @(bind v #/RE/) .
+
The
.code @*
syntax for longest match is available. Example: