From d0a5516da63238efd535c81307e3eea12149360c Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Sun, 29 Sep 2013 14:07:53 +0800 Subject: [PATCH] Move global string literal to eval. --- edef.h | 5 ----- eval.c | 17 +++++++++++++++-- eval.h | 1 - globals.c | 5 ----- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/edef.h b/edef.h index 792f61e..07f45bc 100644 --- a/edef.h +++ b/edef.h @@ -71,14 +71,9 @@ extern kbdstate kbdmode ; /* current keyboard macro mode */ extern int kbdrep; /* number of repetitions */ extern int restflag; /* restricted use? */ extern int lastkey; /* last keystoke */ -extern int seed; /* random number seed */ extern long envram; /* # of bytes current in use by malloc */ extern int macbug; /* macro debuging flag */ -extern char errorm[]; /* error literal */ -extern char truem[]; /* true literal */ -extern char falsem[]; /* false litereal */ extern int cmdstatus; /* last command status */ -extern char palstr[]; /* palette string */ extern int saveflag; /* Flags, saved with the $target var */ extern int rval; /* return value of a subprocess */ extern int overlap; /* line overlap in forw/back page */ diff --git a/eval.c b/eval.c index 6848eca..89b6ef8 100644 --- a/eval.c +++ b/eval.c @@ -41,6 +41,12 @@ struct user_variable { char *u_value; /* value (string) */ }; +static char errorm[] = "ERROR" ; /* error literal */ + +static int seed = 0 ; /* random number seed */ + +static char *ltos( int val) ; + /* List of recognized environment variables. */ static const char *envars[] = { @@ -494,8 +500,12 @@ char *gtenv(char *vname) return ltos(macbug); case EVSTATUS: return ltos(cmdstatus); - case EVPALETTE: + case EVPALETTE: { + static char palstr[ 49] = "" ; /* palette string */ + return palstr; + } + case EVASAVE: return itoa(gasave); case EVACOUNT: @@ -1089,8 +1099,11 @@ int stol(char *val) * * int val; value to translate */ -char *ltos(int val) +static char *ltos( int val) { + static char truem[] = "TRUE" ; /* true literal */ + static char falsem[] = "FALSE" ; /* false literal */ + if (val) return truem; else diff --git a/eval.h b/eval.h index d2a7364..85dd60e 100644 --- a/eval.h +++ b/eval.h @@ -25,7 +25,6 @@ int setvar( int f, int n) ; char *itoa( int i) ; char *getval( char *token) ; int stol( char *val) ; -char *ltos( int val) ; char *mkupper( char *str) ; char *mklower( char *str) ; int abs( int x) ; diff --git a/globals.c b/globals.c index 76e67fa..852e2f8 100644 --- a/globals.c +++ b/globals.c @@ -72,14 +72,9 @@ kbdstate 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 */ int rval = 0; /* return value of a subprocess */ int overlap = 0; /* line overlap in forw/back page */