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>
This commit is contained in:
parent
62c15fc49b
commit
befe341468
|
@ -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)
|
static int show_one_line(FILE *fp, int l, bool skip, bool show_num)
|
||||||
{
|
{
|
||||||
char buf[LINEBUF_SIZE];
|
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)
|
do {
|
||||||
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') {
|
|
||||||
if (fgets(buf, LINEBUF_SIZE, fp) == NULL)
|
if (fgets(buf, LINEBUF_SIZE, fp) == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
if (!skip) {
|
if (skip)
|
||||||
if (show_num)
|
continue;
|
||||||
fprintf(stdout, "%s", buf);
|
if (!prefix) {
|
||||||
else
|
prefix = show_num ? "%7d " : " ";
|
||||||
color_fprintf(stdout, color, "%s", buf);
|
color_fprintf(stdout, color, prefix, l);
|
||||||
}
|
}
|
||||||
}
|
color_fprintf(stdout, color, "%s", buf);
|
||||||
|
|
||||||
|
} while (strchr(buf, '\n') == NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
error:
|
error:
|
||||||
|
|
Loading…
Reference in New Issue