]> granicus.if.org Git - jq/commitdiff
Never close stdin; allow multiple `-` arguments
authorNicolas Williams <nico@cryptonector.com>
Sat, 30 Aug 2014 05:28:41 +0000 (00:28 -0500)
committerNicolas Williams <nico@cryptonector.com>
Sat, 30 Aug 2014 05:40:03 +0000 (00:40 -0500)
main.c

diff --git a/main.c b/main.c
index 12dcd70bf992911fb6d410b15bdc4a2cb655041a..335ca7b2aba2d524e2a09ff5aaac2962de4df122 100644 (file)
--- a/main.c
+++ b/main.c
@@ -151,7 +151,11 @@ int next_input_idx;
 static int read_more(char* buf, size_t size, int* islast) {
   while (!current_input || feof(current_input)) {
     if (current_input) {
-      fclose(current_input);
+      if (current_input == stdin) {
+        clearerr(stdin); // perhaps we can read again
+      } else {
+        fclose(current_input);
+      }
       current_input = 0;
     }
     if (next_input_idx == ninput_files) {