From 69a5ca0bb9ab757c115f8779492aa068dff6c5c6 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 6 Feb 2014 20:51:15 -0800 Subject: [PATCH] Include filename in error output --- jsoncat.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jsoncat.c b/jsoncat.c index a5c339e..1d3c3d1 100644 --- a/jsoncat.c +++ b/jsoncat.c @@ -75,7 +75,7 @@ void json_print(json_object *j, int depth) { } } -void process(FILE *f) { +void process(FILE *f, char *fname) { json_pull *jp = json_begin_file(f); json_object *j = NULL; @@ -88,13 +88,13 @@ void process(FILE *f) { } if (jp->error != NULL) { - fprintf(stderr, "%d: %s\n", jp->line, jp->error); + fprintf(stderr, "%s: %d: %s\n", fname, jp->line, jp->error); } } int main(int argc, char **argv) { if (argc == 1) { - process(stdin); + process(stdin, "standard input"); } else { int i; for (i = 1; i < argc; i++) { @@ -103,7 +103,7 @@ int main(int argc, char **argv) { perror(argv[i]); exit(EXIT_FAILURE); } - process(f); + process(f, argv[i]); fclose(f); } }