home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2325 < prev    next >
Internet Message Format  |  1990-12-28  |  90KB

  1. From: pfalstad@phoenix.Princeton.EDU (Paul John Falstad)
  2. Newsgroups: alt.sources
  3. Subject: zsh - ksh/tcsh-like shell (part 6 of 8)
  4. Message-ID: <4748@idunno.Princeton.EDU>
  5. Date: 14 Dec 90 23:32:40 GMT
  6.  
  7. ---cut here---cut here---cut here---
  8. -            }
  9. -    zerr("warning: undefined signal name: SIG%s",s+4);
  10. -}
  11. -
  12. -void unsettrap(char *s)
  13. -{
  14. -int t0;
  15. -
  16. -    if (strncmp(s,"TRAP",4))
  17. -        return;
  18. -    for (t0 = 0; t0 != SIGCOUNT+2; t0++)
  19. -        if (!strcmp(s+4,sigs[t0]))
  20. -            {
  21. -            if (jobbing && (t0 == SIGTTOU || t0 == SIGTSTP || t0 == SIGTTIN
  22. -                    || t0 == SIGPIPE))
  23. -                {
  24. -                zerr("can't trap SIG%s in interactive shells",s);
  25. -                return;
  26. -                }
  27. -            sigtrapped[t0] = 0;
  28. -            if (t0 == SIGINT)
  29. -                intr();
  30. -            else if (t0 && t0 < SIGCOUNT && t0 != SIGCHLD)
  31. -                signal(t0,SIG_DFL);
  32. -            return;
  33. -            }
  34. -    zerr("warning: undefined signal name: SIG%s",s+4);
  35. -}
  36. -
  37. -void dotrap(int sig)
  38. -{
  39. -char buf[16];
  40. -list l;
  41. -int sav;
  42. -
  43. -    sav = sigtrapped[sig];
  44. -    if (sav == 2)
  45. -        return;
  46. -    sigtrapped[sig] = 2;
  47. -    sprintf(buf,"TRAP%s",sigs[sig]);
  48. -    if (l = gethnode(buf,shfunchtab))
  49. -        newrunlist(l);
  50. -    sigtrapped[sig] = sav;
  51. -}
  52. -
  53. -/* get the text corresponding to a command */
  54. -
  55. -char *gettext(comm comm)
  56. -{
  57. -char *s,*t;
  58. -
  59. -    switch(comm->type)
  60. -        {
  61. -        case SIMPLE:
  62. -            return getsimptext(comm);
  63. -        case SUBSH:
  64. -            t = getltext(comm->left);
  65. -            s = tricat("(",t,")");
  66. -            free(t);
  67. -            return s;
  68. -        case CURSH:
  69. -        case SHFUNC:
  70. -            t = getltext(comm->left);
  71. -            s = tricat("{",t,"}");
  72. -            free(t);
  73. -            return s;
  74. -        case CFOR:
  75. -            return getfortext((struct fornode *) comm->info,comm);
  76. -        case CWHILE:
  77. -            return getwhiletext((struct whilenode *) comm->info);
  78. -        case CREPEAT:
  79. -            return getrepeattext((struct repeatnode *) comm->info);
  80. -        case CIF:
  81. -            return getiftext((struct ifnode *) comm->info);
  82. -        case CCASE:
  83. -            return getcasetext((struct casenode *) comm->info,comm->args);
  84. -        case CSELECT:
  85. -            return getfortext((struct fornode *) comm->info,comm);
  86. -        default:
  87. -            return strdup("(...)");
  88. -        }
  89. -    return NULL;
  90. -}
  91. -
  92. -char *getltext(list l)
  93. -{
  94. -char *s,*t,*u;
  95. -
  96. -    s = getl2text(l->left);
  97. -    if (l->type == ASYNC)
  98. -        {
  99. -        t = dyncat(s," &");
  100. -        free(s);
  101. -        s = t;
  102. -        }
  103. -    if (!l->right)
  104. -        return s;
  105. -    t = getltext(l->right);
  106. -    u = tricat(s,(l->type == SYNC) ? "\n" : "",t);
  107. -    free(s);
  108. -    free(t);
  109. -    return u;
  110. -}
  111. -
  112. -char *getl2text(list2 l)
  113. -{
  114. -char *s,*t,*u;
  115. -
  116. -    s = getptext(l->left);
  117. -    if (!l->right)
  118. -        return s;
  119. -    t = getl2text(l->right);
  120. -    u = tricat(s,(l->type == ORNEXT) ? " || " : " && ",t);
  121. -    free(s);
  122. -    free(t);
  123. -    return u;
  124. -}
  125. -
  126. -char *getptext(pline p)
  127. -{
  128. -char *s,*t,*u;
  129. -
  130. -    s = gettext(p->left);
  131. -    if (!p->right)
  132. -        return s;
  133. -    t = getptext(p->right);
  134. -    u = tricat(s," | ",t);
  135. -    free(s);
  136. -    free(t);
  137. -    return u;
  138. -}
  139. -
  140. -char *getsimptext(comm comm)
  141. -{
  142. -int len = 0;
  143. -Node n;
  144. -char *fstr[] = {
  145. -    ">",">!",">>",">>!","<","<<","<&",">&",">&-"
  146. -    };
  147. -struct fnode *f;
  148. -char *s,*t,u = '=';
  149. -
  150. -    for (n = comm->args->first; n; n = n->next)
  151. -        len += strlen(n->dat)+1;
  152. -    if (comm->vars)
  153. -        for (n = comm->vars->first; n; n = n->next)
  154. -            len += strlen(n->dat)+1;
  155. -    for (n = comm->redir->first; n; n = n->next)
  156. -        {
  157. -        f = n->dat;
  158. -        switch(f->type)
  159. -            {
  160. -            case WRITE: case WRITENOW: case APP: case APPNOW: case READ:
  161. -                len += strlen(fstr[f->type])+strlen(f->u.name)+8;
  162. -                break;
  163. -            case HEREDOC: case MERGE: case MERGEOUT:
  164. -                len += strlen(fstr[f->type])+10;
  165. -                break;
  166. -            case CLOSE:
  167. -                len += 10;
  168. -                break;
  169. -            case INPIPE:
  170. -            case OUTPIPE:
  171. -                len += strlen(f->u.name)+10;
  172. -                break;
  173. -            }
  174. -        }
  175. -    len += strlen(comm->cmd);
  176. -    s = t = zalloc(len+5);
  177. -    if (comm->vars)
  178. -        for (n = comm->vars->first; n; n = n->next)
  179. -            {
  180. -            strucpy(&t,n->dat);
  181. -            *t++ = u;
  182. -            u = ('='+' ')-u;
  183. -            }
  184. -    strucpy(&t,comm->cmd);
  185. -    *t++ = ' ';
  186. -    for (n = comm->args->first; n; n = n->next)
  187. -        {
  188. -        strucpy(&t,n->dat);
  189. -        *t++ = ' ';
  190. -        }
  191. -    for (n = comm->redir->first; n; n = n->next)
  192. -        {
  193. -        f = n->dat;
  194. -        switch(f->type)
  195. -            {
  196. -            case WRITE: case WRITENOW: case APP: case APPNOW: case READ:
  197. -                if (f->fd1 != ((f->type == READ) ? 0 : 1))
  198. -                    *t++ = '0'+f->fd1;
  199. -                strucpy(&t,fstr[f->type]);
  200. -                *t++ = ' ';
  201. -                strucpy(&t,f->u.name);
  202. -                *t++ = ' ';
  203. -                break;
  204. -            case HEREDOC: case MERGE: case MERGEOUT:
  205. -                if (f->fd1 != ((f->type == MERGEOUT) ? 1 : 0))
  206. -                    *t++ = '0'+f->fd1;
  207. -                strucpy(&t,fstr[f->type]);
  208. -                *t++ = ' ';
  209. -                sprintf(t,"%d ",f->u.fd2);
  210. -                t += strlen(t);
  211. -                break;
  212. -            case CLOSE:
  213. -                *t++ = '0'+f->fd1;
  214. -                strucpy(&t,">&- ");
  215. -                break;
  216. -            case INPIPE:
  217. -            case OUTPIPE:
  218. -                if (f->fd1 != ((f->type == INPIPE) ? 0 : 1))
  219. -                    *t++ = '0'+f->fd1;
  220. -                strucpy(&t,(f->type == INPIPE) ? "< " : "> ");
  221. -                strucpy(&t,f->u.name);
  222. -                strucpy(&t," ");
  223. -                len += strlen(f->u.name)+6;
  224. -                break;
  225. -            }
  226. -        }
  227. -    t[-1] = '\0';
  228. -    return s;
  229. -}
  230. -
  231. -char *getfortext(struct fornode *n,comm comm)
  232. -{
  233. -char *s,*t,*u,*v;
  234. -
  235. -    s = getltext(n->list);
  236. -    u = dyncat((comm->type == CFOR) ? "for " : "select ",n->name);
  237. -    if (comm->args)
  238. -        {
  239. -        t = makehlist(comm->args,0);
  240. -        v = tricat(u," in ",t);
  241. -        free(u);
  242. -        free(t);
  243. -        u = v;
  244. -        }
  245. -    v = dyncat(u,"\n do ");
  246. -    free(u);
  247. -    u = tricat(v,s,"\n done");
  248. -    free(v);
  249. -    free(s);
  250. -    return u;
  251. -}
  252. -
  253. -char *getwhiletext(struct whilenode *n)
  254. -{
  255. -char *s,*t,*u,*v;
  256. -
  257. -    t = getltext(n->cont);
  258. -    v = getltext(n->loop);
  259. -    s = tricat((!n->cond) ? "while " : "until ",t,"\n do ");
  260. -    u = tricat(s,v,"\n done");
  261. -    free(s);
  262. -    free(t);
  263. -    free(v);
  264. -    return u;
  265. -}
  266. -
  267. -char *getrepeattext(struct repeatnode *n)
  268. -{
  269. -char buf[100];
  270. -char *s,*t,*u;
  271. -
  272. -    s = getltext(n->list);
  273. -    sprintf(buf,"%d",n->count);
  274. -    t = tricat("repeat ",buf," do ");
  275. -    u = tricat(t,s,"\n done");
  276. -    free(s);
  277. -    free(t);
  278. -    return u;
  279. -}
  280. -
  281. -char *getiftext(struct ifnode *n)
  282. -{
  283. -int fst = 1;
  284. -char *v = strdup("");
  285. -char *s,*t,*u,*w;
  286. -
  287. -    while (n && n->ifl)
  288. -        {
  289. -        s = getltext(n->ifl);
  290. -        t = getltext(n->thenl);
  291. -        u = tricat((fst) ? "if " : "elif ",s,"\n then ");
  292. -        w = tricat(u,t,"\n ");
  293. -        free(s);
  294. -        free(t);
  295. -        free(u);
  296. -        s = dyncat(v,w);
  297. -        free(v);
  298. -        free(w);
  299. -        v = s;
  300. -        fst = 0;
  301. -        n = n->next;
  302. -        }
  303. -    if (n)
  304. -        {
  305. -        s = getltext(n->thenl);
  306. -        t = tricat(v,"else ",s);
  307. -        u = dyncat(t,"\n fi");
  308. -        free(s);
  309. -        free(t);
  310. -        free(v);
  311. -        return u;
  312. -        }
  313. -    u = dyncat(v,"\n fi");
  314. -    free(v);
  315. -    return u;
  316. -}
  317. -
  318. -char *getcasetext(struct casenode *n,table l)
  319. -{
  320. -char *s,*t,*u,*v;
  321. -
  322. -    s = tricat("case ",l->first->dat," in ");
  323. -    while (n)
  324. -        {
  325. -        u = getltext(n->list);
  326. -        t = tricat(n->pat,") ",u);
  327. -        v = tricat(s,t," ;;\n");
  328. -        free(s);
  329. -        free(t);
  330. -        free(u);
  331. -        s = v;
  332. -        n = n->next;
  333. -        }
  334. -    t = dyncat(s,"esac\n");
  335. -    free(s);
  336. -    return t;
  337. -}
  338. -
  339. -/* copy t into *s and update s */
  340. -
  341. -void strucpy(char **s,char *t)
  342. -{
  343. -char *u = *s;
  344. -
  345. -    while (*u++ = *t++);
  346. -    *s = u-1;
  347. -}
  348. -
  349. -void checkrmall(void)
  350. -{
  351. -    fflush(stdin);
  352. -    fprintf(stderr,"zsh: are you sure you want to delete "
  353. -        "all the files? ");
  354. -    fflush(stderr);
  355. -    ding();
  356. -    errflag |= !getquery();
  357. -}
  358. -
  359. -int getquery(void)
  360. -{
  361. -char c;
  362. -int yes = 0;
  363. -
  364. -    setcbreak();
  365. -    if (read(SHTTY,&c,1) == 1 && (c == 'y' || c == 'Y'))
  366. -        yes = 1;
  367. -    unsetcbreak();
  368. -    if (c != '\n')
  369. -        write(2,"\n",1);
  370. -    return yes;
  371. -}
  372. -
  373. -static int d;
  374. -static char *guess,*best;
  375. -
  376. -void spscan(char *s,char *junk)
  377. -{
  378. -int nd;
  379. -
  380. -    nd = spdist(s,guess);
  381. -    if (nd <= d && nd != 3)
  382. -        {
  383. -        best = s;
  384. -        d = nd;
  385. -        }
  386. -}
  387. -
  388. -/* spellcheck a command */
  389. -
  390. -void spckcmd(char **s)
  391. -{
  392. -char *t;
  393. -
  394. -    if (gethnode(*s,chtab) || gethnode(*s,shfunchtab))
  395. -        return;
  396. -    for (t = *s; *t; t++)
  397. -        if (*t == '/')
  398. -            return;
  399. -    if (access(*s,F_OK) == 0)
  400. -        return;
  401. -    best = NULL;
  402. -    guess = *s;
  403. -    d = 3;
  404. -    listhtable(chtab,spscan);
  405. -    listhtable(shfunchtab,spscan);
  406. -    if (best)
  407. -        {
  408. -        fprintf(stderr,"zsh: correct to `%s' (y/n)? ",best);
  409. -        fflush(stderr);
  410. -        ding();
  411. -        if (getquery())
  412. -            {
  413. -            free(*s);
  414. -            *s = strdup(best);
  415. -            }
  416. -        }
  417. -}
  418. -
  419. -void addlocal(char *s)
  420. -{
  421. -    if (locallist)
  422. -        addnode(locallist,strdup(s));
  423. -}
  424. -
  425. -/* perform pathname substitution on a PATH or CDPATH component */
  426. -
  427. -void pathsub(char **s)
  428. -{
  429. -    if (**s == '=')
  430. -        **s = Equals;
  431. -    if (**s == '~')
  432. -        **s = Tilde;
  433. -    filesub((void **) s);
  434. -}
  435. -
  436. -#ifndef STRFTIME
  437. -int strftime(char *buf,int bufsize,char *fmt,struct tm *tm)
  438. -{
  439. -char *astr[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
  440. -char *estr[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul",
  441. -    "Aug","Sep","Oct","Nov","Dec"};
  442. -char *lstr[] = {"12"," 1"," 2"," 3"," 4"," 5"," 6"," 7"," 8"," 9","10","11"};
  443. -
  444. -    while (*fmt)
  445. -        if (*fmt == '%')
  446. -            {
  447. -            fmt++;
  448. -            switch(*fmt++)
  449. -                {
  450. -                case 'a':
  451. -                    strucpy(&buf,astr[tm->tm_wday]);
  452. -                    break;
  453. -                case 'b':
  454. -                    strucpy(&buf,estr[tm->tm_mon]);
  455. -                    break;
  456. -                case 'd':
  457. -                    *buf++ = '0'+tm->tm_mday/10;
  458. -                    *buf++ = '0'+tm->tm_mday%10;
  459. -                    break;
  460. -                case 'e':
  461. -                    *buf++ = (tm->tm_mday > 9) ? '0'+tm->tm_mday/10 : ' ';
  462. -                    *buf++ = '0'+tm->tm_mday%10;
  463. -                    break;
  464. -                case 'k':
  465. -                    *buf++ = (tm->tm_hour > 9) ? '0'+tm->tm_hour/10 : ' ';
  466. -                    *buf++ = '0'+tm->tm_hour%10;
  467. -                    break;
  468. -                case 'l':
  469. -                    strucpy(&buf,lstr[tm->tm_hour%12]);
  470. -                    break;
  471. -                case 'm':
  472. -                    *buf++ = '0'+tm->tm_mon/10;
  473. -                    *buf++ = '0'+tm->tm_mon%10;
  474. -                    break;
  475. -                case 'M':
  476. -                    *buf++ = '0'+tm->tm_min/10;
  477. -                    *buf++ = '0'+tm->tm_min%10;
  478. -                    break;
  479. -                case 'p':
  480. -                    *buf++ = (tm->tm_hour > 11) ? 'P' : 'A';
  481. -                    *buf++ = 'M';
  482. -                    break;
  483. -                case 'S':
  484. -                    *buf++ = '0'+tm->tm_sec/10;
  485. -                    *buf++ = '0'+tm->tm_sec%10;
  486. -                    break;
  487. -                case 'y':
  488. -                    *buf++ = '0'+tm->tm_year/10;
  489. -                    *buf++ = '0'+tm->tm_year%10;
  490. -                    break;
  491. -                default:
  492. -                    exit(20);
  493. -                }
  494. -            }
  495. -        else
  496. -            *buf++ = *fmt++;
  497. -    *buf = '\0';
  498. -    return 0;
  499. -}
  500. -#endif
  501. -
  502. -#ifndef PUTENV
  503. -int putenv(char *a)
  504. -{
  505. -char *b = a;
  506. -
  507. -    while (*a++ != '=');
  508. -    a[-1] = '\0';
  509. -    setenv(strdup(b),strdup(a));
  510. -    free(b);
  511. -    return 0;
  512. -}
  513. -#endif
  514. -
  515. -int ppcount(void)
  516. -{
  517. -Node n;
  518. -int val = -1;
  519. -
  520. -    for (n = pparms->first; n; n = n->next,val++);
  521. -    return val;
  522. -}
  523. -
  524. End of utils.c
  525. echo utils.pro 1>&2
  526. sed 's/^-//' >utils.pro <<'End of utils.pro'
  527. -void addvars(table vars);
  528. -void setiparm(char *s,long v,int isint);
  529. -void setparm(char *s,char *t,int ex,int isint);
  530. -void unsetparm(char *s);
  531. -long getiparm(char *s);
  532. -char *getparm(char *s);
  533. -void parsepath(void);
  534. -void parsecdpath(void);
  535. -int source(char *s);
  536. -void sourcehome(char *s);
  537. -void zerrnam(char *cmd, char *fmt, ...);
  538. -void zerr(char *fmt,...);
  539. -void niceputc(int c,FILE *f);
  540. -void intr(void);
  541. -void noholdintr(void);
  542. -void holdintr(void);
  543. -char *fgetline(char *buf,int len,FILE *in);
  544. -char *findcwd(char *s);
  545. -char *xsymlink(char *s);
  546. -char **slashsplit(char *s);
  547. -int islink(char *s);
  548. -int xsymlinks(char *s);
  549. -void printdir(char *s);
  550. -int ddifftime(time_t t1,time_t t2);
  551. -void scanjobs(void);
  552. -void preprompt(void);
  553. -void checkmail(void);
  554. -void checkfirstmail(void);
  555. -void checkmailpath(void);
  556. -void createchtab(void);
  557. -void freechnode(void *a);
  558. -void freestr(void *a);
  559. -void freeanode(void *a);
  560. -void freeredir(void *a);
  561. -void freeshfunc(void *a);
  562. -void freepm(void *a);
  563. -void restoretty(void);
  564. -void gettyinfo(struct ttyinfo *ti);
  565. -void settyinfo(struct ttyinfo *ti);
  566. -int zyztem(char *s,char *t);
  567. -int waitfork(void);
  568. -int movefd(int fd);
  569. -void redup(int x,int y);
  570. -void settrap(char *s,int empty);
  571. -void unsettrap(char *s);
  572. -void dotrap(int sig);
  573. -char *gettext(comm comm);
  574. -char *getltext(list l);
  575. -char *getl2text(list2 l);
  576. -char *getptext(pline p);
  577. -char *getsimptext(comm comm);
  578. -char *getfortext(struct fornode *n,comm comm);
  579. -char *getwhiletext(struct whilenode *n);
  580. -char *getrepeattext(struct repeatnode *n);
  581. -char *getiftext(struct ifnode *n);
  582. -char *getcasetext(struct casenode *n,table l);
  583. -void strucpy(char **s,char *t);
  584. -void checkrmall(void);
  585. -int getquery(void);
  586. -void spscan(char *s,char *junk);
  587. -void spckcmd(char **s);
  588. -void addlocal(char *s);
  589. -void pathsub(char **s);
  590. -int strftime(char *buf,int bufsize,char *fmt,struct tm *tm);
  591. End of utils.pro
  592. echo vars.c 1>&2
  593. sed 's/^-//' >vars.c <<'End of vars.c'
  594. -/*
  595. -
  596. -    vars.c - variable declarations
  597. -
  598. -    This file is part of zsh, the Z shell.
  599. -
  600. -   zsh is free software; no one can prevent you from reading the source
  601. -   code, or giving it to someone else.
  602. -   This file is copyrighted under the GNU General Public License, which
  603. -   can be found in the file called COPYING.
  604. -
  605. -   Copyright (C) 1990 Paul Falstad
  606. -
  607. -   zsh is distributed in the hope that it will be useful, but
  608. -   WITHOUT ANY WARRANTY.  No author or distributor accepts
  609. -   responsibility to anyone for the consequences of using it or for
  610. -   whether it serves any particular purpose or works at all, unless he
  611. -   says so in writing.  Refer to the GNU General Public License
  612. -   for full details.
  613. -
  614. -   Everyone is granted permission to copy, modify and redistribute
  615. -   zsh, but only under the conditions described in the GNU General Public
  616. -   License.   A copy of this license is supposed to have been given to you
  617. -   along with zsh so you can know your rights and responsibilities.
  618. -   It should be in a file named COPYING.
  619. -
  620. -   Among other things, the copyright notice and this notice must be
  621. -   preserved on all copies.
  622. -
  623. -*/
  624. -
  625. -#include "zsh.h"
  626. -
  627. -/* buffered shell input for non-interactive shells */
  628. -
  629. -FILE *bshin;
  630. -
  631. -/* null-terminated array of pointers to strings containing elements
  632. -    of PATH and CDPATH */
  633. -
  634. -char **path,**cdpath;
  635. -
  636. -/* number of elements in aforementioned array */
  637. -
  638. -int pathct,cdpathct;
  639. -
  640. -/* error/break flag */
  641. -
  642. -int errflag = 0;
  643. -
  644. -/* current history event number */
  645. -
  646. -int cev = 0;
  647. -
  648. -/* if != 0, this is the first line of the command */
  649. -
  650. -int firstln;
  651. -
  652. -/* if != 0, this is the first char of the command (not including
  653. -    white space */
  654. -
  655. -int firstch;
  656. -
  657. -/* first event number in the history table */
  658. -
  659. -int tfev = 1;
  660. -
  661. -/* capacity of history table */
  662. -
  663. -int tevs = 20;
  664. -
  665. -/* if = 1, we have performed history substitution on the current line
  666. -    if = 2, we have used the 'p' modifier */
  667. -
  668. -int hflag;
  669. -
  670. -/* default event (usually cev-1, that is, "!!") */
  671. -
  672. -int dev = 0;
  673. -
  674. -/* != 0 if we are in the middle of parsing a command (== 0 if we
  675. -    have not yet parsed the command word */
  676. -
  677. -int incmd = 0;
  678. -
  679. -/* the list of history events */
  680. -
  681. -table histlist;
  682. -
  683. -/* the current history event (can be NULL) */
  684. -
  685. -table curtab;
  686. -
  687. -/* the directory stack */
  688. -
  689. -table dirstack;
  690. -
  691. -/* a string containing all the ungot characters (hungetch()) */
  692. -
  693. -char *ungots;
  694. -
  695. -/* the pointer to the next character to read from ungots */
  696. -
  697. -char *ungotptr;
  698. -
  699. -/* the contents of the IFS parameter */
  700. -
  701. -char *ifs;
  702. -
  703. -/* != 0 if this is a subshell */
  704. -
  705. -int subsh;
  706. -
  707. -/* # of break levels (break builtin) */
  708. -
  709. -int breaks;
  710. -
  711. -/* != 0 if we have a return pending (return builtin) */
  712. -
  713. -int retflag;
  714. -
  715. -/* # of nested loops we are in */
  716. -
  717. -int loops;
  718. -
  719. -/* # of continue levels */
  720. -
  721. -int contflag;
  722. -
  723. -/* the job currently being created/waited for (not current job in the sense
  724. -    of '+' and '-', that's topjob */
  725. -
  726. -int curjob;
  727. -
  728. -/* the current job (+) */
  729. -
  730. -int topjob = -1;
  731. -
  732. -/* the previous job (-) */
  733. -
  734. -int prevjob = -1;
  735. -
  736. -/* hash table containing the aliases and reserved words */
  737. -
  738. -htable alhtab;
  739. -
  740. -/* hash table containing the parameters */
  741. -
  742. -htable parmhtab;
  743. -
  744. -/* hash table containing the builtins/hashed commands */
  745. -
  746. -htable chtab;
  747. -
  748. -/* hash table containing the shell functions */
  749. -
  750. -htable shfunchtab;
  751. -
  752. -/* the job table */
  753. -
  754. -struct jobnode jobtab[MAXJOB];
  755. -
  756. -/* the list of sched jobs pending */
  757. -
  758. -struct schnode *scheds = NULL;
  759. -
  760. -/* the last l for s/l/r/ history substitution */
  761. -
  762. -char *last;
  763. -
  764. -/* the last r for s/l/r/ history substitution */
  765. -
  766. -char *rast;
  767. -
  768. -/* if peek == STRING or ENVSTRING, the next token */
  769. -
  770. -char *tstr;
  771. -
  772. -/* who am i */
  773. -
  774. -char *username;
  775. -
  776. -/* the return code of the last command */
  777. -
  778. -int lastval;
  779. -
  780. -/* != 0 if this is a login shell */
  781. -
  782. -int islogin;
  783. -
  784. -/* the next token (enum xtok) */
  785. -
  786. -int peek;
  787. -
  788. -/* the file descriptor associated with the next token, if it
  789. -    is something like '<' or '>>', etc. */
  790. -
  791. -int peekfd;
  792. -
  793. -/* input fd from the coprocess */
  794. -
  795. -int spin = -1;
  796. -
  797. -/* output fd from the coprocess */
  798. -
  799. -int spout = -1;
  800. -
  801. -/* the last time we checked mail */
  802. -
  803. -time_t lastmailcheck;
  804. -
  805. -/* the last modified date on the mail file last time we checked */
  806. -
  807. -time_t lastmailval;
  808. -
  809. -/* the last time we checked the people in the WATCH variable */
  810. -
  811. -time_t lastwatch;
  812. -
  813. -/* the last time we did the periodic() shell function */
  814. -
  815. -time_t lastperiod;
  816. -
  817. -/* $SECONDS = time(NULL) - shtimer */
  818. -
  819. -time_t shtimer;
  820. -
  821. -/* the size of the mail file last time we checked */
  822. -
  823. -off_t lastmailsize;
  824. -
  825. -/* $$ */
  826. -
  827. -long procnum;
  828. -
  829. -/* $! (the pid of the last background command invoked */
  830. -
  831. -long proclast;
  832. -
  833. -/* the process group of the shell */
  834. -
  835. -long shpgrp;
  836. -
  837. -/* the current working directory */
  838. -
  839. -char *cwd;
  840. -
  841. -/* the hostname, truncated after the '.' */
  842. -
  843. -char *hostM;
  844. -
  845. -/* the hostname */
  846. -
  847. -char *hostm;
  848. -
  849. -/* the home directory */
  850. -
  851. -char *home;
  852. -
  853. -/* the positional parameters */
  854. -
  855. -table pparms;
  856. -
  857. -/* the list of local variables we have to destroy */
  858. -
  859. -table locallist;
  860. -
  861. -/* the shell input fd */
  862. -
  863. -int SHIN;
  864. -
  865. -/* the shell tty fd */
  866. -
  867. -int SHTTY;
  868. -
  869. -/* the stack of aliases we are expanding */
  870. -
  871. -struct anode *alstack[MAXAL];
  872. -
  873. -/* the alias stack pointer; also, the number of aliases currently
  874. -    being expanded */
  875. -
  876. -int alix = 0;
  877. -
  878. -/* != 0 means we are reading input from a string */
  879. -
  880. -int strin = 0;
  881. -
  882. -/* == 1 means we are doing TAB expansion
  883. -    == 2 means expansion has occurred during TAB expansion */
  884. -
  885. -int magic = 0;
  886. -
  887. -/* period between periodic() commands, in seconds */
  888. -
  889. -int period = 0;
  890. -
  891. -/* != 0 means history is turned off (through !" or setopt nobanghist) */
  892. -
  893. -int stophist = 0;
  894. -
  895. -/* != 0 means we have removed the current event from the history list */
  896. -
  897. -int histremmed = 0;
  898. -
  899. -/* the options; e.g. if opts['a'] is nonzero, -a is turned on */
  900. -
  901. -int opts[128];
  902. -
  903. -/* LINENO */
  904. -
  905. -int lineno;
  906. -
  907. -/* != 0 means we have called execlist() and then intend to exit(),
  908. -    so don't fork if not necessary */
  909. -
  910. -int exiting = 0;
  911. -
  912. -/* the limits for child processes */
  913. -
  914. -struct rlimit limits[RLIM_NLIMITS];
  915. -
  916. -/* the tokens */
  917. -
  918. -char *tokens = "#$^*()$=|{}[]`<>?~`,";
  919. -
  920. -/* the current word in the history list */
  921. -
  922. -char *hlastw;
  923. -
  924. -/* the pointer to the current character in the current word
  925. -    in the history list */
  926. -
  927. -char *hlastp;
  928. -
  929. -/* the size of the current word in the history list */
  930. -
  931. -int hlastsz;
  932. -
  933. -/* the alias expansion status - if == ALSTAT_MORE, we just finished
  934. -    expanding an alias ending with a space */
  935. -
  936. -int alstat;
  937. -
  938. -/* we have printed a 'you have stopped (running) jobs.' message */
  939. -
  940. -int stopmsg;
  941. -
  942. -/* the default tty state */
  943. -
  944. -struct ttyinfo shttyinfo;
  945. -
  946. -/* signal names */
  947. -
  948. -char *sigs[] = { "EXIT",
  949. - "HUP", "INT", "QUIT", "ILL", "TRAP", "IOT", "EMT", "FPE", "KILL",
  950. - "BUS", "SEGV", "SYS", "PIPE", "ALRM", "TERM", "URG", "STOP", "TSTP",
  951. - "CONT", "CHLD", "TTIN", "TTOU", "IO", "XCPU", "XFSZ", "VTALRM", "PROF",
  952. - "WINCH", "LOST", "USR1", "USR2", "ERR", "DEBUG"
  953. -};
  954. -
  955. -/* signals that are trapped = 1, signals ignored =2 */
  956. -
  957. -int sigtrapped[SIGCOUNT+2];
  958. -
  959. End of vars.c
  960. echo vars.pro 1>&2
  961. sed 's/^-//' >vars.pro <<'End of vars.pro'
  962. End of vars.pro
  963. echo zhistory.c 1>&2
  964. sed 's/^-//' >zhistory.c <<'End of zhistory.c'
  965. -/*
  966. -
  967. -    zhistory.c - interface between readline an zsh's ideas of history
  968. -
  969. -    This file is part of zsh, the Z shell.
  970. -
  971. -   zsh is free software; no one can prevent you from reading the source
  972. -   code, or giving it to someone else.
  973. -   This file is copyrighted under the GNU General Public License, which
  974. -   can be found in the file called COPYING.
  975. -
  976. -   Copyright (C) 1990 Paul Falstad
  977. -
  978. -   zsh is distributed in the hope that it will be useful, but
  979. -   WITHOUT ANY WARRANTY.  No author or distributor accepts
  980. -   responsibility to anyone for the consequences of using it or for
  981. -   whether it serves any particular purpose or works at all, unless he
  982. -   says so in writing.  Refer to the GNU General Public License
  983. -   for full details.
  984. -
  985. -   Everyone is granted permission to copy, modify and redistribute
  986. -   zsh, but only under the conditions described in the GNU General Public
  987. -   License.   A copy of this license is supposed to have been given to you
  988. -   along with zsh so you can know your rights and responsibilities.
  989. -   It should be in a file named COPYING.
  990. -
  991. -   Among other things, the copyright notice and this notice must be
  992. -   preserved on all copies.
  993. -
  994. -*/
  995. -
  996. -#include "zsh.h"
  997. -#include "funcs.h"
  998. -#include "readline/history.h"
  999. -
  1000. -/* bindings to make zsh and readline get along */
  1001. -
  1002. -static int histline;
  1003. -
  1004. -void using_history(void)
  1005. -{
  1006. -    histline = cev;
  1007. -}
  1008. -
  1009. -int where_history(void)
  1010. -{
  1011. -    return histline;
  1012. -}
  1013. -
  1014. -int history_set_pos(int pos)
  1015. -{
  1016. -    histline = pos;
  1017. -    return 0;
  1018. -}
  1019. -
  1020. -HIST_ENTRY *current_history(void)
  1021. -{
  1022. -table tab;
  1023. -char *str;
  1024. -HIST_ENTRY *he;
  1025. -
  1026. -    tab = quietgetevent(histline);
  1027. -    if (!tab)
  1028. -        return NULL;
  1029. -    str = makehlist(tab,0);
  1030. -    he = (HIST_ENTRY *) malloc(sizeof *he);
  1031. -    he->line = str;
  1032. -    he->data = NULL;
  1033. -    return he;
  1034. -}
  1035. -
  1036. -HIST_ENTRY *previous_history(void)
  1037. -{
  1038. -    if (histline == tfev)
  1039. -        return NULL;
  1040. -    histline--;
  1041. -    return current_history();
  1042. -}
  1043. -
  1044. -HIST_ENTRY *next_history(void)
  1045. -{
  1046. -    if (histline == cev)
  1047. -        return NULL;
  1048. -    histline++;
  1049. -    return current_history();
  1050. -}
  1051. -
  1052. -char *extracthistarg(int num)
  1053. -{
  1054. -Node n;
  1055. -
  1056. -    if (histlist->last == (Node) histlist ||
  1057. -            histlist->last->last == (Node) histlist)
  1058. -        return NULL;
  1059. -    n = ((table) (histlist->last->last))->first;
  1060. -    for (; n && num; num--,n = n->next);
  1061. -    if (!n)
  1062. -        return NULL;
  1063. -    return strdup(n->dat);
  1064. -}
  1065. -
  1066. End of zhistory.c
  1067. echo readline/chardefs.h 1>&2
  1068. sed 's/^-//' >readline/chardefs.h <<'End of readline/chardefs.h'
  1069. -/* chardefs.h -- Character definitions for readline. */
  1070. -#ifndef _CHARDEFS_
  1071. -
  1072. -#ifndef savestring
  1073. -#define savestring(x) (char *)strcpy (xmalloc (1 + strlen (x)), (x))
  1074. -#endif
  1075. -
  1076. -#ifndef whitespace
  1077. -#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
  1078. -#endif
  1079. -
  1080. -#ifdef CTRL
  1081. -#undef CTRL
  1082. -#endif
  1083. -
  1084. -/* Some character stuff. */
  1085. -#define control_character_threshold 0x020   /* smaller than this is control */
  1086. -#define meta_character_threshold 0x07f        /* larger than this is Meta. */
  1087. -#define control_character_bit 0x40        /* 0x000000, must be off. */
  1088. -#define meta_character_bit 0x080        /* x0000000, must be on. */
  1089. -
  1090. -#define CTRL(c) ((c) & (~control_character_bit))
  1091. -#define META(c) ((c) | meta_character_bit)
  1092. -
  1093. -#define UNMETA(c) ((c) & (~meta_character_bit))
  1094. -#define UNCTRL(c) to_upper(((c)|control_character_bit))
  1095. -
  1096. -#define lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1)))
  1097. -#define uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1)))
  1098. -
  1099. -#define pure_alphabetic(c) (lowercase_p(c) || uppercase_p(c))
  1100. -
  1101. -#ifndef to_upper
  1102. -#define to_upper(c) (lowercase_p(c) ? ((c) - 32) : (c))
  1103. -#define to_lower(c) (uppercase_p(c) ? ((c) + 32) : (c))
  1104. -#endif
  1105. -
  1106. -#define CTRL_P(c) ((c) < control_character_threshold)
  1107. -#define META_P(c) ((c) > meta_character_threshold)
  1108. -
  1109. -#define NEWLINE '\n'
  1110. -#define RETURN CTRL('M')
  1111. -#define RUBOUT 0x07f
  1112. -#define TAB '\t'
  1113. -#define ABORT_CHAR CTRL('G')
  1114. -#define PAGE CTRL('L')
  1115. -#define SPACE 0x020
  1116. -#define ESC CTRL('[')
  1117. -
  1118. -#endif  /* _CHARDEFS_ */
  1119. End of readline/chardefs.h
  1120. echo readline/emacs_keymap.c 1>&2
  1121. sed 's/^-//' >readline/emacs_keymap.c <<'End of readline/emacs_keymap.c'
  1122. -/* emacs_keymap.c -- the keymap for emacs_mode in readline (). */
  1123. -
  1124. -/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
  1125. -
  1126. -   This file is part of GNU Readline, a library for reading lines
  1127. -   of text with interactive input and history editing.
  1128. -
  1129. -   Readline is free software; you can redistribute it and/or modify it
  1130. -   under the terms of the GNU General Public License as published by the
  1131. -   Free Software Foundation; either version 1, or (at your option) any
  1132. -   later version.
  1133. -
  1134. -   Readline is distributed in the hope that it will be useful, but
  1135. -   WITHOUT ANY WARRANTY; without even the implied warranty of
  1136. -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  1137. -   General Public License for more details.
  1138. -
  1139. -   You should have received a copy of the GNU General Public License
  1140. -   along with Readline; see the file COPYING.  If not, write to the Free
  1141. -   Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  1142. -
  1143. -#ifndef FILE
  1144. -#include <stdio.h>
  1145. -#endif /* FILE */
  1146. -
  1147. -#include "readline.h"
  1148. -
  1149. -/* An array of function pointers, one for each possible key.
  1150. -   If the type byte is ISKMAP, then the pointer is the address of
  1151. -   a keymap. */
  1152. -
  1153. -KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
  1154. -
  1155. -  /* Control keys. */
  1156. -  { ISFUNC, (Function *)0x0 },        /* Control-@ */
  1157. -  { ISFUNC, rl_beg_of_line },        /* Control-a */
  1158. -  { ISFUNC, rl_backward },        /* Control-b */
  1159. -  { ISFUNC, (Function *)0x0 },    /* Control-c */
  1160. -  { ISFUNC, rl_delete },        /* Control-d */
  1161. -  { ISFUNC, rl_end_of_line },        /* Control-e */
  1162. -  { ISFUNC, rl_forward },        /* Control-f */
  1163. -  { ISFUNC, rl_abort },            /* Control-g */
  1164. -  { ISFUNC, rl_rubout },        /* Control-h */  /* pjf */
  1165. -  { ISFUNC, rl_complete },        /* Control-i */
  1166. -  { ISFUNC, rl_newline },        /* Control-j */
  1167. -  { ISFUNC, rl_kill_line },        /* Control-k */
  1168. -  { ISFUNC, rl_clear_screen },        /* Control-l */
  1169. -  { ISFUNC, rl_newline },        /* Control-m */
  1170. -  { ISFUNC, rl_get_next_history },    /* Control-n */
  1171. -  { ISFUNC, (Function *)0x0 },        /* Control-o */
  1172. -  { ISFUNC, rl_get_previous_history },    /* Control-p */
  1173. -  { ISFUNC, rl_quoted_insert },        /* Control-q */
  1174. -  { ISFUNC, (Function *)0x0 }, /* Control-r */
  1175. -  { ISFUNC, (Function *)0x0 }, /* Control-s */
  1176. -  { ISFUNC, rl_transpose_chars },    /* Control-t */
  1177. -  { ISFUNC, rl_unix_line_discard },    /* Control-u */
  1178. -  { ISFUNC, rl_quoted_insert },        /* Control-v */
  1179. -  { ISFUNC, rl_unix_word_rubout },    /* Control-w */
  1180. -  { ISKMAP, (Function *)emacs_ctlx_keymap },    /* Control-x */
  1181. -  { ISFUNC, rl_yank },            /* Control-y */
  1182. -  { ISFUNC, (Function *)0x0 },        /* Control-z */
  1183. -  { ISKMAP, (Function *)emacs_meta_keymap }, /* Control-[ */
  1184. -  { ISFUNC, (Function *)0x0 },        /* Control-\ */
  1185. -  { ISFUNC, (Function *)0x0 },        /* Control-] */
  1186. -  { ISFUNC, (Function *)0x0 },        /* Control-^ */
  1187. -  { ISFUNC, rl_undo_command },        /* Control-_ */
  1188. -
  1189. -  /* The start of printing characters. */
  1190. -  { ISFUNC, rl_insert },    /* SPACE */
  1191. -  { ISFUNC, rl_insert },    /* ! */
  1192. -  { ISFUNC, rl_insert },    /* " */
  1193. -  { ISFUNC, rl_insert },    /* # */
  1194. -  { ISFUNC, rl_insert },    /* $ */
  1195. -  { ISFUNC, rl_insert },    /* % */
  1196. -  { ISFUNC, rl_insert },    /* & */
  1197. -  { ISFUNC, rl_insert },    /* ' */
  1198. -  { ISFUNC, rl_insert },    /* ( */
  1199. -  { ISFUNC, rl_insert },    /* ) */
  1200. -  { ISFUNC, rl_insert },    /* * */
  1201. -  { ISFUNC, rl_insert },    /* + */
  1202. -  { ISFUNC, rl_insert },    /* , */
  1203. -  { ISFUNC, rl_insert },    /* - */
  1204. -  { ISFUNC, rl_insert },    /* . */
  1205. -  { ISFUNC, rl_insert },    /* / */
  1206. -
  1207. -  /* Regular digits. */
  1208. -  { ISFUNC, rl_insert },    /* 0 */
  1209. -  { ISFUNC, rl_insert },    /* 1 */
  1210. -  { ISFUNC, rl_insert },    /* 2 */
  1211. -  { ISFUNC, rl_insert },    /* 3 */
  1212. -  { ISFUNC, rl_insert },    /* 4 */
  1213. -  { ISFUNC, rl_insert },    /* 5 */
  1214. -  { ISFUNC, rl_insert },    /* 6 */
  1215. -  { ISFUNC, rl_insert },    /* 7 */
  1216. -  { ISFUNC, rl_insert },    /* 8 */
  1217. -  { ISFUNC, rl_insert },    /* 9 */
  1218. -
  1219. -  /* A little more punctuation. */
  1220. -  { ISFUNC, rl_insert },    /* : */
  1221. -  { ISFUNC, rl_insert },    /* ; */
  1222. -  { ISFUNC, rl_insert },    /* < */
  1223. -  { ISFUNC, rl_insert },    /* = */
  1224. -  { ISFUNC, rl_insert },    /* > */
  1225. -  { ISFUNC, rl_insert },    /* ? */
  1226. -  { ISFUNC, rl_insert },    /* @ */
  1227. -
  1228. -  /* Uppercase alphabet. */
  1229. -  { ISFUNC, rl_insert },    /* A */
  1230. -  { ISFUNC, rl_insert },    /* B */
  1231. -  { ISFUNC, rl_insert },    /* C */
  1232. -  { ISFUNC, rl_insert },    /* D */
  1233. -  { ISFUNC, rl_insert },    /* E */
  1234. -  { ISFUNC, rl_insert },    /* F */
  1235. -  { ISFUNC, rl_insert },    /* G */
  1236. -  { ISFUNC, rl_insert },    /* H */
  1237. -  { ISFUNC, rl_insert },    /* I */
  1238. -  { ISFUNC, rl_insert },    /* J */
  1239. -  { ISFUNC, rl_insert },    /* K */
  1240. -  { ISFUNC, rl_insert },    /* L */
  1241. -  { ISFUNC, rl_insert },    /* M */
  1242. -  { ISFUNC, rl_insert },    /* N */
  1243. -  { ISFUNC, rl_insert },    /* O */
  1244. -  { ISFUNC, rl_insert },    /* P */
  1245. -  { ISFUNC, rl_insert },    /* Q */
  1246. -  { ISFUNC, rl_insert },    /* R */
  1247. -  { ISFUNC, rl_insert },    /* S */
  1248. -  { ISFUNC, rl_insert },    /* T */
  1249. -  { ISFUNC, rl_insert },    /* U */
  1250. -  { ISFUNC, rl_insert },    /* V */
  1251. -  { ISFUNC, rl_insert },    /* W */
  1252. -  { ISFUNC, rl_insert },    /* X */
  1253. -  { ISFUNC, rl_insert },    /* Y */
  1254. -  { ISFUNC, rl_insert },    /* Z */
  1255. -
  1256. -  /* Some more punctuation. */
  1257. -  { ISFUNC, rl_insert },    /* [ */
  1258. -  { ISFUNC, rl_insert },    /* \ */
  1259. -  { ISFUNC, rl_insert },    /* ] */
  1260. -  { ISFUNC, rl_insert },    /* ^ */
  1261. -  { ISFUNC, rl_insert },    /* _ */
  1262. -  { ISFUNC, rl_insert },    /* ` */
  1263. -
  1264. -  /* Lowercase alphabet. */
  1265. -  { ISFUNC, rl_insert },    /* a */
  1266. -  { ISFUNC, rl_insert },    /* b */
  1267. -  { ISFUNC, rl_insert },    /* c */
  1268. -  { ISFUNC, rl_insert },    /* d */
  1269. -  { ISFUNC, rl_insert },    /* e */
  1270. -  { ISFUNC, rl_insert },    /* f */
  1271. -  { ISFUNC, rl_insert },    /* g */
  1272. -  { ISFUNC, rl_insert },    /* h */
  1273. -  { ISFUNC, rl_insert },    /* i */
  1274. -  { ISFUNC, rl_insert },    /* j */
  1275. -  { ISFUNC, rl_insert },    /* k */
  1276. -  { ISFUNC, rl_insert },    /* l */
  1277. -  { ISFUNC, rl_insert },    /* m */
  1278. -  { ISFUNC, rl_insert },    /* n */
  1279. -  { ISFUNC, rl_insert },    /* o */
  1280. -  { ISFUNC, rl_insert },    /* p */
  1281. -  { ISFUNC, rl_insert },    /* q */
  1282. -  { ISFUNC, rl_insert },    /* r */
  1283. -  { ISFUNC, rl_insert },    /* s */
  1284. -  { ISFUNC, rl_insert },    /* t */
  1285. -  { ISFUNC, rl_insert },    /* u */
  1286. -  { ISFUNC, rl_insert },    /* v */
  1287. -  { ISFUNC, rl_insert },    /* w */
  1288. -  { ISFUNC, rl_insert },    /* x */
  1289. -  { ISFUNC, rl_insert },    /* y */
  1290. -  { ISFUNC, rl_insert },    /* z */
  1291. -
  1292. -  /* Final punctuation. */
  1293. -  { ISFUNC, rl_insert },    /* { */
  1294. -  { ISFUNC, rl_insert },    /* | */
  1295. -  { ISFUNC, rl_insert },    /* } */
  1296. -  { ISFUNC, rl_insert },    /* ~ */
  1297. -  { ISFUNC, rl_rubout }        /* RUBOUT */
  1298. -};
  1299. -
  1300. -KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
  1301. -
  1302. -  /* Meta keys.  Just like above, but the high bit is set. */
  1303. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-@ */
  1304. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-a */
  1305. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-b */
  1306. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-c */
  1307. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-d */
  1308. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-e */
  1309. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-f */
  1310. -  { ISFUNC, rl_abort },        /* Meta-Control-g */
  1311. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-h */
  1312. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-i */
  1313. -  { ISFUNC, rl_vi_editing_mode }, /* Meta-Control-j */
  1314. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-k */
  1315. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-l */
  1316. -  { ISFUNC, rl_vi_editing_mode }, /* Meta-Control-m */
  1317. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-n */
  1318. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-o */
  1319. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-p */
  1320. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-q */
  1321. -  { ISFUNC, rl_revert_line },    /* Meta-Control-r */
  1322. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-s */
  1323. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-t */
  1324. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-u */
  1325. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-v */
  1326. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-w */
  1327. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-x */
  1328. -  { ISFUNC, rl_yank_nth_arg },    /* Meta-Control-y */
  1329. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-z */
  1330. -
  1331. -  { ISFUNC, (Function *)0x0 },   /* Meta-Control-[ */
  1332. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-\ */
  1333. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-] */
  1334. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-^ */
  1335. -  { ISFUNC, (Function *)0x0 },    /* Meta-Control-_ */
  1336. -
  1337. -  /* The start of printing characters. */
  1338. -  { ISFUNC, (Function *)rl_magic_space },    /* Meta-SPACE */
  1339. -  { ISFUNC, (Function *)0x0 },    /* Meta-! */
  1340. -  { ISFUNC, (Function *)0x0 },    /* Meta-" */
  1341. -  { ISFUNC, (Function *)0x0 },    /* Meta-# */
  1342. -  { ISFUNC, rl_check_spelling },    /* Meta-$ */
  1343. -  { ISFUNC, (Function *)0x0 },    /* Meta-% */
  1344. -  { ISFUNC, (Function *)0x0 },    /* Meta-& */
  1345. -  { ISFUNC, (Function *)0x0 },    /* Meta-' */
  1346. -  { ISFUNC, (Function *)0x0 },    /* Meta-( */
  1347. -  { ISFUNC, (Function *)0x0 },    /* Meta-) */
  1348. -  { ISFUNC, (Function *)0x0 },    /* Meta-* */
  1349. -  { ISFUNC, (Function *)0x0 },    /* Meta-+ */
  1350. -  { ISFUNC, (Function *)0x0 },    /* Meta-, */
  1351. -  { ISFUNC, rl_digit_argument }, /* Meta-- */
  1352. -  { ISFUNC, (Function *)0x0 },    /* Meta-. */
  1353. -  { ISFUNC, (Function *)0x0 },    /* Meta-/ */
  1354. -
  1355. -  /* Regular digits. */
  1356. -  { ISFUNC, rl_digit_argument }, /* Meta-0 */
  1357. -  { ISFUNC, rl_digit_argument }, /* Meta-1 */
  1358. -  { ISFUNC, rl_digit_argument }, /* Meta-2 */
  1359. -  { ISFUNC, rl_digit_argument }, /* Meta-3 */
  1360. -  { ISFUNC, rl_digit_argument }, /* Meta-4 */
  1361. -  { ISFUNC, rl_digit_argument }, /* Meta-5 */
  1362. -  { ISFUNC, rl_digit_argument }, /* Meta-6 */
  1363. -  { ISFUNC, rl_digit_argument }, /* Meta-7 */
  1364. -  { ISFUNC, rl_digit_argument }, /* Meta-8 */
  1365. -  { ISFUNC, rl_digit_argument }, /* Meta-9 */
  1366. -
  1367. -  /* A little more punctuation. */
  1368. -  { ISFUNC, (Function *)0x0 },        /* Meta-: */
  1369. -  { ISFUNC, (Function *)0x0 },        /* Meta-; */
  1370. -  { ISFUNC, rl_beginning_of_history },    /* Meta-< */
  1371. -  { ISFUNC, (Function *)0x0 },        /* Meta-= */
  1372. -  { ISFUNC, rl_end_of_history },    /* Meta-> */
  1373. -  { ISFUNC, rl_possible_completions },    /* Meta-? */
  1374. -  { ISFUNC, (Function *)0x0 },        /* Meta-@ */
  1375. -
  1376. -  /* Uppercase alphabet. */
  1377. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-A */
  1378. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-B */
  1379. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-C */
  1380. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-D */
  1381. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-E */
  1382. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-F */
  1383. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-G */
  1384. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-H */
  1385. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-I */
  1386. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-J */
  1387. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-K */
  1388. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-L */
  1389. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-M */
  1390. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-N */
  1391. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-O */
  1392. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-P */
  1393. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-Q */
  1394. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-R */
  1395. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-S */
  1396. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-T */
  1397. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-U */
  1398. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-V */
  1399. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-W */
  1400. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-X */
  1401. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-Y */
  1402. -  { ISFUNC, rl_do_lowercase_version },    /* Meta-Z */
  1403. -
  1404. -  /* Some more punctuation. */
  1405. -  { ISFUNC, rl_function_key },    /* Meta-[ */
  1406. -  { ISFUNC, (Function *)0x0 },    /* Meta-\ */
  1407. -  { ISFUNC, (Function *)0x0 },    /* Meta-] */
  1408. -  { ISFUNC, (Function *)0x0 },    /* Meta-^ */
  1409. -  { ISFUNC, (Function *)0x0 },    /* Meta-_ */
  1410. -  { ISFUNC, (Function *)0x0 },    /* Meta-` */
  1411. -
  1412. -  /* Lowercase alphabet. */
  1413. -  { ISFUNC, (Function *)0x0 },    /* Meta-a */
  1414. -  { ISFUNC, rl_backward_word },    /* Meta-b */
  1415. -  { ISFUNC, rl_capitalize_word }, /* Meta-c */
  1416. -  { ISFUNC, rl_kill_word },    /* Meta-d */
  1417. -  { ISFUNC, (Function *)0x0 },    /* Meta-e */
  1418. -  { ISFUNC, rl_forward_word },    /* Meta-f */
  1419. -  { ISFUNC, (Function *)0x0 },    /* Meta-g */
  1420. -  { ISFUNC, (Function *)0x0 },    /* Meta-h */
  1421. -  { ISFUNC, (Function *)0x0 },    /* Meta-i */
  1422. -  { ISFUNC, (Function *)0x0 },    /* Meta-j */
  1423. -  { ISFUNC, (Function *)0x0 },    /* Meta-k */
  1424. -  { ISFUNC, rl_downcase_word },    /* Meta-l */
  1425. -  { ISFUNC, (Function *)0x0 },    /* Meta-m */
  1426. -  { ISFUNC, (Function *)0x0 },    /* Meta-n */
  1427. -  { ISFUNC, (Function *)0x0 },    /* Meta-o */
  1428. -  { ISFUNC, (Function *)0x0 },    /* Meta-p */
  1429. -  { ISFUNC, (Function *)0x0 },    /* Meta-q */
  1430. -  { ISFUNC, rl_revert_line },    /* Meta-r */
  1431. -  { ISFUNC, (Function *)0x0 },    /* Meta-s */
  1432. -  { ISFUNC, rl_transpose_words }, /* Meta-t */
  1433. -  { ISFUNC, rl_upcase_word },    /* Meta-u */
  1434. -  { ISFUNC, (Function *)0x0 },    /* Meta-v */
  1435. -  { ISFUNC, (Function *)0x0 },    /* Meta-w */
  1436. -  { ISFUNC, (Function *)0x0 },    /* Meta-x */
  1437. -  { ISFUNC, rl_yank_pop },    /* Meta-y */
  1438. -  { ISFUNC, (Function *)0x0 },    /* Meta-z */
  1439. -
  1440. -  /* Final punctuation. */
  1441. -  { ISFUNC, (Function *)0x0 },    /* Meta-{ */
  1442. -  { ISFUNC, (Function *)0x0 },    /* Meta-| */
  1443. -  { ISFUNC, (Function *)0x0 },    /* Meta-} */
  1444. -  { ISFUNC, (Function *)0x0 },    /* Meta-~ */
  1445. -  { ISFUNC, rl_backward_kill_word } /* Meta-rubout */
  1446. -};
  1447. -
  1448. -KEYMAP_ENTRY_ARRAY emacs_ctlx_keymap = {
  1449. -
  1450. -  /* Control keys. */
  1451. -  { ISFUNC, (Function *)0x0 },        /* Control-@ */
  1452. -  { ISFUNC, (Function *)0x0 },        /* Control-a */
  1453. -  { ISFUNC, (Function *)0x0 },        /* Control-b */
  1454. -  { ISFUNC, (Function *)0x0 },        /* Control-c */
  1455. -  { ISFUNC, (Function *)0x0 },        /* Control-d */
  1456. -  { ISFUNC, (Function *)0x0 },        /* Control-e */
  1457. -  { ISFUNC, (Function *)0x0 },        /* Control-f */
  1458. -  { ISFUNC, rl_abort },            /* Control-g */
  1459. -  { ISFUNC, (Function *)0x0 },        /* Control-h */
  1460. -  { ISFUNC, (Function *)0x0 },        /* Control-i */
  1461. -  { ISFUNC, (Function *)0x0 },        /* Control-j */
  1462. -  { ISFUNC, (Function *)0x0 },        /* Control-k */
  1463. -  { ISFUNC, (Function *)0x0 },        /* Control-l */
  1464. -  { ISFUNC, (Function *)0x0 },        /* Control-m */
  1465. -  { ISFUNC, (Function *)0x0 },        /* Control-n */
  1466. -  { ISFUNC, (Function *)0x0 },        /* Control-o */
  1467. -  { ISFUNC, (Function *)0x0 },        /* Control-p */
  1468. -  { ISFUNC, (Function *)0x0 },        /* Control-q */
  1469. -  { ISFUNC, rl_re_read_init_file },    /* Control-r */
  1470. -  { ISFUNC, (Function *)0x0 },        /* Control-s */
  1471. -  { ISFUNC, (Function *)0x0 },        /* Control-t */
  1472. -  { ISFUNC, rl_undo_command },        /* Control-u */
  1473. -  { ISFUNC, (Function *)0x0 },        /* Control-v */
  1474. -  { ISFUNC, (Function *)0x0 },        /* Control-w */
  1475. -  { ISFUNC, (Function *)0x0 },        /* Control-x */
  1476. -  { ISFUNC, (Function *)0x0 },        /* Control-y */
  1477. -  { ISFUNC, (Function *)0x0 },        /* Control-z */
  1478. -  { ISFUNC, (Function *)0x0 },        /* Control-[ */
  1479. -  { ISFUNC, (Function *)0x0 },        /* Control-\ */
  1480. -  { ISFUNC, (Function *)0x0 },        /* Control-] */
  1481. -  { ISFUNC, (Function *)0x0 },        /* Control-^ */
  1482. -  { ISFUNC, (Function *)0x0 },        /* Control-_ */
  1483. -
  1484. -  /* The start of printing characters. */
  1485. -  { ISFUNC, (Function *)0x0 },        /* SPACE */
  1486. -  { ISFUNC, (Function *)0x0 },        /* ! */
  1487. -  { ISFUNC, (Function *)0x0 },        /* " */
  1488. -  { ISFUNC, (Function *)0x0 },        /* # */
  1489. -  { ISFUNC, (Function *)0x0 },        /* $ */
  1490. -  { ISFUNC, (Function *)0x0 },        /* % */
  1491. -  { ISFUNC, (Function *)0x0 },        /* & */
  1492. -  { ISFUNC, (Function *)0x0 },        /* ' */
  1493. -  { ISFUNC, rl_start_kbd_macro },    /* ( */
  1494. -  { ISFUNC, rl_end_kbd_macro  },    /* ) */
  1495. -  { ISFUNC, (Function *)0x0 },        /* * */
  1496. -  { ISFUNC, (Function *)0x0 },        /* + */
  1497. -  { ISFUNC, (Function *)0x0 },        /* , */
  1498. -  { ISFUNC, (Function *)0x0 },        /* - */
  1499. -  { ISFUNC, (Function *)0x0 },        /* . */
  1500. -  { ISFUNC, (Function *)0x0 },        /* / */
  1501. -
  1502. -  /* Regular digits. */
  1503. -  { ISFUNC, (Function *)0x0 },        /* 0 */
  1504. -  { ISFUNC, (Function *)0x0 },        /* 1 */
  1505. -  { ISFUNC, (Function *)0x0 },        /* 2 */
  1506. -  { ISFUNC, (Function *)0x0 },        /* 3 */
  1507. -  { ISFUNC, (Function *)0x0 },        /* 4 */
  1508. -  { ISFUNC, (Function *)0x0 },        /* 5 */
  1509. -  { ISFUNC, (Function *)0x0 },        /* 6 */
  1510. -  { ISFUNC, (Function *)0x0 },        /* 7 */
  1511. -  { ISFUNC, (Function *)0x0 },        /* 8 */
  1512. -  { ISFUNC, (Function *)0x0 },        /* 9 */
  1513. -
  1514. -  /* A little more punctuation. */
  1515. -  { ISFUNC, (Function *)0x0 },    /* : */
  1516. -  { ISFUNC, (Function *)0x0 },    /* ; */
  1517. -  { ISFUNC, (Function *)0x0 },    /* < */
  1518. -  { ISFUNC, (Function *)0x0 },    /* = */
  1519. -  { ISFUNC, (Function *)0x0 },    /* > */
  1520. -  { ISFUNC, (Function *)0x0 },    /* ? */
  1521. -  { ISFUNC, (Function *)0x0 },    /* @ */
  1522. -
  1523. -  /* Uppercase alphabet. */
  1524. -  { ISFUNC, rl_do_lowercase_version },    /* A */
  1525. -  { ISFUNC, rl_do_lowercase_version },    /* B */
  1526. -  { ISFUNC, rl_do_lowercase_version },    /* C */
  1527. -  { ISFUNC, rl_do_lowercase_version },    /* D */
  1528. -  { ISFUNC, rl_do_lowercase_version },    /* E */
  1529. -  { ISFUNC, rl_do_lowercase_version },    /* F */
  1530. -  { ISFUNC, rl_do_lowercase_version },    /* G */
  1531. -  { ISFUNC, rl_do_lowercase_version },    /* H */
  1532. -  { ISFUNC, rl_do_lowercase_version },    /* I */
  1533. -  { ISFUNC, rl_do_lowercase_version },    /* J */
  1534. -  { ISFUNC, rl_do_lowercase_version },    /* K */
  1535. -  { ISFUNC, rl_do_lowercase_version },    /* L */
  1536. -  { ISFUNC, rl_do_lowercase_version },    /* M */
  1537. -  { ISFUNC, rl_do_lowercase_version },    /* N */
  1538. -  { ISFUNC, rl_do_lowercase_version },    /* O */
  1539. -  { ISFUNC, rl_do_lowercase_version },    /* P */
  1540. -  { ISFUNC, rl_do_lowercase_version },    /* Q */
  1541. -  { ISFUNC, rl_do_lowercase_version },    /* R */
  1542. -  { ISFUNC, rl_do_lowercase_version },    /* S */
  1543. -  { ISFUNC, rl_do_lowercase_version },    /* T */
  1544. -  { ISFUNC, rl_do_lowercase_version },    /* U */
  1545. -  { ISFUNC, rl_do_lowercase_version },    /* V */
  1546. -  { ISFUNC, rl_do_lowercase_version },    /* W */
  1547. -  { ISFUNC, rl_do_lowercase_version },    /* X */
  1548. -  { ISFUNC, rl_do_lowercase_version },    /* Y */
  1549. -  { ISFUNC, rl_do_lowercase_version },    /* Z */
  1550. -
  1551. -  /* Some more punctuation. */
  1552. -  { ISFUNC, (Function *)0x0 },        /* [ */
  1553. -  { ISFUNC, (Function *)0x0 },        /* \ */
  1554. -  { ISFUNC, (Function *)0x0 },        /* ] */
  1555. -  { ISFUNC, (Function *)0x0 },        /* ^ */
  1556. -  { ISFUNC, (Function *)0x0 },        /* _ */
  1557. -  { ISFUNC, (Function *)0x0 },        /* ` */
  1558. -
  1559. -  /* Lowercase alphabet. */
  1560. -  { ISFUNC, (Function *)0x0 },        /* a */
  1561. -  { ISFUNC, (Function *)0x0 },        /* b */
  1562. -  { ISFUNC, (Function *)0x0 },        /* c */
  1563. -  { ISFUNC, (Function *)0x0 },        /* d */
  1564. -  { ISFUNC, rl_call_last_kbd_macro },    /* e */
  1565. -  { ISFUNC, (Function *)0x0 },        /* f */
  1566. -  { ISFUNC, (Function *)0x0 },        /* g */
  1567. -  { ISFUNC, (Function *)0x0 },        /* h */
  1568. -  { ISFUNC, (Function *)0x0 },        /* i */
  1569. -  { ISFUNC, (Function *)0x0 },        /* j */
  1570. -  { ISFUNC, (Function *)0x0 },        /* k */
  1571. -  { ISFUNC, (Function *)0x0 },        /* l */
  1572. -  { ISFUNC, (Function *)0x0 },        /* m */
  1573. -  { ISFUNC, (Function *)0x0 },        /* n */
  1574. -  { ISFUNC, (Function *)0x0 },        /* o */
  1575. -  { ISFUNC, (Function *)0x0 },        /* p */
  1576. -  { ISFUNC, (Function *)0x0 },        /* q */
  1577. -  { ISFUNC, (Function *)0x0 },        /* r */
  1578. -  { ISFUNC, (Function *)0x0 },        /* s */
  1579. -  { ISFUNC, (Function *)0x0 },        /* t */
  1580. -  { ISFUNC, (Function *)0x0 },        /* u */
  1581. -  { ISFUNC, (Function *)0x0 },        /* v */
  1582. -  { ISFUNC, (Function *)0x0 },        /* w */
  1583. -  { ISFUNC, (Function *)0x0 },        /* x */
  1584. -  { ISFUNC, (Function *)0x0 },        /* y */
  1585. -  { ISFUNC, (Function *)0x0 },        /* z */
  1586. -
  1587. -  /* Final punctuation. */
  1588. -  { ISFUNC, (Function *)0x0 },        /* { */
  1589. -  { ISFUNC, (Function *)0x0 },        /* | */
  1590. -  { ISFUNC, (Function *)0x0 },        /* } */
  1591. -  { ISFUNC, (Function *)0x0 },        /* ~ */
  1592. -  { ISFUNC, rl_backward_kill_line }    /* RUBOUT */
  1593. -};
  1594. End of readline/emacs_keymap.c
  1595. echo readline/funmap.c 1>&2
  1596. sed 's/^-//' >readline/funmap.c <<'End of readline/funmap.c'
  1597. -/* funmap.c -- attach names to functions. */
  1598. -
  1599. -/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
  1600. -
  1601. -   This file is part of GNU Readline, a library for reading lines
  1602. -   of text with interactive input and history editing.
  1603. -
  1604. -   Readline is free software; you can redistribute it and/or modify it
  1605. -   under the terms of the GNU General Public License as published by the
  1606. -   Free Software Foundation; either version 1, or (at your option) any
  1607. -   later version.
  1608. -
  1609. -   Readline is distributed in the hope that it will be useful, but
  1610. -   WITHOUT ANY WARRANTY; without even the implied warranty of
  1611. -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  1612. -   General Public License for more details.
  1613. -
  1614. -   You should have received a copy of the GNU General Public License
  1615. -   along with Readline; see the file COPYING.  If not, write to the Free
  1616. -   Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  1617. -
  1618. -#define STATIC_MALLOC
  1619. -#ifndef STATIC_MALLOC
  1620. -extern char *xmalloc (), *xrealloc ();
  1621. -#else
  1622. -static char *xmalloc (), *xrealloc ();
  1623. -#endif
  1624. -
  1625. -#ifndef FILE
  1626. -#include <stdio.h>
  1627. -#endif /* FILE */
  1628. -
  1629. -#include "readline.h"
  1630. -
  1631. -FUNMAP **funmap = (FUNMAP **)NULL;
  1632. -static int funmap_size = 0;
  1633. -static int funmap_entry = 0;
  1634. -
  1635. -static FUNMAP default_funmap[] = {
  1636. -  { "beginning-of-line", rl_beg_of_line },
  1637. -  { "backward-char", rl_backward },
  1638. -  { "delete-char", rl_delete },
  1639. -  { "end-of-line", rl_end_of_line },
  1640. -  { "forward-char", rl_forward },
  1641. -  { "accept-line", rl_newline },
  1642. -  { "kill-line", rl_kill_line },
  1643. -  { "clear-screen", rl_clear_screen },
  1644. -  { "next-history", rl_get_next_history },
  1645. -  { "previous-history", rl_get_previous_history },
  1646. -  { "quoted-insert", rl_quoted_insert },
  1647. -  { "transpose-chars", rl_transpose_chars },
  1648. -  { "unix-line-discard", rl_unix_line_discard },
  1649. -  { "unix-word-rubout", rl_unix_word_rubout },
  1650. -  { "yank", rl_yank },
  1651. -  { "yank-pop", rl_yank_pop },
  1652. -  { "yank-nth-arg", rl_yank_nth_arg },
  1653. -  { "backward-delete-char", rl_rubout },
  1654. -  { "backward-word", rl_backward_word },
  1655. -  { "kill-word", rl_kill_word },
  1656. -  { "forward-word", rl_forward_word },
  1657. -  { "tab-insert", rl_tab_insert },
  1658. -  { "backward-kill-word", rl_backward_kill_word },
  1659. -  { "backward-kill-line", rl_backward_kill_line },
  1660. -  { "transpose-words", rl_transpose_words },
  1661. -  { "digit-argument", rl_digit_argument },
  1662. -  { "complete", rl_complete },
  1663. -  { "possible-completions", rl_possible_completions },
  1664. -  { "do-lowercase-version", rl_do_lowercase_version },
  1665. -  { "digit-argument", rl_digit_argument },
  1666. -  { "universal-argument", rl_universal_argument },
  1667. -  { "abort", rl_abort },
  1668. -  { "undo", rl_undo_command },
  1669. -  { "upcase-word", rl_upcase_word },
  1670. -  { "downcase-word", rl_downcase_word },
  1671. -  { "capitalize-word", rl_capitalize_word },
  1672. -  { "revert-line", rl_revert_line },
  1673. -  { "beginning-of-history", rl_beginning_of_history },
  1674. -  { "end-of-history", rl_end_of_history },
  1675. -  { "self-insert", rl_insert },
  1676. -  { "start-kbd-macro", rl_start_kbd_macro },
  1677. -  { "end-kbd-macro", rl_end_kbd_macro },
  1678. -  { "re-read-init-file", rl_re_read_init_file },
  1679. -  { "history-expand", rl_magic_space },
  1680. -  { "check-spelling", rl_check_spelling },
  1681. -#ifdef VI_MODE
  1682. -  { "vi-movement-mode", rl_vi_movement_mode },
  1683. -  { "vi-insertion-mode", rl_vi_insertion_mode },
  1684. -  { "vi-arg-digit", rl_vi_arg_digit },
  1685. -  { "vi-prev-word", rl_vi_prev_word },
  1686. -  { "vi-next-word", rl_vi_next_word },
  1687. -  { "vi-char-search", rl_vi_char_search },
  1688. -  { "vi-editing-mode", rl_vi_editing_mode },
  1689. -  { "vi-eof-maybe", rl_vi_eof_maybe },
  1690. -  { "vi-append-mode", rl_vi_append_mode },
  1691. -  { "vi-put", rl_vi_put },
  1692. -  { "vi-append-eol", rl_vi_append_eol },
  1693. -  { "vi-insert-beg", rl_vi_insert_beg },
  1694. -  { "vi-delete", rl_vi_delete },
  1695. -  { "vi-comment", rl_vi_comment },
  1696. -  { "vi-first-print", rl_vi_first_print },
  1697. -  { "vi-fword", rl_vi_fword },
  1698. -  { "vi-fWord", rl_vi_fWord },
  1699. -  { "vi-bword", rl_vi_bword },
  1700. -  { "vi-bWord", rl_vi_bWord },
  1701. -  { "vi-eword", rl_vi_eword },
  1702. -  { "vi-eWord", rl_vi_eWord },
  1703. -  { "vi-end-word", rl_vi_end_word },
  1704. -  { "vi-change-case", rl_vi_change_case },
  1705. -  { "vi-match", rl_vi_match },
  1706. -  { "vi-bracktype", rl_vi_bracktype },
  1707. -  { "vi-change-char", rl_vi_change_char },
  1708. -  { "vi-yank-arg", rl_vi_yank_arg },
  1709. -  { "vi-search", rl_vi_search },
  1710. -  { "vi-search-again", rl_vi_search_again },
  1711. -  { "vi-dosearch", rl_vi_dosearch },
  1712. -  { "vi-subst", rl_vi_subst },
  1713. -  { "vi-overstrike", rl_vi_overstrike },
  1714. -  { "vi-overstrike-delete", rl_vi_overstrike_delete },
  1715. -  { "vi-replace, ", rl_vi_replace },
  1716. -  { "vi-column", rl_vi_column },
  1717. -  { "vi-delete-to", rl_vi_delete_to },
  1718. -  { "vi-change-to", rl_vi_change_to },
  1719. -  { "vi-yank-to", rl_vi_yank_to },
  1720. -  { "vi-complete", rl_vi_complete },
  1721. -#endif /* VI_MODE */
  1722. -
  1723. - {(char *)NULL, (Function *)NULL }
  1724. -};
  1725. -
  1726. -rl_add_funmap_entry (name, function)
  1727. -     char *name;
  1728. -     Function *function;
  1729. -{
  1730. -  if (funmap_entry + 2 >= funmap_size)
  1731. -    if (!funmap)
  1732. -      funmap = (FUNMAP **)xmalloc ((funmap_size = 80) * sizeof (FUNMAP *));
  1733. -    else
  1734. -      funmap =
  1735. -    (FUNMAP **)xrealloc (funmap, (funmap_size += 80) * sizeof (FUNMAP *));
  1736. -  
  1737. -  funmap[funmap_entry] = (FUNMAP *)xmalloc (sizeof (FUNMAP));
  1738. -  funmap[funmap_entry]->name = name;
  1739. -  funmap[funmap_entry]->function = function;
  1740. -
  1741. -  funmap[++funmap_entry] = (FUNMAP *)NULL;
  1742. -}
  1743. -
  1744. -static int funmap_initialized = 0;
  1745. -
  1746. -/* Make the funmap contain all of the default entries. */
  1747. -rl_initialize_funmap ()
  1748. -{
  1749. -  register int i;
  1750. -
  1751. -  if (funmap_initialized)
  1752. -    return;
  1753. -
  1754. -  for (i = 0; default_funmap[i].name; i++)
  1755. -    rl_add_funmap_entry (default_funmap[i].name, default_funmap[i].function);
  1756. -
  1757. -  funmap_initialized = 1;
  1758. -}
  1759. -
  1760. -/* Things that mean `Control'. */
  1761. -char *possible_control_prefixes[] = {
  1762. -  "Control-", "C-", "CTRL-", (char *)NULL
  1763. -};
  1764. -
  1765. -char *possible_meta_prefixes[] = {
  1766. -  "Meta", "M-", (char *)NULL
  1767. -};
  1768. -
  1769. -#ifdef STATIC_MALLOC
  1770. -
  1771. -/* **************************************************************** */
  1772. -/*                                    */
  1773. -/*            xmalloc and xrealloc ()                     */
  1774. -/*                                    */
  1775. -/* **************************************************************** */
  1776. -
  1777. -static void memory_error_and_abort ();
  1778. -
  1779. -static char *
  1780. -xmalloc (bytes)
  1781. -     int bytes;
  1782. -{
  1783. -  char *temp = (char *)malloc (bytes);
  1784. -
  1785. -  if (!temp)
  1786. -    memory_error_and_abort ();
  1787. -  return (temp);
  1788. -}
  1789. -
  1790. -static char *
  1791. -xrealloc (pointer, bytes)
  1792. -     char *pointer;
  1793. -     int bytes;
  1794. -{
  1795. -  char *temp = (char *)realloc (pointer, bytes);
  1796. -
  1797. -  if (!temp)
  1798. -    memory_error_and_abort ();
  1799. -  return (temp);
  1800. -}
  1801. -
  1802. -static void
  1803. -memory_error_and_abort ()
  1804. -{
  1805. -  fprintf (stderr, "history: Out of virtual memory!\n");
  1806. -  abort ();
  1807. -}
  1808. -#endif /* STATIC_MALLOC */
  1809. End of readline/funmap.c
  1810. echo readline/history.h 1>&2
  1811. sed 's/^-//' >readline/history.h <<'End of readline/history.h'
  1812. -/* History.h -- the names of functions that you can call in history. */
  1813. -/* modified by pjf */
  1814. -
  1815. -typedef struct _hist_entry {
  1816. -  char *line;
  1817. -  char *data;
  1818. -} HIST_ENTRY;
  1819. -
  1820. -/* For convenience only.  You set this when interpreting history commands.
  1821. -   It is the logical offset of the first history element. */
  1822. -extern int tfev;
  1823. -#define history_base tfev
  1824. -
  1825. -/* Begin a session in which the history functions might be used.  This
  1826. -   just initializes the interactive variables. */
  1827. -extern void using_history ();
  1828. -
  1829. -/* Place STRING at the end of the history list.
  1830. -   The associated data field (if any) is set to NULL. */
  1831. -/* extern void add_history (); */
  1832. -
  1833. -/* Returns the number which says what history element we are now
  1834. -   looking at.  */
  1835. -extern int where_history ();
  1836. -  
  1837. -/* Set the position in the history list to POS. */
  1838. -int history_set_pos ();
  1839. -   
  1840. -/* Search for STRING in the history list, starting at POS, an
  1841. -   absolute index into the list.  DIR, if negative, says to search
  1842. -   backwards from POS, else forwards.
  1843. -   Returns the absolute index of the history element where STRING
  1844. -   was found, or -1 otherwise. */
  1845. -extern int history_search_pos ();
  1846. -
  1847. -/* A reasonably useless function, only here for completeness.  WHICH
  1848. -   is the magic number that tells us which element to delete.  The
  1849. -   elements are numbered from 0. */
  1850. -/* inline HIST_ENTRY *remove_history () {return NULL;} */
  1851. -
  1852. -/* Stifle the history list, remembering only MAX number of entries. */
  1853. -/* extern void stifle_history (); */
  1854. -
  1855. -/* Stop stifling the history.  This returns the previous amount the
  1856. -   history was stifled by.  The value is positive if the history was
  1857. -   stifled, negative if it wasn't. */
  1858. -/* extern int unstifle_history (); */
  1859. -
  1860. -/* Add the contents of FILENAME to the history list, a line at a time.
  1861. -   If FILENAME is NULL, then read from ~/.history.  Returns 0 if
  1862. -   successful, or errno if not. */
  1863. -/* extern int read_history (); */
  1864. -
  1865. -/* Append the current history to FILENAME.  If FILENAME is NULL,
  1866. -   then append the history list to ~/.history.  Values returned
  1867. -   are as in read_history ().  */
  1868. -/* extern int write_history (); */
  1869. -
  1870. -
  1871. -/* Make the history entry at WHICH have LINE and DATA.  This returns
  1872. -   the old entry so you can dispose of the data.  In the case of an
  1873. -   invalid WHICH, a NULL pointer is returned. */
  1874. -/* extern HIST_ENTRY *replace_history_entry (); */
  1875. -
  1876. -/* Return the history entry at the current position, as determined by
  1877. -   history_offset.  If there is no entry there, return a NULL pointer. */
  1878. -HIST_ENTRY *current_history ();
  1879. -
  1880. -/* Back up history_offset to the previous history entry, and return
  1881. -   a pointer to that entry.  If there is no previous entry, return
  1882. -   a NULL pointer. */
  1883. -extern HIST_ENTRY *previous_history ();
  1884. -
  1885. -/* Move history_offset forward to the next item in the input_history,
  1886. -   and return the a pointer to that entry.  If there is no next entry,
  1887. -   return a NULL pointer. */
  1888. -extern HIST_ENTRY *next_history ();
  1889. -
  1890. -/* Return a NULL terminated array of HIST_ENTRY which is the current input
  1891. -   history.  Element 0 of this list is the beginning of time.  If there
  1892. -   is no history, return NULL. */
  1893. -/*extern HIST_ENTRY **history_list ();*/
  1894. -
  1895. -/* Search the history for STRING, starting at history_offset.
  1896. -   If DIRECTION < 0, then the search is through previous entries,
  1897. -   else through subsequent.  If the string is found, then
  1898. -   current_history () is the history entry, and the value of this function
  1899. -   is the offset in the line of that history entry that the string was
  1900. -   found in.  Otherwise, nothing is changed, and a -1 is returned. */
  1901. -/* extern int history_search (); */
  1902. -
  1903. -/* Expand the string STRING, placing the result into OUTPUT, a pointer
  1904. -   to a string.  Returns:
  1905. -
  1906. -   0) If no expansions took place (or, if the only change in
  1907. -      the text was the de-slashifying of the history expansion
  1908. -      character)
  1909. -   1) If expansions did take place
  1910. -  -1) If there was an error in expansion.
  1911. -
  1912. -  If an error ocurred in expansion, then OUTPUT contains a descriptive
  1913. -  error message. */
  1914. -/*extern int history_expand ();*/
  1915. -
  1916. -/* Extract a string segment consisting of the FIRST through LAST
  1917. -   arguments present in STRING.  Arguments are broken up as in
  1918. -   the shell. pjf: only 1-segment strings are supported.  */
  1919. -extern char *history_arg_extract ();
  1920. -
  1921. -
  1922. End of readline/history.h
  1923. echo readline/keymaps.c 1>&2
  1924. sed 's/^-//' >readline/keymaps.c <<'End of readline/keymaps.c'
  1925. -/* keymaps.c -- Functions and keymaps for the GNU Readline library. */
  1926. -
  1927. -/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
  1928. -
  1929. -   This file is part of GNU Readline, a library for reading lines
  1930. -   of text with interactive input and history editing.
  1931. -
  1932. -   Readline is free software; you can redistribute it and/or modify it
  1933. -   under the terms of the GNU General Public License as published by the
  1934. -   Free Software Foundation; either version 1, or (at your option) any
  1935. -   later version.
  1936. -
  1937. -   Readline is distributed in the hope that it will be useful, but
  1938. -   WITHOUT ANY WARRANTY; without even the implied warranty of
  1939. -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  1940. -   General Public License for more details.
  1941. -
  1942. -   You should have received a copy of the GNU General Public License
  1943. -   along with Readline; see the file COPYING.  If not, write to the Free
  1944. -   Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  1945. -
  1946. -#include "keymaps.h"
  1947. -#include "emacs_keymap.c"
  1948. -
  1949. -#ifdef VI_MODE
  1950. -#include "vi_keymap.c"
  1951. -#endif
  1952. -
  1953. -/* Remove these declarations when we have a complete libgnu.a. */
  1954. -#define STATIC_MALLOC
  1955. -#ifndef STATIC_MALLOC
  1956. -extern char *xmalloc (), *xrealloc ();
  1957. -#else
  1958. -static char *xmalloc (), *xrealloc ();
  1959. -#endif
  1960. -
  1961. -/* **************************************************************** */
  1962. -/*                                    */
  1963. -/*              Functions for manipulating Keymaps.        */
  1964. -/*                                    */
  1965. -/* **************************************************************** */
  1966. -
  1967. -
  1968. -/* Return a new, empty keymap.
  1969. -   Free it with free() when you are done. */
  1970. -Keymap
  1971. -rl_make_bare_keymap ()
  1972. -{
  1973. -  register int i;
  1974. -  Keymap keymap = (Keymap)xmalloc (128 * sizeof (KEYMAP_ENTRY));
  1975. -
  1976. -  for (i = 0; i < 128; i++)
  1977. -    {
  1978. -      keymap[i].type = ISFUNC;
  1979. -      keymap[i].function = (Function *)NULL;
  1980. -    }
  1981. -
  1982. -  for (i = 'A'; i < ('Z' + 1); i++)
  1983. -    {
  1984. -      keymap[i].type = ISFUNC;
  1985. -      keymap[i].function = rl_do_lowercase_version;
  1986. -    }
  1987. -
  1988. -  return (keymap);
  1989. -}
  1990. -
  1991. -/* Return a new keymap which is a copy of MAP. */
  1992. -Keymap
  1993. -rl_copy_keymap (map)
  1994. -     Keymap map;
  1995. -{
  1996. -  register int i;
  1997. -  Keymap temp = rl_make_bare_keymap ();
  1998. -
  1999. -  for (i = 0; i < 128; i++)
  2000. -    {
  2001. -      temp[i].type = map[i].type;
  2002. -      temp[i].function = map[i].function;
  2003. -    }
  2004. -  return (temp);
  2005. -}
  2006. -
  2007. -/* Return a new keymap with the printing characters bound to rl_insert,
  2008. -   the uppercase Meta characters bound to run their lowercase equivalents,
  2009. -   and the Meta digits bound to produce numeric arguments. */
  2010. -Keymap
  2011. -rl_make_keymap ()
  2012. -{
  2013. -  extern rl_insert (), rl_rubout (), rl_do_lowercase_version ();
  2014. -  extern rl_digit_argument ();
  2015. -  register int i;
  2016. -  Keymap newmap;
  2017. -
  2018. -  newmap = rl_make_bare_keymap ();
  2019. -
  2020. -  /* All printing characters are self-inserting. */
  2021. -  for (i = ' '; i < 126; i++)
  2022. -    newmap[i].function = rl_insert;
  2023. -
  2024. -  newmap[TAB].function = rl_insert;
  2025. -  newmap[RUBOUT].function = rl_rubout;
  2026. -
  2027. -  return (newmap);
  2028. -}
  2029. -
  2030. -/* Free the storage associated with MAP. */
  2031. -rl_discard_keymap (map)
  2032. -     Keymap (map);
  2033. -{
  2034. -  int i;
  2035. -
  2036. -  if (!map)
  2037. -    return;
  2038. -
  2039. -  for (i = 0; i < 128; i++)
  2040. -    {
  2041. -      switch (map[i].type)
  2042. -    {
  2043. -    case ISFUNC:
  2044. -      break;
  2045. -
  2046. -    case ISKMAP:
  2047. -      rl_discard_keymap ((Keymap)map[i].function);
  2048. -      break;
  2049. -
  2050. -    case ISMACR:
  2051. -      free ((char *)map[i].function);
  2052. -      break;
  2053. -    }
  2054. -    }
  2055. -}
  2056. -
  2057. -#ifdef STATIC_MALLOC
  2058. -
  2059. -/* **************************************************************** */
  2060. -/*                                    */
  2061. -/*            xmalloc and xrealloc ()                     */
  2062. -/*                                    */
  2063. -/* **************************************************************** */
  2064. -
  2065. -static void memory_error_and_abort ();
  2066. -
  2067. -static char *
  2068. -xmalloc (bytes)
  2069. -     int bytes;
  2070. -{
  2071. -  char *temp = (char *)malloc (bytes);
  2072. -
  2073. -  if (!temp)
  2074. -    memory_error_and_abort ();
  2075. -  return (temp);
  2076. -}
  2077. -
  2078. -static char *
  2079. -xrealloc (pointer, bytes)
  2080. -     char *pointer;
  2081. -     int bytes;
  2082. -{
  2083. -  char *temp = (char *)realloc (pointer, bytes);
  2084. -
  2085. -  if (!temp)
  2086. -    memory_error_and_abort ();
  2087. -  return (temp);
  2088. -}
  2089. -
  2090. -static void
  2091. -memory_error_and_abort ()
  2092. -{
  2093. -  fprintf (stderr, "readline: Out of virtual memory!\n");
  2094. -  abort ();
  2095. -}
  2096. -#endif /* STATIC_MALLOC */
  2097. End of readline/keymaps.c
  2098. echo readline/keymaps.h 1>&2
  2099. sed 's/^-//' >readline/keymaps.h <<'End of readline/keymaps.h'
  2100. -/* keymaps.h -- Manipulation of readline keymaps. */
  2101. -
  2102. -#ifndef _KEYMAPS_H_
  2103. -#define _KEYMAPS_H_
  2104. -
  2105. -#include <readline/chardefs.h>
  2106. -
  2107. -#ifndef __FUNCTION_DEF
  2108. -typedef int Function ();
  2109. -#define __FUNCTION_DEF
  2110. -#endif
  2111. -
  2112. -/* A keymap contains one entry for each key in the ASCII set.
  2113. -   Each entry consists of a type and a pointer.
  2114. -   POINTER is the address of a function to run, or the
  2115. -   address of a keymap to indirect through.
  2116. -   TYPE says which kind of thing POINTER is. */
  2117. -typedef struct _keymap_entry {
  2118. -  char type;
  2119. -  Function *function;
  2120. -} KEYMAP_ENTRY;
  2121. -
  2122. -/* I wanted to make the above structure contain a union of:
  2123. -   union { Function *function; struct _keymap_entry *keymap; } value;
  2124. -   but this made it impossible for me to create a static array.
  2125. -   Maybe I need C lessons. */
  2126. -
  2127. -typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[128];
  2128. -typedef KEYMAP_ENTRY *Keymap;
  2129. -
  2130. -/* The values that TYPE can have in a keymap entry. */
  2131. -#define ISFUNC 0
  2132. -#define ISKMAP 1
  2133. -#define ISMACR 2
  2134. -
  2135. -extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap;
  2136. -extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
  2137. -
  2138. -/* Return a new, empty keymap.
  2139. -   Free it with free() when you are done. */
  2140. -Keymap rl_make_bare_keymap ();
  2141. -
  2142. -/* Return a new keymap which is a copy of MAP. */
  2143. -Keymap rl_copy_keymap ();
  2144. -
  2145. -/* Return a new keymap with the printing characters bound to rl_insert,
  2146. -   the lowercase Meta characters bound to run their equivalents, and
  2147. -   the Meta digits bound to produce numeric arguments. */
  2148. -Keymap rl_make_keymap ();
  2149. -
  2150. -#endif /* _KEYMAPS_H_ */
  2151. -
  2152. -
  2153. End of readline/keymaps.h
  2154. echo readline/readline.c 1>&2
  2155. sed 's/^-//' >readline/readline.c <<'End of readline/readline.c'
  2156. -/* readline.c -- a general facility for reading lines of input
  2157. -   with emacs style editing and completion. */
  2158. -
  2159. -/* Copyright (C) 1987,1989 Free Software Foundation, Inc.
  2160. -
  2161. -   This file contains the Readline Library (the Library), a set of
  2162. -   routines for providing Emacs style line input to programs that ask
  2163. -   for it.
  2164. -
  2165. -   The Library is free software; you can redistribute it and/or modify
  2166. -   it under the terms of the GNU General Public License as published by
  2167. -   the Free Software Foundation; either version 1, or (at your option)
  2168. -   any later version.
  2169. -
  2170. -   The Library is distributed in the hope that it will be useful, but
  2171. -   WITHOUT ANY WARRANTY; without even the implied warranty of
  2172. -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  2173. -   General Public License for more details.
  2174. -
  2175. -   The GNU General Public License is often shipped with GNU software, and
  2176. -   is generally kept in a file called COPYING or LICENSE.  If you do not
  2177. -   have a copy of the license, write to the Free Software Foundation,
  2178. -   675 Mass Ave, Cambridge, MA 02139, USA. */
  2179. -
  2180. -/* Remove these declarations when we have a complete libgnu.a. */
  2181. -#define STATIC_MALLOC
  2182. -#ifndef STATIC_MALLOC
  2183. -extern char *xmalloc (), *xrealloc ();
  2184. -#else
  2185. -static char *xmalloc (), *xrealloc ();
  2186. -#endif
  2187. -
  2188. -char *docompsubs();
  2189. -extern int errno,errflag;
  2190. -
  2191. -#include <stdio.h>
  2192. -#include <sys/types.h>
  2193. -#include <fcntl.h>
  2194. -#include <sys/file.h>
  2195. -#include <sys/param.h>
  2196. -#include <signal.h>
  2197. -
  2198. -#ifdef __GNUC__
  2199. -#define alloca __builtin_alloca
  2200. -#else
  2201. -#if defined (sparc) && defined (sun)
  2202. -#include <alloca.h>
  2203. -#endif
  2204. -#endif
  2205. -
  2206. -#define NEW_TTY_DRIVER
  2207. -#if defined (SYSV) || defined (hpux)
  2208. -#undef NEW_TTY_DRIVER
  2209. -#include <termio.h>
  2210. -#else
  2211. -#include <sgtty.h>
  2212. -#endif
  2213. -
  2214. -#include <errno.h>
  2215. -extern int errno;
  2216. -
  2217. -#include <setjmp.h>
  2218. -
  2219. -/* These next are for filename completion.  Perhaps this belongs
  2220. -   in a different place. */
  2221. -#include <sys/stat.h>
  2222. -
  2223. -#include <pwd.h>
  2224. -#ifdef SYSV
  2225. -struct passwd *getpwuid (), *getpwent ();
  2226. -#endif
  2227. -
  2228. -#define HACK_TERMCAP_MOTION
  2229. -
  2230. -#ifndef SYSV
  2231. -#include <sys/dir.h>
  2232. -#else  /* SYSV */
  2233. -#if defined (xenix)
  2234. -#include <sys/ndir.h>
  2235. -#else
  2236. -#ifdef hpux
  2237. -#include <ndir.h>
  2238. -#else
  2239. -#include <dirent.h>
  2240. -#define direct dirent
  2241. -#define d_namlen d_reclen
  2242. -#endif  /* hpux */
  2243. -#endif  /* xenix */
  2244. -#endif  /* SYSV */
  2245. -
  2246. -#ifndef O_CBREAK
  2247. -#define O_CBREAK CBREAK
  2248. -#define O_ECHO ECHO
  2249. -#define O_RAW RAW
  2250. -#endif
  2251. -
  2252. -/* Some standard library routines. */
  2253. -#include "readline.h"
  2254. -#include "history.h"
  2255. -
  2256. -#ifndef digit
  2257. -#define digit(c)  ((c) >= '0' && (c) <= '9')
  2258. -#endif
  2259. -
  2260. -#ifndef isletter
  2261. -#define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
  2262. -#endif
  2263. -
  2264. -#ifndef digit_value
  2265. -#define digit_value(c) ((c) - '0')
  2266. -#endif
  2267. -
  2268. -#ifndef member
  2269. -char *index ();
  2270. -#define member(c, s) ((c) ? index ((s), (c)) : 0)
  2271. -#endif
  2272. -
  2273. -#ifndef isident
  2274. -#define isident(c) ((isletter(c) || digit(c) || c == '_'))
  2275. -#endif
  2276. -
  2277. -#ifndef exchange
  2278. -#define exchange(x, y) {int temp = x; x = y; y = temp;}
  2279. -#endif
  2280. -
  2281. -static update_line ();
  2282. -static void output_character_function ();
  2283. -static delete_chars ();
  2284. -static delete_chars ();
  2285. -static insert_some_chars ();
  2286. -
  2287. -void rl_safe_insert_text();
  2288. -
  2289. -#ifdef VOID_SIGHANDLER
  2290. -#define sighandler void
  2291. -#else
  2292. -#define sighandler int
  2293. -#endif
  2294. -
  2295. -/* This typedef is equivalant to the one for Function; it allows us
  2296. -   to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */
  2297. -typedef sighandler SigHandler ();
  2298. -
  2299. -#ifdef SIGWINCH
  2300. -static sighandler rl_handle_sigwinch ();
  2301. -static SigHandler *old_sigwinch = (SigHandler *)NULL;
  2302. -#endif
  2303. -
  2304. -/* If on, then readline handles signals in a way that doesn't screw. */
  2305. -#define HANDLE_SIGNALS
  2306. -
  2307. -#if defined (SYSV)
  2308. -#ifdef HANDLE_SIGNALS
  2309. -#undef HANDLE_SIGNALS
  2310. -#endif
  2311. -#endif
  2312. -
  2313. -
  2314. -/* **************************************************************** */
  2315. -/*                                                                  */
  2316. -/*                      Line editing input utility                  */
  2317. -/*                                                                  */
  2318. -/* **************************************************************** */
  2319. -
  2320. -/* A pointer to the keymap that is currently in use.
  2321. -   By default, it is the standard emacs keymap. */
  2322. -Keymap keymap = emacs_standard_keymap;
  2323. -
  2324. -#define vi_mode 0
  2325. -#define emacs_mode 1
  2326. -
  2327. -/* The current style of editing. */
  2328. -int rl_editing_mode = emacs_mode;
  2329. -
  2330. -/* Non-zero if the previous command was a kill command. */
  2331. -static int last_command_was_kill = 0;
  2332. -
  2333. -/* The current value of the numeric argument specified by the user. */
  2334. -int rl_numeric_arg = 1;
  2335. -
  2336. -/* Non-zero if an argument was typed. */
  2337. -int rl_explicit_arg = 0;
  2338. -
  2339. -/* Temporary value used while generating the argument. */
  2340. -static int arg_sign = 1;
  2341. -
  2342. -/* Non-zero means we have been called at least once before. */
  2343. -static int rl_initialized = 0;
  2344. -
  2345. -/* If non-zero, this program is running in an EMACS buffer. */
  2346. -static char *running_in_emacs = (char *)NULL;
  2347. -
  2348. -/* The current offset in the current input line. */
  2349. -int rl_point;
  2350. -
  2351. -/* Mark in the current input line. */
  2352. -int rl_mark;
  2353. -
  2354. -/* Length of the current input line. */
  2355. -int rl_end;
  2356. -
  2357. -/* Make this non-zero to return the current input_line. */
  2358. -int rl_done;
  2359. -
  2360. -/* The last function executed by readline. */
  2361. -Function *rl_last_func = (Function *)NULL;
  2362. -
  2363. -/* Top level environment for readline_internal (). */
  2364. -static jmp_buf readline_top_level;
  2365. -
  2366. -/* The streams we interact with. */
  2367. -static FILE *in_stream, *out_stream;
  2368. -
  2369. -/* The names of the streams that we do input and output to. */
  2370. -FILE *rl_instream = stdin, *rl_outstream = stdout;
  2371. -
  2372. -/* Non-zero means echo characters as they are read. */
  2373. -int readline_echoing_p = 1;
  2374. -
  2375. -/* Current prompt. */
  2376. -char *rl_prompt;
  2377. -
  2378. -/* The number of characters read in order to type this complete command. */
  2379. -int rl_key_sequence_length = 0;
  2380. -
  2381. -/* 1 means the line editor is active. */
  2382. -int rl_active = 0;
  2383. -
  2384. -/* 1 means we are waiting for a character. */
  2385. -int rl_waiting = 0;
  2386. -
  2387. -/* If non-zero, then this is the address of a function to call just
  2388. -   before readline_internal () prints the first prompt. */
  2389. -Function *rl_startup_hook = (Function *)NULL;
  2390. -
  2391. -/* What we use internally.  You should always refer to RL_LINE_BUFFER. */
  2392. -static char *the_line;
  2393. -
  2394. -/* The character that can generate an EOF.  Really read from
  2395. -   the terminal driver... just defaulted here. */
  2396. -static int eof_char = CTRL ('D');
  2397. -
  2398. -/* Non-zero makes this the next keystroke to read. */
  2399. -int rl_pending_input = 0;
  2400. -
  2401. -/* Pointer to a useful terminal name. */
  2402. -char *rl_terminal_name = (char *)NULL;
  2403. -
  2404. -/* Line buffer and maintenence. */
  2405. -char *rl_line_buffer = (char *)NULL;
  2406. -static int rl_line_buffer_len = 0;
  2407. -#define DEFAULT_BUFFER_SIZE 256
  2408. -
  2409. -
  2410. -/* **************************************************************** */
  2411. -/*                                                                  */
  2412. -/*                      `Forward' declarations                      */
  2413. -/*                                                                  */
  2414. -/* **************************************************************** */
  2415. -
  2416. -/* Non-zero means do not parse any lines other than comments and
  2417. -   parser directives. */
  2418. -static unsigned char parsing_conditionalized_out = 0;
  2419. -
  2420. -/* Caseless strcmp (). */
  2421. -static int stricmp (), strnicmp ();
  2422. -
  2423. -/* Non-zero means to save keys that we dispatch on in a kbd macro. */
  2424. -static int defining_kbd_macro = 0;
  2425. -
  2426. -
  2427. -/* **************************************************************** */
  2428. -/*                                                                  */
  2429. -/*                      Top Level Functions                         */
  2430. -/*                                                                  */
  2431. -/* **************************************************************** */
  2432. -
  2433. -/* Read a line of input.  Prompt with PROMPT.  A NULL PROMPT means
  2434. -   none.  A return value of NULL means that EOF was encountered. */
  2435. -char *
  2436. -readline (prompt)
  2437. -char *prompt;
  2438. -{
  2439. -    int rl_prep_terminal (), rl_deprep_terminal ();
  2440. -    char *readline_internal ();
  2441. -    char *value;
  2442. -
  2443. -    rl_prompt = prompt;
  2444. -
  2445. -    /* If we are at EOF return a NULL string. */
  2446. -    if (rl_pending_input == EOF)
  2447. -    {
  2448. -        rl_pending_input = 0;
  2449. -        return ((char *)NULL);
  2450. -    }
  2451. -
  2452. -    rl_initialize ();
  2453. -    rl_prep_terminal ();
  2454. -
  2455. -#ifdef SIGWINCH
  2456. -    old_sigwinch = (SigHandler *)signal (SIGWINCH, rl_handle_sigwinch);
  2457. -#endif
  2458. -
  2459. -#ifdef HANDLE_SIGNALS
  2460. -    rl_set_signals ();
  2461. -#endif
  2462. -
  2463. -    rl_active = 1;
  2464. -    rl_waiting = 0;
  2465. -    value = readline_internal ();
  2466. -    rl_active = 0;
  2467. -    rl_deprep_terminal ();
  2468. -
  2469. -#ifdef SIGWINCH
  2470. -    signal (SIGWINCH, old_sigwinch);
  2471. -#endif
  2472. -
  2473. -#ifdef HANDLE_SIGNALS
  2474. -    rl_clear_signals ();
  2475. -#endif
  2476. -
  2477. -    return (value);
  2478. -}
  2479. -
  2480. -/* Read a line of input from the global rl_instream, doing output on
  2481. -   the global rl_outstream.
  2482. -   If rl_prompt is non-null, then that is our prompt. */
  2483. -char *
  2484. -readline_internal ()
  2485. -{
  2486. -    int lastc, c, eof_found;
  2487. -
  2488. -    in_stream = rl_instream; 
  2489. -    out_stream = rl_outstream;
  2490. -    lastc = eof_found = 0;
  2491. -
  2492. -    if (rl_startup_hook)
  2493. -        (*rl_startup_hook) ();
  2494. -
  2495. -    if (!readline_echoing_p)
  2496. -    {
  2497. -        if (rl_prompt)
  2498. -        {
  2499. -            fprintf (out_stream, "%s", rl_prompt);
  2500. -            fflush (out_stream);
  2501. -        }
  2502. -    }
  2503. -    else
  2504. -    {
  2505. -        rl_on_new_line ();
  2506. -        rl_redisplay ();
  2507. -#ifdef VI_MODE
  2508. -        if (rl_editing_mode == vi_mode)
  2509. -            rl_vi_insertion_mode ();
  2510. -#endif /* VI_MODE */
  2511. -    }
  2512. -
  2513. -    while (!rl_done)
  2514. -    {
  2515. -        int lk = last_command_was_kill;
  2516. -        int code = setjmp (readline_top_level);
  2517. -
  2518. -        if (code)
  2519. -            rl_redisplay ();
  2520. -
  2521. -        if (!rl_pending_input)
  2522. -        {
  2523. -            /* Then initialize the argument and number of keys read. */
  2524. -            rl_init_argument ();
  2525. -            rl_key_sequence_length = 0;
  2526. -        }
  2527. -
  2528. -        c = rl_read_key ();
  2529. -        if (c == EOF)
  2530. -            {
  2531. -            eof_found = 1;
  2532. -            putc('\n',stderr);
  2533. -            break;
  2534. -            }
  2535. -
  2536. -        /* EOF typed to a non-blank line is a <NL>. */
  2537. -        if (c == EOF && rl_end)
  2538. -            c = NEWLINE;
  2539. -
  2540. -        if (errflag)
  2541. -        {
  2542. -            eof_found = 1;
  2543. -            break;
  2544. -        }
  2545. -
  2546. -        /* The character eof_char typed to blank line, and not as the
  2547. -     previous character is interpreted as EOF. */
  2548. -        if (((c == eof_char && lastc != c) || c == EOF) && !rl_end)
  2549. -        {
  2550. -            eof_found = 1;
  2551. -            break;
  2552. -        }
  2553. -
  2554. -        lastc = c;
  2555. -        rl_dispatch (c, keymap);
  2556. -
  2557. -        /* If there was no change in last_command_was_kill, then no kill
  2558. -     has taken place.  Note that if input is pending we are reading
  2559. -     a prefix command, so nothing has changed yet. */
  2560. -        if (!rl_pending_input)
  2561. -        {
  2562. -            if (lk == last_command_was_kill)
  2563. -                last_command_was_kill = 0;
  2564. -        }
  2565. -
  2566. -#ifdef VI_MODE
  2567. -        /* In vi mode, when you exit insert mode, the cursor moves back
  2568. -     over the previous character.  We explicitly check for that here. */
  2569. -        if (rl_editing_mode == vi_mode && keymap == vi_movement_keymap)
  2570. -            rl_vi_check ();
  2571. -#endif
  2572. -        if (!rl_done)
  2573. -            rl_redisplay ();
  2574. -    }
  2575. -
  2576. -    /* Restore the original of this history line, iff the line that we
  2577. -     are editing was originally in the history, AND the line has changed. */
  2578. -    {
  2579. -        HIST_ENTRY *entry = current_history ();
  2580. -
  2581. -        if (entry && rl_undo_list)
  2582. -        {
  2583. -            char *temp = savestring (the_line);
  2584. -            rl_revert_line ();
  2585. -            free_history_entry (entry);
  2586. -
  2587. -            strcpy (the_line, temp);
  2588. -            free (temp);
  2589. -        }
  2590. -    }
  2591. -
  2592. -    /* At any rate, it is highly likely that this line has an undo list.  Get
  2593. -     rid of it now. */
  2594. -    if (rl_undo_list)
  2595. -        free_undo_list ();
  2596. -
  2597. -    if (eof_found)
  2598. -        return (char *)NULL;
  2599. -    else
  2600. -        return (savestring (the_line));
  2601. -}
  2602. -
  2603. -
  2604. -/* **************************************************************** */
  2605. -/*                                        */
  2606. -/*               Signal Handling                          */
  2607. -/*                                    */
  2608. -/* **************************************************************** */
  2609. -
  2610. -#ifdef SIGWINCH
  2611. -static sighandler
  2612. -rl_handle_sigwinch (sig, code, scp)
  2613. -int sig, code;
  2614. -struct sigcontext *scp;
  2615. -{
  2616. -    char *term = rl_terminal_name, *getenv ();
  2617. -
  2618. -    if (readline_echoing_p)
  2619. -    {
  2620. -        if (!term)
  2621. -            term = getenv ("TERM");
  2622. -        if (!term)
  2623. -            term = "dumb";
  2624. -        rl_reset_terminal (term);
  2625. -#ifdef NEVER
  2626. -        crlf ();
  2627. -        rl_forced_update_display ();
  2628. -#endif
  2629. -    }
  2630. -
  2631. -    if (old_sigwinch &&
  2632. -        old_sigwinch != (SigHandler *)SIG_IGN &&
  2633. -        old_sigwinch != (SigHandler *)SIG_DFL)
  2634. -        (*old_sigwinch)(sig, code, scp);
  2635. -}
  2636. -#endif  /* SIGWINCH */
  2637. -
  2638. -#ifdef HANDLE_SIGNALS
  2639. -/* Interrupt handling. */
  2640. -static SigHandler *old_int  = (SigHandler *)NULL,
  2641. -*old_tstp = (SigHandler *)NULL,
  2642. -*old_ttou = (SigHandler *)NULL,
  2643. -*old_ttin = (SigHandler *)NULL,
  2644. -*old_cont = (SigHandler *)NULL;
  2645. -
  2646. -/* Handle an interrupt character. */
  2647. -static sighandler
  2648. -rl_signal_handler (sig, code, scp)
  2649. -int sig, code;
  2650. -struct sigcontext *scp;
  2651. -{
  2652. -    rl_prep_terminal (), rl_deprep_terminal ();
  2653. -
  2654. -    switch (sig)
  2655. -    {
  2656. -    case SIGINT:
  2657. -        free_undo_list ();
  2658. -        rl_clear_message ();
  2659. -        rl_init_argument ();
  2660. -#ifdef SIGWINCH
  2661. -        signal (SIGWINCH, old_sigwinch);
  2662. -#endif
  2663. -
  2664. -#ifdef SIGTSTP
  2665. -    case SIGTSTP:
  2666. -    case SIGTTOU:
  2667. -    case SIGTTIN:
  2668. -#endif
  2669. -
  2670. -        rl_clean_up_for_exit ();
  2671. -        rl_deprep_terminal ();
  2672. -        rl_clear_signals ();
  2673. -        rl_pending_input = 0;
  2674. -
  2675. -        kill (getpid (), sig);
  2676. -        sigsetmask (0);
  2677. -
  2678. -        rl_prep_terminal ();
  2679. -        rl_set_signals ();
  2680. -    }
  2681. -}
  2682. -
  2683. -rl_set_signals ()
  2684. -{
  2685. -    old_int = (SigHandler *)signal (SIGINT, rl_signal_handler);
  2686. -    if (old_int == (SigHandler *)SIG_IGN)
  2687. -        signal (SIGINT, SIG_IGN);
  2688. -
  2689. -#ifdef SIGTSTP
  2690. -    old_tstp = (SigHandler *)signal (SIGTSTP, rl_signal_handler);
  2691. -    if (old_tstp == (SigHandler *)SIG_IGN)
  2692. -        signal (SIGTSTP, SIG_IGN);
  2693. -#endif
  2694. -#ifdef SIGTTOU
  2695. -    old_ttou = (SigHandler *)signal (SIGTTOU, rl_signal_handler);
  2696. -    old_ttin = (SigHandler *)signal (SIGTTIN, rl_signal_handler);
  2697. -
  2698. -    if (old_tstp == (SigHandler *)SIG_IGN)
  2699. -    {
  2700. -        signal (SIGTTOU, SIG_IGN);
  2701. -        signal (SIGTTIN, SIG_IGN);
  2702. -    }
  2703. -#endif
  2704. -}
  2705. -
  2706. -rl_clear_signals ()
  2707. -{
  2708. -    signal (SIGINT, old_int);
  2709. -
  2710. -#ifdef SIGTSTP
  2711. -    signal (SIGTSTP, old_tstp);
  2712. -#endif
  2713. -#ifdef SIGTTOU
  2714. -    signal (SIGTTOU, old_ttou);
  2715. -    signal (SIGTTIN, old_ttin);
  2716. -#endif
  2717. -}
  2718. -#endif  /* HANDLE_SIGNALS */
  2719. -
  2720. -
  2721. -/* **************************************************************** */
  2722. -/*                                    */
  2723. -/*            Character Input Buffering               */
  2724. -/*                                    */
  2725. -/* **************************************************************** */
  2726. -
  2727. -/* If the terminal was in xoff state when we got to it, then xon_char
  2728. -   contains the character that is supposed to start it again. */
  2729. -static int xon_char, xoff_state;
  2730. -static int pop_index = 0, push_index = 0, ibuffer_len = 511;
  2731. -static unsigned char ibuffer[512];
  2732. -
  2733. -/* Non-null means it is a pointer to a function to run while waiting for
  2734. -   character input. */
  2735. -Function *rl_event_hook = (Function *)NULL;
  2736. -
  2737. -#define any_typein (push_index != pop_index)
  2738. -
  2739. -/* Add KEY to the buffer of characters to be read. */
  2740. -rl_stuff_char (key)
  2741. -int key;
  2742. -{
  2743. -    if (key == EOF)
  2744. -    {
  2745. -        key = NEWLINE;
  2746. -        rl_pending_input = EOF;
  2747. -    }
  2748. -    ibuffer[push_index++] = key;
  2749. -    if (push_index >= ibuffer_len)
  2750. -        push_index = 0;
  2751. -}
  2752. -
  2753. -/* Return the amount of space available in the
  2754. -   buffer for stuffing characters. */
  2755. -int
  2756. -ibuffer_space ()
  2757. -{
  2758. -    if (pop_index > push_index)
  2759. -        return (pop_index - push_index);
  2760. -    else
  2761. -        return (ibuffer_len - (push_index - pop_index));
  2762. -}
  2763. -
  2764. -/* Get a key from the buffer of characters to be read.
  2765. -   Return the key in KEY.
  2766. -   Result is KEY if there was a key, or 0 if there wasn't. */
  2767. -int
  2768. -rl_get_char (key)
  2769. -int *key;
  2770. -{
  2771. -    if (push_index == pop_index)
  2772. -        return (0);
  2773. -
  2774. -    *key = ibuffer[pop_index++];
  2775. -
  2776. -    if (pop_index >= ibuffer_len)
  2777. -        pop_index = 0;
  2778. -
  2779. -    return (1);
  2780. -}
  2781. -
  2782. -/* Stuff KEY into the *front* of the input buffer.
  2783. -   Returns non-zero if successful, zero if there is
  2784. -   no space left in the buffer. */
  2785. -int
  2786. -rl_unget_char (key)
  2787. -int key;
  2788. -{
  2789. -    if (ibuffer_space ())
  2790. -    {
  2791. -        pop_index--;
  2792. -        if (pop_index < 0)
  2793. -            pop_index = ibuffer_len - 1;
  2794. -        ibuffer[pop_index] = key;
  2795. -        return (1);
  2796. -    }
  2797. -    return (0);
  2798. -}
  2799. -
  2800. -/* If a character is available to be read, then read it
  2801. -   and stuff it into IBUFFER.  Otherwise, just return. */
  2802. -rl_gather_tyi ()
  2803. -{
  2804. -    int tty = fileno (in_stream);
  2805. -    register int tem, result = -1;
  2806. -    long chars_avail;
  2807. -    char input;
  2808. -
  2809. -#ifdef FIONREAD
  2810. -    result = ioctl (tty, FIONREAD, &chars_avail);
  2811. -#endif
  2812. -
  2813. -    if (result == -1)
  2814. -    {
  2815. -        fcntl (tty, F_SETFL, O_NDELAY);
  2816. -        chars_avail = read (tty, &input, 1);
  2817. -        fcntl (tty, F_SETFL, 0);
  2818. -        if (chars_avail == -1 && errno == EAGAIN)
  2819. -            return;
  2820. -    }
  2821. -
  2822. -    tem = ibuffer_space ();
  2823. -
  2824. -    if (chars_avail > tem)
  2825. -        chars_avail = tem;
  2826. -
  2827. -    /* One cannot read all of the available input.  I can only read a single
  2828. -     character at a time, or else programs which require input can be
  2829. -     thwarted.  If the buffer is larger than one character, I lose.
  2830. -     Damn! */
  2831. -    if (tem < ibuffer_len)
  2832. -        chars_avail = 0;
  2833. -
  2834. -    if (result != -1)
  2835. -    {
  2836. -        while (chars_avail--)
  2837. -            rl_stuff_char (rl_getc (in_stream));
  2838. -    }
  2839. -    else
  2840. -    {
  2841. -        if (chars_avail)
  2842. -            rl_stuff_char (input);
  2843. -    }
  2844. -}
  2845. -
  2846. -/* Read a key, including pending input. */
  2847. -int
  2848. -rl_read_key ()
  2849. -{
  2850. -    int c;
  2851. -
  2852. -    rl_key_sequence_length++;
  2853. -
  2854. -    if (rl_pending_input)
  2855. -    {
  2856. -        c = rl_pending_input;
  2857. -        rl_pending_input = 0;
  2858. -    }
  2859. -    else
  2860. -    {
  2861. -        static int next_macro_key ();
  2862. -
  2863. -        /* If input is coming from a macro, then use that. */
  2864. -        if (c = next_macro_key ())
  2865. -            return (c);
  2866. -
  2867. -        /* If the user has an event function, then call it periodically. */
  2868. -        if (rl_event_hook)
  2869. -        {
  2870. -            while (rl_event_hook && !rl_get_char (&c))
  2871. -            {
  2872. -                (*rl_event_hook) ();
  2873. -                rl_gather_tyi ();
  2874. -            }
  2875. -        }
  2876. -        else
  2877. -        {
  2878. -            if (!rl_get_char (&c))
  2879. -                c = rl_getc (in_stream);
  2880. -        }
  2881. -    }
  2882. -
  2883. -#ifdef NEVER  /* This breaks supdup to 4.0.3c machines. */
  2884. -#ifdef TIOCSTART
  2885. -    /* Ugh.  But I can't think of a better way. */
  2886. -    if (xoff_state && c == xon_char)
  2887. -    {
  2888. -        ioctl (fileno (in_stream), TIOCSTART, 0);
  2889. -        xoff_state = 0;
  2890. -        return (rl_read_key ());
  2891. -    }
  2892. -#endif /* TIOCSTART */
  2893. -#endif
  2894. -
  2895. -    return (c);
  2896. -}
  2897. -
  2898. -/* I'm beginning to hate the declaration rules for various compilers. */
  2899. -static void add_macro_char ();
  2900. -
  2901. -/* Do the command associated with KEY in MAP.
  2902. -   If the associated command is really a keymap, then read
  2903. -   another key, and dispatch into that map. */
  2904. -rl_dispatch (key, map)
  2905. -register int key;
  2906. -Keymap map;
  2907. -{
  2908. -
  2909. -    if (defining_kbd_macro)
  2910. -        add_macro_char (key);
  2911. -
  2912. -    if (key > 127 && key < 256)
  2913. -    {
  2914. -        if (map[ESC].type == ISKMAP)
  2915. -        {
  2916. -            map = (Keymap)map[ESC].function;
  2917. -            key -= 128;
  2918. -            rl_dispatch (key, map);
  2919. -        }
  2920. -        else
  2921. -            ding ();
  2922. -        return;
  2923. -    }
  2924. -
  2925. -    switch (map[key].type)
  2926. -    {
  2927. -    case ISFUNC:
  2928. -        {
  2929. -            Function *func = map[key].function;
  2930. -
  2931. -            if (func != (Function *)NULL)
  2932. -            {
  2933. -                /* Special case rl_do_lowercase_version (). */
  2934. -                if (func == rl_do_lowercase_version)
  2935. -                {
  2936. -                    rl_dispatch (to_lower (key), map);
  2937. -                    return;
  2938. -                }
  2939. -
  2940. -                (*map[key].function)(rl_numeric_arg * arg_sign, key);
  2941. -            }
  2942. -            else
  2943. -            {
  2944. -                ding ();
  2945. -                return;
  2946. -            }
  2947. -        }
  2948. -        break;
  2949. -
  2950. -    case ISKMAP:
  2951. -        if (map[key].function != (Function *)NULL)
  2952. -        {
  2953. -            int newkey;
  2954. -
  2955. -            rl_key_sequence_length++;
  2956. -            newkey = rl_read_key ();
  2957. -            rl_dispatch (newkey, (Keymap)map[key].function);
  2958. -        }
  2959. -        else
  2960. -        {
  2961. -            ding ();
  2962. -            return;
  2963. -        }
  2964. -        break;
  2965. -
  2966. -    case ISMACR:
  2967. -        if (map[key].function != (Function *)NULL)
  2968. -        {
  2969. -            static with_macro_input ();
  2970. -            char *macro = savestring ((char *)map[key].function);
  2971. -
  2972. -            with_macro_input (macro);
  2973. -            return;
  2974. -        }
  2975. -        break;
  2976. -    }
  2977. -
  2978. -    /* If we have input pending, then the last command was a prefix
  2979. -     command.  Don't change the state of rl_last_func. */
  2980. -    if (!rl_pending_input)
  2981. -        rl_last_func = map[key].function;
  2982. -}
  2983. -
  2984. -
  2985. -/* **************************************************************** */
  2986. -/*                                    */
  2987. -/*            Hacking Keyboard Macros             */
  2988. -/*                                    */
  2989. -/* **************************************************************** */
  2990. -
  2991. -/* The currently executing macro string.  If this is non-zero,
  2992. -   then it is a malloc ()'ed string where input is coming from. */
  2993. -static char *executing_macro = (char *)NULL;
  2994. -
  2995. -/* The offset in the above string to the next character to be read. */
  2996. -static int executing_macro_index = 0;
  2997. -
  2998. -/* The current macro string being built.  Characters get stuffed
  2999. -   in here by add_macro_char (). */
  3000. -static char *current_macro = (char *)NULL;
  3001. -
  3002. -/* The size of the buffer allocated to current_macro. */
  3003. -static int current_macro_size = 0;
  3004. -
  3005. -/* The index at which characters are being added to current_macro. */
  3006. -static int current_macro_index = 0;
  3007. -
  3008. -/* A structure used to save nested macro strings.
  3009. -   It is a linked list of string/index for each saved macro. */
  3010. -struct saved_macro {
  3011. -    struct saved_macro *next;
  3012. -    char *string;
  3013. -    int index;
  3014. -};
  3015. -
  3016. -/* The list of saved macros. */
  3017. -struct saved_macro *macro_list = (struct saved_macro *)NULL;
  3018. -
  3019. -/* Forward declarations of static functions.  Thank you C. */
  3020. -static void push_executing_macro (), pop_executing_macro ();
  3021. -
  3022. -/* This one has to be declared earlier in the file. */
  3023. -/* static void add_macro_char (); */
  3024. -
  3025. -/* Set up to read subsequent input from STRING.
  3026. -   STRING is free ()'ed when we are done with it. */
  3027. -static
  3028. -with_macro_input (string)
  3029. -char *string;
  3030. -{
  3031. -    push_executing_macro ();
  3032. -    executing_macro = string;
  3033. -    executing_macro_index = 0;
  3034. -}
  3035. -
  3036. -/* Return the next character available from a macro, or 0 if
  3037. -   there are no macro characters. */
  3038. -static int
  3039. -next_macro_key ()
  3040. -{
  3041. -    if (!executing_macro)
  3042. -        return (0);
  3043. -
  3044. -    if (!executing_macro[executing_macro_index])
  3045. -    {
  3046. -        pop_executing_macro ();
  3047. -        return (next_macro_key ());
  3048. -    }
  3049. -
  3050. -    return (executing_macro[executing_macro_index++]);
  3051. -}
  3052. -
  3053. -/* Save the currently executing macro on a stack of saved macros. */
  3054. -static void
  3055. -push_executing_macro ()
  3056. -{
  3057. -    struct saved_macro *saver;
  3058. -
  3059. -    saver = (struct saved_macro *)xmalloc (sizeof (struct saved_macro));
  3060. -    saver->next = macro_list;
  3061. -    saver->index = executing_macro_index;
  3062. -    saver->string = executing_macro;
  3063. -
  3064. -    macro_list = saver;
  3065. -}
  3066. -
  3067. -/* Discard the current macro, replacing it with the one
  3068. -   on the top of the stack of saved macros. */
  3069. -static void
  3070. -pop_executing_macro ()
  3071. -{
  3072. -    if (executing_macro)
  3073. -        free (executing_macro);
  3074. -
  3075. -    executing_macro = (char *)NULL;
  3076. -    executing_macro_index = 0;
  3077. -
  3078. -    if (macro_list)
  3079. -    {
  3080. -        struct saved_macro *disposer = macro_list;
  3081. -        executing_macro = macro_list->string;
  3082. -        executing_macro_index = macro_list->index;
  3083. -        macro_list = macro_list->next;
  3084. -        free (disposer);
  3085. -    }
  3086. -}
  3087. -
  3088. -/* Add a character to the macro being built. */
  3089. -static void
  3090. -add_macro_char (c)
  3091. -int c;
  3092. -{
  3093. -    if (current_macro_index + 1 >= current_macro_size)
  3094. -    {
  3095. -        if (!current_macro)
  3096. -            current_macro = (char *)xmalloc (current_macro_size = 25);
  3097. -        else
  3098. -            current_macro =
  3099. -                (char *)xrealloc (current_macro, current_macro_size += 25);
  3100. -    }
  3101. -
  3102. -    current_macro[current_macro_index++] = c;
  3103. -    current_macro[current_macro_index] = '\0';
  3104. -}
  3105. -
  3106. -/* Begin defining a keyboard macro.
  3107. -   Keystrokes are recorded as they are executed.
  3108. -   End the definition with rl_end_kbd_macro ().
  3109. -   If a numeric argument was explicitly typed, then append this
  3110. -   definition to the end of the existing macro, and start by
  3111. -   re-executing the existing macro. */
  3112. -rl_start_kbd_macro (ignore1, ignore2)
  3113. -int ignore1, ignore2;
  3114. -{
  3115. -    if (defining_kbd_macro)
  3116. -        rl_abort ();
  3117. -
  3118. -    if (rl_explicit_arg)
  3119. -    {
  3120. -        if (current_macro)
  3121. -            with_macro_input (savestring (current_macro));
  3122. -    }
  3123. -    else
  3124. -        current_macro_index = 0;
  3125. -
  3126. -    defining_kbd_macro = 1;
  3127. -}
  3128. -
  3129. -/* Stop defining a keyboard macro.
  3130. -   A numeric argument says to execute the macro right now,
  3131. -   that many times, counting the definition as the first time. */
  3132. -rl_end_kbd_macro (count, ignore)
  3133. -int count, ignore;
  3134. -{
  3135. -    if (!defining_kbd_macro)
  3136. -        rl_abort ();
  3137. -
  3138. -    current_macro_index -= (rl_key_sequence_length - 1);
  3139. -    current_macro[current_macro_index] = '\0';
  3140. -
  3141. -    defining_kbd_macro = 0;
  3142. -
  3143. -    rl_call_last_kbd_macro (--count, 0);
  3144. -}
  3145. -
  3146. -/* Execute the most recently defined keyboard macro.
  3147. -   COUNT says how many times to execute it. */
  3148. -rl_call_last_kbd_macro (count, ignore)
  3149. -int count, ignore;
  3150. -{
  3151. -    if (!current_macro)
  3152. -        rl_abort ();
  3153. -
  3154. -    while (count--)
  3155. -        with_macro_input (savestring (current_macro));
  3156. -}
  3157. -
  3158. -
  3159. -/* **************************************************************** */
  3160. -/*                                    */
  3161. -/*            Initializations                 */
  3162. -/*                                    */
  3163. -/* **************************************************************** */
  3164. -
  3165. -/* Initliaze readline (and terminal if not already). */
  3166. -rl_initialize ()
  3167. -{
  3168. -    extern char *rl_display_prompt;
  3169. -
  3170. -    /* If we have never been called before, initialize the
  3171. -     terminal and data structures. */
  3172. -    if (!rl_initialized)
  3173. -    {
  3174. -        readline_initialize_everything ();
  3175. -        rl_initialized++;
  3176. -    }
  3177. -
  3178. -    /* Initalize the current line information. */
  3179. -    rl_point = rl_end = 0;
  3180. -    the_line = rl_line_buffer;
  3181. -    the_line[0] = 0;
  3182. -
  3183. -    /* We aren't done yet.  We haven't even gotten started yet! */
  3184. -    rl_done = 0;
  3185. -
  3186. -    /* Tell the history routines what is going on. */
  3187. -    start_using_history ();
  3188. -
  3189. -    /* Make the display buffer match the state of the line. */
  3190. -    {
  3191. -        extern char *rl_display_prompt;
  3192. -        extern int forced_display;
  3193. -
  3194. -        rl_on_new_line ();
  3195. -
  3196. -        rl_display_prompt = rl_prompt ? rl_prompt : "";
  3197. -        forced_display = 1;
  3198. -    }
  3199. -
  3200. -    /* No such function typed yet. */
  3201. -    rl_last_func = (Function *)NULL;
  3202. -
  3203. -    /* Parsing of key-bindings begins in an enabled state. */
  3204. -    parsing_conditionalized_out = 0;
  3205. -}
  3206. -
  3207. -/* Initialize the entire state of the world. */
  3208. -readline_initialize_everything ()
  3209. -{
  3210. -    /* Find out if we are running in Emacs. */
  3211. -    running_in_emacs = (char *)getenv ("EMACS");
  3212. -
  3213. -    /* Allocate data structures. */
  3214. -    if (!rl_line_buffer)
  3215. -        rl_line_buffer =
  3216. -            (char *)xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE);
  3217. -
  3218. -    /* Initialize the terminal interface. */
  3219. -    init_terminal_io ((char *)NULL);
  3220. -
  3221. -    /* Bind tty characters to readline functions. */
  3222. -    readline_default_bindings ();
  3223. -
  3224. -    /* Initialize the function names. */
  3225. -    rl_initialize_funmap ();
  3226. -
  3227. -    /* Read in the init file. */
  3228. -    rl_read_init_file ((char *)NULL);
  3229. -
  3230. -    /* If the completion parser's default word break characters haven't
  3231. -     been set yet, then do so now. */
  3232. -    {
  3233. -        extern char *rl_completer_word_break_characters;
  3234. -        extern char *rl_basic_word_break_characters;
  3235. -
  3236. -        if (rl_completer_word_break_characters == (char *)NULL)
  3237. -            rl_completer_word_break_characters = rl_basic_word_break_characters;
  3238. -    }
  3239. -}
  3240. -
  3241. -/* If this system allows us to look at the values of the regular
  3242. -   input editing characters, then bind them to their readline
  3243. -   equivalents. */
  3244. -readline_default_bindings ()
  3245. -{
  3246. -
  3247. -#ifdef NEW_TTY_DRIVER
  3248. -    struct sgttyb ttybuff;
  3249. -    int tty = fileno (rl_instream);
  3250. -
  3251. -    if (ioctl (tty, TIOCGETP, &ttybuff) != -1)
  3252. -    {
  3253. -        int erase = ttybuff.sg_erase, kill = ttybuff.sg_kill;
  3254. -
  3255. -        if (erase != -1 && keymap[erase].type == ISFUNC)
  3256. -            keymap[erase].function = rl_rubout;
  3257. -
  3258. -        if (kill != -1 && keymap[kill].type == ISFUNC)
  3259. -            keymap[kill].function = rl_unix_line_discard;
  3260. -    }
  3261. -
  3262. -#ifdef TIOCGLTC
  3263. -    {
  3264. -        struct ltchars lt;
  3265. -
  3266. -        if (ioctl (tty, TIOCGLTC, <) != -1)
  3267. -        {
  3268. -            int erase = lt.t_werasc, nextc = lt.t_lnextc;
  3269. -
  3270. -            if (erase != -1 && keymap[erase].type == ISFUNC)
  3271. -                keymap[erase].function = rl_unix_word_rubout;
  3272. -
  3273. -            if (nextc != -1 && keymap[nextc].type == ISFUNC)
  3274. -                keymap[nextc].function = rl_quoted_insert;
  3275. -        }
  3276. -    }
  3277. -#endif /* TIOCGLTC */
  3278. -#else /* not NEW_TTY_DRIVER */
  3279. -    struct termio ttybuff;
  3280. -    int tty = fileno (rl_instream);
  3281. -
  3282. -    if (ioctl (tty, TCGETA, &ttybuff) != -1)
  3283. -    {
  3284. -        int erase = ttybuff.c_cc[VERASE];
  3285. -        int kill = ttybuff.c_cc[VKILL]l
  3286. -
  3287. -        if (erase != -1 && keymap[(unsigned char)erase].type == ISFUNC)
  3288. -            keymap[(unsigned char)erase].function = rl_rubout;
  3289. -
  3290. -        if (kill != -1 && keymap[(unsigned char)kill].type == ISFUNC)
  3291. -            keymap[(unsigned char)kill].function = rl_unix_line_discard;
  3292. -    }
  3293. -#endif /* NEW_TTY_DRIVER */
  3294. -}
  3295. -
  3296. -
  3297. -/* **************************************************************** */
  3298. -/*                                    */
  3299. -/*            Numeric Arguments                */
  3300. -/*                                    */
  3301. -/* **************************************************************** */
  3302. -
  3303. -/* Handle C-u style numeric args, as well as M--, and M-digits. */
  3304. -
  3305. -/* Add the current digit to the argument in progress. */
  3306. -rl_digit_argument (ignore, key)
  3307. -int ignore, key;
  3308. -{
  3309. -    rl_pending_input = key;
  3310. -    rl_digit_loop ();
  3311. -}
  3312. -
  3313. -/* What to do when you abort reading an argument. */
  3314. -rl_discard_argument ()
  3315. -{
  3316. -    ding ();
  3317. -    rl_clear_message ();
  3318. -    rl_init_argument ();
  3319. -}
  3320. -
  3321. -/* Create a default argument. */
  3322. -rl_init_argument ()
  3323. -{
  3324. -    rl_numeric_arg = arg_sign = 1;
  3325. -    rl_explicit_arg = 0;
  3326. -}
  3327. -
  3328. -/* C-u, universal argument.  Multiply the current argument by 4.
  3329. -   Read a key.  If the key has nothing to do with arguments, then
  3330. -   dispatch on it.  If the key is the abort character then abort. */
  3331. -rl_universal_argument ()
  3332. -{
  3333. -    rl_numeric_arg *= 4;
  3334. -    rl_digit_loop ();
  3335. -}
  3336. -
  3337. -rl_digit_loop ()
  3338. -{
  3339. -    int key, c;
  3340. -    while (1)
  3341. -    {
  3342. -        rl_message ("(arg: %d) ", arg_sign * rl_numeric_arg);
  3343. -        key = c = rl_read_key ();
  3344. -
  3345. -        if (keymap[c].type == ISFUNC &&
  3346. -            keymap[c].function == rl_universal_argument)
  3347. -        {
  3348. -            rl_numeric_arg *= 4;
  3349. -            continue;
  3350. -        }
  3351. -        c = UNMETA (c);
  3352. -        if (numeric (c))
  3353. -        {
  3354. -            if (rl_explicit_arg)
  3355. -                rl_numeric_arg = (rl_numeric_arg * 10) + (c - '0');
  3356. -            else
  3357. -                rl_numeric_arg = (c - '0');
  3358. -            rl_explicit_arg = 1;
  3359. -        }
  3360. -        else
  3361. -        {
  3362. -            if (c == '-' && !rl_explicit_arg)
  3363. -            {
  3364. -                rl_numeric_arg = 1;
  3365. -                arg_sign = -1;
  3366. -            }
  3367. -            else
  3368. -            {
  3369. -                rl_clear_message ();
  3370. -                rl_dispatch (key, keymap);
  3371. -                return;
  3372. -            }
  3373. -        }
  3374. -    }
  3375. -}
  3376. -
  3377. -
  3378. -/* **************************************************************** */
  3379. -/*                                    */
  3380. -/*            Display stuff                    */
  3381. -/*                                    */
  3382. -/* **************************************************************** */
  3383. -
  3384. -/* This is the stuff that is hard for me.  I never seem to write good
  3385. -   display routines in C.  Let's see how I do this time. */
  3386. -
  3387. -/* (PWP) Well... Good for a simple line updater, but totally ignores
  3388. -   the problems of input lines longer than the screen width.
  3389. -
  3390. -   update_line and the code that calls it makes a multiple line,
  3391. -   automatically wrapping line update.  Carefull attention needs
  3392. -   to be paid to the vertical position variables.
  3393. -
  3394. -   handling of terminals with autowrap on (incl. DEC braindamage)
  3395. -   could be improved a bit.  Right now I just cheat and decrement
  3396. -   screenwidth by one. */
  3397. -
  3398. -/* Keep two buffers; one which reflects the current contents of the
  3399. -   screen, and the other to draw what we think the new contents should
  3400. -   be.  Then compare the buffers, and make whatever changes to the
  3401. -   screen itself that we should.  Finally, make the buffer that we
  3402. -   just drew into be the one which reflects the current contents of the
  3403. -   screen, and place the cursor where it belongs.
  3404. -
  3405. -   Commands that want to can fix the display themselves, and then let
  3406. -   this function know that the display has been fixed by setting the
  3407. -   RL_DISPLAY_FIXED variable.  This is good for efficiency. */
  3408. -
  3409. -/* Termcap variables: */
  3410. -extern char *term_up, *term_dc, *term_cr;
  3411. -extern int screenheight, screenwidth, terminal_can_insert;
  3412. -
  3413. ---cut here---cut here---cut here---
  3414.