From: Adam M. <ama...@us...> - 2005-02-16 06:02:50
|
Update of /cvsroot/bibdesk/bibdesk In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22121 Modified Files: BibDocument.m BibTeXParser.h BibTeXParser.m Log Message: Save @strings with front matter if using the new parser. Appears to work with grosse-eric.bib. Index: BibTeXParser.h =================================================================== RCS file: /cvsroot/bibdesk/bibdesk/BibTeXParser.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** BibTeXParser.h 7 Feb 2005 03:13:57 -0000 1.13 --- BibTeXParser.h 16 Feb 2005 06:02:41 -0000 1.14 *************** *** 38,42 **** - (NSMutableArray *)itemsFromString:(NSString *)fullString error:(BOOL *)hadProblems frontMatter:(NSMutableString *)frontMatter filePath:(NSString *)filePath addToDocument:(BibDocument *)document; - (NSMutableArray *)itemsFromData:(NSData *)inData error:(BOOL *)hadProblems frontMatter:(NSMutableString *)frontMatter filePath:(NSString *)filePath; ! - (void)parseItemsFromString:(NSString *)fullString addToDocument:(BibDocument *)document; - (BibDocument *)document; - (void)setDocument:(BibDocument *)aDocument; --- 38,42 ---- - (NSMutableArray *)itemsFromString:(NSString *)fullString error:(BOOL *)hadProblems frontMatter:(NSMutableString *)frontMatter filePath:(NSString *)filePath addToDocument:(BibDocument *)document; - (NSMutableArray *)itemsFromData:(NSData *)inData error:(BOOL *)hadProblems frontMatter:(NSMutableString *)frontMatter filePath:(NSString *)filePath; ! - (void)parseItemsFromString:(NSString *)fullString addToDocument:(BibDocument *)document frontMatter:(NSMutableString *)frontMatter; - (BibDocument *)document; - (void)setDocument:(BibDocument *)aDocument; Index: BibDocument.m =================================================================== RCS file: /cvsroot/bibdesk/bibdesk/BibDocument.m,v retrieving revision 1.177 retrieving revision 1.178 diff -C2 -d -r1.177 -r1.178 *** BibDocument.m 15 Feb 2005 06:00:53 -0000 1.177 --- BibDocument.m 16 Feb 2005 06:02:40 -0000 1.178 *************** *** 1049,1053 **** NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; BibTeXParser *parser = [[BibTeXParser alloc] init]; ! [parser parseItemsFromString:fileContents addToDocument:self]; [parser release]; [pool release]; --- 1049,1053 ---- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; BibTeXParser *parser = [[BibTeXParser alloc] init]; ! [parser parseItemsFromString:fileContents addToDocument:self frontMatter:frontMatter]; [parser release]; [pool release]; Index: BibTeXParser.m =================================================================== RCS file: /cvsroot/bibdesk/bibdesk/BibTeXParser.m,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** BibTeXParser.m 14 Feb 2005 20:57:02 -0000 1.63 --- BibTeXParser.m 16 Feb 2005 06:02:41 -0000 1.64 *************** *** 82,88 **** } ! - (void)parseItemsFromString:(NSString *)fullString addToDocument:(BibDocument *)document{ BOOL hadProblems; ! [self itemsFromString:fullString error:&hadProblems frontMatter:nil filePath:[document fileName] addToDocument:document]; } --- 82,88 ---- } ! - (void)parseItemsFromString:(NSString *)fullString addToDocument:(BibDocument *)document frontMatter:(NSMutableString *)frontMatter{ BOOL hadProblems; ! [self itemsFromString:fullString error:&hadProblems frontMatter:frontMatter filePath:[document fileName] addToDocument:document]; } *************** *** 209,212 **** --- 209,213 ---- filePath:filePath hadProblems:&*hadProblems]]; + NSLog(@"frontMatter is %@", frontMatter); nextAtRange = [fullString rangeOfString:@"@" options:NSLiteralSearch range:SafeForwardSearchRange([scanner scanLocation], fullStringLength - [scanner scanLocation], fullStringLength)]; if(nextAtRange.location != NSNotFound){ *************** *** 468,471 **** --- 469,481 ---- } + #warning FIXME: macros + // temporary hack to save @string definitions along with frontmatter + NSEnumerator *stringEnum = [stringsDictionary keyEnumerator]; + NSString *theString = nil; + while(theString = [stringEnum nextObject]){ + [frontMatter appendFormat:@"@string{%@ = %@}\n\n", theString, [stringsDictionary objectForKey:theString]]; + } + // end @string hack + [bibItemArray retain]; // don't release this when we release the threadPool! *************** *** 494,499 **** value = [value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; ! if([[fullString substringWithRange:NSMakeRange([scanner scanLocation], 1)] isEqualToString:@"\""]) ! value = [value stringByTrimmingCharactersInSet:trimQuoteCharacterSet]; NSAssert( [scanner scanLocation] < range.location, @"Scanner scanned out of range!" ); --- 504,511 ---- value = [value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]; ! #warning FIXME: macros ! // not sure if the macro support will want these quoted or unquoted; in order to save them with the frontmatter, I'm leaving quotes for now, if they exist. ! // if([[fullString substringWithRange:NSMakeRange([scanner scanLocation], 1)] isEqualToString:@"\""]) ! // value = [value stringByTrimmingCharactersInSet:trimQuoteCharacterSet]; NSAssert( [scanner scanLocation] < range.location, @"Scanner scanned out of range!" ); |