From cc5070156f01d9272aa5873e57096203843b478e Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Mon, 11 Jan 2021 14:12:46 +0000 Subject: [PATCH] finger: Reduce default width of login name field. The default width of the login name field (the full "MAXLOGNAME", which is 32 characters) causes the default width of a line in the short print mode to exceed the default width of a terminal window (sadly, still 80 columns as we remain beholden to the Hollerith punched card). This reduces the default width to "MINLOGNAME", which is a constant that set to 12 characters. The longest login name in /etc/passwd as shipped on Dragonfly is 10 characters; probably very few people have login names beyond 12 characters, and those that do probably don't care about the output of "finger", so this seems like a reasonable default. Signed-off-by: Dan Cross --- usr.bin/finger/sprint.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/usr.bin/finger/sprint.c b/usr.bin/finger/sprint.c index 65eac98091..0c37d83525 100644 --- a/usr.bin/finger/sprint.c +++ b/usr.bin/finger/sprint.c @@ -75,9 +75,10 @@ sflag_print(void) * else * remote host */ +#define MINLOGNAME 12 #define MAXREALNAME 20 #define MAXHOSTNAME 17 /* in reality, hosts are never longer than 16 */ - (void)printf("%-*s %-*s%s %s\n", MAXLOGNAME, "Login", MAXREALNAME, + (void)printf("%-*s %-*s%s %s\n", MINLOGNAME, "Login", MAXREALNAME, "Name", " TTY Idle Login Time ", (gflag) ? "" : oflag ? "Office Phone" : "Where"); @@ -94,7 +95,7 @@ sflag_print(void) namelen = MAXREALNAME; if (w->info == LOGGEDIN && !w->writable) --namelen; /* leave space before `*' */ - (void)printf("%-*.*s %-*.*s", MAXLOGNAME, MAXLOGNAME, + (void)printf("%-*.*s %-*.*s", MINLOGNAME, MAXLOGNAME, pn->name, MAXREALNAME, namelen, pn->realname ? pn->realname : ""); if (!w->loginat) { -- 2.28.0