Commit 7d6a7e78 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf tools: Introduce trim function

To be used in cases for both sides trim.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Andreas Hollmann <hollmann@in.tum.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1460013073-18444-1-git-send-email-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent d1d438a3
...@@ -1607,9 +1607,8 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows ...@@ -1607,9 +1607,8 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists)); ret = fmt->header(fmt, &dummy_hpp, hists_to_evsel(hists));
dummy_hpp.buf[ret] = '\0'; dummy_hpp.buf[ret] = '\0';
rtrim(dummy_hpp.buf);
start = ltrim(dummy_hpp.buf); start = trim(dummy_hpp.buf);
ret = strlen(start); ret = strlen(start);
if (start != dummy_hpp.buf) if (start != dummy_hpp.buf)
......
...@@ -569,9 +569,8 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp, ...@@ -569,9 +569,8 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
first_col = false; first_col = false;
fmt->header(fmt, hpp, hists_to_evsel(hists)); fmt->header(fmt, hpp, hists_to_evsel(hists));
rtrim(hpp->buf);
header_width += fprintf(fp, "%s", ltrim(hpp->buf)); header_width += fprintf(fp, "%s", trim(hpp->buf));
} }
} }
......
...@@ -254,6 +254,11 @@ int hex2u64(const char *ptr, u64 *val); ...@@ -254,6 +254,11 @@ int hex2u64(const char *ptr, u64 *val);
char *ltrim(char *s); char *ltrim(char *s);
char *rtrim(char *s); char *rtrim(char *s);
static inline char *trim(char *s)
{
return ltrim(rtrim(s));
}
void dump_stack(void); void dump_stack(void);
void sighandler_dump_stack(int sig); void sighandler_dump_stack(int sig);
......
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