diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-01-26 08:49:43 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-01-26 08:49:43 -0800 |
commit | 6899c7cd2b6890acd8ef86f4f2301708c6f59c1d (patch) | |
tree | 46ad9f1a4fd81e4e44e4c3ce4600681a4cc11b3b /share | |
parent | be0aa60ca1fda9d6402bec586d60cc49cb870e87 (diff) | |
download | txr-6899c7cd2b6890acd8ef86f4f2301708c6f59c1d.tar.gz txr-6899c7cd2b6890acd8ef86f4f2301708c6f59c1d.tar.bz2 txr-6899c7cd2b6890acd8ef86f4f2301708c6f59c1d.zip |
awk macro: bind *stdin* to current input stream.
* share/txr/stdlib/awk.tl (sys:awk-state loop): Instead of
using the lexical variable stin, use *stdin*, so that
the standard input stream is re-bound.
* txr.1: Documented binding and scope of *stdin*.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/awk.tl | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/share/txr/stdlib/awk.tl b/share/txr/stdlib/awk.tl index caa5a311..9732ea24 100644 --- a/share/txr/stdlib/awk.tl +++ b/share/txr/stdlib/awk.tl @@ -121,11 +121,11 @@ (inc aws.file-num) (when beg-file-func [beg-file-func aws]) - (let* ((stin (if (streamp in) in (open-file in))) + (let* ((*stdin* (if (streamp in) in (open-file in))) (noted-rs (not aws.rs)) (noted-krs (not aws.krs)) (cached-rr nil)) - (flet ((get-rec-reader (stin) + (flet ((get-rec-reader (*stdin*) (cond ((and (equal noted-rs aws.rs) (eq noted-krs aws.krs)) cached-rr) @@ -135,7 +135,7 @@ (cond ((and (equal aws.rs "\n") (not aws.krs)) (set aws.par-mode nil) - (lambda () (get-line stin))) + (lambda () (get-line *stdin*))) ((null aws.rs) (set aws.par-mode t) (let ((rin (record-adapter #/\n[ \n\t]*\n/)) @@ -154,12 +154,12 @@ (let ((rin (record-adapter (if (regexp aws.rs) aws.rs (regex-compile aws.rs)) - stin + *stdin* aws.krs))) (lambda () (get-line rin)))))))))) (set aws.file-rec-num 0) (unwind-protect - (whilet ((rr (get-rec-reader stin)) + (whilet ((rr (get-rec-reader *stdin*)) (rec (call rr))) (set aws.rec rec aws.orig-rec rec) (inc aws.rec-num) |