Hi,

Make who(1) a tiny bit smarter and show more of the host part. Max
linewidth is 80.

        -Otto

Index: who.c
===================================================================
RCS file: /cvs/src/usr.bin/who/who.c,v
retrieving revision 1.18
diff -u -p -r1.18 who.c
--- who.c       27 Oct 2009 23:59:50 -0000      1.18
+++ who.c       10 Nov 2010 07:35:48 -0000
@@ -59,7 +59,9 @@ int show_labels;              /* show column labels 
 int show_quick;                        /* quick, names only */
 
 #define NAME_WIDTH     8
-#define HOST_WIDTH     32
+#define HOST_WIDTH     45
+
+int hostwidth = HOST_WIDTH;
 
 int
 main(int argc, char *argv[])
@@ -100,6 +102,11 @@ main(int argc, char *argv[])
        if (show_quick) {
                only_current_term = show_term = show_idle = show_labels = 0;
        }
+       
+       if (show_term)
+               hostwidth -= 2;
+       if (show_idle)
+               hostwidth -= 6;
 
        if (show_labels)
                output_labels();
@@ -245,7 +252,7 @@ output(struct utmp *up)
        }
        
        if (*up->ut_host)
-               printf("  (%.*s)", HOST_WIDTH, up->ut_host);
+               printf("  (%.*s)", hostwidth, up->ut_host);
        (void)putchar('\n');
 }
 
@@ -263,7 +270,7 @@ output_labels(void)
        if (show_idle)
                (void)printf("IDLE  ");
 
-       (void)printf("  %.*s", HOST_WIDTH, "FROM");
+       (void)printf("  %.*s", hostwidth, "FROM");
 
        (void)putchar('\n');
 }

Reply via email to