Implement NTDLL.towupper and NTDLL.towlower using already existing

case conversion tables. Replace all direct calls to towupper/towlower
either to NTDLL for core or to CRTDLL if latter already used in the
non core dll.
This commit is contained in:
Dmitry Timoshkov 2000-06-08 20:05:18 +00:00 committed by Alexandre Julliard
parent 960dc908b4
commit 0072c88111
9 changed files with 45 additions and 69 deletions

View File

@ -495,8 +495,8 @@ init CRTDLL_Init
@ cdecl tmpnam(str) CRTDLL_tmpnam
@ cdecl tolower(long) tolower
@ cdecl toupper(long) toupper
@ cdecl towlower(long) towlower
@ cdecl towupper(long) towupper
@ cdecl towlower(long) CRTDLL_towlower
@ cdecl towupper(long) CRTDLL_towupper
@ stub ungetc
@ stub ungetwc
@ cdecl vfprintf(ptr str ptr) CRTDLL_vfprintf

View File

@ -18,6 +18,7 @@
#endif
#include "windef.h"
#include "ntddk.h"
#include "crtdll.h"
#include "debugtools.h"
@ -144,12 +145,7 @@ LPWSTR __cdecl CRTDLL__wcsupr( LPWSTR str )
*/
WCHAR __cdecl CRTDLL_towlower( WCHAR ch )
{
#ifdef HAVE_WCTYPE_H
ch = (WCHAR)towlower( (wchar_t)ch );
#else
if (!HIBYTE(ch)) ch = (WCHAR)tolower( LOBYTE(ch) ); /* FIXME */
#endif
return ch;
return NTDLL_towlower(ch);
}
@ -158,12 +154,7 @@ WCHAR __cdecl CRTDLL_towlower( WCHAR ch )
*/
WCHAR __cdecl CRTDLL_towupper( WCHAR ch )
{
#ifdef HAVE_WCTYPE_H
ch = (WCHAR)towupper( (wchar_t)ch );
#else
if (!HIBYTE(ch)) ch = (WCHAR)toupper( LOBYTE(ch) ); /* FIXME */
#endif
return ch;
return NTDLL_towupper(ch);
}

View File

@ -935,8 +935,8 @@ type win32
@ stub tan
@ cdecl tolower(long) tolower
@ cdecl toupper(long) toupper
@ cdecl towlower(long) towlower
@ cdecl towupper(long) towupper
@ 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

View File

@ -9,9 +9,6 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifdef HAVE_WCTYPE_H
# include <wctype.h>
#endif
#include "wine/winestring.h"
#include "crtdll.h"
#include "heap.h"
@ -20,10 +17,30 @@
#include "ntdll_misc.h"
#include "ntddk.h"
#include "casemap.h"
DEFAULT_DEBUG_CHANNEL(ntdll)
/* STRING FUNCTIONS */
/**************************************************************************
* NTDLL.towupper
*/
WCHAR CDECL NTDLL_towupper(WCHAR code)
{
const WCHAR * ptr = uprtable[HIBYTE(code)];
return ptr ? ptr[LOBYTE(code)] : code;
}
/**************************************************************************
* NTDLL.towlower
*/
WCHAR CDECL NTDLL_towlower(WCHAR code)
{
const WCHAR * ptr = lwrtable[HIBYTE(code)];
return ptr ? ptr[LOBYTE(code)] : code;
}
/**************************************************************************
* RtlInitString
*/
@ -242,7 +259,7 @@ DWORD WINAPI RtlUpcaseUnicodeString(
for (i=0; i < len/sizeof(WCHAR); i++)
{
dest->Buffer[i] = towupper(src->Buffer[i]);
dest->Buffer[i] = NTDLL_towupper(src->Buffer[i]);
}
dest->Length = len;
return STATUS_SUCCESS;
@ -346,7 +363,7 @@ WINAPI RtlUpcaseUnicodeStringToOemString(
for (i=0; i < len; i++)
{
oem->Buffer[i] = towupper((char)(uni->Buffer[i]));
oem->Buffer[i] = NTDLL_towupper((char)(uni->Buffer[i]));
}
oem->Buffer[i] = 0;
return STATUS_SUCCESS;

View File

@ -468,7 +468,7 @@ int WINAPI PathGetDriveNumberA(LPCSTR lpszPath)
*/
int WINAPI PathGetDriveNumberW(LPCWSTR lpszPath)
{
int chr = towlower(lpszPath[0]);
int chr = CRTDLL_towlower(lpszPath[0]);
TRACE ("%s\n",debugstr_w(lpszPath));
@ -1313,7 +1313,7 @@ static BOOL PathMatchSingleMaskW(LPCWSTR name, LPCWSTR mask)
} while (*name++);
return 0;
}
if (towupper(*mask)!=towupper(*name) && *mask!='?') return 0;
if (CRTDLL_towupper(*mask)!=CRTDLL_towupper(*name) && *mask!='?') return 0;
name++;
mask++;
}
@ -1428,7 +1428,7 @@ BOOL WINAPI PathIsSameRootW(LPCWSTR lpszPath1, LPCWSTR lpszPath2)
if (PathIsRelativeW(lpszPath1) || PathIsRelativeW(lpszPath2)) return FALSE;
/* usual path */
if ( towupper(lpszPath1[0])==towupper(lpszPath2[0]) &&
if ( CRTDLL_towupper(lpszPath1[0])==CRTDLL_towupper(lpszPath2[0]) &&
lpszPath1[1]==':' && lpszPath2[1]==':' &&
lpszPath1[2]=='\\' && lpszPath2[2]=='\\')
return TRUE;

View File

@ -585,6 +585,9 @@ DWORD WINAPI RtlGetAce(
/* string functions */
WCHAR CDECL NTDLL_towupper(WCHAR code);
WCHAR CDECL NTDLL_towlower(WCHAR code);
VOID WINAPI RtlInitAnsiString(
PANSI_STRING target,
LPCSTR source);

View File

@ -7,7 +7,6 @@
#ifdef __WINE__
# undef wsprintf
#endif
#include <wctype.h> /* needed for towupper */
#endif
#include "windef.h"
@ -417,12 +416,6 @@
/* use this in a WineLib program if you really want all types */
#define LOCALE_TIMEDATEBOTH 0x00000300 /* full set */
#ifndef HAVE_WCTYPE_H /* fight native wctype.h */
/* Prototypes for Unicode case conversion routines */
WCHAR towupper(WCHAR);
WCHAR towlower(WCHAR);
#endif
/* Definitions for IsTextUnicode() function */
#define IS_TEXT_UNICODE_ASCII16 0x0001
#define IS_TEXT_UNICODE_SIGNATURE 0x0008

View File

@ -12,6 +12,7 @@
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "ntddk.h"
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "wine/keyboard16.h"
@ -224,12 +225,12 @@ INT WINAPI lstrcmpiW( LPCWSTR str1, LPCWSTR str2 )
if ((*str1<0x100 ) && (*str2<0x100)) {
if ((res = toupper(*str1) - toupper(*str2)) != 0) return res;
} else {
if ((res = towupper(*str1) - towupper(*str2)) != 0) return res;
if ((res = NTDLL_towupper(*str1) - NTDLL_towupper(*str2)) != 0) return res;
}
str1++;
str2++;
}
return towupper(*str1) - towupper(*str2);
return NTDLL_towupper(*str1) - NTDLL_towupper(*str2);
}

View File

@ -26,6 +26,7 @@
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "ntddk.h"
#include "wine/winbase16.h"
#include "wine/winuser16.h"
#include "winnls.h"
@ -40,38 +41,8 @@ DEFAULT_DEBUG_CHANNEL(resource);
extern const WORD OLE2NLS_CT_CType3_LUT[]; /* FIXME: does not belong here */
/* Funny to divide them between user and kernel. */
/* be careful: always use functions from wctype.h if character > 255 */
/*
* Unicode case conversion routines ... these should be used where
* toupper/tolower are used for ASCII.
*/
#ifndef HAVE_WCTYPE_H
/* FIXME: should probably get rid of wctype.h altogether */
#include "casemap.h"
/***********************************************************************
* towupper
*/
WCHAR towupper(WCHAR code)
{
const WCHAR * ptr = uprtable[HIBYTE(code)];
return ptr ? ptr[LOBYTE(code)] : code;
}
/***********************************************************************
* towlower
*/
WCHAR towlower(WCHAR code)
{
const WCHAR * ptr = lwrtable[HIBYTE(code)];
return ptr ? ptr[LOBYTE(code)] : code;
}
#endif /* HAVE_WCTYPE_H */
/***********************************************************************
* IsCharAlpha (USER.433)
*/
@ -321,7 +292,7 @@ DWORD WINAPI CharLowerBuffW(LPWSTR x,DWORD buflen)
if (!x) return 0; /* YES */
while (*x && (buflen--))
{
*x=towlower(*x);
*x=NTDLL_towlower(*x);
x++;
done++;
}
@ -339,12 +310,12 @@ LPWSTR WINAPI CharLowerW(LPWSTR x)
LPWSTR s = x;
while (*s)
{
*s=towlower(*s);
*s=NTDLL_towlower(*s);
s++;
}
return x;
}
else return (LPWSTR)((UINT)towlower(LOWORD(x)));
else return (LPWSTR)((UINT)NTDLL_towlower(LOWORD(x)));
}
/***********************************************************************
@ -395,7 +366,7 @@ DWORD WINAPI CharUpperBuffW(LPWSTR x,DWORD buflen)
if (!x) return 0; /* YES */
while (*x && (buflen--))
{
*x=towupper(*x);
*x=NTDLL_towupper(*x);
x++;
done++;
}
@ -413,12 +384,12 @@ LPWSTR WINAPI CharUpperW(LPWSTR x)
LPWSTR s = x;
while (*s)
{
*s=towupper(*s);
*s=NTDLL_towupper(*s);
s++;
}
return x;
}
else return (LPWSTR)((UINT)towupper(LOWORD(x)));
else return (LPWSTR)((UINT)NTDLL_towupper(LOWORD(x)));
}
/***********************************************************************