aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorFranck Bui-Huu <fbuihuu@gmail.com>2010-12-20 15:18:01 +0100
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-12-21 16:20:11 -0200
commitbefe341468f4e61ecaf337a0237f2aab76817437 (patch)
tree468b4e1cb810a104311672ce7449e7428391ce19 /tools
parent62c15fc49bd1b35d79b34ea96f132ab435e2215a (diff)
downloadkernel_samsung_crespo-befe341468f4e61ecaf337a0237f2aab76817437.zip
kernel_samsung_crespo-befe341468f4e61ecaf337a0237f2aab76817437.tar.gz
kernel_samsung_crespo-befe341468f4e61ecaf337a0237f2aab76817437.tar.bz2
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/probe-event.c29
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: