Skip to content

Commit

Permalink
Fix various typos (#5075)
Browse files Browse the repository at this point in the history
* Fix various typos

* code review: avoid using reserved C++ keywords
  • Loading branch information
Coeur authored Nov 6, 2024
1 parent cb8377e commit 21b3196
Show file tree
Hide file tree
Showing 61 changed files with 120 additions and 121 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ option(FOUNDATION_BUILD_NETWORKING "build FoundationNetworking"

set(CMAKE_POSITION_INDEPENDENT_CODE YES)

# Fetchable dependcies
# Fetchable dependencies
include(FetchContent)
if (_SwiftFoundationICU_SourceDIR)
FetchContent_Declare(SwiftFoundationICU
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It is designed with these goals in mind:

There is more information on the Foundation framework [here](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/ObjC_classic/).

This project, `swift-corelibs-foundation`, provides an compatibility implementation of the Foundation API for platforms where there is no Objective-C runtime. On macOS, iOS, and other Apple platforms, apps should use the Foundation that comes with the operating system.
This project, `swift-corelibs-foundation`, provides a compatibility implementation of the Foundation API for platforms where there is no Objective-C runtime. On macOS, iOS, and other Apple platforms, apps should use the Foundation that comes with the operating system.

## Project Navigator

Expand Down
4 changes: 2 additions & 2 deletions Sources/CoreFoundation/CFBundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ static CFBundleRef _CFBundleCreate(CFAllocatorRef allocator, CFURLRef bundleURL,
}


// This section of _CFBundleCreate touches the disk, so it should be done outside the lock. This avoids blocking threads which are just attempting to get an existing bundle on file system access, potentially from a lower-piority thread.
// This section of _CFBundleCreate touches the disk, so it should be done outside the lock. This avoids blocking threads which are just attempting to get an existing bundle on file system access, potentially from a lower-priority thread.
_CFBundleVersion localVersion = _CFBundleGetBundleVersionForURL(newURL);
if (_CFBundleVersionFlat == localVersion) {
Boolean exists = false;
Expand Down Expand Up @@ -1741,7 +1741,7 @@ CFBundleRef _CFBundleGetBundleWithIdentifierAndLibraryName(CFStringRef bundleID,
}

static void _CFBundleEnsureAllBundlesUpToDate(void) {
// This method returns all the statically linked bundles. This includes the main bundle as well as any frameworks that the process was linked against at launch time. It does not include frameworks or opther bundles that were loaded dynamically.
// This method returns all the statically linked bundles. This includes the main bundle as well as any frameworks that the process was linked against at launch time. It does not include frameworks or other bundles that were loaded dynamically.
CFArrayRef imagePaths = NULL;
// Tickle the main bundle into existence
(void)CFBundleGetMainBundle();
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreFoundation/CFBundle_InfoPlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,7 @@ CF_PRIVATE void _CFBundleRefreshInfoDictionaryAlreadyLocked(CFBundleRef bundle)
if (bundle->_infoPlistUrl) {
CFRelease(bundle->_infoPlistUrl);
}
bundle->_infoPlistUrl = infoPlistUrl; // transfered as retained
bundle->_infoPlistUrl = infoPlistUrl; // transferred as retained

// Add or fixup any keys that will be expected later
if (bundle->_infoDict) _CFBundleInfoPlistFixupInfoDictionary(bundle, (CFMutableDictionaryRef)bundle->_infoDict);
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreFoundation/CFBundle_Tables.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static void _CFBundleRemoveFromTables(CFBundleRef bundle, CFURLRef bundleURL, CF
// Since we no longer allow bundles to be removed from tables, this method does nothing. Modifying the tables during deallocation is risky because if the caller has over-released the bundle object then we will deadlock on the global lock.
#if TARGET_OS_OSX
if (_useUnsafeUnretainedTables()) {
// Except for special cases of unsafe-unretained, where we must clean up the table or risk handing out a zombie object. There may still be outstanding pointers to these bundes (e.g. the result of CFBundleGetBundleWithIdentifier) but there is nothing we can do about that after this point.
// Except for special cases of unsafe-unretained, where we must clean up the table or risk handing out a zombie object. There may still be outstanding pointers to these bundles (e.g. the result of CFBundleGetBundleWithIdentifier) but there is nothing we can do about that after this point.

// Unique bundles aren't in the tables anyway
if (bundle->_isUnique) return;
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreFoundation/CFCalendar.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static void __CFCalendarSetToFirstInstant(CFCalendarRef calendar, CFCalendarUnit
int32_t qmonth[] = {0, 0, 0, 3, 3, 3, 6, 6, 6, 9, 9, 9, 9};
month = qmonth[month];
}
// #warning if there is a lunar leap month of the same number *preceeding* month N,
// #warning if there is a lunar leap month of the same number *preceding* month N,
// then we should set the calendar to the leap month, not the regular month.
__cficu_ucal_set(calendar->_cal, UCAL_MONTH, month);
__cficu_ucal_set(calendar->_cal, UCAL_IS_LEAP_MONTH, 0);
Expand Down
4 changes: 2 additions & 2 deletions Sources/CoreFoundation/CFCalendar_Enumerate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1755,13 +1755,13 @@ static CFDateRef _Nullable _CFCalendarCreateAdjustedDateForMismatchedLeapMonthOr
if (!foundGregLeap || !foundGregLeapMatchesComps) {
if (strictMatching) {
if (isGregorianCalendar) {
*exactMatch = false; // We couldn't find what we needed but we found sumthin. Step C will decide whether or not to NULL the date out.
*exactMatch = false; // We couldn't find what we needed but we found something. Step C will decide whether or not to NULL the date out.
} else {
// For other calendars (besides Chinese which is already being handled), go to the top of the next period for the next highest unit of the one that bailed.
Boolean eraMatch = false;
CFDateRef tempDate = _CFCalendarCreateMatchingDateAfterStartDateMatchingComponentsInNextHighestUnitRange(calendar, &eraMatch, matchingComponents, nextHighestUnit, searchingDate, goBackwards, findLast, opts);
if (!eraMatch) {
*exactMatch = false; // We couldn't find what we needed but we found sumthin. Step C will decide whether or not to NULL the date out.
*exactMatch = false; // We couldn't find what we needed but we found something. Step C will decide whether or not to NULL the date out.
CFRelease(tempDate);
} else {
CFRelease(result);
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreFoundation/CFData.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ enum {
};

typedef enum {
kCFImmutable = 0x0, /* unchangable and fixed capacity; default */
kCFImmutable = 0x0, /* unchangeable and fixed capacity; default */
kCFFixedMutable = 0x1, /* changeable and fixed capacity */
kCFMutable = 0x3 /* changeable and variable capacity */
} _CFDataMutableVariety;
Expand Down
20 changes: 10 additions & 10 deletions Sources/CoreFoundation/CFDateFormatter.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ CFStringRef CFDateFormatterCreateDateFormatFromTemplate(CFAllocatorRef allocator
}

UChar pattern[BUFFER_SIZE] = {0}, skel[BUFFER_SIZE] = {0}, bpat[BUFFER_SIZE] = {0};
CFIndex tmpltLen = CFStringGetLength(tmplateString);
if (BUFFER_SIZE < tmpltLen) tmpltLen = BUFFER_SIZE;
CFStringGetCharacters(tmplateString, CFRangeMake(0, tmpltLen), (UniChar *)pattern);
CFIndex tmplateLen = CFStringGetLength(tmplateString);
if (BUFFER_SIZE < tmplateLen) tmplateLen = BUFFER_SIZE;
CFStringGetCharacters(tmplateString, CFRangeMake(0, tmplateLen), (UniChar *)pattern);
CFRelease(tmplateString);

int32_t patlen = tmpltLen;
int32_t patlen = tmplateLen;
UErrorCode status = U_ZERO_ERROR;
int32_t skellen = __cficu_udatpg_getSkeleton(ptg, pattern, patlen, skel, sizeof(skel) / sizeof(skel[0]), &status);
if (!U_FAILURE(status)) {
Expand Down Expand Up @@ -872,7 +872,7 @@ static CFMutableStringRef __createISO8601FormatString(CFISO8601DateFormatOptions
CFStringAppendCString(resultStr, "HH:mm:ss", kCFStringEncodingUTF8);
}

// Add support for fracional seconds
// Add support for fractional seconds
if (includeFractionalSecs) {
CFStringAppendCString(resultStr, ".SSS", kCFStringEncodingUTF8);
}
Expand Down Expand Up @@ -2174,8 +2174,8 @@ CFTypeRef CFDateFormatterCopyProperty(CFDateFormatterRef formatter, CFStringRef
}

CFStringRef _CFDateFormatterCreateSkeletonFromTemplate(CFStringRef tmplateString, CFLocaleRef locale, UErrorCode *outErrorCode) {
CFIndex const tmpltLen = CFStringGetLength(tmplateString);
if (tmpltLen == 0) {
CFIndex const tmplateLen = CFStringGetLength(tmplateString);
if (tmplateLen == 0) {
if (outErrorCode) {
*outErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
}
Expand All @@ -2186,15 +2186,15 @@ CFStringRef _CFDateFormatterCreateSkeletonFromTemplate(CFStringRef tmplateString
Boolean success = useTemplatePatternGenerator(locale, ^(UDateTimePatternGenerator *ptg) {
#define BUFFER_SIZE 768

SAFE_STACK_BUFFER_DECL(UChar, ubuffer, tmpltLen, BUFFER_SIZE);
SAFE_STACK_BUFFER_DECL(UChar, ubuffer, tmplateLen, BUFFER_SIZE);
UChar const *ustr = (UChar *)CFStringGetCharactersPtr(tmplateString);
if (ustr == NULL) {
CFStringGetCharacters(tmplateString, CFRangeMake(0, tmpltLen), (UniChar *)ubuffer);
CFStringGetCharacters(tmplateString, CFRangeMake(0, tmplateLen), (UniChar *)ubuffer);
ustr = ubuffer;
}

UChar skel[BUFFER_SIZE] = {0};
int32_t patlen = tmpltLen;
int32_t patlen = tmplateLen;
UErrorCode status = U_ZERO_ERROR;
int32_t skelLen = __cficu_udatpg_getSkeleton(ptg, ustr, patlen, skel, sizeof(skel) / sizeof(skel[0]), &status);
if (U_SUCCESS(status)) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreFoundation/CFICUConverters.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ CF_PRIVATE CFIndex __CFStringEncodingICUToBytes(const char *icuName, uint32_t fl
ucnv_fromUnicode(converter, &destination, destinationLimit, (const UChar **)&source, (const UChar *)sourceLimit, NULL, flush, &errorCode);

#if HAS_ICU_BUG_6024743
/* Another critical ICU design issue. Similar to conversion error, source pointer returned from U_BUFFER_OVERFLOW_ERROR is already beyond the last valid character position. It renders the returned value from source entirely unusable. We have to manually back up until succeeding <rdar://problem/7183045> Intrestingly, this issue doesn't apply to ucnv_toUnicode. The asynmmetric nature makes this more dangerous */
/* Another critical ICU design issue. Similar to conversion error, source pointer returned from U_BUFFER_OVERFLOW_ERROR is already beyond the last valid character position. It renders the returned value from source entirely unusable. We have to manually back up until succeeding <rdar://problem/7183045> Interestingly, this issue doesn't apply to ucnv_toUnicode. The asynmmetric nature makes this more dangerous */
if (U_BUFFER_OVERFLOW_ERROR == errorCode) {
const uint8_t *bitmap = CFUniCharGetBitmapPtrForPlane(kCFUniCharNonBaseCharacterSet, 0);
const uint8_t *nonBase;
Expand Down
8 changes: 4 additions & 4 deletions Sources/CoreFoundation/CFLocale.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ CFArrayRef _CFLocaleCopyValidNumberingSystemsForLocaleIdentifier(CFStringRef loc
return numberingSystemIDs;
}

CFStringRef _CFLocaleCreateLocaleIdentiferByReplacingLanguageCodeAndScriptCode(CFStringRef localeIDWithDesiredLangCode, CFStringRef localeIDWithDesiredComponents) {
CFStringRef _CFLocaleCreateLocaleIdentifierByReplacingLanguageCodeAndScriptCode(CFStringRef localeIDWithDesiredLangCode, CFStringRef localeIDWithDesiredComponents) {
CFStringRef localeID = NULL;
if (localeIDWithDesiredLangCode && localeIDWithDesiredComponents) {
CFStringRef langIDToUse = _CFLocaleCopyLanguageIdentifierWithScriptCodeForLocaleIdentifier(localeIDWithDesiredLangCode);
Expand Down Expand Up @@ -540,7 +540,7 @@ CFStringRef _CFLocaleCreateLocaleIdentiferByReplacingLanguageCodeAndScriptCode(C
if (indexOfNumberingSystem == kCFNotFound || indexOfNumberingSystem == 0) {
CFDictionaryRemoveValue(mutableComps, CFSTR("numbers"));
}
// If the numbering system for `localeIDWithDesiredComponents` is compatible with the constructed locale’s language and is not already the default numbering system (index 0), then set it on the new locale, e.g. `hi_IN@numbers=latn` + `ar` shoudl get `ar_IN@numbers=latn`, since `latn` is valid for `ar`.
// If the numbering system for `localeIDWithDesiredComponents` is compatible with the constructed locale’s language and is not already the default numbering system (index 0), then set it on the new locale, e.g. `hi_IN@numbers=latn` + `ar` should get `ar_IN@numbers=latn`, since `latn` is valid for `ar`.
else if (indexOfNumberingSystem > 0) {
CFDictionarySetValue(mutableComps, CFSTR("numbers"), numberingSystem);
}
Expand Down Expand Up @@ -601,7 +601,7 @@ static CFStringRef _CFLocaleCreateLocaleIdentifierForAvailableLocalizations(CFAr
if (CFEqual(preferredLocaleLanguageID, preferredLocalizationLanguageID)) {
result = CFRetain(preferredLocaleID);
} else {
result = _CFLocaleCreateLocaleIdentiferByReplacingLanguageCodeAndScriptCode(preferredLocalization, preferredLocaleID);
result = _CFLocaleCreateLocaleIdentifierByReplacingLanguageCodeAndScriptCode(preferredLocalization, preferredLocaleID);
}
}
if (preferredLocaleLanguageID) { CFRelease(preferredLocaleLanguageID); }
Expand Down Expand Up @@ -723,7 +723,7 @@ static CFLocaleRef _CFLocaleCopyCurrentGuts(CFStringRef name, Boolean useCache,
if (!ident) {
ident = (CFStringRef)CFRetain(FALLBACK_LOCALE_NAME);

// <rdar://problem/51409572> CFLocaleCopyCurrent() failed to look up current locale -- gpsd dameon is not localized, does not interact directly with users
// <rdar://problem/51409572> CFLocaleCopyCurrent() failed to look up current locale -- gpsd daemon is not localized, does not interact directly with users
// This log was added to try to catch scenarios in which apps fail to look up the current locale thanks to sandboxing issues or CFPreferences issues. It turns out that in its current formulation, this log has a high false positive rate and is very confusing.
// Disabled for now.
/*
Expand Down
14 changes: 7 additions & 7 deletions Sources/CoreFoundation/CFLocaleIdentifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -1950,7 +1950,7 @@ SPI: CFLocaleGetLanguageRegionEncodingForLocaleIdentifier gets the appropriate
otherwise may set *langCode and/or *regCode to -1 if there is no appropriate legacy value for the locale.
This is a replacement for the CFBundle SPI CFBundleGetLocalizationInfoForLocalization (which was intended to be temporary and transitional);
this function is more up-to-date in its handling of locale strings, and is in CFLocale where this functionality should belong. Compared
to CFBundleGetLocalizationInfoForLocalization, this function does not spcially interpret a NULL localeIdentifier to mean use the single most
to CFBundleGetLocalizationInfoForLocalization, this function does not specially interpret a NULL localeIdentifier to mean use the single most
preferred localization in the current context (this function returns NO for a NULL localeIdentifier); and in this function
langCode, regCode, and scriptCode are all SInt16* (not SInt32* like the equivalent parameters in CFBundleGetLocalizationInfoForLocalization).
*/
Expand All @@ -1966,18 +1966,18 @@ Boolean CFLocaleGetLanguageRegionEncodingForLocaleIdentifier(CFStringRef localeI
char localeCString[kLocaleIdentifierCStringMax];
if ( CFStringGetCString(canonicalIdentifier, localeCString, sizeof(localeCString), kCFStringEncodingASCII) ) {
UErrorCode icuStatus = U_ZERO_ERROR;
int32_t languagelength;
int32_t languageLength;
char searchString[ULOC_LANG_CAPACITY + ULOC_FULLNAME_CAPACITY];

languagelength = uloc_getLanguage( localeCString, searchString, ULOC_LANG_CAPACITY, &icuStatus );
if ( U_SUCCESS(icuStatus) && languagelength > 0 ) {
languageLength = uloc_getLanguage( localeCString, searchString, ULOC_LANG_CAPACITY, &icuStatus );
if ( U_SUCCESS(icuStatus) && languageLength > 0 ) {
// OK, here we have at least a language code, check for other components in order
LocaleToLegacyCodes searchEntry = { (const char *)searchString, 0, 0, 0 };
const LocaleToLegacyCodes * foundEntryPtr;
int32_t componentLength;
char componentString[ULOC_FULLNAME_CAPACITY];

languagelength = strlen(searchString); // in case it got truncated
languageLength = strlen(searchString); // in case it got truncated
icuStatus = U_ZERO_ERROR;
componentLength = uloc_getScript( localeCString, componentString, sizeof(componentString), &icuStatus );
Boolean foundScript = false;
Expand Down Expand Up @@ -2006,9 +2006,9 @@ Boolean CFLocaleGetLanguageRegionEncodingForLocaleIdentifier(CFStringRef localeI

// Do not try fallback if string encoding is requested AND a script is present in the passed-in locale since the script might affect the string encoding: <rdar://problem/54531339>
BOOL lookingForScript = foundScript && stringEncoding != NULL;
if (foundEntryPtr == NULL && (int32_t) strlen(searchString) > languagelength && !lookingForScript) {
if (foundEntryPtr == NULL && (int32_t) strlen(searchString) > languageLength && !lookingForScript) {
// Otherwise truncate to language alone and try again
searchString[languagelength] = 0;
searchString[languageLength] = 0;
foundEntryPtr = (const LocaleToLegacyCodes *)bsearch( &searchEntry, localeToLegacyCodes, kNumLocaleToLegacyCodes, sizeof(LocaleToLegacyCodes), CompareLocaleToLegacyCodesEntries );
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/CoreFoundation/CFStream.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ static void _signalEventSync(struct _CFStream* stream)

/* What happens if the callback sets the client to NULL? We're in a loop here... Hmm. */
/* After writing that comment, I see: <rdar://problem/6793636> CFReadStreamSetClient(..., NULL) unsafely releases info pointer immediately */
/* Of note, when the stream callbacks are set to to NULL, we're re-initalized so as not to receive more events, so we
/* Of note, when the stream callbacks are set to to NULL, we're re-initialized so as not to receive more events, so we
* should break pout of this loop */
}
}
Expand Down
Loading

0 comments on commit 21b3196

Please sign in to comment.