From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/win32u/win32u_private.h | 95 -------------------------------- dlls/winex11.drv/x11drv.h | 50 ----------------- include/wine/unixlib.h | 101 +++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 145 deletions(-)
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 2d69cbef78e..053fb25fe36 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -525,99 +525,6 @@ static inline WCHAR win32u_towupper( WCHAR ch ) return RtlUpcaseUnicodeChar( ch ); }
-static inline LONG win32u_wcstol( LPCWSTR s, LPWSTR *end, INT base ) -{ - BOOL negative = FALSE, empty = TRUE; - LONG ret = 0; - - if (base < 0 || base == 1 || base > 36) return 0; - if (end) *end = (WCHAR *)s; - while (*s == ' ' || *s == '\t') s++; - - if (*s == '-') - { - negative = TRUE; - s++; - } - else if (*s == '+') s++; - - if ((base == 0 || base == 16) && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) - { - base = 16; - s += 2; - } - if (base == 0) base = s[0] != '0' ? 10 : 8; - - while (*s) - { - int v; - - if ('0' <= *s && *s <= '9') v = *s - '0'; - else if ('A' <= *s && *s <= 'Z') v = *s - 'A' + 10; - else if ('a' <= *s && *s <= 'z') v = *s - 'a' + 10; - else break; - if (v >= base) break; - if (negative) v = -v; - s++; - empty = FALSE; - - if (!negative && (ret > MAXLONG / base || ret * base > MAXLONG - v)) - ret = MAXLONG; - else if (negative && (ret < (LONG)MINLONG / base || ret * base < (LONG)(MINLONG - v))) - ret = MINLONG; - else - ret = ret * base + v; - } - - if (end && !empty) *end = (WCHAR *)s; - return ret; -} - -static inline ULONG win32u_wcstoul( const WCHAR *s, WCHAR **end, int base ) -{ - BOOL negative = FALSE, empty = TRUE; - ULONG ret = 0; - - if (base < 0 || base == 1 || base > 36) return 0; - if (end) *end = (WCHAR *)s; - while (*s == ' ' || *s == '\t') s++; - - if (*s == '-') - { - negative = TRUE; - s++; - } - else if (*s == '+') s++; - - if ((base == 0 || base == 16) && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) - { - base = 16; - s += 2; - } - if (base == 0) base = s[0] != '0' ? 10 : 8; - - while (*s) - { - int v; - - if ('0' <= *s && *s <= '9') v = *s - '0'; - else if ('A' <= *s && *s <= 'Z') v = *s - 'A' + 10; - else if ('a' <= *s && *s <= 'z') v = *s - 'a' + 10; - else break; - if (v >= base) break; - s++; - empty = FALSE; - - if (ret > MAXDWORD / base || ret * base > MAXDWORD - v) - ret = MAXDWORD; - else - ret = ret * base + v; - } - - if (end && !empty) *end = (WCHAR *)s; - return negative ? -ret : ret; -} - extern CPTABLEINFO ansi_cp DECLSPEC_HIDDEN;
DWORD win32u_mbtowc( CPTABLEINFO *info, WCHAR *dst, DWORD dstlen, const char *src, @@ -643,8 +550,6 @@ static inline WCHAR *towstr( const char *str )
#define towupper(c) win32u_towupper(c) #define wcsdup(s) win32u_wcsdup(s) -#define wcstol(s,e,b) win32u_wcstol(s,e,b) -#define wcstoul(s,e,b) win32u_wcstoul(s,e,b)
static inline void ascii_to_unicode( WCHAR *dst, const char *src, size_t len ) { diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 307932b0bf0..003604cd97d 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -928,54 +928,4 @@ static inline UINT asciiz_to_unicode( WCHAR *dst, const char *src ) return (p - dst) * sizeof(WCHAR); }
-static inline LONG x11drv_wcstol( LPCWSTR s, LPWSTR *end, INT base ) -{ - BOOL negative = FALSE, empty = TRUE; - LONG ret = 0; - - if (base < 0 || base == 1 || base > 36) return 0; - if (end) *end = (WCHAR *)s; - while (*s == ' ' || *s == '\t') s++; - - if (*s == '-') - { - negative = TRUE; - s++; - } - else if (*s == '+') s++; - - if ((base == 0 || base == 16) && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) - { - base = 16; - s += 2; - } - if (base == 0) base = s[0] != '0' ? 10 : 8; - - while (*s) - { - int v; - - if ('0' <= *s && *s <= '9') v = *s - '0'; - else if ('A' <= *s && *s <= 'Z') v = *s - 'A' + 10; - else if ('a' <= *s && *s <= 'z') v = *s - 'a' + 10; - else break; - if (v >= base) break; - if (negative) v = -v; - s++; - empty = FALSE; - - if (!negative && (ret > MAXLONG / base || ret * base > MAXLONG - v)) - ret = MAXLONG; - else if (negative && (ret < (LONG)MINLONG / base || ret * base < (LONG)(MINLONG - v))) - ret = MINLONG; - else - ret = ret * base + v; - } - - if (end && !empty) *end = (WCHAR *)s; - return ret; -} - -#define wcstol x11drv_wcstol - #endif /* __WINE_X11DRV_H */ diff --git a/include/wine/unixlib.h b/include/wine/unixlib.h index a7cfb8f6cab..ef60b32184c 100644 --- a/include/wine/unixlib.h +++ b/include/wine/unixlib.h @@ -84,6 +84,11 @@ NTSTATUS WINAPI KeUserModeCallback( ULONG id, const void *args, ULONG len, void
/* wide char string functions */
+static inline int ntdll_iswspace( WCHAR wc ) +{ + return ('\t' <= wc && wc <= '\r') || wc == ' ' || wc == 0xa0; +} + static inline size_t ntdll_wcslen( const WCHAR *str ) { const WCHAR *s = str; @@ -150,6 +155,100 @@ static inline SIZE_T ntdll_wcscspn( const WCHAR *str, const WCHAR *reject ) return ptr - str; }
+static inline LONG ntdll_wcstol( const WCHAR *s, WCHAR **end, int base ) +{ + BOOL negative = FALSE, empty = TRUE; + LONG ret = 0; + + if (base < 0 || base == 1 || base > 36) return 0; + if (end) *end = (WCHAR *)s; + while (ntdll_iswspace(*s)) s++; + + if (*s == '-') + { + negative = TRUE; + s++; + } + else if (*s == '+') s++; + + if ((base == 0 || base == 16) && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) + { + base = 16; + s += 2; + } + if (base == 0) base = s[0] != '0' ? 10 : 8; + + while (*s) + { + int v; + + if ('0' <= *s && *s <= '9') v = *s - '0'; + else if ('A' <= *s && *s <= 'Z') v = *s - 'A' + 10; + else if ('a' <= *s && *s <= 'z') v = *s - 'a' + 10; + else break; + if (v >= base) break; + if (negative) v = -v; + s++; + empty = FALSE; + + if (!negative && (ret > MAXLONG / base || ret * base > MAXLONG - v)) + ret = MAXLONG; + else if (negative && (ret < (LONG)MINLONG / base || ret * base < (LONG)(MINLONG - v))) + ret = MINLONG; + else + ret = ret * base + v; + } + + if (end && !empty) *end = (WCHAR *)s; + return ret; +} + +static inline ULONG ntdll_wcstoul( const WCHAR *s, WCHAR **end, int base ) +{ + BOOL negative = FALSE, empty = TRUE; + ULONG ret = 0; + + if (base < 0 || base == 1 || base > 36) return 0; + if (end) *end = (WCHAR *)s; + while (ntdll_iswspace(*s)) s++; + + if (*s == '-') + { + negative = TRUE; + s++; + } + else if (*s == '+') s++; + + if ((base == 0 || base == 16) && s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) + { + base = 16; + s += 2; + } + if (base == 0) base = s[0] != '0' ? 10 : 8; + + while (*s) + { + int v; + + if ('0' <= *s && *s <= '9') v = *s - '0'; + else if ('A' <= *s && *s <= 'Z') v = *s - 'A' + 10; + else if ('a' <= *s && *s <= 'z') v = *s - 'a' + 10; + else break; + if (v >= base) break; + s++; + empty = FALSE; + + if (ret > MAXDWORD / base || ret * base > MAXDWORD - v) + ret = MAXDWORD; + else + ret = ret * base + v; + } + + if (end && !empty) *end = (WCHAR *)s; + return negative ? -ret : ret; +} + +#define iswspace(ch) ntdll_iswspace(ch) #define wcslen(str) ntdll_wcslen(str) #define wcscpy(dst,src) ntdll_wcscpy(dst,src) #define wcscat(dst,src) ntdll_wcscat(dst,src) @@ -162,6 +261,8 @@ static inline SIZE_T ntdll_wcscspn( const WCHAR *str, const WCHAR *reject ) #define wcscspn(str,rej) ntdll_wcscspn(str,rej) #define wcsicmp(s1, s2) ntdll_wcsicmp(s1,s2) #define wcsnicmp(s1, s2,n) ntdll_wcsnicmp(s1,s2,n) +#define wcstol(str,e,b) ntdll_wcstol(str,e,b) +#define wcstoul(str,e,b) ntdll_wcstoul(str,e,b)
#endif /* WINE_UNIX_LIB */