[tip:perf/core] perf probe: Rewrite show_one_line() to make it simpler

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: tip-bot for Franck Bui-Huu
Date: Wednesday, December 22, 2010 - 4:30 am

Commit-ID:  befe341468f4e61ecaf337a0237f2aab76817437
Gitweb:     http://git.kernel.org/tip/befe341468f4e61ecaf337a0237f2aab76817437
Author:     Franck Bui-Huu <fbuihuu@gmail.com>
AuthorDate: Mon, 20 Dec 2010 15:18:01 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Tue, 21 Dec 2010 16:20:11 -0200

perf probe: Rewrite show_one_line() to make it simpler

Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
LKML-Reference: <1292854685-8230-3-git-send-email-fbuihuu@gmail.com>
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-event.c |   29 +++++++++++------------------
 1 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 0163fc0..327604c 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -290,28 +290,21 @@ static int get_real_path(const char *raw_path, const char *comp_dir,
 static int show_one_line(FILE *fp, int l, bool skip, bool show_num)
 {
 	char buf[LINEBUF_SIZE];
-	const char *color = PERF_COLOR_BLUE;
+	const char *color = show_num ? "" : PERF_COLOR_BLUE;
+	const char *prefix = NULL;
 
-	if (fgets(buf, LINEBUF_SIZE, fp) == NULL)
-		goto error;
-	if (!skip) {
-		if (show_num)
-			fprintf(stdout, "%7d  %s", l, buf);
-		else
-			color_fprintf(stdout, color, "         %s", buf);
-	}
-
-	while (strlen(buf) == LINEBUF_SIZE - 1 &&
-	       buf[LINEBUF_SIZE - 2] != '\n') {
+	do {
 		if (fgets(buf, LINEBUF_SIZE, fp) == NULL)
 			goto error;
-		if (!skip) {
-			if (show_num)
-				fprintf(stdout, "%s", buf);
-			else
-				color_fprintf(stdout, color, "%s", buf);
+		if (skip)
+			continue;
+		if (!prefix) {
+			prefix = show_num ? "%7d  " : "         ";
+			color_fprintf(stdout, color, prefix, l);
 		}
-	}
+		color_fprintf(stdout, color, "%s", buf);
+
+	} while (strchr(buf, '\n') == NULL);
 
 	return 0;
 error:
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/6] Minor cleanups &amp; fixes for perf-probe(1), Franck Bui-Huu, (Mon Dec 20, 7:17 am)
Re: [PATCH 1/6] perf-tools: make perf-probe -L display the ..., Masami Hiramatsu, (Mon Dec 20, 10:30 pm)
Re: [PATCH 6/6] perf-probe: handle gracefully some stupid ..., Masami Hiramatsu, (Tue Dec 21, 6:10 am)
Re: [PATCH 0/6] Minor cleanups &amp; fixes for perf-probe(1), Masami Hiramatsu, (Tue Dec 21, 6:11 am)
Re: [PATCH 0/6] Minor cleanups &amp; fixes for perf-probe(1), Franck Bui-Huu, (Tue Dec 21, 11:01 am)
Re: [PATCH 0/6] Minor cleanups &amp; fixes for perf-probe(1), Arnaldo Carvalho de Melo, (Tue Dec 21, 2:05 pm)
[tip:perf/core] perf probe: Make -L display the absolute p ..., tip-bot for Franck B ..., (Wed Dec 22, 4:30 am)
[tip:perf/core] perf probe: Rewrite show_one_line() to mak ..., tip-bot for Franck B ..., (Wed Dec 22, 4:30 am)
[tip:perf/core] perf probe: Clean up redundant tests in sh ..., tip-bot for Franck B ..., (Wed Dec 22, 4:31 am)
[tip:perf/core] perf probe: Fix line range description sin ..., tip-bot for Franck B ..., (Wed Dec 22, 4:31 am)
[tip:perf/core] perf probe: Don't always consider EOF as a ..., tip-bot for Franck B ..., (Wed Dec 22, 4:31 am)
[tip:perf/core] perf probe: Handle gracefully some stupid ..., tip-bot for Franck B ..., (Wed Dec 22, 4:32 am)
Re: [tip:perf/core] perf probe: Don't always consider EOF ..., Arnaldo Carvalho de Melo, (Wed Dec 22, 7:43 am)
Re: [PATCH 0/6] Minor cleanups &amp; fixes for perf-probe(1), Masami Hiramatsu, (Thu Dec 23, 5:36 pm)
[tip:perf/core] perf probe: Fix wrong warning in __show_on ..., tip-bot for Franck B ..., (Sat Dec 25, 1:58 am)