diff options
-rw-r--r-- | usr.bin/w/w.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index 924ba11..06c9d72 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -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); |