home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3495 < prev    next >
Encoding:
Internet Message Format  |  1991-06-20  |  54.5 KB

  1. From: pgf@cayman.COM (Paul Fox)
  2. Newsgroups: alt.sources
  3. Subject: Vile 09/17 - vi feel-alike (multi-window)
  4. Message-ID: <4528@cayman.COM>
  5. Date: 7 Jun 91 22:09:47 GMT
  6.  
  7. #!/bin/sh
  8. # this is vileshar.09 (part 9 of Vile)
  9. # do not concatenate these parts, unpack them in order with /bin/sh
  10. # file main.c continued
  11. #
  12. if test ! -r _shar_seq_.tmp; then
  13.     echo 'Please unpack part 1 first!'
  14.     exit 1
  15. fi
  16. (read Scheck
  17.  if test "$Scheck" != 9; then
  18.     echo Please unpack part "$Scheck" next!
  19.     exit 1
  20.  else
  21.     exit 0
  22.  fi
  23. ) < _shar_seq_.tmp || exit 1
  24. echo 'x - continuing file main.c'
  25. sed 's/^X//' << 'SHAR_EOF' >> 'main.c' &&
  26. X *
  27. X * This file contains the main driving routine, and some keyboard processing
  28. X * code, for the screen editor.
  29. X *
  30. X */
  31. X
  32. #include        <stdio.h>
  33. X
  34. /* for MSDOS, increase the default stack space */
  35. X
  36. #if    MSDOS & LATTICE
  37. unsigned _stack = 32767;
  38. #endif
  39. X
  40. #if    ATARI & LATTICE & 0
  41. int _mneed = 256000;        /* reset memory pool size */
  42. #endif
  43. X
  44. #if    MSDOS & AZTEC
  45. int _STKSIZ = 32767/16;        /* stack size in paragraphs */
  46. int _STKRED = 1024;        /* stack checking limit */
  47. int _HEAPSIZ = 4096/16;        /* (in paragraphs) */
  48. int _STKLOW = 0;        /* default is stack above heap (small only) */
  49. #endif
  50. X
  51. #if    MSDOS & TURBO
  52. unsigned _stklen = 32768;
  53. #endif
  54. X
  55. /* make global definitions not external */
  56. #define    maindef
  57. X
  58. #include        "estruct.h"    /* global structures and defines */
  59. X
  60. #if UNIX
  61. #include    <signal.h>
  62. #endif
  63. X
  64. #include    "nefunc.h"    /* function declarations */
  65. #include    "nebind.h"    /* default key bindings */
  66. #include    "nename.h"    /* name table */
  67. #include    "edef.h"    /* global definitions */
  68. X
  69. X
  70. #if     VMS
  71. #include        <ssdef.h>
  72. #define GOOD    (SS$_NORMAL)
  73. #endif
  74. X
  75. #ifndef GOOD
  76. #define GOOD    0
  77. #endif
  78. X
  79. main(argc, argv)
  80. char    *argv[];
  81. {
  82. X        int    c;        /* command character */
  83. X        int    f;        /* default flag */
  84. X        int    n;        /* numeric repeat count */
  85. X    int    s;
  86. X    register BUFFER *bp;        /* temp buffer pointer */
  87. X    register int    gotafile;    /* filename arg present? */
  88. X    register int    carg;        /* current arg to scan */
  89. X    register int    ranstartup;    /* startup executed flag */
  90. X    BUFFER *firstbp = NULL;        /* ptr to first buffer in cmd line */
  91. X    int viewflag;            /* are we starting in view mode? */
  92. X        int gotoflag;                   /* do we need to goto a line at start? */
  93. X        int helpflag;                   /* do we need to goto a line at start? */
  94. X        int gline;                      /* if so, what line? */
  95. X        int searchflag;                 /* Do we need to search at start? */
  96. #if TAGS
  97. X        int tagflag, didtag;                    /* look up a tag to start? */
  98. X    char *tname;
  99. #endif
  100. X        char bname[NBUFN];        /* buffer name of file to read */
  101. X    char *msg;
  102. #if    CRYPT
  103. X    /* int cryptflag;            /* encrypting on the way in? */
  104. X    char ekey[NPAT];        /* startup encryption key */
  105. #endif
  106. X    char *strncpy();
  107. #if UNIX
  108. X    extern int catchintr();
  109. X    extern int imdying();
  110. X    extern int sizesignal();
  111. #endif
  112. X    extern char *pathname[];    /* startup file path/name array */
  113. X
  114. X    charinit();        /* character types -- we need these pretty
  115. X                    early  */
  116. X
  117. X    viewflag = FALSE;    /* view mode defaults off in command line */
  118. X    gotoflag = FALSE;    /* set to off to begin with */
  119. X    helpflag = FALSE;    /* set to off to begin with */
  120. X    searchflag = FALSE;    /* set to off to begin with */
  121. #if TAGS
  122. X    tagflag = FALSE;    /* set to off to begin with */
  123. #endif
  124. X    gotafile = FALSE;    /* no file to edit yet */
  125. X    ranstartup = FALSE;    /* startup file not executed yet */
  126. #if    CRYPT
  127. X    cryptflag = FALSE;    /* no encryption by default */
  128. #endif
  129. X
  130. X    /* Parse the command line */
  131. X    for (carg = 1; carg < argc; ++carg) {
  132. X
  133. X        /* Process Switches */
  134. X        if (argv[carg][0] == '-') {
  135. X            switch (argv[carg][1]) {
  136. #if    NeWS
  137. X            case 'l':    /* -l for screen lines */
  138. X            case 'L':
  139. X                term.t_nrow = atoi(&argv[carg][2]);
  140. X                break;
  141. #endif
  142. X            case 'e':    /* -e for Edit file */
  143. X            case 'E':
  144. X                viewflag = FALSE;
  145. X                break;
  146. X            case 'g':    /* -g for initial goto */
  147. X            case 'G':
  148. X                gotoflag = TRUE;
  149. X                if (argv[carg][2]) {
  150. X                    gline = atoi(&argv[carg][2]);
  151. X                } else {
  152. X                    if (++carg < argc)
  153. X                        gline = atoi(&argv[carg][0]);
  154. X                    else
  155. X                        goto usage;
  156. X                }
  157. X                break;
  158. X            case 'h':    /* -h for initial help */
  159. X            case 'H':
  160. X                helpflag = TRUE;
  161. X                break;
  162. #if    CRYPT
  163. X            case 'k':    /* -k<key> for code key */
  164. X            case 'K':
  165. X                cryptflag = TRUE;
  166. X                if (argv[carg][2]) {
  167. X                    strcpy(ekey, &argv[carg][2]);
  168. X                } else {
  169. X                    if (++carg < argc)
  170. X                        strcpy(ekey, &argv[carg][0]);
  171. X                    else
  172. X                        goto usage;
  173. X                }
  174. X                break;
  175. #endif
  176. X            case 's':  /* -s for initial search string */
  177. X            case 'S':
  178. X                searchflag = TRUE;
  179. X                if (argv[carg][2]) {
  180. X                    strncpy(pat,&argv[carg][2],NPAT);
  181. X                } else {
  182. X                    if (++carg < argc)
  183. X                        strncpy(pat,&argv[carg][0],NPAT);
  184. X                    else
  185. X                        goto usage;
  186. X                }
  187. X                rvstrcpy(tap, pat);
  188. X                break;
  189. #if TAGS
  190. X            case 't':  /* -t for initial tag lookup */
  191. X            case 'T':
  192. X                tagflag = TRUE;
  193. X                if (argv[carg][2]) {
  194. X                    tname = &argv[carg][2];
  195. X                } else {
  196. X                    if (++carg < argc)
  197. X                        tname = &argv[carg][0];
  198. X                    else
  199. X                        goto usage;
  200. X                }
  201. X                break;
  202. #endif
  203. X            case 'v':    /* -v for View File */
  204. X            case 'V':
  205. X                viewflag = TRUE;
  206. X                break;
  207. X            default:    /* unknown switch */
  208. X            usage:
  209. X                fprintf(stderr,
  210. X            "usage: %s -flags files...\n%s%s%s%s%s%s",argv[0],
  211. X                "    -h to get help on startup\n",
  212. X                  "    -gNNN or simply +NNN to go to line NNN\n",
  213. X                "    -sstring to search for string\n",
  214. #if TAGS
  215. X                "    -ttagname to look up a tag\n",
  216. #else
  217. X                "",
  218. #endif
  219. X                "    -v to view files as read-only\n",
  220. #if CRYPT
  221. X                "    -kcryptkey for encrypted files\n"
  222. #else
  223. X                ""
  224. #endif
  225. X                );
  226. X                exit(1);
  227. X            }
  228. X
  229. X        } else if (argv[carg][0]== '+') { /* alternate form of -g */
  230. X            gotoflag = TRUE;
  231. X            gline = atoi(&argv[carg][1]);
  232. X        } else if (argv[carg][0]== '@') {
  233. X            /* Process Startup macroes */
  234. X            if (startup(&argv[carg][1]) == TRUE)
  235. X                ranstartup = TRUE; /* don't execute .vilerc */
  236. X        } else {
  237. X
  238. X            /* Process an input file */
  239. X
  240. X            /* set up a buffer for this file */
  241. X                    makename(bname, argv[carg]);
  242. X            unqname(bname,FALSE);
  243. X
  244. X            bp = bfind(bname, OK_CREAT, 0);
  245. X            make_current(bp); /* pull it to the front */
  246. X            strcpy(bp->b_fname, argv[carg]);
  247. X            if (!gotafile) {
  248. X                firstbp = bp;
  249. X                gotafile = TRUE;
  250. X            }
  251. X
  252. X            /* set the modes appropriatly */
  253. X            if (viewflag)
  254. X                bp->b_mode |= MDVIEW;
  255. #if    CRYPT
  256. X            if (cryptflag) {
  257. X                bp->b_mode |= MDCRYPT;
  258. X                crypt((char *)NULL, 0);
  259. X                crypt(ekey, strlen(ekey));
  260. X                strncpy(bp->b_key, ekey, NPAT);
  261. X            }
  262. #endif
  263. X        }
  264. X    }
  265. X
  266. X    /* initialize the editor */
  267. #if UNIX
  268. X    signal(SIGHUP,imdying);
  269. X    signal(SIGINT,catchintr);
  270. X    signal(SIGBUS,imdying);
  271. X    signal(SIGSEGV,imdying);
  272. X    signal(SIGSYS,imdying);
  273. X    signal(SIGTERM,imdying);
  274. X    signal(SIGQUIT,imdying);
  275. X    signal(SIGPIPE,SIG_IGN);
  276. #ifdef SIGWINCH
  277. X    signal(SIGWINCH,sizesignal);
  278. #endif
  279. #endif
  280. X    vtinit();        /* Display */
  281. X    winit();        /* windows */
  282. X    varinit();        /* user variables */
  283. X    
  284. X    /* we made some calls to makecurrent() above, to shuffle the
  285. X        list order.  this set curbp, which isn't actually kosher */
  286. X    curbp = NULL;
  287. X
  288. X    /* this comes out to 70 on an 80 column display */
  289. X    fillcol = (7 * term.t_ncol) / 8;
  290. X    if (fillcol > 70)
  291. X        fillcol = 70;
  292. X
  293. X    /* if invoked with no other startup files,
  294. X       run the system startup file here */
  295. X    if (!ranstartup) {
  296. X
  297. X        /* if .vilerc is one of the input files....don't clobber it */
  298. X        if (gotafile && strcmp(pathname[0], firstbp->b_bname) == 0) {
  299. X            c = firstbp->b_bname[0];
  300. X            firstbp->b_bname[0] = '[';
  301. X            startup(pathname[0]);
  302. X            firstbp->b_bname[0] = c;
  303. X        } else {
  304. X            startup(pathname[0]);
  305. X        }
  306. X        ranstartup = TRUE;
  307. X    }
  308. X
  309. X    /* if there are any files to read, read the first one! */
  310. X    if (gotafile) {
  311. X        nextbuffer(FALSE,0);
  312. X    }
  313. #if TAGS
  314. X    else if (tagflag) {
  315. X             tags(tname);
  316. X             didtag = TRUE;
  317. X    }
  318. #endif
  319. X    if (!curbp) {
  320. X        bp = bfind("[unnamed]", OK_CREAT, 0);
  321. X        bp->b_active = TRUE;
  322. X        swbuffer(bp);
  323. X    }
  324. X    curbp->b_mode |= (gmode & ~(MDCMOD|MDDOS));
  325. X
  326. X    msg = "";
  327. X    if (helpflag) {
  328. X        if (help(TRUE,1) != TRUE) {
  329. X            msg = 
  330. X    "[Problem with help information. Type \":quit\" to exit if you wish]";
  331. X        }
  332. X    } else {
  333. X        msg = "[Use ^A-h, ^X-h, or :help to get help]";
  334. X    }
  335. X
  336. X        /* Deal with startup gotos and searches */
  337. X        if (gotoflag + searchflag
  338. #if TAGS
  339. X         + tagflag 
  340. #endif
  341. X        > 1) {
  342. #if TAGS
  343. X        msg = "[Search, goto and tag are used one at a time]";
  344. #else
  345. X        msg = "[Cannot search and goto at the same time]";
  346. #endif
  347. X    } else if (gotoflag) {
  348. X                if (gotoline(TRUE,gline) == FALSE)
  349. X            msg = "[Invalid goto argument]";
  350. X        } else if (searchflag) {
  351. X                forwhunt(FALSE, 0);
  352. #if TAGS
  353. X        } else if (tagflag && !didtag) {
  354. X                tags(tname);
  355. #endif
  356. X        }
  357. X
  358. X    update(FALSE);
  359. X    mlwrite(msg);
  360. X
  361. X
  362. X    /* process commands */
  363. X    loop();
  364. X
  365. }
  366. X
  367. loop()
  368. {
  369. X    int s,c,f,n;
  370. X    while(1) {
  371. X        /* Vi doesn't let the cursor rest on the newline itself.  This
  372. X            takes care of that. */
  373. X        if (curwp->w_doto == llength(curwp->w_dotp) &&
  374. X                llength(curwp->w_dotp) != 0)
  375. X            backchar(TRUE,1);
  376. X
  377. X        /* same goes for end of file */
  378. X        if (curwp->w_dotp == curbp->b_linep &&
  379. X            lback(curwp->w_dotp) != curbp->b_linep)
  380. X            backline(TRUE,1);
  381. X
  382. X        /* start recording for '.' command */
  383. X        dotcmdbegin();
  384. X
  385. X        /* Fix up the screen    */
  386. X        s = update(FALSE);
  387. X
  388. X        /* get the next command from the keyboard */
  389. X        c = kbd_seq();
  390. X
  391. X        /* if there is something on the command line, clear it */
  392. X        if (mpresf != FALSE) {
  393. X            mlerase();
  394. X            if (s != SORTOFTRUE) /* did nothing due to typeahead */
  395. X                update(FALSE);
  396. X        }
  397. X
  398. X        f = FALSE;
  399. X        n = 1;
  400. X
  401. X        do_num_proc(&c,&f,&n);
  402. X        do_rept_arg_proc(&c,&f,&n);
  403. X
  404. X        kregflag = 0;
  405. X        
  406. X        /* flag the first time through for some commands -- e.g. subst
  407. X            must know to not prompt for strings again, and pregion
  408. X            must only restart the p-lines buffer once for each
  409. X            command. */
  410. X        calledbefore = FALSE;
  411. X
  412. X        /* and execute the command */
  413. X        execute(kcod2fnc(c), f, n);
  414. X        
  415. X        if (bheadp != curbp)
  416. X            mlwrite("BUG: main: bheadp != curbp, bhead name is %s",
  417. X                     bheadp->b_bname);
  418. X
  419. X        /* stop recording for '.' command */
  420. X        dotcmdfinish();
  421. X    }
  422. }
  423. X
  424. #if BSD | USG | V7
  425. catchintr()
  426. {
  427. X    interrupted = TRUE;
  428. #if USG
  429. X    signal(SIGINT,catchintr);
  430. #endif
  431. }
  432. #endif
  433. X
  434. /* do number processing if needed */
  435. do_num_proc(cp,fp,np)
  436. int *cp, *fp, *np;
  437. {
  438. X    register int c, f, n;
  439. X        register int    mflag;
  440. X
  441. X    c = *cp;
  442. X    f = *fp;
  443. X    n = *np;
  444. X
  445. X    if (iscntrl(c) || (c & (CTLA|CTLX|SPEC)))
  446. X        return;
  447. X    if ( isdigit(c) && c != '0' ) {
  448. X        f = TRUE;        /* there is a # arg */
  449. X        n = 0;            /* start with a zero default */
  450. X        mflag = 1;        /* current minus flag */
  451. X        while (isdigit(c) || (c == '-')) {
  452. X            if (c == '-') {
  453. X                /* already hit a minus or digit? */
  454. X                if ((mflag == -1) || (n != 0))
  455. X                    break;
  456. X                mflag = -1;
  457. X            } else {
  458. X                n = n * 10 + (c - '0');
  459. X            }
  460. X            if ((n == 0) && (mflag == -1))    /* lonely - */
  461. X                mlwrite("arg:");
  462. X            else
  463. X                mlwrite("arg: %d",n * mflag);
  464. X
  465. X            c = kbd_seq();    /* get the next key */
  466. X        }
  467. X        n = n * mflag;    /* figure in the sign */
  468. X    }
  469. X    *cp = c;
  470. X    *fp = f;
  471. X    *np = n;
  472. }
  473. X
  474. /* do ^U-style repeat argument processing -- vile binds this to 'K' */
  475. do_rept_arg_proc(cp,fp,np)
  476. int *cp, *fp, *np;
  477. {
  478. X    register int c, f, n;
  479. X        register int    mflag;
  480. X    c = *cp;
  481. X    f = *fp;
  482. X    n = *np;
  483. X
  484. X        if (c != reptc) 
  485. X        return;
  486. X
  487. X        f = TRUE;
  488. X        n = 4;                          /* with argument of 4 */
  489. X        mflag = 0;                      /* that can be discarded. */
  490. X        mlwrite("arg: 4");
  491. X        while (isdigit(c=kbd_seq()) || c==reptc || c=='-'){
  492. X                if (c == reptc)
  493. X            if ((n > 0) == ((n*4) > 0))
  494. X                                n = n*4;
  495. X                        else
  496. X                            n = 1;
  497. X                /*
  498. X                 * If dash, and start of argument string, set arg.
  499. X                 * to -1.  Otherwise, insert it.
  500. X                 */
  501. X                else if (c == '-') {
  502. X                        if (mflag)
  503. X                                break;
  504. X                        n = 0;
  505. X                        mflag = -1;
  506. X                }
  507. X                /*
  508. X                 * If first digit entered, replace previous argument
  509. X                 * with digit and set sign.  Otherwise, append to arg.
  510. X                 */
  511. X                else {
  512. X                        if (!mflag) {
  513. X                                n = 0;
  514. X                                mflag = 1;
  515. X                        }
  516. X                        n = 10*n + c - '0';
  517. X                }
  518. X                mlwrite("arg: %d", (mflag >=0) ? n : (n ? -n : -1));
  519. X        }
  520. X        /*
  521. X         * Make arguments preceded by a minus sign negative and change
  522. X         * the special argument "^U -" to an effective "^U -1".
  523. X         */
  524. X        if (mflag == -1) {
  525. X                if (n == 0)
  526. X                        n++;
  527. X                n = -n;
  528. X        }
  529. X
  530. X    *cp = c;
  531. X    *fp = f;
  532. X    *np = n;
  533. }
  534. X
  535. X
  536. /*
  537. X * This is the general command execution routine. It takes care of checking
  538. X * flags, globals, etc, to be sure we're not doing something dumb.
  539. X * Return the status of command.
  540. X */
  541. X
  542. int
  543. execute(execfunc, f, n)
  544. CMDFUNC *execfunc;        /* ptr to function to execute */
  545. {
  546. X        register int status, flags;
  547. X    LINE *odotp;
  548. X    int odoto;
  549. X
  550. X    if (execfunc == NULL) {
  551. X        TTbeep();
  552. #if REBIND
  553. X        mlwrite("[Key not bound]");    /* complain        */
  554. #else
  555. X        mlwrite("[Not a command]");    /* complain        */
  556. #endif
  557. X        return (FALSE);
  558. X    }
  559. X
  560. X    flags = execfunc->c_flags;
  561. X
  562. X    /* commands following operators can't be redone or undone */
  563. X    if ( !doingopcmd) {
  564. X        /* don't record non-redoable cmds */
  565. X        if ((flags & REDO) == 0)
  566. X            dotcmdstop();
  567. X        if (flags & UNDO) {
  568. X            /* undoable command can't be permitted when read-only */
  569. X            if (curbp->b_mode&MDVIEW)
  570. X                return(rdonly());
  571. X            mayneedundo();
  572. X        }
  573. X    }
  574. X
  575. X    /* if motion is absolute, remember where we are */
  576. X    if (flags & ABS) {
  577. X        odotp = curwp->w_dotp;
  578. X        odoto = curwp->w_doto;
  579. X    }
  580. X
  581. X    status = (execfunc->c_func)(f, n, NULL, NULL);
  582. X    if ((flags & GOAL) == 0) { /* goal should not be retained */
  583. X        curgoal = -1;
  584. X    }
  585. X    if (flags & UNDO)    /* verify malloc arena after line changers */
  586. X        vverify("main");
  587. X
  588. X    /* if motion was absolute, and we moved, update the "last dot" mark */
  589. X    if ((flags & ABS) && curwp->w_dotp != odotp) {
  590. X        curwp->w_ldmkp = odotp;
  591. X        curwp->w_ldmko = odoto;
  592. X    }
  593. X
  594. X    return (status);
  595. }
  596. X
  597. /*
  598. X * Fancy quit command, as implemented by Norm. If the any buffer has
  599. X * changed do a write on that buffer and exit, otherwise simply exit.
  600. X */
  601. quickexit(f, n)
  602. {
  603. X    register BUFFER *bp;    /* scanning pointer to buffers */
  604. X        register BUFFER *oldcb; /* original current buffer */
  605. X    register int status;
  606. X    int thiscmd;
  607. X    int cnt;
  608. X
  609. X        oldcb = curbp;                          /* save in case we fail */
  610. X
  611. X    thiscmd = lastcmd;
  612. X    if (cnt = anycb()) {
  613. X        mlwrite("Will write %d buffer%c  %s ",
  614. X            cnt, cnt > 1 ? 's':'.',
  615. X            clexec ? "" : "Repeat command to continue.");
  616. X        if (!clexec && !isnamedcmd) {
  617. X            if (thiscmd != kbd_seq())
  618. X                return(FALSE);
  619. X        }
  620. X
  621. X        bp = bheadp;
  622. X        while (bp != NULL) {
  623. X            if ((bp->b_flag&BFCHG) != 0 &&
  624. X                (bp->b_flag&BFINVS) == 0) {
  625. X                    make_current(bp);
  626. X                mlwrite("[Saving %s]",bp->b_fname);
  627. X                mlwrite("\n");
  628. X                if ((status = filesave(f, n)) != TRUE) {
  629. X                        make_current(oldcb);
  630. X                    return(status);
  631. X                }
  632. X                mlwrite("\n");
  633. X            }
  634. X            bp = bp->b_bufp;    /* on to the next buffer */
  635. X        }
  636. X    } else if (!clexec && !isnamedcmd) {
  637. X        if (thiscmd != kbd_seq())
  638. X            return(FALSE);
  639. X    }
  640. X        quithard(f, n);                             /* conditionally quit   */
  641. X    return(TRUE);
  642. }
  643. X
  644. /* Force quit by giving argument */
  645. quithard(f,n)
  646. {
  647. X    quit(TRUE,1);
  648. }
  649. X
  650. /*
  651. X * Quit command. If an argument, always quit. Otherwise confirm if a buffer
  652. X * has been changed and not written out.
  653. X */
  654. quit(f, n)
  655. {
  656. X    int cnt;
  657. X    
  658. X        if (f != FALSE || (cnt = anycb()) == 0) {
  659. X                vttidy(TRUE);
  660. #if    FILOCK
  661. X        if (lockrel() != TRUE) {
  662. X            exit(1);
  663. X        }
  664. #endif
  665. X                exit(GOOD);
  666. X        }
  667. X    if (cnt == 1)
  668. X        mlwrite(
  669. X        "There is an unwritten modified buffer.  Write it, or use :q!");
  670. X    else
  671. X        mlwrite(
  672. X        "There are %d unwritten modified buffers.  Write them, or use :q!",
  673. X            cnt);
  674. X        return (FALSE);
  675. }
  676. X
  677. writequit(f,n)
  678. {
  679. X    int s;
  680. X    s = filesave(FALSE,n);
  681. X    if (s != TRUE)
  682. X        return s;
  683. X    return(quit(FALSE,n));
  684. }
  685. X
  686. /*
  687. X * Begin recording a dot command macro.
  688. X * Set up variables and return.
  689. X */
  690. dotcmdbegin()
  691. {
  692. X    switch (dotcmdmode) {
  693. X        case TMPSTOP:
  694. X    case PLAY:
  695. X                return(FALSE);
  696. X    }
  697. X    tmpcmdptr = &tmpcmdm[0];
  698. X    tmpcmdend = tmpcmdptr;
  699. X        dotcmdmode = RECORD;
  700. X        return (TRUE);
  701. }
  702. X
  703. /*
  704. X * End dot command
  705. X */
  706. dotcmdfinish()
  707. {
  708. X
  709. X    switch (dotcmdmode) {
  710. X        case STOP:
  711. X    case PLAY:
  712. X    case TMPSTOP:
  713. X                return(FALSE);
  714. X
  715. X    case RECORD:
  716. X        ;
  717. X    }
  718. X    tmpcmdptr = &tmpcmdm[0];
  719. X    dotcmdptr = &dotcmdm[0];
  720. X    while (tmpcmdptr < tmpcmdend)
  721. X        *dotcmdptr++ = *tmpcmdptr++;
  722. X    dotcmdend = dotcmdptr;
  723. X    dotcmdptr = &dotcmdm[0];
  724. X    tmpcmdptr = tmpcmdptr = &tmpcmdm[0];
  725. X    /* leave us in RECORD mode */
  726. X        return(TRUE);
  727. }
  728. X
  729. dotcmdstop()
  730. {
  731. X    if (dotcmdmode == RECORD) {
  732. X        dotcmdmode = STOP;
  733. X    }
  734. }
  735. X
  736. /*
  737. X * Execute a macro.
  738. X * The command argument is the number of times to loop. Quit as soon as a
  739. X * command gets an error. Return TRUE if all ok, else FALSE.
  740. X */
  741. dotcmdplay(f, n)
  742. {
  743. X        if (n <= 0)
  744. X                return (TRUE);
  745. X    dotcmdrep = n;        /* remember how many times to execute */
  746. X    dotcmdmode = PLAY;        /* put us in play mode */
  747. X    dotcmdptr = &dotcmdm[0];    /*    at the beginning */
  748. X
  749. X    return(TRUE);
  750. }
  751. /*
  752. X * Begin a keyboard macro.
  753. X * Error if not at the top level in keyboard processing. Set up variables and
  754. X * return.
  755. X */
  756. ctlxlp(f, n)
  757. {
  758. X        if (kbdmode != STOP) {
  759. X                mlwrite("%%Macro already active");
  760. X                return(FALSE);
  761. X        }
  762. X        mlwrite("[Start macro]");
  763. X    kbdptr = &kbdm[0];
  764. X    kbdend = kbdptr;
  765. X        kbdmode = RECORD;
  766. X        return (TRUE);
  767. }
  768. X
  769. /*
  770. X * End keyboard macro. Check for the same limit conditions as the above
  771. X * routine. Set up the variables and return to the caller.
  772. X */
  773. ctlxrp(f, n)
  774. {
  775. X        if (kbdmode == STOP) {
  776. X                mlwrite("%%Macro not active");
  777. X                return(FALSE);
  778. X        }
  779. X    if (kbdmode == RECORD) {
  780. X            mlwrite("[End macro]");
  781. X            kbdmode = STOP;
  782. X    }
  783. X        return(TRUE);
  784. }
  785. X
  786. /*
  787. X * Execute a macro.
  788. X * The command argument is the number of times to loop. Quit as soon as a
  789. X * command gets an error. Return TRUE if all ok, else FALSE.
  790. X */
  791. ctlxe(f, n)
  792. {
  793. X        if (kbdmode != STOP) {
  794. X                mlwrite("%%Macro already active");
  795. X                return(FALSE);
  796. X        }
  797. X        if (n <= 0)
  798. X                return (TRUE);
  799. X    kbdrep = n;        /* remember how many times to execute */
  800. X    kbdmode = PLAY;        /* start us in play mode */
  801. X    kbdptr = &kbdm[0];    /*    at the beginning */
  802. X    return(TRUE);
  803. }
  804. X
  805. /*
  806. X * Abort.
  807. X * Beep the beeper. Kill off any keyboard macro, etc., that is in progress.
  808. X * Sometimes called as a routine, to do general aborting of stuff.
  809. X */
  810. esc(f, n)
  811. {
  812. X        TTbeep();
  813. X    kbdmode = STOP;
  814. X    dotcmdmode = STOP;
  815. X    fulllineregions = FALSE;
  816. X    doingopcmd = FALSE;
  817. X    opcmd = 0;
  818. X    mlwrite("[Aborted]");
  819. X        return(ABORT);
  820. }
  821. X
  822. /* tell the user that this command is illegal while we are in
  823. X   VIEW (read-only) mode                */
  824. X
  825. rdonly()
  826. {
  827. X    TTbeep();
  828. X    mlwrite("[No changes are allowed while in \"view\" mode]");
  829. X    return FALSE;
  830. }
  831. X
  832. showversion(f,n)
  833. {
  834. X    mlwrite(version);
  835. X    return TRUE;
  836. }
  837. X
  838. unimpl()
  839. {
  840. X    TTbeep();
  841. X    mlwrite("[Sorry, that vi command is unimplemented in vile ]");
  842. X    return FALSE;
  843. }
  844. X
  845. opercopy() { return unimpl(); }
  846. opermove() { return unimpl(); }
  847. opertransf() { return unimpl(); }
  848. X
  849. operglobals() { return unimpl(); }
  850. opervglobals() { return unimpl(); }
  851. X
  852. map() { return unimpl(); }
  853. unmap() { return unimpl(); }
  854. X
  855. source() { return unimpl(); }
  856. X
  857. subst_again() { return unimpl(); }
  858. X
  859. visual() { return unimpl(); }
  860. ex() { return unimpl(); }
  861. X
  862. nullproc()    /* user function that does (almost) NOTHING */
  863. {
  864. X    return TRUE;
  865. }
  866. X
  867. cntl_af()    /* dummy function for binding to control-a prefix */
  868. {
  869. }
  870. X
  871. cntl_xf()    /* dummy function for binding to control-x prefix */
  872. {
  873. }
  874. X
  875. unarg()    /* dummy function for binding to universal-argument */
  876. {
  877. }
  878. X
  879. /* initialize our version of the "chartypes" stuff normally in ctypes.h */
  880. charinit()
  881. {
  882. X    register int c;
  883. X
  884. X    /* legal in pathnames */
  885. X    _chartypes_['.'] = 
  886. X        _chartypes_['_'] = 
  887. X        _chartypes_['-'] =
  888. X        _chartypes_['*'] = 
  889. X        _chartypes_['/'] = _path;
  890. X
  891. X    /* legal in "identifiers" */
  892. X    _chartypes_['_'] |= _ident;
  893. X
  894. X    /* whitespace */
  895. X    _chartypes_[' '] =
  896. X        _chartypes_['\t'] = 
  897. X        _chartypes_['\r'] =
  898. X        _chartypes_['\n'] = 
  899. X        _chartypes_['\f'] = _space;
  900. X
  901. X    /* control characters */
  902. X    for (c = 0; c < ' '; c++)
  903. X        _chartypes_[c] |= _cntrl;
  904. X    _chartypes_[127] |= _cntrl;
  905. X
  906. X    /* lowercase */
  907. X    for (c = 'a'; c <= 'z'; c++)
  908. X        _chartypes_[c] |= _lower|_path|_ident;
  909. X
  910. X    /* uppercase */
  911. X    for (c = 'A'; c <= 'Z'; c++)
  912. X        _chartypes_[c] |= _upper|_path|_ident;
  913. X
  914. X    /* digits */
  915. X    for (c = '0'; c <= '9'; c++)
  916. X        _chartypes_[c] |= _digit|_path|_ident|_linespec;
  917. X
  918. X    /* punctuation */
  919. X    for (c = '!'; c <= '/'; c++)
  920. X        _chartypes_[c] |= _punct;
  921. X    for (c = ':'; c <= '@'; c++)
  922. X        _chartypes_[c] |= _punct;
  923. X    for (c = '['; c <= '`'; c++)
  924. X        _chartypes_[c] |= _punct;
  925. X    for (c = '{'; c <= '~'; c++)
  926. X        _chartypes_[c] |= _punct;
  927. X
  928. X    /* printable */
  929. X    for (c = ' '; c <= '~'; c++)
  930. X        _chartypes_[c] |= _print;
  931. X
  932. X    /* backspacers: ^H, rubout, and the user's backspace char */
  933. X    /* we'll add the user's char later */
  934. X    _chartypes_['\b'] |= _bspace;
  935. X    _chartypes_[127] |= _bspace;
  936. X
  937. X    /* wildcard chars for most shells */
  938. X    _chartypes_['*'] |= _wild;
  939. X    _chartypes_['?'] |= _wild;
  940. X    _chartypes_['~'] |= _wild;
  941. X    _chartypes_['['] |= _wild;
  942. X    _chartypes_[']'] |= _wild;
  943. X    _chartypes_['$'] |= _wild;
  944. X    _chartypes_['{'] |= _wild;
  945. X    _chartypes_['}'] |= _wild;
  946. X
  947. X    /* ex mode line specifiers */
  948. X    _chartypes_[','] |= _linespec;
  949. X    _chartypes_['%'] |= _linespec;
  950. X    _chartypes_['-'] |= _linespec;
  951. X    _chartypes_['+'] |= _linespec;
  952. X    _chartypes_['.'] |= _linespec;
  953. X    _chartypes_['$'] |= _linespec;
  954. X    _chartypes_['\''] |= _linespec;
  955. X
  956. }
  957. X
  958. X
  959. /*****        Compiler specific Library functions    ****/
  960. X
  961. #if    MWC86 & MSDOS
  962. movmem(source, dest, size)
  963. char *source;    /* mem location to move memory from */
  964. char *dest;    /* memory location to move text to */
  965. int size;    /* number of bytes to move */
  966. {
  967. X    register int i;
  968. X
  969. X    for (i=0; i < size; i++)
  970. X        *dest++ = *source++;
  971. }
  972. #endif
  973. X
  974. #if    (AZTEC | MSC | TURBO | LATTICE) & MSDOS
  975. /*    strncpy:    copy a string...with length restrictions
  976. X            ALWAYS null terminate
  977. Hmmmm...
  978. I don't know much about DOS, but I do know that strncpy shouldn't ALWAYS
  979. X    null terminate.  -pgf
  980. */
  981. X
  982. char *strncpy(dst, src, maxlen)
  983. char *dst;    /* destination of copied string */
  984. char *src;    /* source */
  985. int maxlen;    /* maximum length */
  986. {
  987. X    char *dptr;    /* ptr into dst */
  988. X
  989. X    dptr = dst;
  990. X    while (*src && (maxlen-- > 0))
  991. X        *dptr++ = *src++;
  992. X    *dptr = 0;
  993. X    return(dst);
  994. }
  995. #endif
  996. X
  997. #if    RAMSIZE & LATTICE & MSDOS
  998. /*    These routines will allow me to track memory usage by placing
  999. X    a layer on top of the standard system malloc() and free() calls.
  1000. X    with this code defined, the environment variable, $RAM, will
  1001. X    report on the number of bytes allocated via malloc.
  1002. X
  1003. X    with SHOWRAM defined, the number is also posted on the
  1004. X    end of the bottom mode line and is updated whenever it is changed.
  1005. */
  1006. X
  1007. #undef    malloc
  1008. #undef    free
  1009. X
  1010. char *allocate(nbytes)    /* allocate nbytes and track */
  1011. unsigned nbytes;    /* # of bytes to allocate */
  1012. {
  1013. X    char *mp;    /* ptr returned from malloc */
  1014. X
  1015. X    mp = malloc(nbytes);
  1016. X    if (mp) {
  1017. X        envram += nbytes;
  1018. #if    RAMSHOW
  1019. X        dspram();
  1020. #endif
  1021. X    }
  1022. X
  1023. X    return(mp);
  1024. }
  1025. X
  1026. release(mp)    /* release malloced memory and track */
  1027. char *mp;    /* chunk of RAM to release */
  1028. {
  1029. X    unsigned *lp;    /* ptr to the long containing the block size */
  1030. X
  1031. X    if (mp) {
  1032. X        lp = ((unsigned *)mp) - 1;
  1033. X
  1034. X        /* update amount of ram currently malloced */
  1035. X        envram -= (long)*lp - 2;
  1036. X        free(mp);
  1037. #if    RAMSHOW
  1038. X        dspram();
  1039. #endif
  1040. X    }
  1041. }
  1042. X
  1043. #if    RAMSHOW
  1044. dspram()    /* display the amount of RAM currently malloced */
  1045. {
  1046. X    char mbuf[20];
  1047. X    char *sp;
  1048. X
  1049. X    TTmove(term.t_nrow - 1, 70);
  1050. #if    COLOR
  1051. X    TTforg(7);
  1052. X    TTbacg(0);
  1053. #endif
  1054. X    sprintf(mbuf, "[%lu]", envram);
  1055. X    sp = &mbuf[0];
  1056. X    while (*sp)
  1057. X        TTputc(*sp++);
  1058. X    TTmove(term.t_nrow, 0);
  1059. X    movecursor(term.t_nrow, 0);
  1060. }
  1061. #endif
  1062. #endif
  1063. SHAR_EOF
  1064. echo 'File main.c is complete' &&
  1065. chmod 0444 main.c ||
  1066. echo 'restore of main.c failed'
  1067. Wc_c="`wc -c < 'main.c'`"
  1068. test 23507 -eq "$Wc_c" ||
  1069.     echo 'main.c: original size 23507, current size' "$Wc_c"
  1070. # ============= make.ini ==============
  1071. echo 'x - extracting make.ini (Text)'
  1072. sed 's/^X//' << 'SHAR_EOF' > 'make.ini' &&
  1073. CP    =    copy            # what 'cp' to use.
  1074. RM    =    del            # what 'rm' to use.
  1075. MV    =    ren            # What 'mv' to use.
  1076. LINKER    =    \usr\lib\bin\tlink.exe    # What link to use.
  1077. CC    =    tcc            # What C compiler I am using.
  1078. X
  1079. INCLUDE    =    \usr\lib\tinclude    # Where to find header files.      .h
  1080. LIB    =    \usr\lib\tlib        # Where to find the libary files. .lib
  1081. MAPFILE    =    \dev\nul        # Where to put the link map file.
  1082. X
  1083. # switches for TurboC....
  1084. MODEL    =    l            # t)iny s)mall c)ompact m)edium l)arge h)uge
  1085. MDL    =    $(MODEL)        # The masm model.
  1086. CPU    =    1            # 0=8088 1=186/286
  1087. MATH    =    f            # f87=8087 f=emulate f-=no floating
  1088. MATHLIB =    emu            # emu, f87, or nothing
  1089. TYPE    =    G            # G=speed    O=size
  1090. SWITCHES=    -I$(INCLUDE) -L$(LIB) -m$(MODEL) -$(CPU) -$(MATH)       \
  1091. X        -$(TYPE)
  1092. CFLAGS    =    $(SWITCHES)
  1093. X
  1094. # Print the `make -h' message
  1095. .HELP
  1096. X
  1097. # The order to search for rules and files is specified by .SUFFIXES
  1098. .SUFFIXES:    .exe .obj .c .for .asm
  1099. X
  1100. # DEFAULT RULES
  1101. .asm.obj:
  1102. X    masm    $*.asm;
  1103. X
  1104. .c.obj:
  1105. X    $(CC)    $(CFLAGS) -c $*.c
  1106. X
  1107. .for.obj:
  1108. X    for1    $*.for;
  1109. X    pas2
  1110. X
  1111. .obj.exe:
  1112. X    $(CP)    $(LINKER) .\link.exe
  1113. X    link    $(LIB)\c0$(MODEL) $(OBJS), $@, $(MAPFILE),          \
  1114. X        $(LIB)\$(MATHLIB) $(LIB)\math$(MODEL) $(LIB)\c$(MODEL)
  1115. X    $(RM)    .\link.exe
  1116. X    $(CP)    $(PROGRAM) $(DEST)
  1117. X
  1118. # .obj.exe:
  1119. #    link    $*.obj, $@, $(MAPFILE), $(LIBS)
  1120. X
  1121. .asm.exe:
  1122. X    masm    $*.asm;
  1123. X    link    $*.obj, $@, $(MAPFILE), $(LIBS)
  1124. X    $(RM)    $*.obj
  1125. X
  1126. .c.exe:
  1127. X    $(CC)    $(CFLAGS) -c $*.c
  1128. X    link    $*.obj, $@;
  1129. X    $(RM)    $*.obj
  1130. X
  1131. .for.exe:
  1132. X    for1    $*.for;
  1133. X    pas2
  1134. X    link    $*.obj, $@, $(MAPFILE), $(LIB)\FORTRAN.LIB
  1135. SHAR_EOF
  1136. chmod 0444 make.ini ||
  1137. echo 'restore of make.ini failed'
  1138. Wc_c="`wc -c < 'make.ini'`"
  1139. test 1438 -eq "$Wc_c" ||
  1140.     echo 'make.ini: original size 1438, current size' "$Wc_c"
  1141. # ============= makefile ==============
  1142. echo 'x - extracting makefile (Text)'
  1143. sed 's/^X//' << 'SHAR_EOF' > 'makefile' &&
  1144. #
  1145. # makefile for vile.  
  1146. # The defs for what system this is really running on are in estruct.h.
  1147. #  Be sure to edit that, to define your system.
  1148. # The command/name/key/function bindings are defined in the file "cmdtbl". The
  1149. #  mktbls program parses this to produce nebind.h, nename.h, and nefunc.h,
  1150. #  which are used by the rest of the build.
  1151. #
  1152. #  The version number (currently three) is found near the top of
  1153. #  edef.h, and is displayed with the '*' and ":version" commands.
  1154. #         Paul Fox
  1155. #
  1156. # original makefile for uemacs:    Adam Fritz    July 30,1987
  1157. X
  1158. X
  1159. # To change screen driver modules, change SCREEN below, and edit estruct.h to
  1160. #  make sure the correct one is #defined as "1", and the others all as "0"
  1161. #SCREEN = at386
  1162. # if you use tcap.c, you'll need libtermcap.a too.
  1163. SCREEN = tcap
  1164. X
  1165. TARGET = vile
  1166. X
  1167. #DESTDIR = $(HOME)/bin
  1168. DESTDIR = /usr/local/bin
  1169. LIBS = -ltermcap
  1170. X
  1171. REMOTE=towno!pgf
  1172. X
  1173. #CFLAGS = -O
  1174. CFLAGS = -g
  1175. #CFLAGS = -g -systype sysv    # for the mips machine
  1176. CC=cc
  1177. X
  1178. X
  1179. # All of the makefiles which should be preserved
  1180. MAKEFILES = makefile make.ini
  1181. HEADER_BUILDER = ./mktbls
  1182. X
  1183. ALLTOOLS = $(MAKEFILES)
  1184. X
  1185. # this stuff lives in the shorten subdirectory.  It was lifted from the
  1186. #    GNU emacs distribution.  See the file COPYING for more info.
  1187. SHORTSTUFF = shorten/COPYING \
  1188. X    shorten/names.c \
  1189. X    shorten/dups.c \
  1190. X    shorten/defines.c \
  1191. X    shorten/header.h \
  1192. X    shorten/reserved \
  1193. X    shorten/special
  1194. X
  1195. # these are normal editable headers
  1196. HDRS = estruct.h epath.h evar.h edef.h
  1197. X
  1198. # these headers are built by the mktbls program from the information
  1199. #  in cmdtbl, but are backed up and
  1200. #  distributed anyway, in case you can't get mktbls running
  1201. BUILTHDRS = nebind.h nefunc.h nename.h 
  1202. X
  1203. # this is obsolete stuff NOT needed by the build, but it shouldn't
  1204. #  be thrown away (yet).  For instance, ebind.h has per-machine binding
  1205. #  information that hasn't been incorporated into cmdtbl yet.
  1206. OLDHDRS = ebind.h efunc.h
  1207. X
  1208. ALLHDRS = $(HDRS) $(BUILTHDRS) $(OLDHDRS)
  1209. X
  1210. # All the C files which should be saved
  1211. #  (including tools, like mktbls.c, unused screen drivers, etc.)
  1212. CSRCac = ansi.c at386.c basic.c bind.c buffer.c crypt.c csrch.c
  1213. CSRCde = dg10.c display.c dolock.c eval.c exec.c
  1214. CSRCfh = file.c fileio.c finderr.c globals.c hp110.c hp150.c
  1215. CSRCim = ibmpc.c input.c isearch.c line.c lock.c main.c mktbls.c
  1216. CSRCnr = news.c npopen.c opers.c oneliner.c random.c region.c
  1217. CSRCst = search.c spawn.c st520.c tags.c tcap.c termio.c tipc.c
  1218. CSRCuz = undo.c vmalloc.c vmsvt.c vt52.c window.c word.c wordmov.c z309.c
  1219. X
  1220. CSRC = $(CSRCac) $(CSRCde) $(CSRCfh) $(CSRCim) $(CSRCnr) \
  1221. X    $(CSRCst) $(CSRCuz)
  1222. X
  1223. # non-C source code
  1224. OTHERSRC = z100bios.asm news.cps
  1225. X
  1226. # text and data files
  1227. TEXTFILES = README cmdtbl vile.hlp tags buglist readme.news
  1228. X
  1229. ALLSRC = $(CSRC) $(OTHERSRC)
  1230. X
  1231. EVERYTHING = $(ALLTOOLS) $(ALLHDRS) $(ALLSRC) $(TEXTFILES) $(SHORTSTUFF)
  1232. X
  1233. SRC = npopen.c finderr.c main.c buffer.c $(SCREEN).c termio.c display.c \
  1234. X    word.c wordmov.c window.c spawn.c \
  1235. X    region.c search.c random.c isearch.c lock.c line.c \
  1236. X    input.c fileio.c exec.c file.c eval.c \
  1237. X    dolock.c crypt.c bind.c basic.c opers.c undo.c csrch.c tags.c \
  1238. X    vmalloc.c globals.c oneliner.c
  1239. X
  1240. OBJ = npopen.o finderr.o main.o buffer.o $(SCREEN).o termio.o display.o \
  1241. X    word.o wordmov.o window.o spawn.o \
  1242. X    region.o search.o random.o isearch.o lock.o line.o \
  1243. X    input.o fileio.o exec.o file.o eval.o \
  1244. X    dolock.o crypt.o bind.o basic.o opers.o undo.o csrch.o tags.o \
  1245. X    vmalloc.o globals.o oneliner.o
  1246. X
  1247. all: $(TARGET)
  1248. X
  1249. $(TARGET) : $(BUILTHDRS) $(OBJ) makefile
  1250. X    -mv $(TARGET) o$(TARGET)
  1251. X    $(CC) $(CFLAGS) -o $(TARGET) $(OBJ) $(LIBS)
  1252. X
  1253. $(BUILTHDRS): cmdtbl $(HEADER_BUILDER)
  1254. X    $(HEADER_BUILDER) cmdtbl
  1255. X
  1256. install : $(TARGET)
  1257. X    cp $(TARGET) $(DESTDIR)
  1258. X    test -f vile.hlp && /bin/rm -f $(DESTDIR)/vile.hlp
  1259. X    cp vile.hlp $(DESTDIR)
  1260. X    chmod 0644 $(DESTDIR)/vile.hlp 
  1261. X
  1262. compr-shar:
  1263. X    [ -d cshardir ] || mkdir cshardir
  1264. #    add -a for archive headers, add -s pgf@cayman.com for submitted-by
  1265. X    shar -p -nvile -L55 -o cshardir/vileshar \
  1266. X        -T README -C `ls $(EVERYTHING) | sed /README/d`
  1267. X
  1268. shar:
  1269. X    [ -d shardir ] || mkdir shardir
  1270. #    add -a for archive headers, add -s pgf@cayman.com for submitted-by
  1271. X    shar -x -a -spgf@cayman.com -nVile -L55 \
  1272. X            -o shardir/vileshar `ls $(EVERYTHING)`
  1273. X
  1274. # only uucp things changed since last time
  1275. uuto:
  1276. X    uuto `ls -t $(EVERYTHING) uutodone | sed '/uutodone/q'` $(REMOTE)
  1277. X    date >uutodone
  1278. X
  1279. floppy:
  1280. X    ls $(EVERYTHING) | oo
  1281. X
  1282. # you don't want to know...
  1283. dosscript:
  1284. X    (                                \
  1285. X    echo echo on                            ;\
  1286. X    for x in `ls -t $(EVERYTHING) dosback.bat | sed '/dosback.bat/q'` ;\
  1287. X    do                                \
  1288. X        echo copy o:$$x a:                    ;\
  1289. X    done                                 ;\
  1290. X    echo quit                            ;\
  1291. X    ) >tmp.bat
  1292. X    ud < tmp.bat >dosback.bat
  1293. X    /bin/rm -f tmp.bat
  1294. X    #-dos
  1295. X    #>dosback.bat
  1296. X    
  1297. newdosfloppy:
  1298. X    touch 0101010170 dosback.bat
  1299. X
  1300. # dump a list of the important files
  1301. list:
  1302. X    @ls $(EVERYTHING) | more
  1303. X
  1304. # dump a list of files that may have changed since last backup
  1305. rw list-writeable:
  1306. X    @for x in $(EVERYTHING) ;\
  1307. X    do \
  1308. X        if [ -w $$x ] ;\
  1309. X        then \
  1310. X            echo $$x ;\
  1311. X        fi \
  1312. X    done
  1313. X
  1314. no-write:
  1315. X    chmod -w $(EVERYTHING)
  1316. X
  1317. tags:
  1318. X    dotags $(SRC) $(HDRS)
  1319. X
  1320. lint:    $(SRC)
  1321. X    lint -hbvxac $(SRC) >lint.out 
  1322. X
  1323. clean:
  1324. X    rm -f *.o o$(TARGET) $(BUILTHDRS) $(HEADER_BUILDER) news.h core *~ *.BAK
  1325. X
  1326. clobber: clean
  1327. X    rm -f $(TARGET)
  1328. X
  1329. news.h: news.cps
  1330. X    cps news.cps
  1331. X
  1332. print:
  1333. X    pr makefile $(HDRS) $(SRC) | lpr
  1334. X
  1335. depend:     $(SRC) $(HDRS) $(BUILTHDRS)
  1336. X    mv -f makefile makefile.orig
  1337. X    (sed -e '/^#DEPENDS/,$$d' makefile.orig ; \
  1338. X        echo "#DEPENDS" ; \
  1339. X        $(CC) -M $(CFLAGS) $? ) > makefile
  1340. X
  1341. # you need this if SHORTNAMES is 0 in estruct.h
  1342. # estruct.h: shorten/remap.h
  1343. X
  1344. # or this either
  1345. shorten/remap.h:
  1346. X    cd shorten; $(MAKE) remap.h
  1347. X
  1348. #DEPENDS
  1349. news.o: news.c
  1350. news.o: /usr/include/stdio.h
  1351. news.o: ./estruct.h
  1352. news.o: ./edef.h
  1353. news.o: ./news.h
  1354. word.o: word.c
  1355. word.o: /usr/include/stdio.h
  1356. word.o: ./estruct.h
  1357. word.o: ./edef.h
  1358. vmsvt.o: vmsvt.c
  1359. vmsvt.o: /usr/include/stdio.h
  1360. vmsvt.o: ./estruct.h
  1361. vmsvt.o: ./edef.h
  1362. window.o: window.c
  1363. window.o: /usr/include/stdio.h
  1364. window.o: ./estruct.h
  1365. window.o: ./edef.h
  1366. vt52.o: vt52.c
  1367. vt52.o: /usr/include/stdio.h
  1368. vt52.o: ./estruct.h
  1369. vt52.o: ./edef.h
  1370. tipc.o: tipc.c
  1371. tipc.o: /usr/include/stdio.h
  1372. tipc.o: ./estruct.h
  1373. tipc.o: ./edef.h
  1374. tcap.o: tcap.c
  1375. tcap.o: /usr/include/stdio.h
  1376. tcap.o: ./estruct.h
  1377. tcap.o: ./edef.h
  1378. termio.o: termio.c
  1379. termio.o: /usr/include/stdio.h
  1380. termio.o: ./estruct.h
  1381. termio.o: ./edef.h
  1382. termio.o: /usr/include/sgtty.h
  1383. termio.o: /usr/include/sys/ioctl.h
  1384. #termio.o: /usr/include/sys/ttychars.h
  1385. #termio.o: /usr/include/sys/ttydev.h
  1386. termio.o: /usr/include/signal.h
  1387. termio.o: /usr/include/sys/ioctl.h
  1388. spawn.o: spawn.c
  1389. spawn.o: /usr/include/stdio.h
  1390. spawn.o: ./estruct.h
  1391. spawn.o: ./edef.h
  1392. spawn.o: /usr/include/signal.h
  1393. st520.o: st520.c
  1394. st520.o: /usr/include/stdio.h
  1395. st520.o: ./estruct.h
  1396. st520.o: ./edef.h
  1397. region.o: region.c
  1398. region.o: /usr/include/stdio.h
  1399. region.o: ./estruct.h
  1400. region.o: ./edef.h
  1401. search.o: search.c
  1402. search.o: /usr/include/stdio.h
  1403. search.o: ./estruct.h
  1404. search.o: ./edef.h
  1405. main.o: main.c
  1406. main.o: /usr/include/stdio.h
  1407. main.o: ./estruct.h
  1408. main.o: ./nefunc.h
  1409. main.o: ./edef.h
  1410. main.o: ./nebind.h
  1411. main.o: ./nename.h
  1412. random.o: random.c
  1413. random.o: /usr/include/stdio.h
  1414. random.o: ./estruct.h
  1415. random.o: ./edef.h
  1416. isearch.o: isearch.c
  1417. isearch.o: /usr/include/stdio.h
  1418. isearch.o: ./estruct.h
  1419. isearch.o: ./edef.h
  1420. lock.o: lock.c
  1421. lock.o: /usr/include/stdio.h
  1422. lock.o: ./estruct.h
  1423. lock.o: ./edef.h
  1424. lock.o: /usr/include/sys/errno.h
  1425. line.o: line.c
  1426. line.o: /usr/include/stdio.h
  1427. line.o: ./estruct.h
  1428. line.o: ./edef.h
  1429. ibmpc.o: ibmpc.c
  1430. ibmpc.o: /usr/include/stdio.h
  1431. ibmpc.o: ./estruct.h
  1432. ibmpc.o: ./edef.h
  1433. input.o: input.c
  1434. input.o: /usr/include/stdio.h
  1435. input.o: ./estruct.h
  1436. input.o: ./edef.h
  1437. hp110.o: hp110.c
  1438. hp110.o: /usr/include/stdio.h
  1439. hp110.o: ./estruct.h
  1440. hp110.o: ./edef.h
  1441. hp150.o: hp150.c
  1442. hp150.o: /usr/include/stdio.h
  1443. hp150.o: ./estruct.h
  1444. hp150.o: ./edef.h
  1445. fileio.o: fileio.c
  1446. fileio.o: /usr/include/stdio.h
  1447. fileio.o: ./estruct.h
  1448. fileio.o: ./edef.h
  1449. exec.o: exec.c
  1450. exec.o: /usr/include/stdio.h
  1451. exec.o: ./estruct.h
  1452. exec.o: ./edef.h
  1453. file.o: file.c
  1454. file.o: /usr/include/stdio.h
  1455. file.o: ./estruct.h
  1456. file.o: ./edef.h
  1457. eval.o: eval.c
  1458. eval.o: /usr/include/stdio.h
  1459. eval.o: ./estruct.h
  1460. eval.o: ./edef.h
  1461. eval.o: ./evar.h
  1462. display.o: display.c
  1463. display.o: /usr/include/stdio.h
  1464. display.o: ./estruct.h
  1465. display.o: ./edef.h
  1466. dolock.o: dolock.c
  1467. buffer.o: buffer.c
  1468. buffer.o: /usr/include/stdio.h
  1469. buffer.o: ./estruct.h
  1470. buffer.o: ./edef.h
  1471. crypt.o: crypt.c
  1472. crypt.o: /usr/include/stdio.h
  1473. crypt.o: ./estruct.h
  1474. crypt.o: ./edef.h
  1475. dg10.o: dg10.c
  1476. dg10.o: /usr/include/stdio.h
  1477. dg10.o: ./estruct.h
  1478. dg10.o: ./edef.h
  1479. bind.o: bind.c
  1480. bind.o: /usr/include/stdio.h
  1481. bind.o: ./estruct.h
  1482. bind.o: ./edef.h
  1483. bind.o: ./epath.h
  1484. basic.o: basic.c
  1485. basic.o: /usr/include/stdio.h
  1486. basic.o: ./estruct.h
  1487. basic.o: ./edef.h
  1488. ansi.o: ansi.c
  1489. ansi.o: /usr/include/stdio.h
  1490. ansi.o: ./estruct.h
  1491. ansi.o: ./edef.h
  1492. opers.o: opers.c
  1493. opers.o: ./estruct.h
  1494. opers.o: ./edef.h
  1495. wordmov.o: wordmov.c
  1496. wordmov.o: ./estruct.h
  1497. wordmov.o: ./edef.h
  1498. csrch.o: csrch.c
  1499. csrch.o: ./estruct.h
  1500. csrch.o: ./edef.h
  1501. undo.o: undo.c
  1502. undo.o: ./estruct.h
  1503. undo.o: ./edef.h
  1504. tags.o: tags.c
  1505. tags.o: ./estruct.h
  1506. tags.o: ./edef.h
  1507. finderr.o: finderr.c
  1508. finderr.o: ./estruct.h
  1509. finderr.o: ./edef.h
  1510. at386.o: at386.c
  1511. at386.o: /usr/include/stdio.h
  1512. at386.o: ./estruct.h
  1513. at386.o: ./edef.h
  1514. npopen.o: npopen.c
  1515. npopen.o: ./estruct.h
  1516. npopen.o: ./edef.h
  1517. oneliner.o: oneliner.c
  1518. oneliner.o: ./estruct.h
  1519. oneliner.o: ./edef.h
  1520. globals.o: globals.c
  1521. globals.o: ./estruct.h
  1522. globals.o: ./edef.h
  1523. SHAR_EOF
  1524. chmod 0444 makefile ||
  1525. echo 'restore of makefile failed'
  1526. Wc_c="`wc -c < 'makefile'`"
  1527. test 9302 -eq "$Wc_c" ||
  1528.     echo 'makefile: original size 9302, current size' "$Wc_c"
  1529. # ============= mktbls.c ==============
  1530. echo 'x - extracting mktbls.c (Text)'
  1531. sed 's/^X//' << 'SHAR_EOF' > 'mktbls.c' &&
  1532. #include <stdio.h>
  1533. X
  1534. /* This standalone utility program constructs the function, key and command
  1535. X    binding tables for vile.  The input is a data file containing the
  1536. X    desired default relationships among the three entities.  Output
  1537. X    is nebind.h, nefunc.h, and nename.h, all of which are then included
  1538. X    in main.c
  1539. X    This code written by Paul Fox, (c)1990
  1540. X    
  1541. X    See the file "cmdtbls" for input data formats, and "estruct.h" for
  1542. X    the output structures.
  1543. X    
  1544. */
  1545. X
  1546. char *progcreat = "/* %s: this header file was produced automatically by\n\
  1547. X * the %s program, based on input from the file %s\n */\n";
  1548. X
  1549. #define    DIFCNTRL    0x40
  1550. #define tocntrl(c)    ((c)^DIFCNTRL)
  1551. #define toalpha(c)    ((c)^DIFCNTRL)
  1552. #define    DIFCASE        0x20
  1553. #define toupper(c)    ((c)^DIFCASE)
  1554. #define tolower(c)    ((c)^DIFCASE)
  1555. X
  1556. int l = 0;
  1557. FILE *nebind, *nefunc, *nename, *cmdtbl;
  1558. X
  1559. char *malloc();
  1560. char *formcond();
  1561. X
  1562. struct stringl {
  1563. X    char *s1;
  1564. X    char *s2;
  1565. X    char *s3;
  1566. X    struct stringl *nst;
  1567. };
  1568. X    
  1569. main(argc, argv)
  1570. char    *argv[];
  1571. {
  1572. X    char line[100];
  1573. X    char func[50];
  1574. X    char flags[50];
  1575. X    char english[50];
  1576. X    char fcond[50];
  1577. X    char ncond[50];
  1578. X    char key[50];
  1579. X    char bcond[50];
  1580. X    int r;
  1581. X    
  1582. X    if (argc != 2) {
  1583. X        fprintf(stderr, "usage: mktbls cmd-file\n");
  1584. X        exit(1);
  1585. X    }
  1586. X    
  1587. X    if ((cmdtbl = fopen(argv[1],"r")) == NULL ) {
  1588. X        fprintf(stderr,"mktbls: couldn't open cmd-file\n");
  1589. X        exit(1);
  1590. X    }
  1591. X    
  1592. X    if ( (nebind = fopen("nebind.h","w")) == NULL ||
  1593. X        (nefunc = fopen("nefunc.h","w")) == NULL ||
  1594. X        (nename = fopen("nename.h","w")) == NULL ) {
  1595. X        fprintf(stderr,"mktbls: couldn't open header files\n");
  1596. X        exit(1);
  1597. X    }
  1598. X    
  1599. X    fprintf(nebind,progcreat,"nebind.h",argv[0],argv[1]);
  1600. X    fprintf(nefunc,progcreat,"nefunc.h",argv[0],argv[1]);
  1601. X    fprintf(nename,progcreat,"nename.h",argv[0],argv[1]);
  1602. X    
  1603. X    
  1604. X    /* process each input line */
  1605. X    while (fgets(line,100,cmdtbl) != NULL) {
  1606. X        l++;
  1607. X        if (line[0] == '#') {  /* comment */
  1608. X            continue;
  1609. X        } else if (line[0] == '\n') { /* empty line */
  1610. X            continue;
  1611. X        } else if (line[0] != '\t') { /* then it's a new func */
  1612. X            /* we can spill information about funcs right away */
  1613. X            r = sscanf(line,"%s %s %s",func,flags,fcond);
  1614. X            if (r < 2 || r > 3)
  1615. X                badfmt("looking for new function");
  1616. X            if (r != 3)
  1617. X                fcond[0] = '\0';
  1618. X                
  1619. X            if (fcond[0])
  1620. X                fprintf(nefunc,"#if %s\n",fcond);
  1621. X            fprintf(nefunc,"extern int %s();\n", func);
  1622. X            fprintf(nefunc,"\tCMDFUNC f_%s = { %s,\t%s };\n",
  1623. X                func, func, flags);
  1624. X            if (fcond[0])
  1625. X                fprintf(nefunc,"#endif\n");
  1626. X                
  1627. X        } else if (line[1] == '"') { /* then it's an english name */
  1628. X        
  1629. X            r = sscanf(line, " \"%[^\"]\"    %s", english,ncond);
  1630. X            if (r < 1 || r > 2)
  1631. X                badfmt("looking for english name");
  1632. X            if (r != 2)
  1633. X                ncond[0] = '\0';
  1634. X                
  1635. X            savenames(english, func, formcond(fcond,ncond));
  1636. X                
  1637. X        } else if (line[1] == '\'') { /* then it's a key */
  1638. X            r = sscanf(&line[2], "%[^']' %s", key, ncond);
  1639. X            if (r < 1 || r > 2)
  1640. X                badfmt("looking for key binding");
  1641. X            if (r != 2)
  1642. X                ncond[0] = '\0';
  1643. X                
  1644. X            savebindings(key, func, formcond(fcond,ncond));
  1645. X            
  1646. X        } else {
  1647. X            badfmt("bad line");
  1648. X        }
  1649. X    }
  1650. X    
  1651. X    dumpnames();
  1652. X    dumpbindings();
  1653. X    
  1654. X    exit(0);
  1655. }
  1656. X
  1657. char *
  1658. formcond(c1,c2)
  1659. char *c1, *c2;
  1660. {
  1661. X    static char cond[50];
  1662. X    if (c1[0] && c2[0])
  1663. X        sprintf(cond,"#if (%s) & (%s)\n",c1,c2);
  1664. X    else if (c1[0] || c2[0])
  1665. X        sprintf(cond,"#if (%s%s)\n",c1,c2);
  1666. X    else
  1667. X        cond[0] = '\0';
  1668. X    return cond;
  1669. }
  1670. X
  1671. badfmt(s)
  1672. {
  1673. X    fprintf(stderr,"\"cmdtbl\", line %d: bad format:",l);
  1674. X    fprintf(stderr,"    %s\n",s);
  1675. X    exit(1);
  1676. }
  1677. X
  1678. #define ASCIIBIND 0
  1679. #define CTLXBIND 1
  1680. #define CTLABIND 2
  1681. #define SPECBIND 3
  1682. char *bindings[4][128];
  1683. char *conditions[4][128];
  1684. char *tblname[] = {"asciitbl", "ctlxtbl", "metatbl", "spectbl" };
  1685. char *prefname[] = {"", "CTLX|", "CTLA|", "SPEC|" };
  1686. X
  1687. /* prc2kcod: translate printable code to C-language keycode */
  1688. savebindings(s,func,cond)
  1689. char *s, *func, *cond;
  1690. {
  1691. X    int btype, c;
  1692. X    
  1693. X    btype = ASCIIBIND;
  1694. X    
  1695. X    if (*s == '^' && *(s+1) == 'A'&& *(s+2) == '-') {
  1696. X        btype = CTLABIND;
  1697. X        s += 3;
  1698. X    } else if (*s == 'F' && *(s+1) == 'N' && *(s+2) == '-') {
  1699. X        btype = SPECBIND;
  1700. X        s += 3;
  1701. X    } else if (*s == '^' && *(s+1) == 'X'&& *(s+2) == '-') {
  1702. X        btype = CTLXBIND;
  1703. X        s += 3;
  1704. X    }
  1705. X    
  1706. X    if (*s == '\\') { /* try for an octal value */
  1707. X        c = 0;
  1708. X        while (*++s < '8' && *s >= '0') c = (c*8) + *s - '0';
  1709. X        if (c > 127)
  1710. X            badfmt("octal character");
  1711. X        if (bindings[btype][c] != NULL)
  1712. X            badfmt("duplicate key binding");
  1713. X        bindings[btype][c] = malloc(strlen(func)+1);
  1714. X        strcpy(bindings[btype][c], func);
  1715. X    } else if (*s == '^' && (c = *(s+1)) != '\0') { /* a control char? */
  1716. X        if (c > 'a' &&  c < 'z')
  1717. X            c = toupper(c);
  1718. X        c = tocntrl(c);
  1719. X        if (bindings[btype][c] != NULL)
  1720. X            badfmt("duplicate key binding");
  1721. X        bindings[btype][c] = malloc(strlen(func)+1);
  1722. X        strcpy(bindings[btype][c], func);
  1723. X        s += 2;
  1724. X    } else if (c = *s) {
  1725. X        if (bindings[btype][c] != NULL)
  1726. X            badfmt("duplicate key binding");
  1727. X        bindings[btype][c] = malloc(strlen(func)+1);
  1728. X        strcpy(bindings[btype][c], func);
  1729. X        s++;
  1730. X    } else {
  1731. X        badfmt("getting binding");
  1732. X    }
  1733. X    if (cond[0]) {
  1734. X        conditions[btype][c] = malloc(strlen(cond)+1);
  1735. X        strcpy(conditions[btype][c], cond);
  1736. X    } else {
  1737. X        conditions[btype][c] = NULL;
  1738. X    }
  1739. X    
  1740. X    if (*s != '\0')
  1741. X        badfmt("got extra characters");
  1742. X    
  1743. }
  1744. X
  1745. dumpbindings()
  1746. {
  1747. X    char **bindptr;
  1748. X    char *sctl;
  1749. X    int i, c, btype;
  1750. X    
  1751. X    btype = ASCIIBIND;
  1752. X    
  1753. X    fprintf(nebind,"\nCMDFUNC *%s[128] = {\n",tblname[btype]);
  1754. X    for (i = 0; i < 128; i++) {
  1755. X        if (conditions[btype][i]) {
  1756. X            fprintf(nebind,"%s", conditions[btype][i]);
  1757. X        }
  1758. X        if (i < ' ' || i > '~' ) {
  1759. X            sctl = "ctrl-";
  1760. X            c = toalpha(i);
  1761. X        } else {
  1762. X            sctl = "";
  1763. X            c = i;
  1764. X        }
  1765. X            
  1766. X        if (bindings[btype][i])
  1767. X            fprintf(nebind,"    &f_%s,    /* %s%c */\n",
  1768. X                bindings[btype][i], sctl, c);
  1769. X        else
  1770. X            fprintf(nebind,"    NULL,    /* %s%c */\n", sctl, c);
  1771. X        if (conditions[btype][i]) {
  1772. X            fprintf(nebind,"#else\n    NULL,\n#endif\n");
  1773. X        }
  1774. X            
  1775. X    }
  1776. X    fprintf(nebind,"};\n");
  1777. X    
  1778. X    
  1779. X    fprintf(nebind,"\nKBIND kbindtbl[NBINDS] = {\n");
  1780. X    for (btype = 1; btype <= 3; btype++) {
  1781. X        for (i = 0; i < 128; i++) {
  1782. X            if (bindings[btype][i]) {
  1783. X                if (conditions[btype][i]) {
  1784. X                    fprintf(nebind,"%s",
  1785. X                        conditions[btype][i]);
  1786. X                }
  1787. X                if (i < ' ')
  1788. X                    fprintf(nebind,
  1789. X                    "    { %stocntrl('%c'), &f_%s },\n",
  1790. X                        prefname[btype],
  1791. X                        toalpha(i),bindings[btype][i]);
  1792. X                else
  1793. X                    fprintf(nebind,
  1794. X                    "    { %s'%c', &f_%s },\n",
  1795. X                        prefname[btype],
  1796. X                        i, bindings[btype][i]);
  1797. X                if (conditions[btype][i]) {
  1798. X                    fprintf(nebind,"#endif\n");
  1799. X                }
  1800. X            }
  1801. X        }
  1802. X    }
  1803. X    fprintf(nebind,"    { 0, NULL }\n");
  1804. X    fprintf(nebind,"};\n");
  1805. }
  1806. X
  1807. struct stringl lastname = {"\177\177\177\177\177\177", "", "", NULL};
  1808. struct stringl lnamecond = {"", "", "", NULL};
  1809. struct stringl firstname = {"", "", "", &lastname};
  1810. struct stringl fnamecond = {"", "", "", &lnamecond};
  1811. X
  1812. savenames(name,func,cond)
  1813. char *name, *func, *cond;
  1814. {
  1815. X    char tmpline[80];
  1816. X    struct stringl *n, *m;
  1817. X    int r;
  1818. X    
  1819. X    n = (struct stringl *)malloc(sizeof (struct stringl));
  1820. X    
  1821. X    /* strtolower(name); */
  1822. X    
  1823. X    n->s1 = (char *)malloc(strlen(name)+1);
  1824. X    strcpy(n->s1, name);
  1825. X    
  1826. X    sprintf(tmpline,"\t{ \"%s\",\t&f_%s },\n",
  1827. X        name, func);
  1828. X    n->s2 = (char *)malloc(strlen(func)+1);
  1829. X    strcpy(n->s2, func);
  1830. X    
  1831. X    n->s3 = (char *)malloc(strlen(cond)+1);
  1832. X    strcpy(n->s3, cond);
  1833. X    
  1834. X    for (m = &firstname; m->nst != NULL; m = m->nst) {
  1835. X        if ((r = strcmp(n->s1, m->nst->s1)) < 0) { /* insert it here */
  1836. X            n->nst = m->nst;
  1837. X            m->nst = n;
  1838. X            break;
  1839. X        } else if (r == 0) {
  1840. X            badfmt("duplicate english name");
  1841. X        }
  1842. X    }
  1843. }
  1844. X
  1845. dumpnames()
  1846. {
  1847. X    struct stringl *m;
  1848. X    
  1849. X    fprintf(nename,"\n/* if you maintain this by hand, keep it in */\n");
  1850. X    fprintf(nename,"/* alphabetical order!!!! */\n\n");
  1851. X    fprintf(nename,"NTAB nametbl[] = {\n");
  1852. X    for (m = firstname.nst; m->nst != NULL; m = m->nst) {
  1853. X        if (m->s3[0])
  1854. X            fprintf(nename,"%s",m->s3);
  1855. X        fprintf(nename,"\t{ \"%s\",\t&f_%s },\n", m->s1, m->s2);
  1856. X        if (m->s3[0])
  1857. X            fprintf(nename,"#endif\n");
  1858. X    }
  1859. X    fprintf(nename,"    { NULL, NULL }\n};\n");
  1860. }
  1861. X
  1862. strtolower(s)
  1863. char *s;
  1864. {
  1865. X    while (*s) {
  1866. X        if (*s >= 'A' && *s <= 'Z')
  1867. X            *s = tolower(*s);
  1868. X        s++;
  1869. X    }
  1870. }
  1871. SHAR_EOF
  1872. chmod 0444 mktbls.c ||
  1873. echo 'restore of mktbls.c failed'
  1874. Wc_c="`wc -c < 'mktbls.c'`"
  1875. test 7809 -eq "$Wc_c" ||
  1876.     echo 'mktbls.c: original size 7809, current size' "$Wc_c"
  1877. # ============= nebind.h ==============
  1878. echo 'x - extracting nebind.h (Text)'
  1879. sed 's/^X//' << 'SHAR_EOF' > 'nebind.h' &&
  1880. /* nebind.h: this header file was produced automatically by
  1881. X * the ./mktbls program, based on input from the file cmdtbl
  1882. X */
  1883. X
  1884. CMDFUNC *asciitbl[128] = {
  1885. X    NULL,    /* ctrl-@ */
  1886. X    &f_cntl_af,    /* ctrl-A */
  1887. X    &f_backpage,    /* ctrl-B */
  1888. X    NULL,    /* ctrl-C */
  1889. X    &f_forwhpage,    /* ctrl-D */
  1890. X    &f_mvdnwind,    /* ctrl-E */
  1891. X    &f_forwpage,    /* ctrl-F */
  1892. X    &f_showcpos,    /* ctrl-G */
  1893. X    &f_backchar,    /* ctrl-H */
  1894. X    NULL,    /* ctrl-I */
  1895. X    &f_forwline,    /* ctrl-J */
  1896. X    &f_delwind,    /* ctrl-K */
  1897. X    &f_refresh,    /* ctrl-L */
  1898. X    &f_forwbline,    /* ctrl-M */
  1899. X    &f_nextwind,    /* ctrl-N */
  1900. X    &f_onlywind,    /* ctrl-O */
  1901. X    &f_prevwind,    /* ctrl-P */
  1902. X    &f_nullproc,    /* ctrl-Q */
  1903. X    &f_insfile,    /* ctrl-R */
  1904. X    &f_nullproc,    /* ctrl-S */
  1905. X    &f_splitwind,    /* ctrl-T */
  1906. X    &f_backhpage,    /* ctrl-U */
  1907. X    &f_quote,    /* ctrl-V */
  1908. X    &f_operwrite,    /* ctrl-W */
  1909. X    &f_cntl_xf,    /* ctrl-X */
  1910. X    &f_mvupwind,    /* ctrl-Y */
  1911. #if (UNIX&&defined(SIGTSTP))
  1912. X    &f_bktoshell,    /* ctrl-Z */
  1913. #else
  1914. X    NULL,
  1915. #endif
  1916. X    &f_esc,    /* ctrl-[ */
  1917. X    NULL,    /* ctrl-\ */
  1918. #if (TAGS)
  1919. X    &f_gototag,    /* ctrl-] */
  1920. #else
  1921. X    NULL,
  1922. #endif
  1923. X    &f_altbuff,    /* ctrl-^ */
  1924. X    NULL,    /* ctrl-_ */
  1925. X    &f_forwchar,    /*   */
  1926. X    &f_operfilter,    /* ! */
  1927. X    &f_usekreg,    /* " */
  1928. X    NULL,    /* # */
  1929. X    &f_gotoeol,    /* $ */
  1930. #if (CFENCE)
  1931. X    &f_getfence,    /* % */
  1932. #else
  1933. X    NULL,
  1934. #endif
  1935. X    NULL,    /* & */
  1936. X    &f_golinenmmark,    /* ' */
  1937. X    &f_unimpl,    /* ( */
  1938. X    &f_unimpl,    /* ) */
  1939. X    &f_togglelistbuffers,    /* * */
  1940. X    &f_forwbline,    /* + */
  1941. X    &f_rev_csrch,    /* , */
  1942. X    &f_backbline,    /* - */
  1943. X    &f_dotcmdplay,    /* . */
  1944. X    &f_forwsearch,    /* / */
  1945. X    &f_gotobol,    /* 0 */
  1946. X    NULL,    /* 1 */
  1947. X    NULL,    /* 2 */
  1948. X    NULL,    /* 3 */
  1949. X    NULL,    /* 4 */
  1950. X    NULL,    /* 5 */
  1951. X    NULL,    /* 6 */
  1952. X    NULL,    /* 7 */
  1953. X    NULL,    /* 8 */
  1954. X    NULL,    /* 9 */
  1955. X    &f_namedcmd,    /* : */
  1956. X    &f_rep_csrch,    /* ; */
  1957. X    &f_operlshift,    /* < */
  1958. X    NULL,    /* = */
  1959. X    &f_operrshift,    /* > */
  1960. X    &f_backsearch,    /* ? */
  1961. X    NULL,    /* @ */
  1962. X    &f_appendeol,    /* A */
  1963. X    &f_backword,    /* B */
  1964. X    &f_chgtoeol,    /* C */
  1965. X    &f_deltoeol,    /* D */
  1966. X    &f_forwendw,    /* E */
  1967. X    &f_bcsrch,    /* F */
  1968. X    &f_gotoline,    /* G */
  1969. X    &f_gotobos,    /* H */
  1970. X    &f_insertbol,    /* I */
  1971. X    &f_join,    /* J */
  1972. X    &f_unarg,    /* K */
  1973. X    &f_gotoeos,    /* L */
  1974. X    &f_gotomos,    /* M */
  1975. X    &f_revsearch,    /* N */
  1976. X    &f_openup,    /* O */
  1977. X    &f_putbefore,    /* P */
  1978. X    &f_quit,    /* Q */
  1979. X    &f_overwrite,    /* R */
  1980. X    &f_chgline,    /* S */
  1981. X    &f_bcsrch_to,    /* T */
  1982. X    &f_lineundo,    /* U */
  1983. X    &f_enlargewind,    /* V */
  1984. X    &f_forwword,    /* W */
  1985. X    &f_backdelchar,    /* X */
  1986. X    &f_yankline,    /* Y */
  1987. X    &f_quickexit,    /* Z */
  1988. #if (WORDPRO)
  1989. X    &f_gotobosec,    /* [ */
  1990. #else
  1991. X    NULL,
  1992. #endif
  1993. X    NULL,    /* \ */
  1994. #if (WORDPRO)
  1995. X    &f_gotoeosec,    /* ] */
  1996. #else
  1997. X    NULL,
  1998. #endif
  1999. X    &f_firstnonwhite,    /* ^ */
  2000. X    &f_histbuff,    /* _ */
  2001. X    &f_goexactnmmark,    /* ` */
  2002. X    &f_append,    /* a */
  2003. X    &f_backviword,    /* b */
  2004. X    &f_operchg,    /* c */
  2005. X    &f_operdel,    /* d */
  2006. X    &f_forwviendw,    /* e */
  2007. X    &f_fcsrch,    /* f */
  2008. X    NULL,    /* g */
  2009. X    &f_backchar,    /* h */
  2010. X    &f_insert,    /* i */
  2011. X    &f_forwline,    /* j */
  2012. X    &f_backline,    /* k */
  2013. X    &f_forwchar,    /* l */
  2014. X    &f_setnmmark,    /* m */
  2015. X    &f_consearch,    /* n */
  2016. X    &f_opendown,    /* o */
  2017. X    &f_putafter,    /* p */
  2018. X    NULL,    /* q */
  2019. X    &f_replacechar,    /* r */
  2020. X    &f_chgchar,    /* s */
  2021. X    &f_fcsrch_to,    /* t */
  2022. X    &f_undo,    /* u */
  2023. X    &f_shrinkwind,    /* v */
  2024. X    &f_forwviword,    /* w */
  2025. X    &f_forwdelchar,    /* x */
  2026. X    &f_operyank,    /* y */
  2027. X    &f_poswind,    /* z */
  2028. #if (WORDPRO)
  2029. X    &f_gotobop,    /* { */
  2030. #else
  2031. X    NULL,
  2032. #endif
  2033. X    &f_gotocol,    /* | */
  2034. #if (WORDPRO)
  2035. X    &f_gotoeop,    /* } */
  2036. #else
  2037. X    NULL,
  2038. #endif
  2039. X    &f_flipchar,    /* ~ */
  2040. X    NULL,    /* ctrl-? */
  2041. };
  2042. X
  2043. KBIND kbindtbl[NBINDS] = {
  2044. X    { CTLX|tocntrl('C'), &f_quit },
  2045. X    { CTLX|tocntrl('L'), &f_mvleftwind },
  2046. X    { CTLX|tocntrl('R'), &f_mvrightwind },
  2047. #if (FINDERR)
  2048. X    { CTLX|tocntrl('X'), &f_finderr },
  2049. #endif
  2050. #if (TAGS)
  2051. X    { CTLX|tocntrl(']'), &f_untagpop },
  2052. #endif
  2053. X    { CTLX|'!', &f_pipecmd },
  2054. X    { CTLX|'&', &f_ctlxe },
  2055. X    { CTLX|'(', &f_ctlxlp },
  2056. X    { CTLX|')', &f_ctlxrp },
  2057. X    { CTLX|'/', &f_scrforwsearch },
  2058. X    { CTLX|'0', &f_delwind },
  2059. X    { CTLX|'1', &f_onlywind },
  2060. X    { CTLX|'2', &f_splitwind },
  2061. X    { CTLX|'=', &f_showcpos },
  2062. X    { CTLX|'?', &f_scrbacksearch },
  2063. X    { CTLX|'P', &f_lineputbefore },
  2064. #if (ISRCH)
  2065. X    { CTLX|'R', &f_risearch },
  2066. #endif
  2067. #if (ISRCH)
  2068. X    { CTLX|'S', &f_fisearch },
  2069. #endif
  2070. #if (CRYPT)
  2071. X    { CTLX|'X', &f_setkey },
  2072. #endif
  2073. X    { CTLX|'c', &f_operlinechg },
  2074. X    { CTLX|'d', &f_operlinedel },
  2075. X    { CTLX|'e', &f_filefind },
  2076. X    { CTLX|'f', &f_setfillcol },
  2077. X    { CTLX|'h', &f_help },
  2078. X    { CTLX|'p', &f_lineputafter },
  2079. X    { CTLX|'s', &f_opersubst },
  2080. X    { CTLX|'t', &f_settab },
  2081. #if (VMALLOC)
  2082. X    { CTLX|'v', &f_setvmalloc },
  2083. #endif
  2084. X    { CTLX|'y', &f_operlineyank },
  2085. X    { CTLA|tocntrl('D'), &f_scrnextdw },
  2086. X    { CTLA|tocntrl('E'), &f_mvdnnxtwind },
  2087. #if (AEDIT)
  2088. X    { CTLA|tocntrl('I'), &f_entab },
  2089. #endif
  2090. X    { CTLA|tocntrl('U'), &f_scrnextup },
  2091. X    { CTLA|tocntrl('Y'), &f_mvupnxtwind },
  2092. #if (AEDIT)
  2093. X    { CTLA|' ', &f_detab },
  2094. #endif
  2095. X    { CTLA|'*', &f_listbuffers },
  2096. X    { CTLA|'/', &f_scrsearchpat },
  2097. X    { CTLA|':', &f_onamedcmd },
  2098. #if (WORDPRO)
  2099. X    { CTLA|'f', &f_operformat },
  2100. #endif
  2101. X    { CTLA|'h', &f_help },
  2102. #if (WORDPRO)
  2103. X    { CTLA|'j', &f_operformat },
  2104. #endif
  2105. X    { CTLA|'l', &f_operlower },
  2106. #if (AEDIT)
  2107. X    { CTLA|'o', &f_deblank },
  2108. #endif
  2109. X    { CTLA|'t', &f_trimline },
  2110. X    { CTLA|'u', &f_operupper },
  2111. X    { CTLA|'~', &f_operflip },
  2112. #if (TERMCAP)
  2113. X    { SPEC|'1', &f_cbuf1 },
  2114. #endif
  2115. #if (TERMCAP)
  2116. X    { SPEC|'2', &f_cbuf2 },
  2117. #endif
  2118. #if (TERMCAP)
  2119. X    { SPEC|'3', &f_cbuf3 },
  2120. #endif
  2121. #if (TERMCAP)
  2122. X    { SPEC|'4', &f_cbuf4 },
  2123. #endif
  2124. #if (TERMCAP)
  2125. X    { SPEC|'5', &f_cbuf5 },
  2126. #endif
  2127. #if (TERMCAP)
  2128. X    { SPEC|'6', &f_cbuf6 },
  2129. #endif
  2130. #if (TERMCAP)
  2131. X    { SPEC|'7', &f_cbuf7 },
  2132. #endif
  2133. #if (TERMCAP)
  2134. X    { SPEC|'8', &f_cbuf8 },
  2135. #endif
  2136. #if (TERMCAP)
  2137. X    { SPEC|'9', &f_cbuf9 },
  2138. #endif
  2139. X    { 0, NULL }
  2140. };
  2141. SHAR_EOF
  2142. chmod 0664 nebind.h ||
  2143. echo 'restore of nebind.h failed'
  2144. Wc_c="`wc -c < 'nebind.h'`"
  2145. test 5332 -eq "$Wc_c" ||
  2146.     echo 'nebind.h: original size 5332, current size' "$Wc_c"
  2147. # ============= nefunc.h ==============
  2148. echo 'x - extracting nefunc.h (Text)'
  2149. sed 's/^X//' << 'SHAR_EOF' > 'nefunc.h' &&
  2150. /* nefunc.h: this header file was produced automatically by
  2151. X * the ./mktbls program, based on input from the file cmdtbl
  2152. X */
  2153. extern int altbuff();
  2154. X    CMDFUNC f_altbuff = { altbuff,    NONE };
  2155. extern int append();
  2156. X    CMDFUNC f_append = { append,    REDO|UNDO };
  2157. extern int appendeol();
  2158. X    CMDFUNC f_appendeol = { appendeol,    REDO|UNDO };
  2159. #if APROP|REBIND
  2160. extern int apro();
  2161. X    CMDFUNC f_apro = { apro,    NONE };
  2162. #endif
  2163. extern int backchar();
  2164. X    CMDFUNC f_backchar = { backchar,    MOTION };
  2165. extern int backdelchar();
  2166. X    CMDFUNC f_backdelchar = { backdelchar,    REDO|UNDO };
  2167. #if !SMALLER
  2168. extern int backhunt();
  2169. X    CMDFUNC f_backhunt = { backhunt,    ABS|MOTION };
  2170. #endif
  2171. extern int backhpage();
  2172. X    CMDFUNC f_backhpage = { backhpage,    NONE };
  2173. extern int backline();
  2174. X    CMDFUNC f_backline = { backline,    GOAL|MOTION|FL };
  2175. extern int backbline();
  2176. X    CMDFUNC f_backbline = { backbline,    MOTION|FL };
  2177. extern int backpage();
  2178. X    CMDFUNC f_backpage = { backpage,    MOTION };
  2179. extern int backword();
  2180. X    CMDFUNC f_backword = { backword,    MOTION };
  2181. extern int backviword();
  2182. X    CMDFUNC f_backviword = { backviword,    MOTION };
  2183. extern int backsearch();
  2184. X    CMDFUNC f_backsearch = { backsearch,    ABS|MOTION };
  2185. extern int bcsrch();
  2186. X    CMDFUNC f_bcsrch = { bcsrch,    MOTION };
  2187. extern int bcsrch_to();
  2188. X    CMDFUNC f_bcsrch_to = { bcsrch_to,    MOTION };
  2189. #if REBIND
  2190. extern int bindkey();
  2191. X    CMDFUNC f_bindkey = { bindkey,    NONE };
  2192. #endif
  2193. #if UNIX&&defined(SIGTSTP)
  2194. extern int bktoshell();
  2195. X    CMDFUNC f_bktoshell = { bktoshell,    NONE };
  2196. #endif
  2197. extern int cntl_xf();
  2198. X    CMDFUNC f_cntl_xf = { cntl_xf,    NONE };
  2199. extern int chgchar();
  2200. X    CMDFUNC f_chgchar = { chgchar,    REDO|UNDO };
  2201. extern int chgline();
  2202. X    CMDFUNC f_chgline = { chgline,    REDO|UNDO };
  2203. extern int chgtoeol();
  2204. X    CMDFUNC f_chgtoeol = { chgtoeol,    REDO|UNDO };
  2205. extern int clrmes();
  2206. X    CMDFUNC f_clrmes = { clrmes,    NONE };
  2207. extern int consearch();
  2208. X    CMDFUNC f_consearch = { consearch,    ABS|MOTION };
  2209. extern int opercopy();
  2210. X    CMDFUNC f_opercopy = { opercopy,    OPER|(RANGE|EXTRA) };
  2211. extern int ctlxlp();
  2212. X    CMDFUNC f_ctlxlp = { ctlxlp,    NONE };
  2213. extern int ctlxrp();
  2214. X    CMDFUNC f_ctlxrp = { ctlxrp,    NONE };
  2215. extern int ctlxe();
  2216. X    CMDFUNC f_ctlxe = { ctlxe,    REDO };
  2217. extern int cbuf1();
  2218. X    CMDFUNC f_cbuf1 = { cbuf1,    REDO };
  2219. extern int cbuf2();
  2220. X    CMDFUNC f_cbuf2 = { cbuf2,    REDO };
  2221. extern int cbuf3();
  2222. X    CMDFUNC f_cbuf3 = { cbuf3,    REDO };
  2223. extern int cbuf4();
  2224. X    CMDFUNC f_cbuf4 = { cbuf4,    REDO };
  2225. extern int cbuf5();
  2226. X    CMDFUNC f_cbuf5 = { cbuf5,    REDO };
  2227. extern int cbuf6();
  2228. X    CMDFUNC f_cbuf6 = { cbuf6,    REDO };
  2229. extern int cbuf7();
  2230. X    CMDFUNC f_cbuf7 = { cbuf7,    REDO };
  2231. extern int cbuf8();
  2232. X    CMDFUNC f_cbuf8 = { cbuf8,    REDO };
  2233. extern int cbuf9();
  2234. X    CMDFUNC f_cbuf9 = { cbuf9,    REDO };
  2235. extern int cbuf10();
  2236. X    CMDFUNC f_cbuf10 = { cbuf10,    REDO };
  2237. #if !SMALLER
  2238. extern int cbuf11();
  2239. X    CMDFUNC f_cbuf11 = { cbuf11,    REDO };
  2240. #endif
  2241. #if !SMALLER
  2242. extern int cbuf12();
  2243. X    CMDFUNC f_cbuf12 = { cbuf12,    REDO };
  2244. #endif
  2245. #if !SMALLER
  2246. extern int cbuf13();
  2247. X    CMDFUNC f_cbuf13 = { cbuf13,    REDO };
  2248. #endif
  2249. #if !SMALLER
  2250. extern int cbuf14();
  2251. X    CMDFUNC f_cbuf14 = { cbuf14,    REDO };
  2252. #endif
  2253. #if !SMALLER
  2254. extern int cbuf15();
  2255. X    CMDFUNC f_cbuf15 = { cbuf15,    REDO };
  2256. #endif
  2257. #if !SMALLER
  2258. extern int cbuf16();
  2259. X    CMDFUNC f_cbuf16 = { cbuf16,    REDO };
  2260. #endif
  2261. #if !SMALLER
  2262. extern int cbuf17();
  2263. X    CMDFUNC f_cbuf17 = { cbuf17,    REDO };
  2264. #endif
  2265. #if !SMALLER
  2266. extern int cbuf18();
  2267. X    CMDFUNC f_cbuf18 = { cbuf18,    REDO };
  2268. #endif
  2269. #if !SMALLER
  2270. extern int cbuf19();
  2271. X    CMDFUNC f_cbuf19 = { cbuf19,    REDO };
  2272. #endif
  2273. #if !SMALLER
  2274. extern int cbuf20();
  2275. X    CMDFUNC f_cbuf20 = { cbuf20,    REDO };
  2276. #endif
  2277. #if !SMALLER
  2278. extern int cbuf21();
  2279. X    CMDFUNC f_cbuf21 = { cbuf21,    REDO };
  2280. #endif
  2281. #if !SMALLER
  2282. extern int cbuf22();
  2283. X    CMDFUNC f_cbuf22 = { cbuf22,    REDO };
  2284. #endif
  2285. #if !SMALLER
  2286. extern int cbuf23();
  2287. X    CMDFUNC f_cbuf23 = { cbuf23,    REDO };
  2288. #endif
  2289. #if !SMALLER
  2290. extern int cbuf24();
  2291. X    CMDFUNC f_cbuf24 = { cbuf24,    REDO };
  2292. #endif
  2293. #if !SMALLER
  2294. extern int cbuf25();
  2295. X    CMDFUNC f_cbuf25 = { cbuf25,    REDO };
  2296. #endif
  2297. #if !SMALLER
  2298. extern int cbuf26();
  2299. X    CMDFUNC f_cbuf26 = { cbuf26,    REDO };
  2300. #endif
  2301. #if !SMALLER
  2302. extern int cbuf27();
  2303. X    CMDFUNC f_cbuf27 = { cbuf27,    REDO };
  2304. #endif
  2305. #if !SMALLER
  2306. extern int cbuf28();
  2307. X    CMDFUNC f_cbuf28 = { cbuf28,    REDO };
  2308. #endif
  2309. #if !SMALLER
  2310. extern int cbuf29();
  2311. X    CMDFUNC f_cbuf29 = { cbuf29,    REDO };
  2312. #endif
  2313. #if !SMALLER
  2314. extern int cbuf30();
  2315. X    CMDFUNC f_cbuf30 = { cbuf30,    REDO };
  2316. #endif
  2317. #if !SMALLER
  2318. extern int cbuf31();
  2319. X    CMDFUNC f_cbuf31 = { cbuf31,    REDO };
  2320. #endif
  2321. #if !SMALLER
  2322. extern int cbuf32();
  2323. X    CMDFUNC f_cbuf32 = { cbuf32,    REDO };
  2324. #endif
  2325. #if !SMALLER
  2326. extern int cbuf33();
  2327. X    CMDFUNC f_cbuf33 = { cbuf33,    REDO };
  2328. #endif
  2329. #if !SMALLER
  2330. extern int cbuf34();
  2331. X    CMDFUNC f_cbuf34 = { cbuf34,    REDO };
  2332. #endif
  2333. #if !SMALLER
  2334. extern int cbuf35();
  2335. X    CMDFUNC f_cbuf35 = { cbuf35,    REDO };
  2336. #endif
  2337. #if !SMALLER
  2338. extern int cbuf36();
  2339. X    CMDFUNC f_cbuf36 = { cbuf36,    REDO };
  2340. #endif
  2341. #if !SMALLER
  2342. extern int cbuf37();
  2343. X    CMDFUNC f_cbuf37 = { cbuf37,    REDO };
  2344. #endif
  2345. #if !SMALLER
  2346. extern int cbuf38();
  2347. X    CMDFUNC f_cbuf38 = { cbuf38,    REDO };
  2348. #endif
  2349. #if !SMALLER
  2350. extern int cbuf39();
  2351. X    CMDFUNC f_cbuf39 = { cbuf39,    REDO };
  2352. SHAR_EOF
  2353. true || echo 'restore of nefunc.h failed'
  2354. echo 'End of Vile part 9'
  2355. echo 'File nefunc.h is continued in part 10'
  2356. echo 10 > _shar_seq_.tmp
  2357. exit 0
  2358. -- 
  2359.         paul fox, pgf@cayman.com, (617)494-1999
  2360.         Cayman Systems, 26 Landsdowne St., Cambridge, MA 02139
  2361.