Revision: 29075 http://sourceforge.net/p/bibdesk/svn/29075 Author: hofman Date: 2025-02-27 16:20:26 +0000 (Thu, 27 Feb 2025) Log Message: ----------- Compare author names case insensitively for fuzzy hash when matching names exactly
Modified Paths: -------------- trunk/bibdesk/BibAuthor.m trunk/bibdesk/BibDocument+Scripting.m Modified: trunk/bibdesk/BibAuthor.m =================================================================== --- trunk/bibdesk/BibAuthor.m 2025-02-27 10:20:01 UTC (rev 29074) +++ trunk/bibdesk/BibAuthor.m 2025-02-27 16:20:26 UTC (rev 29075) @@ -203,13 +203,17 @@ // fuzzy tries to match despite common omissions. // currently can't handle spelling errors. - (BOOL)fuzzyEqual:(BibAuthor *)otherAuth{ + // required for access to flags; could also raise an exception + BDSKASSERT([otherAuth isKindOfClass:[self class]]); + if (self == otherAuth) + return YES; + if (NO == [otherAuth isMemberOfClass:[self class]]) + return NO; + if (matchAuthorNamesExactly) - return [self isEqual:otherAuth]; + return CFStringCompare((__bridge CFStringRef)normalizedName, (__bridge CFStringRef)[otherAuth normalizedName], kCFCompareCaseInsensitive|kCFCompareLocalized) == kCFCompareEqualTo; - // required for access to flags; could also raise an exception - BDSKASSERT([otherAuth isKindOfClass:[self class]]); - // check to see if last names match; if not, we can return immediately if(CFStringCompare((__bridge CFStringRef)fuzzyName, (__bridge CFStringRef)otherAuth->fuzzyName, kCFCompareCaseInsensitive|kCFCompareLocalized) != kCFCompareEqualTo) return NO; @@ -223,7 +227,7 @@ - (NSUInteger)fuzzyHash{ if (matchAuthorNamesExactly) - return [self hash]; + return BDCaseInsensitiveStringHash((__bridge void *)normalizedName); // fuzzyEqual: is based on fuzzyName, so also hash must be based on that return BDCaseInsensitiveStringHash((__bridge void *)fuzzyName); } Modified: trunk/bibdesk/BibDocument+Scripting.m =================================================================== --- trunk/bibdesk/BibDocument+Scripting.m 2025-02-27 10:20:01 UTC (rev 29074) +++ trunk/bibdesk/BibDocument+Scripting.m 2025-02-27 16:20:26 UTC (rev 29075) @@ -478,9 +478,10 @@ if ([[parent key] isPersonField]) { if (fuzzyName == nil) fuzzyName = [NSString isEmptyString:name] ? [BibAuthor emptyAuthor] : [BibAuthor authorWithName:name]; - for (BDSKCategoryGroup *group in [parent categoryGroups]) + for (BDSKCategoryGroup *group in [parent categoryGroups]) { if ([[group name] fuzzyEqual:fuzzyName]) return group; + } } else { for (BDSKCategoryGroup *group in [parent categoryGroups]) if ([[group name] isCaseInsensitiveEqual:name]) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit