Source-Changes-HG archive

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

[src/trunk]: src/bin/sh DEBUG mode only change - mostly to output when option...



details:   https://anonhg.NetBSD.org/src/rev/ec56ffe794d8
branches:  trunk
changeset: 824006:ec56ffe794d8
user:      kre <kre%NetBSD.org@localhost>
date:      Thu May 18 15:42:37 2017 +0000

description:
DEBUG mode only change - mostly to output when option to show shell
internal sub-process nesting is enabled, and very deep nesting levels exist.

NFC for anyone else.

diffstat:

 bin/sh/show.c |  25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diffs (60 lines):

diff -r 759dd072c425 -r ec56ffe794d8 bin/sh/show.c
--- a/bin/sh/show.c     Thu May 18 14:43:42 2017 +0000
+++ b/bin/sh/show.c     Thu May 18 15:42:37 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: show.c,v 1.40 2017/05/15 20:00:36 kre Exp $    */
+/*     $NetBSD: show.c,v 1.41 2017/05/18 15:42:37 kre Exp $    */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)show.c     8.3 (Berkeley) 5/4/95";
 #else
-__RCSID("$NetBSD: show.c,v 1.40 2017/05/15 20:00:36 kre Exp $");
+__RCSID("$NetBSD: show.c,v 1.41 2017/05/18 15:42:37 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -926,12 +926,18 @@
        char *p;
 
        if (DFlags & DBG_NEST) {
-               p = indent;
-               for (i = 0; i < 6; i++)
-                       *p++ = (i < ShNest) ? '#' : ' ';
-               while (i++ < ShNest && p < &indent[sizeof indent - 1])
-                       *p++ = '#';
-               *p = '\0';
+               if ((unsigned)ShNest >= sizeof indent - 1) {
+                       (void) snprintf(indent, sizeof indent,
+                           "### %*d ###", (int)(sizeof indent) - 9, ShNest);
+                       p = strchr(indent, '\0');
+               } else {
+                       p = indent;
+                       for (i = 0; i < 6; i++)
+                               *p++ = (i < ShNest) ? '#' : ' ';
+                       while (i++ < ShNest && p < &indent[sizeof indent - 1])
+                               *p++ = '#';
+                       *p = '\0';
+               }
        } else
                indent[0] = '\0';
 
@@ -941,8 +947,6 @@
                    i == tf->pid ? ':' : '=', indent);
                return p;
        } else if (DFlags & DBG_NEST) {
-               *p++ = '\t';
-               *p = '\0';
                (void) asprintf(&p, "%s\t", indent);
                return p;
        }
@@ -1112,6 +1116,7 @@
        if (argc == 1) {
                struct debug_flag *df;
 
+               out1fmt("Debug: %sabled.  Flags: ", debug ? "en" : "dis");
                for (df = debug_flags; df->label != '\0'; df++) {
                        if (df->flag & (df->flag - 1))
                                continue;



Home | Main Index | Thread Index | Old Index