mirror of
https://github.com/mirror/make.git
synced 2025-03-03 14:20:54 +08:00
[SV 46581] Pre-define .LOADED to avoid warnings.
* main.c (main): Pre-define .LOADED as a default-level variable. * load.c (load_file): Set the value rather than append it. Avoid adding an extra initial whitespace. * tests/scripts/features/load: Run with --warn-undefined-variables.
This commit is contained in:
parent
fd1dd7c398
commit
e33f3d72bf
22
load.c
22
load.c
@ -168,9 +168,8 @@ load_file (const gmk_floc *flocp, const char **ldname, int noerror)
|
|||||||
loaded = allocated_variable_expand ("$(.LOADED)");
|
loaded = allocated_variable_expand ("$(.LOADED)");
|
||||||
fp = strstr (loaded, *ldname);
|
fp = strstr (loaded, *ldname);
|
||||||
r = fp && (fp==loaded || fp[-1]==' ') && (fp[nmlen]=='\0' || fp[nmlen]==' ');
|
r = fp && (fp==loaded || fp[-1]==' ') && (fp[nmlen]=='\0' || fp[nmlen]==' ');
|
||||||
free (loaded);
|
|
||||||
if (r)
|
if (r)
|
||||||
return 1;
|
goto exit;
|
||||||
|
|
||||||
/* If we didn't find a symbol name yet, construct it from the ldname. */
|
/* If we didn't find a symbol name yet, construct it from the ldname. */
|
||||||
if (! symname)
|
if (! symname)
|
||||||
@ -214,8 +213,21 @@ load_file (const gmk_floc *flocp, const char **ldname, int noerror)
|
|||||||
|
|
||||||
/* If it succeeded, add the load file to the loaded variable. */
|
/* If it succeeded, add the load file to the loaded variable. */
|
||||||
if (r > 0)
|
if (r > 0)
|
||||||
do_variable_definition (flocp, ".LOADED", *ldname, o_default, f_append, 0);
|
{
|
||||||
|
size_t loadlen = strlen (loaded);
|
||||||
|
char *newval = alloca (loadlen + strlen (*ldname) + 2);
|
||||||
|
/* Don't add a space if it's empty. */
|
||||||
|
if (loadlen)
|
||||||
|
{
|
||||||
|
memcpy (newval, loaded, loadlen);
|
||||||
|
newval[loadlen++] = ' ';
|
||||||
|
}
|
||||||
|
strcpy (&newval[loadlen], *ldname);
|
||||||
|
do_variable_definition (flocp, ".LOADED", newval, o_default, f_simple, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit:
|
||||||
|
free (loaded);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +249,7 @@ unload_file (const char *name)
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
int
|
int
|
||||||
load_file (const gmk_floc *flocp, const char **ldname, int noerror)
|
load_file (const gmk_floc *flocp, const char **ldname UNUSED, int noerror)
|
||||||
{
|
{
|
||||||
if (! noerror)
|
if (! noerror)
|
||||||
O (fatal, flocp,
|
O (fatal, flocp,
|
||||||
@ -247,7 +259,7 @@ load_file (const gmk_floc *flocp, const char **ldname, int noerror)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
unload_file (const char *name)
|
unload_file (const char *name UNUSED)
|
||||||
{
|
{
|
||||||
O (fatal, NILF, "INTERNAL: Cannot unload when load is not supported!");
|
O (fatal, NILF, "INTERNAL: Cannot unload when load is not supported!");
|
||||||
}
|
}
|
||||||
|
1
main.c
1
main.c
@ -1316,6 +1316,7 @@ main (int argc, char **argv, char **envp)
|
|||||||
/* define_variable_cname (".TARGETS", "", o_default, 0)->special = 1; */
|
/* define_variable_cname (".TARGETS", "", o_default, 0)->special = 1; */
|
||||||
define_variable_cname (".RECIPEPREFIX", "", o_default, 0)->special = 1;
|
define_variable_cname (".RECIPEPREFIX", "", o_default, 0)->special = 1;
|
||||||
define_variable_cname (".SHELLFLAGS", "-c", o_default, 0);
|
define_variable_cname (".SHELLFLAGS", "-c", o_default, 0);
|
||||||
|
define_variable_cname (".LOADED", "", o_default, 0);
|
||||||
|
|
||||||
/* Set up .FEATURES
|
/* Set up .FEATURES
|
||||||
Use a separate variable because define_variable_cname() is a macro and
|
Use a separate variable because define_variable_cname() is a macro and
|
||||||
|
@ -56,7 +56,7 @@ load testload.so
|
|||||||
POST := $(.LOADED)
|
POST := $(.LOADED)
|
||||||
all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
|
all: ; @echo pre=$(PRE) post=$(POST) $(TESTLOAD)
|
||||||
!,
|
!,
|
||||||
'', "pre= post=testload.so implicit\n");
|
'--warn-undefined-variables', "pre= post=testload.so implicit\n");
|
||||||
|
|
||||||
# TEST 2
|
# TEST 2
|
||||||
# Load using an explicit function
|
# Load using an explicit function
|
||||||
|
Loading…
Reference in New Issue
Block a user