Skip to content

Fix a few small bugs in CFLocale #946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions CoreFoundation/Locale.subproj/CFLocale.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ static Boolean __CFLocaleEqual(CFTypeRef cf1, CFTypeRef cf2) {
if (__CFLocaleGetType(locale1) != __CFLocaleGetType(locale2)) return false;
if (!CFEqual(locale1->_identifier, locale2->_identifier)) return false;
if (__kCFLocaleUser == __CFLocaleGetType(locale1)) {
return CFEqual(locale1->_prefs, locale2->_prefs);
if (locale1->_prefs && locale2->_prefs) {
return CFEqual(locale1->_prefs, locale2->_prefs);
} else {
return locale1->_prefs == locale2->_prefs;
}
}
return true;
}
Expand Down Expand Up @@ -447,6 +451,7 @@ CFLocaleRef CFLocaleCreate(CFAllocatorRef allocator, CFStringRef identifier) {
uint32_t size = sizeof(struct __CFLocale) - sizeof(CFRuntimeBase);
locale = (struct __CFLocale *)_CFRuntimeCreateInstance(allocator, CFLocaleGetTypeID(), size, NULL);
if (NULL == locale) {
__CFUnlock(&__CFLocaleCacheLock);
if (localeIdentifier) { CFRelease(localeIdentifier); }
return NULL;
}
Expand Down Expand Up @@ -1171,7 +1176,7 @@ static void __CFLocaleGetMeasurementSystemGuts(CFLocaleRef locale, bool user, UM
UMeasurementSystem output = UMS_SI; // Default is Metric
bool done = false;
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
if (user) {
if (user && locale->_prefs) {
CFTypeRef metricPref = CFDictionaryGetValue(locale->_prefs, CFSTR("AppleMetricUnits"));
CFTypeRef measurementPref = CFDictionaryGetValue(locale->_prefs, CFSTR("AppleMeasurementUnits"));
if (metricPref || measurementPref) {
Expand Down Expand Up @@ -1252,7 +1257,7 @@ static bool __CFLocaleCopyTemperatureUnit(CFLocaleRef locale, bool user, CFTypeR
bool celsius = true; // Default is Celsius
bool done = false;
#if DEPLOYMENT_TARGET_MACOSX || DEPLOYMENT_TARGET_EMBEDDED
if (user) {
if (user && locale->_prefs) {
CFTypeRef temperatureUnitPref = CFDictionaryGetValue(locale->_prefs, CFSTR("AppleTemperatureUnit"));
if (temperatureUnitPref) {
if (CFEqual(temperatureUnitPref, kCFLocaleTemperatureUnitFahrenheit)) {
Expand Down Expand Up @@ -1426,7 +1431,7 @@ static bool __CFLocaleFullName(const char *locale, const char *value, CFStringRe
int32_t localSize;
UChar localName[kMaxICUNameSize];
localSize = uloc_getDisplayLanguage(value, locale, localName, kMaxICUNameSize, &localStatus);
if (U_FAILURE(localStatus) || size <= 0 || localStatus == U_USING_DEFAULT_WARNING)
if (U_FAILURE(localStatus) || localSize <= 0 || localStatus == U_USING_DEFAULT_WARNING)
return false;
}

Expand Down