From 19ddbfeca99fba65bfbe40f7237e16caf2ba28a2 Mon Sep 17 00:00:00 2001 From: Brendan Macmillan Date: Fri, 31 May 2013 14:21:55 +1000 Subject: [PATCH] Stop warning on fgets, complex version --- jq_test.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/jq_test.c b/jq_test.c index 25cea1c..d05b7be 100644 --- a/jq_test.c +++ b/jq_test.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "jv.h" #include "execute.h" @@ -39,7 +40,11 @@ static void run_jq_tests(FILE *testdata) { printf("Disassembly:\n"); dump_disassembly(2, bc); printf("\n"); - fgets(buf, sizeof(buf), testdata); + if (!fgets(buf, sizeof(buf), testdata)) { + invalid++; + printf("%s\n", (errno==0)?"Premature EOF":strerror(errno)); + break; + } jv input = jv_parse(buf); if (!jv_is_valid(input)){ invalid++; continue; } jq_init(bc, input, &jq, JQ_DEBUG_TRACE); -- 2.40.0