hostsprint() reserves only 16 columns for IPs and prints one whitespace
too many afterwards:

        $ getent hosts 1.1.1.1 long 1111:2222:3333:4444:5555:6666:7777:8888
        1.1.1.1           one.one.one.one
        1111:2222:3333:4444:5555:6666:7777:8888 long
        1111:2222:3333:4444:5555:6666:7777:8888  long

This diff cranks it up to 39 as per hostsaddrinfo() and aligns nicely:

        $ ./obj/getent hosts 1.1.1.1 long 
1111:2222:3333:4444:5555:6666:7777:8888
        1.1.1.1                                 one.one.one.one
        1111:2222:3333:4444:5555:6666:7777:8888 long
        1111:2222:3333:4444:5555:6666:7777:8888 long

OK?

Index: getent.c
===================================================================
RCS file: /cvs/src/usr.bin/getent/getent.c,v
retrieving revision 1.18
diff -u -p -r1.18 getent.c
--- getent.c    25 Sep 2018 19:51:39 -0000      1.18
+++ getent.c    26 Sep 2018 13:48:49 -0000
@@ -225,7 +225,7 @@ hostsprint(const struct hostent *he)
 
        if (inet_ntop(he->h_addrtype, he->h_addr, buf, sizeof(buf)) == NULL)
                strlcpy(buf, "# unknown", sizeof(buf));
-       printfmtstrings(he->h_aliases, "  ", " ", "%-16s  %s", buf, he->h_name);
+       printfmtstrings(he->h_aliases, "  ", " ", "%-39s %s", buf, he->h_name);
 }
 static int
 hostsaddrinfo(const char *name)

Reply via email to