Revision: 22107 http://sourceforge.net/p/bibdesk/svn/22107 Author: hofman Date: 2018-03-07 16:02:35 +0000 (Wed, 07 Mar 2018) Log Message: ----------- No need to restrict search range to next match
Modified Paths: -------------- trunk/bibdesk/BDSKBibTeXWebParser.m trunk/bibdesk/BibItem.m trunk/bibdesk/NSString_BDSKExtensions.h trunk/bibdesk/NSString_BDSKExtensions.m Modified: trunk/bibdesk/BDSKBibTeXWebParser.m =================================================================== --- trunk/bibdesk/BDSKBibTeXWebParser.m 2018-03-07 15:58:25 UTC (rev 22106) +++ trunk/bibdesk/BDSKBibTeXWebParser.m 2018-03-07 16:02:35 UTC (rev 22107) @@ -68,12 +68,10 @@ for (i = 0; i < iMax; i++) { NSRange range = [[matches objectAtIndex:i] range]; - NSUInteger end = i + 1 == iMax ? [text length] : [[matches objectAtIndex:i + 1] range].location; - - end = [text indexOfRightBracketMatchingLeftBracketInRange:NSMakeRange(NSMaxRange(range) - 1, end - NSMaxRange(range) - 1)]; + NSUInteger closeLoc = [text indexOfRightBracketMatchingLeftBracketAtIndex:NSMaxRange(range) - 1]; - if (end != NSNotFound) { - NSString *string = [text substringWithRange:NSMakeRange(range.location, end + 1 - range.location)]; + if (closeLoc != NSNotFound) { + NSString *string = [text substringWithRange:NSMakeRange(range.location, closeLoc + 1 - range.location)]; NSError *error = nil; if ([BDSKBibTeXParser canParseString:string]) { Modified: trunk/bibdesk/BibItem.m =================================================================== --- trunk/bibdesk/BibItem.m 2018-03-07 15:58:25 UTC (rev 22106) +++ trunk/bibdesk/BibItem.m 2018-03-07 16:02:35 UTC (rev 22107) @@ -2645,7 +2645,7 @@ value = [value substringWithRange:NSMakeRange(5, [value length] - 6)]; } else if([value hasPrefix:@"\\href{"]){ // may also take the form \href{http://arXiv.org/abs/hep-th/0304033}{arXiv:hep-th/0304033} - NSUInteger loc = [value indexOfRightBracketMatchingLeftBracketInRange:NSMakeRange(5, [value length] - 5)]; + NSUInteger loc = [value indexOfRightBracketMatchingLeftBracketAtIndex:5]; if (NSNotFound != loc) value = [value substringWithRange:NSMakeRange(6, loc - 6)]; } Modified: trunk/bibdesk/NSString_BDSKExtensions.h =================================================================== --- trunk/bibdesk/NSString_BDSKExtensions.h 2018-03-07 15:58:25 UTC (rev 22106) +++ trunk/bibdesk/NSString_BDSKExtensions.h 2018-03-07 16:02:35 UTC (rev 22107) @@ -245,6 +245,8 @@ */ - (NSUInteger)indexOfRightBracketMatchingLeftBracketInRange:(NSRange)range; +- (NSUInteger)indexOfRightBracketMatchingLeftBracketAtIndex:(NSUInteger)startLoc; + /*! @method isStringTeXQuotingBalancedWithBraces:connected: @abstract Invoces isStringTeXQuotingBalancedWithBraces:connected:range: with the full range of the receiver. Modified: trunk/bibdesk/NSString_BDSKExtensions.m =================================================================== --- trunk/bibdesk/NSString_BDSKExtensions.m 2018-03-07 15:58:25 UTC (rev 22106) +++ trunk/bibdesk/NSString_BDSKExtensions.m 2018-03-07 16:02:35 UTC (rev 22107) @@ -457,6 +457,11 @@ return matchFound ? (NSUInteger)cnt : NSNotFound; } +- (NSUInteger)indexOfRightBracketMatchingLeftBracketAtIndex:(NSUInteger)startLoc +{ + return [self indexOfRightBracketMatchingLeftBracketInRange:NSMakeRange(startLoc, [self length] - startLoc)]; +} + - (BOOL)isStringTeXQuotingBalancedWithBraces:(BOOL)braces connected:(BOOL)connected{ return [self isStringTeXQuotingBalancedWithBraces:braces connected:connected range:NSMakeRange(0,[self length])]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit