Write number of bytes read to error position on successful decode

Closes #49.
This commit is contained in:
Petri Lehtinen
2012-01-23 21:18:04 +02:00
parent bb24697d9b
commit f471e63bb3
3 changed files with 57 additions and 19 deletions

View File

@@ -836,10 +836,15 @@ static json_t *parse_json(lex_t *lex, size_t flags, json_error_t *error)
if(lex->token != TOKEN_EOF) {
error_set(error, lex, "end of file expected");
json_decref(result);
result = NULL;
return NULL;
}
}
if(error) {
/* Save the position even though there was no error */
error->position = lex->stream.position;
}
return result;
}