From: Christiaan H. <ho...@us...> - 2006-02-28 08:30:17
|
Update of /cvsroot/bibdesk/bibdesk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15523 Modified Files: Tag: BR_1x BibAuthor.m Log Message: Remove newlines and collapse whitespaces before parsing the name, as this can give problems. Also check whether a first character has been found before adding it, as it can give range exceptions otherwise. Index: BibAuthor.m =================================================================== RCS file: /cvsroot/bibdesk/bibdesk/BibAuthor.m,v retrieving revision 1.36.2.48 retrieving revision 1.36.2.49 diff -C2 -d -r1.36.2.48 -r1.36.2.49 *** BibAuthor.m 22 Feb 2006 20:50:38 -0000 1.36.2.48 --- BibAuthor.m 28 Feb 2006 08:30:12 -0000 1.36.2.49 *************** *** 276,280 **** static inline NSString *firstLetterCharacterString(NSString *string) { ! return [string substringWithRange:[string rangeOfCharacterFromSet:[NSCharacterSet letterCharacterSet]]]; } --- 276,281 ---- static inline NSString *firstLetterCharacterString(NSString *string) { ! NSRange range = [string rangeOfCharacterFromSet:[NSCharacterSet letterCharacterSet]]; ! return (range.location != NSNotFound) ? [string substringWithRange:range] : nil; } *************** *** 284,290 **** NSEnumerator *e = [[self firstNames] objectEnumerator]; NSString *fragment = nil; while(fragment = [e nextObject]){ ! [abbrevName appendString:firstLetterCharacterString(fragment)]; ! [abbrevName appendString:@". "]; } --- 285,295 ---- NSEnumerator *e = [[self firstNames] objectEnumerator]; NSString *fragment = nil; + NSString *firstLetter = nil; while(fragment = [e nextObject]){ ! firstLetter = firstLetterCharacterString(fragment); ! if (firstLetter != nil) { ! [abbrevName appendString:firstLetter]; ! [abbrevName appendString:@". "]; ! } } *************** *** 410,413 **** --- 415,421 ---- NSString *tmpStr = nil; + // we need to remove newlines and collapse whitespace before using bt_split_name + newName = [newName fastStringByCollapsingWhitespaceAndNewlinesAndRemovingSurroundingWhitespaceAndNewlines]; + // pass the name as a UTF8 string, since btparse doesn't work with UniChars theName = bt_split_name((char *)[newName UTF8String],(char *)[newName UTF8String],0,0); |