From 1e5de389da4c5043b8aed81138c4980fad7393e3 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 16 Feb 2009 07:46:24 +0000 Subject: * 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- win32/win32.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'win32/win32.c') 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 #include #include +#if _MSC_VER >= 1400 +#include +#endif #ifdef __MINGW32__ #include #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;} -- cgit v1.2.3