aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/acme/look.c
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2020-01-13 20:00:51 -0500
committerRuss Cox <rsc@swtch.com>2020-01-13 21:43:54 -0500
commit81d992e35f12d53e6799d20c744ffb4e6a49787d (patch)
tree3b82a7de122d983cb024b0eeac858adbdc230e99 /src/cmd/acme/look.c
parent3a62e5630748d788166a50ed34b7f0dc6d43a5ee (diff)
downloadplan9port-81d992e35f12d53e6799d20c744ffb4e6a49787d.tar.gz
plan9port-81d992e35f12d53e6799d20c744ffb4e6a49787d.tar.bz2
plan9port-81d992e35f12d53e6799d20c744ffb4e6a49787d.zip
acme: factor out tag parsing code
Diffstat (limited to 'src/cmd/acme/look.c')
-rw-r--r--src/cmd/acme/look.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/cmd/acme/look.c b/src/cmd/acme/look.c
index 44e23cca..7b70e242 100644
--- a/src/cmd/acme/look.c
+++ b/src/cmd/acme/look.c
@@ -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;