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

ruby-changes:10772

From: nobu <ko1@a...>
Date: Mon, 16 Feb 2009 16:46:36 +0900 (JST)
Subject: [ruby-changes:10772] Ruby:r22337 (trunk): * debug.c (set_debug_option): added rtc_error option.

nobu	2009-02-16 16:46:24 +0900 (Mon, 16 Feb 2009)

  New Revision: 22337

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22337

  Log:
    * debug.c (set_debug_option): added rtc_error option.
    * win32/Makefile.sub (CRTDEFFLAGS): separated from DEFS.
    
    * win32/win32.c (rtc_error_handler): ignores RTC errors unless
      rtc_error debug option is given.
    
    * win32/win32.c (rb_w32_sysinit): suppress useless CRT assertions.
      [ruby-core:22116]

  Modified files:
    trunk/ChangeLog
    trunk/debug.c
    trunk/win32/Makefile.sub
    trunk/win32/win32.c

Index: debug.c
===================================================================
--- debug.c	(revision 22336)
+++ debug.c	(revision 22337)
@@ -148,6 +148,9 @@
     } while (0)
     SET_WHEN("gc_stress", *ruby_initial_gc_stress_ptr);
     SET_WHEN("core", ruby_enable_coredump);
+#if defined _WIN32 && defined _MSC_VER && _MSC_VER >= 1400
+    SET_WHEN("rtc_error", ruby_w32_rtc_error);
+#endif
     fprintf(stderr, "unexpected debug option: %.*s\n", len, str);
 }
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 22336)
+++ ChangeLog	(revision 22337)
@@ -1,8 +1,15 @@
-Mon Feb 16 01:17:51 2009  Nobuyoshi Nakada  <nobu@r...>
+Mon Feb 16 16:46:14 2009  Nobuyoshi Nakada  <nobu@r...>
 
-	* win32/win32.c (_CrtDbgReportW): prevent from false positive
-	  assertions in msvcrtd.  [ruby-core:22116]
+	* debug.c (set_debug_option): added rtc_error option.
 
+	* win32/Makefile.sub (CRTDEFFLAGS): separated from DEFS.
+
+	* win32/win32.c (rtc_error_handler): ignores RTC errors unless
+	  rtc_error debug option is given.
+
+	* win32/win32.c (rb_w32_sysinit): suppress useless CRT assertions.
+	  [ruby-core:22116]
+
 Sun Feb 15 21:43:44 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/ostruct.rb (OpenStruct#new_ostruct_member): checks if frozen.
Index: win32/win32.c
===================================================================
--- win32/win32.c	(revision 22336)
+++ win32/win32.c	(revision 22337)
@@ -29,6 +29,9 @@
 #include <share.h>
 #include <shlobj.h>
 #include <mbstring.h>
+#if _MSC_VER >= 1400
+#include <crtdbg.h>
+#endif
 #ifdef __MINGW32__
 #include <mswsock.h>
 #endif
@@ -439,10 +442,29 @@
 static void init_stdhandle(void);
 
 #if _MSC_VER >= 1400
-static void invalid_parameter(const wchar_t *expr, const wchar_t *func, const wchar_t *file, unsigned int line, uintptr_t dummy)
+static void
+invalid_parameter(const wchar_t *expr, const wchar_t *func, const wchar_t *file, unsigned int line, uintptr_t dummy)
 {
     // nothing to do
 }
+
+int ruby_w32_rtc_error;
+
+static int __cdecl
+rtc_error_handler(int e, const char *src, int line, const char *exe, const char *fmt, ...)
+{
+    va_list ap;
+    VALUE str;
+
+    if (!ruby_w32_rtc_error) return 0;
+    str = rb_sprintf("%s:%d: ", src, line);
+    va_start(ap, fmt);
+    rb_str_vcatf(str, fmt, ap);
+    va_end(ap);
+    rb_str_cat(str, "\n", 1);
+    rb_write_error2(RSTRING_PTR(str), RSTRING_LEN(str));
+    return 0;
+}
 #endif
 
 static CRITICAL_SECTION select_mutex;
@@ -496,7 +518,9 @@
 #if _MSC_VER >= 1400
     static void set_pioinfo_extra(void);
 
+    _CrtSetReportMode(_CRT_ASSERT, 0);
     _set_invalid_parameter_handler(invalid_parameter);
+    _RTC_SetErrorFunc(rtc_error_handler);
     set_pioinfo_extra();
 #endif
 
@@ -4873,5 +4897,3 @@
     return f;
 }
 #endif
-
-RUBY_EXTERN int __cdecl _CrtDbgReportW() {return 0;}
Index: win32/Makefile.sub
===================================================================
--- win32/Makefile.sub	(revision 22336)
+++ win32/Makefile.sub	(revision 22337)
@@ -188,13 +188,13 @@
 XCFLAGS = -DRUBY_EXPORT -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) -I$(srcdir)/missing $(XCFLAGS)
 !if $(MSC_VER) >= 1400
 # Prevents VC++ 2005 (cl ver 14) warnings
-DEFS = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
+CRTDEFFLAGS = -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE
 MANIFESTTOOL = mt -nologo
 LDSHARED_0 = @$(MINIRUBY) -run -e wait_writable -- -n 10 $@
 LDSHARED_1 = $(MANIFESTTOOL) -manifest $(@).manifest -outputresource:$(@);2
 LDSHARED_2 = @$(RM) $(@:/=\).manifest
 !endif
-CPPFLAGS = $(DEFS) $(ARCHDEFS) $(CPPFLAGS)
+CPPFLAGS = $(CRTDEFFLAGS) $(DEFS) $(ARCHDEFS) $(CPPFLAGS)
 
 DLDFLAGS = $(LDFLAGS) -dll
 SOLIBS = 

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

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