diff options
author | Ian Rogers <irogers@google.com> | 2022-11-17 18:46:05 -0800 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2022-11-24 10:02:40 -0300 |
commit | 1a9c20b45d193ead21dc63b07d1abb40b0a237c2 (patch) | |
tree | 9f7102d477696ce4d1affe62f2e833502b8df0bd /tools/perf/builtin-list.c | |
parent | 6f520ce17920b3cdfbd2479b3ccf27f9706219d0 (diff) | |
download | linux-1a9c20b45d193ead21dc63b07d1abb40b0a237c2.tar.gz linux-1a9c20b45d193ead21dc63b07d1abb40b0a237c2.tar.bz2 linux-1a9c20b45d193ead21dc63b07d1abb40b0a237c2.zip |
perf list: Support newlines in wordwrap
Rather than a newline starting from column 0, record a newline was
seen and then add the newline and space before the next word.
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Caleb Biggers <caleb.biggers@intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Perry Taylor <perry.taylor@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Sandipan Das <sandipan.das@amd.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Weilin Wang <weilin.wang@intel.com>
Cc: Xin Gao <gaoxin@cdjrlc.com>
Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
Link: https://lore.kernel.org/r/20221118024607.409083-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-list.c')
-rw-r--r-- | tools/perf/builtin-list.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c index 84fa2d050eac..f3750331e8f6 100644 --- a/tools/perf/builtin-list.c +++ b/tools/perf/builtin-list.c @@ -74,17 +74,19 @@ static void wordwrap(const char *s, int start, int max, int corr) { int column = start; int n; + bool saw_newline = false; while (*s) { - int wlen = strcspn(s, " \t"); + int wlen = strcspn(s, " \t\n"); - if (column + wlen >= max && column > start) { + if ((column + wlen >= max && column > start) || saw_newline) { printf("\n%*s", start, ""); column = start + corr; } n = printf("%s%.*s", column > start ? " " : "", wlen, s); if (n <= 0) break; + saw_newline = s[wlen] == '\n'; s += wlen; column += n; s = skip_spaces(s); @@ -146,7 +148,7 @@ static void default_print_event(void *ps, const char *pmu_name, const char *topi wordwrap(desc, 8, pager_get_columns(), 0); printf("]\n"); } - + long_desc = long_desc ?: desc; if (long_desc && print_state->long_desc) { printf("%*s", 8, "["); wordwrap(long_desc, 8, pager_get_columns(), 0); @@ -154,7 +156,8 @@ static void default_print_event(void *ps, const char *pmu_name, const char *topi } if (print_state->detailed && encoding_desc) { - printf("%*s%s", 8, "", encoding_desc); + printf("%*s", 8, ""); + wordwrap(encoding_desc, 8, pager_get_columns(), 0); if (metric_name) printf(" MetricName: %s", metric_name); if (metric_expr) |