From e48a3d09d48254741908e3cf14d21aa3bf8499cd Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 11 Sep 2016 04:55:03 -0700 Subject: awk macro: don't use record stream if rs is "\n". * share/txr/stdlib/awk.tl (sys:awk-state loop): Take input stream directly without a record adapter, if the record separator is the string "\n". --- share/txr/stdlib/awk.tl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/share/txr/stdlib/awk.tl b/share/txr/stdlib/awk.tl index de6bcb71..e74a0a18 100644 --- a/share/txr/stdlib/awk.tl +++ b/share/txr/stdlib/awk.tl @@ -72,12 +72,13 @@ (when beg-file-func [beg-file-func aws]) (unwind-protect - (let ((recin (record-adapter (if (regexp aws.rs) - aws.rs - (regex-compile aws.rs)) - (if (streamp in) - in - (open-file in))))) + (let* ((stin (if (streamp in) in (open-file in))) + (recin (if (equal aws.rs "\n") + stin + (record-adapter (if (regexp aws.rs) + aws.rs + (regex-compile aws.rs)) + stin)))) (set aws.file-rec-num 0) (whilet ((rec (get-line recin))) (set aws.rec rec) -- cgit v1.2.3