Commit b20e7f8d authored by Pavel Emelyanov's avatar Pavel Emelyanov

pb: Allow for nested messages pretty specification

It's not perfect, only the depth is taken into account,
not the field number, but this is OK for now.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent bd1d6186
......@@ -357,10 +357,14 @@ static int pb_field_show_pretty(pb_pr_ctl_t *ctl)
char cookie[32];
const char *ptr;
if (!ctl->pretty_fmt || field->depth)
if (!ctl->pretty_fmt)
return 0;
sprintf(cookie, " %d:", field->number);
if (!field->depth)
sprintf(cookie, " %d:", field->number);
else
sprintf(cookie, " %d.%d:", field->depth, field->number);
if (!strncmp(ctl->pretty_fmt, &cookie[1], strlen(&cookie[1])))
ptr = ctl->pretty_fmt;
else {
......@@ -368,7 +372,7 @@ static int pb_field_show_pretty(pb_pr_ctl_t *ctl)
if (!ptr)
return 0;
}
found = sscanf(ptr, "%*[ 1-9:]%s", field->fmt);
found = sscanf(ptr, "%*[ 1-9.:]%s", field->fmt);
BUG_ON(found > 1);
return found;
}
......
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