X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=util%2Fjson-parse.c;h=dae869e5ec549ed3a1b618c421487b0e01bc1abf;hb=c22010a486adc7fe881418f831873dd62b7860f1;hp=db3e47314dbc6c258e45dc3f720c989ed535cd0c;hpb=a6d42174fde823c89a661c17be2165bce0d94870;p=yaz-moved-to-github.git diff --git a/util/json-parse.c b/util/json-parse.c index db3e473..dae869e 100644 --- a/util/json-parse.c +++ b/util/json-parse.c @@ -2,6 +2,9 @@ * Copyright (C) 1995-2010 Index Data * See the file LICENSE for details. */ +#if HAVE_CONFIG_H +#include +#endif #include #include @@ -22,6 +25,7 @@ static struct json_node *do_parse_from_stdin(void) FILE *f = stdin; WRBUF w = wrbuf_alloc(); struct json_node *n; + size_t pos; const char *json_str; const char *err_msg; int c; @@ -29,9 +33,13 @@ static struct json_node *do_parse_from_stdin(void) while ((c = getc(f)) != EOF) wrbuf_putc(w, c); json_str = wrbuf_cstr(w); - n = json_parse(json_str, &err_msg); + n = json_parse2(json_str, &err_msg, &pos); if (!n) - fprintf(stderr, "JSON parse error: %s\n", err_msg); + { + fprintf(stderr, "JSON parse error: %s\nLeading text was:\n", err_msg); + fwrite(json_str, 1, pos, stderr); + fprintf(stderr, "^\n"); + } wrbuf_destroy(w); return n; }