From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Arnaldo Carvalho de Melo <acme@redhat.com>,
David Ahern <dsahern@gmail.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Jiri Olsa <jolsa@redhat.com>, Mike Galbraith <efault@gmx.de>,
Namhyung Kim <namhyung@gmail.com>,
Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <peterz@infradead.org>,
Stephane Eranian <eranian@google.com>
Subject: [PATCH 07/20] perf lib: Introduce rtrim
Date: Tue, 19 Jun 2012 14:50:08 -0300 [thread overview]
Message-ID: <1340128221-17348-8-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1340128221-17348-1-git-send-email-acme@infradead.org>
From: Arnaldo Carvalho de Melo <acme@redhat.com>
Remove the trailing whitespaces.
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-8bxozh5lyixgjmziqaxo9675@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/string.c | 22 ++++++++++++++++++++++
tools/perf/util/util.h | 2 ++
2 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
index d583638..199bc4d 100644
--- a/tools/perf/util/string.c
+++ b/tools/perf/util/string.c
@@ -313,3 +313,25 @@ int strtailcmp(const char *s1, const char *s2)
return 0;
}
+/**
+ * rtrim - Removes trailing whitespace from @s.
+ * @s: The string to be stripped.
+ *
+ * Note that the first trailing whitespace is replaced with a %NUL-terminator
+ * in the given string @s. Returns @s.
+ */
+char *rtrim(char *s)
+{
+ size_t size = strlen(s);
+ char *end;
+
+ if (!size)
+ return s;
+
+ end = s + size - 1;
+ while (end >= s && isspace(*end))
+ end--;
+ *(end + 1) = '\0';
+
+ return s;
+}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 2daaedb..b13c733 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -264,4 +264,6 @@ bool is_power_of_2(unsigned long n)
size_t hex_width(u64 v);
+char *rtrim(char *s);
+
#endif
--
1.7.1
next prev parent reply other threads:[~2012-06-19 18:00 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-19 17:50 [GIT PULL 00/20] perf/core improvements Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 01/20] perf tools: Add sort by src line/number Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 02/20] perf ui: Introduce struct perf_error_ops Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 03/20] perf ui/gtk: Introduce struct perf_gtk_context Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 04/20] perf ui/gtk: Add GTK statusbar widget to browser window Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 05/20] perf ui/gtk: Add GTK info_bar " Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 06/20] perf ui/gtk: Use struct perf_error_ops Arnaldo Carvalho de Melo
2012-06-19 17:50 ` Arnaldo Carvalho de Melo [this message]
2012-06-19 17:50 ` [PATCH 08/20] perf hists browser: Implement printing snapshots to files Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 09/20] perf evsel: Carve out event modifier formatting Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 10/20] perf tools: Reconstruct hw cache event with modifiers from perf_event_attr Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 11/20] perf tools: Reconstruct sw " Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 12/20] perf evsel: Handle all event types in perf_evsel__name Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 13/20] perf tools: Move all users of event_name to perf_evsel__name Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 14/20] perf script: Replace __event_name uses with perf_evsel__name Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 15/20] perf tools: Don't access evsel->name directly Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 16/20] perf tools: Remove __event_name Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 17/20] perf evsel: Reconstruct raw event with modifiers from perf_event_attr Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 18/20] perf tools: Remove unused evsel parameter from machine__resolve_callchain Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 19/20] perf evsel: Make some methods private Arnaldo Carvalho de Melo
2012-06-19 17:50 ` [PATCH 20/20] perf annotate: Check null of sym pointer before using it Arnaldo Carvalho de Melo
2012-06-20 12:01 ` [GIT PULL 00/20] perf/core improvements Ingo Molnar
2012-06-20 14:07 ` Namhyung Kim
2012-06-20 14:49 ` Ingo Molnar
2012-06-22 4:16 ` Namhyung Kim
2012-06-25 8:22 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1340128221-17348-8-git-send-email-acme@infradead.org \
--to=acme@infradead.org \
--cc=acme@redhat.com \
--cc=dsahern@gmail.com \
--cc=efault@gmx.de \
--cc=eranian@google.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@gmail.com \
--cc=paulus@samba.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®