NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bin/45897: lastcomm(1) displays a little bit wider line



>Number:         45897
>Category:       bin
>Synopsis:       lastcomm(1) displays a little bit wider line
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Jan 31 14:45:00 +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@localhost:/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,



>Unformatted:
        
        



Home | Main Index | Thread Index | Old Index