From f7728e425b2d7b1188aaff039053e044a0fe6a20 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sun, 29 Jan 2017 18:09:35 -0800 Subject: awk: support list of string as input source. * share/txr/stdlib/awk.tl (sys:awk-state loop): Allow an input source to be a list of strings, which is converted to a stream. * txr.1: Documented. --- share/txr/stdlib/awk.tl | 5 ++++- txr.1 | 16 +++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/share/txr/stdlib/awk.tl b/share/txr/stdlib/awk.tl index 05567956..90f9e8b0 100644 --- a/share/txr/stdlib/awk.tl +++ b/share/txr/stdlib/awk.tl @@ -125,7 +125,10 @@ in)) (when beg-file-func [beg-file-func aws]) - (let* ((*stdin* (if (streamp in) in (open-file in))) + (let* ((*stdin* (cond + ((streamp in) in) + ((listp in) (make-strlist-input-stream in)) + ((open-file in)))) (noted-rs (not aws.rs)) (noted-krs (not aws.krs)) (cached-rr nil)) diff --git a/txr.1 b/txr.1 index 89e62ad3..e867cb27 100644 --- a/txr.1 +++ b/txr.1 @@ -42790,9 +42790,19 @@ clauses. Each is evaluated and the values of these forms are gathered into a list. This list then comprises the list of input sources for the .code awk -processing task. The input sources are either character strings, -denoting file system path names to be opened for reading, or else -input stream objects. +processing task. + +Each input source must be one of three kinds of objects. +It may be a stream object, which must be capable of character +input. It may be a list of strings, which +.code awk +will convert to an input stream as if by the +.code make-strlist-input-stream +function. +Or else it must be a character +string, which denotes a filesystem path name which +.code awk +will open for reading. If the .code :inputs -- cgit v1.2.3