Skip to content

Commit 921591b

Browse files
committed
code review: avoid using reserved C++ keywords
1 parent e703a13 commit 921591b

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

Sources/CoreFoundation/CFDateFormatter.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ CF_EXPORT const CFStringRef kCFDateFormatterCalendarIdentifierKey;
4949

5050
static CFStringRef __CFDateFormatterCreateForcedTemplate(CFLocaleRef locale, CFStringRef inString, Boolean stripAMPM);
5151

52-
// If you pass in a string in template, you get back NULL (failure) or a CFStringRef.
53-
// If you pass in an array in template, you get back NULL (global failure) or a CFArrayRef with CFStringRefs or kCFNulls (per-template failure) at each corresponding index.
52+
// If you pass in a string in tmplate, you get back NULL (failure) or a CFStringRef.
53+
// If you pass in an array in tmplate, you get back NULL (global failure) or a CFArrayRef with CFStringRefs or kCFNulls (per-template failure) at each corresponding index.
5454

55-
CFArrayRef CFDateFormatterCreateDateFormatsFromTemplates(CFAllocatorRef allocator, CFArrayRef templates, CFOptionFlags options, CFLocaleRef locale) {
56-
return (CFArrayRef)CFDateFormatterCreateDateFormatFromTemplate(allocator, (CFStringRef)templates, options, locale);
55+
CFArrayRef CFDateFormatterCreateDateFormatsFromTemplates(CFAllocatorRef allocator, CFArrayRef tmplates, CFOptionFlags options, CFLocaleRef locale) {
56+
return (CFArrayRef)CFDateFormatterCreateDateFormatFromTemplate(allocator, (CFStringRef)tmplates, options, locale);
5757
}
5858

5959
static Boolean useTemplatePatternGenerator(CFLocaleRef locale, void(^work)(UDateTimePatternGenerator *ptg)) {
@@ -122,21 +122,21 @@ static void _CFDateFormatterStripAMPMIndicators(UniChar **bpat, int32_t *bpatlen
122122
}
123123
}
124124

125-
CFStringRef CFDateFormatterCreateDateFormatFromTemplate(CFAllocatorRef allocator, CFStringRef template, CFOptionFlags options, CFLocaleRef locale) {
125+
CFStringRef CFDateFormatterCreateDateFormatFromTemplate(CFAllocatorRef allocator, CFStringRef tmplate, CFOptionFlags options, CFLocaleRef locale) {
126126
if (allocator) __CFGenericValidateType(allocator, CFAllocatorGetTypeID());
127127
if (locale) __CFGenericValidateType(locale, CFLocaleGetTypeID());
128-
Boolean tmplateIsString = (CFStringGetTypeID() == CFGetTypeID(template));
128+
Boolean tmplateIsString = (CFStringGetTypeID() == CFGetTypeID(tmplate));
129129
if (!tmplateIsString) {
130-
__CFGenericValidateType(template, CFArrayGetTypeID());
130+
__CFGenericValidateType(tmplate, CFArrayGetTypeID());
131131
}
132132

133133
__block CFTypeRef result = tmplateIsString ? NULL : (CFTypeRef)CFArrayCreateMutable(allocator, 0, &kCFTypeArrayCallBacks);
134134

135135
Boolean success = useTemplatePatternGenerator(locale, ^(UDateTimePatternGenerator *ptg) {
136136

137137

138-
for (CFIndex idx = 0, cnt = tmplateIsString ? 1 : CFArrayGetCount((CFArrayRef)template); idx < cnt; idx++) {
139-
CFStringRef tmplateString = tmplateIsString ? (CFStringRef)template : (CFStringRef)CFArrayGetValueAtIndex((CFArrayRef)template, idx);
138+
for (CFIndex idx = 0, cnt = tmplateIsString ? 1 : CFArrayGetCount((CFArrayRef)tmplate); idx < cnt; idx++) {
139+
CFStringRef tmplateString = tmplateIsString ? (CFStringRef)tmplate : (CFStringRef)CFArrayGetValueAtIndex((CFArrayRef)tmplate, idx);
140140
CFStringRef resultString = NULL;
141141

142142
Boolean stripAMPM = CFStringFind(tmplateString, CFSTR("J"), 0).location != kCFNotFound;
@@ -155,12 +155,12 @@ CFStringRef CFDateFormatterCreateDateFormatFromTemplate(CFAllocatorRef allocator
155155
}
156156

157157
UChar pattern[BUFFER_SIZE] = {0}, skel[BUFFER_SIZE] = {0}, bpat[BUFFER_SIZE] = {0};
158-
CFIndex tmpltLen = CFStringGetLength(tmplateString);
159-
if (BUFFER_SIZE < tmpltLen) tmpltLen = BUFFER_SIZE;
160-
CFStringGetCharacters(tmplateString, CFRangeMake(0, tmpltLen), (UniChar *)pattern);
158+
CFIndex tmplateLen = CFStringGetLength(tmplateString);
159+
if (BUFFER_SIZE < tmplateLen) tmplateLen = BUFFER_SIZE;
160+
CFStringGetCharacters(tmplateString, CFRangeMake(0, tmplateLen), (UniChar *)pattern);
161161
CFRelease(tmplateString);
162162

163-
int32_t patlen = tmpltLen;
163+
int32_t patlen = tmplateLen;
164164
UErrorCode status = U_ZERO_ERROR;
165165
int32_t skellen = __cficu_udatpg_getSkeleton(ptg, pattern, patlen, skel, sizeof(skel) / sizeof(skel[0]), &status);
166166
if (!U_FAILURE(status)) {
@@ -2173,9 +2173,9 @@ CFTypeRef CFDateFormatterCopyProperty(CFDateFormatterRef formatter, CFStringRef
21732173
return NULL;
21742174
}
21752175

2176-
CFStringRef _CFDateFormatterCreateSkeletonFromTemplate(CFStringRef templateString, CFLocaleRef locale, UErrorCode *outErrorCode) {
2177-
CFIndex const tmpltLen = CFStringGetLength(templateString);
2178-
if (tmpltLen == 0) {
2176+
CFStringRef _CFDateFormatterCreateSkeletonFromTemplate(CFStringRef tmplateString, CFLocaleRef locale, UErrorCode *outErrorCode) {
2177+
CFIndex const tmplateLen = CFStringGetLength(tmplateString);
2178+
if (tmplateLen == 0) {
21792179
if (outErrorCode) {
21802180
*outErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
21812181
}
@@ -2186,15 +2186,15 @@ CFStringRef _CFDateFormatterCreateSkeletonFromTemplate(CFStringRef templateStrin
21862186
Boolean success = useTemplatePatternGenerator(locale, ^(UDateTimePatternGenerator *ptg) {
21872187
#define BUFFER_SIZE 768
21882188

2189-
SAFE_STACK_BUFFER_DECL(UChar, ubuffer, tmpltLen, BUFFER_SIZE);
2190-
UChar const *ustr = (UChar *)CFStringGetCharactersPtr(templateString);
2189+
SAFE_STACK_BUFFER_DECL(UChar, ubuffer, tmplateLen, BUFFER_SIZE);
2190+
UChar const *ustr = (UChar *)CFStringGetCharactersPtr(tmplateString);
21912191
if (ustr == NULL) {
2192-
CFStringGetCharacters(templateString, CFRangeMake(0, tmpltLen), (UniChar *)ubuffer);
2192+
CFStringGetCharacters(tmplateString, CFRangeMake(0, tmplateLen), (UniChar *)ubuffer);
21932193
ustr = ubuffer;
21942194
}
21952195

21962196
UChar skel[BUFFER_SIZE] = {0};
2197-
int32_t patlen = tmpltLen;
2197+
int32_t patlen = tmplateLen;
21982198
UErrorCode status = U_ZERO_ERROR;
21992199
int32_t skelLen = __cficu_udatpg_getSkeleton(ptg, ustr, patlen, skel, sizeof(skel) / sizeof(skel[0]), &status);
22002200
if (U_SUCCESS(status)) {

Sources/CoreFoundation/include/CFDateFormatter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ typedef struct CF_BRIDGED_MUTABLE_TYPE(id) __CFDateFormatter *CFDateFormatterRef
2424
// CFDateFormatters are not thread-safe. Do not use one from multiple threads!
2525

2626
CF_EXPORT
27-
CFStringRef CFDateFormatterCreateDateFormatFromTemplate(CFAllocatorRef allocator, CFStringRef template, CFOptionFlags options, CFLocaleRef locale) API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0));
27+
CFStringRef CFDateFormatterCreateDateFormatFromTemplate(CFAllocatorRef allocator, CFStringRef tmplate, CFOptionFlags options, CFLocaleRef locale) API_AVAILABLE(macos(10.6), ios(4.0), watchos(2.0), tvos(9.0));
2828
// no options defined, pass 0 for now
2929

3030
CF_EXPORT

0 commit comments

Comments
 (0)