}
}
+static inline
+void write_none_str(struct details_write_ctx *ctx, const char *str)
+{
+ g_string_append_printf(ctx->str, "%s%s%s%s",
+ color_bold(ctx), color_fg_bright_magenta(ctx),
+ str, color_reset(ctx));
+}
+
static inline
void write_compound_member_name(struct details_write_ctx *ctx, const char *name)
{
write_indent(ctx);
- g_string_append_printf(ctx->str, "%s%s%s:",
- color_fg_cyan(ctx), name, color_reset(ctx));
+
+ if (name) {
+ g_string_append_printf(ctx->str, "%s%s%s",
+ color_fg_cyan(ctx), name, color_reset(ctx));
+ } else {
+ write_none_str(ctx, "Unnamed");
+ }
+
+ g_string_append(ctx->str, ":");
}
static inline
color_bold(ctx), value, color_reset(ctx));
}
-static inline
-void write_none_prop_value(struct details_write_ctx *ctx, const char *value)
-{
- g_string_append_printf(ctx->str, "%s%s%s%s",
- color_bold(ctx), color_fg_bright_magenta(ctx),
- value, color_reset(ctx));
-}
-
static inline
void write_uint_str_prop_value(struct details_write_ctx *ctx, const char *value)
{
switch (value_type) {
case BT_VALUE_TYPE_NULL:
write_sp(ctx);
- write_none_prop_value(ctx, "Null");
+ write_none_str(ctx, "Null");
break;
case BT_VALUE_TYPE_BOOL:
write_sp(ctx);
if (length == 0) {
write_sp(ctx);
- write_none_prop_value(ctx, "Empty");
+ write_none_str(ctx, "Empty");
} else {
g_string_append(ctx->str, " Length ");
write_uint_prop_value(ctx, length);
decr_indent(ctx);
} else {
write_sp(ctx);
- write_none_prop_value(ctx, "Empty");
+ write_none_str(ctx, "Empty");
}
break;
if (ns) {
g_string_append(ctx->str, "Namespace `");
- write_none_prop_value(ctx, ns);
+ write_none_str(ctx, ns);
g_string_append(ctx->str, "`, ");
}
}
decr_indent(ctx);
} else {
write_sp(ctx);
- write_none_prop_value(ctx, "Empty");
+ write_none_str(ctx, "Empty");
}
} else if (bt_field_class_type_is(fc_type, BT_FIELD_CLASS_TYPE_ARRAY)) {
uint64_t length = bt_field_array_get_length(field);
if (length == 0) {
write_sp(ctx);
- write_none_prop_value(ctx, "Empty");
+ write_none_str(ctx, "Empty");
} else {
g_string_append(ctx->str, " Length ");
write_uint_prop_value(ctx, length);
if (!content_field) {
write_sp(ctx);
- write_none_prop_value(ctx, "None");
+ write_none_str(ctx, "None");
} else {
write_field(ctx, content_field, NULL);
}
if (length == 0) {
write_sp(ctx);
- write_none_prop_value(ctx, "Empty");
+ write_none_str(ctx, "Empty");
} else {
g_string_append(ctx->str, " Length ");
write_uint_prop_value(ctx, length);