diff --git a/Make.rules.in b/Make.rules.in index 3167b89f1843215dda34b42f09f59cf751969ce6..eebe87ea59c91ab35065c267879b543d3c77a614 100644 --- a/Make.rules.in +++ b/Make.rules.in @@ -96,6 +96,7 @@ DLLS = \ avifil32 \ comctl32 \ comdlg32 \ + crtdll \ dciman32 \ dinput \ dplayx \ diff --git a/Makefile.in b/Makefile.in index 6f75ef6ad3a14557d5146eb69a4ade9a3e02e09c..f7b5928280148b04c4049568f92713ad882f494b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -39,8 +39,6 @@ SUBDIRS = \ debugger \ dlls \ dlls/advapi32 \ - dlls/crtdll \ - dlls/kernel \ dlls/ntdll \ documentation \ files \ @@ -84,7 +82,6 @@ LIBOBJS = \ controls/controls.o \ console/console.o \ dlls/advapi32/advapi32.o \ - dlls/crtdll/crtdll.o \ dlls/ntdll/ntdll.o \ files/files.o \ graphics/graphics.o \ diff --git a/dlls/Makefile.in b/dlls/Makefile.in index 57f1e828bcd8c07f2876655fee5a7a99256abe1d..8ba1e9ee2411b6e0feacb503202a3a5b4cfa4940 100644 --- a/dlls/Makefile.in +++ b/dlls/Makefile.in @@ -16,6 +16,7 @@ DLLFILES = \ avifil32/libavifil32.@LIBEXT@ \ comctl32/libcomctl32.@LIBEXT@ \ commdlg/libcomdlg32.@LIBEXT@ \ + crtdll/libcrtdll.@LIBEXT@ \ dciman32/libdciman32.@LIBEXT@ \ dinput/libdinput.@LIBEXT@ \ dplayx/libdplayx.@LIBEXT@ \ @@ -117,6 +118,7 @@ SUBDIRS = \ avifil32 \ comctl32 \ commdlg \ + crtdll \ dciman32 \ ddraw \ dinput \ @@ -180,6 +182,9 @@ libcomctl32.@LIBEXT@: comctl32/libcomctl32.@LIBEXT@ libcomdlg32.@LIBEXT@ libcommdlg.@LIBEXT@: commdlg/libcomdlg32.@LIBEXT@ $(RM) $@ && $(LN_S) commdlg/libcomdlg32.@LIBEXT@ $@ +libcrtdll.@LIBEXT@: crtdll/libcrtdll.@LIBEXT@ + $(RM) $@ && $(LN_S) crtdll/libcrtdll.@LIBEXT@ $@ + libdciman32.@LIBEXT@: dciman32/libdciman32.@LIBEXT@ $(RM) $@ && $(LN_S) dciman32/libdciman32.@LIBEXT@ $@ diff --git a/dlls/commdlg/filedlg95.c b/dlls/commdlg/filedlg95.c index e636f5d32fdd064a091774488ba4727e7a193b74..73bb817957aada92c84188414fb9ff9320e494c0 100644 --- a/dlls/commdlg/filedlg95.c +++ b/dlls/commdlg/filedlg95.c @@ -25,7 +25,6 @@ #include <string.h> #include "winbase.h" -#include "crtdll.h" #include "ldt.h" #include "heap.h" #include "commdlg.h" @@ -177,6 +176,8 @@ HRESULT FILEDLG95_HandleCustomDialogMessages(HWND hwnd, UINT uMsg, WPARAM wParam BOOL FILEDLG95_OnOpenMultipleFiles(HWND hwnd, LPSTR lpstrFileList, UINT nFileCount, UINT sizeUsed); static BOOL BrowseSelectedFolder(HWND hwnd); +extern LPSTR _strlwr( LPSTR str ); + /*********************************************************************** * GetFileName95 * @@ -1599,7 +1600,7 @@ static HRESULT FILEDLG95_FILETYPE_Init(HWND hwnd) if(lpstrFilter) { - CRTDLL__strlwr(lpstrFilter); /* lowercase */ + _strlwr(lpstrFilter); /* lowercase */ fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc((strlen(lpstrFilter)+1)*2); lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter, lpstrFilter); } @@ -1638,7 +1639,7 @@ static BOOL FILEDLG95_FILETYPE_OnCommand(HWND hwnd, WORD wNotifyCode) if((int)lpstrFilter != CB_ERR) { fodInfos->ShellInfos.lpstrCurrentFilter = MemAlloc((strlen(lpstrFilter)+1)*2); - lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter,CRTDLL__strlwr(lpstrFilter)); + lstrcpyAtoW(fodInfos->ShellInfos.lpstrCurrentFilter,_strlwr(lpstrFilter)); SendCustomDlgNotificationMessage(hwnd,CDN_TYPECHANGE); } diff --git a/dlls/crtdll/.cvsignore b/dlls/crtdll/.cvsignore index 227d8393cc8ceb55580964a308dd33c48970ecf7..bf39f1c25b0bbd96ca49b59a2ac8d9cdc368d9c7 100644 --- a/dlls/crtdll/.cvsignore +++ b/dlls/crtdll/.cvsignore @@ -1,3 +1,4 @@ -Makefile *.spec.c *.spec.glue.s +Makefile +libcrtdll.so.1.0 diff --git a/dlls/crtdll/Makefile.in b/dlls/crtdll/Makefile.in index ca933de8e4ccc993cd14294e4fbff93f55e468fd..2b4fd17cbb6a3308439737f5aa85147c857e3b58 100644 --- a/dlls/crtdll/Makefile.in +++ b/dlls/crtdll/Makefile.in @@ -1,19 +1,15 @@ -DEFS = @DLLFLAGS@ -D__WINE__ TOPSRCDIR = @top_srcdir@ TOPOBJDIR = ../.. SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = crtdll - -SPEC_SRCS = crtdll.spec +SOVERSION = 1.0 C_SRCS = \ crtdll_main.c \ mbstring.c \ wcstring.c -all: $(MODULE).o - -@MAKE_RULES@ +@MAKE_DLL_RULES@ ### Dependencies: diff --git a/dlls/crtdll/crtdll.spec b/dlls/crtdll/crtdll.spec index 1761622dea074b990d5350c209233d0c2e8368dc..1061350d966ea57bab320e67273ea303d2fc5949 100644 --- a/dlls/crtdll/crtdll.spec +++ b/dlls/crtdll/crtdll.spec @@ -3,6 +3,8 @@ name crtdll type win32 init CRTDLL_Init +import ntdll + @ cdecl ??2@YAPAXI@Z(long) CRTDLL_new @ cdecl ??3@YAXPAX@Z(long) CRTDLL_delete @ cdecl ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z(ptr) CRTDLL_set_new_handler @@ -16,7 +18,7 @@ init CRTDLL_Init @ stub _CIfmod @ stub _CIlog @ stub _CIlog10 -@ cdecl _CIpow() CRTDLL__CIpow +@ forward _CIpow ntdll._CIpow @ stub _CIsin @ stub _CIsinh @ stub _CIsqrt @@ -115,7 +117,7 @@ init CRTDLL_Init @ cdecl _fsopen(str str long) CRTDLL__fsopen @ cdecl _fstat(long ptr) CRTDLL__fstat @ stub _ftime -@ cdecl _ftol() CRTDLL__ftol +@ forward _ftol ntdll._ftol @ cdecl _fullpath(ptr str long) CRTDLL__fullpath @ stub _futime @ stub _gcvt @@ -167,7 +169,7 @@ init CRTDLL_Init @ stub _ismbslead @ stub _ismbstrail @ stub _isnan -@ cdecl _itoa(long ptr long) CRTDLL__itoa +@ forward _itoa ntdll._itoa @ stub _itow @ cdecl _j0(double) j0 @ cdecl _j1(double) j1 @@ -182,7 +184,7 @@ init CRTDLL_Init @ stub _lrotr @ stub _lsearch @ cdecl _lseek(long long long) CRTDLL__lseek -@ cdecl _ltoa(long str long) CRTDLL__ltoa +@ forward _ltoa ntdll._ltoa @ stub _ltow @ cdecl _makepath (ptr str str str str) CRTDLL__makepath @ stub _matherr @@ -235,7 +237,7 @@ init CRTDLL_Init @ stub _mbstrlen @ stub _mbsupr @ stub _memccpy -@ cdecl _memicmp(str str long) CRTDLL__memicmp +@ forward _memicmp ntdll._memicmp @ cdecl _mkdir(str) CRTDLL__mkdir @ stub _mktemp @ stub _msize @@ -284,25 +286,25 @@ init CRTDLL_Init @ cdecl _splitpath (str ptr ptr ptr ptr) CRTDLL__splitpath @ cdecl _stat (str ptr) CRTDLL__stat @ stub _statusfp -@ cdecl _strcmpi(str str) CRTDLL__strcmpi +@ cdecl _strcmpi(str str) strcasecmp @ cdecl _strdate(str) CRTDLL__strdate @ stub _strdec @ cdecl _strdup(str) CRTDLL__strdup @ stub _strerror -@ cdecl _stricmp(str str) CRTDLL__strcmpi +@ cdecl _stricmp(str str) strcasecmp @ stub _stricoll @ stub _strinc -@ cdecl _strlwr(str) CRTDLL__strlwr +@ forward _strlwr ntdll._strlwr @ stub _strncnt @ stub _strnextc -@ cdecl _strnicmp(str str long) CRTDLL__strnicmp +@ cdecl _strnicmp(str str long) strncasecmp @ stub _strninc @ stub _strnset @ stub _strrev @ stub _strset @ stub _strspnp @ cdecl _strtime(str) CRTDLL__strtime -@ cdecl _strupr(str) CRTDLL__strupr +@ forward _strupr ntdll._strupr @ stub _swab @ stub _sys_errlist @ stub _sys_nerr_dll @@ -313,7 +315,7 @@ init CRTDLL_Init @ stub _toupper @ stub _tzname @ stub _tzset -@ cdecl _ultoa(long ptr long) CRTDLL__ultoa +@ forward _ultoa ntdll._ultoa @ stub _ultow @ stub _umask @ stub _ungetch @@ -323,14 +325,14 @@ init CRTDLL_Init @ stub _vsnprintf @ stub _vsnwprintf @ cdecl _wcsdup(wstr) CRTDLL__wcsdup -@ cdecl _wcsicmp(wstr wstr) CRTDLL__wcsicmp +@ forward _wcsicmp ntdll._wcsicmp @ cdecl _wcsicoll(wstr wstr) CRTDLL__wcsicoll -@ cdecl _wcslwr(wstr) CRTDLL__wcslwr -@ cdecl _wcsnicmp(wstr wstr long) CRTDLL__wcsnicmp +@ forward _wcslwr forward._wcslwr +@ forward _wcsnicmp forward._wcsnicmp @ cdecl _wcsnset(wstr long long) CRTDLL__wcsnset @ cdecl _wcsrev(wstr) CRTDLL__wcsrev @ cdecl _wcsset(wstr long) CRTDLL__wcsset -@ cdecl _wcsupr(wstr) CRTDLL__wcsupr +@ forward _wcsupr ntdll._wcsupr @ extern _winmajor_dll CRTDLL_winmajor_dll @ extern _winminor_dll CRTDLL_winminor_dll @ extern _winver_dll CRTDLL_winver_dll @@ -408,10 +410,10 @@ init CRTDLL_Init @ cdecl isspace(long) isspace @ cdecl isupper(long) isupper @ cdecl iswalnum(long) CRTDLL_iswalnum -@ cdecl iswalpha(long) CRTDLL_iswalpha +@ forward iswalpha ntdll.iswalpha @ stub iswascii @ cdecl iswcntrl(long) CRTDLL_iswcntrl -@ cdecl iswctype(long long) CRTDLL_iswctype +@ forward iswctype ntdll.iswctype @ cdecl iswdigit(long) CRTDLL_iswdigit @ cdecl iswgraph(long) CRTDLL_iswgraph @ cdecl iswlower(long) CRTDLL_iswlower @@ -431,7 +433,7 @@ init CRTDLL_Init @ cdecl longjmp(ptr long) CRTDLL_longjmp @ cdecl malloc(ptr) CRTDLL_malloc @ cdecl mblen(str long) mblen -@ cdecl mbstowcs(ptr str long) CRTDLL_mbstowcs +@ forward mbstowcs ntdll.mbstowcs @ cdecl mbtowc(ptr ptr long) CRTDLL_mbtowc @ cdecl memchr(ptr long long) memchr @ cdecl memcmp(ptr ptr long) memcmp @@ -495,8 +497,8 @@ init CRTDLL_Init @ cdecl tmpnam(str) CRTDLL_tmpnam @ cdecl tolower(long) tolower @ cdecl toupper(long) toupper -@ cdecl towlower(long) CRTDLL_towlower -@ cdecl towupper(long) CRTDLL_towupper +@ forward towlower ntdll.towlower +@ forward towupper ntdll.towupper @ stub ungetc @ stub ungetwc @ cdecl vfprintf(ptr str ptr) CRTDLL_vfprintf @@ -505,25 +507,25 @@ init CRTDLL_Init @ cdecl vsprintf(ptr str ptr) CRTDLL_vsprintf @ cdecl vswprintf(ptr wstr ptr) CRTDLL_vswprintf @ stub vwprintf -@ cdecl wcscat(wstr wstr) CRTDLL_wcscat -@ cdecl wcschr(wstr long) CRTDLL_wcschr -@ cdecl wcscmp(wstr wstr) CRTDLL_wcscmp +@ forward wcscat ntdll.wcscat +@ forward wcschr ntdll.wcschr +@ forward wcscmp ntdll.wcscmp @ cdecl wcscoll(wstr wstr) CRTDLL_wcscoll -@ cdecl wcscpy(ptr wstr) CRTDLL_wcscpy -@ cdecl wcscspn(wstr wstr) CRTDLL_wcscspn +@ forward wcscpy ntdll.wcscpy +@ forward wcscspn ntdll.wcscspn @ stub wcsftime -@ cdecl wcslen(wstr) CRTDLL_wcslen -@ cdecl wcsncat(wstr wstr long) CRTDLL_wcsncat -@ cdecl wcsncmp(wstr wstr long) CRTDLL_wcsncmp -@ cdecl wcsncpy(ptr wstr long) CRTDLL_wcsncpy +@ forward wcslen ntdll.wcslen +@ forward wcsncat ntdll.wcsncat +@ forward wcsncmp ntdll.wcsncmp +@ forward wcsncpy ntdll.wcsncpy @ cdecl wcspbrk(wstr wstr) CRTDLL_wcspbrk -@ cdecl wcsrchr(wstr long) CRTDLL_wcsrchr -@ cdecl wcsspn(wstr wstr) CRTDLL_wcsspn -@ cdecl wcsstr(wstr wstr) CRTDLL_wcsstr +@ forward wcsrchr ntdll.wcsrchr +@ forward wcsspn ntdll.wcsspn +@ forward wcsstr ntdll.wcsstr @ stub wcstod -@ cdecl wcstok(wstr wstr) CRTDLL_wcstok -@ cdecl wcstol(wstr ptr long) CRTDLL_wcstol -@ cdecl wcstombs(ptr ptr long) CRTDLL_wcstombs +@ forward wcstok ntdll.wcstok +@ forward wcstol ntdll.wcstol +@ forward wcstombs ntdll.wcstombs @ stub wcstoul @ stub wcsxfrm @ cdecl wctomb(ptr long) CRTDLL_wctomb diff --git a/dlls/crtdll/crtdll_main.c b/dlls/crtdll/crtdll_main.c index 31d0f3fb10e3997830e463f4d989aa2c86a3b48f..0abc89a22160157b07aef60b3ee3c465e9a28684 100644 --- a/dlls/crtdll/crtdll_main.c +++ b/dlls/crtdll/crtdll_main.c @@ -100,12 +100,6 @@ typedef VOID (*new_handler_type)(VOID); static new_handler_type new_handler; -#if defined(__GNUC__) && defined(__i386__) -#define USING_REAL_FPU -#define DO_FPU(x,y) __asm__ __volatile__( x " %0;fwait" : "=m" (y) : ) -#define POP_FPU(x) DO_FPU("fstpl",x) -#endif - CRTDLL_FILE * __cdecl CRTDLL__fdopen(INT handle, LPCSTR mode); /********************************************************************* @@ -953,43 +947,6 @@ INT __cdecl CRTDLL_vswprintf( LPWSTR buffer, LPCWSTR spec, va_list args ) return wvsprintfW( buffer, spec, args ); } -/********************************************************************* - * _strcmpi (CRTDLL.282) (CRTDLL.287) - */ -INT __cdecl CRTDLL__strcmpi( LPCSTR s1, LPCSTR s2 ) -{ - return lstrcmpiA( s1, s2 ); -} - - -/********************************************************************* - * _strnicmp (CRTDLL.293) - */ -INT __cdecl CRTDLL__strnicmp( LPCSTR s1, LPCSTR s2, INT n ) -{ - return lstrncmpiA( s1, s2, n ); -} - - -/********************************************************************* - * _strlwr (CRTDLL.293) - * - * convert a string in place to lowercase - */ -LPSTR __cdecl CRTDLL__strlwr(LPSTR x) -{ - unsigned char *y =x; - - TRACE("CRTDLL_strlwr got %s\n", x); - while (*y) { - if ((*y > 0x40) && (*y< 0x5b)) - *y = *y + 0x20; - y++; - } - TRACE(" returned %s\n", x); - - return x; -} /********************************************************************* * system (CRTDLL.485) @@ -1035,20 +992,6 @@ INT __cdecl CRTDLL_system(LPSTR x) return system(buffer); } -/********************************************************************* - * _strupr (CRTDLL.300) - */ -LPSTR __cdecl CRTDLL__strupr(LPSTR x) -{ - LPSTR y=x; - - while (*y) { - *y=toupper(*y); - y++; - } - return x; -} - /********************************************************************* * longjmp (CRTDLL.426) */ @@ -1697,43 +1640,6 @@ LPSTR __cdecl CRTDLL__itoa(INT x,LPSTR buf,INT buflen) return buf; } -/********************************************************************* - * _ltoa (CRTDLL.180) - */ -LPSTR __cdecl CRTDLL__ltoa(long x,LPSTR buf,INT radix) -{ - switch(radix) { - case 2: FIXME("binary format not implemented !\n"); - break; - case 8: wsnprintfA(buf,0x80,"%o",x); - break; - case 10: wsnprintfA(buf,0x80,"%d",x); - break; - case 16: wsnprintfA(buf,0x80,"%x",x); - break; - default: FIXME("radix %d not implemented !\n", radix); - } - return buf; -} - -/********************************************************************* - * _ultoa (CRTDLL.311) - */ -LPSTR __cdecl CRTDLL__ultoa(long x,LPSTR buf,INT radix) -{ - switch(radix) { - case 2: FIXME("binary format not implemented !\n"); - break; - case 8: wsnprintfA(buf,0x80,"%lo",x); - break; - case 10: wsnprintfA(buf,0x80,"%ld",x); - break; - case 16: wsnprintfA(buf,0x80,"%lx",x); - break; - default: FIXME("radix %d not implemented !\n", radix); - } - return buf; -} typedef VOID (*sig_handler_type)(VOID); @@ -1746,41 +1652,6 @@ void * __cdecl CRTDLL_signal(int sig, sig_handler_type ptr) return (void*)-1; } -/********************************************************************* - * _ftol (CRTDLL.113) - */ -#ifdef USING_REAL_FPU -LONG __cdecl CRTDLL__ftol(void) { - /* don't just do DO_FPU("fistp",retval), because the rounding - * mode must also be set to "round towards zero"... */ - double fl; - POP_FPU(fl); - return (LONG)fl; -} -#else -LONG __cdecl CRTDLL__ftol(double fl) { - FIXME("should be register function\n"); - return (LONG)fl; -} -#endif - -/********************************************************************* - * _CIpow (CRTDLL.14) - */ -#ifdef USING_REAL_FPU -LONG __cdecl CRTDLL__CIpow(void) { - double x,y; - POP_FPU(y); - POP_FPU(x); - return pow(x,y); -} -#else -LONG __cdecl CRTDLL__CIpow(double x,double y) { - FIXME("should be register function\n"); - return pow(x,y); -} -#endif - /********************************************************************* * _sleep (CRTDLL.267) */ @@ -1825,29 +1696,6 @@ LPSTR __cdecl CRTDLL__mbsrchr(LPSTR s,CHAR x) { return strrchr(s,x); } -/********************************************************************* - * _memicmp (CRTDLL.233)(NTDLL.868) - * A stringcompare, without \0 check - * RETURNS - * -1:if first string is alphabetically before second string - * 1:if second '' '' '' '' first '' - * 0:if both are equal. - */ -INT __cdecl CRTDLL__memicmp( - LPCSTR s1, /* [in] first string */ - LPCSTR s2, /* [in] second string */ - DWORD len /* [in] length to compare */ -) { - int i; - - for (i=0;i<len;i++) { - if (tolower(s1[i])<tolower(s2[i])) - return -1; - if (tolower(s1[i])>tolower(s2[i])) - return 1; - } - return 0; -} /********************************************************************* * __dllonexit (CRTDLL.25) */ @@ -1856,18 +1704,6 @@ VOID __cdecl CRTDLL___dllonexit () FIXME("stub\n"); } -/********************************************************************* - * wcstol (CRTDLL.520) - * Like strtol, but for wide character strings. - */ -INT __cdecl CRTDLL_wcstol(LPWSTR s,LPWSTR *end,INT base) { - LPSTR sA = HEAP_strdupWtoA(GetProcessHeap(),0,s),endA; - INT ret = strtol(sA,&endA,base); - - HeapFree(GetProcessHeap(),0,sA); - if (end) *end = s+(endA-sA); /* pointer magic checked. */ - return ret; -} /********************************************************************* * _strdate (CRTDLL.283) */ diff --git a/dlls/crtdll/mbstring.c b/dlls/crtdll/mbstring.c index 0e897947a01c6f578e12d9358dac7ee9442f7d61..5eacca39d9f196cca63e360f9ab1eb49528911d6 100644 --- a/dlls/crtdll/mbstring.c +++ b/dlls/crtdll/mbstring.c @@ -44,24 +44,6 @@ INT __cdecl CRTDLL__mbslen( LPCSTR str ) } -/********************************************************************* - * CRTDLL_mbstowcs (CRTDLL.429) - */ -INT __cdecl CRTDLL_mbstowcs( LPWSTR dst, LPCSTR src, INT n ) -{ - wchar_t *buffer, *p; - int ret; - - if (!(buffer = CRTDLL_malloc( n * sizeof(wchar_t) ))) return -1; - ret = mbstowcs( buffer, src, n ); - if (ret < n) n = ret + 1; /* nb of chars to copy (including terminating null) */ - p = buffer; - while (n-- > 0) *dst++ = (WCHAR)*p++; - CRTDLL_free( buffer ); - return ret; -} - - /********************************************************************* * CRTDLL_mbtowc (CRTDLL.430) */ diff --git a/dlls/crtdll/wcstring.c b/dlls/crtdll/wcstring.c index fbcbb8a8590c30ee9626700d7b617f42c11904fd..45ff28f1b2b013f6f1069d479318e35fdd3d0c30 100644 --- a/dlls/crtdll/wcstring.c +++ b/dlls/crtdll/wcstring.c @@ -2,10 +2,6 @@ * CRTDLL wide-char functions * * Copyright 1999 Alexandre Julliard - * - * TODO: - * These functions are really necessary only if sizeof(WCHAR) != sizeof(wchar_t), - * otherwise we could use the libc functions directly. */ #include "config.h" @@ -13,17 +9,15 @@ #include <ctype.h> #include <stdlib.h> #include <string.h> -#ifdef HAVE_WCTYPE_H -#include <wctype.h> -#endif #include "windef.h" -#include "ntddk.h" +#include "wine/unicode.h" #include "crtdll.h" #include "debugtools.h" DEFAULT_DEBUG_CHANNEL(crtdll); + /********************************************************************* * CRTDLL__wcsdup (CRTDLL.320) */ @@ -32,7 +26,7 @@ LPWSTR __cdecl CRTDLL__wcsdup( LPCWSTR str ) LPWSTR ret = NULL; if (str) { - int size = (CRTDLL_wcslen(str) + 1) * sizeof(WCHAR); + int size = (strlenW(str) + 1) * sizeof(WCHAR); ret = CRTDLL_malloc( size ); if (ret) memcpy( ret, str, size ); } @@ -40,53 +34,13 @@ LPWSTR __cdecl CRTDLL__wcsdup( LPCWSTR str ) } -/********************************************************************* - * CRTDLL__wcsicmp (CRTDLL.321) - */ -INT __cdecl CRTDLL__wcsicmp( LPCWSTR str1, LPCWSTR str2 ) -{ - while (*str1 && (CRTDLL_towupper(*str1) == CRTDLL_towupper(*str2))) - { - str1++; - str2++; - } - return CRTDLL_towupper(*str1) - CRTDLL_towupper(*str2); -} - - /********************************************************************* * CRTDLL__wcsicoll (CRTDLL.322) */ INT __cdecl CRTDLL__wcsicoll( LPCWSTR str1, LPCWSTR str2 ) { /* FIXME: handle collates */ - return CRTDLL__wcsicmp( str1, str2 ); -} - - -/********************************************************************* - * CRTDLL__wcslwr (CRTDLL.323) - */ -LPWSTR __cdecl CRTDLL__wcslwr( LPWSTR str ) -{ - LPWSTR ret = str; - for ( ; *str; str++) *str = CRTDLL_towlower(*str); - return ret; -} - - -/********************************************************************* - * CRTDLL__wcsnicmp (CRTDLL.324) - */ -INT __cdecl CRTDLL__wcsnicmp( LPCWSTR str1, LPCWSTR str2, INT n ) -{ - if (!n) return 0; - while ((--n > 0) && *str1 && (CRTDLL_towupper(*str1) == CRTDLL_towupper(*str2))) - { - str1++; - str2++; - } - return CRTDLL_towupper(*str1) - CRTDLL_towupper(*str2); + return strcmpiW( str1, str2 ); } @@ -107,7 +61,7 @@ LPWSTR __cdecl CRTDLL__wcsnset( LPWSTR str, WCHAR c, INT n ) LPWSTR __cdecl CRTDLL__wcsrev( LPWSTR str ) { LPWSTR ret = str; - LPWSTR end = str + CRTDLL_wcslen(str) - 1; + LPWSTR end = str + strlenW(str) - 1; while (end > str) { WCHAR t = *end; @@ -129,153 +83,13 @@ LPWSTR __cdecl CRTDLL__wcsset( LPWSTR str, WCHAR c ) } -/********************************************************************* - * CRTDLL__wcsupr (CRTDLL.328) - */ -LPWSTR __cdecl CRTDLL__wcsupr( LPWSTR str ) -{ - LPWSTR ret = str; - for ( ; *str; str++) *str = CRTDLL_towupper(*str); - return ret; -} - - -/********************************************************************* - * CRTDLL_towlower (CRTDLL.493) - */ -WCHAR __cdecl CRTDLL_towlower( WCHAR ch ) -{ - return NTDLL_towlower(ch); -} - - -/********************************************************************* - * CRTDLL_towupper (CRTDLL.494) - */ -WCHAR __cdecl CRTDLL_towupper( WCHAR ch ) -{ - return NTDLL_towupper(ch); -} - - -/*********************************************************************** - * CRTDLL_wcscat (CRTDLL.503) - */ -LPWSTR __cdecl CRTDLL_wcscat( LPWSTR dst, LPCWSTR src ) -{ - LPWSTR p = dst; - while (*p) p++; - while ((*p++ = *src++)); - return dst; -} - - -/********************************************************************* - * CRTDLL_wcschr (CRTDLL.504) - */ -LPWSTR __cdecl CRTDLL_wcschr( LPCWSTR str, WCHAR ch ) -{ - while (*str) - { - if (*str == ch) return (LPWSTR)str; - str++; - } - return NULL; -} - - -/********************************************************************* - * CRTDLL_wcscmp (CRTDLL.505) - */ -INT __cdecl CRTDLL_wcscmp( LPCWSTR str1, LPCWSTR str2 ) -{ - while (*str1 && (*str1 == *str2)) { str1++; str2++; } - return (INT)(*str1 - *str2); -} - - /********************************************************************* * CRTDLL_wcscoll (CRTDLL.506) */ DWORD __cdecl CRTDLL_wcscoll( LPCWSTR str1, LPCWSTR str2 ) { /* FIXME: handle collates */ - return CRTDLL_wcscmp( str1, str2 ); -} - - -/*********************************************************************** - * CRTDLL_wcscpy (CRTDLL.507) - */ -LPWSTR __cdecl CRTDLL_wcscpy( LPWSTR dst, LPCWSTR src ) -{ - LPWSTR p = dst; - while ((*p++ = *src++)); - return dst; -} - - -/********************************************************************* - * CRTDLL_wcscspn (CRTDLL.508) - */ -INT __cdecl CRTDLL_wcscspn( LPCWSTR str, LPCWSTR reject ) -{ - LPCWSTR start = str; - while (*str) - { - LPCWSTR p = reject; - while (*p && (*p != *str)) p++; - if (*p) break; - str++; - } - return str - start; -} - - -/*********************************************************************** - * CRTDLL_wcslen (CRTDLL.510) - */ -INT __cdecl CRTDLL_wcslen( LPCWSTR str ) -{ - LPCWSTR s = str; - while (*s) s++; - return s - str; -} - - -/********************************************************************* - * CRTDLL_wcsncat (CRTDLL.511) - */ -LPWSTR __cdecl CRTDLL_wcsncat( LPWSTR s1, LPCWSTR s2, INT n ) -{ - LPWSTR ret = s1; - while (*s1) s1++; - while (n-- > 0) if (!(*s1++ = *s2++)) return ret; - *s1 = 0; - return ret; -} - - -/********************************************************************* - * CRTDLL_wcsncmp (CRTDLL.512) - */ -INT __cdecl CRTDLL_wcsncmp( LPCWSTR str1, LPCWSTR str2, INT n ) -{ - if (!n) return 0; - while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; } - return (INT)(*str1 - *str2); -} - - -/********************************************************************* - * CRTDLL_wcsncpy (CRTDLL.513) - */ -LPWSTR __cdecl CRTDLL_wcsncpy( LPWSTR s1, LPCWSTR s2, INT n ) -{ - LPWSTR ret = s1; - while (n-- > 0) if (!(*s1++ = *s2++)) break; - while (n-- > 0) *s1++ = 0; - return ret; + return strcmpW( str1, str2 ); } @@ -294,104 +108,6 @@ LPWSTR __cdecl CRTDLL_wcspbrk( LPCWSTR str, LPCWSTR accept ) } -/********************************************************************* - * CRTDLL_wcsrchr (CRTDLL.515) - */ -LPWSTR __cdecl CRTDLL_wcsrchr( LPWSTR str, WCHAR ch ) -{ - LPWSTR last = NULL; - while (*str) - { - if (*str == ch) last = str; - str++; - } - return last; -} - - -/********************************************************************* - * CRTDLL_wcsspn (CRTDLL.516) - */ -INT __cdecl CRTDLL_wcsspn( LPCWSTR str, LPCWSTR accept ) -{ - LPCWSTR start = str; - while (*str) - { - LPCWSTR p = accept; - while (*p && (*p != *str)) p++; - if (!*p) break; - str++; - } - return str - start; -} - - -/********************************************************************* - * CRTDLL_wcsstr (CRTDLL.517) - */ -LPWSTR __cdecl CRTDLL_wcsstr( LPCWSTR str, LPCWSTR sub ) -{ - while (*str) - { - LPCWSTR p1 = str, p2 = sub; - while (*p1 && *p2 && *p1 == *p2) { p1++; p2++; } - if (!*p2) return (LPWSTR)str; - str++; - } - return NULL; -} - - -/********************************************************************* - * CRTDLL_wcstok (CRTDLL.519) - */ -LPWSTR __cdecl CRTDLL_wcstok( LPWSTR str, LPCWSTR delim ) -{ - static LPWSTR next = NULL; - LPWSTR ret; - - if (!str) - if (!(str = next)) return NULL; - - while (*str && CRTDLL_wcschr( delim, *str )) str++; - if (!*str) return NULL; - ret = str++; - while (*str && !CRTDLL_wcschr( delim, *str )) str++; - if (*str) *str++ = 0; - next = str; - return ret; -} - - -/********************************************************************* - * CRTDLL_wcstombs (CRTDLL.521) - * - * FIXME: the reason I do not use wcstombs is that it seems to fail - * for any latin-1 valid character. Not good. - */ -INT __cdecl CRTDLL_wcstombs( LPSTR dst, LPCWSTR src, INT n ) -{ - int copied=0; - while ((n>0) && *src) { - int ret; - /* FIXME: could potentially overflow if we ever have MB of 2 bytes*/ - ret = wctomb(dst,(wchar_t)*src); - if (ret<0) { - /* FIXME: sadly, some versions of glibc do not like latin characters - * as UNICODE chars for some reason (like german umlauts). Just - * copy those anyway. MM 991106 - */ - *dst=*src; - ret = 1; - } - dst += ret; - n -= ret; - copied += ret; - src++; - } - return copied; -} - /********************************************************************* * CRTDLL_wctomb (CRTDLL.524) */ @@ -400,17 +116,14 @@ INT __cdecl CRTDLL_wctomb( LPSTR dst, WCHAR ch ) return wctomb( dst, (wchar_t)ch ); } +extern INT __cdecl NTDLL_iswctype( WCHAR wc, WCHAR wct ); /* FIXME */ + /********************************************************************* * CRTDLL_iswalnum (CRTDLL.405) */ INT __cdecl CRTDLL_iswalnum( WCHAR wc ) { -#ifdef HAVE_WCTYPE_H -#undef iswalnum - return iswalnum(wc); -#else - return isalnum( LOBYTE(wc) ); /* FIXME */ -#endif + return NTDLL_iswctype( wc, 0x0107 ); } /********************************************************************* @@ -418,12 +131,7 @@ INT __cdecl CRTDLL_iswalnum( WCHAR wc ) */ INT __cdecl CRTDLL_iswalpha( WCHAR wc ) { -#ifdef HAVE_WCTYPE_H -#undef iswalpha - return iswalpha(wc); -#else - return isalpha( LOBYTE(wc) ); /* FIXME */ -#endif + return NTDLL_iswctype( wc, 0x0103 ); } /********************************************************************* @@ -431,12 +139,7 @@ INT __cdecl CRTDLL_iswalpha( WCHAR wc ) */ INT __cdecl CRTDLL_iswcntrl( WCHAR wc ) { -#ifdef HAVE_WCTYPE_H -#undef iswcntrl - return iswcntrl(wc); -#else - return iscntrl( LOBYTE(wc) ); /* FIXME */ -#endif + return NTDLL_iswctype( wc, 0x0020 ); } /********************************************************************* @@ -444,12 +147,7 @@ INT __cdecl CRTDLL_iswcntrl( WCHAR wc ) */ INT __cdecl CRTDLL_iswdigit( WCHAR wc ) { -#ifdef HAVE_WCTYPE_H -#undef iswdigit - return iswdigit(wc); -#else - return isdigit( LOBYTE(wc) ); /* FIXME */ -#endif + return NTDLL_iswctype( wc, 0x0004 ); } /********************************************************************* @@ -457,12 +155,7 @@ INT __cdecl CRTDLL_iswdigit( WCHAR wc ) */ INT __cdecl CRTDLL_iswgraph( WCHAR wc ) { -#ifdef HAVE_WCTYPE_H -#undef iswgraph - return iswgraph(wc); -#else - return isgraph( LOBYTE(wc) ); /* FIXME */ -#endif + return NTDLL_iswctype( wc, 0x0117 ); } /********************************************************************* @@ -470,12 +163,7 @@ INT __cdecl CRTDLL_iswgraph( WCHAR wc ) */ INT __cdecl CRTDLL_iswlower( WCHAR wc ) { -#ifdef HAVE_WCTYPE_H -#undef iswlower - return iswlower(wc); -#else - return islower( LOBYTE(wc) ); /* FIXME */ -#endif + return NTDLL_iswctype( wc, 0x0002 ); } /********************************************************************* @@ -483,12 +171,7 @@ INT __cdecl CRTDLL_iswlower( WCHAR wc ) */ INT __cdecl CRTDLL_iswprint( WCHAR wc ) { -#ifdef HAVE_WCTYPE_H -#undef iswprint - return iswprint(wc); -#else - return isprint( LOBYTE(wc) ); /* FIXME */ -#endif + return NTDLL_iswctype( wc, 0x0157 ); } /********************************************************************* @@ -496,12 +179,7 @@ INT __cdecl CRTDLL_iswprint( WCHAR wc ) */ INT __cdecl CRTDLL_iswpunct( WCHAR wc ) { -#ifdef HAVE_WCTYPE_H -#undef iswpunct - return iswpunct(wc); -#else - return ispunct( LOBYTE(wc) ); /* FIXME */ -#endif + return NTDLL_iswctype( wc, 0x0010 ); } /********************************************************************* @@ -509,12 +187,7 @@ INT __cdecl CRTDLL_iswpunct( WCHAR wc ) */ INT __cdecl CRTDLL_iswspace( WCHAR wc ) { -#ifdef HAVE_WCTYPE_H -#undef iswspace - return iswspace(wc); -#else - return isspace( LOBYTE(wc) ); /* FIXME */ -#endif + return NTDLL_iswctype( wc, 0x0008 ); } /********************************************************************* @@ -522,12 +195,7 @@ INT __cdecl CRTDLL_iswspace( WCHAR wc ) */ INT __cdecl CRTDLL_iswupper( WCHAR wc ) { -#ifdef HAVE_WCTYPE_H -#undef iswupper - return iswupper(wc); -#else - return isupper( LOBYTE(wc) ); /* FIXME */ -#endif + return NTDLL_iswctype( wc, 0x0001 ); } /********************************************************************* @@ -535,32 +203,5 @@ INT __cdecl CRTDLL_iswupper( WCHAR wc ) */ INT __cdecl CRTDLL_iswxdigit( WCHAR wc ) { -#ifdef HAVE_WCTYPE_H -#undef iswxdigit - return iswxdigit(wc); -#else - return isxdigit( LOBYTE(wc) ); /* FIXME */ -#endif -} - -/********************************************************************* - * CRTDLL_iswctype (CRTDLL.409) - */ -INT __cdecl CRTDLL_iswctype( WCHAR wc, WCHAR wct ) -{ - INT res = 0; - - if (wct & 0x0001) res |= CRTDLL_iswupper(wc); - if (wct & 0x0002) res |= CRTDLL_iswlower(wc); - if (wct & 0x0004) res |= CRTDLL_iswdigit(wc); - if (wct & 0x0008) res |= CRTDLL_iswspace(wc); - if (wct & 0x0010) res |= CRTDLL_iswpunct(wc); - if (wct & 0x0020) res |= CRTDLL_iswcntrl(wc); - if (wct & 0x0080) res |= CRTDLL_iswxdigit(wc); - if (wct & 0x0100) res |= CRTDLL_iswalpha(wc); - if (wct & 0x0040) - FIXME(": iswctype(%04hx,_BLANK|...) requested\n",wc); - if (wct & 0x8000) - FIXME(": iswctype(%04hx,_LEADBYTE|...) requested\n",wc); - return res; + return NTDLL_iswctype( wc, 0x0080 ); } diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in index 6d285771b3f6799698e74ee789c2f8f8517fef7a..5e91d270c01c237743066fd446ad1fc32b178266 100644 --- a/dlls/ntdll/Makefile.in +++ b/dlls/ntdll/Makefile.in @@ -17,11 +17,13 @@ C_SRCS = \ reg.c \ rtl.c \ rtlstr.c \ + string.c \ sec.c \ signal_i386.c \ signal_sparc.c \ sync.c \ - time.c + time.c \ + wcstring.c all: $(MODULE).o diff --git a/dlls/ntdll/misc.c b/dlls/ntdll/misc.c index 514167c7cfa2533ae43c2dcffc44b3611470d3a8..224b3961c3b99083905478abfc848e7c2971bb10 100644 --- a/dlls/ntdll/misc.c +++ b/dlls/ntdll/misc.c @@ -10,6 +10,12 @@ DEFAULT_DEBUG_CHANNEL(ntdll); +#if defined(__GNUC__) && defined(__i386__) +#define USING_REAL_FPU +#define DO_FPU(x,y) __asm__ __volatile__( x " %0;fwait" : "=m" (y) : ) +#define POP_FPU(x) DO_FPU("fstpl",x) +#endif + void dump_ObjectAttributes (POBJECT_ATTRIBUTES oa) { if (oa) @@ -52,3 +58,41 @@ LPCSTR debugstr_us (PUNICODE_STRING us) return debugstr_wn(us->Buffer, us->Length); } +/********************************************************************* + * _ftol (NTDLL) + */ +#ifdef USING_REAL_FPU +LONG __cdecl NTDLL__ftol(void) +{ + /* don't just do DO_FPU("fistp",retval), because the rounding + * mode must also be set to "round towards zero"... */ + double fl; + POP_FPU(fl); + return (LONG)fl; +} +#else +LONG __cdecl NTDLL__ftol(double fl) +{ + FIXME("should be register function\n"); + return (LONG)fl; +} +#endif + +/********************************************************************* + * _CIpow (NTDLL) + */ +#ifdef USING_REAL_FPU +LONG __cdecl NTDLL__CIpow(void) +{ + double x,y; + POP_FPU(y); + POP_FPU(x); + return pow(x,y); +} +#else +LONG __cdecl NTDLL__CIpow(double x,double y) +{ + FIXME("should be register function\n"); + return pow(x,y); +} +#endif diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index ebcaaba53bd4c900b7a8939038176ac751f3898c..5aeb475df8b7b25c96ae3ba940c94dd3e63af36c 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -753,7 +753,7 @@ type win32 @ stub ZwWriteFile @ stub ZwWriteRequestData @ stub ZwWriteVirtualMemory -@ stub _CIpow +@ cdecl _CIpow() NTDLL__CIpow @ stub __eCommonExceptions @ stub __eEmulatorInit @ stub __eF2XM1 @@ -868,25 +868,25 @@ type win32 @ register _alloca_probe() NTDLL_alloca_probe @ register _chkstk() NTDLL_chkstk @ stub _fltused -@ cdecl _ftol(double) CRTDLL__ftol -@ cdecl _itoa(long ptr long) CRTDLL__itoa -@ stub _ltoa +@ cdecl _ftol() NTDLL__ftol +@ cdecl _itoa(long ptr long) _itoa +@ cdecl _ltoa(long ptr long) _ltoa @ stub _memccpy -@ cdecl _memicmp(str str long) CRTDLL__memicmp +@ cdecl _memicmp(str str long) _memicmp @ stub _snprintf @ stub _snwprintf @ stub _splitpath -@ cdecl _strcmpi(str str) CRTDLL__strcmpi -@ cdecl _stricmp(str str) CRTDLL__strcmpi -@ cdecl _strlwr(str) CRTDLL__strlwr -@ cdecl _strnicmp(str str long) CRTDLL__strnicmp -@ cdecl _strupr(str) CRTDLL__strupr -@ cdecl _ultoa(long ptr long) CRTDLL__ultoa +@ cdecl _strcmpi(str str) strcasecmp +@ cdecl _stricmp(str str) strcasecmp +@ cdecl _strlwr(str) _strlwr +@ cdecl _strnicmp(str str long) strncasecmp +@ cdecl _strupr(str) _strupr +@ cdecl _ultoa(long ptr long) _ultoa @ stub _vsnprintf -@ cdecl _wcsicmp(wstr wstr) CRTDLL__wcsicmp -@ cdecl _wcslwr(wstr) CRTDLL__wcslwr -@ cdecl _wcsnicmp(wstr wstr long) CRTDLL__wcsnicmp -@ cdecl _wcsupr(wstr) CRTDLL__wcsupr +@ cdecl _wcsicmp(wstr wstr) NTDLL__wcsicmp +@ cdecl _wcslwr(wstr) NTDLL__wcslwr +@ cdecl _wcsnicmp(wstr wstr long) NTDLL__wcsnicmp +@ cdecl _wcsupr(wstr) NTDLL__wcsupr @ stub abs @ stub atan @ cdecl atoi(str) atoi @@ -901,12 +901,12 @@ type win32 @ cdecl isprint(long) isprint @ cdecl isspace(long) isspace @ cdecl isupper(long) isupper -@ cdecl iswalpha(long) CRTDLL_iswalpha -@ cdecl iswctype(long long) CRTDLL_iswctype +@ cdecl iswalpha(long) NTDLL_iswalpha +@ cdecl iswctype(long long) NTDLL_iswctype @ cdecl isxdigit(long) isxdigit @ stub labs @ stub log -@ cdecl mbstowcs(ptr str long) CRTDLL_mbstowcs +@ cdecl mbstowcs(ptr str long) NTDLL_mbstowcs @ cdecl memchr(ptr long long) memchr @ cdecl memcmp(ptr ptr long) memcmp @ cdecl memcpy(ptr ptr long) memcpy @@ -937,23 +937,23 @@ type win32 @ cdecl toupper(long) toupper @ cdecl towlower(long) NTDLL_towlower @ cdecl towupper(long) NTDLL_towupper -@ cdecl vsprintf(ptr str ptr) CRTDLL_vsprintf -@ cdecl wcscat(wstr wstr) CRTDLL_wcscat -@ cdecl wcschr(wstr long) CRTDLL_wcschr -@ cdecl wcscmp(wstr wstr) CRTDLL_wcscmp -@ cdecl wcscpy(ptr wstr) CRTDLL_wcscpy -@ cdecl wcscspn(wstr wstr) CRTDLL_wcscspn -@ cdecl wcslen(wstr) CRTDLL_wcslen -@ cdecl wcsncat(wstr wstr long) CRTDLL_wcsncat -@ cdecl wcsncmp(wstr wstr long) CRTDLL_wcsncmp -@ cdecl wcsncpy(ptr wstr long) CRTDLL_wcsncpy -@ cdecl wcspbrk(wstr wstr) CRTDLL_wcspbrk -@ cdecl wcsrchr(wstr long) CRTDLL_wcsrchr -@ cdecl wcsspn(wstr wstr) CRTDLL_wcsspn -@ cdecl wcsstr(wstr wstr) CRTDLL_wcsstr -@ cdecl wcstok(wstr wstr) CRTDLL_wcstok -@ cdecl wcstol(wstr ptr long) CRTDLL_wcstol -@ cdecl wcstombs(ptr ptr long) CRTDLL_wcstombs +@ cdecl vsprintf(ptr str ptr) vsprintf +@ cdecl wcscat(wstr wstr) NTDLL_wcscat +@ cdecl wcschr(wstr long) NTDLL_wcschr +@ cdecl wcscmp(wstr wstr) NTDLL_wcscmp +@ cdecl wcscpy(ptr wstr) NTDLL_wcscpy +@ cdecl wcscspn(wstr wstr) NTDLL_wcscspn +@ cdecl wcslen(wstr) NTDLL_wcslen +@ cdecl wcsncat(wstr wstr long) NTDLL_wcsncat +@ cdecl wcsncmp(wstr wstr long) NTDLL_wcsncmp +@ cdecl wcsncpy(ptr wstr long) NTDLL_wcsncpy +@ cdecl wcspbrk(wstr wstr) NTDLL_wcspbrk +@ cdecl wcsrchr(wstr long) NTDLL_wcsrchr +@ cdecl wcsspn(wstr wstr) NTDLL_wcsspn +@ cdecl wcsstr(wstr wstr) NTDLL_wcsstr +@ cdecl wcstok(wstr wstr) NTDLL_wcstok +@ cdecl wcstol(wstr ptr long) NTDLL_wcstol +@ cdecl wcstombs(ptr ptr long) NTDLL_wcstombs @ stub wcstoul @ stub NtAddAtom @ stub NtDeleteAtom diff --git a/dlls/ntdll/rtlstr.c b/dlls/ntdll/rtlstr.c index b631ccc9182b355dcd0208b946f3de5d6d9cbc5e..73d456cbbd6d2e7677ed9482505abf0357d44de0 100644 --- a/dlls/ntdll/rtlstr.c +++ b/dlls/ntdll/rtlstr.c @@ -11,7 +11,6 @@ #include <ctype.h> #include "wine/winestring.h" #include "wine/unicode.h" -#include "crtdll.h" #include "heap.h" #include "winnls.h" #include "debugtools.h" @@ -22,22 +21,6 @@ DEFAULT_DEBUG_CHANNEL(ntdll); /* STRING FUNCTIONS */ -/************************************************************************** - * NTDLL.towupper - */ -WCHAR CDECL NTDLL_towupper(WCHAR code) -{ - return toupperW(code); -} - -/************************************************************************** - * NTDLL.towlower - */ -WCHAR CDECL NTDLL_towlower(WCHAR code) -{ - return tolowerW(code); -} - /************************************************************************** * RtlInitString */ @@ -154,9 +137,9 @@ BOOLEAN WINAPI RtlEqualUnicodeString( if (s1->Length != s2->Length) return FALSE; if (CaseInsensitive) - ret = !CRTDLL__wcsnicmp(s1->Buffer,s2->Buffer,s1->Length/sizeof(WCHAR)); + ret = !strncmpiW(s1->Buffer,s2->Buffer,s1->Length/sizeof(WCHAR)); else - ret = !CRTDLL_wcsncmp(s1->Buffer,s2->Buffer,s1->Length/sizeof(WCHAR)); + ret = !strncmpW(s1->Buffer,s2->Buffer,s1->Length/sizeof(WCHAR)); return ret; } @@ -179,9 +162,9 @@ LONG WINAPI RtlCompareUnicodeString( if (s1->Length != s2->Length) return (s1->Length - s2->Length); if (CaseInsensitive) - ret = CRTDLL__wcsnicmp(s1->Buffer,s2->Buffer,s1->Length/sizeof(WCHAR)); + ret = strncmpiW(s1->Buffer,s2->Buffer,s1->Length/sizeof(WCHAR)); else - ret = CRTDLL_wcsncmp(s1->Buffer,s2->Buffer,s1->Length/sizeof(WCHAR)); + ret = strncmpW(s1->Buffer,s2->Buffer,s1->Length/sizeof(WCHAR)); return ret; } diff --git a/dlls/ntdll/string.c b/dlls/ntdll/string.c new file mode 100644 index 0000000000000000000000000000000000000000..5e552b784b808038ea2baba3519601d8d18cae73 --- /dev/null +++ b/dlls/ntdll/string.c @@ -0,0 +1,94 @@ +/* + * NTDLL string functions + * + * Copyright 2000 Alexandre Julliard + */ + +#include "config.h" + +#include <ctype.h> +#include <string.h> + +#include "windef.h" + +/********************************************************************* + * _memicmp (NTDLL) + */ +INT __cdecl _memicmp( LPCSTR s1, LPCSTR s2, DWORD len ) +{ + int ret = 0; + while (len--) + { + if ((ret = tolower(*s1) - tolower(*s2))) break; + s1++; + s2++; + } + return ret; +} + +/********************************************************************* + * _strupr (NTDLL) + */ +LPSTR __cdecl _strupr( LPSTR str ) +{ + LPSTR ret = str; + for ( ; *str; str++) *str = toupper(*str); + return ret; +} + +/********************************************************************* + * _strlwr (NTDLL) + * + * convert a string in place to lowercase + */ +LPSTR __cdecl _strlwr( LPSTR str ) +{ + LPSTR ret = str; + for ( ; *str; str++) *str = tolower(*str); + return ret; +} + + +/********************************************************************* + * _ultoa (NTDLL) + */ +LPSTR __cdecl _ultoa( unsigned long x, LPSTR buf, INT radix ) +{ + char buffer[32], *p; + + p = buffer + sizeof(buffer); + *--p = 0; + do + { + int rem = x % radix; + *--p = (rem <= 9) ? rem + '0' : rem + 'a' - 10; + x /= radix; + } while (x); + strcpy( buf, p + 1 ); + return buf; +} + + +/********************************************************************* + * _ltoa (NTDLL) + */ +LPSTR __cdecl _ltoa( long x, LPSTR buf, INT radix ) +{ + LPSTR p = buf; + if (x < 0) + { + *p++ = '-'; + x = -x; + } + _ultoa( x, p, radix ); + return buf; +} + + +/********************************************************************* + * _itoa (NTDLL) + */ +LPSTR __cdecl _itoa( int x, LPSTR buf, INT radix ) +{ + return _ltoa( x, buf, radix ); +} diff --git a/dlls/ntdll/wcstring.c b/dlls/ntdll/wcstring.c new file mode 100644 index 0000000000000000000000000000000000000000..d257e3f3360479d753fcccf3e9ae5c983cdf401d --- /dev/null +++ b/dlls/ntdll/wcstring.c @@ -0,0 +1,342 @@ +/* + * NTDLL wide-char functions + * + * Copyright 2000 Alexandre Julliard + */ + +#include "config.h" + +#include <ctype.h> +#include <stdlib.h> +#include <string.h> +#ifdef HAVE_WCTYPE_H +#include <wctype.h> +#endif + +#include "windef.h" +#include "winbase.h" +#include "winnls.h" +#include "wine/unicode.h" +#include "heap.h" +#include "debugtools.h" + +DEFAULT_DEBUG_CHANNEL(ntdll); + + +/********************************************************************* + * NTDLL__wcsicmp (NTDLL) + */ +INT __cdecl NTDLL__wcsicmp( LPCWSTR str1, LPCWSTR str2 ) +{ + return strcmpiW( str1, str2 ); +} + + +/********************************************************************* + * NTDLL__wcslwr (NTDLL) + */ +LPWSTR __cdecl NTDLL__wcslwr( LPWSTR str ) +{ + return strlwrW( str ); +} + + +/********************************************************************* + * NTDLL__wcsnicmp (NTDLL) + */ +INT __cdecl NTDLL__wcsnicmp( LPCWSTR str1, LPCWSTR str2, INT n ) +{ + return strncmpiW( str1, str2, n ); +} + + +/********************************************************************* + * NTDLL__wcsupr (NTDLL) + */ +LPWSTR __cdecl NTDLL__wcsupr( LPWSTR str ) +{ + return struprW( str ); +} + + +/********************************************************************* + * NTDLL_towlower (NTDLL) + */ +WCHAR __cdecl NTDLL_towlower( WCHAR ch ) +{ + return tolowerW(ch); +} + + +/********************************************************************* + * NTDLL_towupper (NTDLL) + */ +WCHAR __cdecl NTDLL_towupper( WCHAR ch ) +{ + return toupperW(ch); +} + + +/*********************************************************************** + * NTDLL_wcscat (NTDLL) + */ +LPWSTR __cdecl NTDLL_wcscat( LPWSTR dst, LPCWSTR src ) +{ + return strcatW( dst, src ); +} + + +/********************************************************************* + * NTDLL_wcschr (NTDLL) + */ +LPWSTR __cdecl NTDLL_wcschr( LPCWSTR str, WCHAR ch ) +{ + return strchrW( str, ch ); +} + + +/********************************************************************* + * NTDLL_wcscmp (NTDLL) + */ +INT __cdecl NTDLL_wcscmp( LPCWSTR str1, LPCWSTR str2 ) +{ + return strcmpW( str1, str2 ); +} + + +/*********************************************************************** + * NTDLL_wcscpy (NTDLL) + */ +LPWSTR __cdecl NTDLL_wcscpy( LPWSTR dst, LPCWSTR src ) +{ + return strcpyW( dst, src ); +} + + +/********************************************************************* + * NTDLL_wcscspn (NTDLL) + */ +INT __cdecl NTDLL_wcscspn( LPCWSTR str, LPCWSTR reject ) +{ + LPCWSTR start = str; + while (*str) + { + LPCWSTR p = reject; + while (*p && (*p != *str)) p++; + if (*p) break; + str++; + } + return str - start; +} + + +/*********************************************************************** + * NTDLL_wcslen (NTDLL) + */ +INT __cdecl NTDLL_wcslen( LPCWSTR str ) +{ + return strlenW( str ); +} + + +/********************************************************************* + * NTDLL_wcsncat (NTDLL) + */ +LPWSTR __cdecl NTDLL_wcsncat( LPWSTR s1, LPCWSTR s2, INT n ) +{ + LPWSTR ret = s1; + while (*s1) s1++; + while (n-- > 0) if (!(*s1++ = *s2++)) return ret; + *s1 = 0; + return ret; +} + + +/********************************************************************* + * NTDLL_wcsncmp (NTDLL) + */ +INT __cdecl NTDLL_wcsncmp( LPCWSTR str1, LPCWSTR str2, INT n ) +{ + return strncmpW( str1, str2, n ); +} + + +/********************************************************************* + * NTDLL_wcsncpy (NTDLL) + */ +LPWSTR __cdecl NTDLL_wcsncpy( LPWSTR s1, LPCWSTR s2, INT n ) +{ + LPWSTR ret = s1; + while (n-- > 0) if (!(*s1++ = *s2++)) break; + while (n-- > 0) *s1++ = 0; + return ret; +} + + +/********************************************************************* + * NTDLL_wcspbrk (NTDLL) + */ +LPWSTR __cdecl NTDLL_wcspbrk( LPCWSTR str, LPCWSTR accept ) +{ + LPCWSTR p; + while (*str) + { + for (p = accept; *p; p++) if (*p == *str) return (LPWSTR)str; + str++; + } + return NULL; +} + + +/********************************************************************* + * NTDLL_wcsrchr (NTDLL) + */ +LPWSTR __cdecl NTDLL_wcsrchr( LPWSTR str, WCHAR ch ) +{ + LPWSTR last = NULL; + while (*str) + { + if (*str == ch) last = str; + str++; + } + return last; +} + + +/********************************************************************* + * NTDLL_wcsspn (NTDLL) + */ +INT __cdecl NTDLL_wcsspn( LPCWSTR str, LPCWSTR accept ) +{ + LPCWSTR start = str; + while (*str) + { + LPCWSTR p = accept; + while (*p && (*p != *str)) p++; + if (!*p) break; + str++; + } + return str - start; +} + + +/********************************************************************* + * NTDLL_wcsstr (NTDLL) + */ +LPWSTR __cdecl NTDLL_wcsstr( LPCWSTR str, LPCWSTR sub ) +{ + return strstrW( str, sub ); +} + + +/********************************************************************* + * NTDLL_wcstok (NTDLL) + */ +LPWSTR __cdecl NTDLL_wcstok( LPWSTR str, LPCWSTR delim ) +{ + static LPWSTR next = NULL; + LPWSTR ret; + + if (!str) + if (!(str = next)) return NULL; + + while (*str && NTDLL_wcschr( delim, *str )) str++; + if (!*str) return NULL; + ret = str++; + while (*str && !NTDLL_wcschr( delim, *str )) str++; + if (*str) *str++ = 0; + next = str; + return ret; +} + + +/********************************************************************* + * NTDLL_wcstombs (NTDLL) + */ +INT __cdecl NTDLL_wcstombs( LPSTR dst, LPCWSTR src, INT n ) +{ + INT ret; + if (n <= 0) return 0; + ret = WideCharToMultiByte( CP_ACP, 0, src, -1, dst, dst ? n : 0, NULL, NULL ); + if (!ret) return n; /* overflow */ + return ret - 1; /* do not count terminating NULL */ +} + + +/********************************************************************* + * NTDLL_mbstowcs (NTDLL) + */ +INT __cdecl NTDLL_mbstowcs( LPWSTR dst, LPCSTR src, INT n ) +{ + INT ret; + if (n <= 0) return 0; + ret = MultiByteToWideChar( CP_ACP, 0, src, -1, dst, dst ? n : 0 ); + if (!ret) return n; /* overflow */ + return ret - 1; /* do not count terminating NULL */ +} + + +/********************************************************************* + * wcstol (NTDLL) + * Like strtol, but for wide character strings. + */ +INT __cdecl NTDLL_wcstol(LPWSTR s,LPWSTR *end,INT base) +{ + LPSTR sA = HEAP_strdupWtoA(GetProcessHeap(),0,s),endA; + INT ret = strtol(sA,&endA,base); + + HeapFree(GetProcessHeap(),0,sA); + if (end) *end = s+(endA-sA); /* pointer magic checked. */ + return ret; +} + + +/********************************************************************* + * NTDLL_iswctype (NTDLL) + */ +INT __cdecl NTDLL_iswctype( WCHAR wc, WCHAR wct ) +{ + INT res = 0; + +#ifdef HAVE_WCTYPE_H +#undef iswupper +#undef iswlower +#undef iswdigit +#undef iswspace +#undef iswpunct +#undef iswcntrl +#undef iswxdigit +#undef iswalpha + if (wct & 0x0001) res |= iswupper(wc); + if (wct & 0x0002) res |= iswlower(wc); + if (wct & 0x0004) res |= iswdigit(wc); + if (wct & 0x0008) res |= iswspace(wc); + if (wct & 0x0010) res |= iswpunct(wc); + if (wct & 0x0020) res |= iswcntrl(wc); + if (wct & 0x0080) res |= iswxdigit(wc); + if (wct & 0x0100) res |= iswalpha(wc); +#else + if (wct & 0x0001) res |= isupper(LOBYTE(wc)); + if (wct & 0x0002) res |= islower(LOBYTE(wc)); + if (wct & 0x0004) res |= isdigit(LOBYTE(wc)); + if (wct & 0x0008) res |= isspace(LOBYTE(wc)); + if (wct & 0x0010) res |= ispunct(LOBYTE(wc)); + if (wct & 0x0020) res |= iscntrl(LOBYTE(wc)); + if (wct & 0x0080) res |= isxdigit(LOBYTE(wc)); + if (wct & 0x0100) res |= isalpha(LOBYTE(wc)); +#endif + if (wct & 0x0040) + FIXME(": iswctype(%04hx,_BLANK|...) requested\n",wc); + if (wct & 0x8000) + FIXME(": iswctype(%04hx,_LEADBYTE|...) requested\n",wc); + return res; +} + + +/********************************************************************* + * NTDLL_iswalpha (NTDLL) + */ +INT __cdecl NTDLL_iswalpha( WCHAR wc ) +{ + return NTDLL_iswctype( wc, 0x0100 ); +} diff --git a/include/crtdll.h b/include/crtdll.h index 0756d4eaaa6a56486380d16720384dce0c984b09..9d731fff79c10d9d529cbe8a69feb24c430147cd 100644 --- a/include/crtdll.h +++ b/include/crtdll.h @@ -32,16 +32,11 @@ void __cdecl CRTDLL_free( void *ptr ); LPSTR __cdecl CRTDLL__mbsinc( LPCSTR str ); INT __cdecl CRTDLL__mbslen( LPCSTR str ); -LPSTR __cdecl CRTDLL__strlwr( LPSTR str ); LPWSTR __cdecl CRTDLL__wcsdup( LPCWSTR str ); -INT __cdecl CRTDLL__wcsicmp( LPCWSTR str1, LPCWSTR str2 ); INT __cdecl CRTDLL__wcsicoll( LPCWSTR str1, LPCWSTR str2 ); -LPWSTR __cdecl CRTDLL__wcslwr( LPWSTR str ); -INT __cdecl CRTDLL__wcsnicmp( LPCWSTR str1, LPCWSTR str2, INT n ); LPWSTR __cdecl CRTDLL__wcsnset( LPWSTR str, WCHAR c, INT n ); LPWSTR __cdecl CRTDLL__wcsrev( LPWSTR str ); LPWSTR __cdecl CRTDLL__wcsset( LPWSTR str, WCHAR c ); -LPWSTR __cdecl CRTDLL__wcsupr( LPWSTR str ); INT __cdecl CRTDLL_iswalnum( WCHAR wc ); INT __cdecl CRTDLL_iswalpha( WCHAR wc ); INT __cdecl CRTDLL_iswcntrl( WCHAR wc ); @@ -56,39 +51,18 @@ INT __cdecl CRTDLL_iswxdigit( WCHAR wc ); INT __cdecl CRTDLL_iswctype( WCHAR wc, WCHAR wct ); INT __cdecl CRTDLL_mbstowcs( LPWSTR dst, LPCSTR src, INT n ); INT __cdecl CRTDLL_mbtowc( WCHAR *dst, LPCSTR str, INT n ); -WCHAR __cdecl CRTDLL_towlower( WCHAR ch ); -WCHAR __cdecl CRTDLL_towupper( WCHAR ch ); -LPWSTR __cdecl CRTDLL_wcscat( LPWSTR dst, LPCWSTR src ); -LPWSTR __cdecl CRTDLL_wcschr( LPCWSTR str, WCHAR ch ); -INT __cdecl CRTDLL_wcscmp( LPCWSTR str1, LPCWSTR str2 ); DWORD __cdecl CRTDLL_wcscoll( LPCWSTR str1, LPCWSTR str2 ); -LPWSTR __cdecl CRTDLL_wcscpy( LPWSTR dst, LPCWSTR src ); -INT __cdecl CRTDLL_wcscspn( LPCWSTR str, LPCWSTR reject ); -INT __cdecl CRTDLL_wcslen( LPCWSTR str ); -LPWSTR __cdecl CRTDLL_wcsncat( LPWSTR s1, LPCWSTR s2, INT n ); -INT __cdecl CRTDLL_wcsncmp( LPCWSTR str1, LPCWSTR str2, INT n ); -LPWSTR __cdecl CRTDLL_wcsncpy( LPWSTR s1, LPCWSTR s2, INT n ); LPWSTR __cdecl CRTDLL_wcspbrk( LPCWSTR str, LPCWSTR accept ); -LPWSTR __cdecl CRTDLL_wcsrchr( LPWSTR str, WCHAR ch ); -INT __cdecl CRTDLL_wcsspn( LPCWSTR str, LPCWSTR accept ); -LPWSTR __cdecl CRTDLL_wcsstr( LPCWSTR str, LPCWSTR sub ); -LPWSTR __cdecl CRTDLL_wcstok( LPWSTR str, LPCWSTR delim ); -INT __cdecl CRTDLL_wcstol( LPWSTR s, LPWSTR *end, INT base ); -INT __cdecl CRTDLL_wcstombs( LPSTR dst, LPCWSTR src, INT n ); INT __cdecl CRTDLL_wctomb( LPSTR dst, WCHAR ch ); #ifdef notyet #define _mbsinc CRTDLL__mbsinc #define _mbslen CRTDLL__mbslen #define _wcsdup CRTDLL__wcsdup -#define _wcsicmp CRTDLL__wcsicmp #define _wcsicoll CRTDLL__wcsicoll -#define _wcslwr CRTDLL__wcslwr -#define _wcsnicmp CRTDLL__wcsnicmp #define _wcsnset CRTDLL__wcsnset #define _wcsrev CRTDLL__wcsrev #define _wcsset CRTDLL__wcsset -#define _wcsupr CRTDLL__wcsupr #define iswalnum CRTDLL_iswalnum #define iswalpha CRTDLL_iswalpha #define iswcntrl CRTDLL_iswcntrl @@ -100,26 +74,8 @@ INT __cdecl CRTDLL_wctomb( LPSTR dst, WCHAR ch ); #define iswspace CRTDLL_iswspace #define iswupper CRTDLL_iswupper #define iswxdigit CRTDLL_iswxdigit -#define mbstowcs CRTDLL_mbstowcs #define mbtowc CRTDLL_mbtowc -#define towlower CRTDLL_towlower -#define towupper CRTDLL_towupper -#define wcscat CRTDLL_wcscat -#define wcschr CRTDLL_wcschr -#define wcscmp CRTDLL_wcscmp #define wcscoll CRTDLL_wcscoll -#define wcscpy CRTDLL_wcscpy -#define wcscspn CRTDLL_wcscspn -#define wcslen CRTDLL_wcslen -#define wcsncat CRTDLL_wcsncat -#define wcsncmp CRTDLL_wcsncmp -#define wcsncpy CRTDLL_wcsncpy -#define wcspbrk CRTDLL_wcspbrk -#define wcsrchr CRTDLL_wcsrchr -#define wcsspn CRTDLL_wcsspn -#define wcsstr CRTDLL_wcsstr -#define wcstok CRTDLL_wcstok -#define wcstombs CRTDLL_wcstombs #define wctomb CRTDLL_wctomb #endif