Fix w -n to really show numeric addresses, close PR 402

Partially submitted by: henrich@msu.edu (Charles Henrich)
This commit is contained in:
Andrey A. Chernov 1996-06-17 15:46:25 +00:00
parent 92f6d79189
commit 66b12529e6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=16436

View File

@ -323,6 +323,17 @@ main(argc, argv)
}
p = hp->h_name;
}
if (nflag && inet_addr(p) == INADDR_NONE) {
hp = gethostbyname(p);
if (hp != NULL) {
struct in_addr in;
memmove(&in, hp->h_addr, sizeof(in));
p = inet_ntoa(in);
} else
herror("gethostbyname");
}
if (x) {
(void)snprintf(buf, sizeof(buf), "%s:%.*s", p,
ep->utmp.ut_host + UT_HOSTSIZE - x, x);