summaryrefslogtreecommitdiffstats
path: root/usr.bin/make
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2005-05-24 16:05:51 +0000
committerharti <harti@FreeBSD.org>2005-05-24 16:05:51 +0000
commitdd5f450e83a2cf110049be4a3dec342b25032631 (patch)
tree7377d4a139d673efd4f875e108415e496df43d39 /usr.bin/make
parent79613308dce9cef12aa10cea972360bae9c444f3 (diff)
downloadFreeBSD-src-dd5f450e83a2cf110049be4a3dec342b25032631.zip
FreeBSD-src-dd5f450e83a2cf110049be4a3dec342b25032631.tar.gz
The caller of Var_Value() should not change the variable value. Make
this clear by constifying the return value. Obtained from: DragonFlyBSD
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/job.c2
-rw-r--r--usr.bin/make/main.c2
-rw-r--r--usr.bin/make/make.c14
-rw-r--r--usr.bin/make/var.c9
-rw-r--r--usr.bin/make/var.h2
5 files changed, 15 insertions, 14 deletions
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index ba877c4..8b467f7 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -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);
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c
index 70b8484..aeed734 100644
--- a/usr.bin/make/main.c
+++ b/usr.bin/make/main.c
@@ -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];
diff --git a/usr.bin/make/make.c b/usr.bin/make/make.c
index 8a460f1..9a39a9e 100644
--- a/usr.bin/make/make.c
+++ b/usr.bin/make/make.c
@@ -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) {
/*
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index 9300770..9844e16 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -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 : "");
}
}
diff --git a/usr.bin/make/var.h b/usr.bin/make/var.h
index 8b436dd..618cf7a 100644
--- a/usr.bin/make/var.h
+++ b/usr.bin/make/var.h
@@ -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 */
OpenPOWER on IntegriCloud