Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 147654
b: refs/heads/master
c: 13d0ab5
h: refs/heads/master
v: v3
  • Loading branch information
Ingo Molnar committed Jun 4, 2009
1 parent 977c643 commit e48751e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8fc0321f1ad0ffef969056dda91b453bbd7a494d
refs/heads/master: 13d0ab5ec29852a6925f612830fa9e822669ece6
17 changes: 14 additions & 3 deletions trunk/Documentation/perf_counter/util/color.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "cache.h"
#include "color.h"

int perf_use_color_default = 0;
int perf_use_color_default = -1;

static int parse_color(const char *name, int len)
{
Expand Down Expand Up @@ -169,10 +169,20 @@ static int color_vfprintf(FILE *fp, const char *color, const char *fmt,
{
int r = 0;

if (*color)
/*
* Auto-detect:
*/
if (perf_use_color_default < 0) {
if (isatty(1) || pager_in_use())
perf_use_color_default = 1;
else
perf_use_color_default = 0;
}

if (perf_use_color_default && *color)
r += fprintf(fp, "%s", color);
r += vfprintf(fp, fmt, args);
if (*color)
if (perf_use_color_default && *color)
r += fprintf(fp, "%s", PERF_COLOR_RESET);
if (trail)
r += fprintf(fp, "%s", trail);
Expand All @@ -185,6 +195,7 @@ int color_fprintf(FILE *fp, const char *color, const char *fmt, ...)
{
va_list args;
int r;

va_start(args, fmt);
r = color_vfprintf(fp, color, fmt, args, NULL);
va_end(args);
Expand Down

0 comments on commit e48751e

Please sign in to comment.