aboutsummaryrefslogtreecommitdiff
path: root/sbin/ipfw/ipfw2.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/ipfw/ipfw2.c')
-rw-r--r--sbin/ipfw/ipfw2.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index 145f2269bbce..e9ea0e10c954 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -804,6 +804,7 @@ show_prerequisites(int *flags, int want, int cmd)
static void
show_ipfw(struct ip_fw *rule)
{
+ static int twidth = 0;
int l;
ipfw_insn *cmd;
int proto = 0; /* default */
@@ -825,15 +826,22 @@ show_ipfw(struct ip_fw *rule)
printf("%10qu %10qu ", rule->pcnt, rule->bcnt);
if (do_time) {
+ char timestr[30];
+ time_t t = (time_t)0;
+
+ if (twidth == 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);
+ t = _long_to_time(rule->timestamp);
strcpy(timestr, ctime(&t));
*strchr(timestr, '\n') = '\0';
printf("%s ", timestr);
} else {
- printf(" ");
+ printf("%*s", twidth, " ");
}
}