mirror of
https://git.FreeBSD.org/src.git
synced 2024-10-20 02:38:43 +00:00
The caller of Var_Value() should not change the variable value. Make
this clear by constifying the return value. Obtained from: DragonFlyBSD
This commit is contained in:
parent
19446efc06
commit
527505d8cb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=146581
@ -2786,7 +2786,7 @@ CompatInterrupt(int signo)
|
||||
interrupted = 0;
|
||||
|
||||
if (curTarg != NULL && !Targ_Precious(curTarg)) {
|
||||
char *file = Var_Value(TARGET, curTarg);
|
||||
const char *file = Var_Value(TARGET, curTarg);
|
||||
|
||||
if (!noExecute && eunlink(file) != -1) {
|
||||
printf("*** %s removed\n", file);
|
||||
|
@ -663,7 +663,7 @@ main(int argc, char **argv)
|
||||
const char *machine_arch;
|
||||
const char *machine_cpu;
|
||||
Boolean outOfDate = TRUE; /* FALSE if all targets up to date */
|
||||
char *p;
|
||||
const char *p;
|
||||
const char *pathp;
|
||||
const char *path;
|
||||
char mdpath[MAXPATHLEN];
|
||||
|
@ -338,10 +338,10 @@ Make_HandleUse(GNode *cgn, GNode *pgn)
|
||||
void
|
||||
Make_Update(GNode *cgn)
|
||||
{
|
||||
GNode *pgn; /* the parent node */
|
||||
char *cname; /* the child's name */
|
||||
LstNode *ln; /* Element in parents and iParents lists */
|
||||
char *cpref;
|
||||
GNode *pgn; /* the parent node */
|
||||
const char *cname; /* the child's name */
|
||||
LstNode *ln; /* Element in parents and iParents lists */
|
||||
const char *cpref;
|
||||
|
||||
cname = Var_Value(TARGET, cgn);
|
||||
|
||||
@ -491,9 +491,9 @@ Make_Update(GNode *cgn)
|
||||
void
|
||||
Make_DoAllVar(GNode *gn)
|
||||
{
|
||||
LstNode *ln;
|
||||
GNode *cgn;
|
||||
char *child;
|
||||
LstNode *ln;
|
||||
GNode *cgn;
|
||||
const char *child;
|
||||
|
||||
LST_FOREACH(ln, &gn->children) {
|
||||
/*
|
||||
|
@ -1144,7 +1144,7 @@ Var_Exists(const char *name, GNode *ctxt)
|
||||
* Results:
|
||||
* The value if the variable exists, NULL if it doesn't.
|
||||
*/
|
||||
char *
|
||||
const char *
|
||||
Var_Value(const char name[], GNode *ctxt)
|
||||
{
|
||||
Var *v;
|
||||
@ -2545,12 +2545,13 @@ Var_Print(Lst *vlist, Boolean expandVars)
|
||||
{
|
||||
LstNode *n;
|
||||
const char *name;
|
||||
char *v;
|
||||
char *value;
|
||||
|
||||
LST_FOREACH(n, vlist) {
|
||||
name = Lst_Datum(n);
|
||||
if (expandVars) {
|
||||
char *value;
|
||||
char *v;
|
||||
|
||||
v = emalloc(strlen(name) + 1 + 3);
|
||||
sprintf(v, "${%s}", name);
|
||||
|
||||
@ -2560,7 +2561,7 @@ Var_Print(Lst *vlist, Boolean expandVars)
|
||||
free(v);
|
||||
free(value);
|
||||
} else {
|
||||
value = Var_Value(name, VAR_GLOBAL);
|
||||
const char *value = Var_Value(name, VAR_GLOBAL);
|
||||
printf("%s\n", value != NULL ? value : "");
|
||||
}
|
||||
}
|
||||
|
@ -80,6 +80,6 @@ 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);
|
||||
char *Var_Value(const char *, struct GNode *);
|
||||
const char *Var_Value(const char [], struct GNode *);
|
||||
|
||||
#endif /* var_h_9cccafce */
|
||||
|
Loading…
Reference in New Issue
Block a user