perf tools: Introduce trim function
authorJiri Olsa <jolsa@kernel.org>
Thu, 7 Apr 2016 07:11:11 +0000 (09:11 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 7 Apr 2016 13:21:49 +0000 (10:21 -0300)
To be used in cases for both sides trim.

Signed-off-by: Jiri 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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/ui/browsers/hists.c
tools/perf/ui/stdio/hist.c
tools/perf/util/util.h

index 2a83414159a65a026195f102c164ed6f6eae45be..e70df2e54d6676087237bb3e89231e67eb1a2a9a 100644 (file)
@@ -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));
                        dummy_hpp.buf[ret] = '\0';
-                       rtrim(dummy_hpp.buf);
 
-                       start = ltrim(dummy_hpp.buf);
+                       start = trim(dummy_hpp.buf);
                        ret = strlen(start);
 
                        if (start != dummy_hpp.buf)
index 7aff5acf3265782e03254de2d8bc1dfafb56e03a..560eb47d56f945acbbdc188d6a8fb3e407faf41e 100644 (file)
@@ -569,9 +569,8 @@ static int print_hierarchy_header(struct hists *hists, struct perf_hpp *hpp,
                        first_col = false;
 
                        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));
                }
        }
 
index 8298d607c7383a4255f43e42f1eae219189f8209..3bf3de86d4297b5f21e893f2e6b315bc8bbe3abd 100644 (file)
@@ -254,6 +254,11 @@ int hex2u64(const char *ptr, u64 *val);
 char *ltrim(char *s);
 char *rtrim(char *s);
 
+static inline char *trim(char *s)
+{
+       return ltrim(rtrim(s));
+}
+
 void dump_stack(void);
 void sighandler_dump_stack(int sig);