summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-10-21 13:47:07 -0400
committerKaz Kylheku <kaz@kylheku.com>2011-10-21 13:47:07 -0400
commitf421259f06ee0b81754d3f1d453625ff17cb97d7 (patch)
tree68f4a8370af30022c28f4eaca500ece49f7adea6
parente98d94aa2a8c46c392eec4b7ac664eb989f3c589 (diff)
downloadtxr-f421259f06ee0b81754d3f1d453625ff17cb97d7.tar.gz
txr-f421259f06ee0b81754d3f1d453625ff17cb97d7.tar.bz2
txr-f421259f06ee0b81754d3f1d453625ff17cb97d7.zip
* match.c (v_output): When appending output to a variable,
flatten the previous contents so we can append to a single string, or to deeply nested list, etc. * txr.1: Documented these new extensions to next and output.
-rw-r--r--ChangeLog8
-rw-r--r--match.c2
-rw-r--r--txr.122
3 files changed, 28 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 22e0bfb3..8ae63b4b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2011-10-21 Kaz Kylheku <kaz@kylheku.com>
+ * match.c (v_output): When appending output to a variable,
+ flatten the previous contents so we can append to a single
+ string, or to deeply nested list, etc.
+
+ * txr.1: Documented these new extensions to next and output.
+
+2011-10-21 Kaz Kylheku <kaz@kylheku.com>
+
New features. Strling list output streams in stream
library, allow output to be captured as a list of strings
representing lines (in contrast to string streams which capture
diff --git a/match.c b/match.c
index f5e7c1c8..a2bc8eb3 100644
--- a/match.c
+++ b/match.c
@@ -2180,7 +2180,7 @@ static val v_output(match_files_ctx c, match_files_ctx *cout)
if (existing) {
if (append) {
- *cdr_l(existing) = append2(cdr(existing), list_out);
+ *cdr_l(existing) = append2(flatten(cdr(existing)), list_out);
} else {
*cdr_l(existing) = list_out;
}
diff --git a/txr.1 b/txr.1
index 6f8fea85..8e6ef97d 100644
--- a/txr.1
+++ b/txr.1
@@ -941,7 +941,7 @@ Explicitly match the end of line. Fails if the the current position is not the
end of a line. Also Fails if no data remains (there is no current line).
.IP @(next)
-Continue matching in another file.
+Continue matching in another file or other data source.
.IP @(block)
The remaining query is treated as an anonymous or named block.
@@ -1060,8 +1060,8 @@ understood in an output clause.
.IP @(repeat)
A directive understood within an @(output) section, for repeating multi-line
-text, with successive substitutions pulled from lists. A version @(rept)
-produces repeated text within one line.
+text, with successive substitutions pulled from lists. The directive @(rep)
+produces iteration over lists horizontally within one line.
.IP @(deffilter)
This directive is used for defining named filters, which are useful
@@ -1085,6 +1085,7 @@ with, or without arguments:
@(next SOURCE)
@(next SOURCE :nothrow)
@(next :args)
+ @(next :var SYMBOL)
The lone @(next) without arguments switches to the next file in the
argument list which was passed to the
@@ -1120,6 +1121,11 @@ open the input source named by that argument. If the very first directive of a q
avoids opening the first input source, but it does open the input source for
any other directive, even one which does not consume any data.
+The variant @(next :var SYMBOL) treats a the variable named by SYMBOL
+as a source of text. The contents of the variable are flattened to a list as if
+by the @(flatten) directive (but without modifying the variable).
+The resulting list is treated as if it were the lines of a text file.
+
Note that "remainder of the query" refers to the subquery in which
the next directive appears, not necessarily the entire query.
@@ -2662,6 +2668,16 @@ The argument is a symbol, which specifies a filter to be applied to the
variable substitutions occuring within the output clause.
See the later sections Output Filtering below, and The Deffilter Directive.
+.IP :into
+
+The argument of :into is a symbol which denotes a variable.
+The output will go into that variable. If the variable is unbound,
+it will be created. Otherwise, its contents are overwritten
+unless the :append keyword is used. If :append is used, then
+the new content will be appened to the previous content of
+the variable, after flattening the content to a list,
+as if by the @(flatten) directive.
+
.SS Output Text
Text in an output clause is not matched against anything, but is output