Skip to content

Commit 0c4498a

Browse files
committed
More host tweaks
1 parent 19a0a8d commit 0c4498a

3 files changed

Lines changed: 9 additions & 16 deletions

File tree

Source/NSHost.m

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -199,21 +199,10 @@ - (id) _initWithKey: (NSString*)key
199199
hints.ai_flags = AI_CANONNAME;
200200
hints.ai_family = AF_UNSPEC;
201201

202-
if ([key isEqualToString: myHostName()])
202+
if ([key isEqualToString: localHostName])
203203
{
204-
[addresses addObject: @"127.0.0.1"];
205-
#if defined(AF_INET6)
206-
[addresses addObject: @"::1"];
207-
#endif
208-
[names addObject: @"localhost"];
209-
}
210-
else if ([key isEqualToString: localHostName]
211-
|| [key isEqualToString: @"localhost"])
212-
{
213-
#if defined(AF_INET6)
214-
[addresses addObject: @"::1"];
215-
#endif
216-
ptr = "127.0.0.1";
204+
[addresses unionSet: [hostClass _localAddresses]];
205+
ptr = "localhost";
217206
}
218207

219208
err = getaddrinfo(ptr, 0, &hints, &entry);

Tests/base/NSHost/basic.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66

77
int main()
88
{
9-
NSAutoreleasePool *arp = [NSAutoreleasePool new];
10-
test_NSObject(@"NSHost",[NSArray arrayWithObject:[NSHost currentHost]]);
9+
NSAutoreleasePool *arp = [NSAutoreleasePool new];
10+
NSHost *h = [NSHost currentHost];
11+
12+
test_NSObject(@"NSHost", [NSArray arrayWithObject: h]);
13+
NSLog(@"%@", h);
1114
[arp release]; arp = nil;
1215
return 0;
1316
}

Tests/base/NSHost/create.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ int main()
1818
localh = [NSHost localHost];
1919
PASS(localh != nil && [localh isKindOfClass: [NSHost class]],
2020
"NSHost understands +localHost");
21+
NSLog(@"localHost: %@", localh);
2122
#else
2223
localh = current;
2324
#endif

0 commit comments

Comments
 (0)