1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-06-09 05:20:42 +00:00

Fix ugly "definitions in header file" crud

Move various initializations into new "globals.c" file.

Also mark some variables static, and fix up some trivial compiler and
sparse warnings.
This commit is contained in:
Linus Torvalds 2005-10-01 00:33:44 -07:00
parent 12cb79ceb4
commit 8967dfc2c6
11 changed files with 174 additions and 193 deletions

1
ansi.c
View File

@ -209,7 +209,6 @@ ansiopen()
{ {
#if V7 | USG | BSD #if V7 | USG | BSD
register char *cp; register char *cp;
char *getenv();
if ((cp = getenv("TERM")) == NULL) { if ((cp = getenv("TERM")) == NULL) {
puts("Shell variable TERM not defined!"); puts("Shell variable TERM not defined!");

6
bind.c
View File

@ -77,6 +77,7 @@ int deskey(int f, int n)
/* output the command sequence */ /* output the command sequence */
ostring(ptr); ostring(ptr);
return (TRUE);
} }
/* /*
@ -173,7 +174,7 @@ int bindtokey(int f, int n)
* *
* int f, n; command arguments [IGNORED] * int f, n; command arguments [IGNORED]
*/ */
unbindkey(int f, int n) int unbindkey(int f, int n)
{ {
register int c; /* command key to unbind */ register int c; /* command key to unbind */
char outseq[80]; /* output buffer for keystroke sequence */ char outseq[80]; /* output buffer for keystroke sequence */
@ -249,6 +250,7 @@ int desbind(int f, int n)
#if APROP #if APROP
{ {
buildlist(TRUE, ""); buildlist(TRUE, "");
return (TRUE);
} }
int apro(int f, int n) 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 KEYTAB *ktp; /* pointer into the command table */
register NBIND *nptr; /* pointer into the name binding table */ register NBIND *nptr; /* pointer into the name binding table */
register BUFFER *bp; /* buffer to put binding list into */ register BUFFER *bp; /* buffer to put binding list into */
char *strp; /* pointer int string to send */
int cpos; /* current position to use in outseq */ int cpos; /* current position to use in outseq */
char outseq[80]; /* output buffer for keystroke sequence */ 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 char *sp; /* pointer into path spec */
register int i; /* index */ register int i; /* index */
static char fspec[NSTRING]; /* full path spec to search */ static char fspec[NSTRING]; /* full path spec to search */
char *getenv();
#if ENVFUNC #if ENVFUNC

167
edef.h
View File

@ -27,170 +27,6 @@ char *mklower();
char *mkupper(); char *mkupper();
char *token(); 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 */ /* initialized global external declarations */
extern int fillcol; /* Fill column */ extern int fillcol; /* Fill column */
@ -264,6 +100,7 @@ extern int eexitflag; /* EMACS exit flag */
extern int eexitval; /* and the exit return value */ extern int eexitval; /* and the exit return value */
#endif #endif
#if PKCODE #if PKCODE
extern int nullflag;
extern int justflag; /* justify, don't fill */ extern int justflag; /* justify, don't fill */
#endif #endif
extern int overlap; /* line overlap in forw/back page */ 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 */ extern char outline[]; /* global string to hold debug line text */
#endif #endif
#endif
/* terminal table defined only in TERM.C */ /* terminal table defined only in TERM.C */
#ifndef termdef #ifndef termdef

4
eval.c
View File

@ -36,9 +36,6 @@ char *gtfun(char *fname)
static char result[2 * NSTRING]; /* string result */ static char result[2 * NSTRING]; /* string result */
char *flook(); /* look file up on path */ char *flook(); /* look file up on path */
char *xlat(); /* translate a char string */ char *xlat(); /* translate a char string */
#if ENVFUNC
char *getenv(); /* get environment string */
#endif
/* look the function up in the function table */ /* look the function up in the function table */
fname[3] = 0; /* only first 3 chars significant */ fname[3] = 0; /* only first 3 chars significant */
@ -209,7 +206,6 @@ char *gtenv(char *vname)
if (vnum == NEVARS) if (vnum == NEVARS)
#if ENVFUNC #if ENVFUNC
{ {
extern char *getenv();
char *ename = getenv(vname); char *ename = getenv(vname);
if (ename != NULL) if (ename != NULL)

View File

@ -11,10 +11,6 @@
#include "edef.h" #include "edef.h"
#include "efunc.h" #include "efunc.h"
#if PKCODE
extern int nullflag;
#endif
FILE *ffp; /* File pointer, all functions. */ FILE *ffp; /* File pointer, all functions. */
int eofflag; /* end-of-file flag */ int eofflag; /* end-of-file flag */

160
globals.c Normal file
View File

@ -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

View File

@ -7,6 +7,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <unistd.h>
#include "estruct.h" #include "estruct.h"
#include "edef.h" #include "edef.h"
#include "efunc.h" #include "efunc.h"

View File

@ -3,12 +3,12 @@
SRC=ansi.c basic.c bind.c buffer.c crypt.c display.c eval.c exec.c \ 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 \ 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 \ 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 \ 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 \ 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 \ 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 HDR=ebind.h edef.h efunc.h epath.h estruct.h evar.h

View File

@ -39,8 +39,7 @@ int gethostname(char *name, int namelen)
* if other error, returns "LOCK ERROR: explanation" * if other error, returns "LOCK ERROR: explanation"
* *
*********************/ *********************/
char *dolock(fname) char *dolock(char *fname)
char *fname;
{ {
int fd, n; int fd, n;
static char lname[MAXLOCK], locker[MAXNAME + 1]; static char lname[MAXLOCK], locker[MAXNAME + 1];
@ -101,8 +100,7 @@ char *fname;
* *
*********************/ *********************/
char *undolock(fname) char *undolock(char *fname)
char *fname;
{ {
static char lname[MAXLOCK]; static char lname[MAXLOCK];

View File

@ -45,7 +45,6 @@ int spawncli(int f, int n)
{ {
#if V7 | USG | BSD #if V7 | USG | BSD
register char *cp; register char *cp;
char *getenv();
#endif #endif
/* don't allow this command if restricted */ /* don't allow this command if restricted */
@ -267,9 +266,7 @@ int pipecmd(int f, int n)
#if MSDOS #if MSDOS
char *tmp; char *tmp;
char *getenv();
FILE *fp; FILE *fp;
FILE *fopen();
int len; int len;
#endif #endif
@ -512,7 +509,6 @@ int shellprog(char *cmd)
char swchar; /* switch character to use */ char swchar; /* switch character to use */
union REGS regs; /* parameters for dos call */ union REGS regs; /* parameters for dos call */
char comline[NSTRING]; /* constructed command line */ char comline[NSTRING]; /* constructed command line */
char *getenv();
/* detect current switch character and set us up to use it */ /* detect current switch character and set us up to use it */
regs.h.ah = 0x37; /* get setting data */ regs.h.ah = 0x37; /* get setting data */

10
tcap.c
View File

@ -61,16 +61,16 @@ static void tcapscroll_delins(int from, int to, int linestoscroll);
#define TCAPSLEN 315 #define TCAPSLEN 315
char tcapbuf[TCAPSLEN]; static char tcapbuf[TCAPSLEN];
char *UP, PC, *CM, *CE, *CL, *SO, *SE; static char *UP, PC, *CM, *CE, *CL, *SO, *SE;
#if PKCODE #if PKCODE
char *TI, *TE; static char *TI, *TE;
int term_init_ok = 0; static int term_init_ok = 0;
#endif #endif
#if SCROLLCODE #if SCROLLCODE
char *CS, *DL, *AL, *SF, *SR; static char *CS, *DL, *AL, *SF, *SR;
#endif #endif
TERM term = { TERM term = {