Add a flags parameter to all decoding functions for future needs
As of now, the parameter is unused, but may be needed in the future. I'm adding it now so that in the future both API and ABI remain backwards compatible as long as possible. This is a backwards incompatible change.
This commit is contained in:
@@ -177,9 +177,9 @@ typedef struct {
|
||||
int line;
|
||||
} json_error_t;
|
||||
|
||||
json_t *json_loads(const char *input, json_error_t *error);
|
||||
json_t *json_loadf(FILE *input, json_error_t *error);
|
||||
json_t *json_load_file(const char *path, json_error_t *error);
|
||||
json_t *json_loads(const char *input, size_t flags, json_error_t *error);
|
||||
json_t *json_loadf(FILE *input, size_t flags, json_error_t *error);
|
||||
json_t *json_load_file(const char *path, size_t flags, json_error_t *error);
|
||||
|
||||
#define JSON_INDENT(n) (n & 0x1F)
|
||||
#define JSON_COMPACT 0x20
|
||||
|
||||
10
src/load.c
10
src/load.c
@@ -811,10 +811,11 @@ static int string_eof(void *data)
|
||||
return (stream->data[stream->pos] == '\0');
|
||||
}
|
||||
|
||||
json_t *json_loads(const char *string, json_error_t *error)
|
||||
json_t *json_loads(const char *string, size_t flags, json_error_t *error)
|
||||
{
|
||||
lex_t lex;
|
||||
json_t *result;
|
||||
(void)flags; /* unused */
|
||||
|
||||
string_data_t stream_data = {
|
||||
.data = string,
|
||||
@@ -840,10 +841,11 @@ out:
|
||||
return result;
|
||||
}
|
||||
|
||||
json_t *json_loadf(FILE *input, json_error_t *error)
|
||||
json_t *json_loadf(FILE *input, size_t flags, json_error_t *error)
|
||||
{
|
||||
lex_t lex;
|
||||
json_t *result;
|
||||
(void)flags; /* unused */
|
||||
|
||||
if(lex_init(&lex, (get_func)fgetc, (eof_func)feof, input))
|
||||
return NULL;
|
||||
@@ -864,7 +866,7 @@ out:
|
||||
return result;
|
||||
}
|
||||
|
||||
json_t *json_load_file(const char *path, json_error_t *error)
|
||||
json_t *json_load_file(const char *path, size_t flags, json_error_t *error)
|
||||
{
|
||||
json_t *result;
|
||||
FILE *fp;
|
||||
@@ -879,7 +881,7 @@ json_t *json_load_file(const char *path, json_error_t *error)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = json_loadf(fp, error);
|
||||
result = json_loadf(fp, flags, error);
|
||||
|
||||
fclose(fp);
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user