From de9c05a9b1f1e205aa12df4518afdfa9fafab377 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 16 Jul 2021 10:09:29 +0000 Subject: [PATCH] added mio_json_resetfeedloc() --- mio/lib/json.c | 14 ++++++++++++-- mio/lib/mio-json.h | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/mio/lib/json.c b/mio/lib/json.c index 34d188e..45e033b 100644 --- a/mio/lib/json.c +++ b/mio/lib/json.c @@ -802,9 +802,13 @@ static int feed_json_data (mio_json_t* json, const mio_bch_t* data, mio_oow_t le if (c == '\n') { - json->c_col = 1; + json->c_col = 0; json->c_line++; } + else + { + json->c_col++; + } if (json->state_stack->in_comment) { @@ -879,7 +883,7 @@ int mio_json_init (mio_json_t* json, mio_t* mio) json->state_stack = &json->state_top; json->c_line = 1; - json->c_col = 1; + json->c_col = 0; return 0; } @@ -923,6 +927,12 @@ void mio_json_resetstates (mio_json_t* json) json->state_stack->state = MIO_JSON_STATE_START; } +void mio_json_resetfeedloc (mio_json_t* json) +{ + json->c_line = 1; + json->c_col = 0; +} + int mio_json_feed (mio_json_t* json, const void* ptr, mio_oow_t len, mio_oow_t* rem, int stop_if_ever_completed) { int x; diff --git a/mio/lib/mio-json.h b/mio/lib/mio-json.h index 1555d5d..a6fab27 100644 --- a/mio/lib/mio-json.h +++ b/mio/lib/mio-json.h @@ -253,6 +253,10 @@ MIO_EXPORT void mio_json_resetstates ( mio_json_t* json ); +MIO_EXPORT void mio_json_resetfeedloc ( + mio_json_t* json +); + /** * The mio_json_feed() function processes the raw data. *