]> git.saurik.com Git - apple/cf.git/commitdiff
CF-368.18.tar.gz mac-os-x-1043 v368.18
authorApple <opensource@apple.com>
Tue, 25 Oct 2005 22:39:54 +0000 (22:39 +0000)
committerApple <opensource@apple.com>
Tue, 25 Oct 2005 22:39:54 +0000 (22:39 +0000)
12 files changed:
Base.subproj/CFBase.c
Base.subproj/CFBase.h
Makefile
NumberDate.subproj/CFDate.c
PlugIn.subproj/CFBundle.c
PlugIn.subproj/CFBundle_Internal.h
PlugIn.subproj/CFBundle_Resources.c
Preferences.subproj/CFApplicationPreferences.c
Preferences.subproj/CFPreferences.c
Preferences.subproj/CFXMLPreferencesDomain.c
RunLoop.subproj/CFMachPort.c
String.subproj/CFString.c

index 92691f9e6dadeee3ba84e4d97db19600193c858e..c8076753b50b541c9b91404dc95efc668f40d0b3 100644 (file)
@@ -722,6 +722,7 @@ void CFAllocatorGetContext(CFAllocatorRef allocator, CFAllocatorContext *context
     context->reallocate = __CFAllocatorGetReallocateFunction(&allocator->_context);
     context->deallocate = __CFAllocatorGetDeallocateFunction(&allocator->_context);
     context->preferredSize = __CFAllocatorGetPreferredSizeFunction(&allocator->_context);
+#if defined(__ppc__)   
     context->retain = (void *)((uintptr_t)context->retain & ~0x3);
     context->release = (void *)((uintptr_t)context->release & ~0x3);
     context->copyDescription = (void *)((uintptr_t)context->copyDescription & ~0x3);
@@ -729,6 +730,7 @@ void CFAllocatorGetContext(CFAllocatorRef allocator, CFAllocatorContext *context
     context->reallocate = (void *)((uintptr_t)context->reallocate & ~0x3);
     context->deallocate = (void *)((uintptr_t)context->deallocate & ~0x3);
     context->preferredSize = (void *)((uintptr_t)context->preferredSize & ~0x3);
+#endif
 }
 
 void *_CFAllocatorAllocateGC(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint)
index 1de0fff73090ab5a289d6b8218f67ff4d98c0d86..7bc8b60532c936750bfa85daf1a8fad7b52a866b 100644 (file)
@@ -130,8 +130,10 @@ extern "C" {
 #endif
 
 #if !defined(CF_INLINE)
-    #if defined(__GNUC__)
-       #define CF_INLINE static __inline__
+    #if defined(__GNUC__) && (__GNUC__ == 4)
+       #define CF_INLINE static __inline__ __attribute__((always_inline))
+    #elif defined(__GNUC__)
+    #define CF_INLINE static __inline__
     #elif defined(__MWERKS__) || defined(__cplusplus)
        #define CF_INLINE static inline
     #elif defined(_MSC_VER)
index 801a3063f83c072fc39447a7f0fa8e387755f07f..4685bde6b2ffc55d72874012119e89a12865bb98 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -74,7 +74,7 @@ include framework.make
 # Misc additional options
 #
 
-CURRENT_PROJECT_VERSION = 368.11
+CURRENT_PROJECT_VERSION = 368.18
 
 # common items all build styles should be defining
 CFLAGS += -DCF_BUILDING_CF=1
index 557e2d3386cf39757527f1bd30cc41fde44ac232..3f774f0ae2675e20c8a6e41f6227961e2a9d92b8 100644 (file)
@@ -245,13 +245,17 @@ static void __CFYMDFromAbsolute(int32_t absolute, int32_t *year, int8_t *month,
 }
 
 /* year arg is absolute year; Gregorian 2001 == year 0; 2001/1/1 = absolute date 0 */
-static int32_t __CFAbsoluteFromYMD(int32_t year, int8_t month, int8_t day) {
-    int32_t absolute = 0, idx;
+static double __CFAbsoluteFromYMD(int32_t year, int8_t month, int8_t day) {
+    double absolute = 0.0;
+    int32_t idx;
+    int32_t b = year / 400; // take care of as many multiples of 400 years as possible
+    absolute += b * 146097.0;
+    year -= b * 400;
     if (year < 0) {
        for (idx = year; idx < 0; idx++)
            absolute -= __CFDaysAfterMonth(0, idx, isleap(idx));
     } else {
-       for (idx = year - 1; 0 <= idx; idx--)
+       for (idx = 0; idx < year; idx++)
            absolute += __CFDaysAfterMonth(0, idx, isleap(idx));
     }
     /* Now add the days into the original year */
@@ -451,7 +455,6 @@ SInt32 CFAbsoluteTimeGetDayOfYear(CFAbsoluteTime at, CFTimeZoneRef tz) {
 SInt32 CFAbsoluteTimeGetWeekOfYear(CFAbsoluteTime at, CFTimeZoneRef tz) {
     int32_t absolute, year;
     int8_t month, day;
-    int32_t absolute0101, dow0101;
     CFAbsoluteTime fixedat;
     if (NULL != tz) {
        __CFGenericValidateType(tz, CFTimeZoneGetTypeID());
@@ -459,8 +462,8 @@ SInt32 CFAbsoluteTimeGetWeekOfYear(CFAbsoluteTime at, CFTimeZoneRef tz) {
     fixedat = at + (NULL != tz ? CFTimeZoneGetSecondsFromGMT(tz, at) : 0.0);
     absolute = (int32_t)(float)floor(fixedat / 86400.0);
     __CFYMDFromAbsolute(absolute, &year, &month, &day);
-    absolute0101 = __CFAbsoluteFromYMD(year, 1, 1);
-    dow0101 = (absolute0101 < 0) ? ((absolute0101 + 1) % 7 + 7) : (absolute0101 % 7 + 1);
+    double absolute0101 = __CFAbsoluteFromYMD(year, 1, 1);
+    int32_t dow0101 = __CFDoubleModToInt(absolute0101, 7) + 1;
     /* First three and last three days of a year can end up in a week of a different year */
     if (1 == month && day < 4) {
        if ((day < 4 && 5 == dow0101) || (day < 3 && 6 == dow0101) || (day < 2 && 7 == dow0101)) {
@@ -468,9 +471,8 @@ SInt32 CFAbsoluteTimeGetWeekOfYear(CFAbsoluteTime at, CFTimeZoneRef tz) {
        }
     }
     if (12 == month && 28 < day) {
-       int32_t absolute20101, dow20101;
-       absolute20101 = __CFAbsoluteFromYMD(year + 1, 1, 1);
-       dow20101 = (absolute20101 < 0) ? ((absolute20101 + 1) % 7 + 7) : (absolute20101 % 7 + 1);
+       double absolute20101 = __CFAbsoluteFromYMD(year + 1, 1, 1);
+       int32_t dow20101 = __CFDoubleModToInt(absolute20101, 7) + 1;
        if ((28 < day && 4 == dow20101) || (29 < day && 3 == dow20101) || (30 < day && 2 == dow20101)) {
            return 1;
        }
index b46201d72d82cfe3d9d5135cea3a22306b2fa3ea..3586455b5bf5868a07b5e8c71273c466ad31f0ca 100644 (file)
@@ -2286,12 +2286,12 @@ Boolean CFBundleLoadExecutable(CFBundleRef bundle) {
 
     
     switch (bundle->_binaryType) {
-#if defined(BINARY_SUPPORT_CFM)
+#if defined(BINARY_SUPPORT_CFM) && defined(__ppc__)
         case __CFBundleCFMBinary:
         case __CFBundleUnreadableBinary:
             result = _CFBundleCFMLoad(bundle);
             break;
-#endif /* BINARY_SUPPORT_CFM */
+#endif /* BINARY_SUPPORT_CFM && __ppc__ */
 #if defined(BINARY_SUPPORT_DYLD)
         case __CFBundleDYLDBundleBinary:
             result = _CFBundleDYLDLoadBundle(bundle);
@@ -2343,11 +2343,11 @@ void CFBundleUnloadExecutable(CFBundleRef bundle) {
     _CFPlugInWillUnload(bundle);
 
     switch (bundle->_binaryType) {
-#if defined(BINARY_SUPPORT_CFM)
+#if defined(BINARY_SUPPORT_CFM) && defined(__ppc__)
         case __CFBundleCFMBinary:
              _CFBundleCFMUnload(bundle);
             break;
-#endif /* BINARY_SUPPORT_CFM */
+#endif /* BINARY_SUPPORT_CFM && __ppc__ */
 #if defined(BINARY_SUPPORT_DYLD)
         case __CFBundleDYLDBundleBinary:
             _CFBundleDYLDUnloadBundle(bundle);
@@ -2417,11 +2417,11 @@ void *CFBundleGetFunctionPointerForName(CFBundleRef bundle, CFStringRef funcName
     }
     
     switch (bundle->_binaryType) {
-#if defined(BINARY_SUPPORT_CFM)
+#if defined(BINARY_SUPPORT_CFM) && defined(__ppc__)
         case __CFBundleCFMBinary:
             tvp = _CFBundleCFMGetSymbolByName(bundle, funcName, kTVectorCFragSymbol);
             break;
-#endif /* BINARY_SUPPORT_CFM */
+#endif /* BINARY_SUPPORT_CFM && __ppc__ */
 #if defined(BINARY_SUPPORT_DYLD)
         case __CFBundleDYLDBundleBinary:
         case __CFBundleDYLDFrameworkBinary:
@@ -2461,11 +2461,11 @@ void *_CFBundleGetCFMFunctionPointerForName(CFBundleRef bundle, CFStringRef func
     }
     
     switch (bundle->_binaryType) {
-#if defined(BINARY_SUPPORT_CFM)
+#if defined(BINARY_SUPPORT_CFM) && defined(__ppc__)
         case __CFBundleCFMBinary:
             return _CFBundleCFMGetSymbolByName(bundle, funcName, kTVectorCFragSymbol);
             break;
-#endif /* BINARY_SUPPORT_CFM */
+#endif /* BINARY_SUPPORT_CFM && __ppc__ */
 #if defined(BINARY_SUPPORT_DYLD)
         case __CFBundleDYLDBundleBinary:
         case __CFBundleDYLDFrameworkBinary:
@@ -2522,11 +2522,11 @@ void *CFBundleGetDataPointerForName(CFBundleRef bundle, CFStringRef symbolName)
     }
     
     switch (bundle->_binaryType) {
-#if defined(BINARY_SUPPORT_CFM)
+#if defined(BINARY_SUPPORT_CFM) && defined(__ppc__)
         case __CFBundleCFMBinary:
             dp = _CFBundleCFMGetSymbolByName(bundle, symbolName, kDataCFragSymbol);
             break;
-#endif /* BINARY_SUPPORT_CFM */
+#endif /* BINARY_SUPPORT_CFM && __ppc__ */
 #if defined(BINARY_SUPPORT_DYLD)
         case __CFBundleDYLDBundleBinary:
         case __CFBundleDYLDFrameworkBinary:
index 6b949166fade041b5d57131087063d6fbe572a95..503bf36c4ed99b68e36cd4eb7816b73550e41e8d 100644 (file)
@@ -114,7 +114,7 @@ extern CFArrayRef _CFBundleDYLDCopyLoadedImagePathsIfChanged(void);
 extern CFArrayRef _CFBundleDYLDCopyLoadedImagePathsForHint(CFStringRef hint);
 #endif
 
-#if defined(BINARY_SUPPORT_CFM)
+#if defined(BINARY_SUPPORT_CFM) && defined(__ppc__)
 // CFM API
 #if defined(__MACOS8__)
 #include <CodeFragments.h>
@@ -125,7 +125,7 @@ extern void _CFBundleCFMConnect(CFBundleRef bundle);
 extern void _CFBundleCFMUnload(CFBundleRef bundle);
 extern void *__CFBundleCFMGetSymbol(void *connID, ConstStr255Param name, CFragSymbolClass class);
 extern void *_CFBundleCFMGetSymbolByName(CFBundleRef bundle, CFStringRef symbolName, CFragSymbolClass class);
-#endif /* BINARY_SUPPORT_CFM */
+#endif /* BINARY_SUPPORT_CFM && __ppc__ */
 
 #if defined(BINARY_SUPPORT_DLL)
 extern Boolean _CFBundleDLLLoad(CFBundleRef bundle);
index c2bce548e9a99365e2c9292ab69e17897fde9bef..cd21ecd81785e7ec5eed3584c13fb1252499864e 100644 (file)
@@ -1962,22 +1962,22 @@ static Boolean _CFBundleGetPackageInfoInDirectoryWithInfoDictionary(CFAllocatorR
                 startOfExtension = _CFStartOfPathExtension(buff, strLen);
                 if (((strLen - startOfExtension == 4) || (strLen - startOfExtension == 5)) && (buff[startOfExtension] == (UniChar)'.') && (buff[startOfExtension+1] == (UniChar)'a') && (buff[startOfExtension+2] == (UniChar)'p') && (buff[startOfExtension+3] == (UniChar)'p') && ((strLen - startOfExtension == 4) || (buff[startOfExtension+4] == (UniChar)'/'))) {
                     // This is an app
-                    *packageType = CFSwapInt32BigToHost(0x4150504c);  // 'APPL'
+                    *packageType = 0x4150504c;  // 'APPL'
                 } else if (((strLen - startOfExtension == 6) || (strLen - startOfExtension == 7)) && (buff[startOfExtension] == (UniChar)'.') && (buff[startOfExtension+1] == (UniChar)'d') && (buff[startOfExtension+2] == (UniChar)'e') && (buff[startOfExtension+3] == (UniChar)'b') && (buff[startOfExtension+4] == (UniChar)'u') && (buff[startOfExtension+5] == (UniChar)'g') && ((strLen - startOfExtension == 6) || (buff[startOfExtension+6] == (UniChar)'/'))) {
                     // This is an app (debug version)
-                    *packageType = CFSwapInt32BigToHost(0x4150504c);  // 'APPL'
+                    *packageType = 0x4150504c;  // 'APPL'
                 } else if (((strLen - startOfExtension == 8) || (strLen - startOfExtension == 9)) && (buff[startOfExtension] == (UniChar)'.') && (buff[startOfExtension+1] == (UniChar)'p') && (buff[startOfExtension+2] == (UniChar)'r') && (buff[startOfExtension+3] == (UniChar)'o') && (buff[startOfExtension+4] == (UniChar)'f') && (buff[startOfExtension+5] == (UniChar)'i') && (buff[startOfExtension+6] == (UniChar)'l') && (buff[startOfExtension+7] == (UniChar)'e') && ((strLen - startOfExtension == 8) || (buff[startOfExtension+8] == (UniChar)'/'))) {
                     // This is an app (profile version)
-                    *packageType = CFSwapInt32BigToHost(0x4150504c);  // 'APPL'
+                    *packageType = 0x4150504c;  // 'APPL'
                 } else if (((strLen - startOfExtension == 8) || (strLen - startOfExtension == 9)) && (buff[startOfExtension] == (UniChar)'.') && (buff[startOfExtension+1] == (UniChar)'s') && (buff[startOfExtension+2] == (UniChar)'e') && (buff[startOfExtension+3] == (UniChar)'r') && (buff[startOfExtension+4] == (UniChar)'v') && (buff[startOfExtension+5] == (UniChar)'i') && (buff[startOfExtension+6] == (UniChar)'c') && (buff[startOfExtension+7] == (UniChar)'e') && ((strLen - startOfExtension == 8) || (buff[startOfExtension+8] == (UniChar)'/'))) {
                     // This is a service
-                    *packageType = CFSwapInt32BigToHost(0x4150504c);  // 'APPL'
+                    *packageType = 0x4150504c;  // 'APPL'
                 } else if (((strLen - startOfExtension == 10) || (strLen - startOfExtension == 11)) && (buff[startOfExtension] == (UniChar)'.') && (buff[startOfExtension+1] == (UniChar)'f') && (buff[startOfExtension+2] == (UniChar)'r') && (buff[startOfExtension+3] == (UniChar)'a') && (buff[startOfExtension+4] == (UniChar)'m') && (buff[startOfExtension+5] == (UniChar)'e') && (buff[startOfExtension+6] == (UniChar)'w') && (buff[startOfExtension+7] == (UniChar)'o') && (buff[startOfExtension+8] == (UniChar)'r') && (buff[startOfExtension+9] == (UniChar)'k') && ((strLen - startOfExtension == 10) || (buff[startOfExtension+10] == (UniChar)'/'))) {
                     // This is a framework
-                    *packageType = CFSwapInt32BigToHost(0x464d574b);  // 'FMWK'
+                    *packageType = 0x464d574b;  // 'FMWK'
                 } else {
                     // Default to BNDL for generic bundle
-                    *packageType = CFSwapInt32BigToHost(0x424e444C);  // 'BNDL'
+                    *packageType = 0x424e444c;  // 'BNDL'
                 }
             }
             retVal = true;
@@ -1992,7 +1992,7 @@ CF_EXPORT void CFBundleGetPackageInfo(CFBundleRef bundle, UInt32 *packageType, U
     CFURLRef bundleURL = CFBundleCopyBundleURL(bundle);
     if (!_CFBundleGetPackageInfoInDirectoryWithInfoDictionary(CFGetAllocator(bundle), bundleURL, CFBundleGetInfoDictionary(bundle), packageType, packageCreator)) {
         if (packageType != NULL) {
-            *packageType = CFSwapInt32BigToHost(0x424e444C);  // 'BNDL'
+            *packageType = 0x424e444c;  // 'BNDL'
         }
         if (packageCreator != NULL) {
             *packageCreator = 0x3f3f3f3f;  // '????'
index f18b93a77ebf32e0bbfed64bbee299e229391e6c..764e68c78f23aba51e96efe7d50b05b0a4a63fb3 100644 (file)
@@ -378,6 +378,11 @@ void _CFApplicationPreferencesSet(_CFApplicationPreferences *self, CFStringRef d
 
 void _CFApplicationPreferencesRemove(_CFApplicationPreferences *self, CFStringRef defaultName) {
     CFPreferencesDomainRef appDomain;
+    void *defs = NULL;
+    __CFSpinLock(&userDefaultsLock);
+    defs = userDefaults;
+    __CFSpinUnlock(&userDefaultsLock);
+    CF_OBJC_KVO_WILLCHANGE(defs, defaultName);
     __CFSpinLock(&__CFApplicationPreferencesLock);
     appDomain = _CFPreferencesStandardDomain(self->_appName, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
     if(appDomain) {
@@ -388,6 +393,7 @@ void _CFApplicationPreferencesRemove(_CFApplicationPreferences *self, CFStringRe
         }
     }
     __CFSpinUnlock(&__CFApplicationPreferencesLock);
+    CF_OBJC_KVO_DIDCHANGE(defs, defaultName);
 }
 
 static Boolean _CFApplicationPreferencesSynchronizeNoLock(_CFApplicationPreferences *self) {
index 1d31eaeb3fea269d9b84e60f38822d300693eecb..abfcd21664048f966b108add65cbe434ba157fee 100644 (file)
@@ -86,6 +86,8 @@ CF_EXPORT void CFPreferencesDumpMem(void) {
 }
 #endif
 
+static CFURLRef _CFPreferencesURLForStandardDomainWithSafetyLevel(CFStringRef domainName, CFStringRef userName, CFStringRef hostName, unsigned long safeLevel);
+
 static unsigned long __CFSafeLaunchLevel = 0;
 
 static CFURLRef _preferencesDirectoryForUserHostSafetyLevel(CFStringRef userName, CFStringRef hostName, unsigned long safeLevel) {
index e259c44ddbcb59213c5211c2481ed7ad060b5cf0..c2473b9398d7fe065c07d019e429093985739f3b 100644 (file)
@@ -289,15 +289,29 @@ static Boolean __CFWriteBytesToFileWithAtomicity(CFURLRef url, const void *bytes
     int fd = -1;
     char auxPath[CFMaxPathSize + 16];
     char cpath[CFMaxPathSize];
-    int fsyncErr = 0;
+    uid_t owner = getuid();
+    gid_t group = getgid();
+    Boolean writingFileAsRoot = ((getuid() != geteuid()) && (geteuid() == 0));
 
     if (!CFURLGetFileSystemRepresentation(url, true, cpath, CFMaxPathSize)) {
         return false;
     }
-    if (-1 == mode) {
+    
+    if (-1 == mode || writingFileAsRoot) {
        struct stat statBuf;
-       mode = (0 == stat(cpath, &statBuf)) ? statBuf.st_mode : 0600;
+        if (0 == stat(cpath, &statBuf)) {
+            mode = statBuf.st_mode;
+            owner = statBuf.st_uid;
+            group = statBuf.st_gid;
+        } else {
+            mode = 0664;
+            if (writingFileAsRoot && (0 == strncmp(cpath, "/Library/Preferences", 20))) {
+                owner = geteuid();
+                group = 80;
+            }
+        }
     }
+    
     if (atomic) {
         CFURLRef dir = CFURLCreateCopyDeletingLastPathComponent(NULL, url);
         CFURLRef tempFile = CFURLCreateCopyAppendingPathComponent(NULL, dir, CFSTR("cf#XXXXX"), false);
@@ -311,7 +325,9 @@ static Boolean __CFWriteBytesToFileWithAtomicity(CFURLRef url, const void *bytes
     } else {
         fd = open(cpath, O_WRONLY|O_CREAT|O_TRUNC, mode);
     }
+    
     if (fd < 0) return false;
+    
     if (length && (write(fd, bytes, length) != length || fsync(fd) < 0)) {
         int saveerr = thread_errno();
         close(fd);
@@ -320,7 +336,9 @@ static Boolean __CFWriteBytesToFileWithAtomicity(CFURLRef url, const void *bytes
         thread_set_errno(saveerr);
         return false;
     }
+    
     close(fd);
+    
     if (atomic) {
         // preserve the mode as passed in originally
         chmod(auxPath, mode);
@@ -329,6 +347,11 @@ static Boolean __CFWriteBytesToFileWithAtomicity(CFURLRef url, const void *bytes
             unlink(auxPath);
             return false;
         }
+        
+        // If the file was renamed successfully and we wrote it as root we need to reset the owner & group as they were.
+        if (writingFileAsRoot) {
+            chown(cpath, owner, group);
+        }
     }
     return true;
 }
index 9cf96d8547df5c871f4a01ca67a97e68ee6461d9..50d1c35cde43dd0d1205cba8486ba5da4e81291e 100644 (file)
 #include <CoreFoundation/CFMachPort.h>
 #include <CoreFoundation/CFRunLoop.h>
 #include <CoreFoundation/CFDictionary.h>
+#include <CoreFoundation/CFByteOrder.h>
 #include <mach/mach.h>
 #include <mach/mach_error.h>
 #include <mach/notify.h>
@@ -266,38 +267,44 @@ void _CFMachPortInstallNotifyPort(CFRunLoopRef rl, CFStringRef mode) {
 static void __CFNotifyDeadMachPort(CFMachPortRef port, void *msg, CFIndex size, void *info) {
     mach_msg_header_t *header = (mach_msg_header_t *)msg;
     if (header && header->msgh_id == MACH_NOTIFY_DEAD_NAME) {
-       mach_port_t dead_port = ((mach_dead_name_notification_t *)msg)->not_port;
-       CFMachPortRef existing;
-       /* If the CFMachPort has already been invalidated, it won't be found here. */
-       __CFSpinLock(&__CFAllMachPortsLock);
-       if (NULL != __CFAllMachPorts && CFDictionaryGetValueIfPresent(__CFAllMachPorts, (void *)dead_port, (const void **)&existing)) {
-           CFDictionaryRemoveValue(__CFAllMachPorts, (void *)dead_port);
-           CFRetain(existing);
-           __CFSpinUnlock(&__CFAllMachPortsLock);
-           CFMachPortInvalidate(existing);
-           CFRelease(existing);
-       } else {
-           __CFSpinUnlock(&__CFAllMachPortsLock);
-       }
-       /* Delete port reference we got for this notification */
-       mach_port_deallocate(mach_task_self(), dead_port);
+               mach_port_t dead_port = ((mach_dead_name_notification_t *)msg)->not_port;
+               if (((mach_dead_name_notification_t *)msg)->NDR.int_rep != NDR_record.int_rep) {
+                       dead_port = CFSwapInt32(dead_port);     
+               }
+               CFMachPortRef existing;
+               /* If the CFMachPort has already been invalidated, it won't be found here. */
+               __CFSpinLock(&__CFAllMachPortsLock);
+               if (NULL != __CFAllMachPorts && CFDictionaryGetValueIfPresent(__CFAllMachPorts, (void *)dead_port, (const void **)&existing)) {
+                       CFDictionaryRemoveValue(__CFAllMachPorts, (void *)dead_port);
+                       CFRetain(existing);
+                       __CFSpinUnlock(&__CFAllMachPortsLock);
+                       CFMachPortInvalidate(existing);
+                       CFRelease(existing);
+               } else {
+                       __CFSpinUnlock(&__CFAllMachPortsLock);
+               }
+               /* Delete port reference we got for this notification */
+               mach_port_deallocate(mach_task_self(), dead_port);
     } else if (header && header->msgh_id == MACH_NOTIFY_PORT_DELETED) {
-       mach_port_t dead_port = ((mach_port_deleted_notification_t *)msg)->not_port;
-       CFMachPortRef existing;
-       /* If the CFMachPort has already been invalidated, it won't be found here. */
-       __CFSpinLock(&__CFAllMachPortsLock);
-       if (NULL != __CFAllMachPorts && CFDictionaryGetValueIfPresent(__CFAllMachPorts, (void *)dead_port, (const void **)&existing)) {
-           CFDictionaryRemoveValue(__CFAllMachPorts, (void *)dead_port);
-           CFRetain(existing);
-           __CFSpinUnlock(&__CFAllMachPortsLock);
-           CFMachPortInvalidate(existing);
-           CFRelease(existing);
-       } else {
-           __CFSpinUnlock(&__CFAllMachPortsLock);
-       }
-       /* Delete port reference we got for this notification */
-// Don't do this, since this always fails, and could cause trouble
-//     mach_port_deallocate(mach_task_self(), dead_port);
+               mach_port_t dead_port = ((mach_port_deleted_notification_t *)msg)->not_port;
+               if (((mach_dead_name_notification_t *)msg)->NDR.int_rep != NDR_record.int_rep) {
+                       dead_port = CFSwapInt32(dead_port);     
+               }
+               CFMachPortRef existing;
+               /* If the CFMachPort has already been invalidated, it won't be found here. */
+               __CFSpinLock(&__CFAllMachPortsLock);
+               if (NULL != __CFAllMachPorts && CFDictionaryGetValueIfPresent(__CFAllMachPorts, (void *)dead_port, (const void **)&existing)) {
+                       CFDictionaryRemoveValue(__CFAllMachPorts, (void *)dead_port);
+                       CFRetain(existing);
+                       __CFSpinUnlock(&__CFAllMachPortsLock);
+                       CFMachPortInvalidate(existing);
+                       CFRelease(existing);
+               } else {
+                       __CFSpinUnlock(&__CFAllMachPortsLock);
+               }
+               /* Delete port reference we got for this notification */
+               // Don't do this, since this always fails, and could cause trouble
+               //      mach_port_deallocate(mach_task_self(), dead_port);
     }
 }
 
index 881f27aabbdb6b23bf8002f5a1259a57156c85f7..685075b0c50f230b2b856069a8af1868d7be3c0b 100644 (file)
@@ -2620,7 +2620,7 @@ Boolean CFStringFindWithOptions(CFStringRef string, CFStringRef stringToFind, CF
                             
                             // this is assuming viramas are only in BMP ???
                             if ((str1Char == COMBINING_GRAPHEME_JOINER) || (otherChar == COMBINING_GRAPHEME_JOINER) || (otherChar == ZERO_WIDTH_JOINER) || ((otherChar >= HANGUL_CHOSEONG_START) && (otherChar <= HANGUL_JONGSEONG_END)) || (CFUniCharGetCombiningPropertyForCharacter(otherChar, combClassBMP) == 9)) {
-                                CFRange clusterRange = CFStringGetRangeOfCharacterClusterAtIndex(string, str1Index, kCFStringGramphemeCluster);
+                                CFRange clusterRange = CFStringGetRangeOfCharacterClusterAtIndex(string, str1Index - 1, kCFStringGramphemeCluster);
                                 
                                 if (str1Index < (clusterRange.location + clusterRange.length)) match = false;
                             }