Add dollarsign support.
This commit is contained in:
parent
d96da29b37
commit
d5c40a0da2
1 changed files with 20 additions and 8 deletions
|
|
@ -455,6 +455,8 @@ 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;
|
||||
|
|
@ -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
|
||||
|
|
@ -567,11 +575,15 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
|
|||
}
|
||||
else if(amin == q0)
|
||||
goto Isfile;
|
||||
else{
|
||||
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 */
|
||||
w = lookfile(r, nname);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue