netstat -i: compute most field widths dynamically
The network and address fields were sometimes truncated for netstat -i
without -W, and often much too wide for netstat -i with the -W option.
Fields such as normal packet counts often overflowed. As a result,
columns didn't line up, and large white spaces made it harder to
follow a line across the display. Change the code to compute the
required field sizes for network, address, and various packet counts.
Hoist the code to format network and address into a subroutine that
can be called twice, once to measure the required field widths,
and once to emit the values. Use separate field widths for input
and output packets, byte counts, and error and drop counters.
These are left at defaults (the preceding values) with the -h
option, in which case the fields have a limited total width.
An extra space is included between the Network and Address, which
otherwise seemed too close.
Change the mention of -W with -i in the man page to say that most
field widths are computed dynamically in this case.
Reviewed by: sjg, glebius
Differential Revision: https://reviews.freebsd.org/D41160
(cherry picked from commit 372e3d561d82aba7a66fcd4ecb49a4d0a9f69345)