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): rename getBoolean and s2Boolean



details:   https://anonhg.NetBSD.org/src/rev/13c87062e2ef
branches:  trunk
changeset: 942108:13c87062e2ef
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Nov 06 23:11:11 2020 +0000

description:
make(1): rename getBoolean and s2Boolean

diffstat:

 usr.bin/make/main.c                |  54 +++++++++++++++++++-------------------
 usr.bin/make/nonints.h             |   5 +--
 usr.bin/make/unit-tests/varmisc.mk |   4 +-
 usr.bin/make/var.c                 |   6 ++--
 4 files changed, 34 insertions(+), 35 deletions(-)

diffs (164 lines):

diff -r 2267e68d08a5 -r 13c87062e2ef usr.bin/make/main.c
--- a/usr.bin/make/main.c       Fri Nov 06 23:05:20 2020 +0000
+++ b/usr.bin/make/main.c       Fri Nov 06 23:11:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.431 2020/11/06 23:05:20 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.432 2020/11/06 23:11:11 rillig Exp $        */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -118,7 +118,7 @@
 #include "trace.h"
 
 /*     "@(#)main.c     8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.431 2020/11/06 23:05:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.432 2020/11/06 23:11:11 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -863,6 +863,28 @@
        }
 }
 
+/*
+ * Return a Boolean based on a variable.
+ *
+ * If the knob is not set, return the fallback.
+ * If set, anything that looks or smells like "No", "False", "Off", "0", etc.
+ * is FALSE, otherwise TRUE.
+ */
+static Boolean
+GetBooleanVar(const char *varname, Boolean fallback)
+{
+    char *expr = str_concat3("${", varname, ":U}");
+    char *value;
+    Boolean res;
+
+    (void)Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES, &value);
+    /* TODO: handle errors */
+    res = ParseBoolean(value, fallback);
+    free(value);
+    free(expr);
+    return res;
+}
+
 static void
 doPrintVars(void)
 {
@@ -874,7 +896,7 @@
        else if (opts.debugVflag)
                expandVars = FALSE;
        else
-               expandVars = getBoolean(".MAKE.EXPAND_VARIABLES", FALSE);
+               expandVars = GetBooleanVar(".MAKE.EXPAND_VARIABLES", FALSE);
 
        for (ln = opts.variables->first; ln != NULL; ln = ln->next) {
                const char *varname = ln->datum;
@@ -2037,7 +2059,7 @@
     static int quietly = -1;
 
     if (quietly < 0) {
-       if (DEBUG(JOB) || !getBoolean(".MAKE.DIE_QUIETLY", TRUE))
+       if (DEBUG(JOB) || !GetBooleanVar(".MAKE.DIE_QUIETLY", TRUE))
            quietly = 0;
        else if (bf >= 0)
            quietly = bf;
@@ -2192,7 +2214,7 @@
  * is FALSE, otherwise TRUE.
  */
 Boolean
-s2Boolean(const char *s, Boolean bf)
+ParseBoolean(const char *s, Boolean bf)
 {
     switch(s[0]) {
     case '\0':                 /* not set - the default wins */
@@ -2211,25 +2233,3 @@
     }
     return bf;
 }
-
-/*
- * Return a Boolean based on a variable.
- *
- * If the knob is not set, return the fallback.
- * If set, anything that looks or smells like "No", "False", "Off", "0", etc.
- * is FALSE, otherwise TRUE.
- */
-Boolean
-getBoolean(const char *varname, Boolean fallback)
-{
-    char *expr = str_concat3("${", varname, ":U}");
-    char *value;
-    Boolean res;
-
-    (void)Var_Subst(expr, VAR_GLOBAL, VARE_WANTRES, &value);
-    /* TODO: handle errors */
-    res = s2Boolean(value, fallback);
-    free(value);
-    free(expr);
-    return res;
-}
diff -r 2267e68d08a5 -r 13c87062e2ef usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h    Fri Nov 06 23:05:20 2020 +0000
+++ b/usr.bin/make/nonints.h    Fri Nov 06 23:11:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nonints.h,v 1.149 2020/11/01 00:24:57 rillig Exp $     */
+/*     $NetBSD: nonints.h,v 1.150 2020/11/06 23:11:11 rillig Exp $     */
 
 /*-
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -116,8 +116,7 @@
 int eunlink(const char *);
 void execDie(const char *, const char *);
 char *getTmpdir(void);
-Boolean s2Boolean(const char *, Boolean);
-Boolean getBoolean(const char *, Boolean);
+Boolean ParseBoolean(const char *, Boolean);
 char *cached_realpath(const char *, char *);
 
 /* parse.c */
diff -r 2267e68d08a5 -r 13c87062e2ef usr.bin/make/unit-tests/varmisc.mk
--- a/usr.bin/make/unit-tests/varmisc.mk        Fri Nov 06 23:05:20 2020 +0000
+++ b/usr.bin/make/unit-tests/varmisc.mk        Fri Nov 06 23:11:11 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmisc.mk,v 1.26 2020/10/24 08:50:17 rillig Exp $
+# $NetBSD: varmisc.mk,v 1.27 2020/11/06 23:11:11 rillig Exp $
 #
 # Miscellaneous variable tests.
 
@@ -87,7 +87,7 @@
 .if defined(VARNAME${:U2}) && !empty(VARNAME${:U2})
 .endif
 
-# begin .MAKE.SAVE_DOLLARS; see Var_Set_with_flags and s2Boolean.
+# begin .MAKE.SAVE_DOLLARS; see Var_Set_with_flags and ParseBoolean.
 SD_VALUES=     0 1 2 False True false true Yes No yes no On Off ON OFF on off
 SD_4_DOLLARS=  $$$$
 
diff -r 2267e68d08a5 -r 13c87062e2ef usr.bin/make/var.c
--- a/usr.bin/make/var.c        Fri Nov 06 23:05:20 2020 +0000
+++ b/usr.bin/make/var.c        Fri Nov 06 23:11:11 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.668 2020/11/06 00:29:50 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.669 2020/11/06 23:11:11 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -130,7 +130,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.668 2020/11/06 00:29:50 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.669 2020/11/06 23:11:11 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -854,7 +854,7 @@
        Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);
     }
     if (name[0] == '.' && strcmp(name, MAKE_SAVE_DOLLARS) == 0)
-       save_dollars = s2Boolean(val, save_dollars);
+       save_dollars = ParseBoolean(val, save_dollars);
 
 out:
     free(name_freeIt);



Home | Main Index | Thread Index | Old Index