Module Name: src
Committed By: rillig
Date: Sat Jan 22 18:59:24 UTC 2022
Modified Files:
src/usr.bin/make: compat.c job.c main.c parse.c
src/usr.bin/make/unit-tests: opt-debug-hash.exp opt-debug-hash.mk
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.237 -r1.238 src/usr.bin/make/compat.c
cvs rdiff -u -r1.448 -r1.449 src/usr.bin/make/job.c
cvs rdiff -u -r1.574 -r1.575 src/usr.bin/make/main.c
cvs rdiff -u -r1.654 -r1.655 src/usr.bin/make/parse.c
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/opt-debug-hash.exp \
src/usr.bin/make/unit-tests/opt-debug-hash.mk
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.237 src/usr.bin/make/compat.c:1.238
--- src/usr.bin/make/compat.c:1.237 Sat Jan 8 09:53:44 2022
+++ src/usr.bin/make/compat.c Sat Jan 22 18:59:23 2022
@@ -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 @@ MakeUnmade(GNode *gn, GNode *pgn)
} else if (opts.keepgoing) {
pgn->flags.remake = false;
} else {
- PrintOnError(gn, "\nStop.");
+ PrintOnError(gn, "\nStop.\n");
exit(1);
}
return true;
@@ -671,7 +671,7 @@ MakeBeginNode(void)
Compat_Make(gn, gn);
if (GNode_IsError(gn)) {
- PrintOnError(gn, "\nStop.");
+ PrintOnError(gn, "\nStop.\n");
exit(1);
}
}
@@ -748,7 +748,7 @@ Compat_Run(GNodeList *targs)
Targ_PrintGraph(2);
else if (DEBUG(GRAPH3))
Targ_PrintGraph(3);
- PrintOnError(errorNode, "\nStop.");
+ PrintOnError(errorNode, "\nStop.\n");
exit(1);
}
}
Index: src/usr.bin/make/job.c
diff -u src/usr.bin/make/job.c:1.448 src/usr.bin/make/job.c:1.449
--- src/usr.bin/make/job.c:1.448 Sat Jan 8 09:53:44 2022
+++ src/usr.bin/make/job.c Sat Jan 22 18:59:23 2022
@@ -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 @@ JobFinishDoneExitedError(Job *job, int *
else {
if (deleteOnError)
JobDeleteTarget(job->node);
- PrintOnError(job->node, NULL);
+ PrintOnError(job->node, "\n");
}
}
@@ -1685,7 +1685,7 @@ JobStart(GNode *gn, bool special)
* 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 @@ JobStart(GNode *gn, bool special)
* also dead...
*/
if (!cmdsOK) {
- PrintOnError(gn, NULL); /* provide some clue */
+ PrintOnError(gn, "\n"); /* provide some clue */
DieHorribly();
}
@@ -1986,7 +1986,7 @@ JobRun(GNode *targ)
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 @@ Job_RunTarget(const char *target, const
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;
Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.574 src/usr.bin/make/main.c:1.575
--- src/usr.bin/make/main.c:1.574 Sat Jan 22 16:24:45 2022
+++ src/usr.bin/make/main.c Sat Jan 22 18:59:23 2022
@@ -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 @@ Fatal(const char *fmt, ...)
(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 @@ Punt(const char *fmt, ...)
(void)fprintf(stderr, "\n");
(void)fflush(stderr);
- PrintOnError(NULL, NULL);
+ PrintOnError(NULL, "\n");
DieHorribly();
}
@@ -2045,9 +2045,7 @@ PrintOnError(GNode *gn, const char *msg)
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))
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.654 src/usr.bin/make/parse.c:1.655
--- src/usr.bin/make/parse.c:1.654 Sat Jan 22 16:24:45 2022
+++ src/usr.bin/make/parse.c Sat Jan 22 18:59:23 2022
@@ -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 @@ HandleMessage(ParseErrorLevel level, con
free(xmsg);
if (level == PARSE_FATAL) {
- PrintOnError(NULL, NULL);
+ PrintOnError(NULL, "\n");
exit(1);
}
}
@@ -2850,9 +2850,9 @@ Parse_File(const char *name, int fd)
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);
}
}
Index: src/usr.bin/make/unit-tests/opt-debug-hash.exp
diff -u src/usr.bin/make/unit-tests/opt-debug-hash.exp:1.2 src/usr.bin/make/unit-tests/opt-debug-hash.exp:1.3
--- src/usr.bin/make/unit-tests/opt-debug-hash.exp:1.2 Sat Jan 22 17:10:51 2022
+++ src/usr.bin/make/unit-tests/opt-debug-hash.exp Sat Jan 22 18:59:24 2022
@@ -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
Index: src/usr.bin/make/unit-tests/opt-debug-hash.mk
diff -u src/usr.bin/make/unit-tests/opt-debug-hash.mk:1.2 src/usr.bin/make/unit-tests/opt-debug-hash.mk:1.3
--- src/usr.bin/make/unit-tests/opt-debug-hash.mk:1.2 Sat Jan 22 17:10:51 2022
+++ src/usr.bin/make/unit-tests/opt-debug-hash.mk Sat Jan 22 18:59:24 2022
@@ -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