Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!ames!ptsfa!ihnp4!inuxc!iuvax!isrnix!mr From: mr@isrnix.UUCP (a.k.a regoli@silver.bacs.indiana.edu) Newsgroups: comp.sys.ibm.pc Subject: Repost: EMACS 3.8L Source (Part 3 of 9) Message-ID: <871@isrnix.UUCP> Date: Fri, 31-Jul-87 15:25:06 EDT Article-I.D.: isrnix.871 Posted: Fri Jul 31 15:25:06 1987 Date-Received: Sun, 2-Aug-87 09:41:17 EDT Sender: mr@isrnix.UUCP Organization: indiana university, bloomington Lines: 1910 #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # efunc.h # epath.h # estruct.h # eval.c # evar.h # This archive created: Fri Jul 31 13:54:21 1987 # By: michael regoli (indiana university, bloomington) export PATH; PATH=/bin:/usr/bin:$PATH echo shar: "extracting 'efunc.h'" '(0 character)' if test -f 'efunc.h' then echo shar: "will not over-write existing file 'efunc.h'" else cat << \SHAR_EOF > 'efunc.h' /* EFUNC.H: MicroEMACS function declarations and names This file list all the C code functions used by MicroEMACS and the names to use to bind keys to them. To add functions, declare it here in both the extern function list and the name binding table. */ /* External function declarations */ extern int ctrlg(); /* Abort out of things */ extern int quit(); /* Quit */ extern int ctlxlp(); /* Begin macro */ extern int ctlxrp(); /* End macro */ extern int ctlxe(); /* Execute macro */ extern int fileread(); /* Get a file, read only */ extern int filefind(); /* Get a file, read write */ extern int filewrite(); /* Write a file */ extern int filesave(); /* Save current file */ extern int filename(); /* Adjust file name */ extern int getccol(); /* Get current column */ extern int gotobol(); /* Move to start of line */ extern int forwchar(); /* Move forward by characters */ extern int gotoeol(); /* Move to end of line */ extern int backchar(); /* Move backward by characters */ extern int forwline(); /* Move forward by lines */ extern int backline(); /* Move backward by lines */ extern int forwpage(); /* Move forward by pages */ extern int backpage(); /* Move backward by pages */ extern int gotobob(); /* Move to start of buffer */ extern int gotoeob(); /* Move to end of buffer */ extern int setfillcol(); /* Set fill column. */ extern int setmark(); /* Set mark */ extern int swapmark(); /* Swap "." and mark */ extern int forwsearch(); /* Search forward */ extern int backsearch(); /* Search backwards */ extern int sreplace(); /* search and replace */ extern int qreplace(); /* search and replace w/query */ extern int showcpos(); /* Show the cursor position */ extern int nextwind(); /* Move to the next window */ extern int prevwind(); /* Move to the previous window */ extern int onlywind(); /* Make current window only one */ extern int splitwind(); /* Split current window */ extern int mvdnwind(); /* Move window down */ extern int mvupwind(); /* Move window up */ extern int enlargewind(); /* Enlarge display window. */ extern int shrinkwind(); /* Shrink window. */ extern int listbuffers(); /* Display list of buffers */ extern int usebuffer(); /* Switch a window to a buffer */ extern int killbuffer(); /* Make a buffer go away. */ extern int reposition(); /* Reposition window */ extern int refresh(); /* Refresh the screen */ extern int twiddle(); /* Twiddle characters */ extern int tab(); /* Insert tab */ extern int newline(); /* Insert CR-LF */ extern int indent(); /* Insert CR-LF, then indent */ extern int openline(); /* Open up a blank line */ extern int deblank(); /* Delete blank lines */ extern int quote(); /* Insert literal */ extern int backword(); /* Backup by words */ extern int forwword(); /* Advance by words */ extern int forwdel(); /* Forward delete */ extern int backdel(); /* Backward delete */ extern int killtext(); /* Kill forward */ extern int yank(); /* Yank back from killbuffer. */ extern int upperword(); /* Upper case word. */ extern int lowerword(); /* Lower case word. */ extern int upperregion(); /* Upper case region. */ extern int lowerregion(); /* Lower case region. */ extern int capword(); /* Initial capitalize word. */ extern int delfword(); /* Delete forward word. */ extern int delbword(); /* Delete backward word. */ extern int killregion(); /* Kill region. */ extern int copyregion(); /* Copy region to kill buffer. */ extern int spawncli(); /* Run CLI in a subjob. */ extern int spawn(); /* Run a command in a subjob. */ #if BSD extern int bktoshell(); /* suspend emacs to parent shell*/ extern int rtfrmshell(); /* return from a suspended state*/ #endif extern int quickexit(); /* low keystroke style exit. */ extern int setmode(); /* set an editor mode */ extern int delmode(); /* delete a mode */ extern int gotoline(); /* go to a numbered line */ extern int namebuffer(); /* rename the current buffer */ #if WORDPRO extern int gotobop(); /* go to beginning/paragraph */ extern int gotoeop(); /* go to end/paragraph */ extern int fillpara(); /* fill current paragraph */ #endif extern int help(); /* get the help file here */ extern int deskey(); /* describe a key's binding */ extern int viewfile(); /* find a file in view mode */ extern int insfile(); /* insert a file */ extern int scrnextup(); /* scroll next window back */ extern int scrnextdw(); /* scroll next window down */ extern int bindtokey(); /* bind a function to a key */ extern int unbindkey(); /* unbind a key's function */ extern int namedcmd(); /* execute named command */ extern int desbind(); /* describe bindings */ extern int execcmd(); /* execute a command line */ extern int execbuf(); /* exec commands from a buffer */ extern int execfile(); /* exec commands from a file */ extern int nextbuffer(); /* switch to the next buffer */ #if WORDPRO extern int killpara(); /* kill the current paragraph */ #endif extern int setgmode(); /* set a global mode */ extern int delgmode(); /* delete a global mode */ extern int insspace(); /* insert a space forword */ extern int forwhunt(); /* hunt forward for next match */ extern int backhunt(); /* hunt backwards for next match*/ extern int pipecmd(); /* pipe command into buffer */ extern int filter(); /* filter buffer through dos */ extern int delwind(); /* delete the current window */ extern int cbuf1(); /* execute numbered comd buffer */ extern int cbuf2(); extern int cbuf3(); extern int cbuf4(); extern int cbuf5(); extern int cbuf6(); extern int cbuf7(); extern int cbuf8(); extern int cbuf9(); extern int cbuf10(); extern int cbuf11(); extern int cbuf12(); extern int cbuf13(); extern int cbuf14(); extern int cbuf15(); extern int cbuf16(); extern int cbuf17(); extern int cbuf18(); extern int cbuf19(); extern int cbuf20(); extern int cbuf21(); extern int cbuf22(); extern int cbuf23(); extern int cbuf24(); extern int cbuf25(); extern int cbuf26(); extern int cbuf27(); extern int cbuf28(); extern int cbuf29(); extern int cbuf30(); extern int cbuf31(); extern int cbuf32(); extern int cbuf33(); extern int cbuf34(); extern int cbuf35(); extern int cbuf36(); extern int cbuf37(); extern int cbuf38(); extern int cbuf39(); extern int cbuf40(); extern int storemac(); /* store text for macro */ extern int resize(); /* resize current window */ extern int clrmes(); /* clear the message line */ extern int meta(); /* meta prefix dummy function */ extern int cex(); /* ^X prefix dummy function */ extern int unarg(); /* ^U repeat arg dummy function */ extern int istring(); /* insert string in text */ extern int unmark(); /* unmark current buffer */ #if ISRCH extern int fisearch(); /* forward incremental search */ extern int risearch(); /* reverse incremental search */ #endif #if WORDPRO extern int wordcount(); /* count words in region */ #endif extern int savewnd(); /* save current window */ extern int restwnd(); /* restore current window */ extern int upscreen(); /* force screen update */ extern int writemsg(); /* write text on message line */ #if FLABEL extern int fnclabel(); /* set function key label */ #endif #if APROP extern int apro(); /* apropos fuction */ #endif #if CRYPT extern int setkey(); /* set encryption key */ #endif extern int wrapword(); /* wordwrap function */ #if CFENCE extern int getfence(); /* move cursor to a matching fence */ #endif extern int newsize(); /* change the current screen size */ extern int setvar(); /* set a variables value */ extern int newwidth(); /* change the current screen width */ #if AEDIT extern int trim(); /* trim whitespace from end of line */ extern int detab(); /* detab rest of line */ extern int entab(); /* entab rest of line */ #endif #if PROC extern int storeproc(); /* store names procedure */ extern int execproc(); /* execute procedure */ #endif extern int nullproc(); /* does nothing... */ /* Name to function binding table This table gives the names of all the bindable functions end their C function address. These are used for the bind-to-key function. */ NBIND names[] = { {"abort-command", ctrlg}, {"add-mode", setmode}, {"add-global-mode", setgmode}, #if APROP {"apropos", apro}, #endif {"backward-character", backchar}, {"begin-macro", ctlxlp}, {"beginning-of-file", gotobob}, {"beginning-of-line", gotobol}, {"bind-to-key", bindtokey}, {"buffer-position", showcpos}, {"case-region-lower", lowerregion}, {"case-region-upper", upperregion}, {"case-word-capitalize", capword}, {"case-word-lower", lowerword}, {"case-word-upper", upperword}, {"change-file-name", filename}, {"change-screen-size", newsize}, {"change-screen-width", newwidth}, {"clear-and-redraw", refresh}, {"clear-message-line", clrmes}, {"copy-region", copyregion}, #if WORDPRO {"count-words", wordcount}, #endif {"ctlx-prefix", cex}, {"delete-blank-lines", deblank}, {"delete-buffer", killbuffer}, {"delete-mode", delmode}, {"delete-global-mode", delgmode}, {"delete-next-character", forwdel}, {"delete-next-word", delfword}, {"delete-other-windows", onlywind}, {"delete-previous-character", backdel}, {"delete-previous-word", delbword}, {"delete-window", delwind}, {"describe-bindings", desbind}, {"describe-key", deskey}, #if AEDIT {"detab-line", detab}, #endif {"end-macro", ctlxrp}, {"end-of-file", gotoeob}, {"end-of-line", gotoeol}, #if AEDIT {"entab-line", entab}, #endif {"exchange-point-and-mark", swapmark}, {"execute-buffer", execbuf}, {"execute-command-line", execcmd}, {"execute-file", execfile}, {"execute-macro", ctlxe}, {"execute-macro-1", cbuf1}, {"execute-macro-2", cbuf2}, {"execute-macro-3", cbuf3}, {"execute-macro-4", cbuf4}, {"execute-macro-5", cbuf5}, {"execute-macro-6", cbuf6}, {"execute-macro-7", cbuf7}, {"execute-macro-8", cbuf8}, {"execute-macro-9", cbuf9}, {"execute-macro-10", cbuf10}, {"execute-macro-11", cbuf11}, {"execute-macro-12", cbuf12}, {"execute-macro-13", cbuf13}, {"execute-macro-14", cbuf14}, {"execute-macro-15", cbuf15}, {"execute-macro-16", cbuf16}, {"execute-macro-17", cbuf17}, {"execute-macro-18", cbuf18}, {"execute-macro-19", cbuf19}, {"execute-macro-20", cbuf20}, {"execute-macro-21", cbuf21}, {"execute-macro-22", cbuf22}, {"execute-macro-23", cbuf23}, {"execute-macro-24", cbuf24}, {"execute-macro-25", cbuf25}, {"execute-macro-26", cbuf26}, {"execute-macro-27", cbuf27}, {"execute-macro-28", cbuf28}, {"execute-macro-29", cbuf29}, {"execute-macro-30", cbuf30}, {"execute-macro-31", cbuf31}, {"execute-macro-32", cbuf32}, {"execute-macro-33", cbuf33}, {"execute-macro-34", cbuf34}, {"execute-macro-35", cbuf35}, {"execute-macro-36", cbuf36}, {"execute-macro-37", cbuf37}, {"execute-macro-38", cbuf38}, {"execute-macro-39", cbuf39}, {"execute-macro-40", cbuf40}, {"execute-named-command", namedcmd}, #if PROC {"execute-procedure", execproc}, #endif {"exit-emacs", quit}, #if WORDPRO {"fill-paragraph", fillpara}, #endif {"filter-buffer", filter}, {"find-file", filefind}, {"forward-character", forwchar}, {"goto-line", gotoline}, #if CFENCE {"goto-matching-fence", getfence}, #endif {"grow-window", enlargewind}, {"handle-tab", tab}, {"hunt-forward", forwhunt}, {"hunt-backward", backhunt}, {"help", help}, {"i-shell", spawncli}, #if ISRCH {"incremental-search", fisearch}, #endif {"insert-file", insfile}, {"insert-space", insspace}, {"insert-string", istring}, #if WORDPRO {"kill-paragraph", killpara}, #endif {"kill-region", killregion}, {"kill-to-end-of-line", killtext}, #if FLABEL {"label-function-key", fnclabel}, #endif {"list-buffers", listbuffers}, {"meta-prefix", meta}, {"move-window-down", mvdnwind}, {"move-window-up", mvupwind}, {"name-buffer", namebuffer}, {"newline", newline}, {"newline-and-indent", indent}, {"next-buffer", nextbuffer}, {"next-line", forwline}, {"next-page", forwpage}, #if WORDPRO {"next-paragraph", gotoeop}, #endif {"next-window", nextwind}, {"next-word", forwword}, {"nop", nullproc}, {"open-line", openline}, {"pipe-command", pipecmd}, {"previous-line", backline}, {"previous-page", backpage}, #if WORDPRO {"previous-paragraph", gotobop}, #endif {"previous-window", prevwind}, {"previous-word", backword}, {"query-replace-string", qreplace}, {"quick-exit", quickexit}, {"quote-character", quote}, {"read-file", fileread}, {"redraw-display", reposition}, {"resize-window", resize}, {"restore-window", restwnd}, {"replace-string", sreplace}, #if ISRCH {"reverse-incremental-search", risearch}, #endif #if PROC {"run", execproc}, #endif {"save-file", filesave}, {"save-window", savewnd}, {"scroll-next-up", scrnextup}, {"scroll-next-down", scrnextdw}, {"search-forward", forwsearch}, {"search-reverse", backsearch}, {"select-buffer", usebuffer}, {"set", setvar}, #if CRYPT {"set-encryption-key", setkey}, #endif {"set-fill-column", setfillcol}, {"set-mark", setmark}, {"shell-command", spawn}, {"shrink-window", shrinkwind}, {"split-current-window", splitwind}, {"store-macro", storemac}, #if PROC {"store-procedure", storeproc}, #endif #if BSD {"suspend-emacs", bktoshell}, #endif {"transpose-characters", twiddle}, #if AEDIT {"trim-line", trim}, #endif {"unbind-key", unbindkey}, {"universal-argument", unarg}, {"unmark-buffer", unmark}, {"update-screen", upscreen}, {"view-file", viewfile}, {"wrap-word", wrapword}, {"write-file", filewrite}, {"write-message", writemsg}, {"yank", yank}, {"", NULL} }; SHAR_EOF chmod +x 'efunc.h' fi echo shar: "extracting 'epath.h'" '(0 character)' if test -f 'epath.h' then echo shar: "will not over-write existing file 'epath.h'" else cat << \SHAR_EOF > 'epath.h' /* PATH: This file contains certain info needed to locate the MicroEMACS files on a system dependant basis. */ /* possible names and paths of help files under different OSs */ char *pathname[] = #if AMIGA { ".emacsrc", "emacs.hlp", "", ":c/", ":t/" }; #endif #if ST520 { "emacs.rc", "emacs.hlp", "\\", "\\bin\\", "\\util\\", "" }; #endif #if FINDER { "emacs.rc", "emacs.hlp", "/bin", "/sys/public", "" }; #endif #if MSDOS { "emacs.rc", "emacs.hlp", "\\sys\\public\\", "\\usr\\bin\\", "\\bin\\", "\\", "" }; #endif #if V7 | BSD | USG { ".emacsrc", "emacs.hlp", "/usr/local/", "/usr/lib/", "" }; #endif #if VMS { "emacs.rc", "emacs.hlp", "", "sys$sysdevice:[vmstools]" }; #endif #define NPNAMES (sizeof(pathname)/sizeof(char *)) SHAR_EOF chmod +x 'epath.h' fi echo shar: "extracting 'estruct.h'" '(0 character)' if test -f 'estruct.h' then echo shar: "will not over-write existing file 'estruct.h'" else cat << \SHAR_EOF > 'estruct.h' /* ESTRUCT: Structure and preprocesser defined for MicroEMACS 3.8 written by Dave G. Conroy modified by Steve Wilhite, George Jones greatly modified by Daniel Lawrence */ #ifdef LATTICE #undef LATTICE /* don't use their definitions...use ours */ #endif #ifdef MSDOS #undef MSDOS #endif #ifdef CPM #undef CPM #endif #ifdef AMIGA #undef AMIGA #endif #ifdef EGA #undef EGA #endif /* Program Identification..... PROGNAME should always be MicroEMACS for a distibrution unmodified version. People using MicroEMACS as a shell for other products should change this to reflect their product. Macros can query this via the $progname variable */ #define PROGNAME "MicroEMACS" #define VERSION "3.8l" /* Machine/OS definitions */ #define AMIGA 0 /* AmigaDOS */ #define ST520 0 /* ST520, TOS */ #define MSDOS 1 /* MS-DOS */ #define V7 0 /* V7 UNIX or Coherent or BSD4.2*/ #define BSD 0 /* UNIX BSD 4.2 and ULTRIX */ #define USG 0 /* UNIX system V */ #define VMS 0 /* VAX/VMS */ #define CPM 0 /* CP/M-86 */ #define FINDER 0 /* Macintosh OS */ /* Compiler definitions */ #define MWC86 0 /* marc williams compiler */ #define LATTICE 0 /* Lattice 2.14 thruough 3.0 compilers */ #define AZTEC 0 /* Aztec C 3.20e */ #define MSC 0 /* MicroSoft C compile version 3 & 4 */ /* Debugging options */ #define RAMSIZE 0 /* dynamic RAM memory usage tracking */ #define RAMSHOW 0 /* auto dynamic RAM reporting */ /* Special keyboard definitions */ #define WANGPC 0 /* WangPC - mostly escape sequences */ /* Terminal Output definitions */ #define ANSI 0 /* ANSI escape sequences */ #define HP150 0 /* HP150 screen driver */ #define HP110 0 /* HP110 screen driver */ #define VMSVT 0 /* various VMS terminal entries */ #define VT52 0 /* VT52 terminal (Zenith). */ #define VT100 0 /* Handle VT100 style keypad. */ #define RAINBOW 0 /* Use Rainbow fast video. */ #define TERMCAP 0 /* Use TERMCAP */ #define IBMPC 1 /* IBM-PC CGA/MONO/EGA driver */ #define DG10 0 /* Data General system/10 */ #define TIPC 0 /* TI Profesional PC driver */ #define Z309 0 /* Zenith 100 PC family driver */ #define MAC 0 /* Macintosh */ #define ATARI 0 /* Atari 520/1040ST screen */ /* Configuration options */ #define CVMVAS 1 /* arguments to page forward/back in pages */ #define CLRMSG 0 /* space clears the message line with no insert */ #define ACMODE 1 /* auto CMODE on .C and .H files */ #define CFENCE 1 /* fench matching in CMODE */ #define TYPEAH 1 /* type ahead causes update to be skipped */ #define DEBUGM 1 /* $debug triggers macro debugging */ #define VISMAC 0 /* update display during keyboard macros */ #define CTRLZ 0 /* add a ^Z at end of files under MSDOS only */ #define REVSTA 1 /* Status line appears in reverse video */ #define COLOR 1 /* color commands and windows */ #define FILOCK 0 /* file locking under unix BSD 4.2 */ #define ISRCH 1 /* Incremental searches like ITS EMACS */ #define WORDPRO 1 /* Advanced word processing features */ #define FLABEL 0 /* function key label code [HP150] */ #define APROP 1 /* Add code for Apropos command */ #define CRYPT 1 /* file encryption enabled? */ #define MAGIC 1 /* include regular expression matching? */ #define AEDIT 1 /* advanced editing options: en/detabbing, rectangular regions [later] */ #define PROC 1 /* named procedures */ #define ASCII 1 /* always using ASCII char sequences for now */ #define EBCDIC 0 /* later IBM mainfraim versions will use EBCDIC */ /* System dependant library redefinitions, structures and includes */ #if AZTEC #undef fputc #undef fgetc #if MSDOS #define fgetc a1getc #else #define fgetc agetc #endif #define fputc aputc #define int86 sysint #define intdos(a, b) sysint(33, a, b) #define inp inportb #define outp outportb struct XREG { int ax,bx,cx,dx,si,di; }; struct HREG { char al,ah,bl,bh,cl,ch,dl,dh; }; union REGS { struct XREG x; struct HREG h; }; #endif #if MSDOS & MWC86 #include #define int86(a, b, c) intcall(b, c, a) #define inp in struct XREG { int ax,bx,cx,dx,si,di,ds,es,flags; }; struct HREG { char al,ah,bl,bh,cl,ch,dl,dh; int ds,es,flags; }; union REGS { struct XREG x; struct HREG h; }; #endif #if MSDOS & MSC #include #include #define peek(a,b,c,d) movedata(a,b,FP_SEG(c),FP_OFF(c),d) #define poke(a,b,c,d) movedata(FP_SEG(c),FP_OFF(c),a,b,d) #define movmem(a, b, c) memcpy(b, a, c) #endif #if MSDOS & LATTICE #undef CPM #undef LATTICE #include #undef CPM #endif #if VMS #define unlink(a) delete(a) #endif /* define memory mapped flag */ #define MEMMAP 0 #if IBMPC #undef MEMMAP #define MEMMAP 1 #endif #if Z309 #undef MEMMAP #define MEMMAP 1 #endif /* internal constants */ #define NBINDS 256 /* max # of bound keys */ #define NFILEN 80 /* # of bytes, file name */ #define NBUFN 16 /* # of bytes, buffer name */ #define NLINE 256 /* # of bytes, input line */ #define NSTRING 128 /* # of bytes, string buffers */ #define NKBDM 256 /* # of strokes, keyboard macro */ #define NPAT 128 /* # of bytes, pattern */ #define HUGE 1000 /* Huge number */ #define NLOCKS 100 /* max # of file locks active */ #define NCOLORS 8 /* number of supported colors */ #define KBLOCK 250 /* sizeof kill buffer chunks */ #define NBLOCK 16 /* line block chunk size */ #define NVSIZE 10 /* max #chars in a var name */ #define CTRL 0x0100 /* Control flag, or'ed in */ #define META 0x0200 /* Meta flag, or'ed in */ #define CTLX 0x0400 /* ^X flag, or'ed in */ #define SPEC 0x0800 /* special key (function keys) */ #define FALSE 0 /* False, no, bad, etc. */ #define TRUE 1 /* True, yes, good, etc. */ #define ABORT 2 /* Death, ^G, abort, etc. */ #define FAILED 3 /* not-quite fatal false return */ #define RET 4 /* a return from buffer */ #define GOLINE 5 /* exit flagging a GOTO */ #define STOP 0 /* keyboard macro not in use */ #define PLAY 1 /* playing */ #define RECORD 2 /* recording */ /* * PTBEG, PTEND, FORWARD, and REVERSE are all toggle-able values for * the scan routines. */ #define PTBEG 0 /* Leave the point at the beginning on search */ #define PTEND 1 /* Leave the point at the end on search */ #define FORWARD 0 /* forward direction */ #define REVERSE 1 /* backwards direction */ #define FIOSUC 0 /* File I/O, success. */ #define FIOFNF 1 /* File I/O, file not found. */ #define FIOEOF 2 /* File I/O, end of file. */ #define FIOERR 3 /* File I/O, error. */ #define FIOLNG 4 /* line longer than allowed len */ #define FIOFUN 5 /* File I/O, eod of file/bad line*/ #define CFCPCN 0x0001 /* Last command was C-P, C-N */ #define CFKILL 0x0002 /* Last command was a kill */ #define BELL 0x07 /* a bell character */ #define TAB 0x09 /* a tab character */ #if V7 | USG | BSD #define PATHCHR ':' #else #define PATHCHR ';' #endif #define INTWIDTH sizeof(int) * 3 /* Macro argument token types */ #define TKNUL 0 /* end-of-string */ #define TKARG 1 /* interactive argument */ #define TKBUF 2 /* buffer argument */ #define TKVAR 3 /* user variables */ #define TKENV 4 /* environment variables */ #define TKFUN 5 /* function.... */ #define TKDIR 6 /* directive */ #define TKLBL 7 /* line label */ #define TKLIT 8 /* numeric literal */ #define TKSTR 9 /* quoted string literal */ #define TKCMD 10 /* command name */ /* Internal defined functions */ #define nextab(a) (a & ~7) + 8 #undef abs /* DIFCASE represents the integer difference between upper and lower case letters. It is an xor-able value, which is fortunate, since the relative positions of upper to lower case letters is the opposite of ascii in ebcdic. */ #ifdef islower #undef islower #endif #if ASCII #define DIFCASE 0x20 #define isletter(c) (('a' <= c && 'z' >= c) || ('A' <= c && 'Z' >= c)) #define islower(c) (('a' <= c && 'z' >= c)) #endif #if EBCDIC #define DIFCASE 0x40 #define isletter(c) (('a' <= c && 'i' >= c) || ('j' <= c && 'r' >= c) || ('s' <= c && 'z' >= c) || ('A' <= c && 'I' >= c) || ('J' <= c && 'R' >= c) || ('S' <= c && 'Z' >= c)) #define islower(c) (('a' <= c && 'i' >= c) || ('j' <= c && 'r' >= c) || ('s' <= c && 'z' >= c)) #endif /* Dynamic RAM tracking and reporting redefinitions */ #if RAMSIZE #define malloc allocate #define free release #endif /* * There is a window structure allocated for every active display window. The * windows are kept in a big list, in top to bottom screen order, with the * listhead at "wheadp". Each window contains its own values of dot and mark. * The flag field contains some bits that are set by commands to guide * redisplay. Although this is a bit of a compromise in terms of decoupling, * the full blown redisplay is just too expensive to run for every input * character. */ typedef struct WINDOW { struct WINDOW *w_wndp; /* Next window */ struct BUFFER *w_bufp; /* Buffer displayed in window */ struct LINE *w_linep; /* Top line in the window */ struct LINE *w_dotp; /* Line containing "." */ short w_doto; /* Byte offset for "." */ struct LINE *w_markp; /* Line containing "mark" */ short w_marko; /* Byte offset for "mark" */ char w_toprow; /* Origin 0 top row of window */ char w_ntrows; /* # of rows of text in window */ char w_force; /* If NZ, forcing row. */ char w_flag; /* Flags. */ #if COLOR char w_fcolor; /* current forground color */ char w_bcolor; /* current background color */ #endif } WINDOW; #define WFFORCE 0x01 /* Window needs forced reframe */ #define WFMOVE 0x02 /* Movement from line to line */ #define WFEDIT 0x04 /* Editing within a line */ #define WFHARD 0x08 /* Better to a full display */ #define WFMODE 0x10 /* Update mode line. */ #define WFCOLR 0x20 /* Needs a color change */ /* * Text is kept in buffers. A buffer header, described below, exists for every * buffer in the system. The buffers are kept in a big list, so that commands * that search for a buffer by name can find the buffer header. There is a * safe store for the dot and mark in the header, but this is only valid if * the buffer is not being displayed (that is, if "b_nwnd" is 0). The text for * the buffer is kept in a circularly linked list of lines, with a pointer to * the header line in "b_linep". * Buffers may be "Inactive" which means the files associated with them * have not been read in yet. These get read in at "use buffer" time. */ typedef struct BUFFER { struct BUFFER *b_bufp; /* Link to next BUFFER */ struct LINE *b_dotp; /* Link to "." LINE structure */ short b_doto; /* Offset of "." in above LINE */ struct LINE *b_markp; /* The same as the above two, */ short b_marko; /* but for the "mark" */ struct LINE *b_linep; /* Link to the header LINE */ char b_active; /* window activated flag */ char b_nwnd; /* Count of windows on buffer */ char b_flag; /* Flags */ int b_mode; /* editor mode of this buffer */ char b_fname[NFILEN]; /* File name */ char b_bname[NBUFN]; /* Buffer name */ #if CRYPT char b_key[NPAT]; /* current encrypted key */ #endif } BUFFER; #define BFINVS 0x01 /* Internal invisable buffer */ #define BFCHG 0x02 /* Changed since last write */ /* mode flags */ #define NUMMODES 9 /* # of defined modes */ #define MDWRAP 0x0001 /* word wrap */ #define MDCMOD 0x0002 /* C indentation and fence match*/ #define MDSPELL 0x0004 /* spell error parcing */ #define MDEXACT 0x0008 /* Exact matching for searches */ #define MDVIEW 0x0010 /* read-only buffer */ #define MDOVER 0x0020 /* overwrite mode */ #define MDMAGIC 0x0040 /* regular expresions in search */ #define MDCRYPT 0x0080 /* encrytion mode active */ #define MDASAVE 0x0100 /* auto-save mode */ /* * The starting position of a region, and the size of the region in * characters, is kept in a region structure. Used by the region commands. */ typedef struct { struct LINE *r_linep; /* Origin LINE address. */ short r_offset; /* Origin LINE offset. */ long r_size; /* Length in characters. */ } REGION; /* * All text is kept in circularly linked lists of "LINE" structures. These * begin at the header line (which is the blank line beyond the end of the * buffer). This line is pointed to by the "BUFFER". Each line contains a the * number of bytes in the line (the "used" size), the size of the text array, * and the text. The end of line is not stored as a byte; it's implied. Future * additions will include update hints, and a list of marks into the line. */ typedef struct LINE { struct LINE *l_fp; /* Link to the next line */ struct LINE *l_bp; /* Link to the previous line */ short l_size; /* Allocated size */ short l_used; /* Used size */ char l_text[1]; /* A bunch of characters. */ } LINE; #define lforw(lp) ((lp)->l_fp) #define lback(lp) ((lp)->l_bp) #define lgetc(lp, n) ((lp)->l_text[(n)]&0xFF) #define lputc(lp, n, c) ((lp)->l_text[(n)]=(c)) #define llength(lp) ((lp)->l_used) /* * The editor communicates with the display using a high level interface. A * "TERM" structure holds useful variables, and indirect pointers to routines * that do useful operations. The low level get and put routines are here too. * This lets a terminal, in addition to having non standard commands, have * funny get and put character code too. The calls might get changed to * "termp->t_field" style in the future, to make it possible to run more than * one terminal type. */ typedef struct { short t_mrow; /* max number of rows allowable */ short t_nrow; /* current number of rows used */ short t_mcol; /* max Number of columns. */ short t_ncol; /* current Number of columns. */ short t_margin; /* min margin for extended lines*/ short t_scrsiz; /* size of scroll region " */ int t_pause; /* # times thru update to pause */ int (*t_open)(); /* Open terminal at the start. */ int (*t_close)(); /* Close terminal at end. */ int (*t_kopen)(); /* Open keyboard */ int (*t_kclose)(); /* close keyboard */ int (*t_getchar)(); /* Get character from keyboard. */ int (*t_putchar)(); /* Put character to display. */ int (*t_flush)(); /* Flush output buffers. */ int (*t_move)(); /* Move the cursor, origin 0. */ int (*t_eeol)(); /* Erase to end of line. */ int (*t_eeop)(); /* Erase to end of page. */ int (*t_beep)(); /* Beep. */ int (*t_rev)(); /* set reverse video state */ int (*t_rez)(); /* change screen resolution */ #if COLOR int (*t_setfor)(); /* set forground color */ int (*t_setback)(); /* set background color */ #endif } TERM; /* TEMPORARY macros for terminal I/O (to be placed in a machine dependant place later) */ #define TTopen (*term.t_open) #define TTclose (*term.t_close) #define TTkopen (*term.t_kopen) #define TTkclose (*term.t_kclose) #define TTgetc (*term.t_getchar) #define TTputc (*term.t_putchar) #define TTflush (*term.t_flush) #define TTmove (*term.t_move) #define TTeeol (*term.t_eeol) #define TTeeop (*term.t_eeop) #define TTbeep (*term.t_beep) #define TTrev (*term.t_rev) #define TTrez (*term.t_rez) #if COLOR #define TTforg (*term.t_setfor) #define TTbacg (*term.t_setback) #endif /* structure for the table of initial key bindings */ typedef struct { short k_code; /* Key code */ int (*k_fp)(); /* Routine to handle it */ } KEYTAB; /* structure for the name binding table */ typedef struct { char *n_name; /* name of function key */ int (*n_func)(); /* function name is bound to */ } NBIND; /* The editor holds deleted text chunks in the KILL buffer. The kill buffer is logically a stream of ascii characters, however due to its unpredicatable size, it gets implemented as a linked list of chunks. (The d_ prefix is for "deleted" text, as k_ was taken up by the keycode structure) */ typedef struct KILL { struct KILL *d_next; /* link to next chunk, NULL if last */ char d_chunk[KBLOCK]; /* deleted text */ } KILL; /* * Incremental search defines. */ #if ISRCH #define CMDBUFLEN 256 /* Length of our command buffer */ #define IS_ABORT 0x07 /* Abort the isearch */ #define IS_BACKSP 0x08 /* Delete previous char */ #define IS_TAB 0x09 /* Tab character (allowed search char) */ #define IS_NEWLINE 0x0D /* New line from keyboard (Carriage return) */ #define IS_QUOTE 0x11 /* Quote next character */ #define IS_REVERSE 0x12 /* Search backward */ #define IS_FORWARD 0x13 /* Search forward */ #define IS_VMSQUOTE 0x16 /* VMS quote character */ #define IS_VMSFORW 0x18 /* Search forward for VMS */ #define IS_QUIT 0x1B /* Exit the search */ #define IS_RUBOUT 0x7F /* Delete previous character */ /* IS_QUIT is no longer used, the variable metac is used instead */ #endif #if MAGIC /* * Defines for the metacharacters in the regular expressions in search * routines. */ #define MCNIL 0 /* Like the '\0' for strings.*/ #define LITCHAR 1 #define ANY 2 #define CCL 3 #define NCCL 4 #define BOL 5 #define EOL 6 #define CLOSURE 256 /* An or-able value.*/ #define MASKCL CLOSURE - 1 #define MC_ANY '.' /* 'Any' character (except newline).*/ #define MC_CCL '[' /* Character class.*/ #define MC_NCCL '^' /* Negate character class.*/ #define MC_RCCL '-' /* Range in character class.*/ #define MC_ECCL ']' /* End of character class.*/ #define MC_BOL '^' /* Beginning of line.*/ #define MC_EOL '$' /* End of line.*/ #define MC_CLOSURE '*' /* Closure - does not extend past newline.*/ #define MC_ESC '\\' /* Escape - suppress meta-meaning.*/ #define BIT(n) (1 << (n)) /* An integer with one bit set.*/ #define CHCASE(c) ((c) ^ DIFCASE) /* Toggle the case of a letter.*/ /* HICHAR - 1 is the largest character we will deal with. * HIBYTE represents the number of bytes in the bitmap. */ #define HICHAR 256 #define HIBYTE HICHAR >> 3 typedef char *BITMAP; typedef struct { short int mc_type; union { int lchar; BITMAP cclmap; } u; } MC; #endif SHAR_EOF chmod +x 'estruct.h' fi echo shar: "extracting 'eval.c'" '(0 character)' if test -f 'eval.c' then echo shar: "will not over-write existing file 'eval.c'" else cat << \SHAR_EOF > 'eval.c' /* EVAL.C: Expresion evaluation functions for MicroEMACS written 1986 by Daniel Lawrence */ #include #include "estruct.h" #include "edef.h" #include "evar.h" varinit() /* initialize the user variable list */ { register int i; for (i=0; i < MAXVARS; i++) uv[i].u_name[0] = 0; } char *gtfun(fname) /* evaluate a function */ char *fname; /* name of function to evaluate */ { register int fnum; /* index to function to eval */ register int status; /* return status */ char arg1[NSTRING]; /* value of first argument */ char arg2[NSTRING]; /* value of second argument */ char arg3[NSTRING]; /* value of third argument */ static char result[2 * NSTRING]; /* string result */ /* look the function up in the function table */ fname[3] = 0; /* only first 3 chars significant */ mklower(fname); /* and let it be upper or lower case */ for (fnum = 0; fnum < NFUNCS; fnum++) if (strcmp(fname, funcs[fnum].f_name) == 0) break; /* return errorm on a bad reference */ if (fnum == NFUNCS) return(errorm); /* if needed, retrieve the first argument */ if (funcs[fnum].f_type >= MONAMIC) { if ((status = macarg(arg1)) != TRUE) return(errorm); /* if needed, retrieve the second argument */ if (funcs[fnum].f_type >= DYNAMIC) { if ((status = macarg(arg2)) != TRUE) return(errorm); /* if needed, retrieve the third argument */ if (funcs[fnum].f_type >= TRINAMIC) if ((status = macarg(arg3)) != TRUE) return(errorm); } } /* and now evaluate it! */ switch (fnum) { case UFADD: return(itoa(atoi(arg1) + atoi(arg2))); case UFSUB: return(itoa(atoi(arg1) - atoi(arg2))); case UFTIMES: return(itoa(atoi(arg1) * atoi(arg2))); case UFDIV: return(itoa(atoi(arg1) / atoi(arg2))); case UFMOD: return(itoa(atoi(arg1) % atoi(arg2))); case UFNEG: return(itoa(-atoi(arg1))); case UFCAT: strcpy(result, arg1); return(strcat(result, arg2)); case UFLEFT: return(strncpy(result, arg1, atoi(arg2))); case UFRIGHT: return(strcpy(result, &arg1[atoi(arg2)-1])); case UFMID: return(strncpy(result, &arg1[atoi(arg2)-1], atoi(arg3))); case UFNOT: return(ltos(stol(arg1) == FALSE)); case UFEQUAL: return(ltos(atoi(arg1) == atoi(arg2))); case UFLESS: return(ltos(atoi(arg1) < atoi(arg2))); case UFGREATER: return(ltos(atoi(arg1) > atoi(arg2))); case UFSEQUAL: return(ltos(strcmp(arg1, arg2) == 0)); case UFSLESS: return(ltos(strcmp(arg1, arg2) < 0)); case UFSGREAT: return(ltos(strcmp(arg1, arg2) > 0)); case UFIND: return(getval(arg1)); case UFAND: return(ltos(stol(arg1) && stol(arg2))); case UFOR: return(ltos(stol(arg1) || stol(arg2))); case UFLENGTH: return(itoa(strlen(arg1))); case UFUPPER: return(mkupper(arg1)); case UFLOWER: return(mklower(arg1)); case UFTRUTH: return(ltos(atoi(arg1) == 42)); case UFASCII: return(itoa((int)arg1[0])); case UFCHR: result[0] = atoi(arg1); result[1] = 0; return(result); case UFGTKEY: result[0] = tgetc(); result[1] = 0; return(result); case UFRND: return(itoa((ernd() % abs(atoi(arg1))) + 1)); case UFABS: return(itoa(abs(atoi(arg1)))); } exit(-11); /* never should get here */ } char *gtusr(vname) /* look up a user var's value */ char *vname; /* name of user variable to fetch */ { register int vnum; /* ordinal number of user var */ /* scan the list looking for the user var name */ for (vnum = 0; vnum < MAXVARS; vnum++) if (strcmp(vname, uv[vnum].u_name) == 0) break; /* return errorm on a bad reference */ if (vnum == MAXVARS) return(errorm); return(uv[vnum].u_value); } char *gtenv(vname) char *vname; /* name of environment variable to retrieve */ { register int vnum; /* ordinal number of var refrenced */ char *getkill(); /* scan the list, looking for the referenced name */ for (vnum = 0; vnum < NEVARS; vnum++) if (strcmp(vname, envars[vnum]) == 0) break; /* return errorm on a bad reference */ if (vnum == NEVARS) return(errorm); /* otherwise, fetch the appropriate value */ switch (vnum) { case EVFILLCOL: return(itoa(fillcol)); case EVPAGELEN: return(itoa(term.t_nrow + 1)); case EVCURCOL: return(itoa(getccol(FALSE) + 1)); case EVCURLINE: return(itoa(getcline())); case EVRAM: return(itoa((int)(envram / 1024l))); case EVFLICKER: return(ltos(flickcode)); case EVCURWIDTH:return(itoa(term.t_nrow)); case EVCBUFNAME:return(curbp->b_bname); case EVCFNAME: return(curbp->b_fname); case EVSRES: return(sres); case EVDEBUG: return(ltos(macbug)); case EVSTATUS: return(ltos(cmdstatus)); case EVPALETTE: return(palstr); case EVASAVE: return(itoa(gasave)); case EVACOUNT: return(itoa(gacount)); case EVLASTKEY: return(itoa(lastkey)); case EVCURCHAR: return(itoa( lgetc(curwp->w_dotp,curwp->w_doto))); case EVDISCMD: return(ltos(discmd)); case EVVERSION: return(VERSION); case EVPROGNAME:return(PROGNAME); case EVSEED: return(itoa(seed)); case EVDISINP: return(ltos(disinp)); case EVWLINE: return(itoa(curwp->w_ntrows)); case EVCWLINE: return(itoa(getwpos())); case EVTARGET: return(itoa(curgoal)); case EVSEARCH: return(pat); case EVREPLACE: return(rpat); case EVMATCH: return((patmatch == NULL)? "": patmatch); case EVKILL: return(getkill()); } exit(-12); /* again, we should never get here */ } char *getkill() /* return some of the contents of the kill buffer */ { register int size; /* max number of chars to return */ char value[NSTRING]; /* temp buffer for value */ if (kbufh == NULL) /* no kill buffer....just a null string */ value[0] = 0; else { /* copy in the contents... */ if (kused < NSTRING) size = kused; else size = NSTRING - 1; strncpy(value, kbufh->d_chunk, size); } /* and return the constructed value */ return(value); } int setvar(f, n) /* set a variable */ int f; /* default flag */ int n; /* numeric arg (can overide prompted value) */ { register int vnum; /* ordinal number of var refrenced */ register int status; /* status return */ register int vtype; /* type of variable to set */ register int c; /* translated character */ register char * sp; /* scratch string pointer */ char var[NVSIZE+1]; /* name of variable to fetch */ char value[NSTRING]; /* value to set variable to */ /* first get the variable to set.. */ if (clexec == FALSE) { status = mlreply("Variable to set: ", &var[0], NVSIZE); if (status != TRUE) return(status); } else { /* macro line argument */ /* grab token and skip it */ execstr = token(execstr, var); } /* check the legality and find the var */ sv01: vtype = -1; switch (var[0]) { case '$': /* check for legal enviromnent var */ for (vnum = 0; vnum < NEVARS; vnum++) if (strcmp(&var[1], envars[vnum]) == 0) { vtype = TKENV; break; } break; case '%': /* check for existing legal user variable */ for (vnum = 0; vnum < MAXVARS; vnum++) if (strcmp(&var[1], uv[vnum].u_name) == 0) { vtype = TKVAR; break; } if (vnum < MAXVARS) break; /* create a new one??? */ for (vnum = 0; vnum < MAXVARS; vnum++) if (uv[vnum].u_name[0] == 0) { vtype = TKVAR; strcpy(uv[vnum].u_name, &var[1]); break; } break; case '&': /* indirect operator? */ var[4] = 0; if (strcmp(&var[1], "ind") == 0) { /* grab token, and eval it */ execstr = token(execstr, var); strcpy(var, getval(var)); goto sv01; } } /* if its not legal....bitch */ if (vtype == -1) { mlwrite("%%No such variable"); return(FALSE); } /* get the value for that variable */ if (f == TRUE) strcpy(value, itoa(n)); else { status = mlreply("Value: ", &value[0], NSTRING); if (status != TRUE) return(status); } /* and set the appropriate value */ status = TRUE; switch (vtype) { case TKVAR: /* set a user variable */ if (uv[vnum].u_value != NULL) free(uv[vnum].u_value); sp = malloc(strlen(value) + 1); if (sp == NULL) return(FALSE); strcpy(sp, value); uv[vnum].u_value = sp; break; case TKENV: /* set an environment variable */ status = TRUE; /* by default */ switch (vnum) { case EVFILLCOL: fillcol = atoi(value); break; case EVPAGELEN: status = newsize(TRUE, atoi(value)); break; case EVCURCOL: status = setccol(atoi(value)); break; case EVCURLINE: status = gotoline(TRUE, atoi(value)); break; case EVRAM: break; case EVFLICKER: flickcode = stol(value); break; case EVCURWIDTH:status = newwidth(TRUE, atoi(value)); break; case EVCBUFNAME:strcpy(curbp->b_bname, value); curwp->w_flag |= WFMODE; break; case EVCFNAME: strcpy(curbp->b_fname, value); curwp->w_flag |= WFMODE; break; case EVSRES: status = TTrez(value); break; case EVDEBUG: macbug = stol(value); break; case EVSTATUS: cmdstatus = stol(value); break; case EVPALETTE: strncpy(palstr, value, 48); spal(palstr); break; case EVASAVE: gasave = atoi(value); break; case EVACOUNT: gacount = atoi(value); break; case EVLASTKEY: lastkey = atoi(value); break; case EVCURCHAR: ldelete(1, FALSE); /* delete 1 char */ c = atoi(value); if (c == '\n') lnewline(FALSE, 1); else linsert(1, c); break; case EVDISCMD: discmd = stol(value); break; case EVVERSION: break; case EVPROGNAME:break; case EVSEED: seed = atoi(value); break; case EVDISINP: disinp = stol(value); break; case EVWLINE: status = resize(TRUE, atoi(value)); break; case EVCWLINE: status = forwline(TRUE, atoi(value) - getwpos()); break; case EVTARGET: curgoal = atoi(value); thisflag |= CFCPCN; break; case EVSEARCH: strcpy(pat, value); rvstrcpy(tap, pat); mcclear(); break; case EVREPLACE: strcpy(rpat, value); break; case EVMATCH: break; case EVKILL: break; } break; } return(status); } /* atoi: ascii string to integer......This is too inconsistant to use the system's */ atoi(st) char *st; { int result; /* resulting number */ int sign; /* sign of resulting number */ char c; /* current char being examined */ result = 0; sign = 1; /* skip preceding whitespace */ while (*st == ' ' || *st == '\t') ++st; /* check for sign */ if (*st == '-') { sign = -1; ++st; } if (*st == '+') ++st; /* scan digits, build value */ while ((c = *st++)) if (c >= '0' && c <= '9') result = result * 10 + c - '0'; else return(0); return(result * sign); } /* itoa: integer to ascii string.......... This is too inconsistant to use the system's */ char *itoa(i) int i; /* integer to translate to a string */ { register int digit; /* current digit being used */ register char *sp; /* pointer into result */ register int sign; /* sign of resulting number */ static char result[INTWIDTH+1]; /* resulting string */ /* eliminate the trivial 0 */ if (i == 0) return("0"); /* record the sign...*/ sign = 1; if (i < 0) { sign = -1; i = -i; } /* and build the string (backwards!) */ sp = result + INTWIDTH; *sp = 0; while (i) { digit = i % 10; *(--sp) = '0' + digit; /* and install the new digit */ i = i / 10; } /* and fix the sign */ if (sign == -1) { *(--sp) = '-'; /* and install the minus sign */ } return(sp); } int gettyp(token) /* find the type of a passed token */ char *token; /* token to analyze */ { register char c; /* first char in token */ /* grab the first char (this is all we need) */ c = *token; /* no blanks!!! */ if (c == 0) return(TKNUL); /* a numeric literal? */ if (c >= '0' && c <= '9') return(TKLIT); switch (c) { case '"': return(TKSTR); case '!': return(TKDIR); case '@': return(TKARG); case '#': return(TKBUF); case '$': return(TKENV); case '%': return(TKVAR); case '&': return(TKFUN); case '*': return(TKLBL); default: return(TKCMD); } } char *getval(token) /* find the value of a token */ char *token; /* token to evaluate */ { register int status; /* error return */ register BUFFER *bp; /* temp buffer pointer */ register int blen; /* length of buffer argument */ register int distmp; /* temporary discmd flag */ char pad[20]; /* pad 20 bytes on stack for safety */ char buf[NSTRING]; /* string buffer for some returns */ switch (gettyp(token)) { case TKNUL: return(""); case TKARG: /* interactive argument */ strcpy(token, getval(&token[1])); distmp = discmd; /* echo it always! */ discmd = TRUE; status = getstring(token, buf, NSTRING, ctoec('\n')); discmd = distmp; if (status == ABORT) return(errorm); return(buf); case TKBUF: /* buffer contents fetch */ /* grab the right buffer */ strcpy(token, getval(&token[1])); bp = bfind(token, FALSE, 0); if (bp == NULL) return(errorm); /* if the buffer is displayed, get the window vars instead of the buffer vars */ if (bp->b_nwnd > 0) { curbp->b_dotp = curwp->w_dotp; curbp->b_doto = curwp->w_doto; } /* make sure we are not at the end */ if (bp->b_linep == bp->b_dotp) return(errorm); /* grab the line as an argument */ blen = bp->b_dotp->l_used - bp->b_doto; if (blen > NSTRING) blen = NSTRING; strncpy(buf, bp->b_dotp->l_text + bp->b_doto, blen); buf[blen] = 0; /* and step the buffer's line ptr ahead a line */ bp->b_dotp = bp->b_dotp->l_fp; bp->b_doto = 0; /* if displayed buffer, reset window ptr vars*/ if (bp->b_nwnd > 0) { curwp->w_dotp = curbp->b_dotp; curwp->w_doto = 0; curwp->w_flag |= WFMOVE; } /* and return the spoils */ return(buf); case TKVAR: return(gtusr(token+1)); case TKENV: return(gtenv(token+1)); case TKFUN: return(gtfun(token+1)); case TKDIR: return(errorm); case TKLBL: return(itoa(gtlbl(token))); case TKLIT: return(token); case TKSTR: return(token+1); case TKCMD: return(token); } } gtlbl(token) /* find the line number of the given label */ char *token; /* label name to find */ { return(1); } int stol(val) /* convert a string to a numeric logical */ char *val; /* value to check for stol */ { /* check for logical values */ if (val[0] == 'F') return(FALSE); if (val[0] == 'T') return(TRUE); /* check for numeric truth (!= 0) */ return((atoi(val) != 0)); } char *ltos(val) /* numeric logical to string logical */ int val; /* value to translate */ { if (val) return(truem); else return(falsem); } char *mkupper(str) /* make a string upper case */ char *str; /* string to upper case */ { char *sp; sp = str; while (*sp) { if ('a' <= *sp && *sp <= 'z') *sp += 'A' - 'a'; ++sp; } return(str); } char *mklower(str) /* make a string lower case */ char *str; /* string to lower case */ { char *sp; sp = str; while (*sp) { if ('A' <= *sp && *sp <= 'Z') *sp += 'a' - 'A'; ++sp; } return(str); } int abs(x) /* take the absolute value of an integer */ int x; { return(x < 0 ? -x : x); } int ernd() /* returns a random integer */ { seed = abs(seed * 1721 + 10007); return(seed); } SHAR_EOF chmod +x 'eval.c' fi echo shar: "extracting 'evar.h'" '(0 character)' if test -f 'evar.h' then echo shar: "will not over-write existing file 'evar.h'" else cat << \SHAR_EOF > 'evar.h' /* EVAR.H: Environment and user variable definitions for MicroEMACS written 1986 by Daniel Lawrence */ /* structure to hold user variables and their definitions */ typedef struct UVAR { char u_name[NVSIZE + 1]; /* name of user variable */ char *u_value; /* value (string) */ } UVAR; /* current user variables (This structure will probably change) */ #define MAXVARS 100 UVAR uv[MAXVARS]; /* user variables */ /* list of recognized environment variables */ char *envars[] = { "fillcol", /* current fill column */ "pagelen", /* number of lines used by editor */ "curcol", /* current column pos of cursor */ "curline", /* current line in file */ "ram", /* ram in use by malloc */ "flicker", /* flicker supression */ "curwidth", /* current screen width */ "cbufname", /* current buffer name */ "cfname", /* current file name */ "sres", /* current screen resolution */ "debug", /* macro debugging */ "status", /* returns the status of the last command */ "palette", /* current palette string */ "asave", /* # of chars between auto-saves */ "acount", /* # of chars until next auto-save */ "lastkey", /* last keyboard char struck */ "curchar", /* current character under the cursor */ "discmd", /* display commands on command line */ "version", /* current version number */ "progname", /* returns current prog name - "MicroEMACS" */ "seed", /* current random number seed */ "disinp", /* display command line input characters */ "wline", /* # of lines in current window */ "cwline", /* current screen line in window */ "target", /* target for line moves */ "search", /* search pattern */ "replace", /* replacement pattern */ "match", /* last matched magic pattern */ "kill", /* kill buffer (read only) */ }; #define NEVARS sizeof(envars) / sizeof(char *) /* and its preprocesor definitions */ #define EVFILLCOL 0 #define EVPAGELEN 1 #define EVCURCOL 2 #define EVCURLINE 3 #define EVRAM 4 #define EVFLICKER 5 #define EVCURWIDTH 6 #define EVCBUFNAME 7 #define EVCFNAME 8 #define EVSRES 9 #define EVDEBUG 10 #define EVSTATUS 11 #define EVPALETTE 12 #define EVASAVE 13 #define EVACOUNT 14 #define EVLASTKEY 15 #define EVCURCHAR 16 #define EVDISCMD 17 #define EVVERSION 18 #define EVPROGNAME 19 #define EVSEED 20 #define EVDISINP 21 #define EVWLINE 22 #define EVCWLINE 23 #define EVTARGET 24 #define EVSEARCH 25 #define EVREPLACE 26 #define EVMATCH 27 #define EVKILL 28 /* list of recognized user functions */ typedef struct UFUNC { char *f_name; /* name of function */ int f_type; /* 1 = monamic, 2 = dynamic */ } UFUNC; #define NILNAMIC 0 #define MONAMIC 1 #define DYNAMIC 2 #define TRINAMIC 3 UFUNC funcs[] = { "add", DYNAMIC, /* add two numbers together */ "sub", DYNAMIC, /* subtraction */ "tim", DYNAMIC, /* multiplication */ "div", DYNAMIC, /* division */ "mod", DYNAMIC, /* mod */ "neg", MONAMIC, /* negate */ "cat", DYNAMIC, /* concatinate string */ "lef", DYNAMIC, /* left string(string, len) */ "rig", DYNAMIC, /* right string(string, pos) */ "mid", TRINAMIC, /* mid string(string, pos, len) */ "not", MONAMIC, /* logical not */ "equ", DYNAMIC, /* logical equality check */ "les", DYNAMIC, /* logical less than */ "gre", DYNAMIC, /* logical greater than */ "seq", DYNAMIC, /* string logical equality check */ "sle", DYNAMIC, /* string logical less than */ "sgr", DYNAMIC, /* string logical greater than */ "ind", MONAMIC, /* evaluate indirect value */ "and", DYNAMIC, /* logical and */ "or", DYNAMIC, /* logical or */ "len", MONAMIC, /* string length */ "upp", MONAMIC, /* uppercase string */ "low", MONAMIC, /* lower case string */ "tru", MONAMIC, /* Truth of the universe logical test */ "asc", MONAMIC, /* char to integer conversion */ "chr", MONAMIC, /* integer to char conversion */ "gtk", NILNAMIC, /* get 1 charater */ "rnd", MONAMIC, /* get a random number */ "abs", MONAMIC, /* absolute value of a number */ }; #define NFUNCS sizeof(funcs) / sizeof(UFUNC) /* and its preprocesor definitions */ #define UFADD 0 #define UFSUB 1 #define UFTIMES 2 #define UFDIV 3 #define UFMOD 4 #define UFNEG 5 #define UFCAT 6 #define UFLEFT 7 #define UFRIGHT 8 #define UFMID 9 #define UFNOT 10 #define UFEQUAL 11 #define UFLESS 12 #define UFGREATER 13 #define UFSEQUAL 14 #define UFSLESS 15 #define UFSGREAT 16 #define UFIND 17 #define UFAND 18 #define UFOR 19 #define UFLENGTH 20 #define UFUPPER 21 #define UFLOWER 22 #define UFTRUTH 23 #define UFASCII 24 #define UFCHR 25 #define UFGTKEY 26 #define UFRND 27 #define UFABS 28 SHAR_EOF chmod +x 'evar.h' fi exit 0 # End of shell archive,