Source-Changes-HG archive

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

[src/trunk]: src/sbin/dmesg Fix dmesg(8) to preserve leading whitespaces of k...



details:   https://anonhg.NetBSD.org/src/rev/b6bebdbe5029
branches:  trunk
changeset: 1006051:b6bebdbe5029
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Tue Dec 31 19:58:56 2019 +0000

description:
Fix dmesg(8) to preserve leading whitespaces of kernel messages.

Closes PR/54729.

diffstat:

 sbin/dmesg/dmesg.c |  12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diffs (55 lines):

diff -r 50596b3ca1dc -r b6bebdbe5029 sbin/dmesg/dmesg.c
--- a/sbin/dmesg/dmesg.c        Tue Dec 31 18:11:18 2019 +0000
+++ b/sbin/dmesg/dmesg.c        Tue Dec 31 19:58:56 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: dmesg.c,v 1.43 2019/06/04 11:59:05 kre Exp $   */
+/*     $NetBSD: dmesg.c,v 1.44 2019/12/31 19:58:56 tsutsui Exp $       */
 /*-
  * Copyright (c) 1991, 1993
  *     The Regents of the University of California.  All rights reserved.
@@ -38,7 +38,7 @@
 #if 0
 static char sccsid[] = "@(#)dmesg.c    8.1 (Berkeley) 6/5/93";
 #else
-__RCSID("$NetBSD: dmesg.c,v 1.43 2019/06/04 11:59:05 kre Exp $");
+__RCSID("$NetBSD: dmesg.c,v 1.44 2019/12/31 19:58:56 tsutsui Exp $");
 #endif
 #endif /* not lint */
 
@@ -157,7 +157,7 @@
        long nsec, fsec;
        int scale;
        int deltas, quiet, humantime;
-       bool frac;
+       bool frac, postts;
 
        static const int bmib[] = { CTL_KERN, KERN_BOOTTIME };
        size = sizeof(boottime);
@@ -262,6 +262,7 @@
         */
 #ifndef SMALL
        frac = false;
+       postts = false;
        scale = 0;
 #endif
        for (tstamp = 0, newl = 1, log = i = 0, p = bufdata + cur.msg_bufx;
@@ -310,6 +311,7 @@
                                ADDC(ch);
                                ADDC('\0');
                                tstamp = 0;
+                               postts = true;
                                sec = fsec = 0;
                                switch (sscanf(tbuf, "[%jd.%ld]", &sec, &fsec)){
                                case EOF:
@@ -375,8 +377,10 @@
                                continue;
 #endif
                        case ' ':
-                               if (!tstamp)
+                               if (!tstamp && postts) {
+                                       postts = false;
                                        continue;
+                               }
                                /*FALLTHROUGH*/
                        default:
 #ifndef SMALL



Home | Main Index | Thread Index | Old Index