diff options
Diffstat (limited to 'src/pal/src/cruntime/wchar.cpp')
-rw-r--r-- | src/pal/src/cruntime/wchar.cpp | 508 |
1 files changed, 4 insertions, 504 deletions
diff --git a/src/pal/src/cruntime/wchar.cpp b/src/pal/src/cruntime/wchar.cpp index c93a3d5edf..29f1922577 100644 --- a/src/pal/src/cruntime/wchar.cpp +++ b/src/pal/src/cruntime/wchar.cpp @@ -22,7 +22,6 @@ Abstract: #include "pal/palinternal.h" #include "pal/cruntime.h" #include "pal/dbgmsg.h" -#include "pal/unicode_data.h" #include "pal/thread.hpp" #include "pal/threadsusp.hpp" @@ -48,34 +47,6 @@ SET_DEFAULT_DEBUG_CHANNEL(CRT); /*-- Function: - wtolower (internal) - -16-bit wide character version of the ANSI tolower() function. - - --*/ -static -wchar_16 -wtolower(wchar_16 c) -{ - /* Note: Surrogate pairs unicode character are not supported */ - -#if HAVE_TOWLOWER - - wchar_t w; - w = (wchar_t) c; - w = towlower(w); - return (wchar_16) w; - -#else - - return PAL_towlower(c); - -#endif - -} - -/*-- -Function: _wtoi See MSDN doc @@ -123,28 +94,6 @@ _wtoi( } -/*-- -Function: - PAL_iswspace - -See MSDN doc ---*/ -int -__cdecl -PAL_iswspace(wchar_16 c) -{ - int ret; - - PERF_ENTRY(iswspace); - ENTRY("PAL_iswspace (c=%C)\n", c); - - ret = iswspace(c); - - LOGEXIT("PAL_iswspace returns int %d\n", ret); - PERF_EXIT(iswspace); - return ret; -} - /*++ Function: _wcsnicmp @@ -198,7 +147,7 @@ _wcsnicmp( for (i = 0; i < count; i++) { - diff = wtolower(string1[i]) - wtolower(string2[i]); + diff = towlower(string1[i]) - towlower(string2[i]); if (diff != 0 || 0 == string1[i] || 0 == string2[i]) { break; @@ -285,7 +234,7 @@ _wcslwr( for (i=0 ; string[i] != 0; i++) { - string[i] = wtolower(string[i]); + string[i] = towlower(string[i]); } LOGEXIT("_wcslwr returning wchar_t %p (%S)\n", string?string:W16_NULLSTRING, string?string:W16_NULLSTRING); @@ -515,7 +464,7 @@ PAL_wcstoul( if (res > _UI32_MAX) { wchar_16 wc = *nptr; - while (PAL_iswspace(wc)) + while (iswspace(wc)) { wc = *nptr++; } @@ -620,242 +569,6 @@ PAL__wcstoui64Exit: /*++ Function: - PAL_towlower - -See MSDN - ---*/ -wchar_16 -__cdecl -PAL_towlower( wchar_16 c ) -{ -#if HAVE_COREFOUNDATION - PERF_ENTRY(towlower); - ENTRY("towlower (c=%d)\n", c); - if (!PAL_iswlower(c)) - { - CFMutableStringRef cfString = CFStringCreateMutable( - kCFAllocatorDefault, 1); - if (cfString != NULL) - { - CFStringAppendCharacters(cfString, (const UniChar*)&c, 1); - CFStringLowercase(cfString, NULL); - c = CFStringGetCharacterAtIndex(cfString, 0); - CFRelease(cfString); - } - } - LOGEXIT("towlower returns int %d\n", c ); - PERF_EXIT(towlower); - return c; -#else /* HAVE_COREFOUNDATION */ - UnicodeDataRec dataRec; - - PERF_ENTRY(towlower); - ENTRY("towlower (c=%d)\n", c); - - if (!GetUnicodeData(c, &dataRec)) - { - TRACE( "Unable to retrieve unicode data for the character %c.\n", c ); - LOGEXIT("towlower returns int %d\n", c ); - PERF_EXIT(towlower); - return c; - } - - if ( (dataRec.C1_TYPE_FLAGS & C1_LOWER) || (dataRec.nOpposingCase == 0 )) - { - LOGEXIT("towlower returns int %d\n", c ); - PERF_EXIT(towlower); - return c; - } - else - { - LOGEXIT("towlower returns int %d\n", dataRec.nOpposingCase ); - PERF_EXIT(towlower); - return dataRec.nOpposingCase; - } -#endif /* HAVE_COREFOUNDATION */ -} - - -/*++ -Function: - PAL_towupper - -See MSDN - ---*/ -wchar_16 -__cdecl -PAL_towupper( wchar_16 c ) -{ -#if HAVE_COREFOUNDATION - PERF_ENTRY(towupper); - ENTRY("towupper (c=%d)\n", c); - if (!PAL_iswupper(c)) - { - CFMutableStringRef cfString = CFStringCreateMutable( - kCFAllocatorDefault, 1); - if (cfString != NULL) - { - CFStringAppendCharacters(cfString, (const UniChar*)&c, 1); - CFStringUppercase(cfString, NULL); - c = CFStringGetCharacterAtIndex(cfString, 0); - CFRelease(cfString); - } - } - LOGEXIT("towupper returns int %d\n", c ); - PERF_EXIT(towupper); - return c; -#else /* HAVE_COREFOUNDATION */ - UnicodeDataRec dataRec; - - PERF_ENTRY(towupper); - ENTRY("towupper (c=%d)\n", c); - - if (!GetUnicodeData(c, &dataRec)) - { - TRACE( "Unable to retrieve unicode data for the character %c.\n", c ); - LOGEXIT("towupper returns int %d\n", c ); - PERF_EXIT(towupper); - return c; - } - - if ( (dataRec.C1_TYPE_FLAGS & C1_UPPER) || (dataRec.nOpposingCase == 0 )) - { - LOGEXIT("towupper returns int %d\n", c ); - PERF_EXIT(towupper); - return c; - } - else - { - LOGEXIT("towupper returns int %d\n", dataRec.nOpposingCase ); - PERF_EXIT(towupper); - return dataRec.nOpposingCase; - } -#endif /* HAVE_COREFOUNDATION */ -} - -/*++ -Function: - PAL_iswupper - -See MSDN - ---*/ -int -__cdecl -PAL_iswupper( wchar_16 c ) -{ - BOOL bRetVal = FALSE; -#if HAVE_COREFOUNDATION - static CFCharacterSetRef sUppercaseSet; - - if (sUppercaseSet == NULL) - { - sUppercaseSet = CFCharacterSetGetPredefined( - kCFCharacterSetUppercaseLetter); - } - PERF_ENTRY(iswupper); - ENTRY( "iswupper (c=%d)\n", c ); - bRetVal = CFCharacterSetIsCharacterMember(sUppercaseSet, c); -#else /* HAVE_COREFOUNDATION */ - UnicodeDataRec dataRec; - - PERF_ENTRY(iswupper); - ENTRY( "iswupper (c=%d)\n", c ); - - if (!GetUnicodeData(c, &dataRec)) - { - TRACE( "Unable to retrieve unicode data for the character %c.\n", c ); - goto exit; - } - - if (dataRec.C1_TYPE_FLAGS & C1_UPPER) - { - bRetVal = TRUE; - } -exit: -#endif /* HAVE_COREFOUNDATION */ - LOGEXIT( "iswupper returns %s.\n", bRetVal == TRUE ? "TRUE" : "FALSE" ); - PERF_EXIT(iswupper); - return bRetVal; -} - -/*++ -Function: - PAL_iswlower - -See MSDN - ---*/ -int -__cdecl -PAL_iswlower( wchar_16 c ) -{ - BOOL bRetVal = FALSE; -#if HAVE_COREFOUNDATION - static CFCharacterSetRef sLowercaseSet; - - if (sLowercaseSet == NULL) - { - sLowercaseSet = CFCharacterSetGetPredefined( - kCFCharacterSetLowercaseLetter); - } - PERF_ENTRY(iswlower); - ENTRY("PAL_iswlower (c=%d)\n", c); - bRetVal = CFCharacterSetIsCharacterMember(sLowercaseSet, c); -#else /* HAVE_COREFOUNDATION */ - UnicodeDataRec dataRec; - - PERF_ENTRY(iswlower); - ENTRY("PAL_iswlower (c=%d)\n", c); - - if (!GetUnicodeData(c, &dataRec)) - { - TRACE( "Unable to retrieve unicode data for the character %c.\n", c ); - goto exit; - } - - if (dataRec.C1_TYPE_FLAGS & C1_LOWER) - { - bRetVal = TRUE; - } -exit: -#endif /* HAVE_COREFOUNDATION */ - LOGEXIT("PAL_iswlower returns %s.\n", bRetVal == TRUE ? "TRUE" : "FALSE"); - PERF_EXIT(iswlower); - return bRetVal; -} - -/*++ -Function: - PAL_iswalpha - -See MSDN - ---*/ -int -__cdecl -PAL_iswalpha( wchar_16 c ) -{ - PERF_ENTRY(iswalpha); - ENTRY( "PAL_iswalpha (c=%d)\n", c); - - if ( PAL_iswupper( c ) || PAL_iswlower( c ) ) - { - LOGEXIT( "PAL_iswalpha returns 1.\n" ); - PERF_EXIT(iswalpha); - return 1; - } - - LOGEXIT( "PAL_iswalpha returns 0.\n" ); - PERF_EXIT(iswalpha); - return 0; -} - - -/*++ -Function: PAL_wcscat See MSDN or the man page for mcscat. @@ -1356,7 +1069,7 @@ PAL_wcstod( const wchar_16 * nptr, wchar_16 **endptr ) } /* Eat white space. */ - while ( PAL_iswspace( *lpStartOfExpression ) ) + while ( iswspace( *lpStartOfExpression ) ) { lpStartOfExpression++; } @@ -1426,128 +1139,6 @@ PAL_wcstod( const wchar_16 * nptr, wchar_16 **endptr ) /*++ Function: - - iswdigit - -See MSDN for more details. ---*/ -int -__cdecl -PAL_iswdigit( wchar_16 c ) -{ - UINT nRetVal = 0; -#if HAVE_COREFOUNDATION - static CFCharacterSetRef sDigitSet; - - if (sDigitSet == NULL) - { - sDigitSet = CFCharacterSetGetPredefined( - kCFCharacterSetDecimalDigit); - } - PERF_ENTRY(iswdigit); - ENTRY("PAL_iswdigit (c=%d)\n", c); - nRetVal = CFCharacterSetIsCharacterMember(sDigitSet, c); -#else /* HAVE_COREFOUNDATION */ - UnicodeDataRec dataRec; - - PERF_ENTRY(iswdigit); - ENTRY("PAL_iswdigit (c=%d)\n", c); - - if (GetUnicodeData(c, &dataRec)) - { - if (dataRec.C1_TYPE_FLAGS & C1_DIGIT) - { - nRetVal = 1; - } - else - { - nRetVal = 0; - } - } - else - { - TRACE( "No corresonding unicode record for character %d.\n", c ); - } -#endif /* HAVE_COREFOUNDATION */ - LOGEXIT("PAL_iswdigit returning %d\n", nRetVal); - PERF_EXIT(iswdigit); - return nRetVal; -} - -/*++ -Function: - - iswxdigit - -See MSDN for more details. - -Notes : -the information in UnicodeData doesn't help us, it doesn't have enough -granularity. Results in windows show that only ASCII and "Fullwidth" (>0xFF10) -numbers and letters are considered as "hex"; other "numbers" -(nGeneralCategory==8) aren't. ---*/ -int -__cdecl -PAL_iswxdigit( wchar_16 c ) -{ - UINT nRetVal = 0; - - PERF_ENTRY(iswxdigit); - ENTRY("PAL_iswxdigit( c=%d )\n", c); - - /* ASCII characters */ - if((c>= 'A' && c<='F') || /* uppercase hex letters */ - (c>= 'a' && c<='f') || /* lowercase hex letters */ - (c>= '0' && c<='9')) /* digits */ - { - nRetVal = 1; - } - else - /* "fullwidth" characters, whatever that is */ - if((c>= 0xFF10 && c<=0xFF19) || /* digits */ - (c>= 0xFF21 && c<=0xFF26) || /* uppercase hex letters */ - (c>= 0xFF41 && c<=0xFF46)) /* lowercase hex letters */ - { - nRetVal = 1; - } - else - { - nRetVal = 0; - } - LOGEXIT("PAL_iswxdigit returning %d\n", nRetVal); - PERF_EXIT(iswxdigit); - return nRetVal; -} - - -/*++ -Function: - - iswprint - -See MSDN for more details. ---*/ -int -__cdecl -PAL_iswprint( wchar_16 c ) -{ - int ret; - - - PERF_ENTRY(iswprint); - ENTRY("PAL_iswprint (%#X)\n", c); - - ret = iswprint(c); - - LOGEXIT("PAL_iswprint returns %d\n", ret); - PERF_EXIT(iswprint); - return (ret); -} - - -/*++ -Function: PAL_wcscspn Finds the number of consecutive characters from the start of the string @@ -1588,94 +1179,3 @@ PAL_wcscspn(const wchar_16 *string, const wchar_16 *strCharSet) PERF_EXIT(wcscspn); return count; } - -#if HAVE_COREFOUNDATION -/*-- -Function: - PAL_iswblank - -Returns TRUE if c is a Win32 "blank" character. ---*/ -int -__cdecl -PAL_iswblank(wchar_16 c) -{ - int ret; - static CFCharacterSetRef sSpaceAndNewlineSet; - - if (sSpaceAndNewlineSet == NULL) - { - sSpaceAndNewlineSet = CFCharacterSetGetPredefined( - kCFCharacterSetWhitespaceAndNewline); - } - switch (c) - { - case 0x0085: - case 0x1680: - case 0x202f: - case 0xfeff: - // These are blank characters on Windows, but are not part - // of the SpaceAndNewline character set in Core Foundation. - ret = TRUE; - break; - case 0x2028: - case 0x2029: - // These are not blank characters on Windows, but are part - // of the SpaceAndNewline character set in Core Foundation. - ret = FALSE; - break; - default: - ret = CFCharacterSetIsCharacterMember(sSpaceAndNewlineSet, c); - break; - } - return ret; -} - -/*-- -Function: - PAL_iswcntrl - -Returns TRUE if c is a control character. ---*/ -int -__cdecl -PAL_iswcntrl(wchar_16 c) -{ - int ret; - static CFCharacterSetRef sControlSet; - - if (sControlSet == NULL) - { - sControlSet = CFCharacterSetGetPredefined(kCFCharacterSetControl); - } - ret = CFCharacterSetIsCharacterMember(sControlSet, c); - return ret; -} - -/*-- -Function: - PAL_iswpunct - -Returns TRUE if c is a punctuation character. ---*/ -int -__cdecl -PAL_iswpunct(wchar_16 c) -{ - int ret; - static CFCharacterSetRef sPunctuationSet = NULL; - static CFCharacterSetRef sSymbolSet = NULL; - - if (sPunctuationSet == NULL) - { - sPunctuationSet = CFCharacterSetGetPredefined(kCFCharacterSetPunctuation); - } - if (sSymbolSet == NULL) - { - sSymbolSet = CFCharacterSetGetPredefined(kCFCharacterSetSymbol); - } - ret = CFCharacterSetIsCharacterMember(sPunctuationSet, c) || - CFCharacterSetIsCharacterMember(sSymbolSet, c); - return ret; -} -#endif // HAVE_COREFOUNDATION |