make(1): define constants for enum zero-values

This commit is contained in:
rillig 2020-12-05 18:38:02 +00:00
parent 865f9b84f3
commit ee9186d684
6 changed files with 50 additions and 45 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.491 2020/12/01 19:28:32 rillig Exp $ */ /* $NetBSD: main.c,v 1.492 2020/12/05 18:38:02 rillig Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990, 1993 * Copyright (c) 1988, 1989, 1990, 1993
@ -109,7 +109,7 @@
#include "trace.h" #include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: main.c,v 1.491 2020/12/01 19:28:32 rillig Exp $"); MAKE_RCSID("$NetBSD: main.c,v 1.492 2020/12/05 18:38:02 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint) #if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. " "The Regents of the University of California. "
@ -1121,7 +1121,7 @@ static void
CmdOpts_Init(void) CmdOpts_Init(void)
{ {
opts.compatMake = FALSE; /* No compat mode */ opts.compatMake = FALSE; /* No compat mode */
opts.debug = 0; /* No debug verbosity, please. */ opts.debug = DEBUG_NONE; /* No debug verbosity, please. */
/* opts.debug_file has been initialized earlier */ /* opts.debug_file has been initialized earlier */
opts.lint = FALSE; opts.lint = FALSE;
opts.debugVflag = FALSE; opts.debugVflag = FALSE;

View File

@ -1,4 +1,4 @@
/* $NetBSD: make.h,v 1.230 2020/11/29 09:27:40 rillig Exp $ */ /* $NetBSD: make.h,v 1.231 2020/12/05 18:38:02 rillig Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990, 1993 * Copyright (c) 1988, 1989, 1990, 1993
@ -322,6 +322,7 @@ typedef enum GNodeType {
} GNodeType; } GNodeType;
typedef enum GNodeFlags { typedef enum GNodeFlags {
GNF_NONE = 0,
/* this target needs to be (re)made */ /* this target needs to be (re)made */
REMAKE = 0x0001, REMAKE = 0x0001,
/* children of this target were made */ /* children of this target were made */

View File

@ -1,4 +1,4 @@
/* $NetBSD: parse.c,v 1.465 2020/12/05 18:15:40 rillig Exp $ */ /* $NetBSD: parse.c,v 1.466 2020/12/05 18:38:02 rillig Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990, 1993 * Copyright (c) 1988, 1989, 1990, 1993
@ -117,7 +117,7 @@
#include "pathnames.h" #include "pathnames.h"
/* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: parse.c,v 1.465 2020/12/05 18:15:40 rillig Exp $"); MAKE_RCSID("$NetBSD: parse.c,v 1.466 2020/12/05 18:38:02 rillig Exp $");
/* types and constants */ /* types and constants */
@ -299,50 +299,50 @@ static const struct {
ParseSpecial spec; /* Type when used as a target */ ParseSpecial spec; /* Type when used as a target */
GNodeType op; /* Operator when used as a source */ GNodeType op; /* Operator when used as a source */
} parseKeywords[] = { } parseKeywords[] = {
{ ".BEGIN", SP_BEGIN, 0 }, { ".BEGIN", SP_BEGIN, OP_NONE },
{ ".DEFAULT", SP_DEFAULT, 0 }, { ".DEFAULT", SP_DEFAULT, OP_NONE },
{ ".DELETE_ON_ERROR", SP_DELETE_ON_ERROR, 0 }, { ".DELETE_ON_ERROR", SP_DELETE_ON_ERROR, OP_NONE },
{ ".END", SP_END, 0 }, { ".END", SP_END, OP_NONE },
{ ".ERROR", SP_ERROR, 0 }, { ".ERROR", SP_ERROR, OP_NONE },
{ ".EXEC", SP_ATTRIBUTE, OP_EXEC }, { ".EXEC", SP_ATTRIBUTE, OP_EXEC },
{ ".IGNORE", SP_IGNORE, OP_IGNORE }, { ".IGNORE", SP_IGNORE, OP_IGNORE },
{ ".INCLUDES", SP_INCLUDES, 0 }, { ".INCLUDES", SP_INCLUDES, OP_NONE },
{ ".INTERRUPT", SP_INTERRUPT, 0 }, { ".INTERRUPT", SP_INTERRUPT, OP_NONE },
{ ".INVISIBLE", SP_ATTRIBUTE, OP_INVISIBLE }, { ".INVISIBLE", SP_ATTRIBUTE, OP_INVISIBLE },
{ ".JOIN", SP_ATTRIBUTE, OP_JOIN }, { ".JOIN", SP_ATTRIBUTE, OP_JOIN },
{ ".LIBS", SP_LIBS, 0 }, { ".LIBS", SP_LIBS, OP_NONE },
{ ".MADE", SP_ATTRIBUTE, OP_MADE }, { ".MADE", SP_ATTRIBUTE, OP_MADE },
{ ".MAIN", SP_MAIN, 0 }, { ".MAIN", SP_MAIN, OP_NONE },
{ ".MAKE", SP_ATTRIBUTE, OP_MAKE }, { ".MAKE", SP_ATTRIBUTE, OP_MAKE },
{ ".MAKEFLAGS", SP_MFLAGS, 0 }, { ".MAKEFLAGS", SP_MFLAGS, OP_NONE },
{ ".META", SP_META, OP_META }, { ".META", SP_META, OP_META },
{ ".MFLAGS", SP_MFLAGS, 0 }, { ".MFLAGS", SP_MFLAGS, OP_NONE },
{ ".NOMETA", SP_NOMETA, OP_NOMETA }, { ".NOMETA", SP_NOMETA, OP_NOMETA },
{ ".NOMETA_CMP", SP_NOMETA_CMP, OP_NOMETA_CMP }, { ".NOMETA_CMP", SP_NOMETA_CMP, OP_NOMETA_CMP },
{ ".NOPATH", SP_NOPATH, OP_NOPATH }, { ".NOPATH", SP_NOPATH, OP_NOPATH },
{ ".NOTMAIN", SP_ATTRIBUTE, OP_NOTMAIN }, { ".NOTMAIN", SP_ATTRIBUTE, OP_NOTMAIN },
{ ".NOTPARALLEL", SP_NOTPARALLEL, 0 }, { ".NOTPARALLEL", SP_NOTPARALLEL, OP_NONE },
{ ".NO_PARALLEL", SP_NOTPARALLEL, 0 }, { ".NO_PARALLEL", SP_NOTPARALLEL, OP_NONE },
{ ".NULL", SP_NULL, 0 }, { ".NULL", SP_NULL, OP_NONE },
{ ".OBJDIR", SP_OBJDIR, 0 }, { ".OBJDIR", SP_OBJDIR, OP_NONE },
{ ".OPTIONAL", SP_ATTRIBUTE, OP_OPTIONAL }, { ".OPTIONAL", SP_ATTRIBUTE, OP_OPTIONAL },
{ ".ORDER", SP_ORDER, 0 }, { ".ORDER", SP_ORDER, OP_NONE },
{ ".PARALLEL", SP_PARALLEL, 0 }, { ".PARALLEL", SP_PARALLEL, OP_NONE },
{ ".PATH", SP_PATH, 0 }, { ".PATH", SP_PATH, OP_NONE },
{ ".PHONY", SP_PHONY, OP_PHONY }, { ".PHONY", SP_PHONY, OP_PHONY },
#ifdef POSIX #ifdef POSIX
{ ".POSIX", SP_POSIX, 0 }, { ".POSIX", SP_POSIX, OP_NONE },
#endif #endif
{ ".PRECIOUS", SP_PRECIOUS, OP_PRECIOUS }, { ".PRECIOUS", SP_PRECIOUS, OP_PRECIOUS },
{ ".RECURSIVE", SP_ATTRIBUTE, OP_MAKE }, { ".RECURSIVE", SP_ATTRIBUTE, OP_MAKE },
{ ".SHELL", SP_SHELL, 0 }, { ".SHELL", SP_SHELL, OP_NONE },
{ ".SILENT", SP_SILENT, OP_SILENT }, { ".SILENT", SP_SILENT, OP_SILENT },
{ ".SINGLESHELL", SP_SINGLESHELL, 0 }, { ".SINGLESHELL", SP_SINGLESHELL, OP_NONE },
{ ".STALE", SP_STALE, 0 }, { ".STALE", SP_STALE, OP_NONE },
{ ".SUFFIXES", SP_SUFFIXES, 0 }, { ".SUFFIXES", SP_SUFFIXES, OP_NONE },
{ ".USE", SP_ATTRIBUTE, OP_USE }, { ".USE", SP_ATTRIBUTE, OP_USE },
{ ".USEBEFORE", SP_ATTRIBUTE, OP_USEBEFORE }, { ".USEBEFORE", SP_ATTRIBUTE, OP_USEBEFORE },
{ ".WAIT", SP_WAIT, 0 }, { ".WAIT", SP_WAIT, OP_NONE },
}; };
/* file loader */ /* file loader */

View File

@ -1,4 +1,4 @@
/* $NetBSD: suff.c,v 1.325 2020/12/05 17:12:02 rillig Exp $ */ /* $NetBSD: suff.c,v 1.326 2020/12/05 18:38:02 rillig Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990, 1993 * Copyright (c) 1988, 1989, 1990, 1993
@ -114,7 +114,7 @@
#include "dir.h" #include "dir.h"
/* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */ /* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */
MAKE_RCSID("$NetBSD: suff.c,v 1.325 2020/12/05 17:12:02 rillig Exp $"); MAKE_RCSID("$NetBSD: suff.c,v 1.326 2020/12/05 18:38:02 rillig Exp $");
#define SUFF_DEBUG0(text) DEBUG0(SUFF, text) #define SUFF_DEBUG0(text) DEBUG0(SUFF, text)
#define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1) #define SUFF_DEBUG1(fmt, arg1) DEBUG1(SUFF, fmt, arg1)
@ -146,6 +146,7 @@ static GNodeList transforms = LST_INIT;
static int sNum = 0; static int sNum = 0;
typedef enum SuffixFlags { typedef enum SuffixFlags {
SUFF_NONE = 0,
/* /*
* This suffix marks include files. Their search path ends up in the * This suffix marks include files. Their search path ends up in the
@ -475,7 +476,7 @@ Suffix_New(const char *name)
Lst_Init(&suff->parents); Lst_Init(&suff->parents);
Lst_Init(&suff->ref); Lst_Init(&suff->ref);
suff->sNum = sNum++; suff->sNum = sNum++;
suff->flags = 0; suff->flags = SUFF_NONE;
suff->refCount = 1; /* XXX: why 1? It's not assigned anywhere yet. */ suff->refCount = 1; /* XXX: why 1? It's not assigned anywhere yet. */
return suff; return suff;

View File

@ -1,4 +1,4 @@
/* $NetBSD: targ.c,v 1.151 2020/12/05 15:57:02 rillig Exp $ */ /* $NetBSD: targ.c,v 1.152 2020/12/05 18:38:02 rillig Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990, 1993 * Copyright (c) 1988, 1989, 1990, 1993
@ -119,7 +119,7 @@
#include "dir.h" #include "dir.h"
/* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */ /* "@(#)targ.c 8.2 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: targ.c,v 1.151 2020/12/05 15:57:02 rillig Exp $"); MAKE_RCSID("$NetBSD: targ.c,v 1.152 2020/12/05 18:38:02 rillig Exp $");
/* /*
* All target nodes that appeared on the left-hand side of one of the * All target nodes that appeared on the left-hand side of one of the
@ -192,8 +192,8 @@ GNode_New(const char *name)
gn->name = bmake_strdup(name); gn->name = bmake_strdup(name);
gn->uname = NULL; gn->uname = NULL;
gn->path = NULL; gn->path = NULL;
gn->type = name[0] == '-' && name[1] == 'l' ? OP_LIB : 0; gn->type = name[0] == '-' && name[1] == 'l' ? OP_LIB : OP_NONE;
gn->flags = 0; gn->flags = GNF_NONE;
gn->made = UNMADE; gn->made = UNMADE;
gn->unmade = 0; gn->unmade = 0;
gn->mtime = 0; gn->mtime = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: var.c,v 1.706 2020/12/05 18:15:40 rillig Exp $ */ /* $NetBSD: var.c,v 1.707 2020/12/05 18:38:02 rillig Exp $ */
/* /*
* Copyright (c) 1988, 1989, 1990, 1993 * Copyright (c) 1988, 1989, 1990, 1993
@ -130,7 +130,7 @@
#include "metachar.h" #include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
MAKE_RCSID("$NetBSD: var.c,v 1.706 2020/12/05 18:15:40 rillig Exp $"); MAKE_RCSID("$NetBSD: var.c,v 1.707 2020/12/05 18:38:02 rillig Exp $");
#define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1) #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
#define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2) #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@ -188,6 +188,7 @@ GNode *VAR_GLOBAL; /* variables from the makefile */
GNode *VAR_CMDLINE; /* variables defined on the command-line */ GNode *VAR_CMDLINE; /* variables defined on the command-line */
typedef enum VarFlags { typedef enum VarFlags {
VAR_NONE = 0,
/* /*
* The variable's value is currently being used by Var_Parse or * The variable's value is currently being used by Var_Parse or
@ -290,6 +291,7 @@ typedef enum VarExportFlags {
/* Flags for pattern matching in the :S and :C modifiers */ /* Flags for pattern matching in the :S and :C modifiers */
typedef enum VarPatternFlags { typedef enum VarPatternFlags {
VARP_NONE = 0,
/* Replace as often as possible ('g') */ /* Replace as often as possible ('g') */
VARP_SUB_GLOBAL = 1 << 0, VARP_SUB_GLOBAL = 1 << 0,
/* Replace only once ('1') */ /* Replace only once ('1') */
@ -461,7 +463,7 @@ VarAdd(const char *name, const char *val, GNode *ctxt, VarSetFlags flags)
{ {
HashEntry *he = HashTable_CreateEntry(&ctxt->vars, name, NULL); HashEntry *he = HashTable_CreateEntry(&ctxt->vars, name, NULL);
Var *v = VarNew(he->key /* aliased */, NULL, val, Var *v = VarNew(he->key /* aliased */, NULL, val,
flags & VAR_SET_READONLY ? VAR_READONLY : 0); flags & VAR_SET_READONLY ? VAR_READONLY : VAR_NONE);
HashEntry_Set(he, v); HashEntry_Set(he, v);
if (!(ctxt->flags & INTERNAL)) { if (!(ctxt->flags & INTERNAL)) {
VAR_DEBUG3("%s:%s = %s\n", ctxt->name, name, val); VAR_DEBUG3("%s:%s = %s\n", ctxt->name, name, val);
@ -659,7 +661,7 @@ Var_Export(const char *str, Boolean isExport)
if (isExport && strncmp(str, "-env", 4) == 0) { if (isExport && strncmp(str, "-env", 4) == 0) {
str += 4; str += 4;
flags = 0; flags = VAR_EXPORT_NORMAL;
} else if (isExport && strncmp(str, "-literal", 8) == 0) { } else if (isExport && strncmp(str, "-literal", 8) == 0) {
str += 8; str += 8;
flags = VAR_EXPORT_LITERAL; flags = VAR_EXPORT_LITERAL;
@ -1844,6 +1846,7 @@ VarStrftime(const char *fmt, Boolean zulu, time_t tim)
*/ */
typedef enum VarExprFlags { typedef enum VarExprFlags {
VEF_NONE = 0,
/* The variable expression is based on an undefined variable. */ /* The variable expression is based on an undefined variable. */
VEF_UNDEF = 0x01, VEF_UNDEF = 0x01,
/* /*
@ -2531,7 +2534,7 @@ ApplyModifier_Subst(const char **pp, ApplyModifiersState *st)
*pp += 2; *pp += 2;
args.pflags = 0; args.pflags = VARP_NONE;
args.matched = FALSE; args.matched = FALSE;
/* /*
@ -2612,7 +2615,7 @@ ApplyModifier_Regex(const char **pp, ApplyModifiersState *st)
return AMR_CLEANUP; return AMR_CLEANUP;
} }
args.pflags = 0; args.pflags = VARP_NONE;
args.matched = FALSE; args.matched = FALSE;
oneBigWord = st->oneBigWord; oneBigWord = st->oneBigWord;
for (;; (*pp)++) { for (;; (*pp)++) {
@ -3872,7 +3875,7 @@ ParseVarnameLong(
* is still undefined, Var_Parse will return an empty string * is still undefined, Var_Parse will return an empty string
* instead of the actually computed value. * instead of the actually computed value.
*/ */
v = VarNew(varname, varname, "", 0); v = VarNew(varname, varname, "", VAR_NONE);
*out_TRUE_exprFlags = VEF_UNDEF; *out_TRUE_exprFlags = VEF_UNDEF;
} else } else
free(varname); free(varname);
@ -3946,7 +3949,7 @@ Var_Parse(const char **pp, GNode *ctxt, VarEvalFlags eflags,
Var *v; Var *v;
char *value; char *value;
char eflags_str[VarEvalFlags_ToStringSize]; char eflags_str[VarEvalFlags_ToStringSize];
VarExprFlags exprFlags = 0; VarExprFlags exprFlags = VEF_NONE;
VAR_DEBUG2("Var_Parse: %s with %s\n", start, VAR_DEBUG2("Var_Parse: %s with %s\n", start,
Enum_FlagsToString(eflags_str, sizeof eflags_str, eflags, Enum_FlagsToString(eflags_str, sizeof eflags_str, eflags,