From 0ae65c4b477a4eaa7c896e73550ab16afdaac9a3 Mon Sep 17 00:00:00 2001 From: Apple Date: Mon, 7 Aug 2006 22:19:04 +0000 Subject: [PATCH] CF-368.27.tar.gz --- AppServices.subproj/CFUserNotification.c | 1 + Base.subproj/CFFileUtilities.c | 1 + Base.subproj/CFInternal.h | 1 + Makefile | 2 +- Parsing.subproj/CFPropertyList.c | 1 + PlugIn.subproj/CFBundle.c | 16 +++++- PlugIn.subproj/CFBundle_Internal.h | 1 + PlugIn.subproj/CFPlugIn_PlugIn.c | 50 ++++++++++++------- .../CFApplicationPreferences.c | 1 + RunLoop.subproj/CFMessagePort.c | 3 +- String.subproj/CFStringEncodings.c | 9 ++-- framework.make | 4 +- 12 files changed, 63 insertions(+), 27 deletions(-) diff --git a/AppServices.subproj/CFUserNotification.c b/AppServices.subproj/CFUserNotification.c index 35e9d19..e915640 100644 --- a/AppServices.subproj/CFUserNotification.c +++ b/AppServices.subproj/CFUserNotification.c @@ -32,6 +32,7 @@ #include #include "CFInternal.h" + #define __kCFLogUserNotification 20 #define CFUserNotificationLog(alertHeader, alertMessage) CFLog(__kCFLogUserNotification, CFSTR("%@: %@"), alertHeader, alertMessage); diff --git a/Base.subproj/CFFileUtilities.c b/Base.subproj/CFFileUtilities.c index 21913a3..9a17577 100644 --- a/Base.subproj/CFFileUtilities.c +++ b/Base.subproj/CFFileUtilities.c @@ -102,6 +102,7 @@ __private_extern__ Boolean _CFReadBytesFromFile(CFAllocatorRef alloc, CFURLRef u *bytes = NULL; + #if defined(__WIN32__) fd = open(path, O_RDONLY|CF_OPENFLGS, 0666|_S_IREAD); #else diff --git a/Base.subproj/CFInternal.h b/Base.subproj/CFInternal.h index 5cc43ae..471aa92 100644 --- a/Base.subproj/CFInternal.h +++ b/Base.subproj/CFInternal.h @@ -56,6 +56,7 @@ #include "auto_stubs.h" #include + #if defined(__MACH__) #if defined(__ppc__) // This hack is in here because B&I kernel does not set up comm page with Tiger additions yet. diff --git a/Makefile b/Makefile index 16e7bae..a2c1e5e 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ include framework.make # Misc additional options # -CURRENT_PROJECT_VERSION = 368.26 +CURRENT_PROJECT_VERSION = 368.27 # common items all build styles should be defining CFLAGS += -DCF_BUILDING_CF=1 diff --git a/Parsing.subproj/CFPropertyList.c b/Parsing.subproj/CFPropertyList.c index e173b1d..087bd32 100644 --- a/Parsing.subproj/CFPropertyList.c +++ b/Parsing.subproj/CFPropertyList.c @@ -43,6 +43,7 @@ #include #include + __private_extern__ bool allowMissingSemi = false; // Should move this somewhere else diff --git a/PlugIn.subproj/CFBundle.c b/PlugIn.subproj/CFBundle.c index 3586455..711467f 100644 --- a/PlugIn.subproj/CFBundle.c +++ b/PlugIn.subproj/CFBundle.c @@ -78,6 +78,7 @@ #endif #endif + // Public CFBundle Info plist keys CONST_STRING_DECL(kCFBundleInfoDictionaryVersionKey, "CFBundleInfoDictionaryVersion") CONST_STRING_DECL(kCFBundleExecutableKey, "CFBundleExecutable") @@ -2315,6 +2316,7 @@ Boolean CFBundleLoadExecutable(CFBundleRef bundle) { CFLog(__kCFLogBundle, CFSTR("Cannot recognize type of executable for %@"), bundle); break; } + if (result && bundle->_plugInData._isPlugIn) _CFBundlePlugInLoaded(bundle); return result; } @@ -2685,11 +2687,13 @@ static void _CFBundleEnsureBundleExistsForImagePath(CFStringRef imagePath) { // If an image path corresponds to a bundle, we see if there is already a bundle instance. If there is and it is NOT in the _dynamicBundles array, it is added to the staticBundles. Do not add the main bundle to the list here. CFBundleRef bundle; CFURLRef curURL = _CFBundleCopyFrameworkURLForExecutablePath(NULL, imagePath); + Boolean doFinalProcessing = false; if (curURL != NULL) { bundle = _CFBundleFindByURL(curURL, true); if (bundle == NULL) { - bundle = _CFBundleCreate(NULL, curURL, true, true); + bundle = _CFBundleCreate(NULL, curURL, true, false); + doFinalProcessing = true; } if (bundle != NULL && !bundle->_isLoaded) { // make sure that these bundles listed as loaded, and mark them frameworks (we probably can't see anything else here, and we cannot unload them) @@ -2704,6 +2708,16 @@ static void _CFBundleEnsureBundleExistsForImagePath(CFStringRef imagePath) { #endif /* BINARY_SUPPORT_DYLD */ bundle->_isLoaded = true; } + // Perform delayed final processing steps. + // This must be done after _isLoaded has been set. + if (bundle && doFinalProcessing) { + _CFBundleCheckWorkarounds(bundle); + if (_CFBundleNeedsInitPlugIn(bundle)) { + __CFSpinUnlock(&CFBundleGlobalDataLock); + _CFBundleInitPlugIn(bundle); + __CFSpinLock(&CFBundleGlobalDataLock); + } + } CFRelease(curURL); } } diff --git a/PlugIn.subproj/CFBundle_Internal.h b/PlugIn.subproj/CFBundle_Internal.h index 503bf36..3f6be1f 100644 --- a/PlugIn.subproj/CFBundle_Internal.h +++ b/PlugIn.subproj/CFBundle_Internal.h @@ -138,6 +138,7 @@ extern void *_CFBundleDLLGetSymbolByName(CFBundleRef bundle, CFStringRef symbolN extern Boolean _CFBundleNeedsInitPlugIn(CFBundleRef bundle); extern void _CFBundleInitPlugIn(CFBundleRef bundle); +extern void _CFBundlePlugInLoaded(CFBundleRef bundle); extern void _CFBundleDeallocatePlugIn(CFBundleRef bundle); extern void _CFPlugInWillUnload(CFPlugInRef plugIn); diff --git a/PlugIn.subproj/CFPlugIn_PlugIn.c b/PlugIn.subproj/CFPlugIn_PlugIn.c index 4e461aa..2f139ca 100644 --- a/PlugIn.subproj/CFPlugIn_PlugIn.c +++ b/PlugIn.subproj/CFPlugIn_PlugIn.c @@ -28,6 +28,7 @@ #include "CFBundle_Internal.h" #include "CFInternal.h" + static void _registerFactory(const void *key, const void *val, void *context) { CFStringRef factoryIDStr = (CFStringRef)key; CFStringRef factoryFuncStr = (CFStringRef)val; @@ -120,32 +121,44 @@ __private_extern__ void _CFBundleInitPlugIn(CFBundleRef bundle) { CFDictionaryApplyFunction(typeDict, _registerType, bundle); } - /* Now do dynamic registration if necessary */ + /* Now set key for dynamic registration if necessary */ if (doDynamicReg) { + CFDictionarySetValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration"), CFSTR("YES")); + if (CFBundleIsExecutableLoaded(bundle)) _CFBundlePlugInLoaded(bundle); + } +} + +__private_extern__ void _CFBundlePlugInLoaded(CFBundleRef bundle) { + CFDictionaryRef infoDict = CFBundleGetInfoDictionary(bundle); + CFStringRef tempStr; + CFPlugInDynamicRegisterFunction func = NULL; + + if (!__CFBundleGetPlugInData(bundle)->_isPlugIn || __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration || !infoDict || !CFBundleIsExecutableLoaded(bundle)) return; + + tempStr = CFDictionaryGetValue(infoDict, CFSTR("CFPlugInNeedsDynamicRegistration")); + if (tempStr != NULL && CFGetTypeID(tempStr) == CFStringGetTypeID() && CFStringCompare(tempStr, CFSTR("YES"), kCFCompareCaseInsensitive) == kCFCompareEqualTo) { + CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration")); tempStr = CFDictionaryGetValue(infoDict, kCFPlugInDynamicRegisterFunctionKey); if (tempStr == NULL || CFGetTypeID(tempStr) != CFStringGetTypeID() || CFStringGetLength(tempStr) <= 0) { tempStr = CFSTR("CFPlugInDynamicRegister"); } __CFBundleGetPlugInData(bundle)->_loadOnDemand = false; + __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = true; - if (CFBundleLoadExecutable(bundle)) { - CFPlugInDynamicRegisterFunction func = NULL; - - __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = true; - - /* Find the symbol and call it. */ - func = (CFPlugInDynamicRegisterFunction)CFBundleGetFunctionPointerForName(bundle, tempStr); - if (func) { - func(bundle); - // MF:!!! Unload function is never called. Need to deal with this! - } + /* Find the symbol and call it. */ + func = (CFPlugInDynamicRegisterFunction)CFBundleGetFunctionPointerForName(bundle, tempStr); + if (func) { + func(bundle); + // MF:!!! Unload function is never called. Need to deal with this! + } - __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = false; - if (__CFBundleGetPlugInData(bundle)->_loadOnDemand && (__CFBundleGetPlugInData(bundle)->_instanceCount == 0)) { - /* Unload now if we can/should. */ - CFBundleUnloadExecutable(bundle); - } + __CFBundleGetPlugInData(bundle)->_isDoingDynamicRegistration = false; + if (__CFBundleGetPlugInData(bundle)->_loadOnDemand && (__CFBundleGetPlugInData(bundle)->_instanceCount == 0)) { + /* Unload now if we can/should. */ + CFBundleUnloadExecutable(bundle); } + } else { + CFDictionaryRemoveValue((CFMutableDictionaryRef)infoDict, CFSTR("CFPlugInNeedsDynamicRegistration")); } } @@ -169,7 +182,8 @@ UInt32 CFPlugInGetTypeID(void) { } CFPlugInRef CFPlugInCreate(CFAllocatorRef allocator, CFURLRef plugInURL) { - return (CFPlugInRef)CFBundleCreate(allocator, plugInURL); + CFBundleRef bundle = CFBundleCreate(allocator, plugInURL); + return (CFPlugInRef)bundle; } CFBundleRef CFPlugInGetBundle(CFPlugInRef plugIn) { diff --git a/Preferences.subproj/CFApplicationPreferences.c b/Preferences.subproj/CFApplicationPreferences.c index 764e68c..36a026d 100644 --- a/Preferences.subproj/CFApplicationPreferences.c +++ b/Preferences.subproj/CFApplicationPreferences.c @@ -30,6 +30,7 @@ #include #include + static Boolean _CFApplicationPreferencesSynchronizeNoLock(_CFApplicationPreferences *self); void _CFPreferencesDomainSetMultiple(CFPreferencesDomainRef domain, CFDictionaryRef dict); static void updateDictRep(_CFApplicationPreferences *self); diff --git a/RunLoop.subproj/CFMessagePort.c b/RunLoop.subproj/CFMessagePort.c index 2ca7e96..932f3a8 100644 --- a/RunLoop.subproj/CFMessagePort.c +++ b/RunLoop.subproj/CFMessagePort.c @@ -41,6 +41,7 @@ #include #include + #define __kCFMessagePortMaxNameLengthMax 255 #if defined(BOOTSTRAP_MAX_NAME_LEN) @@ -647,7 +648,7 @@ SInt32 CFMessagePortSendRequest(CFMessagePortRef remote, SInt32 msgid, CFDataRef Boolean didRegister = false; kern_return_t ret; -//#warning CF: This should be an assert + //#warning CF: This should be an assert // if (!__CFMessagePortIsRemote(remote)) return -999; if (!__CFMessagePortIsValid(remote)) return kCFMessagePortIsInvalid; __CFMessagePortLock(remote); diff --git a/String.subproj/CFStringEncodings.c b/String.subproj/CFStringEncodings.c index c85bc11..a3d999e 100644 --- a/String.subproj/CFStringEncodings.c +++ b/String.subproj/CFStringEncodings.c @@ -824,11 +824,12 @@ Boolean CFStringGetFileSystemRepresentation(CFStringRef string, char *buffer, CF #if defined(__MACH__) #define MAX_STACK_BUFFER_LEN (255) const UTF16Char *characters = CFStringGetCharactersPtr(string); + CFIndex length = CFStringGetLength(string); uint32_t usedBufLen; - if (NULL == characters) { - CFIndex length = CFStringGetLength(string); + if (maxBufLen < length) return false; // Since we're using UTF-8, the byte length is never shorter than the char length. Also, it filters out 0 == maxBufLen + if (NULL == characters) { if (length > MAX_STACK_BUFFER_LEN) { UTF16Char charactersBuffer[MAX_STACK_BUFFER_LEN]; CFRange range = CFRangeMake(0, MAX_STACK_BUFFER_LEN); @@ -836,7 +837,7 @@ Boolean CFStringGetFileSystemRepresentation(CFStringRef string, char *buffer, CF usedBufLen = 0; - while (length > 0) { + while ((length > 0) && (maxBufLen > usedBufLen)) { CFStringGetCharacters(string, range, charactersBuffer); if (CFUniCharIsSurrogateHighCharacter(charactersBuffer[range.length - 1])) --range.length; // Backup for a high surrogate @@ -856,7 +857,7 @@ Boolean CFStringGetFileSystemRepresentation(CFStringRef string, char *buffer, CF buffer += usedBufLen; } } else { - if (!CFUniCharDecompose(characters, CFStringGetLength(string), NULL, (void *)buffer, maxBufLen, &usedBufLen, true, kCFUniCharUTF8Format, true)) return false; + if (!CFUniCharDecompose(characters, length, NULL, (void *)buffer, maxBufLen, &usedBufLen, true, kCFUniCharUTF8Format, true)) return false; buffer += usedBufLen; } diff --git a/framework.make b/framework.make index 2f70262..34431c8 100755 --- a/framework.make +++ b/framework.make @@ -131,8 +131,8 @@ endif # ifeq "$(PLATFORM)" "Darwin" -C_WARNING_FLAGS += -Wno-four-char-constants -Wall -CPP_WARNING_FLAGS += -Wno-four-char-constants -Wall +C_WARNING_FLAGS += -Wno-precomp -Wno-four-char-constants -Wall +CPP_WARNING_FLAGS += -Wno-precomp -Wno-four-char-constants -Wall endif ifeq "$(PLATFORM)" "CYGWIN" -- 2.45.2