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): convert VarFind flags to typed enum



details:   https://anonhg.NetBSD.org/src/rev/5d913bb93b4e
branches:  trunk
changeset: 973958:5d913bb93b4e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 19 12:51:06 2020 +0000

description:
make(1): convert VarFind flags to typed enum

diffstat:

 usr.bin/make/var.c |  27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diffs (82 lines):

diff -r 562975fe8a7b -r 5d913bb93b4e usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sun Jul 19 12:35:30 2020 +0000
+++ b/usr.bin/make/var.c        Sun Jul 19 12:51:06 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.259 2020/07/19 12:26:17 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.260 2020/07/19 12:51:06 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.259 2020/07/19 12:26:17 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.260 2020/07/19 12:51:06 rillig Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c      8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.259 2020/07/19 12:26:17 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.260 2020/07/19 12:51:06 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -189,9 +189,11 @@
 GNode          *VAR_GLOBAL;    /* variables from the makefile */
 GNode          *VAR_CMD;       /* variables defined on the command-line */
 
-#define FIND_CMD       0x1     /* look in VAR_CMD when searching */
-#define FIND_GLOBAL    0x2     /* look in VAR_GLOBAL as well */
-#define FIND_ENV       0x4     /* look in the environment also */
+typedef enum {
+    FIND_CMD           = 0x01, /* look in VAR_CMD when searching */
+    FIND_GLOBAL                = 0x02, /* look in VAR_GLOBAL as well */
+    FIND_ENV           = 0x04  /* look in the environment also */
+} VarFindFlags;
 
 typedef enum {
     VAR_IN_USE         = 0x01, /* Variable's value is currently being used.
@@ -311,10 +313,9 @@
  * Input:
  *     name            name to find
  *     ctxt            context in which to find it
- *     flags           FIND_GLOBAL set means to look in the
- *                     VAR_GLOBAL context as well. FIND_CMD set means
- *                     to look in the VAR_CMD context also. FIND_ENV
- *                     set means to look in the environment
+ *     flags           FIND_GLOBAL     look in VAR_GLOBAL as well
+ *                     FIND_CMD        look in VAR_CMD as well
+ *                     FIND_ENV        look in the environment as well
  *
  * Results:
  *     A pointer to the structure describing the desired variable or
@@ -325,7 +326,7 @@
  *-----------------------------------------------------------------------
  */
 static Var *
-VarFind(const char *name, GNode *ctxt, int flags)
+VarFind(const char *name, GNode *ctxt, VarFindFlags flags)
 {
     Hash_Entry                 *var;
     Var                        *v;
@@ -1011,7 +1012,7 @@
        name = expanded_name;
     }
 
-    v = VarFind(name, ctxt, ctxt == VAR_GLOBAL ? (FIND_CMD|FIND_ENV) : 0);
+    v = VarFind(name, ctxt, ctxt == VAR_GLOBAL ? (FIND_CMD | FIND_ENV) : 0);
 
     if (v == NULL) {
        Var_Set(name, val, ctxt);
@@ -1064,7 +1065,7 @@
 
     if ((cp = strchr(name, '$')) != NULL)
        cp = Var_Subst(NULL, name, ctxt, VARE_WANTRES);
-    v = VarFind(cp ? cp : name, ctxt, FIND_CMD|FIND_GLOBAL|FIND_ENV);
+    v = VarFind(cp ? cp : name, ctxt, FIND_CMD | FIND_GLOBAL | FIND_ENV);
     free(cp);
     if (v == NULL)
        return FALSE;



Home | Main Index | Thread Index | Old Index