Commit 220b6ab3 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Added _wassert implementation.

parent 0aebe831
......@@ -1277,7 +1277,7 @@
@ cdecl _waccess_s(wstr long) msvcrt._waccess_s
@ cdecl _wasctime(ptr) msvcrt._wasctime
@ stub _wasctime_s
@ stub _wassert
@ cdecl _wassert(wstr wstr long) msvcrt._wassert
@ cdecl _wchdir(wstr) msvcrt._wchdir
@ cdecl _wchmod(wstr long) msvcrt._wchmod
@ extern _wcmdln msvcrt._wcmdln
......
......@@ -1130,7 +1130,7 @@
@ cdecl _waccess_s(wstr long) msvcrt._waccess_s
@ cdecl _wasctime(ptr) msvcrt._wasctime
@ stub _wasctime_s
@ stub _wassert
@ cdecl _wassert(wstr wstr long) msvcrt._wassert
@ cdecl _wchdir(wstr) msvcrt._wchdir
@ cdecl _wchmod(wstr long) msvcrt._wchmod
@ extern _wcmdln msvcrt._wcmdln
......
......@@ -1117,7 +1117,7 @@
@ cdecl _waccess_s(wstr long) msvcrt._waccess_s
@ cdecl _wasctime(ptr) msvcrt._wasctime
@ stub _wasctime_s
@ stub _wassert
@ cdecl _wassert(wstr wstr long) msvcrt._wassert
@ cdecl _wchdir(wstr) msvcrt._wchdir
@ cdecl _wchmod(wstr long) msvcrt._wchmod
@ extern _wcmdln msvcrt._wcmdln
......
......@@ -37,7 +37,7 @@ static MSVCRT_purecall_handler purecall_handler = NULL;
static const char szMsgBoxTitle[] = "Wine C++ Runtime Library";
extern int MSVCRT_app_type;
extern char *MSVCRT__pgmptr;
extern MSVCRT_wchar_t *MSVCRT__wpgmptr;
static unsigned int MSVCRT_abort_behavior = MSVCRT__WRITE_ABORT_MSG | MSVCRT__CALL_REPORTFAULT;
static int MSVCRT_error_mode = MSVCRT__OUT_TO_DEFAULT;
......@@ -103,32 +103,45 @@ void CDECL MSVCRT__exit(int exitcode)
}
/* Print out an error message with an option to debug */
static void DoMessageBox(LPCSTR lead, LPCSTR message)
static void DoMessageBoxW(const MSVCRT_wchar_t *lead, const MSVCRT_wchar_t *message)
{
MSGBOXPARAMSA msgbox;
char text[2048];
static const MSVCRT_wchar_t message_format[] = {'%','s','\n','\n','P','r','o','g','r','a','m',':',' ','%','s','\n',
'%','s','\n','\n','P','r','e','s','s',' ','O','K',' ','t','o',' ','e','x','i','t',' ','t','h','e',' ',
'p','r','o','g','r','a','m',',',' ','o','r',' ','C','a','n','c','e','l',' ','t','o',' ','s','t','a','r','t',' ',
't','h','e',' ','W','i','n','e',' ','d','e','b','b','u','g','e','r','.','\n',0};
MSGBOXPARAMSW msgbox;
MSVCRT_wchar_t text[2048];
INT ret;
snprintf(text,sizeof(text),"%s\n\nProgram: %s\n%s\n\n"
"Press OK to exit the program, or Cancel to start the Wine debugger.\n ",
lead, MSVCRT__pgmptr, message);
MSVCRT__snwprintf(text,sizeof(text),message_format, lead, MSVCRT__wpgmptr, message);
msgbox.cbSize = sizeof(msgbox);
msgbox.hwndOwner = GetActiveWindow();
msgbox.hInstance = 0;
msgbox.lpszText = text;
msgbox.lpszCaption = szMsgBoxTitle;
msgbox.lpszText = (LPCWSTR)text;
msgbox.lpszCaption = (LPCWSTR)szMsgBoxTitle;
msgbox.dwStyle = MB_OKCANCEL|MB_ICONERROR;
msgbox.lpszIcon = NULL;
msgbox.dwContextHelpId = 0;
msgbox.lpfnMsgBoxCallback = NULL;
msgbox.dwLanguageId = LANG_NEUTRAL;
ret = MessageBoxIndirectA(&msgbox);
ret = MessageBoxIndirectW(&msgbox);
if (ret == IDCANCEL)
DebugBreak();
}
static void DoMessageBox(const char *lead, const char *message)
{
MSVCRT_wchar_t leadW[1024], messageW[1024];
MSVCRT_mbstowcs(leadW, lead, 1024);
MSVCRT_mbstowcs(messageW, message, 1024);
return DoMessageBoxW(leadW, messageW);
}
/*********************************************************************
* _amsg_exit (MSVCRT.@)
*/
......@@ -188,26 +201,46 @@ unsigned int CDECL MSVCRT__set_abort_behavior(unsigned int flags, unsigned int m
}
/*********************************************************************
* _assert (MSVCRT.@)
* _wassert (MSVCRT.@)
*/
void CDECL MSVCRT__assert(const char* str, const char* file, unsigned int line)
void CDECL MSVCRT__wassert(const MSVCRT_wchar_t* str, const MSVCRT_wchar_t* file, unsigned int line)
{
TRACE("(%s,%s,%d)\n",str,file,line);
static const MSVCRT_wchar_t assertion_failed[] = {'A','s','s','e','r','t','i','o','n',' ','f','a','i','l','e','d','!',0};
static const MSVCRT_wchar_t format_msgbox[] = {'F','i','l','e',':',' ','%','s','\n','L','i','n','e',':',' ','%','d',
'\n','\n','E','x','p','r','e','s','s','i','o','n',':',' ','\"','%','s','\"',0};
static const MSVCRT_wchar_t format_console[] = {'A','s','s','e','r','t','i','o','n',' ','f','a','i','l','e','d',':',' ',
'%','s',',',' ','f','i','l','e',' ','%','s',',',' ','l','i','n','e',' ','%','d','\n','\n',0};
TRACE("(%s,%s,%d)\n", debugstr_w(str), debugstr_w(file), line);
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);
DoMessageBox("Assertion failed!", text);
MSVCRT_wchar_t text[2048];
MSVCRT__snwprintf(text, sizeof(text), format_msgbox, file, line, str);
DoMessageBoxW(assertion_failed, text);
}
else
_cprintf("Assertion failed: %s, file %s, line %d\n\n",str, file, line);
_cwprintf(format_console, str, file, line);
MSVCRT_raise(MSVCRT_SIGABRT);
/* in case raise() returns */
MSVCRT__exit(3);
}
/*********************************************************************
* _assert (MSVCRT.@)
*/
void CDECL MSVCRT__assert(const char* str, const char* file, unsigned int line)
{
MSVCRT_wchar_t strW[1024], fileW[1024];
MSVCRT_mbstowcs(strW, str, 1024);
MSVCRT_mbstowcs(fileW, file, 1024);
MSVCRT__wassert(strW, fileW, line);
}
/*********************************************************************
* _c_exit (MSVCRT.@)
*/
void CDECL MSVCRT__c_exit(void)
......
......@@ -804,6 +804,7 @@ MSVCRT_FILE* __cdecl MSVCRT__wfdopen(int, const MSVCRT_wchar_t *);
int __cdecl MSVCRT_vsnprintf(char *str, MSVCRT_size_t len, const char *format, __ms_va_list valist);
int __cdecl MSVCRT_vsnwprintf(MSVCRT_wchar_t *str, MSVCRT_size_t len,
const MSVCRT_wchar_t *format, __ms_va_list valist );
int __cdecl MSVCRT__snwprintf(MSVCRT_wchar_t*, unsigned int, const MSVCRT_wchar_t*, ...);
int __cdecl MSVCRT_sprintf(char*,const char*,...);
int __cdecl MSVCRT__scprintf(const char*,...);
int __cdecl MSVCRT_raise(int sig);
......@@ -871,6 +872,7 @@ int __cdecl MSVCRT__write(int,const void*,unsigned int);
int __cdecl _getch(void);
int __cdecl _ismbblead(unsigned int);
int __cdecl _ismbstrail(const unsigned char* start, const unsigned char* str);
MSVCRT_size_t __cdecl MSVCRT_mbstowcs(MSVCRT_wchar_t*,const char*,MSVCRT_size_t);
MSVCRT_intptr_t __cdecl MSVCRT__spawnve(int,const char*,const char* const *,const char* const *);
MSVCRT_intptr_t __cdecl MSVRT__spawnvpe(int,const char*,const char* const *,const char* const *);
MSVCRT_intptr_t __cdecl _wspawnve(int,const MSVCRT_wchar_t*,const MSVCRT_wchar_t* const *,const MSVCRT_wchar_t* const *);
......@@ -883,6 +885,7 @@ char* __cdecl _strset(char*,int);
int __cdecl _ungetch(int);
int __cdecl _cputs(const char*);
int __cdecl _cprintf(const char*,...);
int __cdecl _cwprintf(const MSVCRT_wchar_t*,...);
char*** __cdecl __p__environ(void);
int* __cdecl __p___mb_cur_max(void);
unsigned int* __cdecl __p__fmode(void);
......
......@@ -1052,7 +1052,7 @@
@ cdecl _waccess_s(wstr long)
@ cdecl _wasctime(ptr) MSVCRT__wasctime
# stub _wasctime_s
# stub _wassert
@ cdecl _wassert(wstr wstr long) MSVCRT__wassert
@ cdecl _wchdir(wstr)
@ cdecl _wchmod(wstr long)
@ extern _wcmdln MSVCRT__wcmdln
......
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