From owner-freebsd-audit Mon Jan 14 7:26:15 2002 Delivered-To: freebsd-audit@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id 711DC37B402 for ; Mon, 14 Jan 2002 07:25:56 -0800 (PST) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.6/8.11.2) id g0EFOsG49747; Mon, 14 Jan 2002 17:24:54 +0200 (EET) (envelope-from ru) Date: Mon, 14 Jan 2002 17:24:54 +0200 From: Ruslan Ermilov To: Giorgos Keramidas Cc: audit@FreeBSD.ORG Subject: Re: last with -y option Message-ID: <20020114172454.G21333@sunbay.com> References: <20020111232631.GA66629@hades.hell.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020111232631.GA66629@hades.hell.gr> User-Agent: Mutt/1.3.23i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sat, Jan 12, 2002 at 01:26:31AM +0200, Giorgos Keramidas wrote: > The patch that was sent in PR bin/12982 does not apply to the > usr.bin/last (probably because our last was modified for WARNS=2 after > the patch was submitted), but I liked the idea that it describes. > > The attached patch adds a -y option to last that will print the year > too when listing wtmp records. It also removes a few EOL whitespaces > that I found while reading the last.c source. > > If this does not break any standards, and you don't think that it > breaks last(1) in some way, I'll have to find myself an src/ committer > to take care of this PR :-) > There're two functional and style bugs in your patch, see below. > Index: last.1 [...] > @@ -162,4 +163,6 @@ > Widen the duration field to show seconds, as well as the > default days, hours and minutes. > +.It Fl w > +Report years too in the login session duration. > .El > .Pp This should yield -y not -w. > Index: last.c [...] > @@ -246,13 +250,22 @@ > /* > * don't print shutdown/reboot entries > - * unless flagged for > - */ > + * unless flagged for > + */ Please don't commit unrelated whitespace changes together with functional ones, commit them seperately. > if (!snaptime && want(bp)) { > t = int_to_time(bp->ut_time); > tm = localtime(&t); > - (void) strftime(ct, sizeof(ct), > - d_first ? "%a %e %b %R" : > - "%a %b %e %R", > - tm); > + if (yflag) { > + (void) strftime(ct, sizeof(ct), > + d_first > + ? "%a %e %b %Y %R" > + : "%a %b %e %Y %R", > + tm); > + } else { > + (void) strftime(ct, sizeof(ct), > + d_first > + ? "%a %e %b %Y %R" > + : "%a %b %e %Y %R", > + tm); > + } These two sub-blocks in the "if" clause are identical, meaning you have year printed unconditionally for startup/shutdown events. > @@ -293,5 +315,5 @@ > if (!strncmp(tt->tty, bp->ut_line, UT_LINESIZE)) > break; > - > + > if (tt == NULL) { > /* add new one */ Garbage. > @@ -303,5 +325,5 @@ > LIST_INSERT_HEAD(&ttylist, tt, list); > } > - > + > /* > * print record if not in snapshot mode and wanted Ditto. > @@ -346,5 +375,5 @@ > delta = tt->logout - bp->ut_time; > if ( sflag ) { > - printf(" (%8ld)\n", > + printf(" (%8ld)\n", > (long)delta); > } else { Ditto. Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message