Revision: 25170 http://sourceforge.net/p/bibdesk/svn/25170 Author: hofman Date: 2020-12-08 23:13:05 +0000 (Tue, 08 Dec 2020) Log Message: ----------- Only use logic from universal cite key for unique characters when using the universal cite key format
Modified Paths: -------------- trunk/bibdesk/BDSKFormatParser.m Modified: trunk/bibdesk/BDSKFormatParser.m =================================================================== --- trunk/bibdesk/BDSKFormatParser.m 2020-12-08 19:07:26 UTC (rev 25169) +++ trunk/bibdesk/BDSKFormatParser.m 2020-12-08 23:13:05 UTC (rev 25170) @@ -66,7 +66,8 @@ suffix:(NSString *)suffix forField:(NSString *)fieldName ofItem:(id <BDSKParseableItem>)pub - inFolder:(NSURL *)papersFolderURL; + inFolder:(NSURL *)papersFolderURL + isUniversal:(BOOL)isUniversal; + (BOOL)currentString:(NSString *)suggestion matchesString:(NSString *)baseStr @@ -813,7 +814,8 @@ suffix:uniqueSuffix forField:fieldName ofItem:pub - inFolder:resolvedPapersFolderURL]]; + inFolder:resolvedPapersFolderURL + isUniversal:[format isEqualToString:@"%a1:%Y%u2"]]]; } } @@ -829,7 +831,8 @@ suffix:(NSString *)suffix forField:(NSString *)fieldName ofItem:(id <BDSKParseableItem>)pub - inFolder:(NSURL *)papersFolderURL { + inFolder:(NSURL *)papersFolderURL + isUniversal:(BOOL)isUniversal { __block NSString *(^uniqueString)(char *, NSUInteger, NSUInteger) = ^NSString *(char *chars, NSUInteger count, NSUInteger i) { if (i < count) { @@ -862,7 +865,7 @@ if (number > 0) { // first try unique characters based on the hashed doi or title, to get a deterministic value // consistent with the unique cite key of Papers 2 and 3 - NSUInteger hash = hashedDOI([pub stringValueOfField:BDSKDoiString]); + NSUInteger hash = isUniversal ? hashedDOI([pub stringValueOfField:BDSKDoiString]) : NSNotFound; BOOL isTitle = NO; if (hash == NSNotFound) { hash = hashedTitle([pub title]); @@ -872,7 +875,7 @@ char chars[number + 1]; memset(chars, '\0', number + 1); while (n-- > 0) { - if (number == 1 || n > 0 || charRange.length != 26) + if (isUniversal == NO || n > 0) chars[n] = charRange.location + (hash % charRange.length); else if (isTitle) chars[n] = charRange.location + 19 + (hash % 4); 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