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): remove constant parameter from MakeMode



details:   https://anonhg.NetBSD.org/src/rev/9ed29e4030c2
branches:  trunk
changeset: 958019:9ed29e4030c2
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Dec 20 14:39:46 2020 +0000

description:
make(1): remove constant parameter from MakeMode

diffstat:

 usr.bin/make/main.c    |  33 ++++++++++++++++-----------------
 usr.bin/make/nonints.h |   3 +--
 2 files changed, 17 insertions(+), 19 deletions(-)

diffs (91 lines):

diff -r 6c51225a1795 -r 9ed29e4030c2 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sun Dec 20 14:32:13 2020 +0000
+++ b/usr.bin/make/main.c       Sun Dec 20 14:39:46 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.499 2020/12/20 14:32:13 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.500 2020/12/20 14:39:46 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -109,7 +109,7 @@
 #include "trace.h"
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.499 2020/12/20 14:32:13 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.500 2020/12/20 14:39:46 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -807,33 +807,32 @@
 }
 #endif
 
-/*
- * Allow makefiles some control over the mode we run in.
- */
-void
-MakeMode(const char *mode)
+/* Allow makefiles some control over the mode we run in. */
+static void
+MakeMode(void)
 {
-       char *mode_freeIt = NULL;
+       FStr mode = FStr_InitRefer(NULL);
 
-       if (mode == NULL) {
+       if (mode.str == NULL) {
+               char *expanded;
                (void)Var_Subst("${" MAKE_MODE ":tl}",
-                   VAR_GLOBAL, VARE_WANTRES, &mode_freeIt);
+                   VAR_GLOBAL, VARE_WANTRES, &expanded);
                /* TODO: handle errors */
-               mode = mode_freeIt;
+               mode = FStr_InitOwn(expanded);
        }
 
-       if (mode[0] != '\0') {
-               if (strstr(mode, "compat")) {
+       if (mode.str[0] != '\0') {
+               if (strstr(mode.str, "compat")) {
                        opts.compatMake = TRUE;
                        forceJobs = FALSE;
                }
 #if USE_META
-               if (strstr(mode, "meta"))
-                       meta_mode_init(mode);
+               if (strstr(mode.str, "meta"))
+                       meta_mode_init(mode.str);
 #endif
        }
 
-       free(mode_freeIt);
+       FStr_Done(&mode);
 }
 
 static void
@@ -1546,7 +1545,7 @@
        if (enterFlagObj)
                printf("%s: Entering directory `%s'\n", progname, objdir);
 
-       MakeMode(NULL);
+       MakeMode();
 
        {
                FStr makeflags = Var_Value(MAKEFLAGS, VAR_GLOBAL);
diff -r 6c51225a1795 -r 9ed29e4030c2 usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Sun Dec 20 14:32:13 2020 +0000
+++ b/usr.bin/make/nonints.h    Sun Dec 20 14:39:46 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nonints.h,v 1.178 2020/12/20 14:32:13 rillig Exp $     */
+/*     $NetBSD: nonints.h,v 1.179 2020/12/20 14:39:46 rillig Exp $     */
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,6 @@
 
 /* main.c */
 void Main_ParseArgLine(const char *);
-void MakeMode(const char *);
 char *Cmd_Exec(const char *, const char **);
 void Error(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2);
 void Fatal(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD;



Home | Main Index | Thread Index | Old Index