diff --git a/ansi.c b/ansi.c index 89f54e5..9b1072c 100644 --- a/ansi.c +++ b/ansi.c @@ -209,7 +209,6 @@ ansiopen() { #if V7 | USG | BSD register char *cp; - char *getenv(); if ((cp = getenv("TERM")) == NULL) { puts("Shell variable TERM not defined!"); diff --git a/bind.c b/bind.c index bfc4046..e5c9d73 100644 --- a/bind.c +++ b/bind.c @@ -77,6 +77,7 @@ int deskey(int f, int n) /* output the command sequence */ ostring(ptr); + return (TRUE); } /* @@ -173,7 +174,7 @@ int bindtokey(int f, int n) * * int f, n; command arguments [IGNORED] */ -unbindkey(int f, int n) +int unbindkey(int f, int n) { register int c; /* command key to unbind */ char outseq[80]; /* output buffer for keystroke sequence */ @@ -249,6 +250,7 @@ int desbind(int f, int n) #if APROP { buildlist(TRUE, ""); + return (TRUE); } int apro(int f, int n) @@ -276,7 +278,6 @@ int buildlist(int type, char *mstring) register KEYTAB *ktp; /* pointer into the command table */ register NBIND *nptr; /* pointer into the name binding table */ register BUFFER *bp; /* buffer to put binding list into */ - char *strp; /* pointer int string to send */ int cpos; /* current position to use in outseq */ char outseq[80]; /* output buffer for keystroke sequence */ @@ -477,7 +478,6 @@ char *flook(char *fname, int hflag) register char *sp; /* pointer into path spec */ register int i; /* index */ static char fspec[NSTRING]; /* full path spec to search */ - char *getenv(); #if ENVFUNC diff --git a/edef.h b/edef.h index 8ceae60..ff69d0d 100644 --- a/edef.h +++ b/edef.h @@ -27,170 +27,6 @@ char *mklower(); char *mkupper(); char *token(); -#ifdef maindef - -/* for MAIN.C */ - -/* initialized global definitions */ - -int fillcol = 72; /* Current fill column */ -short kbdm[NKBDM]; /* Macro */ -char *execstr = NULL; /* pointer to string to execute */ -char golabel[NPAT] = ""; /* current line to go to */ -int execlevel = 0; /* execution IF level */ -int eolexist = TRUE; /* does clear to EOL exist */ -int revexist = FALSE; /* does reverse video exist? */ -int flickcode = FALSE; /* do flicker supression? */ -char *modename[] = { /* name of modes */ - "WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER", - "MAGIC", "CRYPT", "ASAVE" -}; -char *mode2name[] = { /* name of modes */ - "Wrap", "Cmode", "Spell", "Exact", "View", "Over", - "Magic", "Crypt", "Asave" -}; -char modecode[] = "WCSEVOMYA"; /* letters to represent modes */ -int gmode = 0; /* global editor mode */ -int gflags = GFREAD; /* global control flag */ -#if PKCODE & IBMPC -int gfcolor = 8; /* global forgrnd color (white) */ -#else -int gfcolor = 7; /* global forgrnd color (white) */ -#endif -int gbcolor = 0; /* global backgrnd color (black) */ -int gasave = 256; /* global ASAVE size */ -int gacount = 256; /* count until next ASAVE */ -int sgarbf = TRUE; /* TRUE if screen is garbage */ -int mpresf = FALSE; /* TRUE if message in last line */ -int clexec = FALSE; /* command line execution flag */ -int mstore = FALSE; /* storing text to macro flag */ -int discmd = TRUE; /* display command flag */ -int disinp = TRUE; /* display input characters */ -struct BUFFER *bstore = NULL; /* buffer to store macro text to */ -int vtrow = 0; /* Row location of SW cursor */ -int vtcol = 0; /* Column location of SW cursor */ -int ttrow = HUGE; /* Row location of HW cursor */ -int ttcol = HUGE; /* Column location of HW cursor */ -int lbound = 0; /* leftmost column of current line - being displayed */ -int taboff = 0; /* tab offset for display */ -int metac = CONTROL | '['; /* current meta character */ -int ctlxc = CONTROL | 'X'; /* current control X prefix char */ -int reptc = CONTROL | 'U'; /* current universal repeat char */ -int abortc = CONTROL | 'G'; /* current abort command char */ - -int quotec = 0x11; /* quote char during mlreply() */ -int tabmask = 0x07; /* tabulator mask */ -char *cname[] = { /* names of colors */ - "BLACK", "RED", "GREEN", "YELLOW", "BLUE", - "MAGENTA", "CYAN", "WHITE" -#if PKCODE & IBMPC - , "HIGH" -#endif -}; -KILL *kbufp = NULL; /* current kill buffer chunk pointer */ -KILL *kbufh = NULL; /* kill buffer header pointer */ -int kused = KBLOCK; /* # of bytes used in kill buffer */ -window_t *swindow = NULL; /* saved window pointer */ -int cryptflag = FALSE; /* currently encrypting? */ -short *kbdptr; /* current position in keyboard buf */ -short *kbdend = &kbdm[0]; /* ptr to end of the keyboard */ -int kbdmode = STOP; /* current keyboard macro mode */ -int kbdrep = 0; /* number of repetitions */ -int restflag = FALSE; /* restricted use? */ -int lastkey = 0; /* last keystoke */ -int seed = 0; /* random number seed */ -long envram = 0l; /* # of bytes current in use by malloc */ -int macbug = FALSE; /* macro debuging flag */ -char errorm[] = "ERROR"; /* error literal */ -char truem[] = "TRUE"; /* true literal */ -char falsem[] = "FALSE"; /* false litereal */ -int cmdstatus = TRUE; /* last command status */ -char palstr[49] = ""; /* palette string */ -int saveflag = 0; /* Flags, saved with the $target var */ -char *fline = NULL; /* dynamic return line */ -int flen = 0; /* current length of fline */ -int rval = 0; /* return value of a subprocess */ -#if CALLED -int eexitflag = FALSE; /* EMACS exit flag */ -int eexitval = 0; /* and the exit return value */ -#endif -#if PKCODE -int nullflag = FALSE; /* accept null characters */ -int justflag = FALSE; /* justify, don't fill */ -#endif -int overlap = 0; /* line overlap in forw/back page */ -int scrollcount = 1; /* number of lines to scroll */ - -/* uninitialized global definitions */ - -int currow; /* Cursor row */ -int curcol; /* Cursor column */ -int thisflag; /* Flags, this command */ -int lastflag; /* Flags, last command */ -int curgoal; /* Goal for C-P, C-N */ -window_t *curwp; /* Current window */ -BUFFER *curbp; /* Current buffer */ -window_t *wheadp; /* Head of list of windows */ -BUFFER *bheadp; /* Head of list of buffers */ -BUFFER *blistp; /* Buffer for C-X C-B */ - -BUFFER *bfind(char *bname, int cflag, int bflag); /* Lookup a buffer by name */ -window_t *wpopup(); /* Pop up window creation */ -LINE *lalloc(); /* Allocate a line */ -char sres[NBUFN]; /* current screen resolution */ - -char pat[NPAT]; /* Search pattern */ -char tap[NPAT]; /* Reversed pattern array. */ -char rpat[NPAT]; /* replacement pattern */ - -/* The variable matchlen holds the length of the matched - * string - used by the replace functions. - * The variable patmatch holds the string that satisfies - * the search command. - * The variables matchline and matchoff hold the line and - * offset position of the *start* of match. - */ -unsigned int matchlen = 0; -unsigned int mlenold = 0; -char *patmatch = NULL; -LINE *matchline = NULL; -int matchoff = 0; - -#if MAGIC -/* - * The variables magical and rmagical determine if there - * were actual metacharacters in the search and replace strings - - * if not, then we don't have to use the slower MAGIC mode - * search functions. - */ -short int magical = FALSE; -short int rmagical = FALSE; -MC mcpat[NPAT]; /* the magic pattern */ -MC tapcm[NPAT]; /* the reversed magic pattern */ -RMC rmcpat[NPAT]; /* the replacement magic array */ - -#endif - -/* directive name table: - This holds the names of all the directives.... */ - -char *dname[] = { - "if", "else", "endif", - "goto", "return", "endm", - "while", "endwhile", "break", - "force" -}; - -#if DEBUGM -/* vars needed for macro debugging output */ -char outline[NSTRING]; /* global string to hold debug line text */ -#endif - -#else - -/* for all the other .C files */ - /* initialized global external declarations */ extern int fillcol; /* Fill column */ @@ -264,6 +100,7 @@ extern int eexitflag; /* EMACS exit flag */ extern int eexitval; /* and the exit return value */ #endif #if PKCODE +extern int nullflag; extern int justflag; /* justify, don't fill */ #endif extern int overlap; /* line overlap in forw/back page */ @@ -311,8 +148,6 @@ extern char *dname[]; /* directive name table */ extern char outline[]; /* global string to hold debug line text */ #endif -#endif - /* terminal table defined only in TERM.C */ #ifndef termdef diff --git a/eval.c b/eval.c index d702f98..b872917 100644 --- a/eval.c +++ b/eval.c @@ -36,9 +36,6 @@ char *gtfun(char *fname) static char result[2 * NSTRING]; /* string result */ char *flook(); /* look file up on path */ char *xlat(); /* translate a char string */ -#if ENVFUNC - char *getenv(); /* get environment string */ -#endif /* look the function up in the function table */ fname[3] = 0; /* only first 3 chars significant */ @@ -209,7 +206,6 @@ char *gtenv(char *vname) if (vnum == NEVARS) #if ENVFUNC { - extern char *getenv(); char *ename = getenv(vname); if (ename != NULL) diff --git a/fileio.c b/fileio.c index 46c00b5..6f8eac0 100644 --- a/fileio.c +++ b/fileio.c @@ -11,10 +11,6 @@ #include "edef.h" #include "efunc.h" -#if PKCODE -extern int nullflag; -#endif - FILE *ffp; /* File pointer, all functions. */ int eofflag; /* end-of-file flag */ diff --git a/globals.c b/globals.c new file mode 100644 index 0000000..bb2444a --- /dev/null +++ b/globals.c @@ -0,0 +1,160 @@ +#include "estruct.h" +#include "edef.h" + +/* initialized global definitions */ + +int fillcol = 72; /* Current fill column */ +short kbdm[NKBDM]; /* Macro */ +char *execstr = NULL; /* pointer to string to execute */ +char golabel[NPAT] = ""; /* current line to go to */ +int execlevel = 0; /* execution IF level */ +int eolexist = TRUE; /* does clear to EOL exist */ +int revexist = FALSE; /* does reverse video exist? */ +int flickcode = FALSE; /* do flicker supression? */ +char *modename[] = { /* name of modes */ + "WRAP", "CMODE", "SPELL", "EXACT", "VIEW", "OVER", + "MAGIC", "CRYPT", "ASAVE" +}; +char *mode2name[] = { /* name of modes */ + "Wrap", "Cmode", "Spell", "Exact", "View", "Over", + "Magic", "Crypt", "Asave" +}; +char modecode[] = "WCSEVOMYA"; /* letters to represent modes */ +int gmode = 0; /* global editor mode */ +int gflags = GFREAD; /* global control flag */ +#if PKCODE & IBMPC +int gfcolor = 8; /* global forgrnd color (white) */ +#else +int gfcolor = 7; /* global forgrnd color (white) */ +#endif +int gbcolor = 0; /* global backgrnd color (black) */ +int gasave = 256; /* global ASAVE size */ +int gacount = 256; /* count until next ASAVE */ +int sgarbf = TRUE; /* TRUE if screen is garbage */ +int mpresf = FALSE; /* TRUE if message in last line */ +int clexec = FALSE; /* command line execution flag */ +int mstore = FALSE; /* storing text to macro flag */ +int discmd = TRUE; /* display command flag */ +int disinp = TRUE; /* display input characters */ +struct BUFFER *bstore = NULL; /* buffer to store macro text to */ +int vtrow = 0; /* Row location of SW cursor */ +int vtcol = 0; /* Column location of SW cursor */ +int ttrow = HUGE; /* Row location of HW cursor */ +int ttcol = HUGE; /* Column location of HW cursor */ +int lbound = 0; /* leftmost column of current line + being displayed */ +int taboff = 0; /* tab offset for display */ +int metac = CONTROL | '['; /* current meta character */ +int ctlxc = CONTROL | 'X'; /* current control X prefix char */ +int reptc = CONTROL | 'U'; /* current universal repeat char */ +int abortc = CONTROL | 'G'; /* current abort command char */ + +int quotec = 0x11; /* quote char during mlreply() */ +int tabmask = 0x07; /* tabulator mask */ +char *cname[] = { /* names of colors */ + "BLACK", "RED", "GREEN", "YELLOW", "BLUE", + "MAGENTA", "CYAN", "WHITE" +#if PKCODE & IBMPC + , "HIGH" +#endif +}; +KILL *kbufp = NULL; /* current kill buffer chunk pointer */ +KILL *kbufh = NULL; /* kill buffer header pointer */ +int kused = KBLOCK; /* # of bytes used in kill buffer */ +window_t *swindow = NULL; /* saved window pointer */ +int cryptflag = FALSE; /* currently encrypting? */ +short *kbdptr; /* current position in keyboard buf */ +short *kbdend = &kbdm[0]; /* ptr to end of the keyboard */ +int kbdmode = STOP; /* current keyboard macro mode */ +int kbdrep = 0; /* number of repetitions */ +int restflag = FALSE; /* restricted use? */ +int lastkey = 0; /* last keystoke */ +int seed = 0; /* random number seed */ +long envram = 0l; /* # of bytes current in use by malloc */ +int macbug = FALSE; /* macro debuging flag */ +char errorm[] = "ERROR"; /* error literal */ +char truem[] = "TRUE"; /* true literal */ +char falsem[] = "FALSE"; /* false litereal */ +int cmdstatus = TRUE; /* last command status */ +char palstr[49] = ""; /* palette string */ +int saveflag = 0; /* Flags, saved with the $target var */ +char *fline = NULL; /* dynamic return line */ +int flen = 0; /* current length of fline */ +int rval = 0; /* return value of a subprocess */ +#if CALLED +int eexitflag = FALSE; /* EMACS exit flag */ +int eexitval = 0; /* and the exit return value */ +#endif +#if PKCODE +int nullflag = FALSE; /* accept null characters */ +int justflag = FALSE; /* justify, don't fill */ +#endif +int overlap = 0; /* line overlap in forw/back page */ +int scrollcount = 1; /* number of lines to scroll */ + +/* uninitialized global definitions */ + +int currow; /* Cursor row */ +int curcol; /* Cursor column */ +int thisflag; /* Flags, this command */ +int lastflag; /* Flags, last command */ +int curgoal; /* Goal for C-P, C-N */ +window_t *curwp; /* Current window */ +BUFFER *curbp; /* Current buffer */ +window_t *wheadp; /* Head of list of windows */ +BUFFER *bheadp; /* Head of list of buffers */ +BUFFER *blistp; /* Buffer for C-X C-B */ + +BUFFER *bfind(char *bname, int cflag, int bflag); /* Lookup a buffer by name */ +window_t *wpopup(); /* Pop up window creation */ +LINE *lalloc(); /* Allocate a line */ +char sres[NBUFN]; /* current screen resolution */ + +char pat[NPAT]; /* Search pattern */ +char tap[NPAT]; /* Reversed pattern array. */ +char rpat[NPAT]; /* replacement pattern */ + +/* The variable matchlen holds the length of the matched + * string - used by the replace functions. + * The variable patmatch holds the string that satisfies + * the search command. + * The variables matchline and matchoff hold the line and + * offset position of the *start* of match. + */ +unsigned int matchlen = 0; +unsigned int mlenold = 0; +char *patmatch = NULL; +LINE *matchline = NULL; +int matchoff = 0; + +#if MAGIC +/* + * The variables magical and rmagical determine if there + * were actual metacharacters in the search and replace strings - + * if not, then we don't have to use the slower MAGIC mode + * search functions. + */ +short int magical = FALSE; +short int rmagical = FALSE; +MC mcpat[NPAT]; /* the magic pattern */ +MC tapcm[NPAT]; /* the reversed magic pattern */ +RMC rmcpat[NPAT]; /* the replacement magic array */ + +#endif + +/* directive name table: + This holds the names of all the directives.... */ + +char *dname[] = { + "if", "else", "endif", + "goto", "return", "endm", + "while", "endwhile", "break", + "force" +}; + +#if DEBUGM +/* vars needed for macro debugging output */ +char outline[NSTRING]; /* global string to hold debug line text */ +#endif + + diff --git a/input.c b/input.c index 46db3b9..656ebe7 100644 --- a/input.c +++ b/input.c @@ -7,6 +7,7 @@ */ #include +#include #include "estruct.h" #include "edef.h" #include "efunc.h" diff --git a/makefile b/makefile index f0275f9..659a4c0 100644 --- a/makefile +++ b/makefile @@ -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 names.c + termio.c vmsvt.c vt52.c window.c word.c names.c globals.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 names.o + termio.o vmsvt.o vt52.o window.o word.o names.o globals.o HDR=ebind.h edef.h efunc.h epath.h estruct.h evar.h diff --git a/pklock.c b/pklock.c index 5fc5c21..50a77a7 100644 --- a/pklock.c +++ b/pklock.c @@ -39,8 +39,7 @@ int gethostname(char *name, int namelen) * if other error, returns "LOCK ERROR: explanation" * *********************/ -char *dolock(fname) -char *fname; +char *dolock(char *fname) { int fd, n; static char lname[MAXLOCK], locker[MAXNAME + 1]; @@ -101,8 +100,7 @@ char *fname; * *********************/ -char *undolock(fname) -char *fname; +char *undolock(char *fname) { static char lname[MAXLOCK]; diff --git a/spawn.c b/spawn.c index 58d44bc..da9d06a 100644 --- a/spawn.c +++ b/spawn.c @@ -45,7 +45,6 @@ int spawncli(int f, int n) { #if V7 | USG | BSD register char *cp; - char *getenv(); #endif /* don't allow this command if restricted */ @@ -267,9 +266,7 @@ int pipecmd(int f, int n) #if MSDOS char *tmp; - char *getenv(); FILE *fp; - FILE *fopen(); int len; #endif @@ -512,7 +509,6 @@ int shellprog(char *cmd) char swchar; /* switch character to use */ union REGS regs; /* parameters for dos call */ char comline[NSTRING]; /* constructed command line */ - char *getenv(); /* detect current switch character and set us up to use it */ regs.h.ah = 0x37; /* get setting data */ diff --git a/tcap.c b/tcap.c index c265496..f58e2cb 100644 --- a/tcap.c +++ b/tcap.c @@ -61,16 +61,16 @@ static void tcapscroll_delins(int from, int to, int linestoscroll); #define TCAPSLEN 315 -char tcapbuf[TCAPSLEN]; -char *UP, PC, *CM, *CE, *CL, *SO, *SE; +static char tcapbuf[TCAPSLEN]; +static char *UP, PC, *CM, *CE, *CL, *SO, *SE; #if PKCODE -char *TI, *TE; -int term_init_ok = 0; +static char *TI, *TE; +static int term_init_ok = 0; #endif #if SCROLLCODE -char *CS, *DL, *AL, *SF, *SR; +static char *CS, *DL, *AL, *SF, *SR; #endif TERM term = {