Skip to content

Commit bf6b481

Browse files
committed
Fixes indentation in CFTimeZoneCreateWithName function
1 parent 6e7817b commit bf6b481

File tree

1 file changed

+59
-59
lines changed

1 file changed

+59
-59
lines changed

CoreFoundation/NumberDate.subproj/CFTimeZone.c

Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1498,39 +1498,39 @@ CFTimeZoneRef CFTimeZoneCreateWithName(CFAllocatorRef allocator, CFStringRef nam
14981498
__CFGenericValidateType(allocator, CFAllocatorGetTypeID());
14991499
__CFGenericValidateType(name, CFStringGetTypeID());
15001500
if (CFEqual(CFSTR(""), name)) {
1501-
// empty string is not a time zone name, just abort now,
1502-
// following stuff will fail anyway
1503-
return NULL;
1501+
// empty string is not a time zone name, just abort now,
1502+
// following stuff will fail anyway
1503+
return NULL;
15041504
}
15051505
__CFTimeZoneLockGlobal();
15061506
if (NULL != __CFTimeZoneCache && CFDictionaryGetValueIfPresent(__CFTimeZoneCache, name, (const void **)&result)) {
1507-
__CFTimeZoneUnlockGlobal();
1508-
return (CFTimeZoneRef)CFRetain(result);
1507+
__CFTimeZoneUnlockGlobal();
1508+
return (CFTimeZoneRef)CFRetain(result);
15091509
}
15101510
__CFTimeZoneUnlockGlobal();
15111511
CFIndex len = CFStringGetLength(name);
15121512
if (6 == len || 8 == len) {
1513-
UniChar buffer[8];
1514-
CFStringGetCharacters(name, CFRangeMake(0, len), buffer);
1515-
if ('G' == buffer[0] && 'M' == buffer[1] && 'T' == buffer[2] && ('+' == buffer[3] || '-' == buffer[3])) {
1516-
if (('0' <= buffer[4] && buffer[4] <= '9') && ('0' <= buffer[5] && buffer[5] <= '9')) {
1517-
int32_t hours = (buffer[4] - '0') * 10 + (buffer[5] - '0');
1518-
if (-14 <= hours && hours <= 14) {
1519-
CFTimeInterval ti = hours * 3600.0;
1520-
if (6 == len) {
1521-
return CFTimeZoneCreateWithTimeIntervalFromGMT(allocator, ('-' == buffer[3] ? -1.0 : 1.0) * ti);
1522-
} else {
1523-
if (('0' <= buffer[6] && buffer[6] <= '9') && ('0' <= buffer[7] && buffer[7] <= '9')) {
1524-
int32_t minutes = (buffer[6] - '0') * 10 + (buffer[7] - '0');
1525-
if ((-14 == hours && 0 == minutes) || (14 == hours && 0 == minutes) || (0 <= minutes && minutes <= 59)) {
1526-
ti = ti + minutes * 60.0;
1527-
return CFTimeZoneCreateWithTimeIntervalFromGMT(allocator, ('-' == buffer[3] ? -1.0 : 1.0) * ti);
1528-
}
1529-
}
1530-
}
1531-
}
1513+
UniChar buffer[8];
1514+
CFStringGetCharacters(name, CFRangeMake(0, len), buffer);
1515+
if ('G' == buffer[0] && 'M' == buffer[1] && 'T' == buffer[2] && ('+' == buffer[3] || '-' == buffer[3])) {
1516+
if (('0' <= buffer[4] && buffer[4] <= '9') && ('0' <= buffer[5] && buffer[5] <= '9')) {
1517+
int32_t hours = (buffer[4] - '0') * 10 + (buffer[5] - '0');
1518+
if (-14 <= hours && hours <= 14) {
1519+
CFTimeInterval ti = hours * 3600.0;
1520+
if (6 == len) {
1521+
return CFTimeZoneCreateWithTimeIntervalFromGMT(allocator, ('-' == buffer[3] ? -1.0 : 1.0) * ti);
1522+
} else {
1523+
if (('0' <= buffer[6] && buffer[6] <= '9') && ('0' <= buffer[7] && buffer[7] <= '9')) {
1524+
int32_t minutes = (buffer[6] - '0') * 10 + (buffer[7] - '0');
1525+
if ((-14 == hours && 0 == minutes) || (14 == hours && 0 == minutes) || (0 <= minutes && minutes <= 59)) {
1526+
ti = ti + minutes * 60.0;
1527+
return CFTimeZoneCreateWithTimeIntervalFromGMT(allocator, ('-' == buffer[3] ? -1.0 : 1.0) * ti);
1528+
}
1529+
}
1530+
}
1531+
}
1532+
}
15321533
}
1533-
}
15341534
}
15351535
CFURLRef baseURL = NULL;
15361536

@@ -1568,35 +1568,35 @@ CFTimeZoneRef CFTimeZoneCreateWithName(CFAllocatorRef allocator, CFStringRef nam
15681568
baseURL = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault, __tzZoneInfo, kCFURLPOSIXPathStyle, true);
15691569
#endif
15701570
if (tryAbbrev) {
1571-
CFDictionaryRef abbrevs = CFTimeZoneCopyAbbreviationDictionary();
1572-
tzName = CFDictionaryGetValue(abbrevs, name);
1573-
if (NULL != tzName) {
1574-
data = _CFTimeZoneDataCreate(baseURL, tzName);
1575-
}
1576-
CFRelease(abbrevs);
1571+
CFDictionaryRef abbrevs = CFTimeZoneCopyAbbreviationDictionary();
1572+
tzName = CFDictionaryGetValue(abbrevs, name);
1573+
if (NULL != tzName) {
1574+
data = _CFTimeZoneDataCreate(baseURL, tzName);
1575+
}
1576+
CFRelease(abbrevs);
15771577
}
15781578
if (NULL == data) {
1579-
CFDictionaryRef dict = __CFTimeZoneCopyCompatibilityDictionary();
1580-
CFStringRef mapping = CFDictionaryGetValue(dict, name);
1581-
if (mapping) {
1582-
name = mapping;
1583-
}
1579+
CFDictionaryRef dict = __CFTimeZoneCopyCompatibilityDictionary();
1580+
CFStringRef mapping = CFDictionaryGetValue(dict, name);
1581+
if (mapping) {
1582+
name = mapping;
1583+
}
15841584
#if !TARGET_OS_ANDROID
1585-
else if (CFStringHasPrefix(name, __tzZoneInfo)) {
1586-
CFMutableStringRef unprefixed = CFStringCreateMutableCopy(kCFAllocatorSystemDefault, CFStringGetLength(name), name);
1587-
CFStringDelete(unprefixed, CFRangeMake(0, CFStringGetLength(__tzZoneInfo)));
1588-
mapping = CFDictionaryGetValue(dict, unprefixed);
1589-
if (mapping) {
1590-
name = mapping;
1591-
}
1592-
CFRelease(unprefixed);
1593-
}
1585+
else if (CFStringHasPrefix(name, __tzZoneInfo)) {
1586+
CFMutableStringRef unprefixed = CFStringCreateMutableCopy(kCFAllocatorSystemDefault, CFStringGetLength(name), name);
1587+
CFStringDelete(unprefixed, CFRangeMake(0, CFStringGetLength(__tzZoneInfo)));
1588+
mapping = CFDictionaryGetValue(dict, unprefixed);
1589+
if (mapping) {
1590+
name = mapping;
1591+
}
1592+
CFRelease(unprefixed);
1593+
}
15941594
#endif
1595-
CFRelease(dict);
1596-
if (CFEqual(CFSTR(""), name)) {
1597-
CFRelease(baseURL);
1598-
return NULL;
1599-
}
1595+
CFRelease(dict);
1596+
if (CFEqual(CFSTR(""), name)) {
1597+
CFRelease(baseURL);
1598+
return NULL;
1599+
}
16001600
}
16011601
if (NULL == data) {
16021602
tzName = name;
@@ -1606,15 +1606,15 @@ CFTimeZoneRef CFTimeZoneCreateWithName(CFAllocatorRef allocator, CFStringRef nam
16061606
CFRelease(baseURL);
16071607
}
16081608
if (NULL != data) {
1609-
result = CFTimeZoneCreate(allocator, tzName, data);
1610-
if (name != tzName) {
1611-
CFStringRef nameCopy = (CFStringRef)CFStringCreateCopy(allocator, name);
1612-
__CFTimeZoneLockGlobal();
1613-
CFDictionaryAddValue(__CFTimeZoneCache, nameCopy, result);
1614-
__CFTimeZoneUnlockGlobal();
1615-
CFRelease(nameCopy);
1616-
}
1617-
CFRelease(data);
1609+
result = CFTimeZoneCreate(allocator, tzName, data);
1610+
if (name != tzName) {
1611+
CFStringRef nameCopy = (CFStringRef)CFStringCreateCopy(allocator, name);
1612+
__CFTimeZoneLockGlobal();
1613+
CFDictionaryAddValue(__CFTimeZoneCache, nameCopy, result);
1614+
__CFTimeZoneUnlockGlobal();
1615+
CFRelease(nameCopy);
1616+
}
1617+
CFRelease(data);
16181618
}
16191619
return result;
16201620
#endif

0 commit comments

Comments
 (0)