pgf@cayman.COM (Paul Fox) (06/08/91)
#!/bin/sh # this is vileshar.09 (part 9 of Vile) # do not concatenate these parts, unpack them in order with /bin/sh # file main.c continued # if test ! -r _shar_seq_.tmp; then echo 'Please unpack part 1 first!' exit 1 fi (read Scheck if test "$Scheck" != 9; then echo Please unpack part "$Scheck" next! exit 1 else exit 0 fi ) < _shar_seq_.tmp || exit 1 echo 'x - continuing file main.c' sed 's/^X//' << 'SHAR_EOF' >> 'main.c' && X * X * This file contains the main driving routine, and some keyboard processing X * code, for the screen editor. X * X */ X #include <stdio.h> X /* for MSDOS, increase the default stack space */ X #if MSDOS & LATTICE unsigned _stack = 32767; #endif X #if ATARI & LATTICE & 0 int _mneed = 256000; /* reset memory pool size */ #endif X #if MSDOS & AZTEC int _STKSIZ = 32767/16; /* stack size in paragraphs */ int _STKRED = 1024; /* stack checking limit */ int _HEAPSIZ = 4096/16; /* (in paragraphs) */ int _STKLOW = 0; /* default is stack above heap (small only) */ #endif X #if MSDOS & TURBO unsigned _stklen = 32768; #endif X /* make global definitions not external */ #define maindef X #include "estruct.h" /* global structures and defines */ X #if UNIX #include <signal.h> #endif X #include "nefunc.h" /* function declarations */ #include "nebind.h" /* default key bindings */ #include "nename.h" /* name table */ #include "edef.h" /* global definitions */ X X #if VMS #include <ssdef.h> #define GOOD (SS$_NORMAL) #endif X #ifndef GOOD #define GOOD 0 #endif X main(argc, argv) char *argv[]; { X int c; /* command character */ X int f; /* default flag */ X int n; /* numeric repeat count */ X int s; X register BUFFER *bp; /* temp buffer pointer */ X register int gotafile; /* filename arg present? */ X register int carg; /* current arg to scan */ X register int ranstartup; /* startup executed flag */ X BUFFER *firstbp = NULL; /* ptr to first buffer in cmd line */ X int viewflag; /* are we starting in view mode? */ X int gotoflag; /* do we need to goto a line at start? */ X int helpflag; /* do we need to goto a line at start? */ X int gline; /* if so, what line? */ X int searchflag; /* Do we need to search at start? */ #if TAGS X int tagflag, didtag; /* look up a tag to start? */ X char *tname; #endif X char bname[NBUFN]; /* buffer name of file to read */ X char *msg; #if CRYPT X /* int cryptflag; /* encrypting on the way in? */ X char ekey[NPAT]; /* startup encryption key */ #endif X char *strncpy(); #if UNIX X extern int catchintr(); X extern int imdying(); X extern int sizesignal(); #endif X extern char *pathname[]; /* startup file path/name array */ X X charinit(); /* character types -- we need these pretty X early */ X X viewflag = FALSE; /* view mode defaults off in command line */ X gotoflag = FALSE; /* set to off to begin with */ X helpflag = FALSE; /* set to off to begin with */ X searchflag = FALSE; /* set to off to begin with */ #if TAGS X tagflag = FALSE; /* set to off to begin with */ #endif X gotafile = FALSE; /* no file to edit yet */ X ranstartup = FALSE; /* startup file not executed yet */ #if CRYPT X cryptflag = FALSE; /* no encryption by default */ #endif X X /* Parse the command line */ X for (carg = 1; carg < argc; ++carg) { X X /* Process Switches */ X if (argv[carg][0] == '-') { X switch (argv[carg][1]) { #if NeWS X case 'l': /* -l for screen lines */ X case 'L': X term.t_nrow = atoi(&argv[carg][2]); X break; #endif X case 'e': /* -e for Edit file */ X case 'E': X viewflag = FALSE; X break; X case 'g': /* -g for initial goto */ X case 'G': X gotoflag = TRUE; X if (argv[carg][2]) { X gline = atoi(&argv[carg][2]); X } else { X if (++carg < argc) X gline = atoi(&argv[carg][0]); X else X goto usage; X } X break; X case 'h': /* -h for initial help */ X case 'H': X helpflag = TRUE; X break; #if CRYPT X case 'k': /* -k<key> for code key */ X case 'K': X cryptflag = TRUE; X if (argv[carg][2]) { X strcpy(ekey, &argv[carg][2]); X } else { X if (++carg < argc) X strcpy(ekey, &argv[carg][0]); X else X goto usage; X } X break; #endif X case 's': /* -s for initial search string */ X case 'S': X searchflag = TRUE; X if (argv[carg][2]) { X strncpy(pat,&argv[carg][2],NPAT); X } else { X if (++carg < argc) X strncpy(pat,&argv[carg][0],NPAT); X else X goto usage; X } X rvstrcpy(tap, pat); X break; #if TAGS X case 't': /* -t for initial tag lookup */ X case 'T': X tagflag = TRUE; X if (argv[carg][2]) { X tname = &argv[carg][2]; X } else { X if (++carg < argc) X tname = &argv[carg][0]; X else X goto usage; X } X break; #endif X case 'v': /* -v for View File */ X case 'V': X viewflag = TRUE; X break; X default: /* unknown switch */ X usage: X fprintf(stderr, X "usage: %s -flags files...\n%s%s%s%s%s%s",argv[0], X " -h to get help on startup\n", X " -gNNN or simply +NNN to go to line NNN\n", X " -sstring to search for string\n", #if TAGS X " -ttagname to look up a tag\n", #else X "", #endif X " -v to view files as read-only\n", #if CRYPT X " -kcryptkey for encrypted files\n" #else X "" #endif X ); X exit(1); X } X X } else if (argv[carg][0]== '+') { /* alternate form of -g */ X gotoflag = TRUE; X gline = atoi(&argv[carg][1]); X } else if (argv[carg][0]== '@') { X /* Process Startup macroes */ X if (startup(&argv[carg][1]) == TRUE) X ranstartup = TRUE; /* don't execute .vilerc */ X } else { X X /* Process an input file */ X X /* set up a buffer for this file */ X makename(bname, argv[carg]); X unqname(bname,FALSE); X X bp = bfind(bname, OK_CREAT, 0); X make_current(bp); /* pull it to the front */ X strcpy(bp->b_fname, argv[carg]); X if (!gotafile) { X firstbp = bp; X gotafile = TRUE; X } X X /* set the modes appropriatly */ X if (viewflag) X bp->b_mode |= MDVIEW; #if CRYPT X if (cryptflag) { X bp->b_mode |= MDCRYPT; X crypt((char *)NULL, 0); X crypt(ekey, strlen(ekey)); X strncpy(bp->b_key, ekey, NPAT); X } #endif X } X } X X /* initialize the editor */ #if UNIX X signal(SIGHUP,imdying); X signal(SIGINT,catchintr); X signal(SIGBUS,imdying); X signal(SIGSEGV,imdying); X signal(SIGSYS,imdying); X signal(SIGTERM,imdying); X signal(SIGQUIT,imdying); X signal(SIGPIPE,SIG_IGN); #ifdef SIGWINCH X signal(SIGWINCH,sizesignal); #endif #endif X vtinit(); /* Display */ X winit(); /* windows */ X varinit(); /* user variables */ X X /* we made some calls to makecurrent() above, to shuffle the X list order. this set curbp, which isn't actually kosher */ X curbp = NULL; X X /* this comes out to 70 on an 80 column display */ X fillcol = (7 * term.t_ncol) / 8; X if (fillcol > 70) X fillcol = 70; X X /* if invoked with no other startup files, X run the system startup file here */ X if (!ranstartup) { X X /* if .vilerc is one of the input files....don't clobber it */ X if (gotafile && strcmp(pathname[0], firstbp->b_bname) == 0) { X c = firstbp->b_bname[0]; X firstbp->b_bname[0] = '['; X startup(pathname[0]); X firstbp->b_bname[0] = c; X } else { X startup(pathname[0]); X } X ranstartup = TRUE; X } X X /* if there are any files to read, read the first one! */ X if (gotafile) { X nextbuffer(FALSE,0); X } #if TAGS X else if (tagflag) { X tags(tname); X didtag = TRUE; X } #endif X if (!curbp) { X bp = bfind("[unnamed]", OK_CREAT, 0); X bp->b_active = TRUE; X swbuffer(bp); X } X curbp->b_mode |= (gmode & ~(MDCMOD|MDDOS)); X X msg = ""; X if (helpflag) { X if (help(TRUE,1) != TRUE) { X msg = X "[Problem with help information. Type \":quit\" to exit if you wish]"; X } X } else { X msg = "[Use ^A-h, ^X-h, or :help to get help]"; X } X X /* Deal with startup gotos and searches */ X if (gotoflag + searchflag #if TAGS X + tagflag #endif X > 1) { #if TAGS X msg = "[Search, goto and tag are used one at a time]"; #else X msg = "[Cannot search and goto at the same time]"; #endif X } else if (gotoflag) { X if (gotoline(TRUE,gline) == FALSE) X msg = "[Invalid goto argument]"; X } else if (searchflag) { X forwhunt(FALSE, 0); #if TAGS X } else if (tagflag && !didtag) { X tags(tname); #endif X } X X update(FALSE); X mlwrite(msg); X X X /* process commands */ X loop(); X } X loop() { X int s,c,f,n; X while(1) { X /* Vi doesn't let the cursor rest on the newline itself. This X takes care of that. */ X if (curwp->w_doto == llength(curwp->w_dotp) && X llength(curwp->w_dotp) != 0) X backchar(TRUE,1); X X /* same goes for end of file */ X if (curwp->w_dotp == curbp->b_linep && X lback(curwp->w_dotp) != curbp->b_linep) X backline(TRUE,1); X X /* start recording for '.' command */ X dotcmdbegin(); X X /* Fix up the screen */ X s = update(FALSE); X X /* get the next command from the keyboard */ X c = kbd_seq(); X X /* if there is something on the command line, clear it */ X if (mpresf != FALSE) { X mlerase(); X if (s != SORTOFTRUE) /* did nothing due to typeahead */ X update(FALSE); X } X X f = FALSE; X n = 1; X X do_num_proc(&c,&f,&n); X do_rept_arg_proc(&c,&f,&n); X X kregflag = 0; X X /* flag the first time through for some commands -- e.g. subst X must know to not prompt for strings again, and pregion X must only restart the p-lines buffer once for each X command. */ X calledbefore = FALSE; X X /* and execute the command */ X execute(kcod2fnc(c), f, n); X X if (bheadp != curbp) X mlwrite("BUG: main: bheadp != curbp, bhead name is %s", X bheadp->b_bname); X X /* stop recording for '.' command */ X dotcmdfinish(); X } } X #if BSD | USG | V7 catchintr() { X interrupted = TRUE; #if USG X signal(SIGINT,catchintr); #endif } #endif X /* do number processing if needed */ do_num_proc(cp,fp,np) int *cp, *fp, *np; { X register int c, f, n; X register int mflag; X X c = *cp; X f = *fp; X n = *np; X X if (iscntrl(c) || (c & (CTLA|CTLX|SPEC))) X return; X if ( isdigit(c) && c != '0' ) { X f = TRUE; /* there is a # arg */ X n = 0; /* start with a zero default */ X mflag = 1; /* current minus flag */ X while (isdigit(c) || (c == '-')) { X if (c == '-') { X /* already hit a minus or digit? */ X if ((mflag == -1) || (n != 0)) X break; X mflag = -1; X } else { X n = n * 10 + (c - '0'); X } X if ((n == 0) && (mflag == -1)) /* lonely - */ X mlwrite("arg:"); X else X mlwrite("arg: %d",n * mflag); X X c = kbd_seq(); /* get the next key */ X } X n = n * mflag; /* figure in the sign */ X } X *cp = c; X *fp = f; X *np = n; } X /* do ^U-style repeat argument processing -- vile binds this to 'K' */ do_rept_arg_proc(cp,fp,np) int *cp, *fp, *np; { X register int c, f, n; X register int mflag; X c = *cp; X f = *fp; X n = *np; X X if (c != reptc) X return; X X f = TRUE; X n = 4; /* with argument of 4 */ X mflag = 0; /* that can be discarded. */ X mlwrite("arg: 4"); X while (isdigit(c=kbd_seq()) || c==reptc || c=='-'){ X if (c == reptc) X if ((n > 0) == ((n*4) > 0)) X n = n*4; X else X n = 1; X /* X * If dash, and start of argument string, set arg. X * to -1. Otherwise, insert it. X */ X else if (c == '-') { X if (mflag) X break; X n = 0; X mflag = -1; X } X /* X * If first digit entered, replace previous argument X * with digit and set sign. Otherwise, append to arg. X */ X else { X if (!mflag) { X n = 0; X mflag = 1; X } X n = 10*n + c - '0'; X } X mlwrite("arg: %d", (mflag >=0) ? n : (n ? -n : -1)); X } X /* X * Make arguments preceded by a minus sign negative and change X * the special argument "^U -" to an effective "^U -1". X */ X if (mflag == -1) { X if (n == 0) X n++; X n = -n; X } X X *cp = c; X *fp = f; X *np = n; } X X /* X * This is the general command execution routine. It takes care of checking X * flags, globals, etc, to be sure we're not doing something dumb. X * Return the status of command. X */ X int execute(execfunc, f, n) CMDFUNC *execfunc; /* ptr to function to execute */ { X register int status, flags; X LINE *odotp; X int odoto; X X if (execfunc == NULL) { X TTbeep(); #if REBIND X mlwrite("[Key not bound]"); /* complain */ #else X mlwrite("[Not a command]"); /* complain */ #endif X return (FALSE); X } X X flags = execfunc->c_flags; X X /* commands following operators can't be redone or undone */ X if ( !doingopcmd) { X /* don't record non-redoable cmds */ X if ((flags & REDO) == 0) X dotcmdstop(); X if (flags & UNDO) { X /* undoable command can't be permitted when read-only */ X if (curbp->b_mode&MDVIEW) X return(rdonly()); X mayneedundo(); X } X } X X /* if motion is absolute, remember where we are */ X if (flags & ABS) { X odotp = curwp->w_dotp; X odoto = curwp->w_doto; X } X X status = (execfunc->c_func)(f, n, NULL, NULL); X if ((flags & GOAL) == 0) { /* goal should not be retained */ X curgoal = -1; X } X if (flags & UNDO) /* verify malloc arena after line changers */ X vverify("main"); X X /* if motion was absolute, and we moved, update the "last dot" mark */ X if ((flags & ABS) && curwp->w_dotp != odotp) { X curwp->w_ldmkp = odotp; X curwp->w_ldmko = odoto; X } X X return (status); } X /* X * Fancy quit command, as implemented by Norm. If the any buffer has X * changed do a write on that buffer and exit, otherwise simply exit. X */ quickexit(f, n) { X register BUFFER *bp; /* scanning pointer to buffers */ X register BUFFER *oldcb; /* original current buffer */ X register int status; X int thiscmd; X int cnt; X X oldcb = curbp; /* save in case we fail */ X X thiscmd = lastcmd; X if (cnt = anycb()) { X mlwrite("Will write %d buffer%c %s ", X cnt, cnt > 1 ? 's':'.', X clexec ? "" : "Repeat command to continue."); X if (!clexec && !isnamedcmd) { X if (thiscmd != kbd_seq()) X return(FALSE); X } X X bp = bheadp; X while (bp != NULL) { X if ((bp->b_flag&BFCHG) != 0 && X (bp->b_flag&BFINVS) == 0) { X make_current(bp); X mlwrite("[Saving %s]",bp->b_fname); X mlwrite("\n"); X if ((status = filesave(f, n)) != TRUE) { X make_current(oldcb); X return(status); X } X mlwrite("\n"); X } X bp = bp->b_bufp; /* on to the next buffer */ X } X } else if (!clexec && !isnamedcmd) { X if (thiscmd != kbd_seq()) X return(FALSE); X } X quithard(f, n); /* conditionally quit */ X return(TRUE); } X /* Force quit by giving argument */ quithard(f,n) { X quit(TRUE,1); } X /* X * Quit command. If an argument, always quit. Otherwise confirm if a buffer X * has been changed and not written out. X */ quit(f, n) { X int cnt; X X if (f != FALSE || (cnt = anycb()) == 0) { X vttidy(TRUE); #if FILOCK X if (lockrel() != TRUE) { X exit(1); X } #endif X exit(GOOD); X } X if (cnt == 1) X mlwrite( X "There is an unwritten modified buffer. Write it, or use :q!"); X else X mlwrite( X "There are %d unwritten modified buffers. Write them, or use :q!", X cnt); X return (FALSE); } X writequit(f,n) { X int s; X s = filesave(FALSE,n); X if (s != TRUE) X return s; X return(quit(FALSE,n)); } X /* X * Begin recording a dot command macro. X * Set up variables and return. X */ dotcmdbegin() { X switch (dotcmdmode) { X case TMPSTOP: X case PLAY: X return(FALSE); X } X tmpcmdptr = &tmpcmdm[0]; X tmpcmdend = tmpcmdptr; X dotcmdmode = RECORD; X return (TRUE); } X /* X * End dot command X */ dotcmdfinish() { X X switch (dotcmdmode) { X case STOP: X case PLAY: X case TMPSTOP: X return(FALSE); X X case RECORD: X ; X } X tmpcmdptr = &tmpcmdm[0]; X dotcmdptr = &dotcmdm[0]; X while (tmpcmdptr < tmpcmdend) X *dotcmdptr++ = *tmpcmdptr++; X dotcmdend = dotcmdptr; X dotcmdptr = &dotcmdm[0]; X tmpcmdptr = tmpcmdptr = &tmpcmdm[0]; X /* leave us in RECORD mode */ X return(TRUE); } X dotcmdstop() { X if (dotcmdmode == RECORD) { X dotcmdmode = STOP; X } } X /* X * Execute a macro. X * The command argument is the number of times to loop. Quit as soon as a X * command gets an error. Return TRUE if all ok, else FALSE. X */ dotcmdplay(f, n) { X if (n <= 0) X return (TRUE); X dotcmdrep = n; /* remember how many times to execute */ X dotcmdmode = PLAY; /* put us in play mode */ X dotcmdptr = &dotcmdm[0]; /* at the beginning */ X X return(TRUE); } /* X * Begin a keyboard macro. X * Error if not at the top level in keyboard processing. Set up variables and X * return. X */ ctlxlp(f, n) { X if (kbdmode != STOP) { X mlwrite("%%Macro already active"); X return(FALSE); X } X mlwrite("[Start macro]"); X kbdptr = &kbdm[0]; X kbdend = kbdptr; X kbdmode = RECORD; X return (TRUE); } X /* X * End keyboard macro. Check for the same limit conditions as the above X * routine. Set up the variables and return to the caller. X */ ctlxrp(f, n) { X if (kbdmode == STOP) { X mlwrite("%%Macro not active"); X return(FALSE); X } X if (kbdmode == RECORD) { X mlwrite("[End macro]"); X kbdmode = STOP; X } X return(TRUE); } X /* X * Execute a macro. X * The command argument is the number of times to loop. Quit as soon as a X * command gets an error. Return TRUE if all ok, else FALSE. X */ ctlxe(f, n) { X if (kbdmode != STOP) { X mlwrite("%%Macro already active"); X return(FALSE); X } X if (n <= 0) X return (TRUE); X kbdrep = n; /* remember how many times to execute */ X kbdmode = PLAY; /* start us in play mode */ X kbdptr = &kbdm[0]; /* at the beginning */ X return(TRUE); } X /* X * Abort. X * Beep the beeper. Kill off any keyboard macro, etc., that is in progress. X * Sometimes called as a routine, to do general aborting of stuff. X */ esc(f, n) { X TTbeep(); X kbdmode = STOP; X dotcmdmode = STOP; X fulllineregions = FALSE; X doingopcmd = FALSE; X opcmd = 0; X mlwrite("[Aborted]"); X return(ABORT); } X /* tell the user that this command is illegal while we are in X VIEW (read-only) mode */ X rdonly() { X TTbeep(); X mlwrite("[No changes are allowed while in \"view\" mode]"); X return FALSE; } X showversion(f,n) { X mlwrite(version); X return TRUE; } X unimpl() { X TTbeep(); X mlwrite("[Sorry, that vi command is unimplemented in vile ]"); X return FALSE; } X opercopy() { return unimpl(); } opermove() { return unimpl(); } opertransf() { return unimpl(); } X operglobals() { return unimpl(); } opervglobals() { return unimpl(); } X map() { return unimpl(); } unmap() { return unimpl(); } X source() { return unimpl(); } X subst_again() { return unimpl(); } X visual() { return unimpl(); } ex() { return unimpl(); } X nullproc() /* user function that does (almost) NOTHING */ { X return TRUE; } X cntl_af() /* dummy function for binding to control-a prefix */ { } X cntl_xf() /* dummy function for binding to control-x prefix */ { } X unarg() /* dummy function for binding to universal-argument */ { } X /* initialize our version of the "chartypes" stuff normally in ctypes.h */ charinit() { X register int c; X X /* legal in pathnames */ X _chartypes_['.'] = X _chartypes_['_'] = X _chartypes_['-'] = X _chartypes_['*'] = X _chartypes_['/'] = _path; X X /* legal in "identifiers" */ X _chartypes_['_'] |= _ident; X X /* whitespace */ X _chartypes_[' '] = X _chartypes_['\t'] = X _chartypes_['\r'] = X _chartypes_['\n'] = X _chartypes_['\f'] = _space; X X /* control characters */ X for (c = 0; c < ' '; c++) X _chartypes_[c] |= _cntrl; X _chartypes_[127] |= _cntrl; X X /* lowercase */ X for (c = 'a'; c <= 'z'; c++) X _chartypes_[c] |= _lower|_path|_ident; X X /* uppercase */ X for (c = 'A'; c <= 'Z'; c++) X _chartypes_[c] |= _upper|_path|_ident; X X /* digits */ X for (c = '0'; c <= '9'; c++) X _chartypes_[c] |= _digit|_path|_ident|_linespec; X X /* punctuation */ X for (c = '!'; c <= '/'; c++) X _chartypes_[c] |= _punct; X for (c = ':'; c <= '@'; c++) X _chartypes_[c] |= _punct; X for (c = '['; c <= '`'; c++) X _chartypes_[c] |= _punct; X for (c = '{'; c <= '~'; c++) X _chartypes_[c] |= _punct; X X /* printable */ X for (c = ' '; c <= '~'; c++) X _chartypes_[c] |= _print; X X /* backspacers: ^H, rubout, and the user's backspace char */ X /* we'll add the user's char later */ X _chartypes_['\b'] |= _bspace; X _chartypes_[127] |= _bspace; X X /* wildcard chars for most shells */ X _chartypes_['*'] |= _wild; X _chartypes_['?'] |= _wild; X _chartypes_['~'] |= _wild; X _chartypes_['['] |= _wild; X _chartypes_[']'] |= _wild; X _chartypes_['$'] |= _wild; X _chartypes_['{'] |= _wild; X _chartypes_['}'] |= _wild; X X /* ex mode line specifiers */ X _chartypes_[','] |= _linespec; X _chartypes_['%'] |= _linespec; X _chartypes_['-'] |= _linespec; X _chartypes_['+'] |= _linespec; X _chartypes_['.'] |= _linespec; X _chartypes_['$'] |= _linespec; X _chartypes_['\''] |= _linespec; X } X X /***** Compiler specific Library functions ****/ X #if MWC86 & MSDOS movmem(source, dest, size) char *source; /* mem location to move memory from */ char *dest; /* memory location to move text to */ int size; /* number of bytes to move */ { X register int i; X X for (i=0; i < size; i++) X *dest++ = *source++; } #endif X #if (AZTEC | MSC | TURBO | LATTICE) & MSDOS /* strncpy: copy a string...with length restrictions X ALWAYS null terminate Hmmmm... I don't know much about DOS, but I do know that strncpy shouldn't ALWAYS X null terminate. -pgf */ X char *strncpy(dst, src, maxlen) char *dst; /* destination of copied string */ char *src; /* source */ int maxlen; /* maximum length */ { X char *dptr; /* ptr into dst */ X X dptr = dst; X while (*src && (maxlen-- > 0)) X *dptr++ = *src++; X *dptr = 0; X return(dst); } #endif X #if RAMSIZE & LATTICE & MSDOS /* These routines will allow me to track memory usage by placing X a layer on top of the standard system malloc() and free() calls. X with this code defined, the environment variable, $RAM, will X report on the number of bytes allocated via malloc. X X with SHOWRAM defined, the number is also posted on the X end of the bottom mode line and is updated whenever it is changed. */ X #undef malloc #undef free X char *allocate(nbytes) /* allocate nbytes and track */ unsigned nbytes; /* # of bytes to allocate */ { X char *mp; /* ptr returned from malloc */ X X mp = malloc(nbytes); X if (mp) { X envram += nbytes; #if RAMSHOW X dspram(); #endif X } X X return(mp); } X release(mp) /* release malloced memory and track */ char *mp; /* chunk of RAM to release */ { X unsigned *lp; /* ptr to the long containing the block size */ X X if (mp) { X lp = ((unsigned *)mp) - 1; X X /* update amount of ram currently malloced */ X envram -= (long)*lp - 2; X free(mp); #if RAMSHOW X dspram(); #endif X } } X #if RAMSHOW dspram() /* display the amount of RAM currently malloced */ { X char mbuf[20]; X char *sp; X X TTmove(term.t_nrow - 1, 70); #if COLOR X TTforg(7); X TTbacg(0); #endif X sprintf(mbuf, "[%lu]", envram); X sp = &mbuf[0]; X while (*sp) X TTputc(*sp++); X TTmove(term.t_nrow, 0); X movecursor(term.t_nrow, 0); } #endif #endif SHAR_EOF echo 'File main.c is complete' && chmod 0444 main.c || echo 'restore of main.c failed' Wc_c="`wc -c < 'main.c'`" test 23507 -eq "$Wc_c" || echo 'main.c: original size 23507, current size' "$Wc_c" # ============= make.ini ============== echo 'x - extracting make.ini (Text)' sed 's/^X//' << 'SHAR_EOF' > 'make.ini' && CP = copy # what 'cp' to use. RM = del # what 'rm' to use. MV = ren # What 'mv' to use. LINKER = \usr\lib\bin\tlink.exe # What link to use. CC = tcc # What C compiler I am using. X INCLUDE = \usr\lib\tinclude # Where to find header files. .h LIB = \usr\lib\tlib # Where to find the libary files. .lib MAPFILE = \dev\nul # Where to put the link map file. X # switches for TurboC.... MODEL = l # t)iny s)mall c)ompact m)edium l)arge h)uge MDL = $(MODEL) # The masm model. CPU = 1 # 0=8088 1=186/286 MATH = f # f87=8087 f=emulate f-=no floating MATHLIB = emu # emu, f87, or nothing TYPE = G # G=speed O=size SWITCHES= -I$(INCLUDE) -L$(LIB) -m$(MODEL) -$(CPU) -$(MATH) \ X -$(TYPE) CFLAGS = $(SWITCHES) X # Print the `make -h' message .HELP X # The order to search for rules and files is specified by .SUFFIXES .SUFFIXES: .exe .obj .c .for .asm X # DEFAULT RULES .asm.obj: X masm $*.asm; X .c.obj: X $(CC) $(CFLAGS) -c $*.c X .for.obj: X for1 $*.for; X pas2 X .obj.exe: X $(CP) $(LINKER) .\link.exe X link $(LIB)\c0$(MODEL) $(OBJS), $@, $(MAPFILE), \ X $(LIB)\$(MATHLIB) $(LIB)\math$(MODEL) $(LIB)\c$(MODEL) X $(RM) .\link.exe X $(CP) $(PROGRAM) $(DEST) X # .obj.exe: # link $*.obj, $@, $(MAPFILE), $(LIBS) X .asm.exe: X masm $*.asm; X link $*.obj, $@, $(MAPFILE), $(LIBS) X $(RM) $*.obj X .c.exe: X $(CC) $(CFLAGS) -c $*.c X link $*.obj, $@; X $(RM) $*.obj X .for.exe: X for1 $*.for; X pas2 X link $*.obj, $@, $(MAPFILE), $(LIB)\FORTRAN.LIB SHAR_EOF chmod 0444 make.ini || echo 'restore of make.ini failed' Wc_c="`wc -c < 'make.ini'`" test 1438 -eq "$Wc_c" || echo 'make.ini: original size 1438, current size' "$Wc_c" # ============= makefile ============== echo 'x - extracting makefile (Text)' sed 's/^X//' << 'SHAR_EOF' > 'makefile' && # # makefile for vile. # The defs for what system this is really running on are in estruct.h. # Be sure to edit that, to define your system. # The command/name/key/function bindings are defined in the file "cmdtbl". The # mktbls program parses this to produce nebind.h, nename.h, and nefunc.h, # which are used by the rest of the build. # # The version number (currently three) is found near the top of # edef.h, and is displayed with the '*' and ":version" commands. # Paul Fox # # original makefile for uemacs: Adam Fritz July 30,1987 X X # To change screen driver modules, change SCREEN below, and edit estruct.h to # make sure the correct one is #defined as "1", and the others all as "0" #SCREEN = at386 # if you use tcap.c, you'll need libtermcap.a too. SCREEN = tcap X TARGET = vile X #DESTDIR = $(HOME)/bin DESTDIR = /usr/local/bin LIBS = -ltermcap X REMOTE=towno!pgf X #CFLAGS = -O CFLAGS = -g #CFLAGS = -g -systype sysv # for the mips machine CC=cc X X # All of the makefiles which should be preserved MAKEFILES = makefile make.ini HEADER_BUILDER = ./mktbls X ALLTOOLS = $(MAKEFILES) X # this stuff lives in the shorten subdirectory. It was lifted from the # GNU emacs distribution. See the file COPYING for more info. SHORTSTUFF = shorten/COPYING \ X shorten/names.c \ X shorten/dups.c \ X shorten/defines.c \ X shorten/header.h \ X shorten/reserved \ X shorten/special X # these are normal editable headers HDRS = estruct.h epath.h evar.h edef.h X # these headers are built by the mktbls program from the information # in cmdtbl, but are backed up and # distributed anyway, in case you can't get mktbls running BUILTHDRS = nebind.h nefunc.h nename.h X # this is obsolete stuff NOT needed by the build, but it shouldn't # be thrown away (yet). For instance, ebind.h has per-machine binding # information that hasn't been incorporated into cmdtbl yet. OLDHDRS = ebind.h efunc.h X ALLHDRS = $(HDRS) $(BUILTHDRS) $(OLDHDRS) X # All the C files which should be saved # (including tools, like mktbls.c, unused screen drivers, etc.) CSRCac = ansi.c at386.c basic.c bind.c buffer.c crypt.c csrch.c CSRCde = dg10.c display.c dolock.c eval.c exec.c CSRCfh = file.c fileio.c finderr.c globals.c hp110.c hp150.c CSRCim = ibmpc.c input.c isearch.c line.c lock.c main.c mktbls.c CSRCnr = news.c npopen.c opers.c oneliner.c random.c region.c CSRCst = search.c spawn.c st520.c tags.c tcap.c termio.c tipc.c CSRCuz = undo.c vmalloc.c vmsvt.c vt52.c window.c word.c wordmov.c z309.c X CSRC = $(CSRCac) $(CSRCde) $(CSRCfh) $(CSRCim) $(CSRCnr) \ X $(CSRCst) $(CSRCuz) X # non-C source code OTHERSRC = z100bios.asm news.cps X # text and data files TEXTFILES = README cmdtbl vile.hlp tags buglist readme.news X ALLSRC = $(CSRC) $(OTHERSRC) X EVERYTHING = $(ALLTOOLS) $(ALLHDRS) $(ALLSRC) $(TEXTFILES) $(SHORTSTUFF) X SRC = npopen.c finderr.c main.c buffer.c $(SCREEN).c termio.c display.c \ X word.c wordmov.c window.c spawn.c \ X region.c search.c random.c isearch.c lock.c line.c \ X input.c fileio.c exec.c file.c eval.c \ X dolock.c crypt.c bind.c basic.c opers.c undo.c csrch.c tags.c \ X vmalloc.c globals.c oneliner.c X OBJ = npopen.o finderr.o main.o buffer.o $(SCREEN).o termio.o display.o \ X word.o wordmov.o window.o spawn.o \ X region.o search.o random.o isearch.o lock.o line.o \ X input.o fileio.o exec.o file.o eval.o \ X dolock.o crypt.o bind.o basic.o opers.o undo.o csrch.o tags.o \ X vmalloc.o globals.o oneliner.o X all: $(TARGET) X $(TARGET) : $(BUILTHDRS) $(OBJ) makefile X -mv $(TARGET) o$(TARGET) X $(CC) $(CFLAGS) -o $(TARGET) $(OBJ) $(LIBS) X $(BUILTHDRS): cmdtbl $(HEADER_BUILDER) X $(HEADER_BUILDER) cmdtbl X install : $(TARGET) X cp $(TARGET) $(DESTDIR) X test -f vile.hlp && /bin/rm -f $(DESTDIR)/vile.hlp X cp vile.hlp $(DESTDIR) X chmod 0644 $(DESTDIR)/vile.hlp X compr-shar: X [ -d cshardir ] || mkdir cshardir # add -a for archive headers, add -s pgf@cayman.com for submitted-by X shar -p -nvile -L55 -o cshardir/vileshar \ X -T README -C `ls $(EVERYTHING) | sed /README/d` X shar: X [ -d shardir ] || mkdir shardir # add -a for archive headers, add -s pgf@cayman.com for submitted-by X shar -x -a -spgf@cayman.com -nVile -L55 \ X -o shardir/vileshar `ls $(EVERYTHING)` X # only uucp things changed since last time uuto: X uuto `ls -t $(EVERYTHING) uutodone | sed '/uutodone/q'` $(REMOTE) X date >uutodone X floppy: X ls $(EVERYTHING) | oo X # you don't want to know... dosscript: X ( \ X echo echo on ;\ X for x in `ls -t $(EVERYTHING) dosback.bat | sed '/dosback.bat/q'` ;\ X do \ X echo copy o:$$x a: ;\ X done ;\ X echo quit ;\ X ) >tmp.bat X ud < tmp.bat >dosback.bat X /bin/rm -f tmp.bat X #-dos X #>dosback.bat X newdosfloppy: X touch 0101010170 dosback.bat X # dump a list of the important files list: X @ls $(EVERYTHING) | more X # dump a list of files that may have changed since last backup rw list-writeable: X @for x in $(EVERYTHING) ;\ X do \ X if [ -w $$x ] ;\ X then \ X echo $$x ;\ X fi \ X done X no-write: X chmod -w $(EVERYTHING) X tags: X dotags $(SRC) $(HDRS) X lint: $(SRC) X lint -hbvxac $(SRC) >lint.out X clean: X rm -f *.o o$(TARGET) $(BUILTHDRS) $(HEADER_BUILDER) news.h core *~ *.BAK X clobber: clean X rm -f $(TARGET) X news.h: news.cps X cps news.cps X print: X pr makefile $(HDRS) $(SRC) | lpr X depend: $(SRC) $(HDRS) $(BUILTHDRS) X mv -f makefile makefile.orig X (sed -e '/^#DEPENDS/,$$d' makefile.orig ; \ X echo "#DEPENDS" ; \ X $(CC) -M $(CFLAGS) $? ) > makefile X # you need this if SHORTNAMES is 0 in estruct.h # estruct.h: shorten/remap.h X # or this either shorten/remap.h: X cd shorten; $(MAKE) remap.h X #DEPENDS news.o: news.c news.o: /usr/include/stdio.h news.o: ./estruct.h news.o: ./edef.h news.o: ./news.h word.o: word.c word.o: /usr/include/stdio.h word.o: ./estruct.h word.o: ./edef.h vmsvt.o: vmsvt.c vmsvt.o: /usr/include/stdio.h vmsvt.o: ./estruct.h vmsvt.o: ./edef.h window.o: window.c window.o: /usr/include/stdio.h window.o: ./estruct.h window.o: ./edef.h vt52.o: vt52.c vt52.o: /usr/include/stdio.h vt52.o: ./estruct.h vt52.o: ./edef.h tipc.o: tipc.c tipc.o: /usr/include/stdio.h tipc.o: ./estruct.h tipc.o: ./edef.h tcap.o: tcap.c tcap.o: /usr/include/stdio.h tcap.o: ./estruct.h tcap.o: ./edef.h termio.o: termio.c termio.o: /usr/include/stdio.h termio.o: ./estruct.h termio.o: ./edef.h termio.o: /usr/include/sgtty.h termio.o: /usr/include/sys/ioctl.h #termio.o: /usr/include/sys/ttychars.h #termio.o: /usr/include/sys/ttydev.h termio.o: /usr/include/signal.h termio.o: /usr/include/sys/ioctl.h spawn.o: spawn.c spawn.o: /usr/include/stdio.h spawn.o: ./estruct.h spawn.o: ./edef.h spawn.o: /usr/include/signal.h st520.o: st520.c st520.o: /usr/include/stdio.h st520.o: ./estruct.h st520.o: ./edef.h region.o: region.c region.o: /usr/include/stdio.h region.o: ./estruct.h region.o: ./edef.h search.o: search.c search.o: /usr/include/stdio.h search.o: ./estruct.h search.o: ./edef.h main.o: main.c main.o: /usr/include/stdio.h main.o: ./estruct.h main.o: ./nefunc.h main.o: ./edef.h main.o: ./nebind.h main.o: ./nename.h random.o: random.c random.o: /usr/include/stdio.h random.o: ./estruct.h random.o: ./edef.h isearch.o: isearch.c isearch.o: /usr/include/stdio.h isearch.o: ./estruct.h isearch.o: ./edef.h lock.o: lock.c lock.o: /usr/include/stdio.h lock.o: ./estruct.h lock.o: ./edef.h lock.o: /usr/include/sys/errno.h line.o: line.c line.o: /usr/include/stdio.h line.o: ./estruct.h line.o: ./edef.h ibmpc.o: ibmpc.c ibmpc.o: /usr/include/stdio.h ibmpc.o: ./estruct.h ibmpc.o: ./edef.h input.o: input.c input.o: /usr/include/stdio.h input.o: ./estruct.h input.o: ./edef.h hp110.o: hp110.c hp110.o: /usr/include/stdio.h hp110.o: ./estruct.h hp110.o: ./edef.h hp150.o: hp150.c hp150.o: /usr/include/stdio.h hp150.o: ./estruct.h hp150.o: ./edef.h fileio.o: fileio.c fileio.o: /usr/include/stdio.h fileio.o: ./estruct.h fileio.o: ./edef.h exec.o: exec.c exec.o: /usr/include/stdio.h exec.o: ./estruct.h exec.o: ./edef.h file.o: file.c file.o: /usr/include/stdio.h file.o: ./estruct.h file.o: ./edef.h eval.o: eval.c eval.o: /usr/include/stdio.h eval.o: ./estruct.h eval.o: ./edef.h eval.o: ./evar.h display.o: display.c display.o: /usr/include/stdio.h display.o: ./estruct.h display.o: ./edef.h dolock.o: dolock.c buffer.o: buffer.c buffer.o: /usr/include/stdio.h buffer.o: ./estruct.h buffer.o: ./edef.h crypt.o: crypt.c crypt.o: /usr/include/stdio.h crypt.o: ./estruct.h crypt.o: ./edef.h dg10.o: dg10.c dg10.o: /usr/include/stdio.h dg10.o: ./estruct.h dg10.o: ./edef.h bind.o: bind.c bind.o: /usr/include/stdio.h bind.o: ./estruct.h bind.o: ./edef.h bind.o: ./epath.h basic.o: basic.c basic.o: /usr/include/stdio.h basic.o: ./estruct.h basic.o: ./edef.h ansi.o: ansi.c ansi.o: /usr/include/stdio.h ansi.o: ./estruct.h ansi.o: ./edef.h opers.o: opers.c opers.o: ./estruct.h opers.o: ./edef.h wordmov.o: wordmov.c wordmov.o: ./estruct.h wordmov.o: ./edef.h csrch.o: csrch.c csrch.o: ./estruct.h csrch.o: ./edef.h undo.o: undo.c undo.o: ./estruct.h undo.o: ./edef.h tags.o: tags.c tags.o: ./estruct.h tags.o: ./edef.h finderr.o: finderr.c finderr.o: ./estruct.h finderr.o: ./edef.h at386.o: at386.c at386.o: /usr/include/stdio.h at386.o: ./estruct.h at386.o: ./edef.h npopen.o: npopen.c npopen.o: ./estruct.h npopen.o: ./edef.h oneliner.o: oneliner.c oneliner.o: ./estruct.h oneliner.o: ./edef.h globals.o: globals.c globals.o: ./estruct.h globals.o: ./edef.h SHAR_EOF chmod 0444 makefile || echo 'restore of makefile failed' Wc_c="`wc -c < 'makefile'`" test 9302 -eq "$Wc_c" || echo 'makefile: original size 9302, current size' "$Wc_c" # ============= mktbls.c ============== echo 'x - extracting mktbls.c (Text)' sed 's/^X//' << 'SHAR_EOF' > 'mktbls.c' && #include <stdio.h> X /* This standalone utility program constructs the function, key and command X binding tables for vile. The input is a data file containing the X desired default relationships among the three entities. Output X is nebind.h, nefunc.h, and nename.h, all of which are then included X in main.c X This code written by Paul Fox, (c)1990 X X See the file "cmdtbls" for input data formats, and "estruct.h" for X the output structures. X */ X char *progcreat = "/* %s: this header file was produced automatically by\n\ X * the %s program, based on input from the file %s\n */\n"; X #define DIFCNTRL 0x40 #define tocntrl(c) ((c)^DIFCNTRL) #define toalpha(c) ((c)^DIFCNTRL) #define DIFCASE 0x20 #define toupper(c) ((c)^DIFCASE) #define tolower(c) ((c)^DIFCASE) X int l = 0; FILE *nebind, *nefunc, *nename, *cmdtbl; X char *malloc(); char *formcond(); X struct stringl { X char *s1; X char *s2; X char *s3; X struct stringl *nst; }; X main(argc, argv) char *argv[]; { X char line[100]; X char func[50]; X char flags[50]; X char english[50]; X char fcond[50]; X char ncond[50]; X char key[50]; X char bcond[50]; X int r; X X if (argc != 2) { X fprintf(stderr, "usage: mktbls cmd-file\n"); X exit(1); X } X X if ((cmdtbl = fopen(argv[1],"r")) == NULL ) { X fprintf(stderr,"mktbls: couldn't open cmd-file\n"); X exit(1); X } X X if ( (nebind = fopen("nebind.h","w")) == NULL || X (nefunc = fopen("nefunc.h","w")) == NULL || X (nename = fopen("nename.h","w")) == NULL ) { X fprintf(stderr,"mktbls: couldn't open header files\n"); X exit(1); X } X X fprintf(nebind,progcreat,"nebind.h",argv[0],argv[1]); X fprintf(nefunc,progcreat,"nefunc.h",argv[0],argv[1]); X fprintf(nename,progcreat,"nename.h",argv[0],argv[1]); X X X /* process each input line */ X while (fgets(line,100,cmdtbl) != NULL) { X l++; X if (line[0] == '#') { /* comment */ X continue; X } else if (line[0] == '\n') { /* empty line */ X continue; X } else if (line[0] != '\t') { /* then it's a new func */ X /* we can spill information about funcs right away */ X r = sscanf(line,"%s %s %s",func,flags,fcond); X if (r < 2 || r > 3) X badfmt("looking for new function"); X if (r != 3) X fcond[0] = '\0'; X X if (fcond[0]) X fprintf(nefunc,"#if %s\n",fcond); X fprintf(nefunc,"extern int %s();\n", func); X fprintf(nefunc,"\tCMDFUNC f_%s = { %s,\t%s };\n", X func, func, flags); X if (fcond[0]) X fprintf(nefunc,"#endif\n"); X X } else if (line[1] == '"') { /* then it's an english name */ X X r = sscanf(line, " \"%[^\"]\" %s", english,ncond); X if (r < 1 || r > 2) X badfmt("looking for english name"); X if (r != 2) X ncond[0] = '\0'; X X savenames(english, func, formcond(fcond,ncond)); X X } else if (line[1] == '\'') { /* then it's a key */ X r = sscanf(&line[2], "%[^']' %s", key, ncond); X if (r < 1 || r > 2) X badfmt("looking for key binding"); X if (r != 2) X ncond[0] = '\0'; X X savebindings(key, func, formcond(fcond,ncond)); X X } else { X badfmt("bad line"); X } X } X X dumpnames(); X dumpbindings(); X X exit(0); } X char * formcond(c1,c2) char *c1, *c2; { X static char cond[50]; X if (c1[0] && c2[0]) X sprintf(cond,"#if (%s) & (%s)\n",c1,c2); X else if (c1[0] || c2[0]) X sprintf(cond,"#if (%s%s)\n",c1,c2); X else X cond[0] = '\0'; X return cond; } X badfmt(s) { X fprintf(stderr,"\"cmdtbl\", line %d: bad format:",l); X fprintf(stderr," %s\n",s); X exit(1); } X #define ASCIIBIND 0 #define CTLXBIND 1 #define CTLABIND 2 #define SPECBIND 3 char *bindings[4][128]; char *conditions[4][128]; char *tblname[] = {"asciitbl", "ctlxtbl", "metatbl", "spectbl" }; char *prefname[] = {"", "CTLX|", "CTLA|", "SPEC|" }; X /* prc2kcod: translate printable code to C-language keycode */ savebindings(s,func,cond) char *s, *func, *cond; { X int btype, c; X X btype = ASCIIBIND; X X if (*s == '^' && *(s+1) == 'A'&& *(s+2) == '-') { X btype = CTLABIND; X s += 3; X } else if (*s == 'F' && *(s+1) == 'N' && *(s+2) == '-') { X btype = SPECBIND; X s += 3; X } else if (*s == '^' && *(s+1) == 'X'&& *(s+2) == '-') { X btype = CTLXBIND; X s += 3; X } X X if (*s == '\\') { /* try for an octal value */ X c = 0; X while (*++s < '8' && *s >= '0') c = (c*8) + *s - '0'; X if (c > 127) X badfmt("octal character"); X if (bindings[btype][c] != NULL) X badfmt("duplicate key binding"); X bindings[btype][c] = malloc(strlen(func)+1); X strcpy(bindings[btype][c], func); X } else if (*s == '^' && (c = *(s+1)) != '\0') { /* a control char? */ X if (c > 'a' && c < 'z') X c = toupper(c); X c = tocntrl(c); X if (bindings[btype][c] != NULL) X badfmt("duplicate key binding"); X bindings[btype][c] = malloc(strlen(func)+1); X strcpy(bindings[btype][c], func); X s += 2; X } else if (c = *s) { X if (bindings[btype][c] != NULL) X badfmt("duplicate key binding"); X bindings[btype][c] = malloc(strlen(func)+1); X strcpy(bindings[btype][c], func); X s++; X } else { X badfmt("getting binding"); X } X if (cond[0]) { X conditions[btype][c] = malloc(strlen(cond)+1); X strcpy(conditions[btype][c], cond); X } else { X conditions[btype][c] = NULL; X } X X if (*s != '\0') X badfmt("got extra characters"); X } X dumpbindings() { X char **bindptr; X char *sctl; X int i, c, btype; X X btype = ASCIIBIND; X X fprintf(nebind,"\nCMDFUNC *%s[128] = {\n",tblname[btype]); X for (i = 0; i < 128; i++) { X if (conditions[btype][i]) { X fprintf(nebind,"%s", conditions[btype][i]); X } X if (i < ' ' || i > '~' ) { X sctl = "ctrl-"; X c = toalpha(i); X } else { X sctl = ""; X c = i; X } X X if (bindings[btype][i]) X fprintf(nebind," &f_%s, /* %s%c */\n", X bindings[btype][i], sctl, c); X else X fprintf(nebind," NULL, /* %s%c */\n", sctl, c); X if (conditions[btype][i]) { X fprintf(nebind,"#else\n NULL,\n#endif\n"); X } X X } X fprintf(nebind,"};\n"); X X X fprintf(nebind,"\nKBIND kbindtbl[NBINDS] = {\n"); X for (btype = 1; btype <= 3; btype++) { X for (i = 0; i < 128; i++) { X if (bindings[btype][i]) { X if (conditions[btype][i]) { X fprintf(nebind,"%s", X conditions[btype][i]); X } X if (i < ' ') X fprintf(nebind, X " { %stocntrl('%c'), &f_%s },\n", X prefname[btype], X toalpha(i),bindings[btype][i]); X else X fprintf(nebind, X " { %s'%c', &f_%s },\n", X prefname[btype], X i, bindings[btype][i]); X if (conditions[btype][i]) { X fprintf(nebind,"#endif\n"); X } X } X } X } X fprintf(nebind," { 0, NULL }\n"); X fprintf(nebind,"};\n"); } X struct stringl lastname = {"\177\177\177\177\177\177", "", "", NULL}; struct stringl lnamecond = {"", "", "", NULL}; struct stringl firstname = {"", "", "", &lastname}; struct stringl fnamecond = {"", "", "", &lnamecond}; X savenames(name,func,cond) char *name, *func, *cond; { X char tmpline[80]; X struct stringl *n, *m; X int r; X X n = (struct stringl *)malloc(sizeof (struct stringl)); X X /* strtolower(name); */ X X n->s1 = (char *)malloc(strlen(name)+1); X strcpy(n->s1, name); X X sprintf(tmpline,"\t{ \"%s\",\t&f_%s },\n", X name, func); X n->s2 = (char *)malloc(strlen(func)+1); X strcpy(n->s2, func); X X n->s3 = (char *)malloc(strlen(cond)+1); X strcpy(n->s3, cond); X X for (m = &firstname; m->nst != NULL; m = m->nst) { X if ((r = strcmp(n->s1, m->nst->s1)) < 0) { /* insert it here */ X n->nst = m->nst; X m->nst = n; X break; X } else if (r == 0) { X badfmt("duplicate english name"); X } X } } X dumpnames() { X struct stringl *m; X X fprintf(nename,"\n/* if you maintain this by hand, keep it in */\n"); X fprintf(nename,"/* alphabetical order!!!! */\n\n"); X fprintf(nename,"NTAB nametbl[] = {\n"); X for (m = firstname.nst; m->nst != NULL; m = m->nst) { X if (m->s3[0]) X fprintf(nename,"%s",m->s3); X fprintf(nename,"\t{ \"%s\",\t&f_%s },\n", m->s1, m->s2); X if (m->s3[0]) X fprintf(nename,"#endif\n"); X } X fprintf(nename," { NULL, NULL }\n};\n"); } X strtolower(s) char *s; { X while (*s) { X if (*s >= 'A' && *s <= 'Z') X *s = tolower(*s); X s++; X } } SHAR_EOF chmod 0444 mktbls.c || echo 'restore of mktbls.c failed' Wc_c="`wc -c < 'mktbls.c'`" test 7809 -eq "$Wc_c" || echo 'mktbls.c: original size 7809, current size' "$Wc_c" # ============= nebind.h ============== echo 'x - extracting nebind.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'nebind.h' && /* nebind.h: this header file was produced automatically by X * the ./mktbls program, based on input from the file cmdtbl X */ X CMDFUNC *asciitbl[128] = { X NULL, /* ctrl-@ */ X &f_cntl_af, /* ctrl-A */ X &f_backpage, /* ctrl-B */ X NULL, /* ctrl-C */ X &f_forwhpage, /* ctrl-D */ X &f_mvdnwind, /* ctrl-E */ X &f_forwpage, /* ctrl-F */ X &f_showcpos, /* ctrl-G */ X &f_backchar, /* ctrl-H */ X NULL, /* ctrl-I */ X &f_forwline, /* ctrl-J */ X &f_delwind, /* ctrl-K */ X &f_refresh, /* ctrl-L */ X &f_forwbline, /* ctrl-M */ X &f_nextwind, /* ctrl-N */ X &f_onlywind, /* ctrl-O */ X &f_prevwind, /* ctrl-P */ X &f_nullproc, /* ctrl-Q */ X &f_insfile, /* ctrl-R */ X &f_nullproc, /* ctrl-S */ X &f_splitwind, /* ctrl-T */ X &f_backhpage, /* ctrl-U */ X &f_quote, /* ctrl-V */ X &f_operwrite, /* ctrl-W */ X &f_cntl_xf, /* ctrl-X */ X &f_mvupwind, /* ctrl-Y */ #if (UNIX&&defined(SIGTSTP)) X &f_bktoshell, /* ctrl-Z */ #else X NULL, #endif X &f_esc, /* ctrl-[ */ X NULL, /* ctrl-\ */ #if (TAGS) X &f_gototag, /* ctrl-] */ #else X NULL, #endif X &f_altbuff, /* ctrl-^ */ X NULL, /* ctrl-_ */ X &f_forwchar, /* */ X &f_operfilter, /* ! */ X &f_usekreg, /* " */ X NULL, /* # */ X &f_gotoeol, /* $ */ #if (CFENCE) X &f_getfence, /* % */ #else X NULL, #endif X NULL, /* & */ X &f_golinenmmark, /* ' */ X &f_unimpl, /* ( */ X &f_unimpl, /* ) */ X &f_togglelistbuffers, /* * */ X &f_forwbline, /* + */ X &f_rev_csrch, /* , */ X &f_backbline, /* - */ X &f_dotcmdplay, /* . */ X &f_forwsearch, /* / */ X &f_gotobol, /* 0 */ X NULL, /* 1 */ X NULL, /* 2 */ X NULL, /* 3 */ X NULL, /* 4 */ X NULL, /* 5 */ X NULL, /* 6 */ X NULL, /* 7 */ X NULL, /* 8 */ X NULL, /* 9 */ X &f_namedcmd, /* : */ X &f_rep_csrch, /* ; */ X &f_operlshift, /* < */ X NULL, /* = */ X &f_operrshift, /* > */ X &f_backsearch, /* ? */ X NULL, /* @ */ X &f_appendeol, /* A */ X &f_backword, /* B */ X &f_chgtoeol, /* C */ X &f_deltoeol, /* D */ X &f_forwendw, /* E */ X &f_bcsrch, /* F */ X &f_gotoline, /* G */ X &f_gotobos, /* H */ X &f_insertbol, /* I */ X &f_join, /* J */ X &f_unarg, /* K */ X &f_gotoeos, /* L */ X &f_gotomos, /* M */ X &f_revsearch, /* N */ X &f_openup, /* O */ X &f_putbefore, /* P */ X &f_quit, /* Q */ X &f_overwrite, /* R */ X &f_chgline, /* S */ X &f_bcsrch_to, /* T */ X &f_lineundo, /* U */ X &f_enlargewind, /* V */ X &f_forwword, /* W */ X &f_backdelchar, /* X */ X &f_yankline, /* Y */ X &f_quickexit, /* Z */ #if (WORDPRO) X &f_gotobosec, /* [ */ #else X NULL, #endif X NULL, /* \ */ #if (WORDPRO) X &f_gotoeosec, /* ] */ #else X NULL, #endif X &f_firstnonwhite, /* ^ */ X &f_histbuff, /* _ */ X &f_goexactnmmark, /* ` */ X &f_append, /* a */ X &f_backviword, /* b */ X &f_operchg, /* c */ X &f_operdel, /* d */ X &f_forwviendw, /* e */ X &f_fcsrch, /* f */ X NULL, /* g */ X &f_backchar, /* h */ X &f_insert, /* i */ X &f_forwline, /* j */ X &f_backline, /* k */ X &f_forwchar, /* l */ X &f_setnmmark, /* m */ X &f_consearch, /* n */ X &f_opendown, /* o */ X &f_putafter, /* p */ X NULL, /* q */ X &f_replacechar, /* r */ X &f_chgchar, /* s */ X &f_fcsrch_to, /* t */ X &f_undo, /* u */ X &f_shrinkwind, /* v */ X &f_forwviword, /* w */ X &f_forwdelchar, /* x */ X &f_operyank, /* y */ X &f_poswind, /* z */ #if (WORDPRO) X &f_gotobop, /* { */ #else X NULL, #endif X &f_gotocol, /* | */ #if (WORDPRO) X &f_gotoeop, /* } */ #else X NULL, #endif X &f_flipchar, /* ~ */ X NULL, /* ctrl-? */ }; X KBIND kbindtbl[NBINDS] = { X { CTLX|tocntrl('C'), &f_quit }, X { CTLX|tocntrl('L'), &f_mvleftwind }, X { CTLX|tocntrl('R'), &f_mvrightwind }, #if (FINDERR) X { CTLX|tocntrl('X'), &f_finderr }, #endif #if (TAGS) X { CTLX|tocntrl(']'), &f_untagpop }, #endif X { CTLX|'!', &f_pipecmd }, X { CTLX|'&', &f_ctlxe }, X { CTLX|'(', &f_ctlxlp }, X { CTLX|')', &f_ctlxrp }, X { CTLX|'/', &f_scrforwsearch }, X { CTLX|'0', &f_delwind }, X { CTLX|'1', &f_onlywind }, X { CTLX|'2', &f_splitwind }, X { CTLX|'=', &f_showcpos }, X { CTLX|'?', &f_scrbacksearch }, X { CTLX|'P', &f_lineputbefore }, #if (ISRCH) X { CTLX|'R', &f_risearch }, #endif #if (ISRCH) X { CTLX|'S', &f_fisearch }, #endif #if (CRYPT) X { CTLX|'X', &f_setkey }, #endif X { CTLX|'c', &f_operlinechg }, X { CTLX|'d', &f_operlinedel }, X { CTLX|'e', &f_filefind }, X { CTLX|'f', &f_setfillcol }, X { CTLX|'h', &f_help }, X { CTLX|'p', &f_lineputafter }, X { CTLX|'s', &f_opersubst }, X { CTLX|'t', &f_settab }, #if (VMALLOC) X { CTLX|'v', &f_setvmalloc }, #endif X { CTLX|'y', &f_operlineyank }, X { CTLA|tocntrl('D'), &f_scrnextdw }, X { CTLA|tocntrl('E'), &f_mvdnnxtwind }, #if (AEDIT) X { CTLA|tocntrl('I'), &f_entab }, #endif X { CTLA|tocntrl('U'), &f_scrnextup }, X { CTLA|tocntrl('Y'), &f_mvupnxtwind }, #if (AEDIT) X { CTLA|' ', &f_detab }, #endif X { CTLA|'*', &f_listbuffers }, X { CTLA|'/', &f_scrsearchpat }, X { CTLA|':', &f_onamedcmd }, #if (WORDPRO) X { CTLA|'f', &f_operformat }, #endif X { CTLA|'h', &f_help }, #if (WORDPRO) X { CTLA|'j', &f_operformat }, #endif X { CTLA|'l', &f_operlower }, #if (AEDIT) X { CTLA|'o', &f_deblank }, #endif X { CTLA|'t', &f_trimline }, X { CTLA|'u', &f_operupper }, X { CTLA|'~', &f_operflip }, #if (TERMCAP) X { SPEC|'1', &f_cbuf1 }, #endif #if (TERMCAP) X { SPEC|'2', &f_cbuf2 }, #endif #if (TERMCAP) X { SPEC|'3', &f_cbuf3 }, #endif #if (TERMCAP) X { SPEC|'4', &f_cbuf4 }, #endif #if (TERMCAP) X { SPEC|'5', &f_cbuf5 }, #endif #if (TERMCAP) X { SPEC|'6', &f_cbuf6 }, #endif #if (TERMCAP) X { SPEC|'7', &f_cbuf7 }, #endif #if (TERMCAP) X { SPEC|'8', &f_cbuf8 }, #endif #if (TERMCAP) X { SPEC|'9', &f_cbuf9 }, #endif X { 0, NULL } }; SHAR_EOF chmod 0664 nebind.h || echo 'restore of nebind.h failed' Wc_c="`wc -c < 'nebind.h'`" test 5332 -eq "$Wc_c" || echo 'nebind.h: original size 5332, current size' "$Wc_c" # ============= nefunc.h ============== echo 'x - extracting nefunc.h (Text)' sed 's/^X//' << 'SHAR_EOF' > 'nefunc.h' && /* nefunc.h: this header file was produced automatically by X * the ./mktbls program, based on input from the file cmdtbl X */ extern int altbuff(); X CMDFUNC f_altbuff = { altbuff, NONE }; extern int append(); X CMDFUNC f_append = { append, REDO|UNDO }; extern int appendeol(); X CMDFUNC f_appendeol = { appendeol, REDO|UNDO }; #if APROP|REBIND extern int apro(); X CMDFUNC f_apro = { apro, NONE }; #endif extern int backchar(); X CMDFUNC f_backchar = { backchar, MOTION }; extern int backdelchar(); X CMDFUNC f_backdelchar = { backdelchar, REDO|UNDO }; #if !SMALLER extern int backhunt(); X CMDFUNC f_backhunt = { backhunt, ABS|MOTION }; #endif extern int backhpage(); X CMDFUNC f_backhpage = { backhpage, NONE }; extern int backline(); X CMDFUNC f_backline = { backline, GOAL|MOTION|FL }; extern int backbline(); X CMDFUNC f_backbline = { backbline, MOTION|FL }; extern int backpage(); X CMDFUNC f_backpage = { backpage, MOTION }; extern int backword(); X CMDFUNC f_backword = { backword, MOTION }; extern int backviword(); X CMDFUNC f_backviword = { backviword, MOTION }; extern int backsearch(); X CMDFUNC f_backsearch = { backsearch, ABS|MOTION }; extern int bcsrch(); X CMDFUNC f_bcsrch = { bcsrch, MOTION }; extern int bcsrch_to(); X CMDFUNC f_bcsrch_to = { bcsrch_to, MOTION }; #if REBIND extern int bindkey(); X CMDFUNC f_bindkey = { bindkey, NONE }; #endif #if UNIX&&defined(SIGTSTP) extern int bktoshell(); X CMDFUNC f_bktoshell = { bktoshell, NONE }; #endif extern int cntl_xf(); X CMDFUNC f_cntl_xf = { cntl_xf, NONE }; extern int chgchar(); X CMDFUNC f_chgchar = { chgchar, REDO|UNDO }; extern int chgline(); X CMDFUNC f_chgline = { chgline, REDO|UNDO }; extern int chgtoeol(); X CMDFUNC f_chgtoeol = { chgtoeol, REDO|UNDO }; extern int clrmes(); X CMDFUNC f_clrmes = { clrmes, NONE }; extern int consearch(); X CMDFUNC f_consearch = { consearch, ABS|MOTION }; extern int opercopy(); X CMDFUNC f_opercopy = { opercopy, OPER|(RANGE|EXTRA) }; extern int ctlxlp(); X CMDFUNC f_ctlxlp = { ctlxlp, NONE }; extern int ctlxrp(); X CMDFUNC f_ctlxrp = { ctlxrp, NONE }; extern int ctlxe(); X CMDFUNC f_ctlxe = { ctlxe, REDO }; extern int cbuf1(); X CMDFUNC f_cbuf1 = { cbuf1, REDO }; extern int cbuf2(); X CMDFUNC f_cbuf2 = { cbuf2, REDO }; extern int cbuf3(); X CMDFUNC f_cbuf3 = { cbuf3, REDO }; extern int cbuf4(); X CMDFUNC f_cbuf4 = { cbuf4, REDO }; extern int cbuf5(); X CMDFUNC f_cbuf5 = { cbuf5, REDO }; extern int cbuf6(); X CMDFUNC f_cbuf6 = { cbuf6, REDO }; extern int cbuf7(); X CMDFUNC f_cbuf7 = { cbuf7, REDO }; extern int cbuf8(); X CMDFUNC f_cbuf8 = { cbuf8, REDO }; extern int cbuf9(); X CMDFUNC f_cbuf9 = { cbuf9, REDO }; extern int cbuf10(); X CMDFUNC f_cbuf10 = { cbuf10, REDO }; #if !SMALLER extern int cbuf11(); X CMDFUNC f_cbuf11 = { cbuf11, REDO }; #endif #if !SMALLER extern int cbuf12(); X CMDFUNC f_cbuf12 = { cbuf12, REDO }; #endif #if !SMALLER extern int cbuf13(); X CMDFUNC f_cbuf13 = { cbuf13, REDO }; #endif #if !SMALLER extern int cbuf14(); X CMDFUNC f_cbuf14 = { cbuf14, REDO }; #endif #if !SMALLER extern int cbuf15(); X CMDFUNC f_cbuf15 = { cbuf15, REDO }; #endif #if !SMALLER extern int cbuf16(); X CMDFUNC f_cbuf16 = { cbuf16, REDO }; #endif #if !SMALLER extern int cbuf17(); X CMDFUNC f_cbuf17 = { cbuf17, REDO }; #endif #if !SMALLER extern int cbuf18(); X CMDFUNC f_cbuf18 = { cbuf18, REDO }; #endif #if !SMALLER extern int cbuf19(); X CMDFUNC f_cbuf19 = { cbuf19, REDO }; #endif #if !SMALLER extern int cbuf20(); X CMDFUNC f_cbuf20 = { cbuf20, REDO }; #endif #if !SMALLER extern int cbuf21(); X CMDFUNC f_cbuf21 = { cbuf21, REDO }; #endif #if !SMALLER extern int cbuf22(); X CMDFUNC f_cbuf22 = { cbuf22, REDO }; #endif #if !SMALLER extern int cbuf23(); X CMDFUNC f_cbuf23 = { cbuf23, REDO }; #endif #if !SMALLER extern int cbuf24(); X CMDFUNC f_cbuf24 = { cbuf24, REDO }; #endif #if !SMALLER extern int cbuf25(); X CMDFUNC f_cbuf25 = { cbuf25, REDO }; #endif #if !SMALLER extern int cbuf26(); X CMDFUNC f_cbuf26 = { cbuf26, REDO }; #endif #if !SMALLER extern int cbuf27(); X CMDFUNC f_cbuf27 = { cbuf27, REDO }; #endif #if !SMALLER extern int cbuf28(); X CMDFUNC f_cbuf28 = { cbuf28, REDO }; #endif #if !SMALLER extern int cbuf29(); X CMDFUNC f_cbuf29 = { cbuf29, REDO }; #endif #if !SMALLER extern int cbuf30(); X CMDFUNC f_cbuf30 = { cbuf30, REDO }; #endif #if !SMALLER extern int cbuf31(); X CMDFUNC f_cbuf31 = { cbuf31, REDO }; #endif #if !SMALLER extern int cbuf32(); X CMDFUNC f_cbuf32 = { cbuf32, REDO }; #endif #if !SMALLER extern int cbuf33(); X CMDFUNC f_cbuf33 = { cbuf33, REDO }; #endif #if !SMALLER extern int cbuf34(); X CMDFUNC f_cbuf34 = { cbuf34, REDO }; #endif #if !SMALLER extern int cbuf35(); X CMDFUNC f_cbuf35 = { cbuf35, REDO }; #endif #if !SMALLER extern int cbuf36(); X CMDFUNC f_cbuf36 = { cbuf36, REDO }; #endif #if !SMALLER extern int cbuf37(); X CMDFUNC f_cbuf37 = { cbuf37, REDO }; #endif #if !SMALLER extern int cbuf38(); X CMDFUNC f_cbuf38 = { cbuf38, REDO }; #endif #if !SMALLER extern int cbuf39(); X CMDFUNC f_cbuf39 = { cbuf39, REDO }; SHAR_EOF true || echo 'restore of nefunc.h failed' echo 'End of Vile part 9' echo 'File nefunc.h is continued in part 10' echo 10 > _shar_seq_.tmp exit 0 -- paul fox, pgf@cayman.com, (617)494-1999 Cayman Systems, 26 Landsdowne St., Cambridge, MA 02139