From: Christiaan H. <ho...@us...> - 2005-07-02 09:19:26
|
Update of /cvsroot/bibdesk/bibdesk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6169 Modified Files: Tag: TRY_CMH_CROSSREF_BR_1x BDSKFindController.m Log Message: Check correct string for complex string validity. Restrict find/replace for macros: - find or replace as macro works on full strings only - non-macro find/replace does not replace in complex strings. We can be smarter for those, but at least this is safe. Index: BDSKFindController.m =================================================================== RCS file: /cvsroot/bibdesk/bibdesk/Attic/BDSKFindController.m,v retrieving revision 1.1.2.11 retrieving revision 1.1.2.12 diff -C2 -d -r1.1.2.11 -r1.1.2.12 *** BDSKFindController.m 25 Jun 2005 04:02:18 -0000 1.1.2.11 --- BDSKFindController.m 2 Jul 2005 09:19:17 -0000 1.1.2.12 *************** *** 179,183 **** NS_DURING ! compStr = [BDSKComplexString complexStringWithBibTeXString:[findTextField stringValue] macroResolver:nil]; NS_HANDLER if([[localException name] isEqualToString:BDSKComplexStringException]){ --- 179,183 ---- NS_DURING ! compStr = [BDSKComplexString complexStringWithBibTeXString:btstring macroResolver:nil]; NS_HANDLER if([[localException name] isEqualToString:BDSKComplexStringException]){ *************** *** 488,491 **** --- 488,492 ---- BOOL findAsMacro = [defaults boolForKey:BDSKFindControllerFindAsMacroKey]; BOOL replaceAsMacro = [defaults boolForKey:BDSKFindControllerReplaceAsMacroKey]; + NSRange range; while(bibItem = [pubE nextObject]){ *************** *** 497,504 **** if(findAsMacro) origStr = [origStr stringAsBibTeXString]; ! if(!isRegex){ // find and replace using NSMutableString methods ! if([origStr rangeOfString:findStr options:searchOpts].location != NSNotFound){ newStr = [origStr mutableCopy]; [newStr replaceOccurrencesOfString:findStr withString:replStr options:searchOpts range:NSMakeRange(0, [newStr length])]; --- 498,510 ---- if(findAsMacro) origStr = [origStr stringAsBibTeXString]; ! else if([origStr isComplex]) ! continue; // we don't want to replace the expanded value ! if(!isRegex){ // find and replace using NSMutableString methods ! range = [origStr rangeOfString:findStr options:searchOpts]; ! if(range.location != NSNotFound){ ! if(([origStr isComplex] || replaceAsMacro) && range.length < [origStr length]) ! continue; // replace only full macros newStr = [origStr mutableCopy]; [newStr replaceOccurrencesOfString:findStr withString:replStr options:searchOpts range:NSMakeRange(0, [newStr length])]; |