Commit 5d4cf067 authored by Jon Griffiths's avatar Jon Griffiths Committed by Alexandre Julliard

- Add several mbcs and CP 932 functions, fix some existing calls

- Bug fixes, -W warnings and winapi_check updates. - Don't be so strict setting default locale, store codepage
parent 335b9e3b
......@@ -306,8 +306,8 @@ INT __cdecl CRTDLL__kbhit(VOID)
{
/* FIXME: There has to be a faster way than this in Win32.. */
INPUT_RECORD *ir;
DWORD count = 0;
int retVal = 0, i;
DWORD count = 0, i;
int retVal = 0;
GetNumberOfConsoleInputEvents(__CRTDLL_console_in, &count);
if (!count)
......@@ -316,19 +316,17 @@ INT __cdecl CRTDLL__kbhit(VOID)
if (!(ir = CRTDLL_malloc(count * sizeof(INPUT_RECORD))))
return 0;
if (!PeekConsoleInputA(__CRTDLL_console_in, ir, count, &count))
return 0;
for(i = 0; i < count - 1; i++)
{
if (ir[i].EventType == KEY_EVENT &&
ir[i].Event.KeyEvent.bKeyDown &&
ir[i].Event.KeyEvent.uChar.AsciiChar)
if (PeekConsoleInputA(__CRTDLL_console_in, ir, count, &count))
for(i = 0; i < count - 1; i++)
{
retVal = 1;
break;
if (ir[i].EventType == KEY_EVENT &&
ir[i].Event.KeyEvent.bKeyDown &&
ir[i].Event.KeyEvent.uChar.AsciiChar)
{
retVal = 1;
break;
}
}
}
CRTDLL_free(ir);
return retVal;
}
......
......@@ -325,8 +325,8 @@ LPSTR __cdecl CRTDLL_gets( LPSTR buf );
INT __cdecl CRTDLL_fclose( CRTDLL_FILE* file );
INT __cdecl CTRDLL__creat( LPCSTR path, INT flags );
INT __cdecl CRTDLL__eof( INT fd );
LONG __cdecl CRTDLL__tell(INT fd);
INT __cdecl CRTDLL__umask(INT umask);
LONG __cdecl CRTDLL__tell( INT fd );
INT __cdecl CRTDLL__umask( INT umask );
INT __cdecl CRTDLL__utime( LPCSTR path, struct _utimbuf *t );
INT __cdecl CRTDLL__unlink( LPCSTR pathname );
INT __cdecl CRTDLL_scanf( LPCSTR format, ... );
......@@ -350,7 +350,7 @@ VOID __cdecl CRTDLL__local_unwind2( PEXCEPTION_FRAME endframe, DWORD nr );
INT __cdecl CRTDLL__setjmp( LPDWORD *jmpbuf );
VOID __cdecl CRTDLL_srand( DWORD seed );
INT __cdecl CRTDLL__getw( CRTDLL_FILE* file );
INT __cdecl CRTDLL__isatty(INT fd);
INT __cdecl CRTDLL__isatty( INT fd );
VOID __cdecl CRTDLL__beep( UINT freq, UINT duration );
INT __cdecl CRTDLL_rand( VOID );
UINT __cdecl CRTDLL__rotl( UINT x,INT shift );
......@@ -359,13 +359,12 @@ DWORD __cdecl CRTDLL__lrotl( DWORD x,INT shift );
DWORD __cdecl CRTDLL__lrotr( DWORD x,INT shift );
DWORD __cdecl CRTDLL__rotr( UINT x,INT shift );
double __cdecl CRTDLL__scalb( double x, LONG y );
INT __cdecl CRTDLL__mbsicmp( unsigned char *x,unsigned char *y );
INT __cdecl CRTDLL_vswprintf( LPWSTR buffer, LPCWSTR spec, va_list args );
VOID __cdecl CRTDLL_longjmp( jmp_buf env, int val );
LPSTR __cdecl CRTDLL_setlocale( INT category,LPCSTR locale );
INT __cdecl CRTDLL__isctype( INT c, UINT type );
LPSTR __cdecl CRTDLL__fullpath( LPSTR buf, LPCSTR name, INT size );
VOID __cdecl CRTDLL__splitpath(LPCSTR inpath, LPSTR drv, LPSTR dir,
VOID __cdecl CRTDLL__splitpath( LPCSTR inpath, LPSTR drv, LPSTR dir,
LPSTR fname, LPSTR ext );
INT __cdecl CRTDLL__matherr( struct _exception *e );
VOID __cdecl CRTDLL__makepath( LPSTR path, LPCSTR drive,
......@@ -396,7 +395,6 @@ INT __cdecl CRTDLL_isupper( INT c);
INT __cdecl CRTDLL_isxdigit( INT c );
INT __cdecl CRTDLL_isleadbyte( UCHAR c );
double __cdecl CRTDLL_ldexp( double x, LONG y );
LPSTR __cdecl CRTDLL__mbsrchr( LPSTR s,CHAR x );
VOID __cdecl CRTDLL___dllonexit ( VOID );
VOID __cdecl CRTDLL__mbccpy( LPSTR dest, LPSTR src );
INT __cdecl CRTDLL___isascii( INT c );
......@@ -485,6 +483,30 @@ LPWSTR __cdecl CRTDLL__wcsset( LPWSTR str, WCHAR c );
DWORD __cdecl CRTDLL_wcscoll( LPCWSTR str1, LPCWSTR str2 );
LPWSTR __cdecl CRTDLL_wcspbrk( LPCWSTR str, LPCWSTR accept );
INT __cdecl CRTDLL_wctomb( LPSTR dst, WCHAR ch );
LPSTR __cdecl CRTDLL__mbsdec( LPCSTR start, LPCSTR cur );
LPSTR __cdecl CRTDLL__mbsninc( LPCSTR str, INT num );
INT __cdecl CRTDLL__mbscmp( LPCSTR str, LPCSTR cmp );
INT __cdecl CRTDLL__mbsicmp( LPCSTR str, LPCSTR cmp );
INT __cdecl CRTDLL__mbsncmp( LPCSTR str, LPCSTR cmp, UINT len );
INT __cdecl CRTDLL__mbsnicmp( LPCSTR str, LPCSTR cmp, UINT len );
LPSTR __cdecl CRTDLL__mbsrchr( LPCSTR s,CHAR x );
USHORT __cdecl CRTDLL__mbbtombc( USHORT c );
INT __cdecl CRTDLL__mbclen( LPCSTR str );
INT __cdecl CRTDLL__ismbbkana( UINT c );
INT __cdecl CRTDLL__ismbckata( UINT c );
INT __cdecl CRTDLL__ismbchira( UINT c );
INT __cdecl CRTDLL__ismbblead( UINT c );
INT __cdecl CRTDLL__ismbslead( LPCSTR start, LPCSTR str);
INT __cdecl CRTDLL__ismbbtrail( UINT c );
INT __cdecl CRTDLL__ismbstrail( LPCSTR start, LPCSTR str );
LPSTR __cdecl CRTDLL__mbsset( LPSTR str, UINT c );
LPSTR __cdecl CRTDLL__mbsnset( LPSTR str, UINT c, UINT len );
INT __cdecl CRTDLL__mbstrlen( LPCSTR str );
UINT __cdecl CRTDLL__mbsnextc( LPCSTR str );
LPSTR __cdecl CRTDLL__mbsncpy( LPSTR dst, LPCSTR src, UINT len );
LPSTR __cdecl CRTDLL__mbschr( LPCSTR str, UINT c );
UINT __cdecl CRTDLL__mbsnccnt( LPCSTR str, UINT len );
LPSTR __cdecl CRTDLL__mbsncat( LPSTR dst, LPCSTR src, UINT len );
/* wcstring.c */
INT __cdecl CRTDLL_iswalnum( WCHAR wc );
......@@ -519,9 +541,11 @@ VOID __CRTDLL_init_console(VOID);
VOID __CRTDLL_free_console(VOID);
extern WORD CRTDLL_ctype [257];
extern UCHAR CRTDLL_mbctype[257];
extern WORD __CRTDLL_current_ctype[257];
extern WORD* CRTDLL_pctype_dll;
extern INT CRTDLL__mb_cur_max_dll;
extern LCID __CRTDLL_current_lc_all_lcid;
extern UINT __CRTDLL_current_lc_all_cp;
#endif /* __WINE_CRTDLL_H */
# C RunTime DLL. All functions use cdecl!
name crtdll
type win32
name crtdll
type win32
init CRTDLL_Init
import kernel32.dll
......@@ -150,16 +150,16 @@ debug_channels (crtdll)
@ stub _ismbbalpha
@ stub _ismbbgraph
@ stub _ismbbkalnum
@ stub _ismbbkana
@ cdecl _ismbbkana(long) CRTDLL__ismbbkana
@ stub _ismbbkpunct
@ stub _ismbblead
@ cdecl _ismbblead(long) CRTDLL__ismbblead
@ stub _ismbbprint
@ stub _ismbbpunct
@ stub _ismbbtrail
@ cdecl _ismbbtrail(long) CRTDLL__ismbbtrail
@ stub _ismbcalpha
@ stub _ismbcdigit
@ stub _ismbchira
@ stub _ismbckata
@ cdecl _ismbchira(long) CRTDLL__ismbchira
@ cdecl _ismbckata(long) CRTDLL__ismbckata
@ stub _ismbcl0
@ stub _ismbcl1
@ stub _ismbcl2
......@@ -169,11 +169,10 @@ debug_channels (crtdll)
@ stub _ismbcspace
@ stub _ismbcsymbol
@ stub _ismbcupper
@ stub _ismbslead
@ stub _ismbstrail
@ cdecl _ismbslead(ptr ptr) CRTDLL__ismbslead
@ cdecl _ismbstrail(ptr ptr) CRTDLL__ismbstrail
@ cdecl _isnan(double) CRTDLL__isnan
@ forward _itoa ntdll._itoa
@ cdecl _itow(long str long) CRTDLL__itow
@ cdecl _j0(double) j0
@ cdecl _j1(double) j1
@ cdecl _jn(long double) jn
......@@ -188,28 +187,27 @@ debug_channels (crtdll)
@ cdecl _lsearch(ptr ptr long long ptr) CRTDLL__lsearch
@ cdecl _lseek(long long long) CRTDLL__lseek
@ forward _ltoa ntdll._ltoa
@ cdecl _ltow(long str long) CRTDLL__ltow
@ cdecl _makepath (ptr str str str str) CRTDLL__makepath
@ cdecl _matherr(ptr) CRTDLL__matherr
@ stub _mbbtombc
@ cdecl _mbbtombc(long) CRTDLL__mbbtombc
@ stub _mbbtype
@ cdecl _mbccpy (str str) CRTDLL__mbccpy
@ cdecl _mbccpy (str str) strcpy
@ stub _mbcjistojms
@ stub _mbcjmstojis
@ stub _mbclen
@ cdecl _mbclen(long) CRTDLL__mbclen
@ stub _mbctohira
@ stub _mbctokata
@ stub _mbctolower
@ stub _mbctombb
@ stub _mbctoupper
@ stub _mbctype
@ extern _mbctype CRTDLL_mbctype
@ stub _mbsbtype
@ cdecl _mbscat(str str) strcat
@ stub _mbschr
@ stub _mbscmp
@ cdecl _mbschr(str long) CRTDLL__mbschr
@ cdecl _mbscmp(str str) CRTDLL__mbscmp
@ cdecl _mbscpy(ptr str) strcpy
@ stub _mbscspn
@ stub _mbsdec
@ cdecl _mbsdec(str str) CRTDLL__mbsdec
@ cdecl _mbsdup(str) CRTDLL__strdup
@ cdecl _mbsicmp(str str) CRTDLL__mbsicmp
@ cdecl _mbsinc(str) CRTDLL__mbsinc
......@@ -221,23 +219,23 @@ debug_channels (crtdll)
@ stub _mbsnbcpy
@ stub _mbsnbicmp
@ stub _mbsnbset
@ stub _mbsncat
@ stub _mbsnccnt
@ stub _mbsncmp
@ stub _mbsncpy
@ stub _mbsnextc
@ stub _mbsnicmp
@ stub _mbsninc
@ stub _mbsnset
@ cdecl _mbsncat(str str long) CRTDLL__mbsncat
@ cdecl _mbsnccnt(str long) CRTDLL__mbsnccnt
@ cdecl _mbsncmp(str str long) CRTDLL__mbsncmp
@ cdecl _mbsncpy(str str long) CRTDLL__mbsncpy
@ cdecl _mbsnextc(str) CRTDLL__mbsnextc
@ cdecl _mbsnicmp(str str long) CRTDLL__mbsncmp
@ cdecl _mbsninc(str long) CRTDLL__mbsninc
@ cdecl _mbsnset(str long long) CRTDLL__mbsnset
@ stub _mbspbrk
@ cdecl _mbsrchr(str long) CRTDLL__mbsrchr
@ stub _mbsrev
@ stub _mbsset
@ cdecl _mbsset(str long) CRTDLL__mbsset
@ stub _mbsspn
@ stub _mbsspnp
@ stub _mbsstr
@ cdecl _mbsstr(str str) strstr
@ stub _mbstok
@ stub _mbstrlen
@ cdecl _mbstrlen(str) CRTDLL__mbstrlen
@ stub _mbsupr
@ cdecl _memccpy(ptr ptr long long) memccpy
@ forward _memicmp ntdll._memicmp
......@@ -534,3 +532,5 @@ debug_channels (crtdll)
@ cdecl wctomb(ptr long) CRTDLL_wctomb
@ stub wprintf
@ stub wscanf
#@ cdecl _itow(long str long) CRTDLL__itow
#@ cdecl _ltow(long str long) CRTDLL__ltow
......@@ -67,7 +67,7 @@ UINT CRTDLL_osminor_dll; /* CRTDLL.242 */
UINT CRTDLL_osmode_dll; /* CRTDLL.243 */
UINT CRTDLL_osver_dll; /* CRTDLL.244 */
UINT CRTDLL_osversion_dll; /* CRTDLL.245 */
LONG CRTDLL_timezone_dll = 1; /* CRTDLL.245 */
LONG CRTDLL_timezone_dll = 0; /* CRTDLL.304 */
UINT CRTDLL_winmajor_dll; /* CRTDLL.329 */
UINT CRTDLL_winminor_dll; /* CRTDLL.330 */
UINT CRTDLL_winver_dll; /* CRTDLL.331 */
......@@ -840,7 +840,7 @@ LPSTR __cdecl CRTDLL__fullpath(LPSTR absPath, LPCSTR relPath, INT size)
fln_fix(res);
len = strlen(res);
if (len >= MAX_PATH || len >= size)
if (len >= MAX_PATH || len >= (size_t)size)
return NULL; /* FIXME: errno? */
if (!absPath)
......@@ -1724,7 +1724,7 @@ INT __cdecl CRTDLL__isnan(double d)
*/
VOID __cdecl CRTDLL__purecall(VOID)
{
CRTDLL__amsg_exit( 6025 );
CRTDLL__amsg_exit( 25 );
}
......@@ -1771,11 +1771,11 @@ div_t __cdecl CRTDLL_div(INT x, INT y)
* [i386] Windows binary compatible - returns the struct in eax/edx.
*/
#ifdef __i386__
LONGLONG __cdecl CRTDLL_ldiv(LONG x, LONG y)
ULONGLONG __cdecl CRTDLL_ldiv(LONG x, LONG y)
{
LONGLONG retVal;
ULONGLONG retVal;
ldiv_t ldt = ldiv(x,y);
retVal = ((LONGLONG)ldt.rem << 32) | ldt.quot;
retVal = ((ULONGLONG)ldt.rem << 32) | (ULONG)ldt.quot;
return retVal;
}
#endif /* defined(__i386__) */
......
......@@ -177,8 +177,7 @@ INT __cdecl CRTDLL__findnext(DWORD hand, find_t * ft)
if (!FindNextFileA(hand, &find_data))
{
SetLastError(ERROR_INVALID_DRIVE);
__CRTDLL__set_errno(GetLastError());
CRTDLL_errno = ENOENT;
return -1;
}
......
......@@ -80,7 +80,10 @@ INT __cdecl CRTDLL__abnormal_termination(VOID)
*/
VOID __cdecl CRTDLL__amsg_exit(INT err)
{
CRTDLL_fprintf(CRTDLL_stderr,"\nrun-time error:\nError Code %d\n",err);
/* FIXME: Should be a popup for msvcrt gui executables, and should have
* text for the error number.
*/
CRTDLL_fprintf(CRTDLL_stderr,"\nruntime error R60%d\n",err);
CRTDLL__exit(255);
}
......
......@@ -888,9 +888,9 @@ INT __cdecl CRTDLL__putw(INT val, CRTDLL_FILE* file)
*/
INT __cdecl CRTDLL__rmtmp(void)
{
int num_removed = 0, i = 3;
int num_removed = 0, i;
while(i < __CRTDLL_fdend)
for (i = 3; i < __CRTDLL_fdend; i++)
if (__CRTDLL_tempfiles[i])
{
CRTDLL__close(i);
......@@ -1281,7 +1281,7 @@ WCHAR __cdecl CRTDLL_fputwc( WCHAR wc, CRTDLL_FILE* file)
*/
INT __cdecl CRTDLL_fputs( LPCSTR s, CRTDLL_FILE* file )
{
return CRTDLL_fwrite(s,strlen(s),1,file);
return CRTDLL_fwrite(s,strlen(s),1,file) == 1 ? 0 : CRTDLL_EOF;
}
......
......@@ -36,15 +36,12 @@
* a table for a supported Wine locale, mail it to me and
* I will add the needed support (jon_p_griffiths@yahoo.com).
*/
#include "crtdll.h"
#include "winnt.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "winnt.h"
DEFAULT_DEBUG_CHANNEL(crtdll);
#define MAX_ELEM_LEN 64 /* Max length of country/language/CP string */
......@@ -55,6 +52,7 @@ DEFAULT_DEBUG_CHANNEL(crtdll);
*/
char __CRTDLL_current_lc_all[MAX_LOCALE_LENGTH];
LCID __CRTDLL_current_lc_all_lcid;
UINT __CRTDLL_current_lc_all_cp;
/* Friendly country strings & iso codes for synonym support.
* Based on MS documentation for setlocale().
......@@ -80,7 +78,7 @@ static const char* _country_synonyms[] =
/* INTERNAL: Map a synonym to an ISO code */
static void remap_synonym(char *name)
{
int i;
size_t i;
for (i = 0; i < sizeof(_country_synonyms)/sizeof(char*); i += 2 )
{
if (!strcasecmp(_country_synonyms[i],name))
......@@ -271,6 +269,7 @@ static void __CRTDLL_set_ctype(UINT codepage, LCID lcid)
unsigned char *traverse = (unsigned char *)cp.LeadByte;
memset(__CRTDLL_current_ctype, 0, sizeof(CRTDLL_ctype));
__CRTDLL_current_lc_all_cp = codepage;
/* Switch ctype macros to MBCS if needed */
CRTDLL__mb_cur_max_dll = cp.MaxCharSize;
......@@ -330,29 +329,28 @@ LPSTR __cdecl CRTDLL_setlocale(INT category, LPCSTR locale)
/* Default Locale: Special case handling */
if (!strlen(locale) || ((toupper(locale[0]) == 'C') && !locale[1]))
{
if ((toupper(__CRTDLL_current_lc_all[0]) != 'C')
|| __CRTDLL_current_lc_all[1])
{
__CRTDLL_current_lc_all[0] = 'C';
__CRTDLL_current_lc_all[1] = 0;
switch (category) {
case CRTDLL_LC_ALL:
lc_all = 1; /* Fall through all cases ... */
case CRTDLL_LC_COLLATE:
if (!lc_all) break;
case CRTDLL_LC_CTYPE:
/* Restore C locale ctype info */
CRTDLL__mb_cur_max_dll = 1;
memcpy(__CRTDLL_current_ctype, CRTDLL_ctype, sizeof(CRTDLL_ctype));
if (!lc_all) break;
case CRTDLL_LC_MONETARY:
if (!lc_all) break;
case CRTDLL_LC_NUMERIC:
if (!lc_all) break;
case CRTDLL_LC_TIME:
}
return __CRTDLL_current_lc_all;
__CRTDLL_current_lc_all[0] = 'C';
__CRTDLL_current_lc_all[1] = '\0';
__CRTDLL_current_lc_all_cp = GetACP();
switch (category) {
case CRTDLL_LC_ALL:
lc_all = 1; /* Fall through all cases ... */
case CRTDLL_LC_COLLATE:
if (!lc_all) break;
case CRTDLL_LC_CTYPE:
/* Restore C locale ctype info */
CRTDLL__mb_cur_max_dll = 1;
memcpy(__CRTDLL_current_ctype, CRTDLL_ctype, sizeof(CRTDLL_ctype));
memset(CRTDLL_mbctype, 0, sizeof(CRTDLL_mbctype));
if (!lc_all) break;
case CRTDLL_LC_MONETARY:
if (!lc_all) break;
case CRTDLL_LC_NUMERIC:
if (!lc_all) break;
case CRTDLL_LC_TIME:
}
return __CRTDLL_current_lc_all;
}
/* Get locale elements */
......
......@@ -9,6 +9,7 @@ CHAR
DWORD
HANDLE
INT
USHORT
LONG
ULONG
UINT
......@@ -17,7 +18,6 @@ UCHAR
clock_t
size_t
time_t
unsigned char
%long # --forbidden
......@@ -28,13 +28,12 @@ unsigned long
%longlong
LONGLONG
ULONGLONG
%ptr
CHAR *
CRTDLL_FILE *
CRTDLL_fpos_t *
LPCSTR *
LPCVOID
LPDWORD
LPDWORD *
......@@ -42,12 +41,12 @@ LPINT
LPUINT
LPSTR *
LPSTR **
LPCSTR *
LPVOID
PCONTEXT
PEXCEPTION_FRAME
PEXCEPTION_FRAME *
PEXCEPTION_RECORD
PINT
VOID *
WCHAR *
_INITTERMFUN *
......@@ -60,6 +59,7 @@ time_t *
struct _heapinfo *
struct _utimbuf *
struct _exception *
CRTDLL_fpos_t *
diskfree_t *
unsigned char *
va_list
......
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