-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmake-4.4.1-warn-noargs.patch
113 lines (101 loc) · 3.96 KB
/
make-4.4.1-warn-noargs.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
--- make-4.4.1-orig/src/main.c 2023-02-21 08:03:51.000000000 +0300
+++ make-4.4.1/src/main.c 2024-09-18 08:53:02.804603700 +0300
@@ -286,6 +286,8 @@
int warn_undefined_variables_flag;
+static char *warn_undefined_variables_option = 0;
+
/* If nonzero, always build all targets, regardless of whether
they appear out of date or not. */
@@ -402,7 +404,8 @@
-W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE\n\
Consider FILE to be infinitely new.\n"),
N_("\
- --warn-undefined-variables Warn when an undefined variable is referenced.\n"),
+ --warn-undefined-variables[=TYPE]\n\
+ Warn when an undefined variable is referenced.\n"),
NULL
};
@@ -497,7 +500,7 @@
{ CHAR_MAX+3, flag, &trace_flag, 1, 1, 0, 0, 0, 0, "trace", 0 },
{ CHAR_MAX+4, flag_off, &print_directory_flag, 1, 1, 0, 0, 0,
&default_print_directory_flag, "no-print-directory", &print_directory_origin },
- { CHAR_MAX+5, flag, &warn_undefined_variables_flag, 1, 1, 0, 0, 0, 0,
+ { CHAR_MAX+5, string, &warn_undefined_variables_option, 1, 1, 0, 0, "noargs", 0,
"warn-undefined-variables", 0 },
{ CHAR_MAX+7, string, &sync_mutex, 1, 1, 0, 0, 0, 0, "sync-mutex", 0 },
{ CHAR_MAX+8, flag_off, &silent_flag, 1, 1, 0, 0, 0, &default_silent_flag,
@@ -925,6 +928,24 @@
die (bad ? MAKE_FAILURE : MAKE_SUCCESS);
}
+static void
+decode_warn_undefined_flags (void)
+{
+ if (warn_undefined_variables_option)
+ {
+ if (streq (warn_undefined_variables_option, "all"))
+ warn_undefined_variables_flag = WARN_UNDEFINED_BASE | WARN_UNDEFINED_ARGS;
+ else if (streq (warn_undefined_variables_option, "noargs"))
+ warn_undefined_variables_flag = WARN_UNDEFINED_BASE;
+ else if (streq (warn_undefined_variables_option, "args"))
+ warn_undefined_variables_flag = WARN_UNDEFINED_ARGS;
+ else
+ OS (fatal, NILF,
+ _("unknown warn-undefined-variables type '%s'"),
+ warn_undefined_variables_option);
+ }
+}
+
#ifdef WINDOWS32
/*
@@ -3373,6 +3394,7 @@
/* If there are any options that need to be decoded do it now. */
decode_debug_flags ();
decode_output_sync_flags ();
+ decode_warn_undefined_flags ();
/* Perform any special switch handling. */
run_silent = silent_flag;
--- make-4.4.1-orig/src/variable.c 2023-01-28 21:04:47.000000000 +0300
+++ make-4.4.1/src/variable.c 2024-09-18 09:04:48.464092600 +0300
@@ -1855,6 +1855,25 @@
return vp;
}
+static int
+filter_undefined_variable_warn (const char *name, size_t length)
+{
+ if (!(warn_undefined_variables_flag & WARN_UNDEFINED_BASE) ||
+ !(warn_undefined_variables_flag & WARN_UNDEFINED_ARGS))
+ {
+ /* $(call ...) arguments are named as $1,$2,$3 and so on,
+ check if variable name is numeric. */
+ size_t i;
+ for (i = 0; i < length && ISDIGIT(name[i]); ++i);
+
+ if ((i == length && !(warn_undefined_variables_flag & WARN_UNDEFINED_ARGS)) ||
+ (i != length && !(warn_undefined_variables_flag & WARN_UNDEFINED_BASE)))
+ return 1;
+ }
+
+ return 0;
+}
+
/* These variables are internal to make, and so considered "defined" for the
purposes of warn_undefined even if they are not really defined. */
@@ -1888,6 +1907,9 @@
if (dp->len == len && memcmp (dp->name, name, len) == 0)
return;
+ if (filter_undefined_variable_warn (name, len))
+ return;
+
error (reading_file, len, _("warning: undefined variable '%.*s'"),
(int)len, name);
}
--- make-4.4.1-orig/src/variable.h 2023-01-28 21:04:47.000000000 +0300
+++ make-4.4.1/src/variable.h 2024-09-18 08:57:33.459838100 +0300
@@ -207,6 +207,9 @@
const floc *flocp);
void warn_undefined (const char* name, size_t length);
+#define WARN_UNDEFINED_BASE (0x001)
+#define WARN_UNDEFINED_ARGS (0x002)
+
/* Define a variable in the current variable set. */
#define define_variable(n,l,v,o,r) \