diff options
Diffstat (limited to 'rc/frobnitzem-globals.patch')
| -rw-r--r-- | rc/frobnitzem-globals.patch | 265 |
1 files changed, 0 insertions, 265 deletions
diff --git a/rc/frobnitzem-globals.patch b/rc/frobnitzem-globals.patch deleted file mode 100644 index 9ec69c0..0000000 --- a/rc/frobnitzem-globals.patch +++ /dev/null | |||
| @@ -1,265 +0,0 @@ | |||
| 1 | commit 553b6890624d04e64ca0973d8fe86b107cb363b7 | ||
| 2 | Author: David M. Rogers <predictivestatmech@gmail.com> | ||
| 3 | Date: Wed Oct 13 11:45:42 2021 -0400 | ||
| 4 | |||
| 5 | Moved global variables into globals.c | ||
| 6 | |||
| 7 | diff --git a/Makefile b/Makefile | ||
| 8 | index 6de563b..c8b7566 100644 | ||
| 9 | --- a/Makefile | ||
| 10 | +++ b/Makefile | ||
| 11 | @@ -3,6 +3,7 @@ include Make.$(shell uname) | ||
| 12 | TARG=rc | ||
| 13 | |||
| 14 | OFILES=\ | ||
| 15 | + globals.$O \ | ||
| 16 | code.$O\ | ||
| 17 | exec.$O\ | ||
| 18 | getflags.$O\ | ||
| 19 | diff --git a/code.c b/code.c | ||
| 20 | index eeaa3ed..876da4b 100644 | ||
| 21 | --- a/code.c | ||
| 22 | +++ b/code.c | ||
| 23 | @@ -15,7 +15,6 @@ char *fnstr(tree*); | ||
| 24 | void outcode(tree*, int); | ||
| 25 | void codeswitch(tree*, int); | ||
| 26 | int iscase(tree*); | ||
| 27 | -code *codecopy(code*); | ||
| 28 | void codefree(code*); | ||
| 29 | |||
| 30 | int | ||
| 31 | diff --git a/exec.c b/exec.c | ||
| 32 | index 3ad8a0d..a24cd74 100644 | ||
| 33 | --- a/exec.c | ||
| 34 | +++ b/exec.c | ||
| 35 | @@ -6,7 +6,6 @@ | ||
| 36 | /* | ||
| 37 | * Start executing the given code at the given pc with the given redirection | ||
| 38 | */ | ||
| 39 | -char *argv0="rc"; | ||
| 40 | |||
| 41 | void | ||
| 42 | start(code *c, int pc, var *local) | ||
| 43 | diff --git a/exec.h b/exec.h | ||
| 44 | index 06d2991..fcab495 100644 | ||
| 45 | --- a/exec.h | ||
| 46 | +++ b/exec.h | ||
| 47 | @@ -56,18 +56,22 @@ struct thread{ | ||
| 48 | tree *treenodes; /* tree nodes created by this process */ | ||
| 49 | thread *ret; /* who continues when this finishes */ | ||
| 50 | }; | ||
| 51 | -thread *runq; | ||
| 52 | + | ||
| 53 | code *codecopy(code*); | ||
| 54 | -code *codebuf; /* compiler output */ | ||
| 55 | -int ntrap; /* number of outstanding traps */ | ||
| 56 | -int trap[NSIG]; /* number of outstanding traps per type */ | ||
| 57 | + | ||
| 58 | +/* globals.c */ | ||
| 59 | +extern thread *runq; | ||
| 60 | +extern code *codebuf; /* compiler output */ | ||
| 61 | +extern int ntrap; /* number of outstanding traps */ | ||
| 62 | +extern int trap[NSIG]; /* number of outstanding traps per type */ | ||
| 63 | +extern int eflagok; /* kludge flag so that -e doesn't exit in startup */ | ||
| 64 | +extern int havefork; | ||
| 65 | + | ||
| 66 | struct builtin{ | ||
| 67 | char *name; | ||
| 68 | void (*fnc)(void); | ||
| 69 | }; | ||
| 70 | extern struct builtin Builtin[]; | ||
| 71 | -int eflagok; /* kludge flag so that -e doesn't exit in startup */ | ||
| 72 | -int havefork; | ||
| 73 | |||
| 74 | void execcd(void), execwhatis(void), execeval(void), execexec(void); | ||
| 75 | int execforkexec(void); | ||
| 76 | diff --git a/globals.c b/globals.c | ||
| 77 | new file mode 100644 | ||
| 78 | index 0000000..b29bfe3 | ||
| 79 | --- /dev/null | ||
| 80 | +++ b/globals.c | ||
| 81 | @@ -0,0 +1,30 @@ | ||
| 82 | +#include "rc.h" | ||
| 83 | +#include "io.h" | ||
| 84 | + | ||
| 85 | +int mypid; | ||
| 86 | + | ||
| 87 | +/* globals associated with lex.c and subr.c */ | ||
| 88 | +int doprompt = 1; /* is it time for a prompt? */ | ||
| 89 | +int lastdol; /* was the last token read '$' or '$#' or '"'? */ | ||
| 90 | +int lastword; /* was the last token read a word or compound word terminator? */ | ||
| 91 | +char tok[NTOK]; | ||
| 92 | +int ndot = 0; // FIXME - never decreases? | ||
| 93 | +int lastc; | ||
| 94 | +int lastword; | ||
| 95 | +int kidpid; | ||
| 96 | + | ||
| 97 | +io *rc_err; | ||
| 98 | + | ||
| 99 | +/* globals associated with exec.c */ | ||
| 100 | +char *promptstr; | ||
| 101 | +tree *cmdtree; | ||
| 102 | +thread *runq; | ||
| 103 | +code *codebuf; /* compiler output */ | ||
| 104 | +int ntrap; /* number of outstanding traps */ | ||
| 105 | +int trap[NSIG]; /* number of outstanding traps per type */ | ||
| 106 | +int eflagok; /* kludge flag so that -e doesn't exit in startup */ | ||
| 107 | + | ||
| 108 | +char *argv0="rc"; | ||
| 109 | +var *gvar[NVAR]; /* hash for globals */ | ||
| 110 | + | ||
| 111 | +int nerror = 0; /* number of errors encountered during compilation */ | ||
| 112 | diff --git a/io.h b/io.h | ||
| 113 | index 21cc6b8..68b9e89 100644 | ||
| 114 | --- a/io.h | ||
| 115 | +++ b/io.h | ||
| 116 | @@ -10,7 +10,7 @@ struct io{ | ||
| 117 | int fd; | ||
| 118 | char *bufp, *ebuf, *strp, buf[NBUF]; | ||
| 119 | }; | ||
| 120 | -io *err; | ||
| 121 | +extern io *err; | ||
| 122 | io *openfd(int), *openstr(void), *opencore(char *, int); | ||
| 123 | int emptybuf(io*); | ||
| 124 | void pchr(io*, int); | ||
| 125 | diff --git a/lex.c b/lex.c | ||
| 126 | index d2bef32..f1e40e2 100644 | ||
| 127 | --- a/lex.c | ||
| 128 | +++ b/lex.c | ||
| 129 | @@ -3,7 +3,11 @@ | ||
| 130 | #include "io.h" | ||
| 131 | #include "getflags.h" | ||
| 132 | #include "fns.h" | ||
| 133 | -int getnext(void); | ||
| 134 | + | ||
| 135 | +static int future = EOF; | ||
| 136 | +static int inquote; | ||
| 137 | +static int incomm; | ||
| 138 | +static int getnext(void); | ||
| 139 | |||
| 140 | int | ||
| 141 | wordchr(int c) | ||
| 142 | @@ -21,10 +25,6 @@ idchr(int c) | ||
| 143 | */ | ||
| 144 | return c>' ' && !strchr("!\"#$%&'()+,-./:;<=>?@[\\]^`{|}~", c); | ||
| 145 | } | ||
| 146 | -int future = EOF; | ||
| 147 | -int doprompt = 1; | ||
| 148 | -int inquote; | ||
| 149 | -int incomm; | ||
| 150 | /* | ||
| 151 | * Look ahead in the input stream | ||
| 152 | */ | ||
| 153 | @@ -52,7 +52,7 @@ advance(void) | ||
| 154 | * read a character from the input stream | ||
| 155 | */ | ||
| 156 | |||
| 157 | -int | ||
| 158 | +static int | ||
| 159 | getnext(void) | ||
| 160 | { | ||
| 161 | int c; | ||
| 162 | @@ -163,8 +163,6 @@ addutf(char *p, int c) | ||
| 163 | } | ||
| 164 | return p; | ||
| 165 | } | ||
| 166 | -int lastdol; /* was the last token read '$' or '$#' or '"'? */ | ||
| 167 | -int lastword; /* was the last token read a word or compound word terminator? */ | ||
| 168 | |||
| 169 | int | ||
| 170 | yylex(void) | ||
| 171 | diff --git a/rc.h b/rc.h | ||
| 172 | index 8a6a5bb..1d87051 100644 | ||
| 173 | --- a/rc.h | ||
| 174 | +++ b/rc.h | ||
| 175 | @@ -53,7 +53,7 @@ tree *mung1(tree*, tree*), *mung2(tree*, tree*, tree*); | ||
| 176 | tree *mung3(tree*, tree*, tree*, tree*), *epimung(tree*, tree*); | ||
| 177 | tree *simplemung(tree*), *heredoc(tree*); | ||
| 178 | void freetree(tree*); | ||
| 179 | -tree *cmdtree; | ||
| 180 | +extern tree *cmdtree; | ||
| 181 | /* | ||
| 182 | * The first word of any code vector is a reference count. | ||
| 183 | * Always create a new reference to a code vector by calling codecopy(.). | ||
| 184 | @@ -64,10 +64,10 @@ union code{ | ||
| 185 | int i; | ||
| 186 | char *s; | ||
| 187 | }; | ||
| 188 | -char *promptstr; | ||
| 189 | -int doprompt; | ||
| 190 | +extern char *promptstr; | ||
| 191 | +extern int doprompt; | ||
| 192 | #define NTOK 8192 | ||
| 193 | -char tok[NTOK]; | ||
| 194 | +extern char tok[NTOK]; | ||
| 195 | #define APPEND 1 | ||
| 196 | #define WRITE 2 | ||
| 197 | #define READ 3 | ||
| 198 | @@ -87,7 +87,7 @@ struct var{ | ||
| 199 | }; | ||
| 200 | var *vlook(char*), *gvlook(char*), *newvar(char*, var*); | ||
| 201 | #define NVAR 521 | ||
| 202 | -var *gvar[NVAR]; /* hash for globals */ | ||
| 203 | +extern var *gvar[NVAR]; /* hash for globals */ | ||
| 204 | #define new(type) ((type *)emalloc(sizeof(type))) | ||
| 205 | void *emalloc(long); | ||
| 206 | void *Malloc(ulong); | ||
| 207 | @@ -98,7 +98,7 @@ struct here{ | ||
| 208 | char *name; | ||
| 209 | struct here *next; | ||
| 210 | }; | ||
| 211 | -int mypid; | ||
| 212 | +extern int mypid; | ||
| 213 | /* | ||
| 214 | * Glob character escape in strings: | ||
| 215 | * In a string, GLOB must be followed by *?[ or GLOB. | ||
| 216 | @@ -117,10 +117,13 @@ int mypid; | ||
| 217 | #define threebyte(c) ((c&0xf0)==0xe0) | ||
| 218 | #define fourbyte(c) ((c&0xf8)==0xf0) | ||
| 219 | |||
| 220 | -char **argp; | ||
| 221 | -char **args; | ||
| 222 | -int nerror; /* number of errors encountered during compilation */ | ||
| 223 | -int doprompt; /* is it time for a prompt? */ | ||
| 224 | +extern char *argv0; | ||
| 225 | +//char **argp; | ||
| 226 | +//char **args; | ||
| 227 | +extern int nerror; /* number of errors encountered during compilation */ | ||
| 228 | +extern int doprompt; /* is it time for a prompt? */ | ||
| 229 | +extern int lastword, lastdol; | ||
| 230 | + | ||
| 231 | /* | ||
| 232 | * Which fds are the reading/writing end of a pipe? | ||
| 233 | * Unfortunately, this can vary from system to system. | ||
| 234 | @@ -129,14 +132,14 @@ int doprompt; /* is it time for a prompt? */ | ||
| 235 | */ | ||
| 236 | #define PRD 0 | ||
| 237 | #define PWR 1 | ||
| 238 | -char *Rcmain, *Fdprefix; | ||
| 239 | +extern char *Rcmain, *Fdprefix; | ||
| 240 | #define register | ||
| 241 | /* | ||
| 242 | * How many dot commands have we executed? | ||
| 243 | * Used to ensure that -v flag doesn't print rcmain. | ||
| 244 | */ | ||
| 245 | -int ndot; | ||
| 246 | +extern int ndot; | ||
| 247 | char *getstatus(void); | ||
| 248 | -int lastc; | ||
| 249 | -int lastword; | ||
| 250 | -int kidpid; | ||
| 251 | +extern int lastc; | ||
| 252 | +extern int lastword; | ||
| 253 | +extern int kidpid; | ||
| 254 | diff --git a/subr.c b/subr.c | ||
| 255 | index a2d8a18..1fe3b9b 100644 | ||
| 256 | --- a/subr.c | ||
| 257 | +++ b/subr.c | ||
| 258 | @@ -22,7 +22,6 @@ efree(void *p) | ||
| 259 | free(p); | ||
| 260 | else pfmt(err, "free 0\n"); | ||
| 261 | } | ||
| 262 | -extern int lastword, lastdol; | ||
| 263 | |||
| 264 | void | ||
| 265 | yyerror(char *m) | ||
