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: extract the non-parsing part from ParseDe...



details:   https://anonhg.NetBSD.org/src/rev/0137ca200850
branches:  trunk
changeset: 1029262:0137ca200850
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Dec 28 19:13:40 2021 +0000

description:
make: extract the non-parsing part from ParseDependencyTargets

No functional change.

diffstat:

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

diffs (88 lines):

diff -r fa6cb64af143 -r 0137ca200850 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Tue Dec 28 19:01:36 2021 +0000
+++ b/usr.bin/make/parse.c      Tue Dec 28 19:13:40 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.600 2021/12/28 19:01:36 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.601 2021/12/28 19:13:40 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.600 2021/12/28 19:01:36 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.601 2021/12/28 19:13:40 rillig Exp $");
 
 /* types and constants */
 
@@ -1377,6 +1377,27 @@
 }
 
 static bool
+ApplyDependencyTarget(char *name, char *nameEnd, ParseSpecial *inout_special,
+                     GNodeType *inout_targetAttr,
+                     SearchPathList **inout_paths)
+{
+       char savec = *nameEnd;
+       *nameEnd = '\0';
+
+       if (!ParseDependencyTarget(name, inout_special,
+           inout_targetAttr, inout_paths))
+               return false;
+
+       if (*inout_special == SP_NOT && *name != '\0')
+               ParseDependencyTargetMundane(name);
+       else if (*inout_special == SP_PATH && *name != '.' && *name != '\0')
+               Parse_Error(PARSE_WARNING, "Extra target (%s) ignored", name);
+
+       *nameEnd = savec;
+       return true;
+}
+
+static bool
 ParseDependencyTargets(char **inout_cp,
                       const char *lstart,
                       ParseSpecial *inout_special,
@@ -1385,7 +1406,6 @@
 {
        char *cp;
        char *tgt = *inout_cp;
-       char savec;
 
        for (;;) {
                /* Find the end of the next word. */
@@ -1413,32 +1433,10 @@
                        return false;
                }
 
-               /* Insert a null terminator. */
-               savec = *cp;
-               *cp = '\0';
-
-               if (!ParseDependencyTarget(tgt, inout_special,
+               if (!ApplyDependencyTarget(tgt, cp, inout_special,
                    inout_targetAttr, inout_paths))
                        return false;
 
-               /*
-                * Have word in line. Get or create its node and stick it at
-                * the end of the targets list
-                */
-               if (*inout_special == SP_NOT && *tgt != '\0')
-                       ParseDependencyTargetMundane(tgt);
-               else if (*inout_special == SP_PATH && *tgt != '.' &&
-                        *tgt != '\0')
-                       Parse_Error(PARSE_WARNING, "Extra target (%s) ignored",
-                           tgt);
-
-               /* Don't need the inserted null terminator any more. */
-               *cp = savec;
-
-               /*
-                * If it is a special type and not .PATH, it's the only target
-                * we allow on this line.
-                */
                if (*inout_special != SP_NOT && *inout_special != SP_PATH)
                        ParseDependencyTargetExtraWarn(&cp, lstart);
                else



Home | Main Index | Thread Index | Old Index