"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/pack_unpack.c" between
jansson-2.13.1.tar.bz2 and jansson-2.14.tar.bz2

About: Jansson is a C library for encoding, decoding and manipulating JSON data.

pack_unpack.c  (jansson-2.13.1.tar.bz2):pack_unpack.c  (jansson-2.14.tar.bz2)
skipping to change at line 547 skipping to change at line 547
if (!value && !opt) { if (!value && !opt) {
set_error(s, "<validation>", json_error_item_not_found, set_error(s, "<validation>", json_error_item_not_found,
"Object item not found: %s", key); "Object item not found: %s", key);
goto out; goto out;
} }
} }
if (unpack(s, value, ap)) if (unpack(s, value, ap))
goto out; goto out;
hashtable_set(&key_set, key, json_null()); hashtable_set(&key_set, key, strlen(key), json_null());
next_token(s); next_token(s);
} }
if (strict == 0 && (s->flags & JSON_STRICT)) if (strict == 0 && (s->flags & JSON_STRICT))
strict = 1; strict = 1;
if (root && strict == 1) { if (root && strict == 1) {
/* We need to check that all non optional items have been parsed */ /* We need to check that all non optional items have been parsed */
const char *key; const char *key;
size_t key_len;
/* keys_res is 1 for uninitialized, 0 for success, -1 for error. */ /* keys_res is 1 for uninitialized, 0 for success, -1 for error. */
int keys_res = 1; int keys_res = 1;
strbuffer_t unrecognized_keys; strbuffer_t unrecognized_keys;
json_t *value; json_t *value;
long unpacked = 0; long unpacked = 0;
if (gotopt || json_object_size(root) != key_set.size) { if (gotopt || json_object_size(root) != key_set.size) {
json_object_foreach(root, key, value) { json_object_foreach(root, key, value) {
if (!hashtable_get(&key_set, key)) { key_len = strlen(key);
if (!hashtable_get(&key_set, key, key_len)) {
unpacked++; unpacked++;
/* Save unrecognized keys for the error message */ /* Save unrecognized keys for the error message */
if (keys_res == 1) { if (keys_res == 1) {
keys_res = strbuffer_init(&unrecognized_keys); keys_res = strbuffer_init(&unrecognized_keys);
} else if (!keys_res) { } else if (!keys_res) {
keys_res = strbuffer_append_bytes(&unrecognized_keys, ", ", 2); keys_res = strbuffer_append_bytes(&unrecognized_keys, ", ", 2);
} }
if (!keys_res) if (!keys_res)
keys_res = keys_res =
strbuffer_append_bytes(&unrecognized_keys, key, strl en(key)); strbuffer_append_bytes(&unrecognized_keys, key, key_ len);
} }
} }
} }
if (unpacked) { if (unpacked) {
set_error(s, "<validation>", json_error_end_of_input_expected, set_error(s, "<validation>", json_error_end_of_input_expected,
"%li object item(s) left unpacked: %s", unpacked, "%li object item(s) left unpacked: %s", unpacked,
keys_res ? "<unknown>" : strbuffer_value(&unrecognized_key s)); keys_res ? "<unknown>" : strbuffer_value(&unrecognized_key s));
strbuffer_close(&unrecognized_keys); strbuffer_close(&unrecognized_keys);
goto out; goto out;
} }
 End of changes. 4 change blocks. 
3 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)