rc: only have single instance of a symbol, extern in header (thanks mcf)

This commit is contained in:
cinap_lenrek 2022-01-04 00:19:36 +00:00
parent 699d2e0ed9
commit 3568e27ec8
8 changed files with 21 additions and 19 deletions

View file

@ -7,7 +7,7 @@
#define c1 t->child[1] #define c1 t->child[1]
#define c2 t->child[2] #define c2 t->child[2]
code *codebuf; code *codebuf;
int codep, ncode, codeline; static int codep, ncode, codeline;
#define emitf(x) ((codep!=ncode || morecode()), codebuf[codep].f = (x), codep++) #define emitf(x) ((codep!=ncode || morecode()), codebuf[codep].f = (x), codep++)
#define emiti(x) ((codep!=ncode || morecode()), codebuf[codep].i = (x), codep++) #define emiti(x) ((codep!=ncode || morecode()), codebuf[codep].i = (x), codep++)
#define emits(x) ((codep!=ncode || morecode()), codebuf[codep].s = (x), codep++) #define emits(x) ((codep!=ncode || morecode()), codebuf[codep].s = (x), codep++)

View file

@ -4,6 +4,11 @@
#include "io.h" #include "io.h"
#include "fns.h" #include "fns.h"
char *argv0="rc";
io *err;
int mypid;
thread *runq;
/* /*
* Start executing the given code at the given pc with the given redirection * Start executing the given code at the given pc with the given redirection
*/ */
@ -216,8 +221,6 @@ shuffleredir(void)
* fabricate bootstrap code and start it (*=(argv);. -bq /usr/lib/rcmain $*) * fabricate bootstrap code and start it (*=(argv);. -bq /usr/lib/rcmain $*)
* start interpreting code * start interpreting code
*/ */
char *argv0="rc";
void void
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {

View file

@ -57,16 +57,17 @@ struct thread{
char *status; /* status for Xpipewait */ char *status; /* status for Xpipewait */
thread *ret; /* who continues when this finishes */ thread *ret; /* who continues when this finishes */
}; };
extern thread *runq;
thread *runq;
void turfstack(var*); void turfstack(var*);
extern int mypid;
extern int ntrap; /* number of outstanding traps */
extern int trap[NSIG]; /* number of outstanding traps per type */
code *codecopy(code*); code *codecopy(code*);
code *codebuf; /* compiler output */ extern code *codebuf; /* compiler output */
extern int ifnot; extern int ifnot;
int ntrap; /* number of outstanding traps */
int trap[NSIG]; /* number of outstanding traps per type */
struct builtin{ struct builtin{
char *name; char *name;
void (*fnc)(void); void (*fnc)(void);
@ -82,5 +83,3 @@ void startfunc(var*, word*, var*, redir*);
char *srcfile(thread*); char *srcfile(thread*);
char *getstatus(void); char *getstatus(void);
extern char *argv0;

View file

@ -5,7 +5,6 @@ struct io{
unsigned char *buf, *bufp, *ebuf; unsigned char *buf, *bufp, *ebuf;
io *next; io *next;
}; };
io *err;
io *openiofd(int), *openiostr(void), *openiocore(void*, int); io *openiofd(int), *openiostr(void), *openiocore(void*, int);
void pchr(io*, int); void pchr(io*, int);

View file

@ -123,8 +123,7 @@ var *vlook(char*), *gvlook(char*), *newvar(char*, var*);
void setvar(char*, word*), freevar(var*); void setvar(char*, word*), freevar(var*);
#define NVAR 521 #define NVAR 521
extern var *gvar[NVAR]; /* hash for globals */
var *gvar[NVAR]; /* hash for globals */
#define new(type) ((type *)emalloc(sizeof(type))) #define new(type) ((type *)emalloc(sizeof(type)))
@ -132,8 +131,6 @@ void *emalloc(long);
void *erealloc(void *, long); void *erealloc(void *, long);
char *estrdup(char*); char *estrdup(char*);
int mypid;
/* /*
* Glob character escape in strings: * Glob character escape in strings:
* In a string, GLOB must be followed by *?[ or GLOB. * In a string, GLOB must be followed by *?[ or GLOB.
@ -152,10 +149,10 @@ int mypid;
#define fourbyte(c) (((c)&0xf8)==0xf0) #define fourbyte(c) (((c)&0xf8)==0xf0)
#define xbyte(c) (((c)&0xc0)==0x80) #define xbyte(c) (((c)&0xc0)==0x80)
extern char **argp; extern char *argv0;
extern char **args;
extern int nerror; /* number of errors encountered during compilation */ extern int nerror; /* number of errors encountered during compilation */
extern int doprompt; /* is it time for a prompt? */ extern int doprompt; /* is it time for a prompt? */
extern io *err;
/* /*
* Which fds are the reading/writing end of a pipe? * Which fds are the reading/writing end of a pipe?
@ -166,3 +163,4 @@ extern int doprompt; /* is it time for a prompt? */
#define PRD 0 #define PRD 0
#define PWR 1 #define PWR 1
extern char Rcmain[], Fdprefix[]; extern char Rcmain[], Fdprefix[];
extern char *Signame[];

View file

@ -1,5 +1,4 @@
#include "rc.h" #include "rc.h"
#include "exec.h"
#include "io.h" #include "io.h"
#include "fns.h" #include "fns.h"

View file

@ -2,7 +2,9 @@
#include "exec.h" #include "exec.h"
#include "fns.h" #include "fns.h"
#include "io.h" #include "io.h"
extern char *Signame[];
int ntrap;
int trap[NSIG];
void void
dotrap(void) dotrap(void)

View file

@ -2,6 +2,8 @@
#include "exec.h" #include "exec.h"
#include "fns.h" #include "fns.h"
var *gvar[NVAR];
int int
hash(char *s, int n) hash(char *s, int n)
{ {