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: replace Var_Value with Var_Exists where a...



details:   https://anonhg.NetBSD.org/src/rev/6857d0612df6
branches:  trunk
changeset: 359661:6857d0612df6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 15 19:34:07 2022 +0000

description:
make: replace Var_Value with Var_Exists where applicable

The latter function already existed in 1993, no idea why it was not
used.

No functional change.

diffstat:

 usr.bin/make/cond.c |   9 +++------
 usr.bin/make/main.c |  11 ++++-------
 usr.bin/make/meta.c |  21 ++++-----------------
 3 files changed, 11 insertions(+), 30 deletions(-)

diffs (110 lines):

diff -r fb3ba3ee9528 -r 6857d0612df6 usr.bin/make/cond.c
--- a/usr.bin/make/cond.c       Sat Jan 15 19:33:58 2022 +0000
+++ b/usr.bin/make/cond.c       Sat Jan 15 19:34:07 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cond.c,v 1.325 2022/01/14 18:25:22 rillig Exp $        */
+/*     $NetBSD: cond.c,v 1.326 2022/01/15 19:34:07 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -95,7 +95,7 @@
 #include "dir.h"
 
 /*     "@(#)cond.c     8.2 (Berkeley) 1/2/94"  */
-MAKE_RCSID("$NetBSD: cond.c,v 1.325 2022/01/14 18:25:22 rillig Exp $");
+MAKE_RCSID("$NetBSD: cond.c,v 1.326 2022/01/15 19:34:07 rillig Exp $");
 
 /*
  * Conditional expressions conform to this grammar:
@@ -290,10 +290,7 @@
 static bool
 FuncDefined(const char *var)
 {
-       FStr value = Var_Value(SCOPE_CMDLINE, var);
-       bool result = value.str != NULL;
-       FStr_Done(&value);
-       return result;
+       return Var_Exists(SCOPE_CMDLINE, var);
 }
 
 /* See if the given target is requested to be made. */
diff -r fb3ba3ee9528 -r 6857d0612df6 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sat Jan 15 19:33:58 2022 +0000
+++ b/usr.bin/make/main.c       Sat Jan 15 19:34:07 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.571 2022/01/15 19:05:23 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.572 2022/01/15 19:34:07 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.571 2022/01/15 19:05:23 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.572 2022/01/15 19:34:07 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -1018,17 +1018,14 @@
 HandlePWD(const struct stat *curdir_st)
 {
        char *pwd;
-       FStr prefix, makeobjdir;
+       FStr makeobjdir;
        struct stat pwd_st;
 
        if (ignorePWD || (pwd = getenv("PWD")) == NULL)
                return;
 
-       prefix = Var_Value(SCOPE_CMDLINE, "MAKEOBJDIRPREFIX");
-       if (prefix.str != NULL) {
-               FStr_Done(&prefix);
+       if (Var_Exists(SCOPE_CMDLINE, "MAKEOBJDIRPREFIX"))
                return;
-       }
 
        makeobjdir = Var_Value(SCOPE_CMDLINE, "MAKEOBJDIR");
        if (makeobjdir.str != NULL && strchr(makeobjdir.str, '$') != NULL)
diff -r fb3ba3ee9528 -r 6857d0612df6 usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Sat Jan 15 19:33:58 2022 +0000
+++ b/usr.bin/make/meta.c       Sat Jan 15 19:34:07 2022 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.191 2022/01/15 19:05:23 rillig Exp $ */
+/*      $NetBSD: meta.c,v 1.192 2022/01/15 19:34:07 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -591,7 +591,6 @@
 {
     static bool once = false;
     const char *cp;
-    FStr value;
 
     useMeta = true;
     useFilemon = true;
@@ -648,21 +647,9 @@
     /*
      * We ignore any paths that match ${.MAKE.META.IGNORE_PATTERNS}
      */
-    value = Var_Value(SCOPE_GLOBAL, MAKE_META_IGNORE_PATTERNS);
-    if (value.str != NULL) {
-       metaIgnorePatterns = true;
-       FStr_Done(&value);
-    }
-    value = Var_Value(SCOPE_GLOBAL, MAKE_META_IGNORE_FILTER);
-    if (value.str != NULL) {
-       metaIgnoreFilter = true;
-       FStr_Done(&value);
-    }
-    value = Var_Value(SCOPE_GLOBAL, MAKE_META_CMP_FILTER);
-    if (value.str != NULL) {
-       metaCmpFilter = true;
-       FStr_Done(&value);
-    }
+    metaIgnorePatterns = Var_Exists(SCOPE_GLOBAL, MAKE_META_IGNORE_PATTERNS);
+    metaIgnoreFilter = Var_Exists(SCOPE_GLOBAL, MAKE_META_IGNORE_FILTER);
+    metaCmpFilter = Var_Exists(SCOPE_GLOBAL, MAKE_META_CMP_FILTER);
 }
 
 /*



Home | Main Index | Thread Index | Old Index