ruby-changes:38391
From: nobu <ko1@a...>
Date: Tue, 12 May 2015 15:50:15 +0900 (JST)
Subject: [ruby-changes:38391] nobu:r50472 (trunk): vm_dump.c: highlight preface
nobu 2015-05-12 15:50:05 +0900 (Tue, 12 May 2015) New Revision: 50472 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50472 Log: vm_dump.c: highlight preface * vm_dump.c (preface_dump): highlight very important but very ofhen ignored message like a Xmas tree. Modified files: trunk/vm_dump.c Index: vm_dump.c =================================================================== --- vm_dump.c (revision 50471) +++ vm_dump.c (revision 50472) @@ -950,8 +950,29 @@ preface_dump(void) https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L950 " * /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 } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/