summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-01-29 18:09:35 -0800
committerKaz Kylheku <kaz@kylheku.com>2017-01-29 18:09:35 -0800
commit12b57f23dcd4f0e42b14a4f375b334be6c7c55a3 (patch)
tree1b08ca8700b616c4dd8c0f2fb150fc1768a401a0
parentb75f188c4991ac07ce7d6db8caaccda8ed4e1542 (diff)
downloadtxr-12b57f23dcd4f0e42b14a4f375b334be6c7c55a3.tar.gz
txr-12b57f23dcd4f0e42b14a4f375b334be6c7c55a3.tar.bz2
txr-12b57f23dcd4f0e42b14a4f375b334be6c7c55a3.zip
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.
-rw-r--r--share/txr/stdlib/awk.tl5
-rw-r--r--txr.116
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