diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-10-21 13:47:07 -0400 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-10-21 13:47:07 -0400 |
commit | f421259f06ee0b81754d3f1d453625ff17cb97d7 (patch) | |
tree | 68f4a8370af30022c28f4eaca500ece49f7adea6 | |
parent | e98d94aa2a8c46c392eec4b7ac664eb989f3c589 (diff) | |
download | txr-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-- | ChangeLog | 8 | ||||
-rw-r--r-- | match.c | 2 | ||||
-rw-r--r-- | txr.1 | 22 |
3 files changed, 28 insertions, 4 deletions
@@ -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 @@ -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; } @@ -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 |