From f2efbb46ef89c7c1693400f7209113c50c959f02 Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Wed, 13 Oct 2021 10:51:54 -0700 Subject: Feat(rc): working(ish) version of rc shell Removed compile commands --- sys/cmd/rc/code.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'sys/cmd/rc/code.c') diff --git a/sys/cmd/rc/code.c b/sys/cmd/rc/code.c index 81deac2..0b280ac 100644 --- a/sys/cmd/rc/code.c +++ b/sys/cmd/rc/code.c @@ -15,18 +15,18 @@ int codep, ncode; #define emits(x) ((void)(codep!=ncode || morecode()), codebuf[codep].s = (x), codep++) void stuffdot(int); -char *fnstr(tree*); -void outcode(tree*, int); -void codeswitch(tree*, int); -int iscase(tree*); -code *codecopy(code*); -void codefree(code*); +char *fnstr(Tree*); +void outcode(Tree*, int); +void codeswitch(Tree*, int); +int iscase(Tree*); +Code *codecopy(Code*); +void codefree(Code*); int morecode(void) { ncode+=100; - codebuf = (code *)realloc((char *)codebuf, ncode*sizeof codebuf[0]); + codebuf = (Code *)realloc((char *)codebuf, ncode*sizeof codebuf[0]); if(codebuf==0) panic("Can't realloc %d bytes in morecode!", ncode*sizeof codebuf[0]); @@ -43,10 +43,10 @@ stuffdot(int a) } int -compile(tree *t) +compile(Tree *t) { ncode = 100; - codebuf = (code *)emalloc(ncode*sizeof codebuf[0]); + codebuf = (Code *)emalloc(ncode*sizeof codebuf[0]); codep = 0; emiti(0); /* reference count */ outcode(t, flag['e']?1:0); @@ -68,9 +68,9 @@ cleanhere(char *f) } char* -fnstr(tree *t) +fnstr(Tree *t) { - io *f = openstr(); + Io *f = openstr(); char *v; extern char nl; char svnl = nl; @@ -84,10 +84,10 @@ fnstr(tree *t) } void -outcode(tree *t, int eflag) +outcode(Tree *t, int eflag) { int p, q; - tree *tt; + Tree *tt; if(t==0) return; if(t->type!=NOT && t->type!=';') @@ -404,12 +404,12 @@ outcode(tree *t, int eflag) */ void -codeswitch(tree *t, int eflag) +codeswitch(Tree *t, int eflag) { int leave; /* patch jump address to leave switch */ int out; /* jump here to leave switch */ int nextcase; /* patch jump address to next case */ - tree *tt; + Tree *tt; if(c1->child[0]==nil || c1->child[0]->type!=';' || !iscase(c1->child[0]->child[0])){ @@ -451,7 +451,7 @@ codeswitch(tree *t, int eflag) } int -iscase(tree *t) +iscase(Tree *t) { if(t->type!=SIMPLE) return 0; @@ -459,17 +459,17 @@ iscase(tree *t) return t->type==WORD && !t->quoted && strcmp(t->str, "case")==0; } -code* -codecopy(code *cp) +Code* +codecopy(Code *cp) { cp[0].i++; return cp; } void -codefree(code *cp) +codefree(Code *cp) { - code *p; + Code *p; if(--cp[0].i!=0) return; for(p = cp+1;p->f;p++){ -- cgit v1.2.1