msvcrt: Use the _set_error_mode value to switch between a dialogbox and stderr for C runtime messages.

This commit is contained in:
Detlef Riekenberg 2011-01-30 23:34:38 +01:00 committed by Alexandre Julliard
parent c865b3f8e0
commit 49a8bb0aa0
2 changed files with 30 additions and 33 deletions

View File

@ -406,35 +406,6 @@ MSVCRT_wchar_t* CDECL __wcserror(const MSVCRT_wchar_t* str)
return data->wcserror_buffer;
}
/******************************************************************************
* _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.@)
*/

View File

@ -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;
}