summaryrefslogtreecommitdiff
path: root/json.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-10-01 21:57:02 -0400
committerEric S. Raymond <esr@thyrsus.com>2013-10-01 21:57:02 -0400
commit0a7ee343eeed8e8826d5a7fe33d2067700152065 (patch)
tree0aa9bbe08df787ba6eb22ff5aced1bc925b7f210 /json.c
parent6028d7bae7ba92ab8e5e00fa9a883dac0389d768 (diff)
downloadgpsd-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.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/json.c b/json.c
index 354e74ea..ac00ab32 100644
--- a/json.c
+++ b/json.c
@@ -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: