added mio_json_resetfeedloc()

This commit is contained in:
hyung-hwan 2021-07-16 10:09:29 +00:00
parent a4d31da64f
commit de9c05a9b1
2 changed files with 16 additions and 2 deletions

View File

@ -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') if (c == '\n')
{ {
json->c_col = 1; json->c_col = 0;
json->c_line++; json->c_line++;
} }
else
{
json->c_col++;
}
if (json->state_stack->in_comment) 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->state_stack = &json->state_top;
json->c_line = 1; json->c_line = 1;
json->c_col = 1; json->c_col = 0;
return 0; return 0;
} }
@ -923,6 +927,12 @@ void mio_json_resetstates (mio_json_t* json)
json->state_stack->state = MIO_JSON_STATE_START; 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 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; int x;

View File

@ -253,6 +253,10 @@ MIO_EXPORT void mio_json_resetstates (
mio_json_t* json mio_json_t* json
); );
MIO_EXPORT void mio_json_resetfeedloc (
mio_json_t* json
);
/** /**
* The mio_json_feed() function processes the raw data. * The mio_json_feed() function processes the raw data.
* *