summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-08-30 19:32:20 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-08-30 19:32:20 +0000
commitf72c9475ba108576d47d826b9b3c01ca0c6210c2 (patch)
tree0b0cda153a5062d6adbdddc44119ec5437562761
parent873dc79dcab5ac36c086506c4c32c2eeb1e712e1 (diff)
downloadgpsd-f72c9475ba108576d47d826b9b3c01ca0c6210c2.tar.gz
Improve parser debugging machinery.
-rw-r--r--json.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/json.c b/json.c
index 8843e02a..6b631b5d 100644
--- a/json.c
+++ b/json.c
@@ -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: