diff options
author | Franck Bui-Huu <fbuihuu@gmail.com> | 2010-12-20 09:18:01 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-12-21 13:20:11 -0500 |
commit | befe341468f4e61ecaf337a0237f2aab76817437 (patch) | |
tree | 468b4e1cb810a104311672ce7449e7428391ce19 /tools/perf/util | |
parent | 62c15fc49bd1b35d79b34ea96f132ab435e2215a (diff) |
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/perf/util')
-rw-r--r-- | 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 0163fc0d25aa..327604c1253f 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, | |||
290 | static int show_one_line(FILE *fp, int l, bool skip, bool show_num) | 290 | static int show_one_line(FILE *fp, int l, bool skip, bool show_num) |
291 | { | 291 | { |
292 | char buf[LINEBUF_SIZE]; | 292 | char buf[LINEBUF_SIZE]; |
293 | const char *color = PERF_COLOR_BLUE; | 293 | const char *color = show_num ? "" : PERF_COLOR_BLUE; |
294 | const char *prefix = NULL; | ||
294 | 295 | ||
295 | if (fgets(buf, LINEBUF_SIZE, fp) == NULL) | 296 | do { |
296 | goto error; | ||
297 | if (!skip) { | ||
298 | if (show_num) | ||
299 | fprintf(stdout, "%7d %s", l, buf); | ||
300 | else | ||
301 | color_fprintf(stdout, color, " %s", buf); | ||
302 | } | ||
303 | |||
304 | while (strlen(buf) == LINEBUF_SIZE - 1 && | ||
305 | buf[LINEBUF_SIZE - 2] != '\n') { | ||
306 | if (fgets(buf, LINEBUF_SIZE, fp) == NULL) | 297 | if (fgets(buf, LINEBUF_SIZE, fp) == NULL) |
307 | goto error; | 298 | goto error; |
308 | if (!skip) { | 299 | if (skip) |
309 | if (show_num) | 300 | continue; |
310 | fprintf(stdout, "%s", buf); | 301 | if (!prefix) { |
311 | else | 302 | prefix = show_num ? "%7d " : " "; |
312 | color_fprintf(stdout, color, "%s", buf); | 303 | color_fprintf(stdout, color, prefix, l); |
313 | } | 304 | } |
314 | } | 305 | color_fprintf(stdout, color, "%s", buf); |
306 | |||
307 | } while (strchr(buf, '\n') == NULL); | ||
315 | 308 | ||
316 | return 0; | 309 | return 0; |
317 | error: | 310 | error: |