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): use enum instead of #define for VarPat...
details: https://anonhg.NetBSD.org/src/rev/059794048349
branches: trunk
changeset: 973486:059794048349
user: rillig <rillig%NetBSD.org@localhost>
date: Thu Jul 02 15:26:21 2020 +0000
description:
make(1): use enum instead of #define for VarPattern flags
diffstat:
usr.bin/make/var.c | 47 ++++++++++++++++++++++++-----------------------
1 files changed, 24 insertions(+), 23 deletions(-)
diffs (116 lines):
diff -r f95c79d3d133 -r 059794048349 usr.bin/make/var.c
--- a/usr.bin/make/var.c Thu Jul 02 15:14:38 2020 +0000
+++ b/usr.bin/make/var.c Thu Jul 02 15:26:21 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.228 2020/07/02 15:14:38 rillig Exp $ */
+/* $NetBSD: var.c,v 1.229 2020/07/02 15:26:21 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.228 2020/07/02 15:14:38 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.229 2020/07/02 15:26:21 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.228 2020/07/02 15:14:38 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.229 2020/07/02 15:26:21 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -235,13 +235,14 @@
*/
#define VAR_EXPORT_LITERAL 2
-/* Var*Pattern flags */
-#define VAR_SUB_GLOBAL 0x01 /* Apply substitution globally */
-#define VAR_SUB_ONE 0x02 /* Apply substitution to one word */
-#define VAR_SUB_MATCHED 0x04 /* There was a match */
-#define VAR_MATCH_START 0x08 /* Match at start of word */
-#define VAR_MATCH_END 0x10 /* Match at end of word */
-#define VAR_NOSUBST 0x20 /* don't expand vars in VarGetPattern */
+typedef enum {
+ VAR_SUB_GLOBAL = 0x01, /* Apply substitution globally */
+ VAR_SUB_ONE = 0x02, /* Apply substitution to one word */
+ VAR_SUB_MATCHED = 0x04, /* There was a match */
+ VAR_MATCH_START = 0x08, /* Match at start of word */
+ VAR_MATCH_END = 0x10, /* Match at end of word */
+ VAR_NOSUBST = 0x20 /* don't expand vars in VarGetPattern */
+} VarPattern_Flags;
/* Var_Set flags */
#define VAR_NO_EXPORT 0x01 /* do not export */
@@ -263,11 +264,11 @@
/* struct passed as 'void *' to VarSubstitute() for ":S/lhs/rhs/",
* to VarSYSVMatch() for ":lhs=rhs". */
typedef struct {
- const char *lhs; /* String to match */
- int leftLen; /* Length of string */
- const char *rhs; /* Replacement string (w/ &'s removed) */
- int rightLen; /* Length of replacement */
- int flags;
+ const char *lhs; /* String to match */
+ int leftLen; /* Length of string */
+ const char *rhs; /* Replacement string (w/ &'s removed) */
+ int rightLen; /* Length of replacement */
+ VarPattern_Flags flags;
} VarPattern;
/* struct passed as 'void *' to VarLoopExpand() for ":@tvar@str@" */
@@ -325,8 +326,8 @@
static Boolean VarLoopExpand(GNode *, Var_Parse_State *,
char *, Boolean, Buffer *, void *);
static char *VarGetPattern(GNode *, Var_Parse_State *,
- int, const char **, int, int *, int *,
- VarPattern *);
+ VarPattern_Flags, const char **, int,
+ VarPattern_Flags *, int *, VarPattern *);
static char *VarQuote(char *, Boolean);
static char *VarHash(char *);
static char *VarModify(GNode *, Var_Parse_State *,
@@ -2225,8 +2226,8 @@
*/
static char *
VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
- int flags, const char **tstr, int delim, int *vflags,
- int *length, VarPattern *pattern)
+ VarPattern_Flags flags, const char **tstr, int delim,
+ VarPattern_Flags *vflags, int *length, VarPattern *pattern)
{
const char *cp;
char *rstr;
@@ -2650,7 +2651,7 @@
char *sv_name;
VarPattern pattern;
int how;
- int vflags;
+ VarPattern_Flags vflags;
if (v->name[0] == 0)
goto bad_modifier;
@@ -2733,7 +2734,7 @@
case '@':
{
VarLoop_t loop;
- int vflags = VAR_NOSUBST;
+ VarPattern_Flags vflags = VAR_NOSUBST;
cp = ++tstr;
delim = '@';
@@ -3379,8 +3380,8 @@
VarPattern pattern;
Boolean value;
int cond_rc;
- int lhs_flags, rhs_flags;
-
+ VarPattern_Flags lhs_flags, rhs_flags;
+
/* find ':', and then substitute accordingly */
if (flags & VARF_WANTRES) {
cond_rc = Cond_EvalExpression(NULL, v->name, &value, 0, FALSE);
Home |
Main Index |
Thread Index |
Old Index