if (fmt->color) {
width -= fmt->color(fmt, &hpp, entry);
} else {
+ int i = 0;
+
width -= fmt->entry(fmt, &hpp, entry);
- ui_browser__printf(&browser->b, "%s", s);
+ ui_browser__printf(&browser->b, "%s", ltrim(s));
+
+ while (isspace(s[i++]))
+ width++;
}
}
return ret;
hists__for_each_format(hists, fmt) {
+ char *start;
+
if (!perf_hpp__is_sort_entry(fmt) && !perf_hpp__is_dynamic_entry(fmt))
continue;
if (perf_hpp__should_skip(fmt, hists))
dummy_hpp.buf[ret] = '\0';
rtrim(dummy_hpp.buf);
- ret = strlen(dummy_hpp.buf);
+ start = ltrim(dummy_hpp.buf);
+ ret = strlen(start);
+
+ if (start != dummy_hpp.buf)
+ memmove(dummy_hpp.buf, start, ret + 1);
+
if (advance_hpp_check(&dummy_hpp, ret))
break;
}
const char *sep = symbol_conf.field_sep;
struct perf_hpp_fmt *fmt;
char *buf = hpp->buf;
+ size_t size = hpp->size;
int ret, printed = 0;
bool first = true;
(nr_sort_key - 1) * HIERARCHY_INDENT + 2, "");
advance_hpp(hpp, ret);
+ printed += fprintf(fp, "%s", buf);
+
+ hpp->buf = buf;
+ hpp->size = size;
+
/*
* No need to call hist_entry__snprintf_alignment() since this
* fmt is always the last column in the hierarchy mode.
else
fmt->entry(fmt, hpp, he);
- printed += fprintf(fp, "%s\n", buf);
+ /*
+ * dynamic entries are right-aligned but we want left-aligned
+ * in the hierarchy mode
+ */
+ printed += fprintf(fp, "%s\n", ltrim(buf));
if (symbol_conf.use_callchain && he->leaf) {
u64 total = hists__total_period(hists);
{
bool first = true;
int nr_sort;
+ int depth;
unsigned width = 0;
unsigned header_width = 0;
struct perf_hpp_fmt *fmt;
if (!first)
header_width += fprintf(fp, " / ");
else {
- header_width += fprintf(fp, "%s", sep ?: " ");
+ fprintf(fp, "%s", sep ?: " ");
first = false;
}
fmt->header(fmt, hpp, hists_to_evsel(hists));
rtrim(hpp->buf);
- header_width += fprintf(fp, "%s", hpp->buf);
+ header_width += fprintf(fp, "%s", ltrim(hpp->buf));
}
- /* preserve max indent depth for combined sort headers */
- print_hierarchy_indent(sep, nr_sort, spaces, fp);
-
fprintf(fp, "\n# ");
/* preserve max indent depth for initial dots */
fprintf(fp, "%.*s", width, dots);
}
+ depth = 0;
hists__for_each_format(hists, fmt) {
if (!perf_hpp__is_sort_entry(fmt) && !perf_hpp__is_dynamic_entry(fmt))
continue;
continue;
width = fmt->width(fmt, hpp, hists_to_evsel(hists));
+ width += depth * HIERARCHY_INDENT;
+
if (width > header_width)
header_width = width;
+
+ depth++;
}
fprintf(fp, "%s%-.*s", sep ?: " ", header_width, dots);
- /* preserve max indent depth for dots under sort headers */
- print_hierarchy_indent(sep, nr_sort, dots, fp);
-
fprintf(fp, "\n#\n");
return 2;