fix error checking file line count in last update

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36644 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2013-05-17 09:24:10 +00:00
parent 0902237bc3
commit 1dd336dba0
2 changed files with 14 additions and 11 deletions

View file

@ -1,3 +1,8 @@
2013-05-17 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSMessagePortNameServer.m: fix error in line count check
in last change.
2013-05-16 Ivan Vučica <ivan@vucica.net> 2013-05-16 Ivan Vučica <ivan@vucica.net>
* Source/GSLocale.m: * Source/GSLocale.m:

View file

@ -157,26 +157,24 @@ static void clean_up_names(void)
{ {
NSString *old = [path stringByAppendingPathComponent: file]; NSString *old = [path stringByAppendingPathComponent: file];
NSArray *lines; NSArray *lines;
NSString *line;
int opid;
lines = [[NSString stringWithContentsOfFile: old] lines = [[NSString stringWithContentsOfFile: old]
componentsSeparatedByString: @"\n"]; componentsSeparatedByString: @"\n"];
if ([lines count] == 2) if ([lines count] > 1
&& (opid = [(line = [lines objectAtIndex: 1]) intValue]) > 0)
{ {
NSString *opid = [lines objectAtIndex: 1]; if (YES == [line isEqual: pid])
if (YES == [opid isEqual: pid])
{ {
NSDebugMLLog(@"NSMessagePort", @"Removing old name %@", old); NSDebugMLLog(@"NSMessagePort", @"Removing old name %@", old);
[mgr removeFileAtPath: old handler: nil]; [mgr removeFileAtPath: old handler: nil];
} }
else if ([opid intValue] > 0) else if (NO == [NSProcessInfo _exists: opid])
{ {
if (NO == [NSProcessInfo _exists: [opid intValue]]) NSDebugMLLog(@"NSMessagePort",
{ @"Removing old name %@ for process %d", old, opid);
NSDebugMLLog(@"NSMessagePort", [mgr removeFileAtPath: old handler: nil];
@"Removing old name %@ for process %@", old, pid);
[mgr removeFileAtPath: old handler: nil];
}
} }
} }
else else