diff options
author | Jonathan Nieder <jrnieder@gmail.com> | 2011-01-02 21:09:38 -0600 |
---|---|---|
committer | Jonathan Nieder <jrnieder@gmail.com> | 2011-02-26 04:59:37 -0600 |
commit | cb3f87cf1ba90373fdc240d65a4d65434099d9a3 (patch) | |
tree | ea9094dc1cf3c5f96df6d6fe56dee306aaddac5f /test-line-buffer.c | |
parent | vcs-svn: allow character-oriented input (diff) | |
download | tgif-cb3f87cf1ba90373fdc240d65a4d65434099d9a3.tar.xz |
vcs-svn: allow input from file descriptor
Based-on-patch-by: David Barr <david.barr@cordelta.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Diffstat (limited to 'test-line-buffer.c')
-rw-r--r-- | test-line-buffer.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/test-line-buffer.c b/test-line-buffer.c index 19bf2d4403..25b20b93fd 100644 --- a/test-line-buffer.c +++ b/test-line-buffer.c @@ -69,13 +69,18 @@ int main(int argc, char *argv[]) else if (argc == 2) filename = argv[1]; else - usage("test-line-buffer [file] < script"); + usage("test-line-buffer [file | &fd] < script"); if (buffer_init(&stdin_buf, NULL)) die_errno("open error"); if (filename) { - if (buffer_init(&file_buf, filename)) - die_errno("error opening %s", filename); + if (*filename == '&') { + if (buffer_fdinit(&file_buf, strtouint32(filename + 1))) + die_errno("error opening fd %s", filename + 1); + } else { + if (buffer_init(&file_buf, filename)) + die_errno("error opening %s", filename); + } input = &file_buf; } |