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;
|
b = nil;
|
||||||
if(t==nil || t->w==nil)
|
if(t==nil || t->w==nil)
|
||||||
goto Rescue;
|
goto Rescue;
|
||||||
|
if(dodollarsigns && n>=1 && r[0]=='$')
|
||||||
|
expandenv(&r, &n);
|
||||||
nt = t->w->tag.file->b.nc;
|
nt = t->w->tag.file->b.nc;
|
||||||
if(nt == 0)
|
if(nt == 0)
|
||||||
goto Rescue;
|
goto Rescue;
|
||||||
|
|
@ -472,9 +474,12 @@ dirname(Text *t, Rune *r, int n)
|
||||||
}
|
}
|
||||||
if(slash < 0)
|
if(slash < 0)
|
||||||
goto Rescue;
|
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);
|
free(r);
|
||||||
return cleanrname(runestr(b, slash+1+n));
|
return cleanrname(runestr(b, slash+n));
|
||||||
|
|
||||||
Rescue:
|
Rescue:
|
||||||
free(b);
|
free(b);
|
||||||
|
|
@ -535,7 +540,7 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
|
||||||
if(n == 0)
|
if(n == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
/* see if it's a file name */
|
/* 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);
|
bufread(&t->file->b, q0, r, n);
|
||||||
/* first, does it have bad chars? */
|
/* first, does it have bad chars? */
|
||||||
nname = -1;
|
nname = -1;
|
||||||
|
|
@ -551,9 +556,12 @@ expandfile(Text *t, uint q0, uint q1, Expand *e)
|
||||||
}
|
}
|
||||||
if(nname == -1)
|
if(nname == -1)
|
||||||
nname = n;
|
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]))
|
if(!isfilec(r[i]))
|
||||||
goto Isntfile;
|
goto Isntfile;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* See if it's a file name in <>, and turn that into an include
|
* 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
|
* 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)
|
else if(amin == q0)
|
||||||
goto Isfile;
|
goto Isfile;
|
||||||
|
else{
|
||||||
|
if(dodollarsigns && r[0] == '$')
|
||||||
|
expandenv(&r, &nname);
|
||||||
else{
|
else{
|
||||||
rs = dirname(t, r, nname);
|
rs = dirname(t, r, nname);
|
||||||
r = rs.r;
|
r = rs.r;
|
||||||
nname = rs.nr;
|
nname = rs.nr;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
e->bname = runetobyte(r, nname);
|
e->bname = runetobyte(r, nname);
|
||||||
/* if it's already a window name, it's a file */
|
/* if it's already a window name, it's a file */
|
||||||
w = lookfile(r, nname);
|
w = lookfile(r, nname);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue