NetBSD Problem Report #45897

From taca@back-street.net  Tue Jan 31 14:42:00 2012
Return-Path: <taca@back-street.net>
Received: from mail.netbsd.org (unknown [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id 7BFE963B8C5
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 31 Jan 2012 14:42:00 +0000 (UTC)
Message-Id: <20120131144157.2908D158E6E@www.back-street.net>
Date: Tue, 31 Jan 2012 23:41:57 +0900 (JST)
From: taca@back-street.net
Reply-To: taca@back-street.net
To: gnats-bugs@gnats.NetBSD.org
Subject: lastcomm(1) displays a little bit wider line
X-Send-Pr-Version: 3.95

>Number:         45897
>Category:       bin
>Synopsis:       lastcomm(1) displays a little bit wider line
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Jan 31 14:45:00 +0000 2012
>Closed-Date:    Wed Feb 01 07:17:32 +0000 2012
>Last-Modified:  Wed Feb 01 07:17:32 +0000 2012
>Originator:     Takahiro Kambe
>Release:        NetBSD 5.99.60
>Organization:

>Environment:


System: NetBSD ns.back-street.net 5.99.60 NetBSD 5.99.60 (HPMICRO) #132: Mon Jan 16 12:48:13 JST 2012 taca@edge.back-street.net:/data/amd64/obj/sys/arch/amd64/compile/HPMICRO amd64
Architecture: x86_64
Machine: amd64
>Description:
	lastcomm(1) of NetBSD current displays a little bit wider line
	which exceeds 80-column.  It simply reflects changes of struct
	acct.

	It isn't a big problem when using window system, but it is very
	nasty under traditonal console.

>How-To-Repeat:
	Enable accounting and exeecute lastcomm(1).

>Fix:
	Here is sample fix which add "-l" option for full width display.

	I wish NetBSD 6.0 would not have this problem.

Index: lastcomm.c
===================================================================
RCS file: /cvs/src/usr.bin/lastcomm/lastcomm.c,v
retrieving revision 1.1.1.1
diff -u -u -r1.1.1.1 lastcomm.c
--- lastcomm.c	28 Dec 2011 04:55:02 -0000	1.1.1.1
+++ lastcomm.c	31 Jan 2012 12:04:38 -0000
@@ -79,16 +79,21 @@
 	off_t size;
 	time_t t;
 	double delta;
-	int ch;
+	int ch, lflag, lwidth;
 	const char *acctfile = _PATH_ACCT;

 	setprogname(argv[0]);
+	lflag = 0;
+	lwidth = -6;

-	while ((ch = getopt(argc, argv, "f:")) != -1)
+	while ((ch = getopt(argc, argv, "f:l")) != -1)
 		switch((char)ch) {
 		case 'f':
 			acctfile = optarg;
 			break;
+		case 'l':
+			lflag = 1;
+			break;
 		case '?':
 		default:
 			usage();
@@ -118,6 +123,7 @@
 	if (lseek(fileno(fp), size, SEEK_SET) == -1)
 		err(1, "%s", acctfile);

+	lwidth = (int)fldsiz(acct, ac_comm) - ((lflag)? 0: 6);
 	for (;;) {
 		if (fread(&ab, sizeof(struct acct), 1, fp) != 1)
 			err(1, "%s", acctfile);
@@ -132,11 +138,12 @@
 					*p = '?';
 		if (!*argv || requested(argv, &ab)) {

+			if (!lflag)
+				ab.ac_comm[10] = '\0';
 			t = expand(ab.ac_utime) + expand(ab.ac_stime);
 			(void)printf(
 			    "%-*.*s %-7s %-*.*s %-*.*s %6.2f secs %.16s",
-			     (int)fldsiz(acct, ac_comm),
-			     (int)fldsiz(acct, ac_comm),
+			     lwidth, lwidth,
 			     ab.ac_comm, flagbits(ab.ac_flag),
 			     UT_NAMESIZE, UT_NAMESIZE,
 			     user_from_uid(ab.ac_uid, 0), UT_LINESIZE,



>Release-Note:

>Audit-Trail:

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/45897 CVS commit: src/usr.bin/lastcomm
Date: Tue, 31 Jan 2012 11:30:40 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Tue Jan 31 16:30:40 UTC 2012

 Modified Files:
 	src/usr.bin/lastcomm: lastcomm.1 lastcomm.c

 Log Message:
 PR/45897: Takahiro Kambe: Make default display < 80 characters and add -w flag
 to display unlimited


 To generate a diff of this commit:
 cvs rdiff -u -r1.11 -r1.12 src/usr.bin/lastcomm/lastcomm.1
 cvs rdiff -u -r1.21 -r1.22 src/usr.bin/lastcomm/lastcomm.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Tue, 31 Jan 2012 22:04:18 +0000
State-Changed-Why:
christos committed the fix, ok to close?


State-Changed-From-To: feedback->open
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Tue, 31 Jan 2012 22:11:12 +0000
State-Changed-Why:
Fix Submitter email


State-Changed-From-To: open->feedback
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Tue, 31 Jan 2012 22:11:26 +0000
State-Changed-Why:
and try again --fixed?


From: Takahiro Kambe <taca@back-street.net>
To: gnats-bugs@NetBSD.org, wiz@NetBSD.org
Cc: 
Subject: Re: bin/45897 (lastcomm(1) displays a little bit wider line)
Date: Wed, 01 Feb 2012 07:49:28 +0900 (JST)

 In message <20120131221128.5DA2263DEB3@www.NetBSD.org>
 	on Tue, 31 Jan 2012 22:11:28 +0000 (UTC),
 	wiz@NetBSD.org wrote:
 > Synopsis: lastcomm(1) displays a little bit wider line
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: wiz@NetBSD.org
 > State-Changed-When: Tue, 31 Jan 2012 22:11:26 +0000
 > State-Changed-Why:
 > and try again --fixed?
 Surely fixed!  Thanks much.

 -- 
 Takahiro Kambe <taca@back-street.net>

State-Changed-From-To: feedback->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Wed, 01 Feb 2012 07:17:32 +0000
State-Changed-Why:
confirmed fixed, thanks!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.