Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/make make: add missing newline after "cannot continu...



details:   https://anonhg.NetBSD.org/src/rev/740cad7dc6b2
branches:  trunk
changeset: 359788:740cad7dc6b2
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 22 18:59:23 2022 +0000

description:
make: add missing newline after "cannot continue" message

It was wrong of Parse_File to output an unfinished line and hope for
some other code to finish it.  As demonstrated in the test, PrintOnError
did not do that in the case of additional debug output.

To keep the overall behavior as close as possible to before, the other
callers of PrintOnError now have to pass the newline themselves. Passing
strings that start with newlines but don't end with them looked
suspicious anyway.

diffstat:

 usr.bin/make/compat.c                      |  10 +++++-----
 usr.bin/make/job.c                         |  14 +++++++-------
 usr.bin/make/main.c                        |  12 +++++-------
 usr.bin/make/parse.c                       |  10 +++++-----
 usr.bin/make/unit-tests/opt-debug-hash.exp |   6 +++---
 usr.bin/make/unit-tests/opt-debug-hash.mk  |   7 +++----
 6 files changed, 28 insertions(+), 31 deletions(-)

diffs (226 lines):

diff -r 526a5a3e6369 -r 740cad7dc6b2 usr.bin/make/compat.c
--- a/usr.bin/make/compat.c     Sat Jan 22 17:10:51 2022 +0000
+++ b/usr.bin/make/compat.c     Sat Jan 22 18:59:23 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat.c,v 1.237 2022/01/08 09:53:44 rillig Exp $      */
+/*     $NetBSD: compat.c,v 1.238 2022/01/22 18:59:23 rillig Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -96,7 +96,7 @@
 #include "pathnames.h"
 
 /*     "@(#)compat.c   8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: compat.c,v 1.237 2022/01/08 09:53:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.238 2022/01/22 18:59:23 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
@@ -583,7 +583,7 @@
        } else if (opts.keepgoing) {
                pgn->flags.remake = false;
        } else {
-               PrintOnError(gn, "\nStop.");
+               PrintOnError(gn, "\nStop.\n");
                exit(1);
        }
        return true;
@@ -671,7 +671,7 @@
 
        Compat_Make(gn, gn);
        if (GNode_IsError(gn)) {
-               PrintOnError(gn, "\nStop.");
+               PrintOnError(gn, "\nStop.\n");
                exit(1);
        }
 }
@@ -748,7 +748,7 @@
                        Targ_PrintGraph(2);
                else if (DEBUG(GRAPH3))
                        Targ_PrintGraph(3);
-               PrintOnError(errorNode, "\nStop.");
+               PrintOnError(errorNode, "\nStop.\n");
                exit(1);
        }
 }
diff -r 526a5a3e6369 -r 740cad7dc6b2 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Sat Jan 22 17:10:51 2022 +0000
+++ b/usr.bin/make/job.c        Sat Jan 22 18:59:23 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.448 2022/01/08 09:53:44 rillig Exp $ */
+/*     $NetBSD: job.c,v 1.449 2022/01/22 18:59:23 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -142,7 +142,7 @@
 #include "trace.h"
 
 /*     "@(#)job.c      8.2 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: job.c,v 1.448 2022/01/08 09:53:44 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.449 2022/01/22 18:59:23 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -1108,7 +1108,7 @@
        else {
                if (deleteOnError)
                        JobDeleteTarget(job->node);
-               PrintOnError(job->node, NULL);
+               PrintOnError(job->node, "\n");
        }
 }
 
@@ -1685,7 +1685,7 @@
                 * also dead...
                 */
                if (!cmdsOK) {
-                       PrintOnError(gn, NULL); /* provide some clue */
+                       PrintOnError(gn, "\n"); /* provide some clue */
                        DieHorribly();
                }
        } else if (((gn->type & OP_MAKE) && !opts.noRecursiveExecute) ||
@@ -1702,7 +1702,7 @@
                 * also dead...
                 */
                if (!cmdsOK) {
-                       PrintOnError(gn, NULL); /* provide some clue */
+                       PrintOnError(gn, "\n"); /* provide some clue */
                        DieHorribly();
                }
 
@@ -1986,7 +1986,7 @@
        Compat_Make(targ, targ);
        /* XXX: Replace with GNode_IsError(gn) */
        if (targ->made == ERROR) {
-               PrintOnError(targ, "\n\nStop.");
+               PrintOnError(targ, "\n\nStop.\n");
                exit(1);
        }
 #endif
@@ -2951,7 +2951,7 @@
        JobRun(gn);
        /* XXX: Replace with GNode_IsError(gn) */
        if (gn->made == ERROR) {
-               PrintOnError(gn, "\n\nStop.");
+               PrintOnError(gn, "\n\nStop.\n");
                exit(1);
        }
        return true;
diff -r 526a5a3e6369 -r 740cad7dc6b2 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sat Jan 22 17:10:51 2022 +0000
+++ b/usr.bin/make/main.c       Sat Jan 22 18:59:23 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.574 2022/01/22 16:24:45 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.575 2022/01/22 18:59:23 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.574 2022/01/22 16:24:45 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.575 2022/01/22 18:59:23 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -1829,7 +1829,7 @@
        (void)fprintf(stderr, "\n");
        (void)fflush(stderr);
 
-       PrintOnError(NULL, NULL);
+       PrintOnError(NULL, "\n");
 
        if (DEBUG(GRAPH2) || DEBUG(GRAPH3))
                Targ_PrintGraph(2);
@@ -1854,7 +1854,7 @@
        (void)fprintf(stderr, "\n");
        (void)fflush(stderr);
 
-       PrintOnError(NULL, NULL);
+       PrintOnError(NULL, "\n");
 
        DieHorribly();
 }
@@ -2045,9 +2045,7 @@
        if (errorNode != NULL)
                return;         /* we've been here! */
 
-       if (msg != NULL)
-               printf("%s", msg);
-       printf("\n%s: stopped in %s\n", progname, curdir);
+       printf("%s%s: stopped in %s\n", msg, progname, curdir);
 
        /* we generally want to keep quiet if a sub-make died */
        if (shouldDieQuietly(gn, -1))
diff -r 526a5a3e6369 -r 740cad7dc6b2 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sat Jan 22 17:10:51 2022 +0000
+++ b/usr.bin/make/parse.c      Sat Jan 22 18:59:23 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.654 2022/01/22 16:24:45 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.655 2022/01/22 18:59:23 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -106,7 +106,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.654 2022/01/22 16:24:45 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.655 2022/01/22 18:59:23 rillig Exp $");
 
 /*
  * A file being read.
@@ -548,7 +548,7 @@
        free(xmsg);
 
        if (level == PARSE_FATAL) {
-               PrintOnError(NULL, NULL);
+               PrintOnError(NULL, "\n");
                exit(1);
        }
 }
@@ -2850,9 +2850,9 @@
        if (parseErrors != 0) {
                (void)fflush(stdout);
                (void)fprintf(stderr,
-                   "%s: Fatal errors encountered -- cannot continue",
+                   "%s: Fatal errors encountered -- cannot continue\n",
                    progname);
-               PrintOnError(NULL, NULL);
+               PrintOnError(NULL, "");
                exit(1);
        }
 }
diff -r 526a5a3e6369 -r 740cad7dc6b2 usr.bin/make/unit-tests/opt-debug-hash.exp
--- a/usr.bin/make/unit-tests/opt-debug-hash.exp        Sat Jan 22 17:10:51 2022 +0000
+++ b/usr.bin/make/unit-tests/opt-debug-hash.exp        Sat Jan 22 18:59:23 2022 +0000
@@ -1,6 +1,6 @@
-make: "opt-debug-hash.mk" line 9: Missing argument for ".error"
-make: Fatal errors encountered -- cannot continueHashTable targets: size=16 numEntries=0 maxchain=0
+make: "opt-debug-hash.mk" line 11: Missing argument for ".error"
+make: Fatal errors encountered -- cannot continue
+HashTable targets: size=16 numEntries=0 maxchain=0
 HashTable Global variables: size=16 numEntries=23 maxchain=3
-
 make: stopped in unit-tests
 exit status 1
diff -r 526a5a3e6369 -r 740cad7dc6b2 usr.bin/make/unit-tests/opt-debug-hash.mk
--- a/usr.bin/make/unit-tests/opt-debug-hash.mk Sat Jan 22 17:10:51 2022 +0000
+++ b/usr.bin/make/unit-tests/opt-debug-hash.mk Sat Jan 22 18:59:23 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: opt-debug-hash.mk,v 1.2 2022/01/22 17:10:51 rillig Exp $
+# $NetBSD: opt-debug-hash.mk,v 1.3 2022/01/22 18:59:24 rillig Exp $
 #
 # Tests for the -dh command line option, which adds debug logging for
 # hash tables.  Even more detailed logging is available by compiling
@@ -6,7 +6,6 @@
 
 .MAKEFLAGS: -dh
 
+# Force a parse error, to demonstrate the newline character in the diagnostic
+# that had been missing before parse.c 1.655 from 2022-01-22.
 .error
-
-# FIXME: There is a newline missing between 'continueHashTable'.
-# expect: make: Fatal errors encountered -- cannot continueHashTable targets: size=16 numEntries=0 maxchain=0



Home | Main Index | Thread Index | Old Index