aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/rc/var.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cmd/rc/var.c')
-rw-r--r--sys/cmd/rc/var.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/sys/cmd/rc/var.c b/sys/cmd/rc/var.c
index d48dc66..a1c60e0 100644
--- a/sys/cmd/rc/var.c
+++ b/sys/cmd/rc/var.c
@@ -2,7 +2,7 @@
#include "exec.h"
#include "fns.h"
-var *gvar[NVAR] = { 0 }; /* hash for globals */
+Var *gvar[NVAR] = { 0 }; /* hash for globals */
int
hash(char *s, int n)
@@ -45,11 +45,11 @@ kinit(void)
kenter(FN, "fn");
}
-tree*
+Tree*
klook(char *name)
{
struct kw *p;
- tree *t = token(name, WORD);
+ Tree *t = token(name, WORD);
for(p = kw[hash(name, NKW)];p;p = p->next)
if(strcmp(p->name, name)==0){
t->type = p->type;
@@ -59,19 +59,19 @@ klook(char *name)
return t;
}
-var*
+Var*
gvlook(char *name)
{
int h = hash(name, NVAR);
- var *v;
+ Var *v;
for(v = gvar[h];v;v = v->next) if(strcmp(v->name, name)==0) return v;
return gvar[h] = newvar(strdup(name), gvar[h]);
}
-var*
+Var*
vlook(char *name)
{
- var *v;
+ Var *v;
if(runq)
for(v = runq->local;v;v = v->next)
if(strcmp(v->name, name)==0) return v;
@@ -79,9 +79,10 @@ vlook(char *name)
}
void
-_setvar(char *name, word *val, int callfn)
+_setvar(char *name, Word *val, int callfn)
{
- struct var *v = vlook(name);
+ struct Var *v = vlook(name);
+
freewords(v->val);
v->val=val;
v->changed=1;
@@ -90,17 +91,17 @@ _setvar(char *name, word *val, int callfn)
}
void
-setvar(char *name, word *val)
+setvar(char *name, Word *val)
{
_setvar(name, val, 1);
}
void
-bigpath(var *v)
+bigpath(Var *v)
{
/* convert $PATH to $path */
char *p, *q;
- word **l, *w;
+ Word **l, *w;
if(v->val == nil){
_setvar("path", nil, 0);
@@ -130,11 +131,11 @@ bigpath(var *v)
}
char*
-list2strcolon(word *words)
+list2strcolon(Word *words)
{
char *value, *s, *t;
int len = 0;
- word *ap;
+ Word *ap;
for(ap = words;ap;ap = ap->next)
len+=1+strlen(ap->word);
value = emalloc(len+1);
@@ -149,14 +150,14 @@ list2strcolon(word *words)
return value;
}
void
-littlepath(var *v)
+littlepath(Var *v)
{
/* convert $path to $PATH */
char *p;
- word *w;
+ Word *w;
p = list2strcolon(v->val);
- w = new(word);
+ w = new(Word);
w->word = p;
w->next = nil;
_setvar("PATH", w, 1); /* 1: recompute $path to expose colon problems */
@@ -165,7 +166,7 @@ littlepath(var *v)
void
pathinit(void)
{
- var *v;
+ Var *v;
v = gvlook("path");
v->changefn = littlepath;