diff options
author | ache <ache@FreeBSD.org> | 1996-06-17 15:46:25 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1996-06-17 15:46:25 +0000 |
commit | 0bf8c3c1dfff066f4f13acf55de550329be5b85f (patch) | |
tree | 87c8873fe85e1308ac1af17473d54a9df1655c28 /usr.bin/w/w.c | |
parent | 22927eddbd6fe69c5cd066c37dfb5a1a074d47c6 (diff) | |
download | FreeBSD-src-0bf8c3c1dfff066f4f13acf55de550329be5b85f.zip FreeBSD-src-0bf8c3c1dfff066f4f13acf55de550329be5b85f.tar.gz |
Fix w -n to really show numeric addresses, close PR 402
Partially submitted by: henrich@msu.edu (Charles Henrich)
Diffstat (limited to 'usr.bin/w/w.c')
-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); |