summaryrefslogtreecommitdiff
path: root/sys/src/cmd/rc/exec.h
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2021-12-31 15:27:10 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2021-12-31 15:27:10 +0000
commitb90036a062ca330ac5f667cd1ee503686cbe0b80 (patch)
treeab9538715188d5017843c6d94e2ee4c5e155448a /sys/src/cmd/rc/exec.h
parent855cf4326f5a07d7142c2d8918f5fa856d912b85 (diff)
rc: fix everything
Untangle the lexer and interpreter thread state. Fix the file and line number error reporting, getting rid of Xsrcfile instruction, as the whole code block can only come from a single file, stuff the source file in slot[1] of the code block instead. Remove limitations for globber (path element limits) and be more intelligent about handling globbing by inserting Xglob instruction only when needed and not run it over every Xsimple argument list. Remove fragile ndot magic and make it explicit by adding the -q flag to . builtin command. Add -b flag for full compilation. Make exitnext() smart, so we can speculate thru rcmain and avoid the fork(). Get rid of all print(2) format functions and use io instead. Improve the io library, adding rstr() to handle tokenization, which allows us to look ahead in the already read buffer for the terminators, avoiding alot of string copies. Auto indent pcmd(), to make line number reporting more usefull. Implement here documents properly, so they can work everywhere.
Diffstat (limited to 'sys/src/cmd/rc/exec.h')
-rw-r--r--sys/src/cmd/rc/exec.h51
1 files changed, 28 insertions, 23 deletions
diff --git a/sys/src/cmd/rc/exec.h b/sys/src/cmd/rc/exec.h
index 1d07b58d5..d75c7f1cd 100644
--- a/sys/src/cmd/rc/exec.h
+++ b/sys/src/cmd/rc/exec.h
@@ -4,15 +4,16 @@
extern void Xappend(void), Xasync(void), Xbackq(void), Xbang(void), Xclose(void);
extern void Xconc(void), Xcount(void), Xdelfn(void), Xdol(void), Xqw(void), Xdup(void);
extern void Xexit(void), Xfalse(void), Xfn(void), Xfor(void), Xglob(void);
-extern void Xjump(void), Xmark(void), Xmatch(void), Xpipe(void), Xread(void);
-extern void Xrdwr(void), Xsrcline(void), Xsrcfile(void);
-extern void Xrdfn(void), Xunredir(void), Xstar(void), Xreturn(void), Xsubshell(void);
-extern void Xtrue(void), Xword(void), Xglobs(void), Xwrite(void), Xpipefd(void), Xcase(void);
-extern void Xlocal(void), Xunlocal(void), Xassign(void), Xsimple(void), Xpopm(void);
+extern void Xjump(void), Xmark(void), Xmatch(void), Xpipe(void), Xread(void), Xhere(void);
+extern void Xrdwr(void), Xsrcline(void);
+extern void Xunredir(void), Xstar(void), Xreturn(void), Xsubshell(void);
+extern void Xtrue(void), Xword(void), Xwrite(void), Xpipefd(void), Xcase(void);
+extern void Xlocal(void), Xunlocal(void), Xassign(void), Xsimple(void), Xpopm(void), Xpush(void);
extern void Xrdcmds(void), Xwastrue(void), Xif(void), Xifnot(void), Xpipewait(void);
-extern void Xdelhere(void), Xpopredir(void), Xsub(void), Xeflag(void), Xsettrue(void);
+extern void Xpopredir(void), Xsub(void), Xeflag(void), Xsettrue(void);
extern void Xerror(char*);
extern void Xerror1(char*);
+
/*
* word lists are in correct order,
* i.e. word0->word1->word2->word3->0
@@ -20,60 +21,64 @@ extern void Xerror1(char*);
struct word{
char *word;
word *next;
- int glob; /* Globsize(word) */
};
struct list{
word *words;
list *next;
};
word *newword(char *, word *), *copywords(word *, word *);
+
struct redir{
- char type; /* what to do */
- short from, to; /* what to do it to */
- redir *next; /* what else to do (reverse order) */
+ int type; /* what to do */
+ int from, to; /* what to do it to */
+ redir *next; /* what else to do (reverse order) */
};
-#define NSTATUS ERRMAX /* length of status (from plan 9) */
+#define NSTATUS 128 /* length of status */
+
/*
* redir types
*/
#define ROPEN 1 /* dup2(from, to); close(from); */
#define RDUP 2 /* dup2(from, to); */
#define RCLOSE 3 /* close(from); */
+void shuffleredir(void);
+
struct thread{
code *code; /* code for this thread */
int pc; /* code[pc] is the next instruction */
- int line; /* source code line */
+ int line; /* source code line for Xsrcline */
list *argv; /* argument stack */
redir *redir; /* redirection stack */
redir *startredir; /* redir inheritance point */
var *local; /* list of local variables */
- char *cmdfile; /* file name in Xrdcmd */
- io *cmdfd; /* file descriptor for Xrdcmd */
- int lexline; /* file descriptor line */
- int iflast; /* static `if not' checking */
- int eof; /* is cmdfd at eof? */
+ lexer *lex; /* lexer for Xrdcmds */
int iflag; /* interactive? */
- int lineno; /* linenumber */
int pid; /* process for Xpipewait to wait for */
char status[NSTATUS]; /* status for Xpipewait */
- tree *treenodes; /* tree nodes created by this process */
thread *ret; /* who continues when this finishes */
};
+
thread *runq;
+void turfstack(var*);
+
code *codecopy(code*);
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);
};
-extern struct builtin Builtin[];
-int eflagok; /* kludge flag so that -e doesn't exit in startup */
+extern void (*builtinfunc(char *name))(void);
void execcd(void), execwhatis(void), execeval(void), execexec(void);
int execforkexec(void);
void execexit(void), execshift(void);
void execwait(void), execumask(void), execdot(void), execflag(void);
-void execfunc(var*), execcmds(io *);
-char *curfile(thread*); \ No newline at end of file
+void execfunc(var*), execcmds(io*, char*, var*, redir*);
+void startfunc(var*, word*, var*, redir*);
+
+char *srcfile(thread*);
+char *getstatus(void);