From d1ea3ab89d704039b9b1f9b88ec251eb0c803516 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Wed, 4 Jun 2014 18:17:27 -0500 Subject: [PATCH] Add flags argument to jv_parser_new() For extensibility. We might add streaming parser options, even binary JSON encoding options. --- jv.h | 2 +- jv_file.c | 2 +- jv_parse.c | 2 +- main.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jv.h b/jv.h index 33a6982..01c1bb6 100644 --- a/jv.h +++ b/jv.h @@ -140,7 +140,7 @@ void jv_nomem_handler(jv_nomem_handler_f, void *); jv jv_load_file(const char *, int); struct jv_parser; -struct jv_parser* jv_parser_new(); +struct jv_parser* jv_parser_new(int); void jv_parser_set_buf(struct jv_parser*, const char*, int, int); jv jv_parser_next(struct jv_parser*); void jv_parser_free(struct jv_parser*); diff --git a/jv_file.c b/jv_file.c index 54ed36b..a633160 100644 --- a/jv_file.c +++ b/jv_file.c @@ -18,7 +18,7 @@ jv jv_load_file(const char* filename, int raw) { data = jv_string(""); } else { data = jv_array(); - parser = jv_parser_new(); + parser = jv_parser_new(0); } while (!feof(file) && !ferror(file)) { char buf[4096]; diff --git a/jv_parse.c b/jv_parse.c index cc1e7b9..5b703fd 100644 --- a/jv_parse.c +++ b/jv_parse.c @@ -370,7 +370,7 @@ static pfunc scan(struct jv_parser* p, char ch, jv* out) { return answer; } -struct jv_parser* jv_parser_new() { +struct jv_parser* jv_parser_new(int flags) { struct jv_parser* p = jv_mem_alloc(sizeof(struct jv_parser)); parser_init(p); return p; diff --git a/main.c b/main.c index b0b4a3b..066cc7e 100644 --- a/main.c +++ b/main.c @@ -280,7 +280,7 @@ int main(int argc, char* argv[]) { slurped = jv_array(); } } - struct jv_parser* parser = jv_parser_new(); + struct jv_parser* parser = jv_parser_new(0); char buf[4096]; while (read_more(buf, sizeof(buf))) { if (options & RAW_INPUT) { -- 2.40.0