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:
Petri Lehtinen
2010-08-13 22:19:20 +03:00
parent f8d0e01e46
commit bfac1972e2
9 changed files with 29 additions and 24 deletions

View File

@@ -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

View File

@@ -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;