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: simplify MakeMode



details:   https://anonhg.NetBSD.org/src/rev/06d5e4863317
branches:  trunk
changeset: 959132:06d5e4863317
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Feb 01 19:53:31 2021 +0000

description:
make: simplify MakeMode

diffstat:

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

diffs (55 lines):

diff -r 0e2c6c18d749 -r 06d5e4863317 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Mon Feb 01 19:46:58 2021 +0000
+++ b/usr.bin/make/main.c       Mon Feb 01 19:53:31 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.523 2021/02/01 19:46:58 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.524 2021/02/01 19:53:31 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.523 2021/02/01 19:46:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.524 2021/02/01 19:53:31 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -816,28 +816,23 @@
 static void
 MakeMode(void)
 {
-       FStr mode = FStr_InitRefer(NULL);
+       char *mode;
 
-       if (mode.str == NULL) {
-               char *expanded;
-               (void)Var_Subst("${" MAKE_MODE ":tl}",
-                   VAR_GLOBAL, VARE_WANTRES, &expanded);
-               /* TODO: handle errors */
-               mode = FStr_InitOwn(expanded);
-       }
+       (void)Var_Subst("${" MAKE_MODE ":tl}", VAR_GLOBAL, VARE_WANTRES, &mode);
+       /* TODO: handle errors */
 
-       if (mode.str[0] != '\0') {
-               if (strstr(mode.str, "compat") != NULL) {
+       if (mode[0] != '\0') {
+               if (strstr(mode, "compat") != NULL) {
                        opts.compatMake = TRUE;
                        forceJobs = FALSE;
                }
 #if USE_META
-               if (strstr(mode.str, "meta") != NULL)
-                       meta_mode_init(mode.str);
+               if (strstr(mode, "meta") != NULL)
+                       meta_mode_init(mode);
 #endif
        }
 
-       FStr_Done(&mode);
+       free(mode);
 }
 
 static void



Home | Main Index | Thread Index | Old Index