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(1): extract ParseLine_ShellCommand from Pa...



details:   https://anonhg.NetBSD.org/src/rev/994db4acf961
branches:  trunk
changeset: 939341:994db4acf961
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Sep 25 20:57:22 2020 +0000

description:
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.

diffstat:

 usr.bin/make/parse.c |  49 ++++++++++++++++++++++++++-----------------------
 1 files changed, 26 insertions(+), 23 deletions(-)

diffs (77 lines):

diff -r 3ddc412d55b4 -r 994db4acf961 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Fri Sep 25 20:48:23 2020 +0000
+++ b/usr.bin/make/parse.c      Fri Sep 25 20:57:22 2020 +0000
@@ -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 @@
     }
 }
 
+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 @@
                 */
                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;
            }
 



Home | Main Index | Thread Index | Old Index