Skip to content

Commit

Permalink
Fix various typos
Browse files Browse the repository at this point in the history
  • Loading branch information
Coeur committed Aug 17, 2024
1 parent a39f398 commit 6706e1e
Show file tree
Hide file tree
Showing 62 changed files with 125 additions and 126 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,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
28 changes: 14 additions & 14 deletions Sources/CoreFoundation/CFDateFormatter.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ CF_EXPORT const CFStringRef kCFDateFormatterCalendarIdentifierKey;

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

// If you pass in a string in tmplate, you get back NULL (failure) or a CFStringRef.
// 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.
// If you pass in a string in template, you get back NULL (failure) or a CFStringRef.
// 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.

CFArrayRef CFDateFormatterCreateDateFormatsFromTemplates(CFAllocatorRef allocator, CFArrayRef tmplates, CFOptionFlags options, CFLocaleRef locale) {
return (CFArrayRef)CFDateFormatterCreateDateFormatFromTemplate(allocator, (CFStringRef)tmplates, options, locale);
CFArrayRef CFDateFormatterCreateDateFormatsFromTemplates(CFAllocatorRef allocator, CFArrayRef templates, CFOptionFlags options, CFLocaleRef locale) {
return (CFArrayRef)CFDateFormatterCreateDateFormatFromTemplate(allocator, (CFStringRef)templates, options, locale);
}

static Boolean useTemplatePatternGenerator(CFLocaleRef locale, void(^work)(UDateTimePatternGenerator *ptg)) {
Expand Down Expand Up @@ -122,21 +122,21 @@ static void _CFDateFormatterStripAMPMIndicators(UniChar **bpat, int32_t *bpatlen
}
}

CFStringRef CFDateFormatterCreateDateFormatFromTemplate(CFAllocatorRef allocator, CFStringRef tmplate, CFOptionFlags options, CFLocaleRef locale) {
CFStringRef CFDateFormatterCreateDateFormatFromTemplate(CFAllocatorRef allocator, CFStringRef template, CFOptionFlags options, CFLocaleRef locale) {
if (allocator) __CFGenericValidateType(allocator, CFAllocatorGetTypeID());
if (locale) __CFGenericValidateType(locale, CFLocaleGetTypeID());
Boolean tmplateIsString = (CFStringGetTypeID() == CFGetTypeID(tmplate));
Boolean tmplateIsString = (CFStringGetTypeID() == CFGetTypeID(template));
if (!tmplateIsString) {
__CFGenericValidateType(tmplate, CFArrayGetTypeID());
__CFGenericValidateType(template, CFArrayGetTypeID());
}

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

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


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

Boolean stripAMPM = CFStringFind(tmplateString, CFSTR("J"), 0).location != kCFNotFound;
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 @@ -2173,8 +2173,8 @@ CFTypeRef CFDateFormatterCopyProperty(CFDateFormatterRef formatter, CFStringRef
return NULL;
}

CFStringRef _CFDateFormatterCreateSkeletonFromTemplate(CFStringRef tmplateString, CFLocaleRef locale, UErrorCode *outErrorCode) {
CFIndex const tmpltLen = CFStringGetLength(tmplateString);
CFStringRef _CFDateFormatterCreateSkeletonFromTemplate(CFStringRef templateString, CFLocaleRef locale, UErrorCode *outErrorCode) {
CFIndex const tmpltLen = CFStringGetLength(templateString);
if (tmpltLen == 0) {
if (outErrorCode) {
*outErrorCode = U_ILLEGAL_ARGUMENT_ERROR;
Expand All @@ -2187,9 +2187,9 @@ CFStringRef _CFDateFormatterCreateSkeletonFromTemplate(CFStringRef tmplateString
#define BUFFER_SIZE 768

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

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
Loading

0 comments on commit 6706e1e

Please sign in to comment.