summaryrefslogtreecommitdiff
path: root/vm_dump.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-12 06:50:05 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-12 06:50:05 (GMT)
commit218617161f0c4bd10c5865052183e269b3f2fa9a (patch)
treeba41f0df03d87e65a452102cd7237307f4c0e821 /vm_dump.c
parent92430a031df42344a40ec050f6db8ff4b853e6e5 (diff)
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
Diffstat (limited to 'vm_dump.c')
-rw-r--r--vm_dump.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/vm_dump.c b/vm_dump.c
index f0d56ba..7766c27 100644
--- a/vm_dump.c
+++ b/vm_dump.c
@@ -950,8 +950,29 @@ preface_dump(void)
" * /Library/Logs/DiagnosticReports\n"
" for more details.\n"
"\n";
-
- fputs(msg, stderr);
+ 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"
+
+ 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
}