From 47ee4b1a03f5b2490ed096a97ff76f461168a993 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 14 Sep 2016 20:52:11 -0700 Subject: 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. --- share/txr/stdlib/awk.tl | 3 ++- txr.1 | 19 +++++-------------- 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 -- cgit v1.2.3