[前][次][番号順一覧][スレッド一覧]

ruby-changes:45244

From: nobu <ko1@a...>
Date: Fri, 13 Jan 2017 11:57:52 +0900 (JST)
Subject: [ruby-changes:45244] nobu:r57317 (trunk): error.c: moved

nobu	2017-01-13 11:57:45 +0900 (Fri, 13 Jan 2017)

  New Revision: 57317

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57317

  Log:
    error.c: moved
    
    * error.c (preface_dump, postscript_dump): moved from
      rb_vm_bugreport to place the last important message at the very
      last after [NOTE].

  Modified files:
    trunk/error.c
    trunk/test/ruby/test_rubyoptions.rb
    trunk/vm_dump.c
Index: vm_dump.c
===================================================================
--- vm_dump.c	(revision 57316)
+++ vm_dump.c	(revision 57317)
@@ -922,72 +922,6 @@ rb_dump_machine_register(const ucontext_ https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L922
 # define rb_dump_machine_register(ctx) ((void)0)
 #endif /* HAVE_PRINT_MACHINE_REGISTERS */
 
-FUNC_MINIMIZED(static void bug_important_message(FILE *out, const char *const msg, size_t len));
-
-static void
-bug_important_message(FILE *out, const char *const msg, size_t len)
-{
-    const char *const endmsg = msg + len;
-    const char *p = msg;
-
-    if (!len) return;
-    if (isatty(fileno(out))) {
-	static const char red[] = "\033[;31;1;7m";
-	static const char green[] = "\033[;32;7m";
-	static const char reset[] = "\033[m";
-	const char *e = strchr(p, '\n');
-	const int w = (int)(e - p);
-	do {
-	    int i = (int)(e - p);
-	    fputs(*p == ' ' ? green : red, out);
-	    fwrite(p, 1, e - p, out);
-	    for (; i < w; ++i) fputc(' ', out);
-	    fputs(reset, out);
-	    fputc('\n', out);
-	} while ((p = e + 1) < endmsg && (e = strchr(p, '\n')) != 0 && e > p + 1);
-    }
-    fwrite(p, 1, endmsg - p, out);
-}
-
-static void
-preface_dump(void)
-{
-#if defined __APPLE__
-    static const char msg[] = ""
-	"-- Crash Report log information "
-	"--------------------------------------------\n"
-	"   See Crash Report log file under the one of following:\n"
-	"     * ~/Library/Logs/CrashReporter\n"
-	"     * /Library/Logs/CrashReporter\n"
-	"     * ~/Library/Logs/DiagnosticReports\n"
-	"     * /Library/Logs/DiagnosticReports\n"
-	"   for more details.\n"
-	"Don't forget to include the above Crash Report log file in bug reports.\n"
-	"\n";
-    const size_t msglen = sizeof(msg) - 1;
-#else
-    const char *msg = NULL;
-    const size_t msglen = 0;
-#endif
-    bug_important_message(stderr, msg, msglen);
-}
-
-static void
-postscript_dump(void)
-{
-#if defined __APPLE__
-    static const char msg[] = ""
-	"[IMPORTANT]\n"
-	"Don't forget to include the Crash Report log file in bug reports.\n"
-	"\n";
-    const size_t msglen = sizeof(msg) - 1;
-#else
-    const char *msg = NULL;
-    const size_t msglen = 0;
-#endif
-    bug_important_message(stderr, msg, msglen);
-}
-
 void
 rb_vm_bugreport(const void *ctx)
 {
@@ -1001,8 +935,6 @@ rb_vm_bugreport(const void *ctx) https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L935
 #endif
     const rb_vm_t *const vm = GET_VM();
 
-    preface_dump();
-
     if (vm) {
 	SDR();
 	rb_backtrace_print_as_bugreport();
@@ -1109,6 +1041,4 @@ rb_vm_bugreport(const void *ctx) https://github.com/ruby/ruby/blob/trunk/vm_dump.c#L1041
 	}
 #endif /* __FreeBSD__ */
     }
-
-    postscript_dump();
 }
Index: error.c
===================================================================
--- error.c	(revision 57316)
+++ error.c	(revision 57317)
@@ -336,6 +336,72 @@ bug_report_file(const char *file, int li https://github.com/ruby/ruby/blob/trunk/error.c#L336
     return NULL;
 }
 
+FUNC_MINIMIZED(static void bug_important_message(FILE *out, const char *const msg, size_t len));
+
+static void
+bug_important_message(FILE *out, const char *const msg, size_t len)
+{
+    const char *const endmsg = msg + len;
+    const char *p = msg;
+
+    if (!len) return;
+    if (isatty(fileno(out))) {
+	static const char red[] = "\033[;31;1;7m";
+	static const char green[] = "\033[;32;7m";
+	static const char reset[] = "\033[m";
+	const char *e = strchr(p, '\n');
+	const int w = (int)(e - p);
+	do {
+	    int i = (int)(e - p);
+	    fputs(*p == ' ' ? green : red, out);
+	    fwrite(p, 1, e - p, out);
+	    for (; i < w; ++i) fputc(' ', out);
+	    fputs(reset, out);
+	    fputc('\n', out);
+	} while ((p = e + 1) < endmsg && (e = strchr(p, '\n')) != 0 && e > p + 1);
+    }
+    fwrite(p, 1, endmsg - p, out);
+}
+
+static void
+preface_dump(FILE *out)
+{
+#if defined __APPLE__
+    static const char msg[] = ""
+	"-- Crash Report log information "
+	"--------------------------------------------\n"
+	"   See Crash Report log file under the one of following:\n"
+	"     * ~/Library/Logs/CrashReporter\n"
+	"     * /Library/Logs/CrashReporter\n"
+	"     * ~/Library/Logs/DiagnosticReports\n"
+	"     * /Library/Logs/DiagnosticReports\n"
+	"   for more details.\n"
+	"Don't forget to include the above Crash Report log file in bug reports.\n"
+	"\n";
+    const size_t msglen = sizeof(msg) - 1;
+#else
+    const char *msg = NULL;
+    const size_t msglen = 0;
+#endif
+    bug_important_message(out, msg, msglen);
+}
+
+static void
+postscript_dump(FILE *out)
+{
+#if defined __APPLE__
+    static const char msg[] = ""
+	"[IMPORTANT]\n"
+	"Don't forget to include the Crash Report log file in bug reports.\n"
+	"\n";
+    const size_t msglen = sizeof(msg) - 1;
+#else
+    const char *msg = NULL;
+    const size_t msglen = 0;
+#endif
+    bug_important_message(out, msg, msglen);
+}
+
 static void
 bug_report_begin_valist(FILE *out, const char *fmt, va_list args)
 {
@@ -346,6 +412,7 @@ bug_report_begin_valist(FILE *out, const https://github.com/ruby/ruby/blob/trunk/error.c#L412
     fputs(buf, out);
     snprintf(buf, sizeof(buf), "\n%s\n\n", ruby_description);
     fputs(buf, out);
+    preface_dump(out);
 }
 
 #define bug_report_begin(out, fmt) do { \
@@ -366,7 +433,8 @@ bug_report_end(FILE *out) https://github.com/ruby/ruby/blob/trunk/error.c#L433
 	    (*reporter->func)(out, reporter->data);
 	}
     }
-    fprintf(out, REPORTBUG_MSG);
+    fputs(REPORTBUG_MSG, out);
+    postscript_dump(out);
 }
 
 #define report_bug(file, line, fmt, ctx) do { \
@@ -487,6 +555,7 @@ rb_assert_failure(const char *file, int https://github.com/ruby/ruby/blob/trunk/error.c#L555
     fprintf(out, "Assertion Failed: %s:%d:", file, line);
     if (name) fprintf(out, "%s:", name);
     fprintf(out, "%s\n%s\n\n", expr, ruby_description);
+    preface_dump(out);
     rb_vm_bugreport(NULL);
     bug_report_end(out);
     die();
Index: test/ruby/test_rubyoptions.rb
===================================================================
--- test/ruby/test_rubyoptions.rb	(revision 57316)
+++ test/ruby/test_rubyoptions.rb	(revision 57317)
@@ -587,6 +587,11 @@ class TestRubyOptions < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L587
         (?:.*\n)?
         For\sdetails:\shttp:\/\/.*\.ruby-lang\.org/.*\n
         \n
+        (?:
+          \[IMPORTANT\]\n
+          .*\n
+          \n
+        )?
       )x,
     ]
     ExpectedStderrList << additional if additional

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]