mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
vm_dump.c: highlight preface
* vm_dump.c (preface_dump): highlight very important but very ofhen ignored message like a Xmas tree. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
92430a031d
commit
218617161f
1 changed files with 22 additions and 1 deletions
23
vm_dump.c
23
vm_dump.c
|
@ -950,8 +950,29 @@ preface_dump(void)
|
|||
" * /Library/Logs/DiagnosticReports\n"
|
||||
" for more details.\n"
|
||||
"\n";
|
||||
const char *const endmsg = msg + sizeof(msg) - 1;
|
||||
const char *p = msg;
|
||||
#define RED "\033[;31;1;7m"
|
||||
#define GREEN "\033[;32;7m"
|
||||
#define RESET "\033[m"
|
||||
|
||||
fputs(msg, stderr);
|
||||
if (isatty(fileno(stderr))) {
|
||||
const char *e = strchr(p, '\n');
|
||||
const int w = (int)(e - p);
|
||||
fputs(RED, stderr);
|
||||
fwrite(p, 1, w, stderr);
|
||||
fputs(RESET, stderr);
|
||||
fputc('\n', stderr);
|
||||
while ((p = e + 1) < endmsg && (e = strchr(p, '\n')) != 0 && e > p + 1) {
|
||||
int i = (int)(e - p);
|
||||
fputs(GREEN, stderr);
|
||||
fwrite(p, 1, e - p, stderr);
|
||||
for (; i < w; ++i) fputc(' ', stderr);
|
||||
fputs(RESET, stderr);
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
}
|
||||
fwrite(p, 1, endmsg - p, stderr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue