More host tweaks

This commit is contained in:
rfm 2025-05-27 14:11:54 +01:00
parent 19a0a8d10b
commit 0c4498a7cc
3 changed files with 9 additions and 16 deletions

View file

@ -199,21 +199,10 @@ myHostName()
hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_UNSPEC;
if ([key isEqualToString: myHostName()])
if ([key isEqualToString: localHostName])
{
[addresses addObject: @"127.0.0.1"];
#if defined(AF_INET6)
[addresses addObject: @"::1"];
#endif
[names addObject: @"localhost"];
}
else if ([key isEqualToString: localHostName]
|| [key isEqualToString: @"localhost"])
{
#if defined(AF_INET6)
[addresses addObject: @"::1"];
#endif
ptr = "127.0.0.1";
[addresses unionSet: [hostClass _localAddresses]];
ptr = "localhost";
}
err = getaddrinfo(ptr, 0, &hints, &entry);

View file

@ -6,8 +6,11 @@
int main()
{
NSAutoreleasePool *arp = [NSAutoreleasePool new];
test_NSObject(@"NSHost",[NSArray arrayWithObject:[NSHost currentHost]]);
NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSHost *h = [NSHost currentHost];
test_NSObject(@"NSHost", [NSArray arrayWithObject: h]);
NSLog(@"%@", h);
[arp release]; arp = nil;
return 0;
}

View file

@ -18,6 +18,7 @@ int main()
localh = [NSHost localHost];
PASS(localh != nil && [localh isKindOfClass: [NSHost class]],
"NSHost understands +localHost");
NSLog(@"localHost: %@", localh);
#else
localh = current;
#endif