Commit 49a8bb0a authored by Detlef Riekenberg's avatar Detlef Riekenberg Committed by Alexandre Julliard

msvcrt: Use the _set_error_mode value to switch between a dialogbox and stderr…

msvcrt: Use the _set_error_mode value to switch between a dialogbox and stderr for C runtime messages.
parent c865b3f8
......@@ -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)
......
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment