Add a json_tokener_get_parse_end() function to replace direct access of tok->char_offset.

This commit is contained in:
Eric Haszlakiewicz
2019-09-08 21:35:37 -04:00
parent 087534c030
commit 05b41b159e
3 changed files with 52 additions and 13 deletions

View File

@@ -15,6 +15,7 @@
#include "config.h"
#include <assert.h>
#include <math.h>
#include "math_compat.h"
#include <stdio.h>
@@ -225,7 +226,7 @@ struct json_object* json_tokener_parse_verbose(const char *str,
)
/* ADVANCE_CHAR() macro:
* Incrementes str & tok->char_offset.
* Increments str & tok->char_offset.
* For convenience of existing conditionals, returns the old value of c (0 on eof)
* Implicit inputs: c var
*/
@@ -995,3 +996,10 @@ void json_tokener_set_flags(struct json_tokener *tok, int flags)
{
tok->flags = flags;
}
size_t json_tokener_get_parse_end(struct json_tokener *tok)
{
assert(tok->char_offset >= 0); /* Drop this line when char_offset becomes a size_t */
return (size_t)tok->char_offset;
}