Lots of ANSI'fication and cleanups

Still tons of warnings with "-Wall", but now it's actually getting closer.

It even compiles again.
This commit is contained in:
Linus Torvalds 2005-09-30 22:52:45 -07:00
parent 92803fe8d5
commit d5dc3160cf
26 changed files with 1151 additions and 1139 deletions

View File

@ -12,6 +12,7 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
/*
* Move the cursor to the

3
bind.c
View File

@ -10,6 +10,7 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
#include "epath.h"
int help(int f, int n)
@ -443,7 +444,7 @@ unsigned int getckey(int mflag)
*
* char *sfname; name of startup file (null if default)
*/
startup(char *sfname)
int startup(char *sfname)
{
char *fname; /* resulting file name to execute */

View File

@ -12,6 +12,7 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
/*
* Attach a buffer to a window. The

28
crypt.c
View File

@ -8,16 +8,19 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
#if CRYPT
static int mod95();
setkey(f, n)
/* reset encryption key of current buffer */
int f; /* default flag */
int n; /* numeric argument */
/*
* reset encryption key of current buffer
*
* int f; default flag
* int n; numeric argument
*/
int setkey(int f, int n)
{
register int status; /* return status */
int odisinp; /* original vlaue of disinp */
@ -134,11 +137,13 @@ int n; /* numeric argument */
* protection and security of the keys themselves are the
* responsiblity of the user.
*
*
* char *bptr; buffer of characters to be encrypted
* unsigned len; number of characters in the buffer
*
**********/
crypt(bptr, len)
register char *bptr; /* buffer of characters to be encrypted */
register unsigned len; /* number of characters in the buffer */
void crypt(char *bptr, unsigned len)
{
register int cc; /* current character being considered */
@ -194,10 +199,7 @@ register unsigned len; /* number of characters in the buffer */
return;
}
static int mod95(val)
register int val;
static int mod95(int val)
{
/* The mathematical MOD does not match the computer MOD */
@ -215,7 +217,7 @@ register int val;
return (val);
}
#else
nocrypt()
static void nocrypt(void)
{
}
#endif

View File

@ -13,6 +13,7 @@
#include <stdarg.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
typedef struct VIDEO {
int v_flag; /* Flags */

226
edef.h
View File

@ -318,229 +318,3 @@ extern char outline[]; /* global string to hold debug line text */
#ifndef termdef
extern TERM term; /* Terminal information. */
#endif
/* word.c */
extern int wrapword(int f, int n);
extern int backword(int f, int n);
extern int forwword(int f, int n);
extern int upperword(int f, int n);
extern int lowerword(int f, int n);
extern int capword(int f, int n);
extern int delfword(int f, int n);
extern int delbword(int f, int n);
extern int inword(void);
extern int fillpara(int f, int n);
extern int justpara(int f, int n);
extern int killpara(int f, int n);
extern int wordcount(int f, int n);
/* line.c */
extern int lfree(LINE *lp);
extern int lchange(int flag);
extern int insspace(int f, int n);
extern int linstr(char *instr);
extern int linsert(int n, int c);
extern int lowrite(int c);
extern int lover(char *ostr);
extern int lnewline(void);
extern int ldelete(long n, int kflag);
extern char *getctext(void);
extern int putctext(char *iline);
extern int ldelnewline(void);
extern int kdelete(void);
extern int kinsert(int c);
extern int yank(int f, int n);
/* window.c */
extern int reposition(int f, int n);
extern int refresh(int f, int n);
extern int nextwind(int f, int n);
extern int prevwind(int f, int n);
extern int mvdnwind(int f, int n);
extern int mvupwind(int f, int n);
extern int onlywind(int f, int n);
extern int delwind(int f, int n);
extern int splitwind(int f, int n);
extern int enlargewind(int f, int n);
extern int shrinkwind(int f, int n);
extern int resize(int f, int n);
extern int scrnextup(int f, int n);
extern int scrnextdw(int f, int n);
extern int savewnd(int f, int n);
extern int restwnd(int f, int n);
extern int newsize(int f, int n);
extern int newwidth(int f, int n);
extern int getwpos(void);
extern int cknewwindow(void);
/* basic.c */
extern int gotobol(int f, int n);
extern int backchar(int f, int n);
extern int gotoeol(int f, int n);
extern int forwchar(int f, int n);
extern int gotoline(int f, int n);
extern int gotobob(int f, int n);
extern int gotoeob(int f, int n);
extern int forwline(int f, int n);
extern int backline(int f, int n);
extern int gotobop(int f, int n);
extern int gotoeop(int f, int n);
extern int getgoal(LINE *dlp);
extern int forwpage(int f, int n);
extern int backpage(int f, int n);
extern int setmark(int f, int n);
extern int swapmark(int f, int n);
/* random.c */
extern int tabsize; /* Tab size (0: use real tabs) */;
extern int setfillcol(int f, int n);
extern int showcpos(int f, int n);
extern int getcline(void);
extern int getccol(int bflg);
extern int setccol(int pos);
extern int twiddle(int f, int n);
extern int quote(int f, int n);
extern int tab(int f, int n);
extern int detab(int f, int n);
extern int entab(int f, int n);
extern int trim(int f, int n);
extern int openline(int f, int n);
extern int newline(int f, int n);
extern int cinsert(void);
extern int insbrace(int n, int c);
extern int insbrace(int n, int c);
extern int inspound(void);
extern int deblank(int f, int n);
extern int indent(int f, int n);
extern int forwdel(int f, int n);
extern int backdel(int f, int n);
extern int killtext(int f, int n);
extern int setmode(int f, int n);
extern int delmode(int f, int n);
extern int setgmode(int f, int n);
extern int delgmode(int f, int n);
extern int adjustmode(int kind, int global);
extern int clrmes(int f, int n);
extern int writemsg(int f, int n);
extern int getfence(int f, int n);
extern int fmatch(int ch);
extern int istring(int f, int n);
extern int ovstring(int f, int n);
/* main.c */
extern int edinit(char *bname);
extern int execute(int c, int f, int n);
extern int quickexit(int f, int n);
extern int quit(int f, int n);
extern int ctlxlp(int f, int n);
extern int ctlxrp(int f, int n);
extern int ctlxe(int f, int n);
extern int ctrlg(int f, int n);
extern int rdonly(void);
extern int resterr(void);
extern int nullproc(int f, int n);
extern int meta(int f, int n);
extern int cex(int f, int n);
extern int unarg(int f, int n);
extern int cexit(int status);
/* display.c */
extern void vtinit(void);
extern void vtfree(void);
extern void vttidy(void);
extern void vtmove(int row, int col);
extern void vtputc(int c);
extern void vteeol(void);
extern int upscreen(int f, int n);
extern int update(int force);
extern int reframe(WINDOW *wp);
extern void updone(WINDOW *wp);
extern void updall(WINDOW *wp);
extern void updpos(void);
extern void upddex(void);
extern void updgar(void);
extern int updupd(int force);
extern int scrolls(int inserts);
extern void scrscroll(int from, int to, int count);
extern int texttest(int vrow, int prow);
extern int endofline(char *s, int n);
extern void updext(void);
extern int updateline(int row, struct VIDEO *vp1, struct VIDEO *vp2);
extern void modeline(WINDOW *wp);
extern void upmode(void);
extern void movecursor(int row, int col);
extern void mlerase(void);
extern void mlwrite(const char *fmt, ...);
extern void mlforce(char *s);
extern void mlputs(char *s);
extern void mlputi(int i, int r);
extern void mlputli(long l, int r);
extern void mlputf(int s);
extern void putline(int row, int col, char *buf);
extern void getscreensize(int *widthp, int *heightp);
extern void sizesignal(int signr);
extern int newscreensize(int h, int w);
/* region.c */
extern int killregion(int f, int n);
extern int copyregion(int f, int n);
extern int lowerregion(int f, int n);
extern int upperregion(int f, int n);
extern int getregion(REGION *rp);
/* posix.c */
extern void ttopen(void);
extern void ttclose(void);
extern int ttputc(int c);
extern void ttflush(void);
extern int ttgetc(void);
extern int typahead(void);
/* input.c */
extern int mlyesno(char *prompt);
extern int mlreply(char *prompt, char *buf, int nbuf);
extern int mlreplyt(char *prompt, char *buf, int nbuf, int eolchar);
extern int ectoc(int c);
extern int ctoec(int c);
extern fn_t getname(void);
extern int tgetc(void);
extern int get1key(void);
extern int getcmd(void);
extern int getstring(char *prompt, char *buf, int nbuf, int eolchar);
extern void outstring(char *s);
extern void ostring(char *s);
/* bind.c */
extern int help(int f, int n);
extern int deskey(int f, int n);
extern int bindtokey(int f, int n);
extern int unbindkey(int f, int n);
extern int unbindchar(int c);
extern int desbind(int f, int n);
extern int apro(int f, int n);
extern int buildlist(int type, char *mstring);
extern int strinc(char *source, char *sub);
extern unsigned int getckey(int mflag);
extern startup(char *sfname);
extern char *flook(char *fname, int hflag);
extern void cmdstr(int c, char *seq);
extern fn_t getbind(int c);
extern char *getfname(fn_t);
extern fn_t fncmatch(char *);
extern unsigned int stock(char *keyname);
extern char *transbind(char *skey);
/* buffer.c */
extern int usebuffer(int f, int n);
extern int nextbuffer(int f, int n);
extern int swbuffer(BUFFER *bp);
extern int killbuffer(int f, int n);
extern int zotbuf(BUFFER *bp);
extern int namebuffer(int f, int n);
extern int listbuffers(int f, int n);
extern int makelist(int iflag);
extern void ltoa(char *buf, int width, long num);
extern int addline(char *text);
extern int anycb(void);
extern int bclear(BUFFER *bp);
extern int unmark(int f, int n);

790
efunc.h
View File

@ -12,420 +12,386 @@
/* 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 | __hpux | SVR4
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 */
#if PKCODE
extern int justpara(); /* justify current paragraph */
#endif
#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 FNLABEL
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... */
extern int ovstring(); /* overwrite a string */
extern int execprg(); /* execute a program */
/* word.c */
extern int wrapword(int f, int n);
extern int backword(int f, int n);
extern int forwword(int f, int n);
extern int upperword(int f, int n);
extern int lowerword(int f, int n);
extern int capword(int f, int n);
extern int delfword(int f, int n);
extern int delbword(int f, int n);
extern int inword(void);
extern int fillpara(int f, int n);
extern int justpara(int f, int n);
extern int killpara(int f, int n);
extern int wordcount(int f, int n);
extern int cknewwindow();
/* line.c */
extern int lfree(LINE *lp);
extern int lchange(int flag);
extern int insspace(int f, int n);
extern int linstr(char *instr);
extern int linsert(int n, int c);
extern int lowrite(int c);
extern int lover(char *ostr);
extern int lnewline(void);
extern int ldelete(long n, int kflag);
extern char *getctext(void);
extern int putctext(char *iline);
extern int ldelnewline(void);
extern int kdelete(void);
extern int kinsert(int c);
extern int yank(int f, int n);
/* Name to function binding table
/* window.c */
extern int reposition(int f, int n);
extern int refresh(int f, int n);
extern int nextwind(int f, int n);
extern int prevwind(int f, int n);
extern int mvdnwind(int f, int n);
extern int mvupwind(int f, int n);
extern int onlywind(int f, int n);
extern int delwind(int f, int n);
extern int splitwind(int f, int n);
extern int enlargewind(int f, int n);
extern int shrinkwind(int f, int n);
extern int resize(int f, int n);
extern int scrnextup(int f, int n);
extern int scrnextdw(int f, int n);
extern int savewnd(int f, int n);
extern int restwnd(int f, int n);
extern int newsize(int f, int n);
extern int newwidth(int f, int n);
extern int getwpos(void);
extern void cknewwindow(void);
This table gives the names of all the bindable functions
end their C function address. These are used for the bind-to-key
function.
*/
/* basic.c */
extern int gotobol(int f, int n);
extern int backchar(int f, int n);
extern int gotoeol(int f, int n);
extern int forwchar(int f, int n);
extern int gotoline(int f, int n);
extern int gotobob(int f, int n);
extern int gotoeob(int f, int n);
extern int forwline(int f, int n);
extern int backline(int f, int n);
extern int gotobop(int f, int n);
extern int gotoeop(int f, int n);
extern int getgoal(LINE *dlp);
extern int forwpage(int f, int n);
extern int backpage(int f, int n);
extern int setmark(int f, int n);
extern int swapmark(int f, int n);
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
{"execute-program", execprg},
{"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
#if PKCODE
{"justify-paragraph", justpara},
#endif
{"kill-paragraph", killpara},
#endif
{"kill-region", killregion},
{"kill-to-end-of-line", killtext},
#if FNLABEL
{"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},
{"overwrite-string", ovstring},
{"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 | __hpux | SVR4
{"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},
/* random.c */
extern int tabsize; /* Tab size (0: use real tabs) */;
extern int setfillcol(int f, int n);
extern int showcpos(int f, int n);
extern int getcline(void);
extern int getccol(int bflg);
extern int setccol(int pos);
extern int twiddle(int f, int n);
extern int quote(int f, int n);
extern int tab(int f, int n);
extern int detab(int f, int n);
extern int entab(int f, int n);
extern int trim(int f, int n);
extern int openline(int f, int n);
extern int newline(int f, int n);
extern int cinsert(void);
extern int insbrace(int n, int c);
extern int inspound(void);
extern int deblank(int f, int n);
extern int indent(int f, int n);
extern int forwdel(int f, int n);
extern int backdel(int f, int n);
extern int killtext(int f, int n);
extern int setmode(int f, int n);
extern int delmode(int f, int n);
extern int setgmode(int f, int n);
extern int delgmode(int f, int n);
extern int adjustmode(int kind, int global);
extern int clrmes(int f, int n);
extern int writemsg(int f, int n);
extern int getfence(int f, int n);
extern int fmatch(int ch);
extern int istring(int f, int n);
extern int ovstring(int f, int n);
{"", NULL}
};
/* main.c */
extern int edinit(char *bname);
extern int execute(int c, int f, int n);
extern int quickexit(int f, int n);
extern int quit(int f, int n);
extern int ctlxlp(int f, int n);
extern int ctlxrp(int f, int n);
extern int ctlxe(int f, int n);
extern int ctrlg(int f, int n);
extern int rdonly(void);
extern int resterr(void);
extern int nullproc(int f, int n);
extern int meta(int f, int n);
extern int cex(int f, int n);
extern int unarg(int f, int n);
extern int cexit(int status);
/* display.c */
extern void vtinit(void);
extern void vtfree(void);
extern void vttidy(void);
extern void vtmove(int row, int col);
extern void vtputc(int c);
extern void vteeol(void);
extern int upscreen(int f, int n);
extern int update(int force);
extern int reframe(WINDOW *wp);
extern void updone(WINDOW *wp);
extern void updall(WINDOW *wp);
extern void updpos(void);
extern void upddex(void);
extern void updgar(void);
extern int updupd(int force);
extern int scrolls(int inserts);
extern void scrscroll(int from, int to, int count);
extern int texttest(int vrow, int prow);
extern int endofline(char *s, int n);
extern void updext(void);
extern int updateline(int row, struct VIDEO *vp1, struct VIDEO *vp2);
extern void modeline(WINDOW *wp);
extern void upmode(void);
extern void movecursor(int row, int col);
extern void mlerase(void);
extern void mlwrite(const char *fmt, ...);
extern void mlforce(char *s);
extern void mlputs(char *s);
extern void mlputi(int i, int r);
extern void mlputli(long l, int r);
extern void mlputf(int s);
extern void putline(int row, int col, char *buf);
extern void getscreensize(int *widthp, int *heightp);
extern void sizesignal(int signr);
extern int newscreensize(int h, int w);
/* region.c */
extern int killregion(int f, int n);
extern int copyregion(int f, int n);
extern int lowerregion(int f, int n);
extern int upperregion(int f, int n);
extern int getregion(REGION *rp);
/* posix.c */
extern void ttopen(void);
extern void ttclose(void);
extern int ttputc(int c);
extern void ttflush(void);
extern int ttgetc(void);
extern int typahead(void);
/* input.c */
extern int mlyesno(char *prompt);
extern int mlreply(char *prompt, char *buf, int nbuf);
extern int mlreplyt(char *prompt, char *buf, int nbuf, int eolchar);
extern int ectoc(int c);
extern int ctoec(int c);
extern fn_t getname(void);
extern int tgetc(void);
extern int get1key(void);
extern int getcmd(void);
extern int getstring(char *prompt, char *buf, int nbuf, int eolchar);
extern void outstring(char *s);
extern void ostring(char *s);
/* bind.c */
extern int help(int f, int n);
extern int deskey(int f, int n);
extern int bindtokey(int f, int n);
extern int unbindkey(int f, int n);
extern int unbindchar(int c);
extern int desbind(int f, int n);
extern int apro(int f, int n);
extern int buildlist(int type, char *mstring);
extern int strinc(char *source, char *sub);
extern unsigned int getckey(int mflag);
extern int startup(char *sfname);
extern char *flook(char *fname, int hflag);
extern void cmdstr(int c, char *seq);
extern fn_t getbind(int c);
extern char *getfname(fn_t);
extern fn_t fncmatch(char *);
extern unsigned int stock(char *keyname);
extern char *transbind(char *skey);
/* buffer.c */
extern int usebuffer(int f, int n);
extern int nextbuffer(int f, int n);
extern int swbuffer(BUFFER *bp);
extern int killbuffer(int f, int n);
extern int zotbuf(BUFFER *bp);
extern int namebuffer(int f, int n);
extern int listbuffers(int f, int n);
extern int makelist(int iflag);
extern void ltoa(char *buf, int width, long num);
extern int addline(char *text);
extern int anycb(void);
extern int bclear(BUFFER *bp);
extern int unmark(int f, int n);
/* file.c */
extern int fileread(int f, int n);
extern int insfile(int f, int n);
extern int filefind(int f, int n);
extern int viewfile(int f, int n);
extern int resetkey(void);
extern int getfile(char *fname, int lockfl);
extern int readin(char *fname, int lockfl);
extern void makename(char *bname, char *fname);
extern void unqname(char *name);
extern int filewrite(int f, int n);
extern int filesave(int f, int n);
extern int writeout(char *fn);
extern int filename(int f, int n);
extern int ifile(char *fname);
/* fileio.c */
extern int ffropen(char *fn);
extern int ffwopen(char *fn);
extern int ffclose(void);
extern int ffputline(char *buf, int nbuf);
extern int ffgetline(void);
extern int fexist(char *fname);
/* exec.c */
extern int namedcmd(int f, int n);
extern int execcmd(int f, int n);
extern int docmd(char *cline);
extern char *token(char *src, char *tok, int size);
extern int macarg(char *tok);
extern int nextarg(char *prompt, char *buffer, int size, int terminator);
extern int storemac(int f, int n);
extern int storeproc(int f, int n);
extern int execproc(int f, int n);
extern int execbuf(int f, int n);
extern int dobuf(BUFFER *bp);
extern int freewhile(WHBLOCK *wp);
extern int execfile(int f, int n);
extern int dofile(char *fname);
extern int cbuf(int f, int n, int bufnum);
extern int cbuf1(int f, int n);
extern int cbuf2(int f, int n);
extern int cbuf3(int f, int n);
extern int cbuf4(int f, int n);
extern int cbuf5(int f, int n);
extern int cbuf6(int f, int n);
extern int cbuf7(int f, int n);
extern int cbuf8(int f, int n);
extern int cbuf9(int f, int n);
extern int cbuf10(int f, int n);
extern int cbuf11(int f, int n);
extern int cbuf12(int f, int n);
extern int cbuf13(int f, int n);
extern int cbuf14(int f, int n);
extern int cbuf15(int f, int n);
extern int cbuf16(int f, int n);
extern int cbuf17(int f, int n);
extern int cbuf18(int f, int n);
extern int cbuf19(int f, int n);
extern int cbuf20(int f, int n);
extern int cbuf21(int f, int n);
extern int cbuf22(int f, int n);
extern int cbuf23(int f, int n);
extern int cbuf24(int f, int n);
extern int cbuf25(int f, int n);
extern int cbuf26(int f, int n);
extern int cbuf27(int f, int n);
extern int cbuf28(int f, int n);
extern int cbuf29(int f, int n);
extern int cbuf30(int f, int n);
extern int cbuf31(int f, int n);
extern int cbuf32(int f, int n);
extern int cbuf33(int f, int n);
extern int cbuf34(int f, int n);
extern int cbuf35(int f, int n);
extern int cbuf36(int f, int n);
extern int cbuf37(int f, int n);
extern int cbuf38(int f, int n);
extern int cbuf39(int f, int n);
extern int cbuf40(int f, int n);
/* spawn.c */
extern int spawncli(int f, int n);
extern void bktoshell(void);
extern void rtfrmshell(void);
extern int spawn(int f, int n);
extern int execprg(int f, int n);
extern int pipecmd(int f, int n);
extern int filter(int f, int n);
extern int sys(char *cmd);
extern int shellprog(char *cmd);
extern int execprog(char *cmd);
/* search.c */
extern int forwsearch(int f, int n);
extern int forwhunt(int f, int n);
extern int backsearch(int f, int n);
extern int backhunt(int f, int n);
extern int mcscanner(MC *mcpatrn, int direct, int beg_or_end);
extern int scanner(unsigned char *patrn, int direct, int beg_or_end);
extern int eq(unsigned char bc, unsigned char pc);
extern void savematch(void);
extern void rvstrcpy(char *rvstr, char *str);
extern int sreplace(int f, int n);
extern int qreplace(int f, int n);
extern int delins(int dlength, char *instr, int use_meta);
extern int expandp(char *srcstr, char *deststr, int maxlength);
extern int boundry(LINE *curline, int curoff, int dir);
extern void mcclear(void);
extern void rmcclear(void);
/* isearch.c */
extern int risearch(int f, int n);
extern int fisearch(int f, int n);
extern int isearch(int f, int n);
extern int checknext(char chr, char *patrn, int dir);
extern int scanmore(char *patrn, int dir);
extern int match_pat(char *patrn);
extern int promptpattern(char *prompt);
extern int echochar(int c, int col);
extern int get_char(void);
extern int uneat(void);
extern int reeat(int c);
/* eval.c */
extern void varinit(void);
extern char *gtfun(char *fname);
extern char *gtusr(char *vname);
extern char *gtenv(char *vname);
extern char *getkill(void);
extern int setvar(int f, int n);
extern void findvar(char *var, VDESC *vd, int size);
extern int svar(VDESC *var, char *value);
extern char *itoa(int i);
extern int gettyp(char *token);
extern char *getval(char *token);
extern int stol(char *val);
extern char *ltos(int val);
extern char *mkupper(char *str);
extern char *mklower(char *str);
extern int abs(int x);
extern int ernd(void);
extern int sindex(char *source, char *pattern);
extern char *xlat(char *source, char *lookup, char *trans);
/* crypt.c */
extern int setkey(int f, int n);
extern void crypt(char *bptr, unsigned len);
/* lock.c */
extern int lockchk(char *fname);
extern int lockrel(void);
extern int lock(char *fname);
extern int unlock(char *fname);
extern void lckerror(char *errstr);
/* names.c */
extern NBIND names[];

View File

@ -608,7 +608,7 @@ typedef struct {
typedef struct {
char *n_name; /* name of function key */
int (*n_func) (); /* function name is bound to */
int (*n_func)(int, int);/* function name is bound to */
} NBIND;
/* The editor holds deleted text chunks in the KILL buffer. The

195
eval.c
View File

@ -9,9 +9,10 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
#include "evar.h"
varinit()
void varinit(void)
{ /* initialize the user variable list */
register int i;
@ -19,10 +20,12 @@ varinit()
uv[i].u_name[0] = 0;
}
char *gtfun(fname)
/* evaluate a function */
char *fname; /* name of function to evaluate */
/*
* evaluate a function
*
* char *fname; name of function to evaluate
*/
char *gtfun(char *fname)
{
register int fnum; /* index to function to eval */
register int status; /* return status */
@ -164,10 +167,12 @@ char *fname; /* name of function to evaluate */
exit(-11); /* never should get here */
}
char *gtusr(vname)
/* look up a user var's value */
char *vname; /* name of user variable to fetch */
/*
* look up a user var's value
*
* char *vname; name of user variable to fetch
*/
char *gtusr(char *vname)
{
register int vnum; /* ordinal number of user var */
@ -184,10 +189,13 @@ char *vname; /* name of user variable to fetch */
return (errorm);
}
char *gtenv(vname)
char *vname; /* name of environment variable to retrieve */
/*
* gtenv()
*
* char *vname; name of environment variable to retrieve
*/
char *gtenv(char *vname)
{
register int vnum; /* ordinal number of var refrenced */
char *getkill();
@ -313,8 +321,11 @@ char *vname; /* name of environment variable to retrieve */
exit(-12); /* again, we should never get here */
}
char *getkill()
{ /* return some of the contents of the kill buffer */
/*
* return some of the contents of the kill buffer
*/
char *getkill(void)
{
register int size; /* max number of chars to return */
static char value[NSTRING]; /* temp buffer for value */
@ -334,11 +345,13 @@ char *getkill()
return (value);
}
int setvar(f, n)
/* set a variable */
int f; /* default flag */
int n; /* numeric arg (can overide prompted value) */
/*
* set a variable
*
* int f; default flag
* int n; numeric arg (can overide prompted value)
*/
int setvar(int f, int n)
{
register int status; /* status return */
#if DEBUGM
@ -432,12 +445,14 @@ int n; /* numeric arg (can overide prompted value) */
return (status);
}
findvar(var, vd, size)
/* find a variables type and name */
char *var; /* name of var to get */
VDESC *vd; /* structure to hold type and ptr */
int size; /* size of var array */
/*
* find a variables type and name
*
* char *var; name of var to get
* VDESC *vd; structure to hold type and ptr
* int size; size of var array
*/
void findvar(char *var, VDESC *vd, int size)
{
register int vnum; /* subscript in varable arrays */
register int vtype; /* type to return */
@ -487,11 +502,13 @@ int size; /* size of var array */
return;
}
int svar(var, value)
/* set a variable */
VDESC *var; /* variable to set */
char *value; /* value to set to */
/*
* set a variable
*
* VDESC *var; variable to set
* char *value; value to set to
*/
int svar(VDESC *var, char *value)
{
register int vnum; /* ordinal number of var refrenced */
register int vtype; /* type of variable to set */
@ -660,13 +677,14 @@ char *value; /* value to set to */
return (status);
}
/* 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 */
/*
* itoa:
* integer to ascii string.......... This is too
* inconsistant to use the system's
*
* int i; integer to translate to a string
*/
char *itoa(int i)
{
register int digit; /* current digit being used */
register char *sp; /* pointer into result */
@ -697,10 +715,12 @@ int i; /* integer to translate to a string */
return (sp);
}
int gettyp(token)
/* find the type of a passed token */
char *token; /* token to analyze */
/*
* find the type of a passed token
*
* char *token; token to analyze
*/
int gettyp(char *token)
{
register char c; /* first char in token */
@ -739,10 +759,12 @@ char *token; /* token to analyze */
}
}
char *getval(token)
/* find the value of a token */
char *token; /* token to evaluate */
/*
* find the value of a token
*
* char *token; token to evaluate
*/
char *getval(char *token)
{
register int status; /* error return */
register BUFFER *bp; /* temp buffer pointer */
@ -823,10 +845,12 @@ char *token; /* token to evaluate */
}
}
int stol(val)
/* convert a string to a numeric logical */
char *val; /* value to check for stol */
/*
* convert a string to a numeric logical
*
* char *val; value to check for stol
*/
int stol(char *val)
{
/* check for logical values */
if (val[0] == 'F')
@ -838,10 +862,12 @@ char *val; /* value to check for stol */
return ((atoi(val) != 0));
}
char *ltos(val)
/* numeric logical to string logical */
int val; /* value to translate */
/*
* numeric logical to string logical
*
* int val; value to translate
*/
char *ltos(int val)
{
if (val)
return (truem);
@ -849,10 +875,12 @@ int val; /* value to translate */
return (falsem);
}
char *mkupper(str)
/* make a string upper case */
char *str; /* string to upper case */
/*
* make a string upper case
*
* char *str; string to upper case
*/
char *mkupper(char *str)
{
char *sp;
@ -865,10 +893,12 @@ char *str; /* string to upper case */
return (str);
}
char *mklower(str)
/* make a string lower case */
char *str; /* string to lower case */
/*
* make a string lower case
*
* char *str; string to lower case
*/
char *mklower(char *str)
{
char *sp;
@ -881,25 +911,30 @@ char *str; /* string to lower case */
return (str);
}
int abs(x)
/* take the absolute value of an integer */
int x;
/*
* take the absolute value of an integer
*/
int abs(int x)
{
return (x < 0 ? -x : x);
}
int ernd()
{ /* returns a random integer */
/*
* returns a random integer
*/
int ernd(void)
{
seed = abs(seed * 1721 + 10007);
return (seed);
}
int sindex(source, pattern)
/* find pattern within source */
char *source; /* source string to search */
char *pattern; /* string to look for */
/*
* find pattern within source
*
* char *source; source string to search
* char *pattern; string to look for
*/
int sindex(char *source, char *pattern)
{
char *sp; /* ptr to current position to scan */
char *csp; /* ptr to source string during comparison */
@ -928,14 +963,14 @@ char *pattern; /* string to look for */
return (0);
}
/* Filter a string through a translation table */
char *xlat(source, lookup, trans)
char *source; /* string to filter */
char *lookup; /* characters to translate */
char *trans; /* resulting translated characters */
/*
* Filter a string through a translation table
*
* char *source; string to filter
* char *lookup; characters to translate
* char *trans; resulting translated characters
*/
char *xlat(char *source, char *lookup, char *trans)
{
register char *sp; /* pointer into source table */
register char *lp; /* pointer into lookup table */

343
exec.c
View File

@ -10,13 +10,15 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
/* namedcmd: execute a named command even if it is not bound */
namedcmd(f, n)
int f, n; /* command arguments [passed through to command executed] */
/*
* namedcmd:
* execute a named command even if it is not bound
*
* int f, n; command arguments [passed through to command executed]
*/
int namedcmd(int f, int n)
{
register int (*kfunc) (); /* ptr to the requexted function to bind to */
int (*getname()) ();
@ -35,13 +37,14 @@ int f, n; /* command arguments [passed through to command executed] */
return ((*kfunc) (f, n));
}
/* execcmd: Execute a command line command to be typed in
by the user */
execcmd(f, n)
int f, n; /* default Flag and Numeric argument */
/*
* execcmd:
* Execute a command line command to be typed in
* by the user
*
* int f, n; default Flag and Numeric argument
*/
int execcmd(int f, int n)
{
register int status; /* status return */
char cmdstr[NSTRING]; /* string holding command to execute */
@ -54,21 +57,20 @@ int f, n; /* default Flag and Numeric argument */
return (docmd(cmdstr));
}
/* docmd: take a passed string as a command line and translate
it to be executed as a command. This function will be
used by execute-command-line and by all source and
startup files. Lastflag/thisflag is also updated.
format of the command line is:
{# arg} <command-name> {<argument string(s)>}
*/
docmd(cline)
char *cline; /* command line to execute */
/*
* docmd:
* take a passed string as a command line and translate
* it to be executed as a command. This function will be
* used by execute-command-line and by all source and
* startup files. Lastflag/thisflag is also updated.
*
* format of the command line is:
*
* {# arg} <command-name> {<argument string(s)>}
*
* char *cline; command line to execute
*/
int docmd(char *cline)
{
register int f; /* default argument flag */
register int n; /* numeric repeat value */
@ -127,15 +129,15 @@ char *cline; /* command line to execute */
return (status);
}
/* token: chop a token off a string
return a pointer past the token
*/
char *token(src, tok, size)
char *src, *tok; /* source string, destination token string */
int size; /* maximum size of token */
/*
* token:
* chop a token off a string
* return a pointer past the token
*
* char *src, *tok; source string, destination token string
* int size; maximum size of token
*/
char *token(char *src, char *tok, int size)
{
register int quotef; /* is the current string quoted? */
register char c; /* temporary character */
@ -202,10 +204,12 @@ int size; /* maximum size of token */
return (src);
}
macarg(tok)
/* get a macro line argument */
char *tok; /* buffer to place argument */
/*
* get a macro line argument
*
* char *tok; buffer to place argument
*/
int macarg(char *tok)
{
int savcle; /* buffer to store original clexec */
int status;
@ -217,15 +221,16 @@ char *tok; /* buffer to place argument */
return (status);
}
/* nextarg: get the next argument */
nextarg(prompt, buffer, size, terminator)
char *prompt; /* prompt to use if we must be interactive */
char *buffer; /* buffer to put token into */
int size; /* size of the buffer */
int terminator; /* terminating char to be used on interactive fetch */
/*
* nextarg:
* get the next argument
*
* char *prompt; prompt to use if we must be interactive
* char *buffer; buffer to put token into
* int size; size of the buffer
* int terminator; terminating char to be used on interactive fetch
*/
int nextarg(char *prompt, char *buffer, int size, int terminator)
{
/* if we are interactive, go get it! */
if (clexec == FALSE)
@ -239,14 +244,15 @@ int terminator; /* terminating char to be used on interactive fetch */
return (TRUE);
}
/* storemac: Set up a macro buffer and flag to store all
executed command lines there */
storemac(f, n)
int f; /* default flag */
int n; /* macro number to use */
/*
* storemac:
* Set up a macro buffer and flag to store all
* executed command lines there
*
* int f; default flag
* int n; macro number to use
*/
int storemac(int f, int n)
{
register struct BUFFER *bp; /* pointer to macro buffer */
char bname[NBUFN]; /* name of buffer to use */
@ -284,14 +290,15 @@ int n; /* macro number to use */
}
#if PROC
/* storeproc: Set up a procedure buffer and flag to store all
executed command lines there */
storeproc(f, n)
int f; /* default flag */
int n; /* macro number to use */
/*
* storeproc:
* Set up a procedure buffer and flag to store all
* executed command lines there
*
* int f; default flag
* int n; macro number to use
*/
int storeproc(int f, int n)
{
register struct BUFFER *bp; /* pointer to macro buffer */
register int status; /* return status */
@ -325,12 +332,13 @@ int n; /* macro number to use */
return (TRUE);
}
/* execproc: Execute a procedure */
execproc(f, n)
int f, n; /* default flag and numeric arg */
/*
* execproc:
* Execute a procedure
*
* int f, n; default flag and numeric arg
*/
int execproc(int f, int n)
{
register BUFFER *bp; /* ptr to buffer to execute */
register int status; /* status return */
@ -359,12 +367,13 @@ int f, n; /* default flag and numeric arg */
}
#endif
/* execbuf: Execute the contents of a buffer of commands */
execbuf(f, n)
int f, n; /* default flag and numeric arg */
/*
* execbuf:
* Execute the contents of a buffer of commands
*
* int f, n; default flag and numeric arg
*/
int execbuf(int f, int n)
{
register BUFFER *bp; /* ptr to buffer to execute */
register int status; /* status return */
@ -387,30 +396,30 @@ int f, n; /* default flag and numeric arg */
return (TRUE);
}
/* dobuf: execute the contents of the buffer pointed to
by the passed BP
Directives start with a "!" and include:
!endm End a macro
!if (cond) conditional execution
!else
!endif
!return Return (terminating current macro)
!goto <label> Jump to a label in the current macro
!force Force macro to continue...even if command fails
!while (cond) Execute a loop if the condition is true
!endwhile
Line Labels begin with a "*" as the first nonblank char, like:
*LBL01
*/
dobuf(bp)
BUFFER *bp; /* buffer to execute */
/*
* dobuf:
* execute the contents of the buffer pointed to
* by the passed BP
*
* Directives start with a "!" and include:
*
* !endm End a macro
* !if (cond) conditional execution
* !else
* !endif
* !return Return (terminating current macro)
* !goto <label> Jump to a label in the current macro
* !force Force macro to continue...even if command fails
* !while (cond) Execute a loop if the condition is true
* !endwhile
*
* Line Labels begin with a "*" as the first nonblank char, like:
*
* *LBL01
*
* BUFFER *bp; buffer to execute
*/
int dobuf(BUFFER *bp)
{
register int status; /* status return */
register LINE *lp; /* pointer to line to execute */
@ -822,10 +831,12 @@ BUFFER *bp; /* buffer to execute */
return (TRUE);
}
freewhile(wp)
/* free a list of while block pointers */
WHBLOCK *wp; /* head of structure to free */
/*
* free a list of while block pointers
*
* WHBLOCK *wp; head of structure to free
*/
int freewhile(WHBLOCK *wp)
{
if (wp == NULL)
return;
@ -834,10 +845,12 @@ WHBLOCK *wp; /* head of structure to free */
free(wp);
}
execfile(f, n)
/* execute a series of commands in a file */
int f, n; /* default flag and numeric arg to pass on to file */
/*
* execute a series of commands in a file
*
* int f, n; default flag and numeric arg to pass on to file
*/
int execfile(int f, int n)
{
register int status; /* return status of name query */
char fname[NSTRING]; /* name of file to execute */
@ -864,13 +877,14 @@ int f, n; /* default flag and numeric arg to pass on to file */
return (TRUE);
}
/* dofile: yank a file into a buffer and execute it
if there are no errors, delete the buffer on exit */
dofile(fname)
char *fname; /* file name to execute */
/*
* dofile:
* yank a file into a buffer and execute it
* if there are no errors, delete the buffer on exit
*
* char *fname; file name to execute
*/
int dofile(char *fname)
{
register BUFFER *bp; /* buffer to place file to exeute */
register BUFFER *cb; /* temp to hold current buf while we read */
@ -902,13 +916,14 @@ char *fname; /* file name to execute */
return (TRUE);
}
/* cbuf: Execute the contents of a numbered buffer */
cbuf(f, n, bufnum)
int f, n; /* default flag and numeric arg */
int bufnum; /* number of buffer to execute */
/*
* cbuf:
* Execute the contents of a numbered buffer
*
* int f, n; default flag and numeric arg
* int bufnum; number of buffer to execute
*/
int cbuf(int f, int n, int bufnum)
{
register BUFFER *bp; /* ptr to buffer to execute */
register int status; /* status return */
@ -931,202 +946,202 @@ int bufnum; /* number of buffer to execute */
return (TRUE);
}
cbuf1(f, n)
int cbuf1(int f, int n)
{
return cbuf(f, n, 1);
}
cbuf2(f, n)
int cbuf2(int f, int n)
{
return cbuf(f, n, 2);
}
cbuf3(f, n)
int cbuf3(int f, int n)
{
return cbuf(f, n, 3);
}
cbuf4(f, n)
int cbuf4(int f, int n)
{
return cbuf(f, n, 4);
}
cbuf5(f, n)
int cbuf5(int f, int n)
{
return cbuf(f, n, 5);
}
cbuf6(f, n)
int cbuf6(int f, int n)
{
return cbuf(f, n, 6);
}
cbuf7(f, n)
int cbuf7(int f, int n)
{
return cbuf(f, n, 7);
}
cbuf8(f, n)
int cbuf8(int f, int n)
{
return cbuf(f, n, 8);
}
cbuf9(f, n)
int cbuf9(int f, int n)
{
return cbuf(f, n, 9);
}
cbuf10(f, n)
int cbuf10(int f, int n)
{
return cbuf(f, n, 10);
}
cbuf11(f, n)
int cbuf11(int f, int n)
{
return cbuf(f, n, 11);
}
cbuf12(f, n)
int cbuf12(int f, int n)
{
return cbuf(f, n, 12);
}
cbuf13(f, n)
int cbuf13(int f, int n)
{
return cbuf(f, n, 13);
}
cbuf14(f, n)
int cbuf14(int f, int n)
{
return cbuf(f, n, 14);
}
cbuf15(f, n)
int cbuf15(int f, int n)
{
return cbuf(f, n, 15);
}
cbuf16(f, n)
int cbuf16(int f, int n)
{
return cbuf(f, n, 16);
}
cbuf17(f, n)
int cbuf17(int f, int n)
{
return cbuf(f, n, 17);
}
cbuf18(f, n)
int cbuf18(int f, int n)
{
return cbuf(f, n, 18);
}
cbuf19(f, n)
int cbuf19(int f, int n)
{
return cbuf(f, n, 19);
}
cbuf20(f, n)
int cbuf20(int f, int n)
{
return cbuf(f, n, 20);
}
cbuf21(f, n)
int cbuf21(int f, int n)
{
return cbuf(f, n, 21);
}
cbuf22(f, n)
int cbuf22(int f, int n)
{
return cbuf(f, n, 22);
}
cbuf23(f, n)
int cbuf23(int f, int n)
{
return cbuf(f, n, 23);
}
cbuf24(f, n)
int cbuf24(int f, int n)
{
return cbuf(f, n, 24);
}
cbuf25(f, n)
int cbuf25(int f, int n)
{
return cbuf(f, n, 25);
}
cbuf26(f, n)
int cbuf26(int f, int n)
{
return cbuf(f, n, 26);
}
cbuf27(f, n)
int cbuf27(int f, int n)
{
return cbuf(f, n, 27);
}
cbuf28(f, n)
int cbuf28(int f, int n)
{
return cbuf(f, n, 28);
}
cbuf29(f, n)
int cbuf29(int f, int n)
{
return cbuf(f, n, 29);
}
cbuf30(f, n)
int cbuf30(int f, int n)
{
return cbuf(f, n, 30);
}
cbuf31(f, n)
int cbuf31(int f, int n)
{
return cbuf(f, n, 31);
}
cbuf32(f, n)
int cbuf32(int f, int n)
{
return cbuf(f, n, 32);
}
cbuf33(f, n)
int cbuf33(int f, int n)
{
return cbuf(f, n, 33);
}
cbuf34(f, n)
int cbuf34(int f, int n)
{
return cbuf(f, n, 34);
}
cbuf35(f, n)
int cbuf35(int f, int n)
{
return cbuf(f, n, 35);
}
cbuf36(f, n)
int cbuf36(int f, int n)
{
return cbuf(f, n, 36);
}
cbuf37(f, n)
int cbuf37(int f, int n)
{
return cbuf(f, n, 37);
}
cbuf38(f, n)
int cbuf38(int f, int n)
{
return cbuf(f, n, 38);
}
cbuf39(f, n)
int cbuf39(int f, int n)
{
return cbuf(f, n, 39);
}
cbuf40(f, n)
int cbuf40(int f, int n)
{
return cbuf(f, n, 40);
}

74
file.c
View File

@ -8,8 +8,10 @@
*/
#include <stdio.h>
#include <unistd.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
/*
* Read a file into the current
@ -18,7 +20,7 @@
* "read a file into the current buffer" code.
* Bound to "C-X C-R".
*/
fileread(f, n)
int fileread(int f, int n)
{
register int s;
char fname[NFILEN];
@ -37,7 +39,7 @@ fileread(f, n)
* "insert a file into the current buffer" code.
* Bound to "C-X C-I".
*/
insfile(f, n)
int insfile(int f, int n)
{
register int s;
char fname[NFILEN];
@ -62,7 +64,7 @@ insfile(f, n)
* text, and switch to the new buffer.
* Bound to C-X C-F.
*/
filefind(f, n)
int filefind(int f, int n)
{
char fname[NFILEN]; /* file user wishes to find */
register int s; /* status return */
@ -74,7 +76,7 @@ filefind(f, n)
return (getfile(fname, TRUE));
}
viewfile(f, n)
int viewfile(int f, int n)
{ /* visit a file in VIEW mode */
char fname[NFILEN]; /* file user wishes to find */
register int s; /* status return */
@ -99,7 +101,7 @@ viewfile(f, n)
}
#if CRYPT
resetkey()
int resetkey(void)
{ /* reset the encryption key if needed */
register int s; /* return status */
@ -131,11 +133,13 @@ resetkey()
}
#endif
getfile(fname, lockfl)
char fname[]; /* file name to find */
int lockfl; /* check the file for locks? */
/*
* getfile()
*
* char fname[]; file name to find
* int lockfl; check the file for locks?
*/
int getfile(char *fname, int lockfl)
{
register BUFFER *bp;
register LINE *lp;
@ -191,19 +195,17 @@ int lockfl; /* check the file for locks? */
}
/*
Read file "fname" into the current buffer, blowing away any text
found there. Called by both the read and find commands. Return
the final status of the read. Also called by the mainline, to
read in a file specified on the command line as an argument.
The command bound to M-FNR is called after the buffer is set up
and before it is read.
*/
readin(fname, lockfl)
char fname[]; /* name of file to read */
int lockfl; /* check for file locks? */
* Read file "fname" into the current buffer, blowing away any text
* found there. Called by both the read and find commands. Return
* the final status of the read. Also called by the mainline, to
* read in a file specified on the command line as an argument.
* The command bound to M-FNR is called after the buffer is set up
* and before it is read.
*
* char fname[]; name of file to read
* int lockfl; check for file locks?
*/
int readin(char *fname, int lockfl)
{
register LINE *lp1;
register LINE *lp2;
@ -323,9 +325,7 @@ int lockfl; /* check for file locks? */
* I suppose that this information could be put in
* a better place than a line of code.
*/
makename(bname, fname)
char bname[];
char fname[];
void makename(char *bname, char *fname)
{
register char *cp1;
register char *cp2;
@ -358,10 +358,12 @@ char fname[];
*cp2 = 0;
}
unqname(name)
/* make sure a buffer name is unique */
char *name; /* name to check on */
/*
* make sure a buffer name is unique
*
* char *name; name to check on
*/
void unqname(char *name)
{
register char *sp;
@ -389,7 +391,7 @@ char *name; /* name to check on */
* is more compatable with Gosling EMACS than
* with ITS EMACS. Bound to "C-X C-W".
*/
filewrite(f, n)
int filewrite(int f, int n)
{
register WINDOW *wp;
register int s;
@ -420,7 +422,7 @@ filewrite(f, n)
* name for the buffer. Bound to "C-X C-S". May
* get called by "C-Z".
*/
filesave(f, n)
int filesave(int f, int n)
{
register WINDOW *wp;
register int s;
@ -462,8 +464,7 @@ filesave(f, n)
* a macro for this. Most of the grief is error
* checking of some sort.
*/
writeout(fn)
char *fn;
int writeout(char *fn)
{
register int s;
register LINE *lp;
@ -515,7 +516,7 @@ char *fn;
* as needing an update. You can type a blank line at the
* prompt if you wish.
*/
filename(f, n)
int filename(int f, int n)
{
register WINDOW *wp;
register int s;
@ -544,8 +545,7 @@ filename(f, n)
* buffer, Called by insert file command. Return the final
* status of the read.
*/
ifile(fname)
char fname[];
int ifile(char *fname)
{
register LINE *lp0;
register LINE *lp1;

View File

@ -9,6 +9,7 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
#if PKCODE
extern int nullflag;
@ -20,8 +21,7 @@ int eofflag; /* end-of-file flag */
/*
* Open a file for reading.
*/
ffropen(fn)
char *fn;
int ffropen(char *fn)
{
if ((ffp = fopen(fn, "r")) == NULL)
return (FIOFNF);
@ -33,8 +33,7 @@ char *fn;
* Open a file for writing. Return TRUE if all is well, and FALSE on error
* (cannot create).
*/
ffwopen(fn)
char *fn;
int ffwopen(char *fn)
{
#if VMS
register int fd;
@ -53,7 +52,7 @@ char *fn;
/*
* Close a file. Should look at the status in all systems.
*/
ffclose()
int ffclose(void)
{
/* free this since we do not need it anymore */
if (fline) {
@ -83,8 +82,7 @@ ffclose()
* and the "nbuf" is its length, less the free newline. Return the status.
* Check only at the newline.
*/
ffputline(buf, nbuf)
char buf[];
int ffputline(char *buf, int nbuf)
{
register int i;
#if CRYPT
@ -120,7 +118,7 @@ char buf[];
* at the end of the file that don't have a newline present. Check for I/O
* errors too. Return status.
*/
ffgetline()
int ffgetline(void)
{
register int c; /* current character read */
register int i; /* current index into fline */
@ -206,10 +204,12 @@ ffgetline()
return (FIOSUC);
}
int fexist(fname)
/* does <fname> exist on disk? */
char *fname; /* file to check for existance */
/*
* does <fname> exist on disk?
*
* char *fname; file to check for existance
*/
int fexist(char *fname)
{
FILE *fp;

View File

@ -9,6 +9,7 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
#if PKCODE
#if MSDOS && TURBO

View File

@ -25,12 +25,10 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
#if ISRCH
extern int scanner(); /* Handy search routine */
extern int eq(); /* Compare chars, match case */
/* A couple of "own" variables for re-eat */
int (*saved_get_char) (); /* Get character routine */
@ -47,8 +45,7 @@ int cmd_reexecute = -1; /* > 0 if re-executing command */
* Subroutine to do incremental reverse search. It actually uses the
* same code as the normal incremental search, as both can go both ways.
*/
int risearch(f, n)
int risearch(int f, int n)
{
LINE *curline; /* Current line on entry */
int curoff; /* Current offset on entry */
@ -78,9 +75,10 @@ int risearch(f, n)
#endif
}
/* Again, but for the forward direction */
int fisearch(f, n)
/*
* Again, but for the forward direction
*/
int fisearch(int f, int n)
{
LINE *curline; /* Current line on entry */
int curoff; /* Current offset on entry */
@ -134,7 +132,7 @@ int fisearch(f, n)
* exists (or until the search is aborted).
*/
isearch(f, n)
int isearch(int f, int n)
{
int status; /* Search status */
int col; /* prompt column */
@ -269,12 +267,12 @@ isearch(f, n)
*
* If the compare fails, we return FALSE and assume the caller will call
* scanmore or something.
*
* char chr; Next char to look for
* char *patrn; The entire search string (incl chr)
* int dir; Search direction
*/
int checknext(chr, patrn, dir) /* Check next character in search string */
char chr; /* Next char to look for */
char *patrn; /* The entire search string (incl chr) */
int dir; /* Search direction */
int checknext(char chr, char *patrn, int dir) /* Check next character in search string */
{
register LINE *curline; /* current line during scan */
register int curoff; /* position within current line */
@ -314,11 +312,11 @@ int dir; /* Search direction */
* we do find a match, "point" will be at the end of the matched string for
* forward searches and at the beginning of the matched string for reverse
* searches.
*
* char *patrn; string to scan for
* int dir; direction to search
*/
int scanmore(patrn, dir) /* search forward or back for a pattern */
char *patrn; /* string to scan for */
int dir; /* direction to search */
int scanmore(char *patrn, int dir) /* search forward or back for a pattern */
{
int sts; /* search status */
@ -344,10 +342,10 @@ int dir; /* direction to search */
* This isn't used for forward searches, because forward searches leave "."
* at the end of the search string (instead of in front), so all that needs to
* be done is match the last char input.
*
* char *patrn; String to match to buffer
*/
int match_pat(patrn) /* See if the pattern string matches string at "." */
char *patrn; /* String to match to buffer */
int match_pat(char *patrn) /* See if the pattern string matches string at "." */
{
register int i; /* Generic loop index/offset */
register int buffchar; /* character at current position */
@ -376,10 +374,10 @@ char *patrn; /* String to match to buffer */
return (TRUE); /* Everything matched? Let's celebrate */
}
/* Routine to prompt for I-Search string. */
int promptpattern(prompt)
char *prompt;
/*
* Routine to prompt for I-Search string.
*/
int promptpattern(char *prompt)
{
char tpat[NPAT + 20];
@ -395,11 +393,13 @@ char *prompt;
return (strlen(tpat));
}
/* routine to echo i-search characters */
int echochar(c, col)
int c; /* character to be echoed */
int col; /* column to be echoed in */
/*
* routine to echo i-search characters
*
* int c; character to be echoed
* int col; column to be echoed in
*/
int echochar(int c, int col)
{
movecursor(term.t_nrow, col); /* Position the cursor */
if ((c < ' ') || (c == 0x7F)) { /* Control character? */
@ -444,8 +444,7 @@ int col; /* column to be echoed in */
* Otherwise, we must be re-executing the command string, so just return the
* next character.
*/
int get_char()
int get_char(void)
{
int c; /* A place to get a character */
@ -476,7 +475,7 @@ int get_char()
/* Come here on the next term.t_getchar call: */
int uneat()
int uneat(void)
{
int c;
@ -486,8 +485,7 @@ int uneat()
return (c); /* and return the last char */
}
int reeat(c)
int c;
int reeat(int c)
{
if (eaten_char != -1) /* If we've already been here */
return /*(NULL) */ ; /* Don't do it again */
@ -496,7 +494,7 @@ int c;
term.t_getchar = uneat; /* Replace it with ours */
}
#else
isearch()
int isearch(int f, int n)
{
}
#endif

1
line.c
View File

@ -16,6 +16,7 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
KILL *ykbuf; /* ptr to current kill buffer chunk being yanked */
int ykboff; /* offset into that chunk */

70
lock.c
View File

@ -8,6 +8,7 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
#if FILOCK
#if BSD | SVR4
@ -19,12 +20,13 @@ extern int errno; /* current error */
char *lname[NLOCKS]; /* names of all locked files */
int numlocks; /* # of current locks active */
/* lockchk: check a file for locking and add it to the list */
lockchk(fname)
char *fname; /* file to check for a lock */
/*
* lockchk:
* check a file for locking and add it to the list
*
* char *fname; file to check for a lock
*/
int lockchk(char *fname)
{
register int i; /* loop indexes */
register int status; /* return status */
@ -63,9 +65,11 @@ char *fname; /* file to check for a lock */
return (TRUE);
}
/* lockrel: release all the file locks so others may edit */
lockrel()
/*
* lockrel:
* release all the file locks so others may edit
*/
int lockrel(void)
{
register int i; /* loop index */
register int status; /* status of locks */
@ -82,16 +86,16 @@ lockrel()
return (status);
}
/* lock: Check and lock a file from access by others
returns TRUE = files was not locked and now is
FALSE = file was locked and overridden
ABORT = file was locked, abort command
*/
lock(fname)
char *fname; /* file name to lock */
/*
* lock:
* Check and lock a file from access by others
* returns TRUE = files was not locked and now is
* FALSE = file was locked and overridden
* ABORT = file was locked, abort command
*
* char *fname; file name to lock
*/
int lock(char *fname)
{
register char *locker; /* lock error message */
register int status; /* return status */
@ -120,14 +124,14 @@ char *fname; /* file name to lock */
return (ABORT);
}
/* unlock: Unlock a file
this only warns the user if it fails
*/
unlock(fname)
char *fname; /* file to unlock */
/*
* unlock:
* Unlock a file
* this only warns the user if it fails
*
* char *fname; file to unlock
*/
int unlock(char *fname)
{
register char *locker; /* undolock return string */
char *undolock();
@ -142,10 +146,12 @@ char *fname; /* file to unlock */
return (FALSE);
}
lckerror(errstr)
/* report a lock error */
char *errstr; /* lock error string to print out */
/*
* report a lock error
*
* char *errstr; lock error string to print out
*/
void lckerror(char *errstr)
{
char obuf[NSTRING]; /* output buffer for error message */
@ -159,7 +165,7 @@ char *errstr; /* lock error string to print out */
}
#endif
#else
lckhello()
static void lckhello(void )
{ /* dummy function */
}
#endif

11
main.c
View File

@ -57,8 +57,8 @@
#define maindef
#include "estruct.h" /* global structures and defines */
#include "efunc.h" /* function declarations and name table */
#include "edef.h" /* global definitions */
#include "efunc.h" /* function declarations and name table */
#include "ebind.h" /* default key bindings */
/* for MSDOS, increase the default stack space */
@ -117,10 +117,6 @@ int main(int argc, char **argv)
#endif
extern *pathname[]; /* startup file path/name array */
int newc;
#if PKCODE
int (*getbind()) ();
int (*execfunc) (); /* ptr to function to execute */
#endif
#if PKCODE & VMS
(void) umask(-1); /* use old protection (this is at wrong place) */
@ -311,6 +307,8 @@ int main(int argc, char **argv)
newc = getcmd();
update(FALSE);
do {
fn_t execfunc;
if (c == newc && (execfunc = getbind(c)) != NULL
&& execfunc != newline && execfunc != tab)
newc = getcmd();
@ -468,8 +466,7 @@ int edinit(char *bname)
int execute(int c, int f, int n)
{
register int status;
int (*execfunc) (); /* ptr to function to execute */
int (*getbind()) ();
fn_t execfunc;
/* if the keystroke is a bound function...do it */
execfunc = getbind(c);

View File

@ -3,12 +3,12 @@
SRC=ansi.c basic.c bind.c buffer.c crypt.c display.c eval.c exec.c \
file.c fileio.c ibmpc.c input.c isearch.c line.c lock.c main.c \
pklock.c posix.c random.c region.c search.c spawn.c tcap.c \
termio.c vmsvt.c vt52.c window.c word.c
termio.c vmsvt.c vt52.c window.c word.c names.c
OBJ=ansi.o basic.o bind.o buffer.o crypt.o display.o eval.o exec.o \
file.o fileio.o ibmpc.o input.o isearch.o line.o lock.o main.o \
pklock.o posix.o random.o region.o search.o spawn.o tcap.o \
termio.o vmsvt.o vt52.o window.o word.o
termio.o vmsvt.o vt52.o window.o word.o names.o
HDR=ebind.h edef.h efunc.h epath.h estruct.h evar.h

224
names.c Normal file
View File

@ -0,0 +1,224 @@
/* 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.
*/
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
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
{"execute-program", execprg},
{"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
#if PKCODE
{"justify-paragraph", justpara},
#endif
{"kill-paragraph", killpara},
#endif
{"kill-region", killregion},
{"kill-to-end-of-line", killtext},
#if FNLABEL
{"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},
{"overwrite-string", ovstring},
{"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 | __hpux | SVR4
{"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}
};

View File

@ -9,6 +9,7 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
int tabsize; /* Tab size (0: use real tabs) */

View File

@ -12,6 +12,7 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
/*
* Kill the region. Ask "getregion"

166
search.c
View File

@ -60,28 +60,28 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
static int readpattern();
static int replaces();
static int nextch();
#if MAGIC
static int cclmake();
static int mcstr();
static int rmcstr();
static int mceq();
static void setbit();
static int amatch();
static int biteq();
static BITMAP clearbits();
#endif
static int amatch(MC *mcptr, int direct, LINE **pcwline, int *pcwoff);
static int readpattern(char *prompt, char *apat, int srch);
static int replaces(int kind, int f, int n);
static int nextch(LINE **pcurline, int *pcuroff, int dir);
static int mcstr(void);
static int rmcstr(void);
static int mceq(int bc, MC *mt);
static int cclmake(char **ppatptr, MC *mcptr);
static int biteq(int bc, BITMAP cclmap);
static BITMAP clearbits(void);
static void setbit(int bc, BITMAP cclmap);
/*
* forwsearch -- Search forward. Get a search string from the user, and
* search for the string. If found, reset the "." to be just after
* the match string, and (perhaps) repaint the display.
*
* int f, n; default flag / numeric argument
*/
forwsearch(f, n)
int f, n; /* default flag / numeric argument */
int forwsearch(int f, int n)
{
register int status = TRUE;
@ -124,10 +124,10 @@ int f, n; /* default flag / numeric argument */
* forwhunt -- Search forward for a previously acquired search string.
* If found, reset the "." to be just after the match string,
* and (perhaps) repaint the display.
*
* int f, n; default flag / numeric argument
*/
forwhunt(f, n)
int f, n; /* default flag / numeric argument */
int forwhunt(int f, int n)
{
register int status = TRUE;
@ -178,9 +178,10 @@ int f, n; /* default flag / numeric argument */
* search, starting at "." and proceeding toward the front of the buffer.
* If found "." is left pointing at the first character of the pattern
* (the last character that was matched).
*
* int f, n; default flag / numeric argument
*/
backsearch(f, n)
int f, n; /* default flag / numeric argument */
int backsearch(int f, int n)
{
register int status = TRUE;
@ -225,9 +226,10 @@ int f, n; /* default flag / numeric argument */
* starting at "." and proceeding toward the front of the buffer.
* If found "." is left pointing at the first character of the pattern
* (the last character that was matched).
*
* int f, n; default flag / numeric argument
*/
backhunt(f, n)
int f, n; /* default flag / numeric argument */
int backhunt(int f, int n)
{
register int status = TRUE;
@ -278,11 +280,12 @@ int f, n; /* default flag / numeric argument */
* mcscanner -- Search for a meta-pattern in either direction. If found,
* reset the "." to be at the start or just after the match string,
* and (perhaps) repaint the display.
*
* MC *mcpatrn; pointer into pattern
* int direct; which way to go.
* int beg_or_end; put point at beginning or end of pattern.
*/
int mcscanner(mcpatrn, direct, beg_or_end)
MC *mcpatrn; /* pointer into pattern */
int direct; /* which way to go. */
int beg_or_end; /* put point at beginning or end of pattern. */
int mcscanner(MC *mcpatrn, int direct, int beg_or_end)
{
LINE *curline; /* current line during scan */
int curoff; /* position within current line */
@ -345,12 +348,13 @@ int beg_or_end; /* put point at beginning or end of pattern. */
* amatch -- Search for a meta-pattern in either direction. Based on the
* recursive routine amatch() (for "anchored match") in
* Kernighan & Plauger's "Software Tools".
*
* MC *mcptr; string to scan for
* int direct; which way to go.
* LINE **pcwline; current line during scan
* int *pcwoff; position within current line
*/
static int amatch(mcptr, direct, pcwline, pcwoff)
register MC *mcptr; /* string to scan for */
int direct; /* which way to go. */
LINE **pcwline; /* current line during scan */
int *pcwoff; /* position within current line */
static int amatch(MC *mcptr, int direct, LINE **pcwline, int *pcwoff)
{
register int c; /* character at current position */
LINE *curline; /* current line during scan */
@ -483,11 +487,12 @@ int *pcwoff; /* position within current line */
* scanner -- Search for a pattern in either direction. If found,
* reset the "." to be at the start or just after the match string,
* and (perhaps) repaint the display.
*
* unsigned char *patrn; string to scan for
* int direct; which way to go.
* int beg_or_end; put point at beginning or end of pattern.
*/
int scanner(patrn, direct, beg_or_end)
unsigned char *patrn; /* string to scan for */
int direct; /* which way to go. */
int beg_or_end; /* put point at beginning or end of pattern. */
int scanner(unsigned char *patrn, int direct, int beg_or_end)
{
register int c; /* character at current position */
register unsigned char *patptr; /* pointer into pattern */
@ -562,14 +567,7 @@ int beg_or_end; /* put point at beginning or end of pattern. */
* eq -- Compare two characters. The "bc" comes from the buffer, "pc"
* from the pattern. If we are not in EXACT mode, fold out the case.
*/
int eq(bc, pc)
#if PKCODE
register char bc;
register char pc;
#else
register int bc;
register int pc;
#endif
int eq(unsigned char bc, unsigned char pc)
{
if ((curwp->w_bufp->b_mode & MDEXACT) == 0) {
if (islower(bc))
@ -593,10 +591,7 @@ register int pc;
* <META> to delimit the end-of-pattern to allow <NL>s in the search
* string.
*/
static int readpattern(prompt, apat, srch)
char *prompt;
char apat[];
int srch;
static int readpattern(char *prompt, char *apat, int srch)
{
int status;
char tpat[NPAT + 20];
@ -640,7 +635,7 @@ int srch;
/*
* savematch -- We found the pattern? Let's save it away.
*/
savematch()
void savematch(void)
{
register char *ptr; /* pointer to last match string */
register int j;
@ -669,8 +664,7 @@ savematch()
/*
* rvstrcpy -- Reverse string copy.
*/
rvstrcpy(rvstr, str)
register char *rvstr, *str;
void rvstrcpy(char *rvstr, char *str)
{
register int i;
@ -684,20 +678,22 @@ register char *rvstr, *str;
/*
* sreplace -- Search and replace.
*
* int f; default flag
* int n; # of repetitions wanted
*/
sreplace(f, n)
int f; /* default flag */
int n; /* # of repetitions wanted */
int sreplace(int f, int n)
{
return (replaces(FALSE, f, n));
}
/*
* qreplace -- search and replace with query.
*
* int f; default flag
* int n; # of repetitions wanted
*/
qreplace(f, n)
int f; /* default flag */
int n; /* # of repetitions wanted */
int qreplace(int f, int n)
{
return (replaces(TRUE, f, n));
}
@ -705,11 +701,12 @@ int n; /* # of repetitions wanted */
/*
* replaces -- Search for a string and replace it with another
* string. Query might be enabled (according to kind).
*
* int kind; Query enabled flag
* int f; default flag
* int n; # of repetitions wanted
*/
static int replaces(kind, f, n)
int kind; /* Query enabled flag */
int f; /* default flag */
int n; /* # of repetitions wanted */
static int replaces(int kind, int f, int n)
{
register int status; /* success flag on pattern inputs */
register int rlength; /* length of replacement string */
@ -925,10 +922,7 @@ int n; /* # of repetitions wanted */
* then either insert the string directly, or make use of
* replacement meta-array.
*/
delins(dlength, instr, use_meta)
int dlength;
char *instr;
int use_meta;
int delins(int dlength, char *instr, int use_meta)
{
int status;
#if MAGIC
@ -961,11 +955,12 @@ int use_meta;
/*
* expandp -- Expand control key sequences for output.
*
* char *srcstr; string to expand
* char *deststr; destination of expanded string
* int maxlength; maximum chars in destination
*/
expandp(srcstr, deststr, maxlength)
char *srcstr; /* string to expand */
char *deststr; /* destination of expanded string */
int maxlength; /* maximum chars in destination */
int expandp(char *srcstr, char *deststr, int maxlength)
{
unsigned char c; /* current char to translate */
@ -1016,9 +1011,7 @@ int maxlength; /* maximum chars in destination */
* in future, a' la VMS EDT. At the moment, just return TRUE or
* FALSE depending on if a boundry is hit (ouch).
*/
int boundry(curline, curoff, dir)
LINE *curline;
int curoff, dir;
int boundry(LINE *curline, int curoff, int dir)
{
register int border;
@ -1040,10 +1033,7 @@ int curoff, dir;
* the current character and move, reverse searches move and
* look at the character.
*/
static int nextch(pcurline, pcuroff, dir)
LINE **pcurline;
int *pcuroff;
int dir;
static int nextch(LINE **pcurline, int *pcuroff, int dir)
{
register LINE *curline;
register int curoff;
@ -1089,7 +1079,7 @@ int dir;
* within the 64K limit. C compilers actually do very little
* in the way of optimizing - they expect you to do that.
*/
static int mcstr()
static int mcstr(void)
{
MC *mcptr, *rtpcm;
char *patptr;
@ -1204,7 +1194,7 @@ static int mcstr()
* the array is never actually created - we will just use the
* character array rpat[] as the replacement string.
*/
static int rmcstr()
static int rmcstr(void)
{
RMC *rmcptr;
char *patptr;
@ -1293,7 +1283,7 @@ static int rmcstr()
/*
* mcclear -- Free up any CCL bitmaps, and MCNIL the MC search arrays.
*/
mcclear()
void mcclear(void)
{
register MC *mcptr;
@ -1311,7 +1301,7 @@ mcclear()
/*
* rmcclear -- Free up any strings, and MCNIL the RMC array.
*/
rmcclear()
void rmcclear(void)
{
register RMC *rmcptr;
@ -1331,9 +1321,7 @@ rmcclear()
* Software Tools, this is the function omatch(), but i felt there
* were too many functions with the 'match' name already.
*/
static int mceq(bc, mt)
int bc;
MC *mt;
static int mceq(int bc, MC *mt)
{
register int result;
@ -1382,9 +1370,7 @@ MC *mt;
* ppatptr is left pointing to the end-of-character-class character,
* so that a loop may automatically increment with safety.
*/
static int cclmake(ppatptr, mcptr)
char **ppatptr;
MC *mcptr;
static int cclmake(char **ppatptr, MC *mcptr)
{
BITMAP clearbits();
BITMAP bmap;
@ -1463,9 +1449,7 @@ MC *mcptr;
/*
* biteq -- is the character in the bitmap?
*/
static int biteq(bc, cclmap)
int bc;
BITMAP cclmap;
static int biteq(int bc, BITMAP cclmap)
{
#if PKCODE
bc = bc & 0xFF;
@ -1479,7 +1463,7 @@ BITMAP cclmap;
/*
* clearbits -- Allocate and zero out a CCL bitmap.
*/
static BITMAP clearbits()
static BITMAP clearbits(void)
{
BITMAP cclstart, cclmap;
register int j;
@ -1494,9 +1478,7 @@ static BITMAP clearbits()
/*
* setbit -- Set a bit (ON only) in the bitmap.
*/
static void setbit(bc, cclmap)
int bc;
BITMAP cclmap;
static void setbit(int bc, BITMAP cclmap)
{
#if PKCODE
bc = bc & 0xFF;

46
spawn.c
View File

@ -7,6 +7,7 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
#if VMS
#define EFN 0 /* Event flag. */
@ -39,7 +40,7 @@ extern void sizesignal();
* repaint. Bound to "^X C". The message at the start in VMS puts out a newline.
* Under some (unknown) condition, you don't get one free when DCL starts up.
*/
spawncli(f, n)
int spawncli(int f, int n)
{
#if V7 | USG | BSD
register char *cp;
@ -103,7 +104,7 @@ spawncli(f, n)
#if BSD | __hpux | SVR4
bktoshell()
void bktoshell(void)
{ /* suspend MicroEMACS and wait to wake up */
int pid;
@ -115,7 +116,7 @@ bktoshell()
kill(0, SIGTSTP);
}
rtfrmshell()
void rtfrmshell(void)
{
TTopen();
curwp->w_flag = WFHARD;
@ -128,7 +129,7 @@ rtfrmshell()
* character to be typed, then mark the screen as garbage so a full repaint is
* done. Bound to "C-X !".
*/
spawn(f, n)
int spawn(int f, int n)
{
register int s;
char line[NLINE];
@ -194,7 +195,7 @@ spawn(f, n)
* done. Bound to "C-X $".
*/
execprg(f, n)
int execprg(int f, int n)
{
register int s;
char line[NLINE];
@ -252,7 +253,7 @@ execprg(f, n)
* Pipe a one line command into a window
* Bound to ^X @
*/
pipecmd(f, n)
int pipecmd(int f, int n)
{
register int s; /* return status from CLI */
register WINDOW *wp; /* pointer to new window */
@ -376,7 +377,7 @@ pipecmd(f, n)
* filter a buffer through an external DOS program
* Bound to ^X #
*/
filter(f, n)
int filter(int f, int n)
{
register int s; /* return status from CLI */
register BUFFER *bp; /* pointer to buffer to zot */
@ -462,8 +463,7 @@ filter(f, n)
* LIB$SPAWN works. You have to do wierd stuff with the terminal on the way in
* and the way out, because DCL does not want the channel to be in raw mode.
*/
sys(cmd)
register char *cmd;
int sys(char *cmd)
{
struct dsc$descriptor cdsc;
struct dsc$descriptor *cdscp;
@ -498,12 +498,12 @@ register char *cmd;
#if MSDOS & (TURBO | MSC)
/* SHELLPROG: Execute a command in a subshell */
shellprog(cmd)
char *cmd; /* Incoming command line to execute */
/*
* SHELLPROG: Execute a command in a subshell
*
* char *cmd; Incoming command line to execute
*/
int shellprog(char *cmd)
{
char *shell; /* Name of system command processor */
char *p; /* Temporary pointer */
@ -543,14 +543,14 @@ char *cmd; /* Incoming command line to execute */
return (execprog(shell));
}
/* EXECPROG: A function to execute a named program
with arguments
*/
execprog(cmd)
char *cmd; /* Incoming command line to execute */
/*
* EXECPROG:
* A function to execute a named program
* with arguments
*
* char *cmd; Incoming command line to execute
*/
int execprog(char *cmd)
{
char *sp; /* temporary string pointer */
char f1[38]; /* FCB1 area (not initialized */

1
tcap.c
View File

@ -17,6 +17,7 @@
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
#if TERMCAP

View File

@ -8,6 +8,7 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
/*
* Reposition dot in the current window to line "n". If the argument is
@ -532,6 +533,7 @@ int scrnextup(int f, int n)
nextwind(FALSE, 1);
backpage(f, n);
prevwind(FALSE, 1);
return (TRUE);
}
int scrnextdw(int f, int n)
@ -539,6 +541,7 @@ int scrnextdw(int f, int n)
nextwind(FALSE, 1);
forwpage(f, n);
prevwind(FALSE, 1);
return (TRUE);
}
int savewnd(int f, int n)
@ -708,7 +711,7 @@ int getwpos(void)
return (sline);
}
int cknewwindow(void)
void cknewwindow(void)
{
execute(META | SPEC | 'X', FALSE, 1);
}

1
word.c
View File

@ -10,6 +10,7 @@
#include <stdio.h>
#include "estruct.h"
#include "edef.h"
#include "efunc.h"
/* Word wrap on n-spaces. Back-over whatever precedes the point on the current
* line and stop on the first word-break or the beginning of the line. If we