diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2009-08-30 19:32:20 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2009-08-30 19:32:20 +0000 |
commit | f72c9475ba108576d47d826b9b3c01ca0c6210c2 (patch) | |
tree | 0b0cda153a5062d6adbdddc44119ec5437562761 | |
parent | 873dc79dcab5ac36c086506c4c32c2eeb1e712e1 (diff) | |
download | gpsd-f72c9475ba108576d47d826b9b3c01ca0c6210c2.tar.gz |
Improve parser debugging machinery.
-rw-r--r-- | json.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -95,6 +95,12 @@ static int json_internal_read_object(const char *cp, const struct json_attr_t *a { enum {init, await_attr, in_attr, await_value, in_val_string, in_val_token, post_val} state = 0; +#ifdef JSONDEBUG + char *statenames[] = { + "init", "await_attr", "in_attr", "await_value", + "in_val_string", "in_val_token", "post_val" + }; +#endif /* JSONDEBUG */ char attrbuf[JSON_ATTR_MAX+1], *pattr = NULL; char valbuf[JSON_VAL_MAX+1], *pval = NULL; const struct json_attr_t *cursor; @@ -145,7 +151,7 @@ static int json_internal_read_object(const char *cp, const struct json_attr_t *a /* parse input JSON */ for (; *cp; cp++) { - json_debug_trace(("State %d, looking at '%c' (%p)\n", state, *cp, cp)); + json_debug_trace(("State %s, looking at '%c' (%p)\n", statenames[state], *cp, cp)); switch (state) { case init: |