[PATCH 1/4] msvcrt: Use the _set_error_mode value to switch between a dialogbox and stderr for C runtime messages [try 2]

Detlef Riekenberg wine.dev at web.de
Sun Jan 30 16:34:38 CST 2011


try 2:
Use a seperate patch for fixing MSVCRT_app_type handling

--
By by ... Detlef
---
 dlls/msvcrt/errno.c |   29 -----------------------------
 dlls/msvcrt/exit.c  |   34 ++++++++++++++++++++++++++++++----
 2 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/dlls/msvcrt/errno.c b/dlls/msvcrt/errno.c
index 70a895c..3f9f300 100644
--- a/dlls/msvcrt/errno.c
+++ b/dlls/msvcrt/errno.c
@@ -407,35 +407,6 @@ MSVCRT_wchar_t* CDECL __wcserror(const MSVCRT_wchar_t* str)
 }
 
 /******************************************************************************
- *		_set_error_mode (MSVCRT.@)
- *
- * Set the error mode, which describes where the C run-time writes error
- * messages.
- *
- * PARAMS
- *   mode - the new error mode
- *
- * RETURNS
- *   The old error mode.
- *
- * TODO
- *  This function does not have a proper implementation; the error mode is
- *  never used.
- */
-int CDECL _set_error_mode(int mode)
-{
-  static int current_mode = MSVCRT__OUT_TO_DEFAULT;
-
-  const int old = current_mode;
-  if ( MSVCRT__REPORT_ERRMODE != mode ) {
-    current_mode = mode;
-    FIXME("dummy implementation (old mode: %d, new mode: %d)\n",
-          old, mode);
-  }
-  return old;
-}
-
-/******************************************************************************
  *		_seterrormode (MSVCRT.@)
  */
 void CDECL _seterrormode(int mode)
diff --git a/dlls/msvcrt/exit.c b/dlls/msvcrt/exit.c
index ac7e9b3..6e5a58a 100644
--- a/dlls/msvcrt/exit.c
+++ b/dlls/msvcrt/exit.c
@@ -40,6 +40,7 @@ extern int MSVCRT_app_type;
 extern char *MSVCRT__pgmptr;
 
 static unsigned int MSVCRT_abort_behavior =  MSVCRT__WRITE_ABORT_MSG | MSVCRT__CALL_REPORTFAULT;
+static int MSVCRT_error_mode = MSVCRT__OUT_TO_DEFAULT;
 
 void (*CDECL _aexit_rtn)(int) = MSVCRT__exit;
 
@@ -134,8 +135,9 @@ static void DoMessageBox(LPCSTR lead, LPCSTR message)
 void CDECL _amsg_exit(int errnum)
 {
   TRACE("(%d)\n", errnum);
-  /* FIXME: text for the error number. */
-  if (MSVCRT_app_type == 2)
+
+  if ((MSVCRT_error_mode == MSVCRT__OUT_TO_MSGBOX) ||
+     ((MSVCRT_error_mode == MSVCRT__OUT_TO_DEFAULT) && (MSVCRT_app_type == 2)))
   {
     char text[32];
     sprintf(text, "Error: R60%d",errnum);
@@ -155,7 +157,8 @@ void CDECL MSVCRT_abort(void)
 
   if (MSVCRT_abort_behavior & MSVCRT__WRITE_ABORT_MSG)
   {
-    if (MSVCRT_app_type == 2)
+    if ((MSVCRT_error_mode == MSVCRT__OUT_TO_MSGBOX) ||
+       ((MSVCRT_error_mode == MSVCRT__OUT_TO_DEFAULT) && (MSVCRT_app_type == 2)))
     {
       DoMessageBox("Runtime error!", "abnormal program termination");
     }
@@ -190,7 +193,8 @@ unsigned int CDECL MSVCRT__set_abort_behavior(unsigned int flags, unsigned int m
 void CDECL MSVCRT__assert(const char* str, const char* file, unsigned int line)
 {
   TRACE("(%s,%s,%d)\n",str,file,line);
-  if (MSVCRT_app_type == 2)
+  if ((MSVCRT_error_mode == MSVCRT__OUT_TO_MSGBOX) ||
+     ((MSVCRT_error_mode == MSVCRT__OUT_TO_DEFAULT) && (MSVCRT_app_type == 2)))
   {
     char text[2048];
     snprintf(text, sizeof(text), "File: %s\nLine: %d\n\nExpression: \"%s\"", file, line, str);
@@ -296,3 +300,25 @@ void CDECL _purecall(void)
       purecall_handler();
   _amsg_exit( 25 );
 }
+
+/******************************************************************************
+ *		_set_error_mode (MSVCRT.@)
+ *
+ * Set the error mode, which describes where the C run-time writes error messages.
+ *
+ * PARAMS
+ *   mode - the new error mode
+ *
+ * RETURNS
+ *   The old error mode.
+ *
+ */
+int CDECL _set_error_mode(int mode)
+{
+
+  const int old = MSVCRT_error_mode;
+  if ( MSVCRT__REPORT_ERRMODE != mode ) {
+    MSVCRT_error_mode = mode;
+  }
+  return old;
+}
-- 
1.7.1




More information about the wine-patches mailing list