look.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <draw.h>
  4. #include <thread.h>
  5. #include <cursor.h>
  6. #include <mouse.h>
  7. #include <keyboard.h>
  8. #include <frame.h>
  9. #include <fcall.h>
  10. #include <regexp.h>
  11. #include <plumb.h>
  12. #include "dat.h"
  13. #include "fns.h"
  14. Window* openfile(Text*, Expand*);
  15. int nuntitled;
  16. void
  17. look3(Text *t, uint q0, uint q1, int external)
  18. {
  19. int n, c, f, expanded;
  20. Text *ct;
  21. Expand e;
  22. Rune *r;
  23. uint p;
  24. Plumbmsg *m;
  25. Runestr dir;
  26. char buf[32];
  27. ct = seltext;
  28. if(ct == nil)
  29. seltext = t;
  30. expanded = expand(t, q0, q1, &e);
  31. if(!external && t->w!=nil && t->w->nopen[QWevent]>0){
  32. /* send alphanumeric expansion to external client */
  33. if(expanded == FALSE)
  34. return;
  35. f = 0;
  36. if((e.at!=nil && t->w!=nil) || (e.nname>0 && lookfile(e.name, e.nname)!=nil))
  37. f = 1; /* acme can do it without loading a file */
  38. if(q0!=e.q0 || q1!=e.q1)
  39. f |= 2; /* second (post-expand) message follows */
  40. if(e.nname)
  41. f |= 4; /* it's a file name */
  42. c = 'l';
  43. if(t->what == Body)
  44. c = 'L';
  45. n = q1-q0;
  46. if(n <= EVENTSIZE){
  47. r = runemalloc(n);
  48. bufread(t->file, q0, r, n);
  49. winevent(t->w, "%c%d %d %d %d %.*S\n", c, q0, q1, f, n, n, r);
  50. free(r);
  51. }else
  52. winevent(t->w, "%c%d %d %d 0 \n", c, q0, q1, f, n);
  53. if(q0==e.q0 && q1==e.q1)
  54. return;
  55. if(e.nname){
  56. n = e.nname;
  57. if(e.a1 > e.a0)
  58. n += 1+(e.a1-e.a0);
  59. r = runemalloc(n);
  60. runemove(r, e.name, e.nname);
  61. if(e.a1 > e.a0){
  62. r[e.nname] = ':';
  63. bufread(e.at->file, e.a0, r+e.nname+1, e.a1-e.a0);
  64. }
  65. }else{
  66. n = e.q1 - e.q0;
  67. r = runemalloc(n);
  68. bufread(t->file, e.q0, r, n);
  69. }
  70. f &= ~2;
  71. if(n <= EVENTSIZE)
  72. winevent(t->w, "%c%d %d %d %d %.*S\n", c, e.q0, e.q1, f, n, n, r);
  73. else
  74. winevent(t->w, "%c%d %d %d 0 \n", c, e.q0, e.q1, f, n);
  75. free(r);
  76. goto Return;
  77. }
  78. if(plumbsendfd >= 0){
  79. /* send whitespace-delimited word to plumber */
  80. m = emalloc(sizeof(Plumbmsg));
  81. m->src = estrdup("acme");
  82. m->dst = nil;
  83. dir = dirname(t, nil, 0);
  84. if(dir.nr==1 && dir.r[0]=='.'){ /* sigh */
  85. free(dir.r);
  86. dir.r = nil;
  87. dir.nr = 0;
  88. }
  89. if(dir.nr == 0)
  90. m->wdir = estrdup(wdir);
  91. else
  92. m->wdir = runetobyte(dir.r, dir.nr);
  93. free(dir.r);
  94. m->type = estrdup("text");
  95. m->attr = nil;
  96. buf[0] = '\0';
  97. if(q1 == q0){
  98. if(t->q1>t->q0 && t->q0<=q0 && q0<=t->q1){
  99. q0 = t->q0;
  100. q1 = t->q1;
  101. }else{
  102. p = q0;
  103. while(q0>0 && (c=tgetc(t, q0-1))!=' ' && c!='\t' && c!='\n')
  104. q0--;
  105. while(q1<t->file->nc && (c=tgetc(t, q1))!=' ' && c!='\t' && c!='\n')
  106. q1++;
  107. if(q1 == q0){
  108. plumbfree(m);
  109. goto Return;
  110. }
  111. sprint(buf, "click=%d", p-q0);
  112. m->attr = plumbunpackattr(buf);
  113. }
  114. }
  115. r = runemalloc(q1-q0);
  116. bufread(t->file, q0, r, q1-q0);
  117. m->data = runetobyte(r, q1-q0);
  118. m->ndata = strlen(m->data);
  119. free(r);
  120. if(m->ndata<messagesize-1024 && plumbsend(plumbsendfd, m) >= 0){
  121. plumbfree(m);
  122. goto Return;
  123. }
  124. plumbfree(m);
  125. /* plumber failed to match; fall through */
  126. }
  127. /* interpret alphanumeric string ourselves */
  128. if(expanded == FALSE)
  129. return;
  130. if(e.name || e.at)
  131. openfile(t, &e);
  132. else{
  133. if(t->w == nil)
  134. return;
  135. ct = &t->w->body;
  136. if(t->w != ct->w)
  137. winlock(ct->w, 'M');
  138. if(t == ct)
  139. textsetselect(ct, e.q1, e.q1);
  140. n = e.q1 - e.q0;
  141. r = runemalloc(n);
  142. bufread(t->file, e.q0, r, n);
  143. if(search(ct, r, n) && e.jump)
  144. moveto(mousectl, addpt(frptofchar(ct, ct->p0), Pt(4, ct->font->height-4)));
  145. if(t->w != ct->w)
  146. winunlock(ct->w);
  147. free(r);
  148. }
  149. Return:
  150. free(e.name);
  151. free(e.bname);
  152. }
  153. int
  154. plumbgetc(void *a, uint n)
  155. {
  156. Rune *r;
  157. r = a;
  158. if(n>runestrlen(r))
  159. return 0;
  160. return r[n];
  161. }
  162. void
  163. plumblook(Plumbmsg *m)
  164. {
  165. Expand e;
  166. char *addr;
  167. if(m->ndata >= BUFSIZE){
  168. warning(nil, "insanely long file name (%d bytes) in plumb message (%.32s...)\n", m->ndata, m->data);
  169. return;
  170. }
  171. e.q0 = 0;
  172. e.q1 = 0;
  173. if(m->data[0] == '\0')
  174. return;
  175. e.ar = nil;
  176. e.bname = m->data;
  177. e.name = bytetorune(e.bname, &e.nname);
  178. e.jump = TRUE;
  179. e.a0 = 0;
  180. e.a1 = 0;
  181. addr = plumblookup(m->attr, "addr");
  182. if(addr != nil){
  183. e.ar = bytetorune(addr, &e.a1);
  184. e.agetc = plumbgetc;
  185. }
  186. openfile(nil, &e);
  187. free(e.name);
  188. free(e.at);
  189. }
  190. void
  191. plumbshow(Plumbmsg *m)
  192. {
  193. Window *w;
  194. Rune rb[256], *r;
  195. int nb, nr;
  196. Runestr rs;
  197. char *name, *p, namebuf[16];
  198. w = makenewwindow(nil);
  199. name = plumblookup(m->attr, "filename");
  200. if(name == nil){
  201. name = namebuf;
  202. nuntitled++;
  203. snprint(namebuf, sizeof namebuf, "Untitled-%d", nuntitled);
  204. }
  205. p = nil;
  206. if(name[0]!='/' && m->wdir!=nil && m->wdir[0]!='\0'){
  207. nb = strlen(m->wdir) + 1 + strlen(name) + 1;
  208. p = emalloc(nb);
  209. snprint(p, nb, "%s/%s", m->wdir, name);
  210. name = p;
  211. }
  212. cvttorunes(name, strlen(name), rb, &nb, &nr, nil);
  213. free(p);
  214. rs = cleanrname((Runestr){rb, nr});
  215. winsetname(w, rs.r, rs.nr);
  216. r = runemalloc(m->ndata);
  217. cvttorunes(m->data, m->ndata, r, &nb, &nr, nil);
  218. textinsert(&w->body, 0, r, nr, TRUE);
  219. free(r);
  220. w->body.file->mod = FALSE;
  221. w->dirty = FALSE;
  222. winsettag(w);
  223. textscrdraw(&w->body);
  224. textsetselect(&w->tag, w->tag.file->nc, w->tag.file->nc);
  225. }
  226. int
  227. search(Text *ct, Rune *r, uint n)
  228. {
  229. uint q, nb, maxn;
  230. int around;
  231. Rune *s, *b, *c;
  232. if(n==0 || n>ct->file->nc)
  233. return FALSE;
  234. if(2*n > RBUFSIZE){
  235. warning(nil, "string too long\n");
  236. return FALSE;
  237. }
  238. maxn = max(2*n, RBUFSIZE);
  239. s = fbufalloc();
  240. b = s;
  241. nb = 0;
  242. b[nb] = 0;
  243. around = 0;
  244. q = ct->q1;
  245. for(;;){
  246. if(q >= ct->file->nc){
  247. q = 0;
  248. around = 1;
  249. nb = 0;
  250. b[nb] = 0;
  251. }
  252. if(nb > 0){
  253. c = runestrchr(b, r[0]);
  254. if(c == nil){
  255. q += nb;
  256. nb = 0;
  257. b[nb] = 0;
  258. if(around && q>=ct->q1)
  259. break;
  260. continue;
  261. }
  262. q += (c-b);
  263. nb -= (c-b);
  264. b = c;
  265. }
  266. /* reload if buffer covers neither string nor rest of file */
  267. if(nb<n && nb!=ct->file->nc-q){
  268. nb = ct->file->nc-q;
  269. if(nb >= maxn)
  270. nb = maxn-1;
  271. bufread(ct->file, q, s, nb);
  272. b = s;
  273. b[nb] = '\0';
  274. }
  275. /* this runeeq is fishy but the null at b[nb] makes it safe */
  276. if(runeeq(b, n, r, n)==TRUE){
  277. if(ct->w){
  278. textshow(ct, q, q+n, 1);
  279. winsettag(ct->w);
  280. }else{
  281. ct->q0 = q;
  282. ct->q1 = q+n;
  283. }
  284. seltext = ct;
  285. fbuffree(s);
  286. return TRUE;
  287. }
  288. --nb;
  289. b++;
  290. q++;
  291. if(around && q>=ct->q1)
  292. break;
  293. }
  294. fbuffree(s);
  295. return FALSE;
  296. }
  297. int
  298. isfilec(Rune r)
  299. {
  300. if(isalnum(r))
  301. return TRUE;
  302. if(runestrchr(L".-+/:", r))
  303. return TRUE;
  304. return FALSE;
  305. }
  306. /* Runestr wrapper for cleanname */
  307. Runestr
  308. cleanrname(Runestr rs)
  309. {
  310. char *s;
  311. int nb, nulls;
  312. s = runetobyte(rs.r, rs.nr);
  313. cleanname(s);
  314. cvttorunes(s, strlen(s), rs.r, &nb, &rs.nr, &nulls);
  315. free(s);
  316. return rs;
  317. }
  318. Runestr
  319. includefile(Rune *dir, Rune *file, int nfile)
  320. {
  321. int m, n;
  322. char *a;
  323. Rune *r;
  324. m = runestrlen(dir);
  325. a = emalloc((m+1+nfile)*UTFmax+1);
  326. sprint(a, "%S/%.*S", dir, nfile, file);
  327. n = access(a, 0);
  328. free(a);
  329. if(n < 0)
  330. return (Runestr){nil, 0};
  331. r = runemalloc(m+1+nfile);
  332. runemove(r, dir, m);
  333. runemove(r+m, L"/", 1);
  334. runemove(r+m+1, file, nfile);
  335. free(file);
  336. return cleanrname((Runestr){r, m+1+nfile});
  337. }
  338. static Rune *objdir;
  339. Runestr
  340. includename(Text *t, Rune *r, int n)
  341. {
  342. Window *w;
  343. char buf[128];
  344. Runestr file;
  345. int i;
  346. if(objdir==nil && objtype!=nil){
  347. sprint(buf, "/%s/include", objtype);
  348. objdir = bytetorune(buf, &i);
  349. objdir = runerealloc(objdir, i+1);
  350. objdir[i] = '\0';
  351. }
  352. w = t->w;
  353. if(n==0 || r[0]=='/' || w==nil)
  354. goto Rescue;
  355. if(n>2 && r[0]=='.' && r[1]=='/')
  356. goto Rescue;
  357. file.r = nil;
  358. file.nr = 0;
  359. for(i=0; i<w->nincl && file.r==nil; i++)
  360. file = includefile(w->incl[i], r, n);
  361. if(file.r == nil)
  362. file = includefile(L"/sys/include", r, n);
  363. if(file.r==nil && objdir!=nil)
  364. file = includefile(objdir, r, n);
  365. if(file.r == nil)
  366. goto Rescue;
  367. return file;
  368. Rescue:
  369. return (Runestr){r, n};
  370. }
  371. Runestr
  372. dirname(Text *t, Rune *r, int n)
  373. {
  374. Rune *b, c;
  375. uint m, nt;
  376. int slash;
  377. Runestr tmp;
  378. b = nil;
  379. if(t==nil || t->w==nil)
  380. goto Rescue;
  381. nt = t->w->tag.file->nc;
  382. if(nt == 0)
  383. goto Rescue;
  384. if(n>=1 && r[0]=='/')
  385. goto Rescue;
  386. b = runemalloc(nt+n+1);
  387. bufread(t->w->tag.file, 0, b, nt);
  388. slash = -1;
  389. for(m=0; m<nt; m++){
  390. c = b[m];
  391. if(c == '/')
  392. slash = m;
  393. if(c==' ' || c=='\t')
  394. break;
  395. }
  396. if(slash < 0)
  397. goto Rescue;
  398. runemove(b+slash+1, r, n);
  399. free(r);
  400. return cleanrname((Runestr){b, slash+1+n});
  401. Rescue:
  402. free(b);
  403. tmp = (Runestr){r, n};
  404. if(r)
  405. return cleanrname(tmp);
  406. return tmp;
  407. }
  408. int
  409. expandfile(Text *t, uint q0, uint q1, Expand *e)
  410. {
  411. int i, n, nname, colon, eval;
  412. uint amin, amax;
  413. Rune *r, c;
  414. Window *w;
  415. Runestr rs;
  416. amax = q1;
  417. if(q1 == q0){
  418. colon = -1;
  419. while(q1<t->file->nc && isfilec(c=textreadc(t, q1))){
  420. if(c == ':'){
  421. colon = q1;
  422. break;
  423. }
  424. q1++;
  425. }
  426. while(q0>0 && (isfilec(c=textreadc(t, q0-1)) || isaddrc(c) || isregexc(c))){
  427. q0--;
  428. if(colon<0 && c==':')
  429. colon = q0;
  430. }
  431. /*
  432. * if it looks like it might begin file: , consume address chars after :
  433. * otherwise terminate expansion at :
  434. */
  435. if(colon >= 0){
  436. q1 = colon;
  437. if(colon<t->file->nc-1 && isaddrc(textreadc(t, colon+1))){
  438. q1 = colon+1;
  439. while(q1<t->file->nc && isaddrc(textreadc(t, q1)))
  440. q1++;
  441. }
  442. }
  443. if(q1 > q0)
  444. if(colon >= 0){ /* stop at white space */
  445. for(amax=colon+1; amax<t->file->nc; amax++)
  446. if((c=textreadc(t, amax))==' ' || c=='\t' || c=='\n')
  447. break;
  448. }else
  449. amax = t->file->nc;
  450. }
  451. amin = amax;
  452. e->q0 = q0;
  453. e->q1 = q1;
  454. n = q1-q0;
  455. if(n == 0)
  456. return FALSE;
  457. /* see if it's a file name */
  458. r = runemalloc(n);
  459. bufread(t->file, q0, r, n);
  460. /* first, does it have bad chars? */
  461. nname = -1;
  462. for(i=0; i<n; i++){
  463. c = r[i];
  464. if(c==':' && nname<0){
  465. if(q0+i+1<t->file->nc && (i==n-1 || isaddrc(textreadc(t, q0+i+1))))
  466. amin = q0+i;
  467. else
  468. goto Isntfile;
  469. nname = i;
  470. }
  471. }
  472. if(nname == -1)
  473. nname = n;
  474. for(i=0; i<nname; i++)
  475. if(!isfilec(r[i]))
  476. goto Isntfile;
  477. /*
  478. * See if it's a file name in <>, and turn that into an include
  479. * file name if so. Should probably do it for "" too, but that's not
  480. * restrictive enough syntax and checking for a #include earlier on the
  481. * line would be silly.
  482. */
  483. if(q0>0 && textreadc(t, q0-1)=='<' && q1<t->file->nc && textreadc(t, q1)=='>'){
  484. rs = includename(t, r, nname);
  485. r = rs.r;
  486. nname = rs.nr;
  487. }
  488. else if(amin == q0)
  489. goto Isfile;
  490. else{
  491. rs = dirname(t, r, nname);
  492. r = rs.r;
  493. nname = rs.nr;
  494. }
  495. e->bname = runetobyte(r, nname);
  496. /* if it's already a window name, it's a file */
  497. w = lookfile(r, nname);
  498. if(w != nil)
  499. goto Isfile;
  500. /* if it's the name of a file, it's a file */
  501. if(access(e->bname, 0) < 0){
  502. free(e->bname);
  503. e->bname = nil;
  504. goto Isntfile;
  505. }
  506. Isfile:
  507. e->name = r;
  508. e->nname = nname;
  509. e->at = t;
  510. e->a0 = amin+1;
  511. eval = FALSE;
  512. address(nil, nil, (Range){-1,-1}, (Range){0, 0}, t, e->a0, amax, tgetc, &eval, (uint*)&e->a1);
  513. return TRUE;
  514. Isntfile:
  515. free(r);
  516. return FALSE;
  517. }
  518. int
  519. expand(Text *t, uint q0, uint q1, Expand *e)
  520. {
  521. memset(e, 0, sizeof *e);
  522. e->agetc = tgetc;
  523. /* if in selection, choose selection */
  524. e->jump = TRUE;
  525. if(q1==q0 && t->q1>t->q0 && t->q0<=q0 && q0<=t->q1){
  526. q0 = t->q0;
  527. q1 = t->q1;
  528. if(t->what == Tag)
  529. e->jump = FALSE;
  530. }
  531. if(expandfile(t, q0, q1, e))
  532. return TRUE;
  533. if(q0 == q1){
  534. while(q1<t->file->nc && isalnum(textreadc(t, q1)))
  535. q1++;
  536. while(q0>0 && isalnum(textreadc(t, q0-1)))
  537. q0--;
  538. }
  539. e->q0 = q0;
  540. e->q1 = q1;
  541. return q1 > q0;
  542. }
  543. Window*
  544. lookfile(Rune *s, int n)
  545. {
  546. int i, j, k;
  547. Window *w;
  548. Column *c;
  549. Text *t;
  550. /* avoid terminal slash on directories */
  551. if(n>1 && s[n-1] == '/')
  552. --n;
  553. for(j=0; j<row.ncol; j++){
  554. c = row.col[j];
  555. for(i=0; i<c->nw; i++){
  556. w = c->w[i];
  557. t = &w->body;
  558. k = t->file->nname;
  559. if(k>1 && t->file->name[k-1] == '/')
  560. k--;
  561. if(runeeq(t->file->name, k, s, n)){
  562. w = w->body.file->curtext->w;
  563. if(w->col != nil) /* protect against race deleting w */
  564. return w;
  565. }
  566. }
  567. }
  568. return nil;
  569. }
  570. Window*
  571. lookid(int id, int dump)
  572. {
  573. int i, j;
  574. Window *w;
  575. Column *c;
  576. for(j=0; j<row.ncol; j++){
  577. c = row.col[j];
  578. for(i=0; i<c->nw; i++){
  579. w = c->w[i];
  580. if(dump && w->dumpid == id)
  581. return w;
  582. if(!dump && w->id == id)
  583. return w;
  584. }
  585. }
  586. return nil;
  587. }
  588. Window*
  589. openfile(Text *t, Expand *e)
  590. {
  591. Range r;
  592. Window *w, *ow;
  593. int eval, i, n;
  594. Rune *rp;
  595. uint dummy;
  596. if(e->nname == 0){
  597. w = t->w;
  598. if(w == nil)
  599. return nil;
  600. }else
  601. w = lookfile(e->name, e->nname);
  602. if(w){
  603. t = &w->body;
  604. if(!t->col->safe && t->maxlines==0) /* window is obscured by full-column window */
  605. colgrow(t->col, t->col->w[0], 1);
  606. }else{
  607. ow = nil;
  608. if(t)
  609. ow = t->w;
  610. w = makenewwindow(t);
  611. t = &w->body;
  612. winsetname(w, e->name, e->nname);
  613. textload(t, 0, e->bname, 1);
  614. t->file->mod = FALSE;
  615. t->w->dirty = FALSE;
  616. winsettag(t->w);
  617. textsetselect(&t->w->tag, t->w->tag.file->nc, t->w->tag.file->nc);
  618. if(ow != nil){
  619. for(i=ow->nincl; --i>=0; ){
  620. n = runestrlen(ow->incl[i]);
  621. rp = runemalloc(n);
  622. runemove(rp, ow->incl[i], n);
  623. winaddincl(w, rp, n);
  624. }
  625. w->autoindent = ow->autoindent;
  626. }else
  627. w->autoindent = globalautoindent;
  628. }
  629. if(e->a1 == e->a0)
  630. eval = FALSE;
  631. else{
  632. eval = TRUE;
  633. r = address(nil, t, (Range){-1, -1}, (Range){t->q0, t->q1}, e->at, e->a0, e->a1, e->agetc, &eval, &dummy);
  634. if(eval == FALSE)
  635. e->jump = FALSE; /* don't jump if invalid address */
  636. }
  637. if(eval == FALSE){
  638. r.q0 = t->q0;
  639. r.q1 = t->q1;
  640. }
  641. textshow(t, r.q0, r.q1, 1);
  642. winsettag(t->w);
  643. seltext = t;
  644. if(e->jump)
  645. moveto(mousectl, addpt(frptofchar(t, t->p0), Pt(4, font->height-4)));
  646. return w;
  647. }
  648. void
  649. new(Text *et, Text *t, Text *argt, int flag1, int flag2, Rune *arg, int narg)
  650. {
  651. int ndone;
  652. Rune *a, *f;
  653. int na, nf;
  654. Expand e;
  655. Runestr rs;
  656. getarg(argt, FALSE, TRUE, &a, &na);
  657. if(a){
  658. new(et, t, nil, flag1, flag2, a, na);
  659. if(narg == 0)
  660. return;
  661. }
  662. /* loop condition: *arg is not a blank */
  663. for(ndone=0; ; ndone++){
  664. a = findbl(arg, narg, &na);
  665. if(a == arg){
  666. if(ndone==0 && et->col!=nil)
  667. winsettag(coladd(et->col, nil, nil, -1));
  668. break;
  669. }
  670. nf = narg-na;
  671. f = runemalloc(nf);
  672. runemove(f, arg, nf);
  673. rs = dirname(et, f, nf);
  674. f = rs.r;
  675. nf = rs.nr;
  676. memset(&e, 0, sizeof e);
  677. e.name = f;
  678. e.nname = nf;
  679. e.bname = runetobyte(f, nf);
  680. e.jump = TRUE;
  681. openfile(et, &e);
  682. free(f);
  683. free(e.bname);
  684. arg = skipbl(a, na, &narg);
  685. }
  686. }