From owner-freebsd-bugs Mon Nov 4 1:30: 5 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 809AC37B401 for ; Mon, 4 Nov 2002 01:30:03 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3882143E6E for ; Mon, 4 Nov 2002 01:30:03 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id gA49U3x3032427 for ; Mon, 4 Nov 2002 01:30:03 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id gA49U2OI032426; Mon, 4 Nov 2002 01:30:02 -0800 (PST) Date: Mon, 4 Nov 2002 01:30:02 -0800 (PST) Message-Id: <200211040930.gA49U2OI032426@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Giorgos Keramidas Subject: Re: kern/44843: ipfw -t l doesn't align columns quite right Reply-To: Giorgos Keramidas Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR kern/44843; it has been noted by GNATS. From: Giorgos Keramidas To: Chris Pepper Cc: bug-followup@freebsd.org, Luigi Rizzo Subject: Re: kern/44843: ipfw -t l doesn't align columns quite right Date: Mon, 4 Nov 2002 11:19:48 +0200 On 2002-11-01 22:46, Chris Pepper wrote: > "ipfw -t l" doesn't align columns very well. > [www:~] root# ipfw -t l > 00100 Fri Nov 1 22:40:38 2002 allow ip from any to any via lo0 > 00200 deny ip from any to 127.0.0.0/8 Can you try the following patch? It seems to fix the problem here. %%% Index: ipfw2.c =================================================================== RCS file: /home/ncvs/src/sbin/ipfw/ipfw2.c,v retrieving revision 1.14 diff -u -r1.14 ipfw2.c --- ipfw2.c 24 Oct 2002 18:04:44 -0000 1.14 +++ ipfw2.c 4 Nov 2002 03:58:37 -0000 @@ -810,6 +810,7 @@ int flags = 0; /* prerequisites */ ipfw_insn_log *logptr = NULL; /* set if we find an O_LOG */ int or_block = 0; /* we are in an or block */ + int twidth = 0; /* timestamp column width */ u_int32_t set_disable = rule->set_disable; @@ -825,15 +826,23 @@ printf("%10qu %10qu ", rule->pcnt, rule->bcnt); if (do_time) { + char timestr[30]; + + if (twidth == 0) { + time_t t = 0; + + strcpy(timestr, ctime(&t)); + *strchr(timestr, '\n') = '\0'; + twidth = strlen(timestr); + } if (rule->timestamp) { - char timestr[30]; time_t t = _long_to_time(rule->timestamp); strcpy(timestr, ctime(&t)); *strchr(timestr, '\n') = '\0'; printf("%s ", timestr); } else { - printf(" "); + printf("%*s ", twidth, " "); } } %%% To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message