Files
reactos/sdk/include/reactos/wine/unicode.h
Hermès Bélusca-Maïto 30226f834d [SDK:WINE] Improve wine/unicode.h (v)sprintfW defines, regarding the (v)swprintf functions (#6823)
These defines assumed that the (v)swprintf functions were the
non-conformant ones (that don't take a 'count' 2nd parameter).
Because of that, use instead the _(v)swprintf functions. However,
those exist only in NT6+. Therefore, redefine these locally
using the _(v)snprintf functions.

NOTE: wine/unicode.h has been removed in wine commit
348eebae872e90a735041a153635d00b01178cfa from July 13, 2022
2024-05-04 13:47:51 +02:00

91 lines
2.6 KiB
C

/*
* PROJECT: ReactOS
* LICENSE: LGPL v2.1 or any later version
* PURPOSE: Map Wine's Unicode functions to native wcs* functions wherever possible
* AUTHORS: ?
*/
#ifndef __WINE_WINE_UNICODE_H
#define __WINE_WINE_UNICODE_H
#include <stdarg.h>
#include <stdlib.h>
#include <wchar.h>
#include <windef.h>
#include <winbase.h>
#include <winnls.h>
#ifndef WINE_UNICODE_API
#define WINE_UNICODE_API
#endif
#ifndef WINE_UNICODE_INLINE
#define WINE_UNICODE_INLINE static inline
#endif
#if (_WIN32_WINNT < _WIN32_WINNT_VISTA) || (DLL_EXPORT_VERSION < _WIN32_WINNT_VISTA)
/* msvcrt versions incompatibilities */
#define _swprintf(s,f,...) _snwprintf((s),MAXLONG,(f),##__VA_ARGS__)
#define _vswprintf(s,f,v) _vsnwprintf((s),MAXLONG,(f),(v))
#endif
#define memicmpW(s1,s2,n) _wcsnicmp((s1),(s2),(n))
#define strlenW(s) wcslen((s))
#define strcpyW(d,s) wcscpy((d),(s))
#define strcatW(d,s) wcscat((d),(s))
#define strcspnW(d,s) wcscspn((d),(s))
#define strstrW(d,s) wcsstr((d),(s))
#define strtolW(s,e,b) wcstol((s),(e),(b))
#define strchrW(s,c) wcschr((s),(c))
#define strrchrW(s,c) wcsrchr((s),(c))
#define strncmpW(s1,s2,n) wcsncmp((s1),(s2),(n))
#define strncpyW(s1,s2,n) wcsncpy((s1),(s2),(n))
#define strcmpW(s1,s2) wcscmp((s1),(s2))
#define strcmpiW(s1,s2) _wcsicmp((s1),(s2))
#define strncmpiW(s1,s2,n) _wcsnicmp((s1),(s2),(n))
#define strtoulW(s1,s2,b) wcstoul((s1),(s2),(b))
#define strspnW(str, accept) wcsspn((str),(accept))
#define strpbrkW(str, accept) wcspbrk((str),(accept))
#define tolowerW(n) towlower((n))
#define toupperW(n) towupper((n))
#define islowerW(n) iswlower((n))
#define isupperW(n) iswupper((n))
#define isalphaW(n) iswalpha((n))
#define isalnumW(n) iswalnum((n))
#define isdigitW(n) iswdigit((n))
#define isxdigitW(n) iswxdigit((n))
#define isspaceW(n) iswspace((n))
#define iscntrlW(n) iswcntrl((n))
#define atoiW(s) _wtoi((s))
#define atolW(s) _wtol((s))
#define strlwrW(s) _wcslwr((s))
#define struprW(s) _wcsupr((s))
#define sprintfW _swprintf
#define vsprintfW _vswprintf
#define snprintfW _snwprintf
#define vsnprintfW _vsnwprintf
#define isprintW iswprint
static __inline unsigned short get_char_typeW( WCHAR ch )
{
extern const unsigned short wine_wctype_table[];
return wine_wctype_table[wine_wctype_table[ch >> 8] + (ch & 0xff)];
}
static __inline WCHAR *memchrW( const WCHAR *ptr, WCHAR ch, size_t n )
{
const WCHAR *end;
for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) return (WCHAR *)ptr;
return NULL;
}
static __inline WCHAR *memrchrW( const WCHAR *ptr, WCHAR ch, size_t n )
{
const WCHAR *end, *ret = NULL;
for (end = ptr + n; ptr < end; ptr++) if (*ptr == ch) ret = ptr;
return (WCHAR *)ret;
}
#endif