rc: only have single instance of a symbol, extern in header (thanks mcf)
This commit is contained in:
parent
699d2e0ed9
commit
3568e27ec8
8 changed files with 21 additions and 19 deletions
|
@ -7,7 +7,7 @@
|
|||
#define c1 t->child[1]
|
||||
#define c2 t->child[2]
|
||||
code *codebuf;
|
||||
int codep, ncode, codeline;
|
||||
static int codep, ncode, codeline;
|
||||
#define emitf(x) ((codep!=ncode || morecode()), codebuf[codep].f = (x), codep++)
|
||||
#define emiti(x) ((codep!=ncode || morecode()), codebuf[codep].i = (x), codep++)
|
||||
#define emits(x) ((codep!=ncode || morecode()), codebuf[codep].s = (x), codep++)
|
||||
|
|
|
@ -4,6 +4,11 @@
|
|||
#include "io.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
|
||||
*/
|
||||
|
@ -216,8 +221,6 @@ shuffleredir(void)
|
|||
* fabricate bootstrap code and start it (*=(argv);. -bq /usr/lib/rcmain $*)
|
||||
* start interpreting code
|
||||
*/
|
||||
char *argv0="rc";
|
||||
|
||||
void
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
|
|
@ -57,16 +57,17 @@ struct thread{
|
|||
char *status; /* status for Xpipewait */
|
||||
thread *ret; /* who continues when this finishes */
|
||||
};
|
||||
|
||||
thread *runq;
|
||||
extern thread *runq;
|
||||
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 *codebuf; /* compiler output */
|
||||
extern code *codebuf; /* compiler output */
|
||||
extern int ifnot;
|
||||
|
||||
int ntrap; /* number of outstanding traps */
|
||||
int trap[NSIG]; /* number of outstanding traps per type */
|
||||
struct builtin{
|
||||
char *name;
|
||||
void (*fnc)(void);
|
||||
|
@ -82,5 +83,3 @@ void startfunc(var*, word*, var*, redir*);
|
|||
|
||||
char *srcfile(thread*);
|
||||
char *getstatus(void);
|
||||
|
||||
extern char *argv0;
|
||||
|
|
|
@ -5,7 +5,6 @@ struct io{
|
|||
unsigned char *buf, *bufp, *ebuf;
|
||||
io *next;
|
||||
};
|
||||
io *err;
|
||||
|
||||
io *openiofd(int), *openiostr(void), *openiocore(void*, int);
|
||||
void pchr(io*, int);
|
||||
|
|
|
@ -123,8 +123,7 @@ var *vlook(char*), *gvlook(char*), *newvar(char*, var*);
|
|||
void setvar(char*, word*), freevar(var*);
|
||||
|
||||
#define NVAR 521
|
||||
|
||||
var *gvar[NVAR]; /* hash for globals */
|
||||
extern var *gvar[NVAR]; /* hash for globals */
|
||||
|
||||
#define new(type) ((type *)emalloc(sizeof(type)))
|
||||
|
||||
|
@ -132,8 +131,6 @@ void *emalloc(long);
|
|||
void *erealloc(void *, long);
|
||||
char *estrdup(char*);
|
||||
|
||||
int mypid;
|
||||
|
||||
/*
|
||||
* Glob character escape in strings:
|
||||
* In a string, GLOB must be followed by *?[ or GLOB.
|
||||
|
@ -152,10 +149,10 @@ int mypid;
|
|||
#define fourbyte(c) (((c)&0xf8)==0xf0)
|
||||
#define xbyte(c) (((c)&0xc0)==0x80)
|
||||
|
||||
extern char **argp;
|
||||
extern char **args;
|
||||
extern char *argv0;
|
||||
extern int nerror; /* number of errors encountered during compilation */
|
||||
extern int doprompt; /* is it time for a prompt? */
|
||||
extern io *err;
|
||||
|
||||
/*
|
||||
* 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 PWR 1
|
||||
extern char Rcmain[], Fdprefix[];
|
||||
extern char *Signame[];
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "rc.h"
|
||||
#include "exec.h"
|
||||
#include "io.h"
|
||||
#include "fns.h"
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
#include "exec.h"
|
||||
#include "fns.h"
|
||||
#include "io.h"
|
||||
extern char *Signame[];
|
||||
|
||||
int ntrap;
|
||||
int trap[NSIG];
|
||||
|
||||
void
|
||||
dotrap(void)
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
#include "exec.h"
|
||||
#include "fns.h"
|
||||
|
||||
var *gvar[NVAR];
|
||||
|
||||
int
|
||||
hash(char *s, int n)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue