From eb6ceada787683d0d6c95ec388b02445d732b32f Mon Sep 17 00:00:00 2001 From: Andrew Barnert Date: Fri, 5 Oct 2012 14:19:43 -0700 Subject: [PATCH] Make sendMode work. - There are a few places that use `&&` instead of `&` to mask bits out of sendMode, which doesn't actually mask out the bits. - Another place is missing parens, so it ends up comparing the last flag instead of the masked value. - The net result is that changing the sendMode doesn't work in a variety of different cases. --- objc-appscript/trunk/src/Appscript/command.m | 14 +++++++------- .../trunk/src/Appscript/sendthreadsafe.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/objc-appscript/trunk/src/Appscript/command.m b/objc-appscript/trunk/src/Appscript/command.m index 9f9ac8d..9c45aca 100644 --- a/objc-appscript/trunk/src/Appscript/command.m +++ b/objc-appscript/trunk/src/Appscript/command.m @@ -178,22 +178,22 @@ - (id)sendWithError:(out NSError **)error { if (!(considsAndIgnoresFlags && kAECaseConsiderMask)) [ignoreListDesc insertDescriptor: [NSAppleEventDescriptor descriptorWithEnumCode: kAECase] atIndex: 0]; - if (considsAndIgnoresFlags && kAEDiacriticIgnoreMask) + if (considsAndIgnoresFlags & kAEDiacriticIgnoreMask) [ignoreListDesc insertDescriptor: [NSAppleEventDescriptor descriptorWithEnumCode: kAEDiacritic] atIndex: 0]; - if (considsAndIgnoresFlags && kAEWhiteSpaceIgnoreMask) + if (considsAndIgnoresFlags & kAEWhiteSpaceIgnoreMask) [ignoreListDesc insertDescriptor: [NSAppleEventDescriptor descriptorWithEnumCode: kAEWhiteSpace] atIndex: 0]; - if (considsAndIgnoresFlags && kAEHyphensIgnoreMask) + if (considsAndIgnoresFlags & kAEHyphensIgnoreMask) [ignoreListDesc insertDescriptor: [NSAppleEventDescriptor descriptorWithEnumCode: kAEHyphens] atIndex: 0]; - if (considsAndIgnoresFlags && kAEExpansionIgnoreMask) + if (considsAndIgnoresFlags & kAEExpansionIgnoreMask) [ignoreListDesc insertDescriptor: [NSAppleEventDescriptor descriptorWithEnumCode: kAEExpansion] atIndex: 0]; - if (considsAndIgnoresFlags && kAEPunctuationIgnoreMask) + if (considsAndIgnoresFlags & kAEPunctuationIgnoreMask) [ignoreListDesc insertDescriptor: [NSAppleEventDescriptor descriptorWithEnumCode: kAEPunctuation] atIndex: 0]; - if (considsAndIgnoresFlags && kASNumericStringsIgnoreMask) + if (considsAndIgnoresFlags & kASNumericStringsIgnoreMask) [ignoreListDesc insertDescriptor: [NSAppleEventDescriptor descriptorWithEnumCode: kASNumericStrings] atIndex: 0]; [AS_event setAttribute: ignoreListDesc forKeyword: enumConsiderations]; @@ -285,7 +285,7 @@ - (NSString *)description { if (timeout != kAEDefaultTimeout) result = [NSString stringWithFormat: @"[%@ timeout: %i]", result, timeout / 60]; if (sendMode != (kAEWaitReply | kAECanSwitchLayer)) { - if (sendMode & ~(kAEWaitReply | kAEQueueReply | kAENoReply) == kAECanSwitchLayer) { + if ((sendMode & ~(kAEWaitReply | kAEQueueReply | kAENoReply)) == kAECanSwitchLayer) { if (sendMode & kAENoReply) result = [NSString stringWithFormat: @"[%@ ignoreReply]", result]; if (sendMode & kAEQueueReply) diff --git a/objc-appscript/trunk/src/Appscript/sendthreadsafe.c b/objc-appscript/trunk/src/Appscript/sendthreadsafe.c index fa4c183..8c89bc9 100644 --- a/objc-appscript/trunk/src/Appscript/sendthreadsafe.c +++ b/objc-appscript/trunk/src/Appscript/sendthreadsafe.c @@ -359,7 +359,7 @@ OSStatus AEMSendMessageThreadSafe( assert(eventPtr != NULL); assert(replyPtr != NULL); - if (sendMode && kAEWaitReply) { + if (sendMode & kAEWaitReply) { replyPort = MACH_PORT_NULL; // Set up the reply port if necessary.