Implement a pseudo-target .WARN that allows toggeling the warning flags

for the current make. This does not override flags specified on the
command line and these settings are not passed to sub-makes.
This commit is contained in:
Hartmut Brandt 2005-04-29 14:37:44 +00:00
parent 0d389e7212
commit 3dece030a5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=145679
6 changed files with 109 additions and 32 deletions

View File

@ -1123,7 +1123,7 @@ Cond_Else(char *line __unused, int code __unused, int lineno __unused)
while (isspace((u_char)*line))
line++;
if (*line != '\0' && (warnflags & WARN_DIRSYNTAX)) {
if (*line != '\0' && (warn_flags & WARN_DIRSYNTAX)) {
Parse_Error(PARSE_WARNING, "junk after .else ignored '%s'",
line);
}
@ -1164,7 +1164,7 @@ Cond_Endif(char *line __unused, int code __unused, int lineno __unused)
while (isspace((u_char)*line))
line++;
if (*line != '\0' && (warnflags & WARN_DIRSYNTAX)) {
if (*line != '\0' && (warn_flags & WARN_DIRSYNTAX)) {
Parse_Error(PARSE_WARNING, "junk after .endif ignored '%s'",
line);
}

View File

@ -1,7 +1,7 @@
/*
* DO NOT EDIT
* $FreeBSD$
* auto-generated from FreeBSD: src/usr.bin/make/parse.c,v 1.97 2005/04/28 07:55:55 harti Exp
* auto-generated from FreeBSD: src/usr.bin/make/parse.c,v 1.98 2005/04/28 12:05:43 harti Exp
* DO NOT EDIT
*/
#include <sys/types.h>
@ -66,8 +66,8 @@ directive_hash(const u_char *key, size_t len)
}
/*
* d=2
* n=67
* m=32
* n=69
* m=33
* c=2.09
* maxlen=1
* minklen=4
@ -75,34 +75,34 @@ directive_hash(const u_char *key, size_t len)
* minchar=46
* maxchar=95
* loop=0
* numiter=2
* numiter=8
* seed=
*/
static const signed char keyword_g[] = {
17, -1, 18, 13, 26, 0, 0, 29, -1, 0,
7, -1, -1, 23, 13, 27, -1, 0, 14, 24,
-1, -1, 0, 24, -1, 0, -1, 27, 19, 12,
3, -1, -1, 3, 19, 28, 10, 17, -1, 8,
-1, -1, -1, 0, 5, 8, -1, 0, -1, -1,
0, 27, 4, -1, -1, 25, -1, 30, -1, 8,
16, -1, 0, -1, 0, 26, 14,
-1, 17, 16, 0, -1, -1, -1, -1, 25, 18,
2, -1, -1, 27, 28, 1, 0, 15, 16, -1,
-1, 14, 19, 1, -1, 13, -1, 0, 1, -1,
11, 15, 0, 8, 14, 18, 31, -1, -1, 22,
-1, 27, -1, 0, -1, 9, -1, -1, -1, 21,
3, 25, 0, 0, 0, -1, -1, 6, 0, 19,
-1, -1, -1, 23, -1, 17, -1, 0, 0,
};
static const u_char keyword_T0[] = {
17, 32, 43, 6, 64, 15, 20, 26, 30, 64,
54, 31, 6, 61, 4, 49, 62, 37, 23, 50,
6, 58, 29, 19, 32, 50, 56, 8, 18, 40,
51, 36, 6, 27, 42, 3, 59, 12, 46, 23,
9, 50, 4, 16, 44, 25, 15, 40, 62, 55,
8, 30, 55, 61, 14, 13, 48, 1, 18, 12,
0, 52, 1, 40, 44, 52, 33, 58, 29, 29,
3, 30, 26, 42, 1, 49, 10, 26, 5, 45,
65, 13, 6, 22, 45, 61, 7, 25, 62, 65,
8, 34, 48, 50, 5, 63, 33, 38, 52, 33,
};
static const u_char keyword_T1[] = {
24, 38, 31, 14, 65, 31, 23, 17, 27, 45,
32, 44, 19, 45, 18, 31, 28, 43, 0, 21,
29, 27, 42, 55, 21, 31, 14, 13, 66, 17,
39, 40, 5, 4, 5, 4, 52, 28, 21, 12,
7, 54, 6, 43, 49, 24, 7, 27, 0, 24,
44, 18, 49, 61, 56, 13, 1, 54, 1, 47,
46, 17, 22, 36, 25, 66, 14, 36, 58, 51,
60, 22, 61, 19, 43, 37, 5, 18, 50, 58,
32, 65, 47, 12, 28, 34, 65, 29, 59, 67,
48, 36, 15, 41, 44, 11, 39, 29, 18, 68,
};
@ -122,8 +122,8 @@ keyword_hash(const u_char *key, size_t len)
f1 += keyword_T1[-46 + *kp];
}
f0 %= 67;
f1 %= 67;
f0 %= 69;
f1 %= 69;
return (keyword_g[f0] + keyword_g[f1]) % 32;
return (keyword_g[f0] + keyword_g[f1]) % 33;
}

View File

@ -121,6 +121,8 @@ extern Boolean oldVars; /* Do old-style variable substitution */
extern int debug;
/* warning flags */
extern uint32_t warnflags;
extern uint32_t warn_cmd; /* positive warning flags on command line */
extern uint32_t warn_nocmd; /* negative warning flags on command line */
extern uint32_t warn_flags; /* current warning flags */
#endif /* globals_h_1c1edb96 */

View File

@ -107,7 +107,9 @@ Lst create = Lst_Initializer(create);
time_t now; /* Time at start of make */
struct GNode *DEFAULT; /* .DEFAULT node */
Boolean allPrecious; /* .PRECIOUS given on line by itself */
uint32_t warnflags;
uint32_t warn_flags; /* actual warning flags */
uint32_t warn_cmd; /* command line warning flags */
uint32_t warn_nocmd; /* command line no-warning flags */
static Boolean noBuiltins; /* -r flag */
@ -170,6 +172,58 @@ MFLAGS_append(const char *flag, char *arg)
}
}
/**
* Main_ParseWarn
*
* Handle argument to warning option.
*/
int
Main_ParseWarn(const char *arg, int iscmd)
{
int i, neg;
static const struct {
const char *option;
uint32_t flag;
} options[] = {
{ "dirsyntax", WARN_DIRSYNTAX },
{ NULL, 0 }
};
neg = 0;
if (arg[0] == 'n' && arg[1] == 'o') {
neg = 1;
arg += 2;
}
for (i = 0; options[i].option != NULL; i++)
if (strcmp(arg, options[i].option) == 0)
break;
if (options[i].option == NULL)
/* unknown option */
return (-1);
if (iscmd) {
if (!neg) {
warn_cmd |= options[i].flag;
warn_nocmd &= ~options[i].flag;
warn_flags |= options[i].flag;
} else {
warn_nocmd |= options[i].flag;
warn_cmd &= ~options[i].flag;
warn_flags &= ~options[i].flag;
}
} else {
if (!neg) {
warn_flags |= (options[i].flag & ~warn_nocmd);
} else {
warn_flags &= ~(options[i].flag | warn_cmd);
}
}
return (0);
}
/**
* MainParseArgs
* Parse a given argument vector. Called from main() and from
@ -347,10 +401,8 @@ MainParseArgs(int argc, char **argv)
MFLAGS_append("-v", NULL);
break;
case 'x':
if (strncmp(optarg, "dirsyntax", strlen(optarg)) == 0) {
if (Main_ParseWarn(optarg, 1) != -1)
MFLAGS_append("-x", optarg);
warnflags |= WARN_DIRSYNTAX;
}
break;
default:

View File

@ -45,7 +45,7 @@
struct Buffer;
void Main_ParseArgLine(char *, int);
int Main_ParseWarn(const char *, int);
Buffer *Cmd_Exec(char *, const char **);
#endif /* nonints_h_33c5dafb */

View File

@ -174,6 +174,7 @@ typedef enum {
SingleShell, /* .SINGLESHELL */
Suffixes, /* .SUFFIXES */
Wait, /* .WAIT */
Warn, /* .WARN */
Attribute /* Generic attribute */
} ParseSpecial;
@ -231,6 +232,7 @@ static const struct keyword {
{ ".SUFFIXES", Suffixes, 0 },
{ ".USE", Attribute, OP_USE },
{ ".WAIT", Wait, 0 },
{ ".WARN", Warn, 0 },
/* KEYWORD-END-TAG */
};
#define NKEYWORDS (sizeof(parseKeywords) / sizeof(parseKeywords[0]))
@ -396,6 +398,23 @@ ParsePopInput(void)
return (TAILQ_EMPTY(&includes) ? DONE : CONTINUE);
}
/**
* parse_warn
* Parse the .WARN pseudo-target.
*/
static void
parse_warn(char *line)
{
char **argv;
int argc;
int i;
argv = brk_string(line, &argc, TRUE);
for (i = 1; i < argc; i++)
Main_ParseWarn(argv[i], 0);
}
/*-
*---------------------------------------------------------------------
* ParseLinkSrc --
@ -1065,6 +1084,10 @@ ParseDoDependency(char *line)
Main_ParseArgLine(line, 0);
*line = '\0';
} else if (specType == Warn) {
parse_warn(line);
*line = '\0';
} else if (specType == ExShell) {
if (Job_ParseShell(line) != SUCCESS) {
Parse_Error(PARSE_FATAL,