Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966177AbcDMHRa (ORCPT ); Wed, 13 Apr 2016 03:17:30 -0400 Received: from terminus.zytor.com ([198.137.202.10]:50480 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964958AbcDMHR1 (ORCPT ); Wed, 13 Apr 2016 03:17:27 -0400 Date: Wed, 13 Apr 2016 00:16:59 -0700 From: tip-bot for Jiri Olsa Message-ID: Cc: tglx@linutronix.de, a.p.zijlstra@chello.nl, hpa@zytor.com, hollmann@in.tum.de, namhyung@kernel.org, dsahern@gmail.com, acme@redhat.com, mingo@kernel.org, jolsa@kernel.org, milian.wolff@kdab.com, linux-kernel@vger.kernel.org Reply-To: a.p.zijlstra@chello.nl, tglx@linutronix.de, hollmann@in.tum.de, hpa@zytor.com, acme@redhat.com, dsahern@gmail.com, namhyung@kernel.org, jolsa@kernel.org, mingo@kernel.org, linux-kernel@vger.kernel.org, milian.wolff@kdab.com In-Reply-To: <1460013073-18444-1-git-send-email-jolsa@kernel.org> References: <1460013073-18444-1-git-send-email-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Introduce trim function Git-Commit-ID: 7d6a7e782558323364bc0ae59f3523175c10b258 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2364 Lines: 71 Commit-ID: 7d6a7e782558323364bc0ae59f3523175c10b258 Gitweb: http://git.kernel.org/tip/7d6a7e782558323364bc0ae59f3523175c10b258 Author: Jiri Olsa AuthorDate: Thu, 7 Apr 2016 09:11:11 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 7 Apr 2016 10:21:49 -0300 perf tools: Introduce trim function To be used in cases for both sides trim. Signed-off-by: Jiri Olsa Cc: Andreas Hollmann Cc: David Ahern Cc: Milian Wolff Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1460013073-18444-1-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/ui/browsers/hists.c | 3 +-- tools/perf/ui/stdio/hist.c | 3 +-- tools/perf/util/util.h | 5 +++++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 2a83414..e70df2e 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c @@ -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) diff --git a/tools/perf/ui/stdio/hist.c b/tools/perf/ui/stdio/hist.c index 7aff5ac..560eb47 100644 --- a/tools/perf/ui/stdio/hist.c +++ b/tools/perf/ui/stdio/hist.c @@ -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)); } } diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 8298d60..3bf3de8 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -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);