+#ifndef __CTYPE_H_
+#define __CTYPE_H_
+
/* ctype.h 4.1 82/05/07 */
/*
*
*/
-
/* table 1 */
#define T_SUB 01
#define T_MET 02
#define letter(c) (((c)&0200)==0 && _ctype2[c]&(T_IDC))
#define alphanum(c) (((c)&0200)==0 && _ctype2[c]&(_IDCH))
#define astchar(c) (((c)&0200)==0 && _ctype2[c]&(T_AST))
+
+#endif
-#ifndef lint
+#include <gen.h>
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)args.c 4.4 7/31/85";
#endif
*
*/
-#include "defs.h"
+/*#include "defs.h"*/
-static struct dolnod *copyargs();
+/*static struct dolnod *copyargs();*/
static struct dolnod *dolh;
char flagadr[10];
/* ======== option handling ======== */
+static struct dolnod *copyargs __P((char *from[], int n));
-int options(argc,argv)
- char **argv;
- int argc;
-{
+int options(argc, argv) int argc; char **argv; {
register char *cp;
register char **argp=argv;
register char *flagc;
return(argc);
}
-void setargs(argi)
- char *argi[];
-{
+void setargs(argi) char *argi[]; {
/* count args */
register char **argp=argi;
register int argn=0;
assnum(&dolladr,dolc=argn-1);
}
-freeargs(blk)
- struct dolnod *blk;
-{
+int freeargs(blk) struct dolnod *blk; {
register char **argp;
register struct dolnod *argr=0;
register struct dolnod *argblk;
return(argr);
}
-static struct dolnod *copyargs(from, n)
- char *from[];
-{
- register struct dolnod *pp = (struct dolnod *)alloc(sizeof(struct dolnod)+n*sizeof(char **));
+static struct dolnod *copyargs(from, n) char *from[]; int n; {
+ register struct dolnod *pp = (struct dolnod *)malloc(sizeof(struct dolnod)+n*sizeof(char **));
register char ** np=pp->dolarg;
register char ** fp=from;
return(pp);
}
-clearup()
-{
+int clearup() {
/* force `for' $* lists to go away */
while (argfor=freeargs(argfor));
while (pop());
}
-struct dolnod *useargs()
-{
+struct dolnod *useargs() {
if (dolh) {
dolh->doluse++;
dolh->dolnxt=argfor;
-#ifndef lint
+#include <gen.h>
+/*#include "brkincr.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)blok.c 4.2 8/11/83";
#endif
*
*/
-#include "defs.h"
-
+/*#include "defs.h"*/
/*
* storage allocator
struct blk *blokp; /*current search pointer*/
struct blk *bloktop/*=(struct blk *)(end)*/; /*top of arena (last blok)*/
-
-
-void *alloc(nbytes)
- unsigned nbytes;
-{
- register unsigned rbytes = round(nbytes+BYTESPERWORD,BYTESPERWORD);
+void *malloc(nbytes) unsigned nbytes; {
+ register unsigned rbytes = round(nbytes+sizeof(char *),sizeof(char *));
for(;;) {
int c=0;
}
}
-void addblok(reqd)
- unsigned reqd;
-{
+void addblok(reqd) unsigned reqd; {
if (stakbas!=staktop) {
register char *rndstak;
register struct blk *blokstak;
pushstak(0);
- rndstak=round(staktop,BYTESPERWORD);
+ rndstak=round(staktop,sizeof(char *));
blokstak=(struct blk *)(stakbas)-1;
blokstak->word=stakbsy; stakbsy=blokstak;
bloktop->word=(struct blk *)(Rcheat(rndstak)|BUSY);
reqd += brkincr; reqd &= ~(brkincr-1);
blokp=bloktop;
bloktop=bloktop->word=(struct blk *)(Rcheat(bloktop)+reqd);
- bloktop->word=(struct blk *)((void *)(end)+1);
- {
+ bloktop->word=(struct blk *)((void *)(end)+1); {
register char *stakadr=(char *)(bloktop+2);
staktop=movstr(stakbot,stakadr);
}
}
-void free(ap)
- void *ap;
-{
+void free(ap) void *ap; {
#define p ((struct blk *)ap)
if (p && p<bloktop) {
Lcheat(p[-1].word) &= ~BUSY;
}
#ifdef DEBUG
-chkbptr(ptr)
- struct blk *ptr;
-{
+int chkbptr(ptr) struct blk *ptr; {
int exf=0;
register struct blk *p = end;
register struct blk *q;
+#ifndef _BRKINCR_H_
+#define _BRKINCR_H_
+
/* brkincr.h 4.1 82/05/07 */
#define BRKINCR 01000
#define BRKMAX 04000
+
+#endif
-#ifndef lint
+#include "defs.h"
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)builtin.c 4.2 8/11/83";
#endif
-builtin(argn, com)
-int argn;
-char **com;
-{return(0);}
+int builtin(argn, com) int argn; char **com; {return(0);}
-#ifndef lint
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+#include "sym.h"
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)cmd.c 4.2 8/11/83";
#endif
*
*/
-#include "defs.h"
-#include "sym.h"
-
-extern struct ionod *inout();
-extern void chkword();
-extern void chksym();
-extern struct trenod *term();
-extern struct trenod *makelist();
-extern struct trenod *list();
-extern struct regnod *syncase();
-extern struct trenod *item();
-extern int skipnl();
-extern void prsym();
-extern void synbad();
-
+/*#include "defs.h"*/
+/*#include "sym.h"*/
+
+/*extern struct ionod *inout();*/
+/*extern void chkword();*/
+/*extern void chksym();*/
+/*extern struct trenod *term();*/
+/*extern struct trenod *makelist();*/
+/*extern struct trenod *list();*/
+/*extern struct regnod *syncase();*/
+/*extern struct trenod *item();*/
+/*extern int skipnl();*/
+/*extern void prsym();*/
+/*extern void synbad();*/
/* ======== command line decoding ========*/
-
-
-
-struct trenod *makefork(flgs, i)
- int flgs;
- struct trenod *i;
-{
+static struct trenod *makelist __P((int type, struct trenod *i, struct trenod *r));
+static struct trenod *list __P((int flg));
+static struct trenod *term __P((int flg));
+static struct regnod *syncase __P((register int esym));
+static struct trenod *item __P((int flag));
+static int skipnl __P((void));
+static struct ionod *inout __P((struct ionod *lastio));
+static void chkword __P((void));
+static void chksym __P((int sym));
+static void prsym __P((int sym));
+static void synbad __P((void));
+
+struct trenod *makefork(flgs, i) int flgs; struct trenod *i; {
register struct forknod *t;
t=(struct forknod *)getstak(sizeof(struct forknod));
return((struct trenod *)t);
}
-static struct trenod *makelist(type,i,r)
- int type;
- struct trenod *i, *r;
-{
+static struct trenod *makelist(type, i, r) int type; struct trenod *i; struct trenod *r; {
register struct lstnod *t;
if (i==0 || r==0) {
* list [ ; cmd ]
*/
-struct trenod *cmd(sym,flg)
- register int sym;
- int flg;
-{
+struct trenod *cmd(sym, flg) register int sym; int flg; {
register struct trenod *i, *e;
i = list(flg);
* list || term
*/
-static struct trenod *list(flg)
-{
+static struct trenod *list(flg) int flg; {
register struct trenod *r;
register int b;
* item |^ term
*/
-static struct trenod *term(flg)
-{
+static struct trenod *term(flg) int flg; {
register struct trenod *t;
reserv++;
}
}
-static struct regnod *syncase(esym)
- register int esym;
-{
+static struct regnod *syncase(esym) register int esym; {
skipnl();
if (wdval==esym) {
return(0);
* begin ... end
*/
-static struct trenod *item(flag)
- bool flag;
-{
+static struct trenod *item(flag) int flag; {
struct trenod *_t;
register struct ionod *io;
switch (wdval) {
- case CASYM:
- {
+ case CASYM: {
#define t (*(struct swnod **)&_t)
t=(struct swnod *)getstak(sizeof(struct swnod));
chkword();
#undef t
}
- case IFSYM:
- {
+ case IFSYM: {
#define t (*(struct ifnod **)&_t)
register int w;
t=(struct ifnod *)getstak(sizeof(struct ifnod));
#undef t
}
- case FORSYM:
- {
+ case FORSYM: {
#define t (*(struct fornod **)&_t)
t=(struct fornod *)getstak(sizeof(struct fornod));
t->fortyp=TFOR;
}
case WHSYM:
- case UNSYM:
- {
+ case UNSYM: {
#define t (*(struct whnod **)&_t)
t=(struct whnod *)getstak(sizeof(struct whnod));
t->whtyp=(wdval==WHSYM ? TWH : TUN);
_t=cmd(KTSYM,NLFLG);
break;
- case '(':
- {
+ case '(': {
register struct parnod *p;
p=(struct parnod *)getstak(sizeof(struct parnod));
p->partre=cmd(')',NLFLG);
return(0);
}
- case 0:
- {
+ case 0: {
#define t (*(struct comnod **)&_t)
register struct argnod *argp;
register struct argnod **argtail;
return(_t);
}
-
-static int skipnl()
-{
+static int skipnl() {
while ((reserv++, word()=='\n')) { chkpr('\n'); }
return(wdval);
}
-static struct ionod *inout(lastio)
- struct ionod *lastio;
-{
+static struct ionod *inout(lastio) struct ionod *lastio; {
register int iof;
register struct ionod *iop;
register char c;
return(iop);
}
-static void chkword()
-{
+static void chkword() {
if (word()) {
synbad();
}
}
-static void chksym(sym)
-{
+static void chksym(sym) int sym; {
register int x = sym&wdval;
if (((x&SYMFLG) ? x : sym) != wdval) {
synbad();
}
}
-static void prsym(sym)
-{
+static void prsym(sym) int sym; {
if (sym&SYMFLG) {
register struct sysnod *sp=reserved;
while (sp->sysval
}
}
-static void synbad()
-{
+static void synbad() {
prp(); prs(synmsg);
if ((flags&ttyflg)==0) {
prs(atline); prn(standin->flin);
-#ifndef lint
+#include "_ctype.h"
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)ctype.c 4.2 8/11/83";
#endif
*
*/
-#include "defs.h"
+/*#include "defs.h"*/
char _ctype1[] = {
/* 000 001 002 003 004 005 006 007 */
0, 0, 0, 0, _BAR, 0, 0, 0
};
-
char _ctype2[] = {
/* 000 001 002 003 004 005 006 007 */
0, 0, 0, 0, 0, 0, 0, 0,
+#ifndef _DEFS_H_
+#define _DEFS_H_
+
+#include <setjmp.h>
+#include <sys/file.h>
+#include "mode.h"
+#include "name.h"
+
/* defs.h 4.4 85/03/19 */
/*
/* arg list terminator */
#define ENDARGS 0
-#include "mode.h"
-#include "name.h"
-
+/*#include "mode.h"*/
+/*#include "name.h"*/
/* result type declarations */
-void *alloc();
-void addblok();
-char *make();
-char *movstr();
-struct trenod *cmd();
-struct trenod *makefork();
-struct namnod *lookup();
-void setname();
-void setargs();
-struct dolnod *useargs();
-float expr();
-char *catpath();
-char *getpath();
-char **scan();
-char *mactrim();
-char *macro();
-char *execs();
-void await();
-void post();
-char *copyto();
-void exname();
-char *staknam();
-void printnam();
-void printflg();
-void prs();
-void prc();
-void setupenv();
-char **setenv();
+/*void *malloc();*/
+/*void addblok();*/
+/*char *make();*/
+/*char *movstr();*/
+/*struct trenod *cmd();*/
+/*struct trenod *makefork();*/
+/*struct namnod *lookup();*/
+/*void setname();*/
+/*void setargs();*/
+/*struct dolnod *useargs();*/
+/*float expr();*/
+/*char *catpath();*/
+/*char *getpath();*/
+/*char **scan();*/
+/*char *mactrim();*/
+/*char *macro();*/
+/*char *execs();*/
+/*void await();*/
+/*void post();*/
+/*char *copyto();*/
+/*void exname();*/
+/*char *staknam();*/
+/*void printnam();*/
+/*void printflg();*/
+/*void prs();*/
+/*void prc();*/
+/*void setupenv();*/
+/*char **setenv();*/
#define attrib(n,f) (n->namflg |= f)
#define round(a,b) (((int)(((void *)(a)+b)-1))&~((b)-1))
extern int flags;
/* error exits from various parts of shell */
-#include <setjmp.h>
+/*#include <setjmp.h>*/
extern jmp_buf subshell;
extern jmp_buf errshell;
extern jmp_buf INTbuf;
#define SIGSET 4
#define SIGMOD 8
-void fault();
+/*void fault();*/
extern bool trapnote;
extern char *trapcom[];
extern bool trapflg[];
extern struct blk *end;
#include "_ctype.h"
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+/* args.c */
+int options __P((int argc, char **argv));
+void setargs __P((char *argi[]));
+int freeargs __P((struct dolnod *blk));
+int clearup __P((void));
+struct dolnod *useargs __P((void));
+
+/* blok.c */
+void *malloc __P((unsigned nbytes));
+void addblok __P((unsigned reqd));
+void free __P((void *ap));
+int chkbptr __P((struct blk *ptr));
+
+/* builtin.c */
+int builtin __P((int argn, char **com));
+
+/* cmd.c */
+struct trenod *makefork __P((int flgs, struct trenod *i));
+struct trenod *cmd __P((register int sym, int flg));
+
+/* error.c */
+int exitset __P((void));
+int sigchk __P((void));
+int failed __P((char *s1, char *s2));
+int error __P((char *s));
+int exitsh __P((int xno));
+int done __P((void));
+int rmtemp __P((struct ionod *base));
+
+/* expand.c */
+int expand __P((char *as, int rflg));
+int gmatch __P((register char *s, register char *p));
+int makearg __P((register struct argnod *args));
+
+/* fault.c */
+void fault __P((register int sig));
+int stdsigs __P((void));
+void (*ignsig __P((int n))) __P((void));
+int getsig __P((int n));
+int oldsigs __P((void));
+int clrsig __P((int i));
+int chktrap __P((void));
+
+/* io.c */
+int initf __P((int fd));
+int estabf __P((register char *s));
+int push __P((struct fileblk *af));
+int pop __P((void));
+int chkpipe __P((int *pv));
+int chkopen __P((char *idf));
+int _rename __P((register int f1, register int f2));
+int create __P((char *s));
+int tmpfil __P((void));
+int copy __P((struct ionod *ioparg));
+
+/* macro.c */
+char *macro __P((char *as));
+int subst __P((int in, int ot));
+
+/* main.c */
+int main __P((int c, char *v[]));
+int chkpr __P((int eor));
+int settmp __P((void));
+int Ldup __P((register int fa, register int fb));
+
+/* name.c */
+int syslook __P((char *w, struct sysnod syswds[]));
+int setlist __P((register struct argnod *arg, int xp));
+void setname __P((char *argi, int xp));
+int replace __P((register char **a, char *v));
+int dfault __P((struct namnod *n, char *v));
+int assign __P((struct namnod *n, char *v));
+int readvar __P((char **names));
+int assnum __P((char **p, int i));
+char *make __P((char *v));
+struct namnod *lookup __P((register char *nam));
+int namscan __P((void (*fn)(void)));
+void printnam __P((struct namnod *n));
+void exname __P((register struct namnod *n));
+void printflg __P((register struct namnod *n));
+void setupenv __P((void));
+void countnam __P((struct namnod *n));
+void pushnam __P((struct namnod *n));
+char **setenv __P((void));
+
+/* print.c */
+int newline __P((void));
+int blank __P((void));
+int prp __P((void));
+void prs __P((char *as));
+void prc __P((int c));
+int prt __P((long t));
+int prn __P((int n));
+int itos __P((int n));
+int stoi __P((char *icp));
+
+/* service.c */
+void initio __P((struct ionod *iop));
+char *getpath __P((char *s));
+int pathopen __P((register char *path, register char *name));
+char *catpath __P((register char *path, char *name));
+void execa __P((char *at[]));
+int gocsh __P((register char **t, register char *cp, register char **xecenv));
+int postclr __P((void));
+void post __P((int pcsid));
+void await __P((int i));
+int trim __P((char *at));
+char *mactrim __P((char *s));
+char **scan __P((int argn));
+int getarg __P((struct comnod *ac));
+
+/* setbrk.c */
+int setbrk __P((int incr));
+
+/* string.c */
+char *movstr __P((register char *a, register char *b));
+int any __P((int c, char *s));
+int cf __P((register char *s1, register char *s2));
+int length __P((char *as));
+
+/* word.c */
+int word __P((void));
+int nextc __P((int quote));
+int readc __P((void));
+
+/* xec.c */
+int execute __P((struct trenod *argt, int execflg, int *pf1, int *pf2));
+int execexp __P((char *s, int f));
+
+#endif
+#ifndef _DUP_H_
+#define _DUP_H_
+
/* dup.h 4.1 82/05/07 */
/*
*/
#define DUPFLG 0100
+
+#endif
-#ifndef lint
+/*#include <setjmp.h> defs.h*/
+/*#include <sys/file.h> defs.h*/
+#include <sys/proc.h>
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)error.c 4.2 8/11/83";
#endif
*
*/
-#include "defs.h"
-
+/*#include "defs.h"*/
/* ======== error handling ======== */
-exitset()
-{
+int exitset() {
assnum(&exitadr,exitval);
}
-sigchk()
-{
+int sigchk() {
/* Find out if it is time to go away.
* `trapnote' is set to SIGSET when fault is seen and
* no trap has been set.
}
}
-failed(s1,s2)
- char *s1, *s2;
-{
+int failed(s1, s2) char *s1; char *s2; {
prp(); prs(s1);
if (s2) {
prs(colon); prs(s2);
newline(); exitsh(ERROR);
}
-error(s)
- char *s;
-{
+int error(s) char *s; {
failed(s,NULL);
}
-exitsh(xno)
- int xno;
-{
+int exitsh(xno) int xno; {
/* Arrive here from `FATAL' errors
* a) exit command,
* b) default trap,
}
}
-done()
-{
+int done() {
register char *t;
if (t=trapcom[0]) {
trapcom[0]=0; /*should free but not long */
_exit(exitval);
}
-rmtemp(base)
- struct ionod *base;
-{
+int rmtemp(base) struct ionod *base; {
while (iotemp>base) {
unlink(iotemp->ioname);
iotemp=iotemp->iolst;
-#ifndef lint
+/*#include <setjmp.h> defs.h*/
+#include <sys/dir.h>
+#include <sys/stat.h>
+/*#include "_ctype.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)expand.c 4.5 8/11/83";
#endif
*
*/
-#include "defs.h"
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <sys/dir.h>
-
-
+/*#include "defs.h"*/
+/*#include <sys/param.h>*/
+/*#include <sys/stat.h>*/
+/*#include <sys/dir.h>*/
/* globals (file name generation)
*
*
*/
-extern void addg();
+/*extern void addg();*/
+static void addg __P((char *as1, char *as2, char *as3));
-int expand(as,rflg)
- char *as;
-{
+int expand(as, rflg) char *as; int rflg; {
int count;
DIR *dirf;
bool dir=0;
s=cs=as;
- /* check for meta chars */
- {
+ /* check for meta chars */ {
register bool slash; slash=0;
while (!fngchar(*cs)) {
*rescan='/';
}
}
-
- {
+ {
register char c;
s=as;
return(count);
}
-gmatch(s, p)
- register char *s, *p;
-{
+int gmatch(s, p) register char *s; register char *p; {
register int scc;
char c;
}
}
-static void addg(as1,as2,as3)
- char *as1, *as2, *as3;
-{
+static void addg(as1, as2, as3) char *as1; char *as2; char *as3; {
register char *s1, *s2;
register int c;
- s2 = locstak()+BYTESPERWORD;
+ s2 = locstak()+sizeof(char *);
s1=as1;
while (c = *s1++) {
makearg(endstak(s2));
}
-makearg(args)
- register struct argnod *args;
-{
+int makearg(args) register struct argnod *args; {
args->argnxt=gchain;
gchain=args;
}
-#ifndef lint
+#include <gen.h>
+/*#include <setjmp.h> defs.h*/
+/*#include <sys/signal.h> gen.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)fault.c 4.3 8/11/83";
#endif
*
*/
-#include "defs.h"
-
+/*#include "defs.h"*/
char *trapcom[MAXTRAP];
bool trapflg[MAXTRAP];
/* ======== fault handling routines ======== */
-
-void fault(sig)
- register int sig;
-{
+void fault(sig) register int sig; {
register int flag;
if (sig==MEMF) {
}
}
-stdsigs()
-{
+int stdsigs() {
ignsig(QUIT);
getsig(INTR);
getsig(MEMF);
getsig(ALARM);
}
-void
-(*ignsig(n))()
-{
+void (*ignsig(n))() int n; {
register void (*s)();
register int i;
return(s);
}
-getsig(n)
-{
+int getsig(n) int n; {
register int i;
if (trapflg[i=n]&SIGMOD || ignsig(i)==SIG_DFL) {
}
}
-oldsigs()
-{
+int oldsigs() {
register int i;
register char *t;
trapnote=0;
}
-clrsig(i)
- int i;
-{
+int clrsig(i) int i; {
free(trapcom[i]); trapcom[i]=0;
if (trapflg[i]&SIGMOD) {
signal(i,fault);
}
}
-chktrap()
-{
+int chktrap() {
/* check for traps */
register int i=MAXTRAP;
register char *t;
-#ifndef lint
+/*#include <sys/file.h> defs.h*/
+/*#include "_ctype.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)io.c 4.3 3/19/85";
#endif
*
*/
-#include "defs.h"
-
+/*#include "defs.h"*/
/* ======== input output and file copying ======== */
-initf(fd)
- int fd;
-{
+int initf(fd) int fd; {
register struct fileblk *f=standin;
f->fdes=fd; f->fsiz=((flags&(oneflg|ttyflg))==0 ? BUFSIZ : 1);
f->feof=0;
}
-estabf(s)
- register char *s;
-{
+int estabf(s) register char *s; {
register struct fileblk *f;
(f=standin)->fdes = -1;
return(f->feof=(s==0));
}
-push(af)
- struct fileblk *af;
-{
+int push(af) struct fileblk *af; {
register struct fileblk *f;
(f=af)->fstak=standin;
standin=f;
}
-pop()
-{
+int pop() {
register struct fileblk *f;
if ((f=standin)->fstak) {
}
}
-chkpipe(pv)
- int *pv;
-{
+int chkpipe(pv) int *pv; {
if (pipe(pv)<0 || pv[INPIPE]<0 || pv[OTPIPE]<0) {
error(piperr);
}
}
-chkopen(idf)
- char *idf;
-{
+int chkopen(idf) char *idf; {
register int rc;
if ((rc=open(idf,0))<0) {
}
}
-rename(f1,f2)
- register int f1, f2;
-{
+int _rename(f1, f2) register int f1; register int f2; {
if (f1!=f2) {
dup2(f1, f2);
close(f1);
}
}
-create(s)
- char *s;
-{
+int create(s) char *s; {
register int rc;
if ((rc=creat(s,0666))<0) {
}
}
-tmpfil()
-{
+int tmpfil() {
itos(serial++); movstr(numbuf,tmpnam);
return(create(tmpout));
}
/* set by trim */
bool nosubst;
-copy(ioparg)
- struct ionod *ioparg;
-{
+int copy(ioparg) struct ionod *ioparg; {
char c, *ends;
register char *cline, *clinep;
int fd;
-#ifndef lint
+/*#include <sys/file.h> defs.h*/
+/*#include "_ctype.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "name.h" defs.h*/
+/*#include "stak.h" defs.h*/
+#include "sym.h"
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)macro.c 4.3 8/11/83";
#endif
*
*/
-#include "defs.h"
-#include "sym.h"
+/*#include "defs.h"*/
+/*#include "sym.h"*/
static char quote; /* used locally */
static char quoted; /* used locally */
+static char *copyto __P((int endch));
+static skipto __P((int endch));
+static getch __P((int endch));
+static comsubst __P((void));
+static flush __P((int ot));
-
-static char *copyto(endch)
- register char endch;
-{
+static char *copyto(endch) int endch; {
register char c;
while ((c=getch(endch))!=endch && c) { pushstak(c|quote); }
if (c!=endch) { error(badsub); }
}
-static skipto(endch)
- register char endch;
-{
+static skipto(endch) int endch; {
/* skip chars up to } */
register char c;
while ((c=readc()) && c!=endch) {
switch (c) {
- case SQUOTE: skipto(SQUOTE); break;
+ case '`': skipto('`'); break;
- case DQUOTE: skipto(DQUOTE); break;
+ case '"': skipto('"'); break;
- case DOLLAR: if (readc()==BRACE) { skipto('}');
+ case '$': if (readc()=='{') { skipto('}');
}
}
}
if (c!=endch) { error(badsub); }
}
-static getch(endch)
- char endch;
-{
+static getch(endch) int endch; {
register char d;
retry:
if (!subchar(d)) {
return(d);
}
- if (d==DOLLAR) {
+ if (d=='$') {
register int c;
if ((c=readc(), dolchar(c))) {
struct namnod *n=NULL;
char idb[2];
char *id=idb;
- if (bra=(c==BRACE)) { c=readc(); }
+ if (bra=(c=='{')) { c=readc(); }
if (letter(c)) {
argp=relstak();
while (alphanum(c)) { pushstak(c); c=readc(); }
else if (d==endch) {
return(d);
}
- else if (d==SQUOTE) {
+ else if (d=='`') {
comsubst(); goto retry;
}
- else if (d==DQUOTE) {
+ else if (d=='"') {
quoted++; quote^=0200; goto retry;
}
return(d);
}
-char *macro(as)
- char *as;
-{
+char *macro(as) char *as; {
/* Strip "" and do $ substitution
* Leaves result on top of stack
*/
return(fixstak());
}
-static comsubst()
-{
+static comsubst() {
/* command substn */
struct fileblk cb;
register char d;
register char *savptr = fixstak();
usestak();
- while ((d=readc())!=SQUOTE && d) { pushstak(d); }
-
- {
+ while ((d=readc())!='`' && d) { pushstak(d); }
+ {
register char *argc;
trim(argc=fixstak());
push(&cb); estabf(argc);
- }
- {
+ } {
register struct trenod *t = makefork(FPOU,cmd(EOFSYM,MTFLG|NLFLG));
int pv[2];
#define CPYSIZ 512
-subst(in,ot)
- int in, ot;
-{
+int subst(in, ot) int in; int ot; {
register char c;
struct fileblk fb;
register int count=CPYSIZ;
push(&fb); initf(in);
- /* DQUOTE used to stop it from quoting */
- while (c=(getch(DQUOTE)&0177)) {
+ /* '"' used to stop it from quoting */
+ while (c=(getch('"')&0177)) {
pushstak(c);
if (--count == 0) {
flush(ot); count=CPYSIZ;
pop();
}
-static flush(ot)
-{
+static flush(ot) int ot; {
write(ot,stakbot,staktop-stakbot);
if (flags&execpr) { write(output,stakbot,staktop-stakbot); }
staktop=stakbot;
-#ifndef lint
+/*#include <setjmp.h> defs.h*/
+/*#include <sys/file.h> defs.h*/
+#include <sys/ioctl.h>
+#include <sys/proc.h>
+#include <sys/stat.h>
+/*#include "brkincr.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+#include "sym.h"
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)main.c 4.3 3/19/85";
#endif
*
*/
-#include "defs.h"
-#include "sym.h"
-#include "timeout.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sgtty.h>
-#include <signal.h>
+/*#include "defs.h"*/
+/*#include "sym.h"*/
+/*#include "timeout.h"*/
+/*#include <sys/types.h>*/
+/*#include <sys/stat.h>*/
+/*#include <sgtty.h>*/
+/*#include <signal.h>*/
/* moved here from defs.h, which now just declares them extern */
/* temp files and io */
struct fileblk stdfile;
struct fileblk *standin = &stdfile;
-extern void exfile();
+/*extern void exfile();*/
+static void exfile __P((int prof));
-
-
-main(c, v)
- int c;
- char *v[];
-{
+int main(c, v) int c; char *v[]; {
register int rflag=ttyflg;
/* initialise storage allocation */
}
else {
*execargs=dolv; /* for `ps' cmd */
-#endif;
+#endif
}
exfile(0);
done();
}
-static void exfile(prof)
-bool prof;
-{
+static void exfile(prof) int prof; {
register long mailtime = 0;
register int userid;
struct stat statb;
dfault(&ps1nod, (userid?stdprompt:supprompt));
dfault(&ps2nod, readmsg);
flags |= ttyflg|prompt; ignsig(KILL);
-/*
- {
+/* {
#include <signal.h>
signal(SIGTTIN, SIG_IGN);
signal(SIGTTOU, SIG_IGN);
}
}
-chkpr(eor)
-char eor;
-{
+int chkpr(eor) int eor; {
if ((flags&prompt) && standin->fstak==0 && eor=='\n') {
prs(ps2nod.namval);
}
}
-settmp()
-{
+int settmp() {
itos(getpid()); serial=0;
tmpnam=movstr(numbuf,&tmpout[TMPNAM]);
}
-Ldup(fa, fb)
- register int fa, fb;
-{
+int Ldup(fa, fb) register int fa; register int fb; {
dup2(fa, fb);
close(fa);
ioctl(fb, FIOCLEX, 0);
+#ifndef _MODE_H_
+#define _MODE_H_
+
/* mode.h 4.1 82/05/07 */
/*
struct ionod *ionxt;
struct ionod *iolst;
};
+
+#endif
-#ifndef lint
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+#include "sym.h"
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)msg.c 4.4 5/22/85";
#endif
*
*/
-
-#include "defs.h"
-#include "sym.h"
+/*#include "defs.h"*/
+/*#include "sym.h"*/
char version[] = "\nVERSION sys137 DATE 1978 Nov 6 14:29:22\n";
-#ifndef lint
+#include <gen.h>
+/*#include <strings.h> gen.h*/
+/*#include <sys/file.h> defs.h*/
+/*#include <sys/proc.h> gen.h*/
+/*#include "_ctype.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "name.h" defs.h*/
+/*#include "stak.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)name.c 4.4 10/31/85";
#endif
*
*/
-#include "defs.h"
-
-extern bool chkid();
+/*#include "defs.h"*/
+/*extern bool chkid();*/
struct namnod ps2nod = { NULL, NULL, ps2name},
fngnod = { NULL, NULL, fngname},
struct namnod *namep = &mailnod;
-
/* ======== variable and string handling ======== */
-syslook(w,syswds)
- char *w;
- struct sysnod syswds[];
-{
+static bool chkid __P((char *nam));
+static void namwalk __P((register struct namnod *np));
+static char *staknam __P((register struct namnod *n));
+
+int syslook(w, syswds) char *w; struct sysnod syswds[]; {
register char first;
register char *s;
register struct sysnod *syscan;
return(0);
}
-setlist(arg,xp)
- register struct argnod *arg;
- int xp;
-{
+int setlist(arg, xp) register struct argnod *arg; int xp; {
while (arg) {
register char *s=mactrim(arg->argval);
setname(s, xp);
}
}
-void setname(argi, xp)
- char *argi;
- int xp;
-{
+void setname(argi, xp) char *argi; int xp; {
register char *argscan=argi;
register struct namnod *n;
failed(argi,notid);
}
-replace(a, v)
- register char **a;
- char *v;
-{
+int replace(a, v) register char **a; char *v; {
free(*a); *a=make(v);
}
-dfault(n,v)
- struct namnod *n;
- char *v;
-{
+int dfault(n, v) struct namnod *n; char *v; {
if (n->namval==0) {
assign(n,v);
}
}
-assign(n,v)
- struct namnod *n;
- char *v;
-{
+int assign(n, v) struct namnod *n; char *v; {
if (n->namflg&N_RDONLY) {
failed(n->namid,wtfailed);
}
}
}
-int readvar(names)
- char **names;
-{
+int readvar(names) char **names; {
struct fileblk fb;
register struct fileblk *f = &fb;
register char c;
return(rc);
}
-assnum(p, i)
- char **p;
- int i;
-{
+int assnum(p, i) char **p; int i; {
itos(i); replace(p,numbuf);
}
-char *make(v)
- char *v;
-{
+char *make(v) char *v; {
register char *p;
if (v) {
- movstr(v,p=alloc(length(v)));
+ movstr(v,p=malloc(length(v)));
return(p);
}
else {
}
}
-
-struct namnod *lookup(nam)
- register char *nam;
-{
+struct namnod *lookup(nam) register char *nam; {
register struct namnod *nscan=namep;
register struct namnod **prev;
int LR;
}
/* add name node */
- nscan=alloc(sizeof *nscan);
+ nscan=malloc(sizeof *nscan);
nscan->namlft=nscan->namrgt=NULL;
nscan->namid=make(nam);
nscan->namval=0; nscan->namflg=N_DEFAULT; nscan->namenv=0;
return(*prev = nscan);
}
-static bool chkid(nam)
- char *nam;
-{
+static bool chkid(nam) char *nam; {
register char * cp=nam;
if (!letter(*cp)) {
}
static void (*namfn)();
-namscan(fn)
- void (*fn)();
-{
+int namscan(fn) void (*fn)(); {
namfn=fn;
namwalk(namep);
}
-static void namwalk(np)
- register struct namnod *np;
-{
+static void namwalk(np) register struct namnod *np; {
if (np) {
namwalk(np->namlft);
(*namfn)(np);
}
}
-void printnam(n)
- struct namnod *n;
-{
+void printnam(n) struct namnod *n; {
register char *s;
sigchk();
}
}
-static char *staknam(n)
- register struct namnod *n;
-{
+static char *staknam(n) register struct namnod *n; {
register char *p;
p=movstr(n->namid,staktop);
return(getstak(p+1-stakbot));
}
-void exname(n)
- register struct namnod *n;
-{
+void exname(n) register struct namnod *n; {
if (n->namflg&N_EXPORT) {
free(n->namenv);
n->namenv = make(n->namval);
}
}
-void printflg(n)
- register struct namnod *n;
-{
+void printflg(n) register struct namnod *n; {
if (n->namflg&N_EXPORT) {
prs(export); blank();
}
}
}
-void setupenv()
-{
+void setupenv() {
register char **e=environ;
while (*e) { setname(*e++, N_ENVNAM); }
static int namec;
-void countnam(n)
- struct namnod *n;
-{
+void countnam(n) struct namnod *n; {
namec++;
}
static char **argnam;
-void pushnam(n)
- struct namnod *n;
-{
+void pushnam(n) struct namnod *n; {
if (n->namval) {
*argnam++ = staknam(n);
}
}
-char **setenv()
-{
+char **setenv() {
register char **er;
namec=0;
namscan(countnam);
- argnam = er = getstak(namec*BYTESPERWORD+BYTESPERWORD);
+ argnam = er = getstak(namec*sizeof(char *)+sizeof(char *));
namscan(pushnam);
*argnam++ = 0;
return(er);
+#ifndef _NAME_H_
+#define _NAME_H_
+
/* name.h 4.1 82/05/07 */
/*
*
*/
-
#define N_RDONLY 0100000
#define N_EXPORT 0040000
#define N_ENVNAM 0020000
char *namenv;
int namflg;
};
+
+#endif
-#ifndef lint
+/*#include <sys/file.h> defs.h*/
+/*#include "_ctype.h" defs.h*/
+#include "defs.h"
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)print.c 4.2 8/11/83";
#endif
*
*/
-#include "defs.h"
+/*#include "defs.h"*/
char numbuf[6];
-
/* printing and io conversion */
-newline()
-{ prc('\n');
+int newline() { prc('\n');
}
-blank()
-{ prc(' ');
+int blank() { prc(' ');
}
-prp()
-{
+int prp() {
if ((flags&prompt)==0 && cmdadr) {
prs(cmdadr); prs(colon);
}
}
-void prs(as)
- char *as;
-{
+void prs(as) char *as; {
register char *s;
if (s=as) {
}
}
-void prc(c)
- char c;
-{
+void prc(c) int c; {
if (c) {
write(output,&c,1);
}
}
-prt(t)
- long t;
-{
+int prt(t) long t; {
register int hr, min, sec;
t += 30; t /= 60;
prn(sec); prc('s');
}
-prn(n)
- int n;
-{
+int prn(n) int n; {
itos(n); prs(numbuf);
}
-itos(n)
-{
+int itos(n) int n; {
register char *abuf; register unsigned a, i; int pr, d;
abuf=numbuf; pr=0; a=n;
for (i=10000; i!=1; i/=10) {
*abuf++=0;
}
-stoi(icp)
-char *icp;
-{
+int stoi(icp) char *icp; {
register char *cp = icp;
register int r = 0;
register char c;
return(r);
}
}
-
-#ifndef lint
+/*#include <setjmp.h> defs.h*/
+/*#include <sys/errno.h> defs.h*/
+#include <sys/exec.h>
+/*#include <sys/file.h> defs.h*/
+#include <sys/ioctl.h>
+#include <sys/wait.h>
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)service.c 4.4 3/19/85";
#endif
*
*/
-#include "defs.h"
+/*#include "defs.h"*/
-
-extern void gsort();
+/*extern void gsort();*/
#define ARGMK 01
#define ENOENT 2
#define ETXTBSY 26
-
-
/* service routines for `execute' */
-void initio(iop)
- struct ionod *iop;
-{
+static char *execs __P((char *ap, register char *t[]));
+static void gsort __P((char *from[], char *to[]));
+static int split __P((register char *s));
+
+void initio(iop) struct ionod *iop; {
register char *ion;
register int iof, fd;
fd=create(ion);
}
if (fd>=0) {
- rename(fd,iof&IOUFD);
+ _rename(fd,iof&IOUFD);
}
}
initio(iop->ionxt);
}
}
-char *getpath(s)
- char *s;
-{
+char *getpath(s) char *s; {
register char *path;
if (any('/',s)) {
if (flags&rshflg) {
}
}
-int pathopen(path, name)
- register char *path, *name;
-{
+int pathopen(path, name) register char *path; register char *name; {
register int f;
do {
return(f);
}
-char *catpath(path,name)
- register char *path;
- char *name;
-{
+char *catpath(path, name) register char *path; char *name; {
/* leaves result on top of stack */
register char *scanp = path,
*argp = locstak();
static char *xecmsg;
static char **xecenv;
-void execa(at)
- char *at[];
-{
+void execa(at) char *at[]; {
register char *path;
register char **t = at;
}
}
-static char *execs(ap,t)
- char *ap;
- register char *t[];
-{
+static char *execs(ap, t) char *ap; register char *t[]; {
register char *p, *prefix;
prefix=catpath(ap,t[0]);
close(output); output=2;
input=chkopen(p);
- /* band aid to get csh... 2/26/79 */
- {
+ /* band aid to get csh... 2/26/79 */ {
char c;
if (!isatty(input)) {
read(input, &c, 1);
}
}
-gocsh(t, cp, xecenv)
- register char **t, *cp, **xecenv;
-{
+int gocsh(t, cp, xecenv) register char **t; register char *cp; register char **xecenv; {
char **newt[1000];
register char **p;
register int i;
static int pwlist[MAXP];
static int pwc;
-postclr()
-{
+int postclr() {
register int *pw = pwlist;
while (pw <= &pwlist[pwc]) { *pw++ = 0; }
pwc=0;
}
-void post(pcsid)
- int pcsid;
-{
+void post(pcsid) int pcsid; {
register int *pw = pwlist;
if (pcsid) {
}
}
-void await(i)
- int i;
-{
+void await(i) int i; {
int rc=0, wx=0;
int w;
int ipwc = pwc;
register int p;
register int sig;
int w_hi;
-
- {
+ {
register int *pw=pwlist;
if (setjmp(INTbuf) == 0) {
bool nosubst;
-trim(at)
- char *at;
-{
+int trim(at) char *at; {
register char *p;
register char c;
register char q=0;
nosubst=q&0200;
}
-char *mactrim(s)
- char *s;
-{
+char *mactrim(s) char *s; {
register char *t=macro(s);
trim(t);
return(t);
}
-char **scan(argn)
- int argn;
-{
+char **scan(argn) int argn; {
register struct argnod *argp = Rcheat(gchain)&~ARGMK;
register char **comargn, **comargm;
- comargn=getstak(BYTESPERWORD*argn+BYTESPERWORD); comargm = comargn += argn; *comargn = ENDARGS;
+ comargn=getstak(sizeof(char *)*argn+sizeof(char *)); comargm = comargn += argn; *comargn = ENDARGS;
while (argp) {
*--comargn = argp->argval;
return(comargn);
}
-static void gsort(from,to)
- char *from[], *to[];
-{
+static void gsort(from, to) char *from[]; char *to[]; {
int k, m, n;
register int i, j;
/* Argument list generation */
-int getarg(ac)
- struct comnod *ac;
-{
+int getarg(ac) struct comnod *ac; {
register struct argnod *argp;
register int count=0;
register struct comnod *c;
return(count);
}
-static int split(s)
- register char *s;
-{
+static int split(s) register char *s; {
register char *argp;
register int c;
int count=0;
for(;;) {
- sigchk(); argp=locstak()+BYTESPERWORD;
+ sigchk(); argp=locstak()+sizeof(char *);
while ((c = *s++, !any(c,ifsnod.namval) && c)) { *argp++ = c; }
- if (argp==staktop+BYTESPERWORD) {
+ if (argp==staktop+sizeof(char *)) {
if (c) {
continue;
}
-#ifndef lint
+#include <sys/proc.h>
+#include "defs.h"
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)setbrk.c 4.2 8/11/83";
#endif
*
*/
-#include "defs.h"
+/*#include "defs.h"*/
-setbrk(incr)
-{
+int setbrk(incr) int incr; {
register char *a=sbrk(incr);
brkend=a+incr;
return(a);
-#ifndef lint
+#include <gen.h>
+/*#include "brkincr.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)stak.c 4.2 8/11/83";
#endif
*
*/
-#include "defs.h"
+/*#include "defs.h"*/
/* moved here from stak.h, which now just declares them extern */
struct blk *stakbsy;
char *stakbot=nullstr;
-
-
/* ======== storage allocation ======== */
-char *getstak(asize)
- int asize;
-{ /* allocate requested stack */
+char *getstak(asize) int asize; { /* allocate requested stack */
register char *oldstak;
register int size;
- size=round(asize,BYTESPERWORD);
+ size=round(asize,sizeof(char *));
oldstak=stakbot;
staktop = stakbot += size;
return(oldstak);
}
-char *locstak()
-{ /* set up stack for local use
+char *locstak() { /* set up stack for local use
* should be followed by `endstak'
*/
if (brkend-stakbot<BRKINCR) {
return(stakbot);
}
-char *savstak()
-{
+char *savstak() {
assert(staktop==stakbot);
return(stakbot);
}
-char *endstak(argp)
- register char *argp;
-{ /* tidy up after `locstak' */
+char *endstak(argp) register char *argp; { /* tidy up after `locstak' */
register char *oldstak;
*argp++=0;
- oldstak=stakbot; stakbot=staktop=round(argp,BYTESPERWORD);
+ oldstak=stakbot; stakbot=staktop=round(argp,sizeof(char *));
return(oldstak);
}
-void tdystak(x)
- register char *x;
-{
+void tdystak(x) register char *x; {
/* try to bring stack back to x */
while ((void *)(stakbsy)>(void *)(x)) {
free(stakbsy);
rmtemp(x);
}
-stakchk()
-{
+int stakchk() {
if ((brkend-stakbas)>BRKINCR+BRKINCR) {
setbrk(-BRKINCR);
}
}
-char *cpystak(x)
- char *x;
-{
+char *cpystak(x) char *x; {
return(endstak(movstr(x,locstak())));
}
+#ifndef _STAK_H_
+#define _STAK_H_
+
+#include "mode.h"
+
/* stak.h 4.1 82/05/07 */
/*
/* for local use only since it hands
* out a real address for the stack top
*/
-char *locstak();
+/*char *locstak();*/
/* Will allocate the item being used and return its
* address (safe now).
/* For use after `locstak' to hand back
* new stack top and then allocate item
*/
-char *endstak();
+/*char *endstak();*/
/* Copy a string onto the stack and
* allocate the space.
*/
-char *cpystak();
+/*char *cpystak();*/
/* Allocate given ammount of stack space */
-char *getstak();
+/*char *getstak();*/
/* A chain of ptrs of stack blocks that
* have become covered by heap allocation.
extern char *staktop;
/* Used with tdystak */
-char *savstak();
+/*char *savstak();*/
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+/* stak.c */
+char *getstak __P((int asize));
+char *locstak __P((void));
+char *savstak __P((void));
+char *endstak __P((register char *argp));
+void tdystak __P((register char *x));
+int stakchk __P((void));
+char *cpystak __P((char *x));
+
+#endif
-#ifndef lint
+#include "defs.h"
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)string.c 4.2 8/11/83";
#endif
*
*/
-#include "defs.h"
-
+/*#include "defs.h"*/
/* ======== general purpose string handling ======== */
-
-char *movstr(a,b)
- register char *a, *b;
-{
+char *movstr(a, b) register char *a; register char *b; {
while (*b++ = *a++);
return(--b);
}
-int any(c,s)
- register char c;
- char *s;
-{
+int any(c, s) int c; char *s; {
register char d;
while (d = *s++) {
return(0);
}
-int cf(s1, s2)
- register char *s1, *s2;
-{
+int cf(s1, s2) register char *s1; register char *s2; {
while (*s1++ == *s2) {
if (*s2++==0) {
return(0);
return(*--s1 - *s2);
}
-int length(as)
- char *as;
-{
+int length(as) char *as; {
register char *s;
if (s=as) { while (*s++); }
+#ifndef _SYM_H_
+#define _SYM_H_
+
/* sym.h 4.1 82/05/07 */
/*
* UNIX shell
*/
-
/* symbols for parsing */
#define DOSYM 0405
#define FISYM 0420
/* for peekc */
#define MARK 0100000
+
+#endif
+#ifndef _TIMEOUT_H_
+#define _TIMEOUT_H_
+
/* timeout.h 4.1 82/05/07 */
/*
*/
#define TIMEOUT 2400
+
+#endif
-#ifndef lint
+/*#include <setjmp.h> defs.h*/
+/*#include <sys/file.h> defs.h*/
+/*#include "_ctype.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "stak.h" defs.h*/
+#include "sym.h"
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)word.c 4.6 10/31/85";
#endif
*
*/
-#include "defs.h"
-#include "sym.h"
-
+/*#include "defs.h"*/
+/*#include "sym.h"*/
/* ======== character handling for command lines ========*/
+static readb __P((void));
-word()
-{
+int word() {
register char c, d;
- register char *argp=locstak()+BYTESPERWORD;
+ register char *argp=locstak()+sizeof(char *);
int alpha=1;
wdnum=0; wdset=0;
if (!eofmeta(c)) {
do {
- if (c==LITERAL) {
- *argp++=(DQUOTE);
- while ((c=readc()) && c!=LITERAL) { *argp++=(c|0200); chkpr(c); }
- *argp++=(DQUOTE);
+ if (c=='\'') {
+ *argp++=('"');
+ while ((c=readc()) && c!='\'') { *argp++=(c|0200); chkpr(c); }
+ *argp++=('"');
}
else {
return(wdval);
}
-nextc(quote)
- char quote;
-{
+int nextc(quote) int quote; {
register char c, d;
- if ((d=readc())==ESCAPE) {
+ if ((d=readc())=='\\') {
if ((c=readc())=='\n') {
chkpr('\n'); d=nextc(quote);
}
return(d);
}
-readc()
-{
+int readc() {
register char c;
register int len;
register struct fileblk *f;
return(c);
}
-static readb()
-{
+static readb() {
register struct fileblk *f=standin;
register int len;
-#ifndef lint
+#include <compat-4.1.h>
+/*#include <sys/file.h> defs.h*/
+#include <sys/proc.h>
+#include <sys/signal.h>
+#include <sys/stat.h>
+/*#include <sys/time.h> compat-4.1.h*/
+/*#include <sys/times.h> compat-4.1.h*/
+/*#include "_ctype.h" defs.h*/
+#include "defs.h"
+/*#include "mode.h" defs.h*/
+/*#include "name.h" defs.h*/
+/*#include "stak.h" defs.h*/
+#include "sym.h"
+
+#if defined(DOSCCS) && !defined(lint)
static char sccsid[] = "@(#)xec.c 4.3 8/11/83";
#endif
*
*/
-#include "defs.h"
-#include "sym.h"
+/*#include "defs.h"*/
+/*#include "sym.h"*/
static int parent;
extern struct sysnod commands[];
-
-
/* ======== command execution ========*/
-
-execute(argt, execflg, pf1, pf2)
- struct trenod *argt;
- int *pf1, *pf2;
-{
+int execute(argt, execflg, pf1, pf2) struct trenod *argt; int execflg; int *pf1; int *pf2; {
/* `stakbot' is preserved by this routine */
register struct trenod *_t;
char *sav=savstak();
}
break;
- case SYSTIMES:
- {
+ case SYSTIMES: {
long tm[4]; times(tm);
prt(tm[2]); blank(); prt(tm[3]); newline();
}
chktrap();
break;
-
}
else {
/* this is the forked branch (child) of execute */
/* pipe in or out */
if (treeflgs&FPIN) {
- rename(pf1[INPIPE],0);
+ _rename(pf1[INPIPE],0);
close(pf1[OTPIPE]);
}
if (treeflgs&FPOU) {
- rename(pf2[OTPIPE],1);
+ _rename(pf2[OTPIPE],1);
close(pf2[INPIPE]);
}
/* default std input for & */
if (treeflgs&FINT && ioset==0) {
- rename(chkopen(devnull),0);
+ _rename(chkopen(devnull),0);
}
/* io redirection */
case TPAR:
#define t ((struct parnod *)_t)
- rename(dup(2),output);
+ _rename(dup(2),output);
execute(t->partre,execflg);
done();
#undef t
return(exitval);
}
-
-execexp(s,f)
- char *s;
- int f;
-{
+int execexp(s, f) char *s; int f; {
struct fileblk fb;
push(&fb);
if (s) {