Commit f821b2ea authored by Vittorio Giovara's avatar Vittorio Giovara

avprobe: Support printing strings with empty keys

parent cc06f7bd
...@@ -235,10 +235,14 @@ static void ini_print_integer(const char *key, int64_t value) ...@@ -235,10 +235,14 @@ static void ini_print_integer(const char *key, int64_t value)
static void ini_print_string(const char *key, const char *value) static void ini_print_string(const char *key, const char *value)
{ {
if (key) {
ini_escape_print(key); ini_escape_print(key);
avio_printf(probe_out, "="); avio_printf(probe_out, "=%s\n", value);
ini_escape_print(value); } else {
avio_w8(probe_out, '\n'); if (octx.prefix[octx.level -1].nb_elems)
avio_printf(probe_out, ",");
avio_printf(probe_out, "%s", value);
}
} }
/* /*
...@@ -329,6 +333,7 @@ static void json_escape_print(const char *s) ...@@ -329,6 +333,7 @@ static void json_escape_print(const char *s)
static void json_print_string(const char *key, const char *value) static void json_print_string(const char *key, const char *value)
{ {
if (key) {
if (octx.prefix[octx.level -1].nb_elems) if (octx.prefix[octx.level -1].nb_elems)
avio_printf(probe_out, ",\n"); avio_printf(probe_out, ",\n");
AVP_INDENT(); AVP_INDENT();
...@@ -337,6 +342,15 @@ static void json_print_string(const char *key, const char *value) ...@@ -337,6 +342,15 @@ static void json_print_string(const char *key, const char *value)
avio_printf(probe_out, "\" : \""); avio_printf(probe_out, "\" : \"");
json_escape_print(value); json_escape_print(value);
avio_w8(probe_out, '\"'); avio_w8(probe_out, '\"');
} else {
if (octx.prefix[octx.level -1].nb_elems)
avio_printf(probe_out, ", ");
else
AVP_INDENT();
avio_w8(probe_out, '\"');
json_escape_print(value);
avio_w8(probe_out, '\"');
}
} }
/* /*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment