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 handling of the -m option into...



details:   https://anonhg.NetBSD.org/src/rev/d93bdd8064f1
branches:  trunk
changeset: 940047:d93bdd8064f1
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Oct 01 23:20:48 2020 +0000

description:
make(1): extract handling of the -m option into separate function

diffstat:

 usr.bin/make/main.c |  36 +++++++++++++++++++++---------------
 1 files changed, 21 insertions(+), 15 deletions(-)

diffs (67 lines):

diff -r 7b0d4b6fd3cd -r d93bdd8064f1 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Thu Oct 01 23:14:07 2020 +0000
+++ b/usr.bin/make/main.c       Thu Oct 01 23:20:48 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.356 2020/10/01 23:14:07 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.357 2020/10/01 23:20:48 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #endif
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.356 2020/10/01 23:14:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.357 2020/10/01 23:20:48 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
  The Regents of the University of California.  All rights reserved.");
@@ -456,11 +456,27 @@
        maxJobTokens = maxJobs;
 }
 
+static void
+MainParseArgSysInc(const char *argvalue)
+{
+       char found_path[MAXPATHLEN + 1];
+
+       /* look for magic parent directory search string */
+       if (strncmp(".../", argvalue, 4) == 0) {
+               if (!Dir_FindHereOrAbove(curdir, argvalue + 4,
+                                        found_path, sizeof(found_path)))
+                       return;
+               (void)Dir_AddDir(sysIncPath, found_path);
+       } else {
+               (void)Dir_AddDir(sysIncPath, argvalue);
+       }
+       Var_Append(MAKEFLAGS, "-m", VAR_GLOBAL);
+       Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
+}
+
 static Boolean
 MainParseArg(char c, char *argvalue)
 {
-       char found_path[MAXPATHLEN + 1];        /* for searching for sys.mk */
-
        switch (c) {
        case '\0':
                break;
@@ -551,17 +567,7 @@
                break;
        case 'm':
                if (argvalue == NULL) return FALSE;
-               /* look for magic parent directory search string */
-               if (strncmp(".../", argvalue, 4) == 0) {
-                       if (!Dir_FindHereOrAbove(curdir, argvalue + 4,
-                           found_path, sizeof(found_path)))
-                               break;          /* nothing doing */
-                       (void)Dir_AddDir(sysIncPath, found_path);
-               } else {
-                       (void)Dir_AddDir(sysIncPath, argvalue);
-               }
-               Var_Append(MAKEFLAGS, "-m", VAR_GLOBAL);
-               Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
+               MainParseArgSysInc(argvalue);
                break;
        case 'n':
                noExecute = TRUE;



Home | Main Index | Thread Index | Old Index