aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog13
-rw-r--r--debug.c3
-rw-r--r--win32/Makefile.sub4
-rw-r--r--win32/win32.c28
4 files changed, 40 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 8edb3d5739..787aa708fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,14 @@
-Mon Feb 16 01:17:51 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Mon Feb 16 16:46:14 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
- * 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@ruby-lang.org>
diff --git a/debug.c b/debug.c
index 265e864aec..bcf2817fe1 100644
--- a/debug.c
+++ b/debug.c
@@ -148,6 +148,9 @@ set_debug_option(const char *str, int len, void *arg)
} 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);
}
diff --git a/win32/Makefile.sub b/win32/Makefile.sub
index 2f200a8424..765951be83 100644
--- a/win32/Makefile.sub
+++ b/win32/Makefile.sub
@@ -188,13 +188,13 @@ LDSHARED = $(LD) -LD
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 =
diff --git a/win32/win32.c b/win32/win32.c
index ead75f37df..3bd857253a 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -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 @@ init_func(void)
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 @@ rb_w32_sysinit(int *argc, char ***argv)
#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 @@ rb_w32_fsopen(const char *path, const char *mode, int shflags)
return f;
}
#endif
-
-RUBY_EXTERN int __cdecl _CrtDbgReportW() {return 0;}