fix bug whe comment extends over end of line

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36353 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2013-03-13 06:14:24 +00:00
parent d314f0f843
commit a727b0bd46

View file

@ -176,11 +176,16 @@ static NSString *parse_string(NSString **ptr)
{ {
l = [l substringFromIndex: 10]; l = [l substringFromIndex: 10];
pos = [l rangeOfString: @" */"].location; pos = [l rangeOfString: @" */"].location;
if (pos == NSNotFound) continue;
[se setComment: [l substringToIndex: pos]]; [se setComment: [l substringToIndex: pos]];
} }
else else
{ {
pos = [l rangeOfString: @"*/"].location; pos = [l rangeOfString: @"*/"].location;
if (pos == NSNotFound)
{
pos = [l length];
}
if ([user_comment length]) if ([user_comment length])
[user_comment appendString: @"\n"]; [user_comment appendString: @"\n"];
[user_comment appendString: [l substringToIndex: pos]]; [user_comment appendString: [l substringToIndex: pos]];
@ -202,14 +207,16 @@ static NSString *parse_string(NSString **ptr)
pos = [l rangeOfString: @"="].location; pos = [l rangeOfString: @"="].location;
if (pos == NSNotFound) if (pos == NSNotFound)
{ {
fprintf(stderr,"parse error in '%s', expecting '='\n",[filename cString]); fprintf(stderr,"parse error in '%s', expecting '='\n",
[filename cString]);
exit(1); exit(1);
} }
l = [l substringFromIndex: pos+1]; l = [l substringFromIndex: pos+1];
pos = [l rangeOfString: @"\""].location; pos = [l rangeOfString: @"\""].location;
if (pos == NSNotFound) if (pos == NSNotFound)
{ {
fprintf(stderr,"parse error in '%s', expecting second string\n",[filename cString]); fprintf(stderr,"parse error in '%s', expecting second string\n",
[filename cString]);
exit(1); exit(1);
} }
l = [l substringFromIndex: pos+1]; l = [l substringFromIndex: pos+1];
@ -218,7 +225,8 @@ static NSString *parse_string(NSString **ptr)
pos = [l rangeOfString: @"; "].location; pos = [l rangeOfString: @"; "].location;
if (pos == NSNotFound) if (pos == NSNotFound)
{ {
fprintf(stderr,"parse error in '%s', expecting ';'\n",[filename cString]); fprintf(stderr,"parse error in '%s', expecting '; '\n",
[filename cString]);
exit(1); exit(1);
} }
l = [l substringFromIndex: pos+1]; l = [l substringFromIndex: pos+1];
@ -236,8 +244,10 @@ static NSString *parse_string(NSString **ptr)
} }
} }
[update_list makeObjectsPerformSelector: @selector(setKey:) withObject: key]; [update_list makeObjectsPerformSelector: @selector(setKey:)
[update_list makeObjectsPerformSelector: @selector(setTranslated:) withObject: trans]; withObject: key];
[update_list makeObjectsPerformSelector: @selector(setTranslated:)
withObject: trans];
{ {
int i,c = [update_list count]; int i,c = [update_list count];
@ -507,7 +517,9 @@ static NSString *parse_string(NSString **ptr)
{ {
NSString *backupname = [filename stringByAppendingString: @"~"]; NSString *backupname = [filename stringByAppendingString: @"~"];
[[NSFileManager defaultManager] removeFileAtPath: backupname handler: nil]; [[NSFileManager defaultManager] removeFileAtPath: backupname handler: nil];
[[NSFileManager defaultManager] movePath: filename toPath: backupname handler: nil]; [[NSFileManager defaultManager] movePath: filename
toPath: backupname
handler: nil];
result = [str writeToFile: filename atomically: YES]; result = [str writeToFile: filename atomically: YES];
if (!result) if (!result)
@ -518,7 +530,8 @@ static NSString *parse_string(NSString **ptr)
DESTROY(un_list); DESTROY(un_list);
if (un_count) if (un_count)
fprintf(stderr,"'%s': %i untranslated or unmatched messages\n",[filename cString],un_count); fprintf(stderr,"'%s': %i untranslated or unmatched messages\n",
[filename cString],un_count);
return result; return result;
} }
@ -550,8 +563,8 @@ static NSString *parse_string(NSString **ptr)
if (([se flags] & FLAG_UNMATCHED) && [[se file] isEqual: [e file]]) if (([se flags] & FLAG_UNMATCHED) && [[se file] isEqual: [e file]])
{ {
if ((![se comment] && ![e comment]) || if ((![se comment] && ![e comment])
([[se comment] isEqual: [e comment]])) || ([[se comment] isEqual: [e comment]]))
{ {
[se setFlags: [se flags] & ~FLAG_UNMATCHED]; [se setFlags: [se flags] & ~FLAG_UNMATCHED];
[se setLine: [e line]]; [se setLine: [e line]];