Replace a lot of Var_Set(..., VAR_GLOBAL) by Var_SetGlobal().

Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.237)
This commit is contained in:
Hartmut Brandt 2005-05-12 14:47:22 +00:00
parent 7007abaf14
commit 1185781977
3 changed files with 30 additions and 18 deletions

View File

@ -253,7 +253,7 @@ ReadMakefile(const char p[])
if (!strcmp(fname, "-")) {
Parse_File("(stdin)", stdin);
Var_Set("MAKEFILE", "", VAR_GLOBAL);
Var_SetGlobal("MAKEFILE", "");
} else {
setMAKEFILE = strcmp(fname, ".depend");
@ -314,7 +314,7 @@ ReadMakefile(const char p[])
*/
found:
if (setMAKEFILE)
Var_Set("MAKEFILE", MAKEFILE, VAR_GLOBAL);
Var_SetGlobal("MAKEFILE", MAKEFILE);
Parse_File(fname, stream);
fclose(stream);
}
@ -360,7 +360,7 @@ MainParseArgs(int argc, char **argv)
err(1, "chdir %s", optarg);
break;
case 'D':
Var_Set(optarg, "1", VAR_GLOBAL);
Var_SetGlobal(optarg, "1");
MFLAGS_append("-D", optarg);
break;
case 'I':
@ -791,14 +791,14 @@ main(int argc, char **argv)
* .MAKEFLAGS gets set to the empty string just in case.
* MFLAGS also gets initialized empty, for compatibility.
*/
Var_Set("MAKE", argv[0], VAR_GLOBAL);
Var_Set(MAKEFLAGS, "", VAR_GLOBAL);
Var_Set("MFLAGS", "", VAR_GLOBAL);
Var_Set("MACHINE", machine, VAR_GLOBAL);
Var_Set("MACHINE_ARCH", machine_arch, VAR_GLOBAL);
Var_Set("MACHINE_CPU", machine_cpu, VAR_GLOBAL);
Var_SetGlobal("MAKE", argv[0]);
Var_SetGlobal(MAKEFLAGS, "");
Var_SetGlobal("MFLAGS", "");
Var_SetGlobal("MACHINE", machine);
Var_SetGlobal("MACHINE_ARCH", machine_arch);
Var_SetGlobal("MACHINE_CPU", machine_cpu);
#ifdef MAKE_VERSION
Var_Set("MAKE_VERSION", MAKE_VERSION, VAR_GLOBAL);
Var_SetGlobal("MAKE_VERSION", MAKE_VERSION);
#endif
/*
@ -845,8 +845,7 @@ main(int argc, char **argv)
if (!(path = getenv("MAKEOBJDIR"))) {
path = PATH_OBJDIR;
pathp = PATH_OBJDIRPREFIX;
snprintf(mdpath, MAXPATHLEN, "%s.%s",
path, machine);
snprintf(mdpath, MAXPATHLEN, "%s.%s", path, machine);
if (!(objdir = chdir_verify_path(mdpath, obpath)))
if (!(objdir=chdir_verify_path(path, obpath))) {
snprintf(mdpath, MAXPATHLEN,
@ -867,9 +866,9 @@ main(int argc, char **argv)
Dir_InitDot(); /* Initialize the "." directory */
if (objdir != curdir)
Path_AddDir(&dirSearchPath, curdir);
Var_Set(".ST_EXPORTVAR", "YES", VAR_GLOBAL);
Var_Set(".CURDIR", curdir, VAR_GLOBAL);
Var_Set(".OBJDIR", objdir, VAR_GLOBAL);
Var_SetGlobal(".ST_EXPORTVAR", "YES");
Var_SetGlobal(".CURDIR", curdir);
Var_SetGlobal(".OBJDIR", objdir);
if (getenv("MAKE_JOBS_FIFO") != NULL)
forceJobs = TRUE;
@ -895,7 +894,9 @@ main(int argc, char **argv)
* created. If none specified, make the variable empty -- the parser
* will fill the thing in with the default or .MAIN target.
*/
if (!Lst_IsEmpty(&create)) {
if (Lst_IsEmpty(&create)) {
Var_SetGlobal(".TARGETS", "");
} else {
LstNode *ln;
for (ln = Lst_First(&create); ln != NULL; ln = Lst_Succ(ln)) {
@ -903,8 +904,7 @@ main(int argc, char **argv)
Var_Append(".TARGETS", name, VAR_GLOBAL);
}
} else
Var_Set(".TARGETS", "", VAR_GLOBAL);
}
/*

View File

@ -1032,6 +1032,17 @@ Var_Set(const char *name, const char *val, GNode *ctxt)
free(n);
}
/**
* Set the a global name variable to the value.
*/
void
Var_SetGlobal(const char name[], const char value[])
{
Var_Set(name, value, VAR_GLOBAL);
}
/**
* Set the VAR_TO_ENV flag on a variable
*/

View File

@ -76,6 +76,7 @@ size_t Var_Match(const char [], struct GNode *);
char *Var_Parse(const char *, struct GNode *, Boolean, size_t *, Boolean *);
void Var_Print(struct Lst *, Boolean);
void Var_Set(const char *, const char *, struct GNode *);
void Var_SetGlobal(const char *, const char *);
void Var_SetEnv(const char *, struct GNode *);
struct Buffer *Var_Subst(const char *, struct GNode *, Boolean);
struct Buffer *Var_SubstOnly(const char *, const char *, Boolean);