|
Lines 246-251
Link Here
|
| 246 |
return 0; |
246 |
return 0; |
| 247 |
} |
247 |
} |
| 248 |
|
248 |
|
|
|
249 |
static const char *sgr_start = "\33[%sm\33[K"; |
| 250 |
static const char *sgr_end = "\33[m\33[K"; |
| 251 |
static const char *colors[2][3] = { |
| 252 |
{NULL, "01;35", "01;31"}, /* Bold magenta, bold red */ |
| 253 |
{NULL, "35", "31"} /* (32 - green), 35 - magenta, 31 - red */ |
| 254 |
}; |
| 255 |
|
| 256 |
static void colorize_start(FILE * fd, const int type, const int where) |
| 257 |
{ |
| 258 |
if (colors[where][type] && isatty(fileno(fd))) { |
| 259 |
fprintf(stderr, sgr_start, colors[where][type]); |
| 260 |
} |
| 261 |
} |
| 262 |
|
| 263 |
static void colorize_stop(FILE * fd, const int type, const int where) |
| 264 |
{ |
| 265 |
if (colors[where][type] && isatty(fileno(fd))) { |
| 266 |
fprintf(stderr, sgr_end); |
| 267 |
} |
| 268 |
} |
| 269 |
|
| 249 |
/* Print info to stderr and optionally to log file and optionally send mail */ |
270 |
/* Print info to stderr and optionally to log file and optionally send mail */ |
| 250 |
static int print_error(const char *msg, const int type) |
271 |
static int print_error(const char *msg, const int type) |
| 251 |
{ |
272 |
{ |
|
Lines 277-287
Link Here
|
| 277 |
log_error(msg, fatal); |
298 |
log_error(msg, fatal); |
| 278 |
} |
299 |
} |
| 279 |
|
300 |
|
|
|
301 |
colorize_start(stderr, type, 0); |
| 280 |
fprintf(stderr, "%s", prefix_std[type]); |
302 |
fprintf(stderr, "%s", prefix_std[type]); |
|
|
303 |
colorize_stop(stderr, type, 0); |
| 281 |
len = lead = strlen(prefix_std[type]); |
304 |
len = lead = strlen(prefix_std[type]); |
| 282 |
w = (char *)msg; |
305 |
w = (char *)msg; |
| 283 |
|
306 |
|
|
|
307 |
colorize_start(stderr, type, 1); |
| 284 |
while (print_word(stderr, &w, &len, lead)) ; |
308 |
while (print_word(stderr, &w, &len, lead)) ; |
|
|
309 |
colorize_stop(stderr, type, 1); |
| 285 |
|
310 |
|
| 286 |
if ((type != MSG) && isatty(fileno(stderr)) |
311 |
if ((type != MSG) && isatty(fileno(stderr)) |
| 287 |
&& (G_info_format() == G_INFO_FORMAT_STANDARD)) { /* Bell */ |
312 |
&& (G_info_format() == G_INFO_FORMAT_STANDARD)) { /* Bell */ |