summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-09-24 07:16:33 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-09-24 07:16:33 -0700
commit935e56bdeca329e8affdb03f20a31736f10ed834 (patch)
tree1b4253c322f297c27e37ed0ecc4d10da5bf66f85 /share
parent657217908b4a9e41de931b433b7b0a494abacb96 (diff)
downloadtxr-935e56bdeca329e8affdb03f20a31736f10ed834.tar.gz
txr-935e56bdeca329e8affdb03f20a31736f10ed834.tar.bz2
txr-935e56bdeca329e8affdb03f20a31736f10ed834.zip
awk macro: exit if no cond-action clauses.
* share/txr/stdlib/awk.tl: If there are no cond-action clauses in the macro, do not generate the main record processing lambda, or the begin-file and end-file lambdas, and do not generate the call to the awk state object's loop method.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/awk.tl26
1 files changed, 14 insertions, 12 deletions
diff --git a/share/txr/stdlib/awk.tl b/share/txr/stdlib/awk.tl
index 07a5f3bc..eccef632 100644
--- a/share/txr/stdlib/awk.tl
+++ b/share/txr/stdlib/awk.tl
@@ -230,26 +230,28 @@
rng-n (macro-time (qref ,awc nranges))))
,*(if awc.output
^((*stdout* (qref ,aws-sym output))))
- ,*(if awc.begin-file-actions
+ ,*(if (and awc.cond-actions awc.begin-file-actions)
^((,awk-begf-fun (lambda (,aws-sym)
,*awc.begin-file-actions))))
- ,*(if awc.end-file-actions
+ ,*(if (and awc.cond-actions awc.end-file-actions)
^((,awk-endf-fun (lambda (,aws-sym)
,*awc.end-file-actions))))
- (,awk-fun (lambda (,aws-sym)
- ,(if awc.rng-exprs
- ^(let* ((,awc.rng-rec-temp rec)
- ,*(nreverse
- (zip awc.rng-expr-temps
- awc.rng-exprs)))
- ,p-actions-xform)
- p-actions-xform))))
+ ,*(if awc.cond-actions
+ ^((,awk-fun (lambda (,aws-sym)
+ ,(if awc.rng-exprs
+ ^(let* ((,awc.rng-rec-temp rec)
+ ,*(nreverse
+ (zip awc.rng-expr-temps
+ awc.rng-exprs)))
+ ,p-actions-xform)
+ p-actions-xform))))))
,*awc.begin-actions
(unwind-protect
- (qref ,aws-sym (loop ,awk-fun
+ ,(if awc.cond-actions
+ ^(qref ,aws-sym (loop ,awk-fun
,(if awc.begin-file-actions
awk-begf-fun)
,(if awc.end-file-actions
- awk-endf-fun)))
+ awk-endf-fun))))
(set ,awk-retval (progn ,*awc.end-actions)))
,awk-retval))))))))