]> granicus.if.org Git - jq/commitdiff
Fix an embarassing I/O bug.
authorStephen Dolan <mu@netsoc.tcd.ie>
Thu, 27 Dec 2012 01:57:09 +0000 (01:57 +0000)
committerStephen Dolan <mu@netsoc.tcd.ie>
Thu, 27 Dec 2012 01:57:09 +0000 (01:57 +0000)
Pulling some I/O out to a function meant that buf changed from
"char buf[4096]" to "char* buf", and "sizeof(buf)" got a lot
less interesting. The upshot of this is that jq read input eight
bytes at a time, which is not the fastest.

main.c

diff --git a/main.c b/main.c
index fd482122521e08f7c9db999e1c165a92bed8846a..e18f6fdd9ae3afbc1ce2d661b23b8964a586a829 100644 (file)
--- a/main.c
+++ b/main.c
@@ -135,7 +135,7 @@ static int read_more(char* buf, size_t size) {
     next_input_idx++;
   }
 
-  if (!fgets(buf, sizeof(buf), current_input)) buf[0] = 0;
+  if (!fgets(buf, size, current_input)) buf[0] = 0;
   return 1;
 }