diff options
-rw-r--r-- | share/txr/stdlib/awk.tl | 10 | ||||
-rw-r--r-- | txr.1 | 11 |
2 files changed, 16 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) @@ -42590,6 +42590,17 @@ record (contents of the variable followed by the output record terminator from the variable .codn ors . +While the processing loop in +.code awk +scans an input source, it also binds the special variable +.code *stdin* +to the open stream associated with that source. This binding is +in effect across all ordinary clauses, as well as across the +special clauses +.code :begin-file +and +.codn :end-file . + The following is a description of the special clauses: .RS .meIP (:name << sym ) |