From d5c40a0da2889b9ff4ad8e23258da297489a701d Mon Sep 17 00:00:00 2001 From: rsc Date: Mon, 14 Mar 2005 21:02:14 +0000 Subject: Add dollarsign support. --- src/cmd/acme/look.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src') 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, 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 */ -- cgit v1.2.3