diff options
author | rsc <devnull@localhost> | 2005-03-21 03:59:19 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-03-21 03:59:19 +0000 |
commit | 5a3960716df079feeda82e55c8849b10126cd6e5 (patch) | |
tree | 664067cbaaacae633863ecc511b85b93c415340a /src/cmd/netfiles | |
parent | baf7825e82bac6f37860c6ebe26a13651fe405fd (diff) | |
download | plan9port-5a3960716df079feeda82e55c8849b10126cd6e5.tar.gz plan9port-5a3960716df079feeda82e55c8849b10126cd6e5.tar.bz2 plan9port-5a3960716df079feeda82e55c8849b10126cd6e5.zip |
fix :5 in window (don't open directory).
search for file windows better (don't lose files).
Diffstat (limited to 'src/cmd/netfiles')
-rw-r--r-- | src/cmd/netfiles/acme.c | 2 | ||||
-rw-r--r-- | src/cmd/netfiles/main.c | 55 |
2 files changed, 29 insertions, 28 deletions
diff --git a/src/cmd/netfiles/acme.c b/src/cmd/netfiles/acme.c index 7519da77..cff529ee 100644 --- a/src/cmd/netfiles/acme.c +++ b/src/cmd/netfiles/acme.c @@ -290,7 +290,7 @@ winindex(void) char *s; mountacme(); - if((fid = fsopen(acmefs, "index", ORDWR)) == nil) + if((fid = fsopen(acmefs, "index", OREAD)) == nil) return nil; s = fsreadm(fid); fsclose(fid); diff --git a/src/cmd/netfiles/main.c b/src/cmd/netfiles/main.c index 9ee20f34..2372d28a 100644 --- a/src/cmd/netfiles/main.c +++ b/src/cmd/netfiles/main.c @@ -81,22 +81,33 @@ arg(char *file, char *addr, Channel *c) return a; } +Win* +winbyid(int id) +{ + Win *w; + + for(w=windows; w; w=w->next) + if(w->id == id) + return w; + return nil; +} + /* - * return window id of a window named name or name/ + * return Win* of a window named name or name/ * assumes name is cleaned. */ -int -nametowinid(char *name) +Win* +nametowin(char *name) { char *index, *p, *next; int len, n; + Win *w; index = winindex(); - n = -1; len = strlen(name); for(p=index; p && *p; p=next){ if((next = strchr(p, '\n')) != nil) - *next = 0; + *next++ = 0; if(strlen(p) <= 5*12) continue; if(memcmp(p+5*12, name, len)!=0) @@ -104,30 +115,16 @@ nametowinid(char *name) if(p[5*12+len]!=' ' && (p[5*12+len]!='/' || p[5*12+len+1]!=' ')) continue; n = atoi(p); - break; + if((w = winbyid(n)) != nil){ + free(index); + return w; + } } free(index); - return n; -} - -/* - * look up window by name - */ -Win* -nametowin(char *name) -{ - int id; - Win *w; - - id = nametowinid(name); - if(id == -1) - return nil; - for(w=windows; w; w=w->next) - if(w->id == id) - return w; return nil; } + /* * look for s in list */ @@ -393,11 +390,14 @@ do3(Win *w, char *text) name = estrdup(text); else{ p = wingetname(w); - q = strrchr(p, '/'); - *(q+1) = 0; + if(text[0] != ':'){ + q = strrchr(p, '/'); + *(q+1) = 0; + } name = emalloc(strlen(p)+1+strlen(text)+1); strcpy(name, p); - strcat(name, "/"); + if(text[0] != ':') + strcat(name, "/"); strcat(name, text); } dprint("do3 %s => %s\n", text, name); @@ -417,6 +417,7 @@ do3(Win *w, char *text) free(path); if(strcmp(type, "file")==0 || strcmp(type, "directory")==0){ w = nametowin(name); + fprint(2, "nametowin %s: %p\n", name); if(w == nil) w = mkwin(name); winaddr(w, "%s", addr); |