acme: factor out tag parsing code

This commit is contained in:
Russ Cox 2020-01-13 20:00:51 -05:00
parent 3a62e56307
commit 81d992e35f
3 changed files with 28 additions and 21 deletions

View file

@ -477,9 +477,9 @@ includename(Text *t, Rune *r, int n)
Runestr
dirname(Text *t, Rune *r, int n)
{
Rune *b, c;
uint m, nt;
int slash;
Rune *b;
uint nt;
int slash, i;
Runestr tmp;
b = nil;
@ -490,15 +490,13 @@ dirname(Text *t, Rune *r, int n)
goto Rescue;
if(n>=1 && r[0]=='/')
goto Rescue;
b = runemalloc(nt+n+1);
bufread(&t->w->tag.file->b, 0, b, nt);
b = parsetag(t->w, &i);
slash = -1;
for(m=0; m<nt; m++){
c = b[m];
if(c == '/')
slash = m;
if(c==' ' || c=='\t')
for(i--; i >= 0; i--){
if(b[i] == '/'){
slash = i;
break;
}
}
if(slash < 0)
goto Rescue;