#include "StringsDocument+ReadWrite.h" #include "StringsEntry.h" static NSString *parse_string(NSString **ptr) { NSString *str=*ptr; NSString *ret; int i,c; unichar ch; c=[str length]; for (i=0;i 0 ) m_sHeader = [l copy]; /* It's one of our banners, just ignore it. If it's the first one we put all comments so far in the global user comment. */ if (user_comment) { if (![user_comment isEqual: @""]) global_comment=[user_comment copy]; DESTROY(user_comment); } } else if ([l hasPrefix: @" File: "]) { se=[[StringsEntry alloc] init]; [se addFlag: [se flags]&~FLAG_UNMATCHED]; /* TODO: ? */ [update_list addObject: se]; [se release]; l=[l substringFromIndex: 7]; pos=[l rangeOfString: @":"].location; [se setFile: [l substringToIndex: pos]]; l=[l substringFromIndex: pos+1]; [se setLine: [l intValue]]; } else if ([l hasPrefix: @" Flag: untranslated */"]) [se addFlag: FLAG_UNTRANSLATED]; else if ([l hasPrefix: @" Flag: unmatched */"]) [se addFlag: FLAG_UNMATCHED]; /* this is essentially a noop */ else if ([l hasPrefix: @" Comment: "]) { l=[l substringFromIndex: 10]; pos=[l rangeOfString: @" */"].location; [se setComment: [l substringToIndex: pos]]; } else { pos=[l rangeOfString: @"*/"].location; if ([user_comment length]) [user_comment appendString: @"\n"]; [user_comment appendString: [l substringToIndex: pos]]; } pos=[l rangeOfString: @"*/"].location; if (pos==NSNotFound) continue; l=[l substringFromIndex: pos+2]; } while (1) { pos=[l rangeOfString: @"\""].location; if (pos==NSNotFound) break; l=[l substringFromIndex: pos+1]; key=parse_string(&l); pos=[l rangeOfString: @"="].location; if (pos==NSNotFound) { fprintf(stderr,"parse error in '%s', expecting '='\n",[[self fileName] cString]); return NO; } l=[l substringFromIndex: pos+1]; pos=[l rangeOfString: @"\""].location; if (pos==NSNotFound) { fprintf(stderr,"parse error in '%s', expecting second string\n",[[self fileName] cString]); return NO; } l=[l substringFromIndex: pos+1]; trans=parse_string(&l); pos=[l rangeOfString: @";"].location; if (pos==NSNotFound) { fprintf(stderr,"parse error in '%s', expecting ';'\n",[[self fileName] cString]); return NO; } l=[l substringFromIndex: pos+1]; if (![update_list count]) { /* we're probably parsing a file not created by us */ if (![dummy_entries objectForKey: key]) { se=[[StringsEntry alloc] init]; [se setFile: DUMMY]; [se setFlags: FLAG_UNMATCHED]; [update_list addObject: se]; [se release]; [dummy_entries setObject: se forKey: key]; } } [update_list makeObjectsPerformSelector: @selector(setKey:) withObject: key]; [update_list makeObjectsPerformSelector: @selector(setTranslated:) withObject: trans]; int i,c=[update_list count]; for (i=0;i