Module Name: src
Committed By: rillig
Date: Fri Sep 25 20:57:22 UTC 2020
Modified Files:
src/usr.bin/make: parse.c
Log Message:
make(1): extract ParseLine_ShellCommand from Parse_File
Parsing a single shell command from a line does not belong in
Parse_File, its proper place is in Parse_Line. Having the whole
detailed code inline in Parse_File is even more confusing.
To generate a diff of this commit:
cvs rdiff -u -r1.325 -r1.326 src/usr.bin/make/parse.c
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/parse.c
diff -u src/usr.bin/make/parse.c:1.325 src/usr.bin/make/parse.c:1.326
--- src/usr.bin/make/parse.c:1.325 Fri Sep 25 20:48:23 2020
+++ src/usr.bin/make/parse.c Fri Sep 25 20:57:22 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.325 2020/09/25 20:48:23 rillig Exp $ */
+/* $NetBSD: parse.c,v 1.326 2020/09/25 20:57:22 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
#include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.325 2020/09/25 20:48:23 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.326 2020/09/25 20:57:22 rillig Exp $");
/* types and constants */
@@ -2887,6 +2887,29 @@ ParseFinishLine(void)
}
}
+static void
+ParseLine_ShellCommand(char *cp)
+{
+ for (; ch_isspace(*cp); cp++)
+ continue;
+
+ if (*cp != '\0') {
+ if (!inLine)
+ Parse_Error(PARSE_FATAL, "Unassociated shell command \"%s\"", cp);
+ /*
+ * So long as it's not a blank line and we're actually
+ * in a dependency spec, add the command to the list of
+ * commands of all targets in the dependency spec
+ */
+ if (targets) {
+ cp = bmake_strdup(cp);
+ Lst_ForEachUntil(targets, ParseAddCmd, cp);
+#ifdef CLEANUP
+ Lst_Append(targCmds, cp);
+#endif
+ }
+ }
+}
/* Parse a top-level makefile into its component parts, incorporating them
* into the global dependency graph.
@@ -2966,27 +2989,7 @@ Parse_File(const char *name, int fd)
*/
cp = line + 1;
shellCommand:
- for (; ch_isspace(*cp); cp++) {
- continue;
- }
- if (*cp) {
- if (!inLine)
- Parse_Error(PARSE_FATAL,
- "Unassociated shell command \"%s\"",
- cp);
- /*
- * So long as it's not a blank line and we're actually
- * in a dependency spec, add the command to the list of
- * commands of all targets in the dependency spec
- */
- if (targets) {
- cp = bmake_strdup(cp);
- Lst_ForEachUntil(targets, ParseAddCmd, cp);
-#ifdef CLEANUP
- Lst_Append(targCmds, cp);
-#endif
- }
- }
+ ParseLine_ShellCommand(cp);
continue;
}