aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-03-14 21:02:14 +0000
committerrsc <devnull@localhost>2005-03-14 21:02:14 +0000
commitd5c40a0da2889b9ff4ad8e23258da297489a701d (patch)
treeb9c98d3d11662232d126eac6acefab9f15d55798 /src/cmd
parentd96da29b373306ea72f99d61e524e7337112652c (diff)
downloadplan9port-d5c40a0da2889b9ff4ad8e23258da297489a701d.tar.gz
plan9port-d5c40a0da2889b9ff4ad8e23258da297489a701d.tar.bz2
plan9port-d5c40a0da2889b9ff4ad8e23258da297489a701d.zip
Add dollarsign support.
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/acme/look.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c
index a6735459..65ee15c9 100644
--- a/src/cmd/acme/look.c
+++ b/src/cmd/acme/look.c
@@ -455,10 +455,12 @@ dirname(Text *t, Rune *r, int n)
b = nil;
if(t==nil || t->w==nil)
goto Rescue;
+ if(dodollarsigns && n>=1 && r[0]=='$')
+ expandenv(&r, &n);
nt = t->w->tag.file->b.nc;
if(nt == 0)
goto Rescue;
- if(n>=1 && r[0]=='/')
+ if(n>=1 && r[0]=='/')
goto Rescue;
b = runemalloc(nt+n+1);
bufread(&t->w->tag.file->b, 0, b, nt);
@@ -472,9 +474,12 @@ dirname(Text *t, Rune *r, int n)
}
if(slash < 0)
goto Rescue;
- runemove(b+slash+1, r, n);
+ slash++;
+ if(dodollarsigns && expandenv(&b, &slash))
+ b = runerealloc(b, slash+n);
+ runemove(b+slash, r, n);
free(r);
- return cleanrname(runestr(b, slash+1+n));
+ return cleanrname(runestr(b, slash+n));
Rescue:
free(b);
@@ -535,7 +540,7 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
if(n == 0)
return FALSE;
/* see if it's a file name */
- r = runemalloc(n);
+ r = runemalloc(n+1); /* +1 for possible $ below */
bufread(&t->file->b, q0, r, n);
/* first, does it have bad chars? */
nname = -1;
@@ -551,9 +556,12 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
}
if(nname == -1)
nname = n;
- for(i=0; i<nname; i++)
+ for(i=0; i<nname; i++){
+ if(dodollarsigns && i==0 && r[0]=='$')
+ continue;
if(!isfilec(r[i]))
goto Isntfile;
+ }
/*
* See if it's a file name in <>, and turn that into an include
* file name if so. Should probably do it for "" too, but that's not
@@ -568,9 +576,13 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
else if(amin == q0)
goto Isfile;
else{
- rs = dirname(t, r, nname);
- r = rs.r;
- nname = rs.nr;
+ if(dodollarsigns && r[0] == '$')
+ expandenv(&r, &nname);
+ else{
+ rs = dirname(t, r, nname);
+ r = rs.r;
+ nname = rs.nr;
+ }
}
e->bname = runetobyte(r, nname);
/* if it's already a window name, it's a file */