diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2013-10-01 21:57:02 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-10-01 21:57:02 -0400 |
commit | 0a7ee343eeed8e8826d5a7fe33d2067700152065 (patch) | |
tree | 0aa9bbe08df787ba6eb22ff5aced1bc925b7f210 /json.c | |
parent | 6028d7bae7ba92ab8e5e00fa9a883dac0389d768 (diff) | |
download | gpsd-0a7ee343eeed8e8826d5a7fe33d2067700152065.tar.gz |
The JSON parser now has an "ignore" type...
...and it's used for the new dependent _text attributes.
Diffstat (limited to 'json.c')
-rw-r--r-- | json.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -114,6 +114,9 @@ static /*@null@*/ char *json_target_address(const struct json_attr_t *cursor, if (parent == NULL || parent->element_type != t_structobject) { /* ordinary case - use the address in the cursor structure */ switch (cursor->type) { + case t_ignore: + targetaddr = NULL; + break; case t_integer: targetaddr = (char *)&cursor->addr.integer[offset]; break; @@ -219,6 +222,7 @@ static int json_internal_read_object(const char *cp, case t_structobject: case t_array: case t_check: + case t_ignore: break; } } @@ -278,7 +282,7 @@ static int json_internal_read_object(const char *cp, maxlen = (int)cursor->len - 1; else if (cursor->type == t_check) maxlen = (int)strlen(cursor->dflt.check); - else if (cursor->type == t_time) + else if (cursor->type == t_time || cursor->type == t_ignore) maxlen = JSON_VAL_MAX; else if (cursor->map != NULL) maxlen = (int)sizeof(valbuf) - 1; @@ -412,7 +416,7 @@ static int json_internal_read_object(const char *cp, if (value_quoted && (cursor->type != t_string && cursor->type != t_character && cursor->type != t_check && cursor->type != t_time - && cursor->map == 0)) { + && cursor->type != t_ignore && cursor->map == 0)) { json_debug_trace((1, "Saw quoted value when expecting non-string.\n")); return JSON_ERR_QNONSTRING; @@ -481,6 +485,7 @@ static int json_internal_read_object(const char *cp, else lptr[0] = valbuf[0]; break; + case t_ignore: /* silences a compiler warning */ case t_object: /* silences a compiler warning */ case t_structobject: case t_array: |