Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Nov 2002 01:30:02 -0800 (PST)
From:      Giorgos Keramidas <keramida@freebsd.org>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/44843: ipfw -t l doesn't align columns quite right
Message-ID:  <200211040930.gA49U2OI032426@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/44843; it has been noted by GNATS.

From: Giorgos Keramidas <keramida@freebsd.org>
To: Chris Pepper <pepper@reppep.com>
Cc: bug-followup@freebsd.org, Luigi Rizzo <luigi@freebsd.org>
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 <pepper@reppep.com> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200211040930.gA49U2OI032426>