From a92db320de2a030b055ef88a589ce5368a34e67d Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 24 May 2006 14:00:47 +0200 Subject: [PATCH] libwine_unicode: Define all functions in the library even if they can be inlined. --- include/wine/unicode.h | 62 ++++++------ libs/unicode/string.c | 185 ++++++++++++++++++++++++++++++++++ libs/unicode/wine_unicode.def | 31 ++++++ libs/unicode/wine_unicode.map | 31 ++++++ 4 files changed, 278 insertions(+), 31 deletions(-) diff --git a/include/wine/unicode.h b/include/wine/unicode.h index 8577f461f8f..88e93b2a822 100644 --- a/include/wine/unicode.h +++ b/include/wine/unicode.h @@ -95,18 +95,18 @@ extern int snprintfW( WCHAR *str, size_t len, const WCHAR *format, ... ); extern int vsprintfW( WCHAR *str, const WCHAR *format, va_list valist ); extern int vsnprintfW( WCHAR *str, size_t len, const WCHAR *format, va_list valist ); -static inline int is_dbcs_leadbyte( const union cptable *table, unsigned char ch ) +extern inline int is_dbcs_leadbyte( const union cptable *table, unsigned char ch ) { return (table->info.char_size == 2) && (table->dbcs.cp2uni_leadbytes[ch]); } -static inline WCHAR tolowerW( WCHAR ch ) +extern inline WCHAR tolowerW( WCHAR ch ) { extern WINE_UNICODE_API const WCHAR wine_casemap_lower[]; return ch + wine_casemap_lower[wine_casemap_lower[ch >> 8] + (ch & 0xff)]; } -static inline WCHAR toupperW( WCHAR ch ) +extern inline WCHAR toupperW( WCHAR ch ) { extern WINE_UNICODE_API const WCHAR wine_casemap_upper[]; return ch + wine_casemap_upper[wine_casemap_upper[ch >> 8] + (ch & 0xff)]; @@ -114,77 +114,77 @@ static inline WCHAR toupperW( WCHAR ch ) /* the character type contains the C1_* flags in the low 12 bits */ /* and the C2_* type in the high 4 bits */ -static inline unsigned short get_char_typeW( WCHAR ch ) +extern inline unsigned short get_char_typeW( WCHAR ch ) { extern WINE_UNICODE_API const unsigned short wine_wctype_table[]; return wine_wctype_table[wine_wctype_table[ch >> 8] + (ch & 0xff)]; } -inline static int iscntrlW( WCHAR wc ) +extern inline int iscntrlW( WCHAR wc ) { return get_char_typeW(wc) & C1_CNTRL; } -inline static int ispunctW( WCHAR wc ) +extern inline int ispunctW( WCHAR wc ) { return get_char_typeW(wc) & C1_PUNCT; } -inline static int isspaceW( WCHAR wc ) +extern inline int isspaceW( WCHAR wc ) { return get_char_typeW(wc) & C1_SPACE; } -inline static int isdigitW( WCHAR wc ) +extern inline int isdigitW( WCHAR wc ) { return get_char_typeW(wc) & C1_DIGIT; } -inline static int isxdigitW( WCHAR wc ) +extern inline int isxdigitW( WCHAR wc ) { return get_char_typeW(wc) & C1_XDIGIT; } -inline static int islowerW( WCHAR wc ) +extern inline int islowerW( WCHAR wc ) { return get_char_typeW(wc) & C1_LOWER; } -inline static int isupperW( WCHAR wc ) +extern inline int isupperW( WCHAR wc ) { return get_char_typeW(wc) & C1_UPPER; } -inline static int isalnumW( WCHAR wc ) +extern inline int isalnumW( WCHAR wc ) { return get_char_typeW(wc) & (C1_ALPHA|C1_DIGIT|C1_LOWER|C1_UPPER); } -inline static int isalphaW( WCHAR wc ) +extern inline int isalphaW( WCHAR wc ) { return get_char_typeW(wc) & (C1_ALPHA|C1_LOWER|C1_UPPER); } -inline static int isgraphW( WCHAR wc ) +extern inline int isgraphW( WCHAR wc ) { return get_char_typeW(wc) & (C1_ALPHA|C1_PUNCT|C1_DIGIT|C1_LOWER|C1_UPPER); } -inline static int isprintW( WCHAR wc ) +extern inline int isprintW( WCHAR wc ) { return get_char_typeW(wc) & (C1_ALPHA|C1_BLANK|C1_PUNCT|C1_DIGIT|C1_LOWER|C1_UPPER); } /* some useful string manipulation routines */ -static inline unsigned int strlenW( const WCHAR *str ) +extern inline unsigned int strlenW( const WCHAR *str ) { const WCHAR *s = str; while (*s) s++; return s - str; } -static inline WCHAR *strcpyW( WCHAR *dst, const WCHAR *src ) +extern inline WCHAR *strcpyW( WCHAR *dst, const WCHAR *src ) { WCHAR *p = dst; while ((*p++ = *src++)); @@ -194,92 +194,92 @@ static inline WCHAR *strcpyW( WCHAR *dst, const WCHAR *src ) /* strncpy doesn't do what you think, don't use it */ #define strncpyW(d,s,n) error do_not_use_strncpyW_use_lstrcpynW_or_memcpy_instead -static inline int strcmpW( const WCHAR *str1, const WCHAR *str2 ) +extern inline int strcmpW( const WCHAR *str1, const WCHAR *str2 ) { while (*str1 && (*str1 == *str2)) { str1++; str2++; } return *str1 - *str2; } -static inline int strncmpW( const WCHAR *str1, const WCHAR *str2, int n ) +extern inline int strncmpW( const WCHAR *str1, const WCHAR *str2, int n ) { if (n <= 0) return 0; while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; } return *str1 - *str2; } -static inline WCHAR *strcatW( WCHAR *dst, const WCHAR *src ) +extern inline WCHAR *strcatW( WCHAR *dst, const WCHAR *src ) { strcpyW( dst + strlenW(dst), src ); return dst; } -static inline WCHAR *strchrW( const WCHAR *str, WCHAR ch ) +extern inline WCHAR *strchrW( const WCHAR *str, WCHAR ch ) { do { if (*str == ch) return (WCHAR *)str; } while (*str++); return NULL; } -static inline WCHAR *strrchrW( const WCHAR *str, WCHAR ch ) +extern inline WCHAR *strrchrW( const WCHAR *str, WCHAR ch ) { WCHAR *ret = NULL; do { if (*str == ch) ret = (WCHAR *)str; } while (*str++); return ret; } -static inline WCHAR *strpbrkW( const WCHAR *str, const WCHAR *accept ) +extern inline WCHAR *strpbrkW( const WCHAR *str, const WCHAR *accept ) { for ( ; *str; str++) if (strchrW( accept, *str )) return (WCHAR *)str; return NULL; } -static inline size_t strspnW( const WCHAR *str, const WCHAR *accept ) +extern inline size_t strspnW( const WCHAR *str, const WCHAR *accept ) { const WCHAR *ptr; for (ptr = str; *ptr; ptr++) if (!strchrW( accept, *ptr )) break; return ptr - str; } -static inline size_t strcspnW( const WCHAR *str, const WCHAR *reject ) +extern inline size_t strcspnW( const WCHAR *str, const WCHAR *reject ) { const WCHAR *ptr; for (ptr = str; *ptr; ptr++) if (strchrW( reject, *ptr )) break; return ptr - str; } -static inline WCHAR *strlwrW( WCHAR *str ) +extern inline WCHAR *strlwrW( WCHAR *str ) { WCHAR *ret = str; while ((*str = tolowerW(*str))) str++; return ret; } -static inline WCHAR *struprW( WCHAR *str ) +extern inline WCHAR *struprW( WCHAR *str ) { WCHAR *ret = str; while ((*str = toupperW(*str))) str++; return ret; } -static inline WCHAR *memchrW( const WCHAR *ptr, WCHAR ch, size_t n ) +extern 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 ) +extern 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; } -static inline long int atolW( const WCHAR *str ) +extern inline long int atolW( const WCHAR *str ) { return strtolW( str, (WCHAR **)0, 10 ); } -static inline int atoiW( const WCHAR *str ) +extern inline int atoiW( const WCHAR *str ) { return (int)atolW( str ); } diff --git a/libs/unicode/string.c b/libs/unicode/string.c index 3aa71e5ad94..7d88586cfd5 100644 --- a/libs/unicode/string.c +++ b/libs/unicode/string.c @@ -23,6 +23,191 @@ #include "wine/unicode.h" +extern const WCHAR wine_casemap_lower[]; +extern const WCHAR wine_casemap_upper[]; +extern const unsigned short wine_wctype_table[]; + +int is_dbcs_leadbyte( const union cptable *table, unsigned char ch ) +{ + return (table->info.char_size == 2) && (table->dbcs.cp2uni_leadbytes[ch]); +} + +WCHAR tolowerW( WCHAR ch ) +{ + return ch + wine_casemap_lower[wine_casemap_lower[ch >> 8] + (ch & 0xff)]; +} + +WCHAR toupperW( WCHAR ch ) +{ + return ch + wine_casemap_upper[wine_casemap_upper[ch >> 8] + (ch & 0xff)]; +} + +/* the character type contains the C1_* flags in the low 12 bits */ +/* and the C2_* type in the high 4 bits */ +unsigned short get_char_typeW( WCHAR ch ) +{ + return wine_wctype_table[wine_wctype_table[ch >> 8] + (ch & 0xff)]; +} + +int iscntrlW( WCHAR wc ) +{ + return get_char_typeW(wc) & C1_CNTRL; +} + +int ispunctW( WCHAR wc ) +{ + return get_char_typeW(wc) & C1_PUNCT; +} + +int isspaceW( WCHAR wc ) +{ + return get_char_typeW(wc) & C1_SPACE; +} + +int isdigitW( WCHAR wc ) +{ + return get_char_typeW(wc) & C1_DIGIT; +} + +int isxdigitW( WCHAR wc ) +{ + return get_char_typeW(wc) & C1_XDIGIT; +} + +int islowerW( WCHAR wc ) +{ + return get_char_typeW(wc) & C1_LOWER; +} + +int isupperW( WCHAR wc ) +{ + return get_char_typeW(wc) & C1_UPPER; +} + +int isalnumW( WCHAR wc ) +{ + return get_char_typeW(wc) & (C1_ALPHA|C1_DIGIT|C1_LOWER|C1_UPPER); +} + +int isalphaW( WCHAR wc ) +{ + return get_char_typeW(wc) & (C1_ALPHA|C1_LOWER|C1_UPPER); +} + +int isgraphW( WCHAR wc ) +{ + return get_char_typeW(wc) & (C1_ALPHA|C1_PUNCT|C1_DIGIT|C1_LOWER|C1_UPPER); +} + +int isprintW( WCHAR wc ) +{ + return get_char_typeW(wc) & (C1_ALPHA|C1_BLANK|C1_PUNCT|C1_DIGIT|C1_LOWER|C1_UPPER); +} + +unsigned int strlenW( const WCHAR *str ) +{ + const WCHAR *s = str; + while (*s) s++; + return s - str; +} + +WCHAR *strcpyW( WCHAR *dst, const WCHAR *src ) +{ + WCHAR *p = dst; + while ((*p++ = *src++)); + return dst; +} + +int strcmpW( const WCHAR *str1, const WCHAR *str2 ) +{ + while (*str1 && (*str1 == *str2)) { str1++; str2++; } + return *str1 - *str2; +} + +int strncmpW( const WCHAR *str1, const WCHAR *str2, int n ) +{ + if (n <= 0) return 0; + while ((--n > 0) && *str1 && (*str1 == *str2)) { str1++; str2++; } + return *str1 - *str2; +} + +WCHAR *strcatW( WCHAR *dst, const WCHAR *src ) +{ + strcpyW( dst + strlenW(dst), src ); + return dst; +} + +WCHAR *strchrW( const WCHAR *str, WCHAR ch ) +{ + do { if (*str == ch) return (WCHAR *)str; } while (*str++); + return NULL; +} + +WCHAR *strrchrW( const WCHAR *str, WCHAR ch ) +{ + WCHAR *ret = NULL; + do { if (*str == ch) ret = (WCHAR *)str; } while (*str++); + return ret; +} + +WCHAR *strpbrkW( const WCHAR *str, const WCHAR *accept ) +{ + for ( ; *str; str++) if (strchrW( accept, *str )) return (WCHAR *)str; + return NULL; +} + +size_t strspnW( const WCHAR *str, const WCHAR *accept ) +{ + const WCHAR *ptr; + for (ptr = str; *ptr; ptr++) if (!strchrW( accept, *ptr )) break; + return ptr - str; +} + +size_t strcspnW( const WCHAR *str, const WCHAR *reject ) +{ + const WCHAR *ptr; + for (ptr = str; *ptr; ptr++) if (strchrW( reject, *ptr )) break; + return ptr - str; +} + +WCHAR *strlwrW( WCHAR *str ) +{ + WCHAR *ret = str; + while ((*str = tolowerW(*str))) str++; + return ret; +} + +WCHAR *struprW( WCHAR *str ) +{ + WCHAR *ret = str; + while ((*str = toupperW(*str))) str++; + return ret; +} + +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; +} + +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; +} + +long int atolW( const WCHAR *str ) +{ + return strtolW( str, (WCHAR **)0, 10 ); +} + +int atoiW( const WCHAR *str ) +{ + return (int)atolW( str ); +} + int strcmpiW( const WCHAR *str1, const WCHAR *str2 ) { for (;;) diff --git a/libs/unicode/wine_unicode.def b/libs/unicode/wine_unicode.def index de74ec139eb..d892629b2ad 100644 --- a/libs/unicode/wine_unicode.def +++ b/libs/unicode/wine_unicode.def @@ -1,14 +1,45 @@ LIBRARY libwine_unicode.dll EXPORTS + atoiW + atolW + get_char_typeW + is_dbcs_leadbyte + isalnumW + isalphaW + iscntrlW + isdigitW + isgraphW + islowerW + isprintW + ispunctW + isspaceW + isupperW + isxdigitW + memchrW memicmpW + memrchrW snprintfW sprintfW + strcatW + strchrW + strcmpW strcmpiW + strcpyW + strcspnW + strlenW + strlwrW + strncmpW strncmpiW + strpbrkW + strrchrW + strspnW strstrW strtolW strtoulW + struprW + tolowerW + toupperW vsnprintfW vsprintfW wine_casemap_lower diff --git a/libs/unicode/wine_unicode.map b/libs/unicode/wine_unicode.map index 7a366b8e8c1..30e308605aa 100644 --- a/libs/unicode/wine_unicode.map +++ b/libs/unicode/wine_unicode.map @@ -1,14 +1,45 @@ WINE_1.0 { global: + atoiW; + atolW; + get_char_typeW; + is_dbcs_leadbyte; + isalnumW; + isalphaW; + iscntrlW; + isdigitW; + isgraphW; + islowerW; + isprintW; + ispunctW; + isspaceW; + isupperW; + isxdigitW; + memchrW; memicmpW; + memrchrW; snprintfW; sprintfW; + strcatW; + strchrW; + strcmpW; strcmpiW; + strcpyW; + strcspnW; + strlenW; + strlwrW; + strncmpW; strncmpiW; + strpbrkW; + strrchrW; + strspnW; strstrW; strtolW; strtoulW; + struprW; + tolowerW; + toupperW; vsnprintfW; vsprintfW; wine_casemap_lower;