Created
February 7, 2015 03:04
-
-
Save kangaroo/95ba61cf32338a4d5368 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/pal/src/locale/locale.cpp b/src/pal/src/locale/locale.cpp | |
index eb7c73d..9fe1791 100644 | |
--- a/src/pal/src/locale/locale.cpp | |
+++ b/src/pal/src/locale/locale.cpp | |
@@ -156,6 +156,16 @@ static const struct CalIdPair requiredCalendars[] = | |
static CFComparisonResult (*s_CFStringCompareWithOptionsAndLocale)(CFStringRef, CFStringRef, CFRange, CFOptionFlags, CFLocaleRef) = NULL; | |
+static UniChar * ToUniChar(WCHAR *buffer) | |
+{ | |
+ return (UniChar *) buffer; | |
+} | |
+ | |
+static UniChar * ToUniChar(LPCWSTR buffer) | |
+{ | |
+ return (UniChar *) buffer; | |
+} | |
+ | |
/* | |
* TODO: Callers of this function really should be using weak linking to get values that are 10.5 only | |
* to do so we need to start building with XCode 3.0 so we have the 10.5 headers. Once that happens | |
@@ -359,7 +369,7 @@ static CFStringRef CFStringCreateMacFormattedLocaleName(LPCWSTR lpLocaleName) | |
return NULL; | |
} | |
- CFStringAppendCharacters(cfMutableLocaleName, (const UniChar*)lpLocaleName, PAL_wcslen(lpLocaleName)); | |
+ CFStringAppendCharacters(cfMutableLocaleName, ToUniChar(lpLocaleName), PAL_wcslen(lpLocaleName)); | |
CFStringFindAndReplace(cfMutableLocaleName, | |
CFSTR("-"), | |
@@ -1614,7 +1624,7 @@ GetDateFormatHelper( | |
* expected by Core Foundation. However, currently no one calls this | |
* with a format where this would actually matter. | |
*/ | |
- cfStringFormat = CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)lpFormat, PAL_wcslen(lpFormat)); | |
+ cfStringFormat = CFStringCreateWithCharacters(kCFAllocatorDefault, ToUniChar(lpFormat), PAL_wcslen(lpFormat)); | |
if (cfStringFormat == NULL) | |
{ | |
SetLastError(ERROR_NOT_ENOUGH_MEMORY); | |
@@ -1945,13 +1955,13 @@ CompareStringHelper( | |
cchCount2 = PAL_wcslen( lpString2 ); | |
} | |
- cfString1 = CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)lpString1, cchCount1); | |
+ cfString1 = CFStringCreateWithCharacters(kCFAllocatorDefault, ToUniChar(lpString1), cchCount1); | |
if (cfString1 == NULL) | |
{ | |
SetLastError(ERROR_NOT_ENOUGH_MEMORY); | |
goto EXIT; | |
} | |
- cfString2 = CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)lpString2, cchCount2); | |
+ cfString2 = CFStringCreateWithCharacters(kCFAllocatorDefault, ToUniChar(lpString2), cchCount2); | |
if (cfString2 == NULL) | |
{ | |
SetLastError(ERROR_NOT_ENOUGH_MEMORY); | |
@@ -4916,7 +4926,7 @@ LCMapStringHelper( | |
SetLastError(ERROR_NOT_ENOUGH_MEMORY); | |
goto EXIT; | |
} | |
- CFStringAppendCharacters(cfMutableString, (const UniChar*)lpSrcStr, cchSrc); | |
+ CFStringAppendCharacters(cfMutableString, ToUniChar(lpSrcStr), cchSrc); | |
switch (dwMapFlags) | |
{ | |
@@ -5085,7 +5095,7 @@ PAL_NormalizeStringExW( | |
SetLastError(ERROR_NOT_ENOUGH_MEMORY); | |
goto EXIT; | |
} | |
- CFStringAppendCharacters(cfMutableString, (const UniChar*)lpSrcStr, cchSrc); | |
+ CFStringAppendCharacters(cfMutableString, ToUniChar(lpSrcStr), cchSrc); | |
// TODO: Additionally, we should normalize according to the locale. | |
// Unfortunately, Core Foundation has no such function in Mac OS X 10.4. | |
@@ -5180,14 +5190,14 @@ PAL_ParseDateW( | |
goto EXIT; | |
} | |
- cfFormat = CFStringCreateWithCharacters(kCFAllocatorDefault, (const UniChar*)lpFormat, PAL_wcslen(lpFormat)); | |
+ cfFormat = CFStringCreateWithCharacters(kCFAllocatorDefault, ToUniChar(lpFormat), PAL_wcslen(lpFormat)); | |
if (cfFormat == NULL) | |
{ | |
SetLastError(ERROR_NOT_ENOUGH_MEMORY); | |
goto EXIT; | |
: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment