summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-09-14 20:52:11 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-09-14 20:52:11 -0700
commitd6f725293fdfd7d28ab5938256866b1fd3b49fe1 (patch)
treeaba89d5ecc7e8dbfd4dea95f3c057e37f0e3f594
parent61617da8db174532055801a7ccdc244b8fb80f2e (diff)
downloadtxr-d6f725293fdfd7d28ab5938256866b1fd3b49fe1.tar.gz
txr-d6f725293fdfd7d28ab5938256866b1fd3b49fe1.tar.bz2
txr-d6f725293fdfd7d28ab5938256866b1fd3b49fe1.zip
awk macro: don't bind *stdout* if :output missing.
* share/txr/stdlib/awk.tl (awk): Bind *stdout* only if awc.output is not nil; i.e. :output has been specified (with a non-nil argument). * txr.1: Revised :output documentation.
-rw-r--r--share/txr/stdlib/awk.tl3
-rw-r--r--txr.119
2 files changed, 7 insertions, 15 deletions
diff --git a/share/txr/stdlib/awk.tl b/share/txr/stdlib/awk.tl
index 45a655bd..fd4788da 100644
--- a/share/txr/stdlib/awk.tl
+++ b/share/txr/stdlib/awk.tl
@@ -211,7 +211,8 @@
,*(if awc.inputs ^(inputs (list ,*awc.inputs)))
,*(if awc.output ^(output ,awc.output))
rng-n (macro-time (qref ,awc nranges))))
- (*stdout* (qref ,aws-sym output))
+ ,*(if awc.output
+ ^((*stdout* (qref ,aws-sym output))))
,*(if awc.begin-file-actions
^((,awk-begf-fun (lambda (,aws-sym)
,*awc.begin-file-actions))))
diff --git a/txr.1 b/txr.1
index 47a4f0aa..96b15fe8 100644
--- a/txr.1
+++ b/txr.1
@@ -37345,24 +37345,15 @@ clause is processed just after the
clause. It must have exactly one argument, which is an expression
that evaluates to a string, or else to an output stream.
If it evaluates to a string, then that string is used as the name
-of a file to open for writing.
-
-If the
-.code :output
-clause is omitted, then the current value of the
-.code *stdout*
-stream is used: the value which that special
-variable has on entry into the code generated by the
-.code awk
-macro.
+of a file to open for writing, and the resulting stream
+is taken in place of that string.
The
.code :output
-clause has the effect of creating a local binding for the
+clause, if present, has the effect of creating a local binding for the
.code *stdout*
-special variable within the dynamic scope of the
-.code awk
-macro. This new value of
+special variable.
+This new value of
.code *stdout*
is visible to all forms within the macro.
If a