diff options
author | Pav Lucistnik <pav@FreeBSD.org> | 2004-06-22 08:24:19 +0000 |
---|---|---|
committer | Pav Lucistnik <pav@FreeBSD.org> | 2004-06-22 08:24:19 +0000 |
commit | 6b787b91fc0797ed15597e469b619422097a60bb (patch) | |
tree | a1b95711a4085320a1bc7b8bb0ee0183fb21ec47 | |
parent | - Fix runtime on nvidia driver (diff) |
Add v7sh, the original Steve R. Bourne shell from the 7th edition Unix including
System III, 4.3BSD-Reno, Ultrix 3.1 and `home made'' fixes and enhancements
PR: ports/68127
Submitted by: Cyrille Lefevre <cyrille.lefevre@laposte.net>
Notes
Notes:
svn path=/head/; revision=111975
39 files changed, 5606 insertions, 0 deletions
diff --git a/shells/Makefile b/shells/Makefile index a72a5d97082b..067d5848cada 100644 --- a/shells/Makefile +++ b/shells/Makefile @@ -24,6 +24,7 @@ SUBDIR += sash SUBDIR += scponly SUBDIR += tcshrc + SUBDIR += v7sh SUBDIR += vshnu SUBDIR += wapsh SUBDIR += zsh diff --git a/shells/v7sh/Makefile b/shells/v7sh/Makefile new file mode 100644 index 000000000000..74aa1647a7f9 --- /dev/null +++ b/shells/v7sh/Makefile @@ -0,0 +1,65 @@ +# New ports collection makefile for: v7sh +# Date created: 4 June 2004 +# Whom: Cyrille.Lefevre@laposte.net +# +# $FreeBSD$ +# + +PORTNAME= v7sh +PORTVERSION= 1.0 +CATEGORIES= shells +MASTER_SITES= ftp://minnie.tuhs.org/UnixArchive/PDP-11/Trees/V7/usr/src/cmd/sh/:s \ + http://minnie.tuhs.org/UnixTree/V7/usr/src/cmd/sh/:s \ + ftp://minnie.tuhs.org/UnixArchive/PDP-11/Trees/V7/usr/man/man1/:m \ + http://minnie.tuhs.org/UnixTree/V7/usr/man/man1/:m +DISTFILES= args.c:s blok.c:s brkincr.h:s builtin.c:s cmd.c:s \ + ctype.c:s ctype.h:s defs.h:s error.c:s expand.c:s \ + fault.c:s io.c:s mac.h:s macro.c:s main.c:s mode.h:s \ + msg.c:s name.c:s name.h:s print.c:s service.c:s \ + setbrk.c:s stak.c:s stak.h:s string.c:s sym.h:s \ + timeout.h:s word.c:s xec.c:s sh.1:m +DIST_SUBDIR= ${PORTNAME} + +MAINTAINER= Cyrille.Lefevre@laposte.net +COMMENT= An implementation of the UNIX 7th Edition shell + +EXTRACT_CMD= ${CP} +EXTRACT_BEFORE_ARGS= +EXTRACT_AFTER_ARGS= ${WRKDIR} + +NO_WRKSUBDIR= yes +MAN1= ${PORTNAME}.1 + +OPTIONS= V7SH_SYSIII "System III enhancements" on \ + V7SH_RENO "4.3BSD-Reno enhancements" on \ + V7SH_ULTRIX "Ultrix 3.1 enhancements" on + +.include <bsd.port.pre.mk> + +.if !defined(WITHOUT_V7SH_SYSIII) +CFLAGS+= -DSYSIII +.endif +.if !defined(WITHOUT_V7SH_RENO) +CFLAGS+= -DRENO +.endif +.if !defined(WITHOUT_V7SH_ULTRIX) +CFLAGS+= -DULTRIX +.endif + +post-extract: + @${MV} ${WRKSRC}/sh.1 ${WRKSRC}/${PORTNAME}.1 + @${CP} ${FILESDIR}/Makefile ${WRKSRC} + @${CP} ${FILESDIR}/test.c ${WRKSRC} # sysIII + @${CP} ${FILESDIR}/pathnames.h ${WRKSRC} # 43reno +.if ${OSVERSION} < 500005 + @${CP} ${FILESDIR}/ulimit.[ch] ${WRKSRC} # fbsd52 +.endif + +post-install: + @${ECHO_MSG} "updating /etc/shells" + @${CP} /etc/shells /etc/shells.bak + @(${GREP} -v ${PREFIX}/bin/${PORTNAME} /etc/shells.bak; \ + ${ECHO_CMD} ${PREFIX}/bin/${PORTNAME}) > /etc/shells + @${RM} /etc/shells.bak + +.include <bsd.port.post.mk> diff --git a/shells/v7sh/distinfo b/shells/v7sh/distinfo new file mode 100644 index 000000000000..e004d92dac14 --- /dev/null +++ b/shells/v7sh/distinfo @@ -0,0 +1,64 @@ +MD5 (v7sh/args.c) = 761c97c283dd6234b89efbf0282fbae2 +SIZE (v7sh/args.c) = 2214 +MD5 (v7sh/blok.c) = 2e91d1753ed5e3d36d22f62b7c77208d +SIZE (v7sh/blok.c) = 1972 +MD5 (v7sh/brkincr.h) = 507b79236ae8a90b52a5407759633bec +SIZE (v7sh/brkincr.h) = 43 +MD5 (v7sh/builtin.c) = 16aa6384422115d068993a1a8153d856 +SIZE (v7sh/builtin.c) = 23 +MD5 (v7sh/cmd.c) = e02fe52dbd9d14e7c2c40803dc9e1b73 +SIZE (v7sh/cmd.c) = 6163 +MD5 (v7sh/ctype.c) = 65f16e2c4ddde250f2d29a0183cd3948 +SIZE (v7sh/ctype.c) = 1907 +MD5 (v7sh/ctype.h) = 28170130bc6220ac758a50b695618dec +SIZE (v7sh/ctype.h) = 2290 +MD5 (v7sh/defs.h) = bf0e20f64d78abf90a48a7afb81040cd +SIZE (v7sh/defs.h) = 4572 +MD5 (v7sh/dup.h) = f789b591f696eb7e6a0dd473bffb8101 +SIZE (v7sh/dup.h) = 97 +MD5 (v7sh/error.c) = 5a82dda92d1f90121942794c5467c5e5 +SIZE (v7sh/error.c) = 1093 +MD5 (v7sh/expand.c) = c9da58f95b5c600a2e523810bfe577a0 +SIZE (v7sh/expand.c) = 2976 +MD5 (v7sh/fault.c) = 1bb5abb43c1bef74896da9ceac1a8ffe +SIZE (v7sh/fault.c) = 1357 +MD5 (v7sh/io.c) = 31ba425d9ec848571a50990f30dbac86 +SIZE (v7sh/io.c) = 1863 +MD5 (v7sh/mac.h) = 19b78457a15877d5408c3a2c25c897ce +SIZE (v7sh/mac.h) = 876 +MD5 (v7sh/macro.c) = a2c6af845ffbaf88f6951dbf4e1c68e8 +SIZE (v7sh/macro.c) = 4067 +MD5 (v7sh/main.c) = 2448db01de9196fa8944d2ab98cdf3c3 +SIZE (v7sh/main.c) = 3079 +MD5 (v7sh/makefile) = 2da3bdb9df0c75146c68ba551db71d79 +SIZE (v7sh/makefile) = 572 +MD5 (v7sh/mode.h) = ee1624607f27baa557750aa277165ecb +SIZE (v7sh/mode.h) = 3203 +MD5 (v7sh/msg.c) = 2683b344f3919a1771c9099f4c69a539 +SIZE (v7sh/msg.c) = 2672 +MD5 (v7sh/name.c) = 7a9259adda8d7213d65caa4dbcea75f0 +SIZE (v7sh/name.c) = 4561 +MD5 (v7sh/name.h) = c10b5fca000d985cbf5a4107d6af0b3d +SIZE (v7sh/name.h) = 311 +MD5 (v7sh/print.c) = aff19822213e606defc51d27e3af1c2d +SIZE (v7sh/print.c) = 1076 +MD5 (v7sh/service.c) = 01bb3791c38adb21f2cdad1bfa21d1d6 +SIZE (v7sh/service.c) = 5736 +MD5 (v7sh/setbrk.c) = 3d97016bd903198aa6e39771cffa54b9 +SIZE (v7sh/setbrk.c) = 167 +MD5 (v7sh/stak.c) = c96e473c892b83a7ecccf5ed2a259978 +SIZE (v7sh/stak.c) = 1201 +MD5 (v7sh/stak.h) = 1943fade02cbcf6e0406692ec5b2ff52 +SIZE (v7sh/stak.h) = 1593 +MD5 (v7sh/string.c) = 753fc34684d37d9a0718d5ab9ee10098 +SIZE (v7sh/string.c) = 586 +MD5 (v7sh/sym.h) = 61f0091b5ece6b7bb05165ffb81975bb +SIZE (v7sh/sym.h) = 763 +MD5 (v7sh/timeout.h) = 987913989291fb929da74152d82a630a +SIZE (v7sh/timeout.h) = 95 +MD5 (v7sh/word.c) = 9c2854c7919ee4747a67d0960fd4221f +SIZE (v7sh/word.c) = 2318 +MD5 (v7sh/xec.c) = 672a9f83cd63d4a27f331078b34cc82d +SIZE (v7sh/xec.c) = 8353 +MD5 (v7sh/sh.1) = 3346f635f2a75d90fa43348ee3484177 +SIZE (v7sh/sh.1) = 19174 diff --git a/shells/v7sh/files/Makefile b/shells/v7sh/files/Makefile new file mode 100644 index 000000000000..845674f69a02 --- /dev/null +++ b/shells/v7sh/files/Makefile @@ -0,0 +1,24 @@ +# $FreeBSD$ + +PREFIX?= /usr/local +BINDIR?= ${PREFIX}/bin +MANDIR?= ${PREFIX}/man/man + +PROG= v7sh +SRCS= args.c blok.c builtin.c cmd.c ctype.c error.c expand.c \ + fault.c io.c macro.c main.c msg.c name.c print.c service.c \ + setbrk.c stak.c string.c test.c word.c xec.c +.if ${OSVERSION} < 500005 +SRCS+= ulimit.c +.endif + +#CFLAGS+= -DSYSIII +#CFLAGS+= -DRENO +#CFLAGS+= -DULTRIX + +CWARNFLAGS?= -ansi -Wbad-function-cast +WARNS?= 6 +NO_WERROR=1 +WFORMAT=0 + +.include <bsd.prog.mk> diff --git a/shells/v7sh/files/patch-args.c b/shells/v7sh/files/patch-args.c new file mode 100644 index 000000000000..f7ba2a806d74 --- /dev/null +++ b/shells/v7sh/files/patch-args.c @@ -0,0 +1,168 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ args.c.orig args.c +--- args.c.orig Fri Jun 4 02:51:00 2004 ++++ args.c Sat Jun 19 18:42:21 2004 +@@ -9,24 +9,24 @@ + + #include "defs.h" + +-PROC STRING *copyargs(); ++LOCAL DOLPTR copyargs(STRING *, INT); + LOCAL DOLPTR dolh; + + CHAR flagadr[10]; +- + CHAR flagchar[] = { +- 'x', 'n', 'v', 't', 's', 'i', 'e', 'r', 'k', 'u', 0 ++ 'x', 'n', 'v', 't', STDFLG, 'i', 'e', 'r', 'k', 'u', 0 + }; + INT flagval[] = { + execpr, noexec, readpr, oneflg, stdflg, intflg, errflg, rshflg, keyflg, setflg, 0 + }; ++DOLPTR argfor; + + /* ======== option handling ======== */ + + + INT options(argc,argv) +- STRING *argv; + INT argc; ++ STRING *argv; + { + REG STRING cp; + REG STRING *argp=argv; +@@ -34,21 +34,66 @@ + STRING flagp; + + IF argc>1 ANDF *argp[1]=='-' ++#if defined(SYSIII) ++ THEN ++ IF argp[1][1] == '-' ++ THEN /* if first argument is "--" then options are not ++ to be changed Fix for problems getting ++ $1 starting with a "-" ++ */ ++ argp[1] = argp[0]; argc--; ++ return(argc); ++ FI ++ cp = argp[1]; ++ IF cp[1] == '\0' THEN flags &= ~(execpr|readpr) FI ++ /* Step along 'flagchar[]' looking for matches. ++ 'sicr' are not legal with 'set' command. ++ */ ++#else /* V7 */ + THEN cp=argp[1]; + flags &= ~(execpr|readpr); ++#endif + WHILE *++cp + DO flagc=flagchar; + + WHILE *flagc ANDF *flagc != *cp DO flagc++ OD + IF *cp == *flagc ++#if defined(SYSIII) ++ THEN IF eq(argv[0], "set") ANDF any(*cp, "sicr") ++ THEN failed(argv[1], badopt); ++ /*NOTREACHED*/ ++ ELSE flags |= flagval[flagc-flagchar]; ++ FI ++#else /* V7 */ + THEN flags |= flagval[flagc-flagchar]; ++#endif + ELIF *cp=='c' ANDF argc>2 ANDF comdiv==0 + THEN comdiv=argp[2]; + argp[1]=argp[0]; argp++; argc--; + ELSE failed(argv[1],badopt); ++ /*NOTREACHED*/ ++ FI ++ OD ++ argp[1]=argp[0]; argc--; ++#if defined(SYSIII) ++ ELIF argc >1 ANDF *argp[1]=='+' /* unset flags x, k, t, n, v, e, u */ ++ THEN cp = argp[1]; ++ WHILE *++cp ++ DO ++ flagc = flagchar; ++ WHILE *flagc ANDF *flagc != *cp DO flagc++ OD ++ /* step through flags */ ++ IF !any(*cp, "csir") ANDF *cp == *flagc ++ THEN ++ IF (flags&flagval[flagc-flagchar]) ++ /* only turn off if already on */ ++ THEN ++ flags &= ~(flagval[flagc-flagchar]) ++ FI + FI + OD + argp[1]=argp[0]; argc--; ++#endif + FI + + /* set up $- */ +@@ -67,6 +112,7 @@ + + VOID setargs(argi) + STRING argi[]; ++ /* sets up positional parameters */ + { + /* count args */ + REG STRING *argp=argi; +@@ -80,45 +126,46 @@ + assnum(&dolladr,dolc=argn-1); + } + +-freeargs(blk) ++DOLPTR freeargs(blk) + DOLPTR blk; + { + REG STRING *argp; + REG DOLPTR argr=0; + REG DOLPTR argblk; + +- IF argblk=blk ++ IF (argblk=blk)!=NIL /* GCC */ + THEN argr = argblk->dolnxt; + IF (--argblk->doluse)==0 +- THEN FOR argp=argblk->dolarg; Rcheat(*argp)!=ENDARGS; argp++ +- DO free(*argp) OD +- free(argblk); ++ THEN FOR argp=(STRING *) argblk->dolarg; Rcheat(*argp)!=ENDARGS; argp++ ++ DO free((BLKPTR) *argp) OD ++ free((BLKPTR) argblk); + FI + FI + return(argr); + } + +-LOCAL STRING * copyargs(from, n) ++LOCAL DOLPTR copyargs(from, n) + STRING from[]; ++ INT n; + { +- REG STRING * np=alloc(sizeof(STRING*)*n+3*BYTESPERWORD); +- REG STRING * fp=from; +- REG STRING * pp=np; ++ REG DOLPTR dp=(DOLPTR) alloc(sizeof(STRING*)*n+3*BYTESPERWORD); ++ REG STRING *np; ++ REG STRING *fp=from; + +- np->doluse=1; /* use count */ +- np=np->dolarg; ++ dp->doluse=1; /* use count */ ++ np=(STRING *) dp->dolarg; + dolv=np; + + WHILE n-- + DO *np++ = make(*fp++) OD + *np++ = ENDARGS; +- return(pp); ++ return(dp); + } + +-clearup() ++VOID clearup() + { + /* force `for' $* lists to go away */ +- WHILE argfor=freeargs(argfor) DONE ++ WHILE (argfor=freeargs(argfor))!=NIL DONE /* GCC */ + + /* clean up io files */ + WHILE pop() DONE diff --git a/shells/v7sh/files/patch-blok.c b/shells/v7sh/files/patch-blok.c new file mode 100644 index 000000000000..349fb063d801 --- /dev/null +++ b/shells/v7sh/files/patch-blok.c @@ -0,0 +1,41 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ blok.c.orig blok.c +--- blok.c.orig Fri Jun 4 02:51:00 2004 ++++ blok.c Sat Jun 19 18:42:21 2004 +@@ -18,9 +18,9 @@ + #define BUSY 01 + #define busy(x) (Rcheat((x)->word)&BUSY) + +-POS brkincr=BRKINCR; +-BLKPTR blokp; /*current search pointer*/ +-BLKPTR bloktop=BLK(end); /*top of arena (last blok)*/ ++INT brkincr=BRKINCR; ++LOCAL BLKPTR blokp; /*current search pointer*/ ++LOCAL BLKPTR bloktop=BLK(end); /*top of arena (last blok)*/ + + + +@@ -34,13 +34,13 @@ + REG BLKPTR q; + REP IF !busy(p) + THEN WHILE !busy(q = p->word) DO p->word = q->word OD +- IF ADR(q)-ADR(p) >= rbytes ++ IF (POS) (ADR(q)-ADR(p)) >= rbytes + THEN blokp = BLK(ADR(p)+rbytes); + IF q > blokp + THEN blokp->word = p->word; + FI + p->word=BLK(Rcheat(blokp)|BUSY); +- return(ADR(p+1)); ++ return((ADDRESS) ADR(p+1)); + FI + FI + q = p; p = BLK(Rcheat(p->word)&~BUSY); +@@ -57,7 +57,7 @@ + REG BLKPTR blokstak; + + pushstak(0); +- rndstak=round(staktop,BYTESPERWORD); ++ rndstak=(STKPTR) round(staktop,BYTESPERWORD); + blokstak=BLK(stakbas)-1; + blokstak->word=stakbsy; stakbsy=blokstak; + bloktop->word=BLK(Rcheat(rndstak)|BUSY); diff --git a/shells/v7sh/files/patch-builtin.c b/shells/v7sh/files/patch-builtin.c new file mode 100644 index 000000000000..4f21c3c45d6a --- /dev/null +++ b/shells/v7sh/files/patch-builtin.c @@ -0,0 +1,49 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ builtin.c.orig builtin.c +--- builtin.c.orig Fri Jun 4 02:51:01 2004 ++++ builtin.c Sat Jun 19 18:42:21 2004 +@@ -1,2 +1,43 @@ +-builtin() +-{return(0);} ++#include "defs.h" ++ ++#if defined(SYSIII) ++VOID builtin(xbuiltin, argn, com) ++/* ++ builtin commands are those that Bourne did not intend ++ to be part of his shell. ++ Redirection of i/o, or rather the lack of it, is still a ++ problem.. ++*/ ++ INT xbuiltin; ++ INT argn; ++ STRING com[]; ++{ ++ SWITCH xbuiltin IN ++ case TEST: /* test expression */ ++ exitval = test(argn,com); ++ break; ++ ENDSW ++} ++ ++VOID bfailed(s1, s2, s3) ++ /* fake diagnostics to continue to look like original ++ test(1) diagnostics ++ */ ++ CSTRING s1, s2, s3; ++{ ++ prp(); prs(s1); ++ IF s2 ++ THEN prs(colon); prs(s2); prs(s3); ++ FI ++ newline(); exitsh(ERROR); ++ /*NOTREACHED*/ ++} ++#else /* V7 */ ++INT builtin(argn, com) ++ INT argn; ++ STRING com[]; ++{ ++ argn=argn; com=com; /* GCC */ ++ return(0); ++} ++#endif diff --git a/shells/v7sh/files/patch-cmd.c b/shells/v7sh/files/patch-cmd.c new file mode 100644 index 000000000000..88813f703e94 --- /dev/null +++ b/shells/v7sh/files/patch-cmd.c @@ -0,0 +1,340 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ cmd.c.orig cmd.c +--- cmd.c.orig Fri Jun 4 02:51:01 2004 ++++ cmd.c Sat Jun 19 18:42:21 2004 +@@ -10,17 +10,17 @@ + #include "defs.h" + #include "sym.h" + +-PROC IOPTR inout(); +-PROC VOID chkword(); +-PROC VOID chksym(); +-PROC TREPTR term(); +-PROC TREPTR makelist(); +-PROC TREPTR list(); +-PROC REGPTR syncase(); +-PROC TREPTR item(); +-PROC VOID skipnl(); +-PROC VOID prsym(); +-PROC VOID synbad(); ++LOCAL TREPTR makelist(INT,TREPTR,TREPTR); ++LOCAL TREPTR list(INT); ++LOCAL TREPTR term(INT); ++LOCAL REGPTR syncase(INT); ++LOCAL TREPTR item(BOOL); ++LOCAL INT skipnl(VOID); ++LOCAL IOPTR inout(IOPTR); ++LOCAL VOID chkword(VOID); ++LOCAL VOID chksym(INT); ++LOCAL VOID prsym(INT); ++LOCAL VOID synbad(VOID); + + + /* ======== command line decoding ========*/ +@@ -34,8 +34,10 @@ + { + REG TREPTR t; + +- t=getstak(FORKTYPE); +- t->forktyp=flgs|TFORK; t->forktre=i; t->forkio=0; ++ t=(TREPTR) getstak(FORKTYPE); ++ t->forknod.forktyp=flgs|TFORK; ++ t->forknod.forktre=i; ++ t->forknod.forkio=0; + return(t); + } + +@@ -43,13 +45,14 @@ + INT type; + TREPTR i, r; + { +- REG TREPTR t; ++ REG TREPTR t=NIL; /* GCC */ + + IF i==0 ORF r==0 + THEN synbad(); +- ELSE t = getstak(LSTTYPE); +- t->lsttyp = type; +- t->lstlef = i; t->lstrit = r; ++ ELSE t=(TREPTR) getstak(LSTTYPE); ++ t->lstnod.lsttyp = type; ++ t->lstnod.lstlef = i; ++ t->lstnod.lstrit = r; + FI + return(t); + } +@@ -85,10 +88,15 @@ + THEN i = makefork(FINT|FPRS|FAMP, i); + ELSE synbad(); + FI ++ /*FALLTHROUGH*/ + + case ';': +- IF e=cmd(sym,flg|MTFLG) ++ IF (e=cmd(sym,flg|MTFLG))!=NIL /* GCC */ + THEN i=makelist(TLST, i, e); ++#if defined(SYSIII) ++ ELIF i == 0 ++ THEN synbad(); ++#endif + FI + break; + +@@ -96,6 +104,7 @@ + IF sym==NL + THEN break; + FI ++ /*FALLTHROUGH*/ + + default: + IF sym +@@ -114,6 +123,7 @@ + */ + + LOCAL TREPTR list(flg) ++ INT flg; + { + REG TREPTR r; + REG INT b; +@@ -132,6 +142,7 @@ + */ + + LOCAL TREPTR term(flg) ++ INT flg; + { + REG TREPTR t; + +@@ -153,7 +164,7 @@ + skipnl(); + IF wdval==esym + THEN return(0); +- ELSE REG REGPTR r=getstak(REGTYPE); ++ ELSE REG REGPTR r=(REGPTR) getstak(REGTYPE); + r->regptr=0; + LOOP wdarg->argnxt=r->regptr; + r->regptr=wdarg; +@@ -201,54 +212,54 @@ + + case CASYM: + BEGIN +- t=getstak(SWTYPE); ++ t=(TREPTR) getstak(SWTYPE); + chkword(); +- t->swarg=wdarg->argval; ++ t->swnod.swarg=wdarg->argval; + skipnl(); chksym(INSYM|BRSYM); +- t->swlst=syncase(wdval==INSYM?ESSYM:KTSYM); +- t->swtyp=TSW; ++ t->swnod.swlst=syncase(wdval==INSYM?ESSYM:KTSYM); ++ t->swnod.swtyp=TSW; + break; + END + + case IFSYM: + BEGIN + REG INT w; +- t=getstak(IFTYPE); +- t->iftyp=TIF; +- t->iftre=cmd(THSYM,NLFLG); +- t->thtre=cmd(ELSYM|FISYM|EFSYM,NLFLG); +- t->eltre=((w=wdval)==ELSYM ? cmd(FISYM,NLFLG) : (w==EFSYM ? (wdval=IFSYM, item(0)) : 0)); ++ t=(TREPTR) getstak(IFTYPE); ++ t->ifnod.iftyp=TIF; ++ t->ifnod.iftre=cmd(THSYM,NLFLG); ++ t->ifnod.thtre=cmd(ELSYM|FISYM|EFSYM,NLFLG); ++ t->ifnod.eltre=((w=wdval)==ELSYM ? cmd(FISYM,NLFLG) : (w==EFSYM ? (wdval=IFSYM, item(0)) : 0)); + IF w==EFSYM THEN return(t) FI + break; + END + + case FORSYM: + BEGIN +- t=getstak(FORTYPE); +- t->fortyp=TFOR; +- t->forlst=0; ++ t=(TREPTR) getstak(FORTYPE); ++ t->fornod.fortyp=TFOR; ++ t->fornod.forlst=0; + chkword(); +- t->fornam=wdarg->argval; ++ t->fornod.fornam=wdarg->argval; + IF skipnl()==INSYM + THEN chkword(); +- t->forlst=item(0); ++ t->fornod.forlst=(COMPTR) item(0); + IF wdval!=NL ANDF wdval!=';' + THEN synbad(); + FI + chkpr(wdval); skipnl(); + FI + chksym(DOSYM|BRSYM); +- t->fortre=cmd(wdval==DOSYM?ODSYM:KTSYM,NLFLG); ++ t->fornod.fortre=cmd(wdval==DOSYM?ODSYM:KTSYM,NLFLG); + break; + END + + case WHSYM: + case UNSYM: + BEGIN +- t=getstak(WHTYPE); +- t->whtyp=(wdval==WHSYM ? TWH : TUN); +- t->whtre = cmd(DOSYM,NLFLG); +- t->dotre = cmd(ODSYM,NLFLG); ++ t=(TREPTR) getstak(WHTYPE); ++ t->whnod.whtyp=(wdval==WHSYM ? TWH : TUN); ++ t->whnod.whtre = cmd(DOSYM,NLFLG); ++ t->whnod.dotre = cmd(ODSYM,NLFLG); + break; + END + +@@ -259,10 +270,10 @@ + case '(': + BEGIN + REG PARPTR p; +- p=getstak(PARTYPE); ++ p=(PARPTR) getstak(PARTYPE); + p->partre=cmd(')',NLFLG); + p->partyp=TPAR; +- t=makefork(0,p); ++ t=makefork(0,(TREPTR) p); + break; + END + +@@ -270,6 +281,7 @@ + IF io==0 + THEN return(0); + FI ++ /*FALLTHROUGH*/ + + case 0: + BEGIN +@@ -277,35 +289,37 @@ + REG ARGPTR *argtail; + REG ARGPTR *argset=0; + INT keywd=1; +- t=getstak(COMTYPE); +- t->comio=io; /*initial io chain*/ +- argtail = &(t->comarg); ++ t=(TREPTR) getstak(COMTYPE); ++ t->comnod.comio=io; /*initial io chain*/ ++ argtail = &(t->comnod.comarg); + WHILE wdval==0 + DO argp = wdarg; + IF wdset ANDF keywd +- THEN argp->argnxt=argset; argset=argp; ++ THEN argp->argnxt=(ARGPTR) argset; argset=(ARGPTR *) argp; + ELSE *argtail=argp; argtail = &(argp->argnxt); keywd=flags&keyflg; + FI + word(); + IF flag +- THEN t->comio=inout(t->comio); ++ THEN t->comnod.comio=inout(t->comnod.comio); + FI + OD + +- t->comtyp=TCOM; t->comset=argset; *argtail=0; ++ t->comnod.comtyp=TCOM; ++ t->comnod.comset=(ARGPTR) argset; ++ *argtail=0; + return(t); + END + + ENDSW + reserv++; word(); +- IF io=inout(io) +- THEN t=makefork(0,t); t->treio=io; ++ IF (io=inout(io))!=NIL ++ THEN t=makefork(0,t); t->treio.treio=io; + FI + return(t); + } + + +-LOCAL VOID skipnl() ++LOCAL INT skipnl() + { + WHILE (reserv++, word()==NL) DO chkpr(NL) OD + return(wdval); +@@ -316,27 +330,33 @@ + { + REG INT iof; + REG IOPTR iop; +- REG CHAR c; ++ REG INT c; + + iof=wdnum; + + SWITCH wdval IN + + case DOCSYM: ++ /* << */ + iof |= IODOC; break; ++ /*FALLTHROUGH*/ + + case APPSYM: ++ /* >> */ + case '>': + IF wdnum==0 THEN iof |= 1 FI + iof |= IOPUT; + IF wdval==APPSYM + THEN iof |= IOAPP; break; + FI ++ /*FALLTHROUGH*/ + + case '<': + IF (c=nextc(0))=='&' + THEN iof |= IOMOV; + ELIF c=='>' ++ /* <> is open for read and write */ ++ /* unadvertised feature */ + THEN iof |= IORDW; + ELSE peekc=c|MARK; + FI +@@ -347,7 +367,7 @@ + ENDSW + + chkword(); +- iop=getstak(IOTYPE); iop->ioname=wdarg->argval; iop->iofile=iof; ++ iop=(IOPTR) getstak(IOTYPE); iop->ioname=wdarg->argval; iop->iofile=iof; + IF iof&IODOC + THEN iop->iolst=iopend; iopend=iop; + FI +@@ -363,6 +383,7 @@ + } + + LOCAL VOID chksym(sym) ++ INT sym; + { + REG INT x = sym&wdval; + IF ((x&SYMFLG) ? x : sym) != wdval +@@ -371,6 +392,7 @@ + } + + LOCAL VOID prsym(sym) ++ INT sym; + { + IF sym&SYMFLG + THEN REG SYSPTR sp=reserved; +@@ -382,7 +404,7 @@ + THEN prs(endoffile); + ELSE IF sym&SYMREP THEN prc(sym) FI + IF sym==NL +- THEN prs("newline"); ++ THEN prs(endofline); + ELSE prc(sym); + FI + FI +@@ -392,7 +414,7 @@ + { + prp(); prs(synmsg); + IF (flags&ttyflg)==0 +- THEN prs(atline); prn(standin->flin); ++ THEN prs(atline); prn((INT) standin->flin); + FI + prs(colon); + prc(LQ); +@@ -403,4 +425,5 @@ + prc(RQ); prs(unexpected); + newline(); + exitsh(SYNBAD); ++ /*NOTREACHED*/ + } diff --git a/shells/v7sh/files/patch-ctype.c b/shells/v7sh/files/patch-ctype.c new file mode 100644 index 000000000000..8cf4308e125d --- /dev/null +++ b/shells/v7sh/files/patch-ctype.c @@ -0,0 +1,33 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ ctype.c.orig ctype.c +--- ctype.c.orig Fri Jun 4 02:51:01 2004 ++++ ctype.c Sat Jun 19 18:42:22 2004 +@@ -9,7 +9,7 @@ + + #include "defs.h" + +-char _ctype1[] { ++char _ctype1[]={ + /* 000 001 002 003 004 005 006 007 */ + _EOF, 0, 0, 0, 0, 0, 0, 0, + +@@ -58,7 +58,7 @@ + }; + + +-char _ctype2[] { ++char _ctype2[]={ + /* 000 001 002 003 004 005 006 007 */ + 0, 0, 0, 0, 0, 0, 0, 0, + +@@ -91,7 +91,11 @@ + _UPC, _UPC, _UPC, _UPC, _UPC, _UPC, _UPC, _UPC, + + /* X Y Z [ \ ] ^ _ */ ++#if defined(SYSIII) ++ _UPC, _UPC, _UPC, 0, 0, 0, 0, _UPC, ++#else /* V7 */ + _UPC, _UPC, _UPC, _SQB, 0, 0, 0, _UPC, ++#endif + + /* ` a b c d e f g */ + 0, _LPC, _LPC, _LPC, _LPC, _LPC, _LPC, _LPC, diff --git a/shells/v7sh/files/patch-ctype.h b/shells/v7sh/files/patch-ctype.h new file mode 100644 index 000000000000..71cd88ea9b50 --- /dev/null +++ b/shells/v7sh/files/patch-ctype.h @@ -0,0 +1,26 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ ctype.h.orig ctype.h +--- ctype.h.orig Fri Jun 4 02:51:01 2004 ++++ ctype.h Sat Jun 19 18:42:22 2004 +@@ -66,7 +66,7 @@ + #define _IDCH (T_IDC|T_DIG) + #define _META (T_SPC|T_DIP|T_MET|T_EOR) + +-char _ctype1[]; ++extern char _ctype1[]; + + /* nb these args are not call by value !!!! */ + #define space(c) (((c)"E)==0 ANDF _ctype1[c]&(T_SPC)) +@@ -77,10 +77,12 @@ + #define subchar(c) (((c)"E)==0 ANDF _ctype1[c]&(T_SUB|T_QOT)) + #define escchar(c) (((c)"E)==0 ANDF _ctype1[c]&(T_ESC)) + +-char _ctype2[]; ++extern char _ctype2[]; + + #define digit(c) (((c)"E)==0 ANDF _ctype2[c]&(T_DIG)) ++#ifndef SYSIII + #define fngchar(c) (((c)"E)==0 ANDF _ctype2[c]&(T_FNG)) ++#endif + #define dolchar(c) (((c)"E)==0 ANDF _ctype2[c]&(T_AST|T_BRC|T_DIG|T_IDC|T_SHN)) + #define defchar(c) (((c)"E)==0 ANDF _ctype2[c]&(T_DEF)) + #define setchar(c) (((c)"E)==0 ANDF _ctype2[c]&(T_SET)) diff --git a/shells/v7sh/files/patch-defs.h b/shells/v7sh/files/patch-defs.h new file mode 100644 index 000000000000..b6822e623f03 --- /dev/null +++ b/shells/v7sh/files/patch-defs.h @@ -0,0 +1,563 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ defs.h.orig defs.h +--- defs.h.orig Tue Jun 22 01:43:19 2004 ++++ defs.h Tue Jun 22 01:55:49 2004 +@@ -1,8 +1,32 @@ + # + /* + * UNIX shell ++ * ++ * S. R. Bourne ++ * Bell Telephone Laboratories ++ * + */ + ++#include <sys/types.h> ++#include <sys/stat.h> ++#include <sys/times.h> ++#include <sys/wait.h> ++#include <dirent.h> ++#include <errno.h> ++#include <fcntl.h> ++#include <setjmp.h> ++#include <signal.h> ++#include <stdlib.h> ++#include <string.h> ++#if defined(ULTRIX) ++#if (__FreeBSD_version - 0) >= 500005 ++#include <ulimit.h> ++#else ++#include "ulimit.h" ++#endif ++#endif ++#include <unistd.h> ++ + /* error exits from various parts of shell */ + #define ERROR 1 + #define SYNBAD 2 +@@ -51,11 +75,22 @@ + #define SYSNULL 16 + #define SYSREAD 17 + #define SYSTST 18 +-#define SYSUMASK 19 ++#define SYSUMASK 19 ++#if defined(SYSIII) ++#define SYSNEWGRP 20 ++#endif ++#if defined(ULTRIX) ++#define SYSULIMIT 21 ++#endif ++ ++#if defined(SYSIII) ++/* builtin table */ ++#define TEST 127 ++#endif + + /* used for input and output of shell */ +-#define INIO 10 +-#define OTIO 11 ++#define INIO 18 /* V7 - 10 */ ++#define OTIO 19 /* V7 - 11 */ + + /*io nodes*/ + #define USERIO 10 +@@ -77,35 +112,145 @@ + + + /* result type declarations */ +-#define alloc malloc +-ADDRESS alloc(); +-VOID addblok(); +-STRING make(); +-STRING movstr(); +-TREPTR cmd(); +-TREPTR makefork(); +-NAMPTR lookup(); +-VOID setname(); +-VOID setargs(); +-DOLPTR useargs(); +-REAL expr(); +-STRING catpath(); +-STRING getpath(); +-STRING *scan(); +-STRING mactrim(); +-STRING macro(); +-STRING execs(); +-VOID await(); +-VOID post(); +-STRING copyto(); +-VOID exname(); +-STRING staknam(); +-VOID printnam(); +-VOID printflg(); +-VOID prs(); +-VOID prc(); +-VOID getenv(); +-STRING *setenv(); ++/* args.c */ ++PROC INT options(INT, STRING *); ++PROC VOID setargs(STRING *); ++PROC DOLPTR freeargs(DOLPTR); ++PROC VOID clearup(VOID); ++PROC DOLPTR useargs(VOID); ++/* blok.c */ ++PROC ADDRESS alloc(POS); ++PROC VOID addblok(POS); ++#define free free_ ++PROC VOID free(BLKPTR); ++/* builtin.c */ ++#if defined(SYSIII) ++PROC VOID builtin(INT, INT, STRING *); ++#else /* V7 */ ++PROC INT builtin(INT, STRING *); ++#endif ++PROC VOID bfailed(CSTRING, CSTRING, CSTRING); ++/* cmd.c */ ++PROC TREPTR makefork(INT, TREPTR); ++PROC TREPTR cmd(INT, INT); ++/* error.c */ ++PROC VOID exitset(VOID); ++PROC VOID sigchk(VOID); ++PROC VOID failed(CSTRING, CSTRING); ++PROC VOID error(CSTRING); ++PROC VOID exitsh(INT); ++PROC VOID done(VOID); ++PROC VOID rmtemp(IOPTR); ++/* expand.c */ ++PROC INT expand(STRING, INT); ++PROC INT gmatch(STRING, STRING); ++PROC VOID makearg(ARGPTR); ++/* expr.c */ ++/* PROC REAL expr(); */ ++/* fault.c */ ++PROC VOID fault(INT); ++PROC VOID stdsigs(VOID); ++PROC SIGPTR ignsig(INT); ++PROC VOID getsig(INT); ++PROC VOID oldsigs(VOID); ++PROC VOID clrsig(INT); ++PROC VOID chktrap(VOID); ++/* io.c */ ++PROC VOID initf(UFD); ++PROC INT estabf(STRING); ++PROC VOID push(FILEPTR); ++PROC INT pop(VOID); ++PROC VOID chkpipe(INT *); ++PROC INT chkopen(CSTRING); ++#define rename rename_ ++PROC VOID rename(INT, INT); ++PROC INT create(STRING); ++PROC INT tmpfil(VOID); ++PROC VOID copy(IOPTR); ++/* macro.c */ ++PROC STRING macro(STRING); ++PROC VOID subst(INT, INT); ++/* main.c */ ++PROC VOID chkpr(INT); ++PROC VOID settmp(VOID); ++/* name.c */ ++PROC INT syslook(STRING, SYSTAB); ++PROC VOID setlist(ARGPTR, INT); ++#if defined(SYSIII) ++PROC INT setname(STRING, INT); ++#else /* V7 */ ++PROC VOID setname(STRING, INT); ++#endif ++PROC VOID replace(STRING *, CSTRING); ++PROC VOID dfault(NAMPTR, CSTRING); ++PROC VOID assign(NAMPTR, CSTRING); ++PROC INT readvar(STRING *); ++PROC VOID assnum(STRING *, INT); ++PROC STRING make(CSTRING); ++PROC NAMPTR lookup(CSTRING); ++PROC VOID namscan(VOID(*)(NAMPTR)); ++PROC VOID printnam(NAMPTR); ++PROC VOID exname(NAMPTR); ++PROC VOID printflg(NAMPTR); ++#define getenv getenv_ ++#if defined(SYSIII) ++PROC INT getenv(VOID); ++#else /* V7 */ ++PROC VOID getenv(VOID); ++#endif ++#define setenv setenv_ ++PROC STRING *setenv(VOID); ++/* print.c */ ++PROC VOID newline(VOID); ++PROC VOID blank(VOID); ++PROC VOID prp(VOID); ++PROC VOID prs(CSTRING); ++PROC VOID prc(INT); ++PROC VOID prt(CLOCK); ++PROC VOID prn(INT); ++PROC VOID prl(LONG); ++PROC VOID itos(INT); ++PROC VOID ltos(LONG); ++PROC INT stoi(CSTRING); ++/* service.c */ ++PROC VOID initio(IOPTR); ++#if defined(SYSIII) ++PROC CSTRING simple(CSTRING); ++#endif ++PROC CSTRING getpath(CSTRING); ++PROC INT pathopen(CSTRING, CSTRING); ++PROC CSTRING catpath(CSTRING, CSTRING); ++PROC VOID execa(STRING *); ++PROC VOID postclr(VOID); ++PROC VOID post(INT); ++#if defined(SYSIII) ++PROC VOID await(INT, INT); ++#else /* V7 */ ++PROC VOID await(INT); ++#endif ++PROC VOID trim(STRING); ++PROC STRING mactrim(STRING); ++PROC STRING *scan(INT); ++PROC INT getarg(COMPTR); ++/* setbrk.c */ ++PROC BYTPTR setbrk(INT); ++/* stak.c -> stak.h */ ++/* string.c */ ++PROC STRING movstr(CSTRING, STRING); ++PROC INT any(INT, CSTRING); ++PROC INT cf(CSTRING, CSTRING); ++PROC INT length(CSTRING); ++/* test.c */ ++#if defined(SYSIII) ++PROC INT test(INT, STRING *); ++#endif ++/* word.c */ ++PROC INT word(VOID); ++PROC INT nextc(INT); ++PROC INT readc(VOID); ++/* xec.c */ ++PROC INT execute(TREPTR, INT, INT *, INT *); ++PROC VOID execexp(STRING, UFD); + + #define attrib(n,f) (n->namflg |= f) + #define round(a,b) (((int)((ADR(a)+b)-1))&~((b)-1)) +@@ -115,16 +260,20 @@ + #define assert(x) ; + + /* temp files and io */ +-UFD output; +-INT ioset; +-IOPTR iotemp; /* files to be deleted sometime */ +-IOPTR iopend; /* documents waiting to be read at NL */ ++EXTERN UFD output; ++EXTERN INT ioset; ++EXTERN IOPTR iotemp; /* files to be deleted sometime */ ++EXTERN IOPTR iopend; /* documents waiting to be read at NL */ ++#if defined(SYSIII) ++EXTERN INT stripflg; ++#endif ++EXTERN BOOL nosubst; + + /* substitution */ +-INT dolc; +-STRING *dolv; +-DOLPTR argfor; +-ARGPTR gchain; ++EXTERN INT dolc; ++EXTERN STRING *dolv; ++EXTERN DOLPTR argfor; ++EXTERN ARGPTR gchain; + + /* stack */ + #define BLK(x) ((BLKPTR)(x)) +@@ -136,68 +285,77 @@ + #include "stak.h" + + /* string constants */ +-MSG atline; +-MSG readmsg; +-MSG colon; +-MSG minus; +-MSG nullstr; +-MSG sptbnl; +-MSG unexpected; +-MSG endoffile; +-MSG synmsg; ++EXTERN CMSG atline; ++EXTERN CMSG readmsg; ++EXTERN CMSG colon; ++EXTERN CMSG minus; ++EXTERN CMSG nullstr; ++EXTERN CMSG sptbnl; ++EXTERN CMSG unexpected; ++EXTERN CMSG endoffile; ++EXTERN CMSG endofline; ++EXTERN CMSG synmsg; + + /* name tree and words */ +-SYSTAB reserved; +-INT wdval; +-INT wdnum; +-ARGPTR wdarg; +-INT wdset; +-BOOL reserv; ++EXTERN SYSTAB reserved; ++EXTERN SYSTAB commands; ++#if defined(SYSIII) ++EXTERN SYSTAB builtins; ++#endif ++EXTERN INT wdval; ++EXTERN INT wdnum; ++EXTERN ARGPTR wdarg; ++EXTERN INT wdset; ++EXTERN BOOL reserv; + + /* prompting */ +-MSG stdprompt; +-MSG supprompt; +-MSG profile; ++EXTERN CMSG stdprompt; ++EXTERN CMSG supprompt; ++EXTERN CMSG profile; ++#if defined(SYSIII) ++EXTERN CMSG sysprofile; ++#endif + + /* built in names */ +-NAMNOD fngnod; +-NAMNOD ifsnod; +-NAMNOD homenod; +-NAMNOD mailnod; +-NAMNOD pathnod; +-NAMNOD ps1nod; +-NAMNOD ps2nod; ++EXTERN NAMNOD fngnod; ++EXTERN NAMNOD ifsnod; ++EXTERN NAMNOD homenod; ++EXTERN NAMNOD mailnod; ++EXTERN NAMNOD pathnod; ++EXTERN NAMNOD ps1nod; ++EXTERN NAMNOD ps2nod; + + /* special names */ +-MSG flagadr; +-STRING cmdadr; +-STRING exitadr; +-STRING dolladr; +-STRING pcsadr; +-STRING pidadr; ++EXTERN MSG flagadr; ++EXTERN STRING cmdadr; ++EXTERN STRING exitadr; ++EXTERN STRING dolladr; ++EXTERN STRING pcsadr; ++EXTERN STRING pidadr; + +-MSG defpath; ++EXTERN CMSG defpath; + + /* names always present */ +-MSG mailname; +-MSG homename; +-MSG pathname; +-MSG fngname; +-MSG ifsname; +-MSG ps1name; +-MSG ps2name; ++EXTERN CMSG mailname; ++EXTERN CMSG homename; ++EXTERN CMSG pathname; ++EXTERN CMSG fngname; ++EXTERN CMSG ifsname; ++EXTERN CMSG ps1name; ++EXTERN CMSG ps2name; + + /* transput */ +-CHAR tmpout[]; +-STRING tmpnam; +-INT serial; ++EXTERN CHAR tmpout[]; ++#define tmpnam tmpnam_ ++EXTERN STRING tmpnam; ++EXTERN INT serial; + #define TMPNAM 7 +-FILE standin; ++EXTERN FILEPTR standin; + #define input (standin->fdes) + #define eof (standin->feof) +-INT peekc; +-STRING comdiv; +-MSG devnull; ++EXTERN INT peekc; ++EXTERN STRING comdiv; ++EXTERN CMSG devnull; + + /* flags */ + #define noexec 01 +@@ -211,77 +369,122 @@ + #define rshflg 0400 + #define waiting 01000 + #define stdflg 02000 ++#define STDFLG 's' ++#define STDFLGLOC 4 + #define execpr 04000 + #define readpr 010000 + #define keyflg 020000 +-INT flags; ++EXTERN INT flags; ++#if defined(SYSIII) ++EXTERN BOOL rwait; ++EXTERN BOOL wasintr; /* used to tell if break or delete is hit ++ while executing a wait */ ++#endif + + /* error exits from various parts of shell */ +-#include <setjmp.h> +-jmp_buf subshell; +-jmp_buf errshell; ++EXTERN jmp_buf subshell; ++EXTERN jmp_buf errshell; ++#if defined(RENO) ++EXTERN jmp_buf INTbuf; ++#endif + + /* fault handling */ + #include "brkincr.h" +-POS brkincr; ++EXTERN INT brkincr; + + #define MINTRAP 0 +-#define MAXTRAP 17 ++#define MAXTRAP 33 + +-#define INTR 2 +-#define QUIT 3 +-#define MEMF 11 +-#define ALARM 14 +-#define KILL 15 ++#define INTR SIGINT ++#define QUIT SIGQUIT ++#define MEMF SIGSEGV ++#define ALARM SIGALRM ++#define KILL SIGTERM + #define TRAPSET 2 + #define SIGSET 4 + #define SIGMOD 8 +- +-VOID fault(); +-BOOL trapnote; +-STRING trapcom[]; +-BOOL trapflg[]; ++#if defined(SYSIII) ++#define SIGCAUGHT 16 ++#endif ++ ++EXTERN BOOL trapnote; ++EXTERN STRING trapcom[]; ++EXTERN BOOL trapflg[]; ++#if defined(RENO) ++EXTERN BOOL trapjmp[]; ++#endif + + /* name tree and words */ +-STRING *environ; +-CHAR numbuf[]; +-MSG export; +-MSG readonly; ++EXTERN STRING *environ; ++EXTERN CHAR numbuf[]; ++EXTERN CMSG export; ++EXTERN CMSG readonly; + + /* execflgs */ +-INT exitval; +-BOOL execbrk; +-INT loopcnt; +-INT breakcnt; ++EXTERN INT exitval; ++EXTERN BOOL execbrk; ++EXTERN INT loopcnt; ++EXTERN INT breakcnt; + + /* messages */ +-MSG mailmsg; +-MSG coredump; +-MSG badopt; +-MSG badparam; +-MSG badsub; +-MSG nospace; +-MSG notfound; +-MSG badtrap; +-MSG baddir; +-MSG badshift; +-MSG illegal; +-MSG restricted; +-MSG execpmsg; +-MSG notid; +-MSG wtfailed; +-MSG badcreate; +-MSG piperr; +-MSG badopen; +-MSG badnum; +-MSG arglist; +-MSG txtbsy; +-MSG toobig; +-MSG badexec; +-MSG notfound; +-MSG badfile; ++EXTERN CMSG mailmsg; ++EXTERN CMSG coredump; ++EXTERN CMSG badopt; ++EXTERN CMSG badparam; ++#if defined(SYSIII) ++EXTERN CMSG unset; ++#endif ++EXTERN CMSG badsub; ++EXTERN CMSG nospace; ++EXTERN CMSG badtrap; ++EXTERN CMSG memfault; ++EXTERN CMSG baddir; ++EXTERN CMSG badshift; ++EXTERN CMSG illegal; ++EXTERN CMSG restricted; ++EXTERN CMSG execpmsg; ++EXTERN CMSG notid; ++EXTERN CMSG badulimit; ++EXTERN CMSG wtfailed; ++EXTERN CMSG badcreate; ++#if defined(SYSIII) ++EXTERN CMSG nofork; ++EXTERN CMSG noswap; ++#endif ++EXTERN CMSG piperr; ++EXTERN CMSG badopen; ++EXTERN CMSG badnum; ++EXTERN CMSG arglist; ++#if defined(SYSIII) ++EXTERN CMSG argcount; ++#endif ++EXTERN CMSG txtbsy; ++EXTERN CMSG toobig; ++EXTERN CMSG badexec; ++EXTERN CMSG notfound; ++EXTERN CMSG badfile; ++EXTERN CSTRING sysmsg[]; ++#if defined(RENO) ++EXTERN INT num_sysmsg; ++#endif ++ ++#if defined(SYSIII) ++/* 'builtin' error messages */ ++EXTERN CMSG btest; ++EXTERN CMSG badop; ++#endif ++ ++#if defined(SYSIII) ++/* fork constant */ ++#define FORKLIM 32 ++#endif ++ ++#if defined(SYSIII) || defined(RENO) ++/* comment delimeter */ ++#define COMCHAR '#' ++#endif + +-address end[]; ++EXTERN address end[]; + + #include "ctype.h" + diff --git a/shells/v7sh/files/patch-error.c b/shells/v7sh/files/patch-error.c new file mode 100644 index 000000000000..7b73594922c9 --- /dev/null +++ b/shells/v7sh/files/patch-error.c @@ -0,0 +1,91 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ error.c.orig error.c +--- error.c.orig Fri Jun 4 02:51:01 2004 ++++ error.c Sat Jun 19 18:42:22 2004 +@@ -9,15 +9,17 @@ + + #include "defs.h" + ++STRING exitadr; ++INT exitval; + + /* ======== error handling ======== */ + +-exitset() ++VOID exitset() + { + assnum(&exitadr,exitval); + } + +-sigchk() ++VOID sigchk() + { + /* Find out if it is time to go away. + * `trapnote' is set to SIGSET when fault is seen and +@@ -25,26 +27,29 @@ + */ + IF trapnote&SIGSET + THEN exitsh(SIGFAIL); ++ /*NOTREACHED*/ + FI + } + +-failed(s1,s2) +- STRING s1, s2; ++VOID failed(s1,s2) ++ CSTRING s1, s2; + { + prp(); prs(s1); + IF s2 + THEN prs(colon); prs(s2); + FI + newline(); exitsh(ERROR); ++ /*NOTREACHED*/ + } + +-error(s) +- STRING s; ++VOID error(s) ++ CSTRING s; + { + failed(s,NIL); ++ /*NOTREACHED*/ + } + +-exitsh(xno) ++VOID exitsh(xno) + INT xno; + { + /* Arrive here from `FATAL' errors +@@ -57,23 +62,29 @@ + exitval=xno; + IF (flags & (forked|errflg|ttyflg)) != ttyflg + THEN done(); ++ /*NOTREACHED*/ + ELSE clearup(); ++#if defined(SYSIII) ++ execbrk = breakcnt = 0; ++#endif + longjmp(errshell,1); + FI + } + +-done() ++VOID done() + { + REG STRING t; +- IF t=trapcom[0] ++ ++ IF (t=trapcom[0])!=NIL /* GCC */ + THEN trapcom[0]=0; /*should free but not long */ + execexp(t,0); + FI + rmtemp(0); + exit(exitval); ++ /*NOTREACHED*/ + } + +-rmtemp(base) ++VOID rmtemp(base) + IOPTR base; + { + WHILE iotemp>base diff --git a/shells/v7sh/files/patch-expand.c b/shells/v7sh/files/patch-expand.c new file mode 100644 index 000000000000..c3aa671fd08e --- /dev/null +++ b/shells/v7sh/files/patch-expand.c @@ -0,0 +1,299 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ expand.c.orig expand.c +--- expand.c.orig Fri Jun 4 02:51:01 2004 ++++ expand.c Sat Jun 19 18:42:22 2004 +@@ -8,10 +8,6 @@ + */ + + #include "defs.h" +-#include <sys/types.h> +-#define DIRSIZ 15 +-#include <sys/stat.h> +-#include <sys/dir.h> + + + +@@ -24,52 +20,98 @@ + * + */ + +-PROC VOID addg(); ++LOCAL VOID addg(STRING, STRING, STRING); ++#if defined(SYSIII) ++LOCAL VOID chgquot(STRING, INT); ++#endif ++ ++ARGPTR gchain; + + + INT expand(as,rflg) + STRING as; ++ INT rflg; + { +- INT count, dirf; ++ INT count; ++ DIR *dirf; + BOOL dir=0; + STRING rescan = 0; + REG STRING s, cs; + ARGPTR schain = gchain; +- struct direct entry; ++ DIRPTR dp; + STATBUF statb; ++ CHAR buf[2]; + + IF trapnote&SIGSET THEN return(0); FI + +- s=cs=as; entry.d_name[DIRSIZ-1]=0; /* to end the string */ ++ s=cs=as; + + /* check for meta chars */ + BEGIN ++#if defined(SYSIII) ++#define open open_ ++ REG BOOL slash, open; slash=0;open=0; ++ LOOP ++ SWITCH *cs++ IN ++ case 0: IF rflg ANDF slash THEN break; ++ ELSE return(0); ++ FI ++ case '/': slash++; ++ open = 0; ++ continue; ++ case '[': open++; ++ continue; ++ case ']': IF open THEN break FI ++ continue; ++ case '?': ++ case '*': cs--; ++ break; ++ default: continue; ++ ENDSW ++ break; ++ POOL ++#undef open ++#else /* V7 */ + REG BOOL slash; slash=0; +- WHILE !fngchar(*cs) ++ WHILE !fngchar((INT) *cs) + DO IF *cs++==0 + THEN IF rflg ANDF slash THEN break; ELSE return(0) FI + ELIF *cs=='/' + THEN slash++; + FI + OD ++#endif + END + + LOOP IF cs==s +- THEN s=nullstr; ++ THEN movstr(nullstr,s=buf); + break; + ELIF *--cs == '/' + THEN *cs=0; +- IF s==cs THEN s="/" FI ++ IF s==cs THEN movstr("/",s=buf) FI + break; + FI + POOL ++#if defined(SYSIII) ++ chgquot(s, 0); ++ IF stat(*s?s:".",&statb)>=0 ++#else /* V7 */ + IF stat(s,&statb)>=0 ++#endif + ANDF (statb.st_mode&S_IFMT)==S_IFDIR +- ANDF (dirf=open(s,0))>0 ++#if defined(SYSIII) ++ ANDF (dirf=opendir(*s?s:".")) != NULL ++#else /* V7 */ ++ ANDF (dirf=opendir(s)) != NULL ++#endif + THEN dir++; ++ ELSE dirf=NULL; + FI ++#if defined(SYSIII) ++ chgquot(s, 1); ++#endif + count=0; +- IF *cs==0 THEN *cs++=0200 FI ++ IF *cs==0 THEN *cs++=QUOTE FI + IF dir + THEN /* check for rescan */ + REG STRING rs; rs=cs; +@@ -77,16 +119,33 @@ + REP IF *rs=='/' THEN rescan=rs; *rs=0; gchain=0 FI + PER *rs++ DONE + +- WHILE read(dirf, &entry, 16) == 16 ANDF (trapnote&SIGSET) == 0 +- DO IF entry.d_ino==0 ORF +- (*entry.d_name=='.' ANDF *cs!='.') ++#if defined(RENO) ++ IF setjmp(INTbuf) == 0 THEN trapjmp[INTR] = 1; FI ++ WHILE (trapnote&SIGSET) == 0 ANDF (dp = readdir(dirf)) != NULL ++#else /* V7 */ ++ WHILE (dp = readdir(dirf)) != NULL ANDF (trapnote&SIGSET) == 0 ++#endif ++ DO IF (*dp->d_name=='.' ANDF *cs!='.') + THEN continue; + FI +- IF gmatch(entry.d_name, cs) +- THEN addg(s,entry.d_name,rescan); count++; ++#if defined(SYSIII) ++/* ++ * Here lies the fix for the "echo * ^H/." problem when ++ * there are files with metacharacters in there names. ++ */ ++ chgquot(dp->d_name, 1); ++#endif ++ IF gmatch(dp->d_name, cs) ++ THEN addg(s,dp->d_name,rescan); count++; + FI ++#if defined(SYSIII) ++ chgquot(dp->d_name, 0); ++#endif + OD +- close(dirf); ++ closedir(dirf); ++#if defined(RENO) ++ trapjmp[INTR] = 0; ++#endif + + IF rescan + THEN REG ARGPTR rchain; +@@ -103,43 +162,68 @@ + FI + + BEGIN +- REG CHAR c; ++ REG INT c; + s=as; +- WHILE c = *s ++ WHILE (c = *s)!=0 /* GCC */ + DO *s++=(c&STRIP?c:'/') OD + END + return(count); + } + +-gmatch(s, p) ++INT gmatch(s, p) + REG STRING s, p; + { + REG INT scc; +- CHAR c; ++ INT c; + +- IF scc = *s++ ++ IF (scc = *s++)!=0 /* GCC */ + THEN IF (scc &= STRIP)==0 +- THEN scc=0200; ++ THEN scc=QUOTE; + FI + FI + SWITCH c = *p++ IN + + case '[': +- {BOOL ok; INT lc; ++ BEGIN ++ BOOL ok; INT lc; ++#if defined(SYSIII) ++ INT notflag=0; ++#endif + ok=0; lc=077777; +- WHILE c = *p++ ++#if defined(SYSIII) ++ IF *p == '!' ORF *p == '^' THEN notflag=1; p++; FI ++#endif ++ WHILE (c = *p++)!=0 /* GCC */ + DO IF c==']' + THEN return(ok?gmatch(s,p):0); + ELIF c==MINUS ++#if defined(SYSIII) ++ THEN IF notflag ++ THEN IF lc>scc ORF scc>*(p++) ++ THEN ok++; ++ ELSE return(0) ++ FI ++ ELSE IF lc<=scc ANDF scc<=(*p++) THEN ok++ FI ++ FI ++ ELSE IF notflag ++ THEN IF scc!=(lc=(c&STRIP)) ++ THEN ok++; ++ ELSE return(0) ++ FI ++ ELSE IF scc==(lc=(c&STRIP)) THEN ok++ FI ++ FI ++#else /* V7 */ + THEN IF lc<=scc ANDF scc<=(*p++) THEN ok++ FI + ELSE IF scc==(lc=(c&STRIP)) THEN ok++ FI ++#endif + FI + OD + return(0); +- } ++ END + + default: + IF (c&STRIP)!=scc THEN return(0) FI ++ /*FALLTHROUGH*/ + + case '?': + return(scc?gmatch(s,p):0); +@@ -165,7 +249,7 @@ + s2 = locstak()+BYTESPERWORD; + + s1=as1; +- WHILE c = *s1++ ++ WHILE (c = *s1++)!=0 /* GCC */ + DO IF (c &= STRIP)==0 + THEN *s2++='/'; + break; +@@ -173,18 +257,42 @@ + *s2++=c; + OD + s1=as2; +- WHILE *s2 = *s1++ DO s2++ OD +- IF s1=as3 ++ WHILE (*s2 = *s1++)!=0 DO s2++ OD /* GCC */ ++ IF (s1=as3)!=NIL /* GCC */ + THEN *s2++='/'; +- WHILE *s2++ = *++s1 DONE ++ WHILE (*s2++ = *++s1)!=0 DONE /* GCC */ + FI +- makearg(endstak(s2)); ++ makearg((ARGPTR) endstak(s2)); + } + +-makearg(args) +- REG STRING args; ++VOID makearg(args) ++ REG ARGPTR args; + { + args->argnxt=gchain; +- gchain=args; ++ gchain=(ARGPTR) args; + } + ++#if defined(SYSIII) ++LOCAL VOID chgquot(str, flg) ++ REG STRING str; ++ REG INT flg; ++{ ++ REG INT i; ++ ++ FOR i=0;str[i];i++ ++ DO ++ SWITCH str[i] IN ++ case '*': ++ case '?': ++ case '[': ++ case '*'|QUOTE: ++ case '?'|QUOTE: ++ case '['|QUOTE: ++ IF flg==0 ++ THEN str[i] &= (~QUOTE); ++ ELSE str[i] |= QUOTE; ++ FI ++ ENDSW ++ OD ++} ++#endif diff --git a/shells/v7sh/files/patch-fault.c b/shells/v7sh/files/patch-fault.c new file mode 100644 index 000000000000..47465abffc26 --- /dev/null +++ b/shells/v7sh/files/patch-fault.c @@ -0,0 +1,182 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ fault.c.orig fault.c +--- fault.c.orig Fri Jun 4 02:51:01 2004 ++++ fault.c Sat Jun 19 18:42:22 2004 +@@ -10,8 +10,54 @@ + #include "defs.h" + + ++BOOL trapnote; + STRING trapcom[MAXTRAP]; ++#if defined(SYSIII) ++BOOL trapflg[MAXTRAP] = { ++ 0, ++ 0, /* Hangup */ ++ SIGCAUGHT, /* Interrupt */ ++ SIGCAUGHT, /* Quit */ ++ 0, /* Illegal instruction */ ++ 0, /* Trace/BPT trap */ ++ 0, /* IOT trap */ ++ 0, /* EMT trap */ ++ 0, /* Floating exception */ ++ 0, /* Killed */ ++ 0, /* Bus error */ ++ 0, /* Memory fault */ ++ 0, /* Bad system call */ ++ 0, /* Broken pipe */ ++ SIGCAUGHT, /* Alarm call */ ++ SIGCAUGHT, /* Terminated */ ++ 0, /* Urgent condition */ ++ 0, /* Stopped */ ++ 0, /* Stopped from terminal */ ++ 0, /* Continued */ ++ 0, /* Child terminated */ ++ 0, /* Stopped on terminal input */ ++ 0, /* Stopped on terminal output */ ++ 0, /* Asynchronous I/O */ ++ 0, /* Exceeded cpu time limit */ ++ 0, /* Exceeded file size limit */ ++ 0, /* Virtual time alarm */ ++ 0, /* Profiling time alarm */ ++ 0, /* Window size changed */ ++ 0, /* Information request */ ++ 0, /* User defined signal 1 */ ++ 0, /* User defined signal 2 */ ++ 0 /* Thread interrupt */ ++}; ++#else /* V7 */ + BOOL trapflg[MAXTRAP]; ++#endif ++#if defined(RENO) ++BOOL trapjmp[MAXTRAP]; ++jmp_buf INTbuf; ++#endif ++#if defined(SYSIII) ++BOOL wasintr; ++#endif + + /* ======== fault handling routines ======== */ + +@@ -21,49 +67,77 @@ + { + REG INT flag; + ++#if defined(V7) + signal(sig,fault); ++#endif + IF sig==MEMF +- THEN IF setbrk(brkincr) == -1 ++ THEN IF setbrk(brkincr) == (BYTPTR)-1 + THEN error(nospace); ++ /*NOTREACHED*/ + FI + ELIF sig==ALARM + THEN IF flags&waiting + THEN done(); ++ /*NOTREACHED*/ + FI + ELSE flag = (trapcom[sig] ? TRAPSET : SIGSET); + trapnote |= flag; + trapflg[sig] |= flag; ++#if defined(SYSIII) ++ IF sig == INTR THEN wasintr++ FI ++#endif + FI ++#if defined(RENO) ++ IF trapjmp[sig] ANDF sig==INTR ++ THEN trapjmp[sig] = 0; ++ longjmp(INTbuf, 1); ++ FI ++#endif + } + +-stdsigs() ++VOID stdsigs() + { + ignsig(QUIT); + getsig(INTR); ++#if defined(SYSIII) ++ signal(MEMF, fault); ++#else /* V7 */ + getsig(MEMF); ++#endif + getsig(ALARM); + } + +-ignsig(n) ++SIGPTR ignsig(n) ++ INT n; + { +- REG INT s, i; ++ REG INT i; ++ REG SIGPTR s=SIG_DFL; /* GCC */ + +- IF (s=signal(i=n,1)&01)==0 ++#if defined(SYSIII) ++ IF (i=n)==MEMF ++ THEN clrsig(i); ++ failed(badtrap, memfault); ++ /*NOTREACHED*/ ++ ELIF (s=signal(i=n,SIG_IGN))==SIG_DFL ++#else /* V7 */ ++ IF (s=signal(i=n,SIG_IGN))==SIG_DFL ++#endif + THEN trapflg[i] |= SIGMOD; + FI + return(s); + } + +-getsig(n) ++VOID getsig(n) ++ INT n; + { + REG INT i; + +- IF trapflg[i=n]&SIGMOD ORF ignsig(i)==0 ++ IF trapflg[i=n]&SIGMOD ORF ignsig(i)==SIG_DFL + THEN signal(i,fault); + FI + } + +-oldsigs() ++VOID oldsigs() + { + REG INT i; + REG STRING t; +@@ -79,17 +153,24 @@ + trapnote=0; + } + +-clrsig(i) ++VOID clrsig(i) + INT i; + { +- free(trapcom[i]); trapcom[i]=0; ++ free((BLKPTR) trapcom[i]); trapcom[i]=0; + IF trapflg[i]&SIGMOD +- THEN signal(i,fault); ++#if defined(SYSIII) ++ THEN IF trapflg[i]&SIGCAUGHT ++ THEN signal(i, fault); ++ ELSE signal(i, SIG_DFL); ++ FI + trapflg[i] &= ~SIGMOD; ++#else /* V7 */ ++ THEN signal(i,fault); ++#endif + FI + } + +-chktrap() ++VOID chktrap() + { + /* check for traps */ + REG INT i=MAXTRAP; +@@ -99,7 +180,7 @@ + WHILE --i + DO IF trapflg[i]&TRAPSET + THEN trapflg[i] &= ~TRAPSET; +- IF t=trapcom[i] ++ IF (t=trapcom[i])!=NIL /* GCC */ + THEN INT savxit=exitval; + execexp(t,0); + exitval=savxit; exitset(); diff --git a/shells/v7sh/files/patch-io.c b/shells/v7sh/files/patch-io.c new file mode 100644 index 000000000000..c1180adb38cb --- /dev/null +++ b/shells/v7sh/files/patch-io.c @@ -0,0 +1,189 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ io.c.orig io.c +--- io.c.orig Fri Jun 4 02:51:01 2004 ++++ io.c Sat Jun 19 18:42:22 2004 +@@ -8,25 +8,34 @@ + */ + + #include "defs.h" +-#include "dup.h" ++ ++IOPTR iotemp; ++IOPTR iopend; ++INT stripflg; ++/* set by trim */ ++BOOL nosubst; + + + /* ======== input output and file copying ======== */ + +-initf(fd) ++VOID initf(fd) + UFD fd; + { +- REG FILE f=standin; ++ REG FILEPTR f=standin; + ++#if defined(SYSIII) ++ f->fdes=fd; f->fsiz=((flags&oneflg)==0 ? BUFSIZ : 1); ++#else /* V7 */ + f->fdes=fd; f->fsiz=((flags&(oneflg|ttyflg))==0 ? BUFSIZ : 1); ++#endif + f->fnxt=f->fend=f->fbuf; f->feval=0; f->flin=1; + f->feof=FALSE; + } + +-estabf(s) ++INT estabf(s) + REG STRING s; + { +- REG FILE f; ++ REG FILEPTR f; + + (f=standin)->fdes = -1; + f->fend=length(s)+(f->fnxt=s); +@@ -34,19 +43,19 @@ + return(f->feof=(s==0)); + } + +-push(af) +- FILE af; ++VOID push(af) ++ FILEPTR af; + { +- REG FILE f; ++ REG FILEPTR f; + + (f=af)->fstak=standin; + f->feof=0; f->feval=0; + standin=f; + } + +-pop() ++INT pop() + { +- REG FILE f; ++ REG FILEPTR f; + + IF (f=standin)->fstak + THEN IF f->fdes>=0 THEN close(f->fdes) FI +@@ -56,64 +65,66 @@ + FI + } + +-chkpipe(pv) ++VOID chkpipe(pv) + INT *pv; + { + IF pipe(pv)<0 ORF pv[INPIPE]<0 ORF pv[OTPIPE]<0 + THEN error(piperr); ++ /*NOTREACHED*/ + FI + } + +-chkopen(idf) +- STRING idf; ++INT chkopen(idf) ++ CSTRING idf; + { + REG INT rc; + +- IF (rc=open(idf,0))<0 ++ IF (rc=open(idf,O_RDONLY))<0 + THEN failed(idf,badopen); +- ELSE return(rc); ++ /*NOTREACHED*/ + FI ++ return(rc); + } + +-rename(f1,f2) ++VOID rename(f1,f2) + REG INT f1, f2; + { + IF f1!=f2 +- THEN dup(f1|DUPFLG, f2); ++ THEN dup2(f1, f2); + close(f1); + IF f2==0 THEN ioset|=1 FI + FI + } + +-create(s) ++INT create(s) + STRING s; + { + REG INT rc; + + IF (rc=creat(s,0666))<0 + THEN failed(s,badcreate); +- ELSE return(rc); ++ /*NOTREACHED*/ + FI ++ return(rc); + } + +-tmpfil() ++INT tmpfil() + { + itos(serial++); movstr(numbuf,tmpnam); + return(create(tmpout)); + } + +-/* set by trim */ +-BOOL nosubst; + +-copy(ioparg) ++VOID copy(ioparg) + IOPTR ioparg; + { +- CHAR c, *ends; +- REG CHAR *cline, *clinep; ++ INT c; ++ STRING ends; ++ REG STRING cline, clinep; + INT fd; + REG IOPTR iop; + +- IF iop=ioparg ++ IF (iop=ioparg)!=NIL /* GCC */ + THEN copy(iop->iolst); + ends=mactrim(iop->ioname); IF nosubst THEN iop->iofile &= ~IODOC FI + fd=tmpfil(); +@@ -121,13 +132,36 @@ + iop->iolst=iotemp; iotemp=iop; + cline=locstak(); + ++#if defined(SYSIII) ++ IF stripflg ++ THEN WHILE *ends=='\t' DO ends++ OD ++ FI ++#endif + LOOP clinep=cline; chkpr(NL); ++#if defined(SYSIII) ++ IF stripflg ++ THEN ++ WHILE (c=(nosubst ? readc() : nextc(*ends)), !eolchar(c)) ++ && cline == clinep && c == '\t' DONE ++ WHILE (!eolchar(c)) ++ DO ++ *clinep++=c; ++ c=(nosubst ? readc() : nextc(*ends)); ++ OD ++ ELSE ++#endif + WHILE (c = (nosubst ? readc() : nextc(*ends)), !eolchar(c)) DO *clinep++ = c OD ++#if defined(SYSIII) ++ FI ++#endif + *clinep=0; + IF eof ORF eq(cline,ends) THEN break FI + *clinep++=NL; +- write(fd,cline,clinep-cline); ++ write(fd,cline,(SIZE) (clinep-cline)); + POOL ++#if defined(SYSIII) ++ IF stripflg THEN stripflg-- FI ++#endif + close(fd); + FI + } diff --git a/shells/v7sh/files/patch-mac.h b/shells/v7sh/files/patch-mac.h new file mode 100644 index 000000000000..1a2f8ee1a0a2 --- /dev/null +++ b/shells/v7sh/files/patch-mac.h @@ -0,0 +1,17 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ mac.h.orig mac.h +--- mac.h.orig Fri Jun 4 02:51:01 2004 ++++ mac.h Sat Jun 19 18:42:23 2004 +@@ -9,10 +9,12 @@ + + #define LOCAL static + #define PROC extern ++#define CONST const ++#define EXTERN extern + #define TYPE typedef + #define STRUCT TYPE struct + #define UNION TYPE union +-#define REG register ++#define REG /* register */ + + #define IF if( + #define THEN ){ diff --git a/shells/v7sh/files/patch-macro.c b/shells/v7sh/files/patch-macro.c new file mode 100644 index 000000000000..8ee18f407c4b --- /dev/null +++ b/shells/v7sh/files/patch-macro.c @@ -0,0 +1,253 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ macro.c.orig macro.c +--- macro.c.orig Fri Jun 4 02:51:01 2004 ++++ macro.c Sat Jun 19 18:42:23 2004 +@@ -10,27 +10,37 @@ + #include "defs.h" + #include "sym.h" + +-LOCAL CHAR quote; /* used locally */ +-LOCAL CHAR quoted; /* used locally */ ++LOCAL VOID copyto(INT); ++LOCAL VOID skipto(INT); ++LOCAL INT getch(INT); ++LOCAL VOID comsubst(VOID); ++#define flush flush_ ++LOCAL VOID flush(INT); + ++LOCAL INT quote; /* used locally */ ++LOCAL BOOL quoted; /* used locally */ + + +-LOCAL STRING copyto(endch) +- REG CHAR endch; ++LOCAL VOID copyto(endch) ++ REG INT endch; + { +- REG CHAR c; ++ REG INT c; + + WHILE (c=getch(endch))!=endch ANDF c + DO pushstak(c|quote) OD + zerostak(); +- IF c!=endch THEN error(badsub) FI ++ IF c!=endch ++ THEN error(badsub); ++ /*NOTREACHED*/ ++ FI + } + +-LOCAL skipto(endch) +- REG CHAR endch; ++LOCAL VOID skipto(endch) ++ REG INT endch; + { + /* skip chars up to } */ +- REG CHAR c; ++ REG INT c; ++ + WHILE (c=readc()) ANDF c!=endch + DO SWITCH c IN + +@@ -43,13 +53,16 @@ + FI + ENDSW + OD +- IF c!=endch THEN error(badsub) FI ++ IF c!=endch ++ THEN error(badsub); ++ /*NOTREACHED*/ ++ FI + } + +-LOCAL getch(endch) ++LOCAL INT getch(endch) + CHAR endch; + { +- REG CHAR d; ++ REG INT d; + + retry: + d=readc(); +@@ -62,13 +75,16 @@ + THEN NAMPTR n=NIL; + INT dolg=0; + BOOL bra; +- REG STRING argp, v; ++ REG STRING argp, v=NIL; /* GCC */ ++#if defined(SYSIII) ++ BOOL nulflg; ++#endif + CHAR idb[2]; +- STRING id=idb; ++ CSTRING id=idb; + +- IF bra=(c==BRACE) THEN c=readc() FI ++ IF (bra=c==BRACE)!=0 THEN c=readc() FI /* GCC */ + IF letter(c) +- THEN argp=relstak(); ++ THEN argp=(STRING) relstak(); + WHILE alphanum(c) DO pushstak(c); c=readc() OD + zerostak(); + n=lookup(absstak(argp)); setstak(argp); +@@ -80,7 +96,7 @@ + THEN dolg=1; c='1'; + FI + c -= '0'; +- v=((c==0) ? cmdadr : (c<=dolc) ? dolv[c] : (dolg=0)); ++ v=((c==0) ? cmdadr : (c<=dolc) ? dolv[c] : (STRING) (dolg=0)); + ELIF c=='$' + THEN v=pidadr; + ELIF c=='!' +@@ -91,18 +107,31 @@ + THEN v=exitadr; + ELIF c=='-' + THEN v=flagadr; +- ELIF bra THEN error(badsub); ++ ELIF bra ++ THEN error(badsub); ++ /*NOTREACHED*/ + ELSE goto retry; + FI + c = readc(); ++#if defined(SYSIII) ++ IF c==':' ANDF bra /* null and unset fix */ ++ THEN nulflg=1; c=readc(); ++ ELSE nulflg=0; ++ FI ++#endif + IF !defchar(c) ANDF bra + THEN error(badsub); ++ /*NOTREACHED*/ + FI + argp=0; + IF bra + THEN IF c!='}' +- THEN argp=relstak(); ++ THEN argp=(STRING) relstak(); ++#if defined(SYSIII) ++ IF (v==0 ORF (nulflg ANDF *v==0)) NEQ (setchar(c)) ++#else /* V7 */ + IF (v==0)NEQ(setchar(c)) ++#endif + THEN copyto('}'); + ELSE skipto('}'); + FI +@@ -110,9 +139,13 @@ + FI + ELSE peekc = c|MARK; c = 0; + FI ++#if defined(SYSIII) ++ IF v ANDF (!nulflg ORF *v) ++#else /* V7 */ + IF v ++#endif + THEN IF c!='+' +- THEN LOOP WHILE c = *v++ ++ THEN LOOP WHILE (c = *v++)!=0 /* GCC */ + DO pushstak(c|quote); OD + IF dolg==0 ORF (++dolg>dolc) + THEN break; +@@ -123,14 +156,21 @@ + ELIF argp + THEN IF c=='?' + THEN failed(id,*argp?argp:badparam); ++ /*NOTREACHED*/ + ELIF c=='=' + THEN IF n + THEN assign(n,argp); + ELSE error(badsub); ++ /*NOTREACHED*/ + FI + FI + ELIF flags&setflg ++#if defined(SYSIII) ++ THEN failed(id,unset); ++#else /* V7 */ + THEN failed(id,badparam); ++#endif ++ /*NOTREACHED*/ + FI + goto retry; + ELSE peekc=c|MARK; +@@ -152,24 +192,25 @@ + * Leaves result on top of stack + */ + REG BOOL savqu =quoted; +- REG CHAR savq = quote; ++ REG INT savq = quote; + FILEHDR fb; + +- push(&fb); estabf(as); ++ push((FILEPTR) &fb); estabf(as); + usestak(); + quote=0; quoted=0; + copyto(0); + pop(); + IF quoted ANDF (stakbot==staktop) THEN pushstak(QUOTE) FI ++ /* above is the fix for *'.c' bug */ + quote=savq; quoted=savqu; + return(fixstak()); + } + +-LOCAL comsubst() ++LOCAL VOID comsubst() + { + /* command substn */ + FILEBLK cb; +- REG CHAR d; ++ REG INT d; + REG STKPTR savptr = fixstak(); + + usestak(); +@@ -194,8 +235,16 @@ + close(pv[OTPIPE]); + END + tdystak(savptr); staktop=movstr(savptr,stakbot); +- WHILE d=readc() DO pushstak(d|quote) OD ++#if defined(RENO) ++ WHILE (d=readc())!=0 DO locstak(); pushstak(d|quote) OD ++#else /* V7 */ ++ WHILE (d=readc())!=0 DO pushstak(d|quote) OD /* GCC */ ++#endif ++#if defined(SYSIII) ++ await(0,0); ++#else /* V7 */ + await(0); ++#endif + WHILE stakbot!=staktop + DO IF (*--staktop&STRIP)!=NL + THEN ++staktop; break; +@@ -206,16 +255,16 @@ + + #define CPYSIZ 512 + +-subst(in,ot) ++VOID subst(in,ot) + INT in, ot; + { +- REG CHAR c; ++ REG INT c; + FILEBLK fb; + REG INT count=CPYSIZ; + + push(&fb); initf(in); + /* DQUOTE used to stop it from quoting */ +- WHILE c=(getch(DQUOTE)&STRIP) ++ WHILE (c=(getch(DQUOTE)&STRIP))!=0 /* GCC */ + DO pushstak(c); + IF --count == 0 + THEN flush(ot); count=CPYSIZ; +@@ -225,9 +274,10 @@ + pop(); + } + +-LOCAL flush(ot) ++LOCAL VOID flush(ot) ++ INT ot; + { +- write(ot,stakbot,staktop-stakbot); +- IF flags&execpr THEN write(output,stakbot,staktop-stakbot) FI ++ write(ot,stakbot,(SIZE) (staktop-stakbot)); ++ IF flags&execpr THEN write(output,stakbot,(SIZE) (staktop-stakbot)) FI + staktop=stakbot; + } diff --git a/shells/v7sh/files/patch-main.c b/shells/v7sh/files/patch-main.c new file mode 100644 index 000000000000..ebc7b24377c9 --- /dev/null +++ b/shells/v7sh/files/patch-main.c @@ -0,0 +1,251 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ main.c.orig main.c +--- main.c.orig Fri Jun 4 02:51:01 2004 ++++ main.c Sat Jun 19 18:42:23 2004 +@@ -8,30 +8,43 @@ + */ + + #include "defs.h" +-#include "dup.h" + #include "sym.h" + #include "timeout.h" +-#include <sys/types.h> +-#include <sys/stat.h> +-#include <sgtty.h> +- +-UFD output = 2; +-LOCAL BOOL beenhere = FALSE; +-CHAR tmpout[20] = "/tmp/sh-"; +-FILEBLK stdfile; +-FILE standin = &stdfile; ++#include "pathnames.h" ++#ifdef stupid + #include <execargs.h> ++#endif + +-PROC VOID exfile(); ++LOCAL VOID exfile(BOOL); ++LOCAL VOID Ldup(INT, INT); + ++LOCAL BOOL beenhere = FALSE; ++LOCAL FILEBLK stdfile; + ++UFD output = 2; ++CHAR tmpout[20] = _PATH_TMPOUT; ++STRING tmpnam; ++FILEPTR standin = &stdfile; ++INT dolc; ++STRING *dolv; ++STRING dolladr; ++STRING cmdadr; ++STRING pidadr; ++STRING comdiv; ++INT flags; ++INT serial; ++jmp_buf subshell; ++jmp_buf errshell; + + +-main(c, v) ++INT main(c, v) + INT c; + STRING v[]; + { + REG INT rflag=ttyflg; ++#if defined(SYSIII) ++ INT rsflag=1; /* local restricted flag */ ++#endif + + /* initialise storage allocation */ + stdsigs(); +@@ -39,42 +52,72 @@ + addblok((POS)0); + + /* set names from userenv */ ++#if !defined(SYSIII) + getenv(); ++#else /* SYSIII */ ++ /* 'rsflag' is non-zero if SHELL variable is ++ set in environment and contains an 'r' in ++ the simple file part of the value. */ ++ rsflag=getenv(); + + /* look for restricted */ +-/* IF c>0 ANDF any('r', *v) THEN rflag=0 FI */ +- ++ /* a shell is also restricted if argv(0) has ++ an 'r' in its simple name */ ++ IF c>0 ANDF any('r', simple(*v)) THEN rflag=0 FI ++#endif + /* look for options */ ++ /* dolc is $# */ + dolc=options(c,v); + IF dolc<2 THEN flags |= stdflg FI ++#if defined(SYSIII) ++ IF dolc < 2 ++ THEN REG STRING flagc = flagadr; ++ WHILE *flagc DO flagc++ OD ++ *flagc = STDFLG; ++ FI ++#endif + IF (flags&stdflg)==0 + THEN dolc--; + FI + dolv=v+c-dolc; dolc--; + + /* return here for shell file execution */ ++ /* but not for parenthesis subshells */ + setjmp(subshell); + +- /* number of positional parameters */ ++ /* number of positional parameters '$#' */ + assnum(&dolladr,dolc); ++ /* comadr is $0 */ + cmdadr=dolv[0]; + +- /* set pidname */ ++ /* set pidname '$$' */ + assnum(&pidadr, getpid()); + + /* set up temp file names */ + settmp(); + +- /* default ifs */ ++ /* default internal field separators - $IFS */ + dfault(&ifsnod, sptbnl); + + IF (beenhere++)==FALSE + THEN /* ? profile */ ++#if defined(SYSIII) ++ IF *simple(cmdadr) == '-' ++ THEN IF (input=pathopen(nullstr, sysprofile))>=0 ++ THEN exfile(rflag); /* file exists */ ++ FI ++ IF (input=pathopen(homenod.namenv, profile))>=0 ++ THEN exfile(rflag); flags &= ~ttyflg; ++ FI ++ FI ++ IF rsflag==0 ORF rflag==0 THEN flags |= rshflg FI ++#else /* V7 */ + IF *cmdadr=='-' + ANDF (input=pathopen(nullstr, profile))>=0 + THEN exfile(rflag); flags &= ~ttyflg; + FI + IF rflag==0 THEN flags |= rshflg FI ++#endif + + /* open input file if specified */ + IF comdiv +@@ -82,18 +125,22 @@ + ELSE input=((flags&stdflg) ? 0 : chkopen(cmdadr)); + comdiv--; + FI +- ELSE *execargs=dolv; /* for `ps' cmd */ ++#ifdef stupid ++ ELSE *execargs=(STRING) dolv; /* for `ps' cmd */ ++#endif + FI + + exfile(0); + done(); ++ /*NOTREACHED*/ ++ return(exitval); /* GCC */ + } + + LOCAL VOID exfile(prof) +-BOOL prof; ++ BOOL prof; + { +- REG L_INT mailtime = 0; +- REG INT userid; ++ REG TIME mailtime = 0; ++ REG UID userid; + struct stat statb; + + /* move input */ +@@ -108,10 +155,14 @@ + output=OTIO; + FI + ++#if defined(SYSIII) ++ userid=geteuid(); ++#else /* V7 */ + userid=getuid(); ++#endif + + /* decide whether interactive */ +- IF (flags&intflg) ORF ((flags&oneflg)==0 ANDF gtty(output,&statb)==0 ANDF gtty(input,&statb)==0) ++ IF (flags&intflg) ORF ((flags&oneflg)==0 ANDF isatty(output) ANDF isatty(input)) + THEN dfault(&ps1nod, (userid?stdprompt:supprompt)); + dfault(&ps2nod, readmsg); + flags |= ttyflg|prompt; ignsig(KILL); +@@ -132,43 +183,63 @@ + exitset(); + IF (flags&prompt) ANDF standin->fstak==0 ANDF !eof + THEN IF mailnod.namval ++#if defined(SYSIII) ++ THEN IF stat(mailnod.namval,&statb)>=0 ++ THEN IF statb.st_size ++ ANDF mailtime ++ ANDF (statb.st_mtime != mailtime) ++ THEN prs(mailmsg) ++ FI ++ mailtime=statb.st_mtime; ++ ELIF mailtime==0 ++ THEN mailtime=1 ++ FI ++ FI ++#else /* V7 */ + ANDF stat(mailnod.namval,&statb)>=0 ANDF statb.st_size + ANDF (statb.st_mtime != mailtime) + ANDF mailtime + THEN prs(mailmsg) + FI + mailtime=statb.st_mtime; ++#endif ++#if TIMEOUT > 0 + prs(ps1nod.namval); alarm(TIMEOUT); flags |= waiting; ++#else /* !TIMEOUT */ ++ prs(ps1nod.namval); ++#endif + FI + + trapnote=0; peekc=readc(); + IF eof + THEN return; + FI ++#if TIMEOUT > 0 + alarm(0); flags &= ~waiting; +- execute(cmd(NL,MTFLG),0); ++#endif ++ execute(cmd(NL,MTFLG),0,0,0); + eof |= (flags&oneflg); + POOL + } + +-chkpr(eor) +-char eor; ++VOID chkpr(eor) ++ INT eor; + { + IF (flags&prompt) ANDF standin->fstak==0 ANDF eor==NL + THEN prs(ps2nod.namval); + FI + } + +-settmp() ++VOID settmp() + { + itos(getpid()); serial=0; + tmpnam=movstr(numbuf,&tmpout[TMPNAM]); + } + +-Ldup(fa, fb) ++LOCAL VOID Ldup(fa, fb) + REG INT fa, fb; + { +- dup(fa|DUPFLG, fb); ++ dup2(fa, fb); + close(fa); +- ioctl(fb, FIOCLEX, 0); ++ fcntl(fb, F_SETFD, FD_CLOEXEC); + } diff --git a/shells/v7sh/files/patch-mode.h b/shells/v7sh/files/patch-mode.h new file mode 100644 index 000000000000..8551343db011 --- /dev/null +++ b/shells/v7sh/files/patch-mode.h @@ -0,0 +1,148 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ mode.h.orig mode.h +--- mode.h.orig Fri Jun 4 02:51:02 2004 ++++ mode.h Sat Jun 19 18:42:23 2004 +@@ -1,6 +1,10 @@ + # + /* + * UNIX shell ++ * ++ * S. R. Bourne ++ * Bell Telephone Laboratories ++ * + */ + + +@@ -10,23 +14,38 @@ + TYPE char BOOL; + TYPE int UFD; + TYPE int INT; ++TYPE unsigned UINT; + TYPE float REAL; + TYPE char *ADDRESS; +-TYPE long int L_INT; +-TYPE int VOID; +-TYPE unsigned POS; ++TYPE long LONG; ++TYPE void VOID; ++TYPE size_t POS; + TYPE char *STRING; ++TYPE CONST char *CSTRING; + TYPE char MSG[]; ++TYPE CONST char CMSG[]; + TYPE int PIPE[]; + TYPE char *STKPTR; ++TYPE const char *CSTKPTR; + TYPE char *BYTPTR; + +-STRUCT stat STATBUF; /* defined in /usr/sys/stat.h */ ++TYPE clock_t CLOCK; ++TYPE mode_t MODE; ++TYPE off_t OFFSET; ++TYPE sig_t SIGPTR; ++TYPE size_t SIZE; ++TYPE time_t TIME; ++TYPE uid_t UID; ++ ++STRUCT dirent *DIRPTR; /* defined in dirent.h */ ++STRUCT stat STATBUF; /* defined in sys/stat.h */ ++STRUCT tms TIMEBUF; /* defined in sys/time.h */ ++ + STRUCT blk *BLKPTR; + STRUCT fileblk FILEBLK; + STRUCT filehdr FILEHDR; +-STRUCT fileblk *FILE; +-STRUCT trenod *TREPTR; ++STRUCT fileblk *FILEPTR; ++UNION trenod *TREPTR; + STRUCT forknod *FORKPTR; + STRUCT comnod *COMPTR; + STRUCT swnod *SWPTR; +@@ -44,7 +63,7 @@ + STRUCT sysnod SYSNOD; + STRUCT sysnod *SYSPTR; + STRUCT sysnod SYSTAB[]; +-#define NIL ((char*)0) ++#define NIL ((void*)0) + + + /* the following nonsense is required +@@ -52,8 +71,12 @@ + * into an Rvalue so two cheats + * are necessary, one for each context. + */ +-union { int _cheat;}; +-#define Lcheat(a) ((a)._cheat) ++#if defined(RENO) ++#define Lcheat(a) (*(int *)&(a)) ++#else /* V7 */ ++union _cheat { int _cheat;}; ++#define Lcheat(a) ((*(union _cheat *)&(a))._cheat) ++#endif + #define Rcheat(a) ((int)(a)) + + +@@ -69,11 +92,13 @@ + BLKPTR _blkptr; + NAMPTR _namptr; + BYTPTR _bytptr; +- } address; ++} address; + + ++#if defined(V7) + /* for functions that do not return values */ + struct void {INT vvvvvvvv;}; ++#endif + + + /* heap storage */ +@@ -90,7 +115,7 @@ + STRING fnxt; + STRING fend; + STRING *feval; +- FILE fstak; ++ FILEPTR fstak; + CHAR fbuf[BUFSIZ]; + }; + +@@ -103,21 +128,15 @@ + STRING fnxt; + STRING fend; + STRING *feval; +- FILE fstak; ++ FILEPTR fstak; + CHAR _fbuf[1]; + }; + + struct sysnod { +- STRING sysnam; ++ CSTRING sysnam; + INT sysval; + }; + +-/* this node is a proforma for those that follow */ +-struct trenod { +- INT tretyp; +- IOPTR treio; +-}; +- + /* dummy for access only */ + struct argnod { + ARGPTR argnxt; +@@ -203,3 +222,16 @@ + #define PARTYPE (sizeof(struct parnod)) + #define LSTTYPE (sizeof(struct lstnod)) + #define IOTYPE (sizeof(struct ionod)) ++ ++/* this node is a proforma for those that precede */ ++union trenod { ++ struct { INT tretyp; IOPTR treio; } treio; ++ struct forknod forknod; ++ struct comnod comnod; ++ struct ifnod ifnod; ++ struct whnod whnod; ++ struct fornod fornod; ++ struct swnod swnod; ++ struct parnod parnod; ++ struct lstnod lstnod; ++}; diff --git a/shells/v7sh/files/patch-msg.c b/shells/v7sh/files/patch-msg.c new file mode 100644 index 000000000000..9fc3eb2ad600 --- /dev/null +++ b/shells/v7sh/files/patch-msg.c @@ -0,0 +1,237 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ msg.c.orig msg.c +--- msg.c.orig Fri Jun 4 02:51:02 2004 ++++ msg.c Sat Jun 19 18:42:23 2004 +@@ -10,64 +10,88 @@ + + #include "defs.h" + #include "sym.h" ++#include "pathnames.h" + +-MSG version = "\nVERSION sys137 DATE 1978 Nov 6 14:29:22\n"; ++CMSG version = "\nVERSION sys137 DATE 1978 Nov 6 14:29:22\n"; + + /* error messages */ +-MSG badopt = "bad option(s)"; +-MSG mailmsg = "you have mail\n"; +-MSG nospace = "no space"; +-MSG synmsg = "syntax error"; +- +-MSG badnum = "bad number"; +-MSG badparam = "parameter not set"; +-MSG badsub = "bad substitution"; +-MSG badcreate = "cannot create"; +-MSG illegal = "illegal io"; +-MSG restricted = "restricted"; +-MSG piperr = "cannot make pipe"; +-MSG badopen = "cannot open"; +-MSG coredump = " - core dumped"; +-MSG arglist = "arg list too long"; +-MSG txtbsy = "text busy"; +-MSG toobig = "too big"; +-MSG badexec = "cannot execute"; +-MSG notfound = "not found"; +-MSG badfile = "bad file number"; +-MSG badshift = "cannot shift"; +-MSG baddir = "bad directory"; +-MSG badtrap = "bad trap"; +-MSG wtfailed = "is read only"; +-MSG notid = "is not an identifier"; ++CMSG badopt = "bad option(s)"; ++CMSG mailmsg = "you have mail\n"; ++CMSG nospace = "no space"; ++CMSG synmsg = "syntax error"; ++ ++CMSG badnum = "bad number"; ++#if defined(SYSIII) ++CMSG badparam = "parameter null or not set"; ++CMSG unset = "parameter not set"; ++#else /* V7 */ ++CMSG badparam = "parameter not set"; ++#endif ++CMSG badsub = "bad substitution"; ++CMSG badcreate = "cannot create"; ++CMSG illegal = "illegal io"; ++CMSG restricted = "restricted"; ++#if defined(SYSIII) ++CMSG nofork = "cannot fork: too many processes"; ++CMSG noswap = "cannot fork: no swap space"; ++#endif ++CMSG piperr = "cannot make pipe"; ++CMSG badopen = "cannot open"; ++CMSG coredump = " - core dumped"; ++CMSG arglist = "arg list too long"; ++#if defined(SYSIII) ++CMSG argcount = "argument count"; ++#endif ++CMSG txtbsy = "text busy"; ++CMSG toobig = "too big"; ++CMSG badexec = "cannot execute"; ++CMSG notfound = "not found"; ++CMSG badfile = "bad file number"; ++CMSG badshift = "cannot shift"; ++CMSG baddir = "bad directory"; ++CMSG badtrap = "bad trap"; ++CMSG memfault = "cannot trap 11"; ++CMSG wtfailed = "is read only"; ++CMSG notid = "is not an identifier"; ++CMSG badulimit = "bad ulimit"; ++ ++#if defined(SYSIII) ++/* messages for 'builtin' functions */ ++CMSG btest = "test"; ++CMSG badop = "unknown operator"; ++#endif + + /* built in names */ +-MSG pathname = "PATH"; +-MSG homename = "HOME"; +-MSG mailname = "MAIL"; +-MSG fngname = "FILEMATCH"; +-MSG ifsname = "IFS"; +-MSG ps1name = "PS1"; +-MSG ps2name = "PS2"; ++CMSG pathname = "PATH"; ++CMSG homename = "HOME"; ++CMSG mailname = "MAIL"; ++CMSG fngname = "FILEMATCH"; ++CMSG ifsname = "IFS"; ++CMSG ps1name = "PS1"; ++CMSG ps2name = "PS2"; + + /* string constants */ +-MSG nullstr = ""; +-MSG sptbnl = " \t\n"; +-MSG defpath = ":/bin:/usr/bin"; +-MSG colon = ": "; +-MSG minus = "-"; +-MSG endoffile = "end of file"; +-MSG unexpected = " unexpected"; +-MSG atline = " at line "; +-MSG devnull = "/dev/null"; +-MSG execpmsg = "+ "; +-MSG readmsg = "> "; +-MSG stdprompt = "$ "; +-MSG supprompt = "# "; +-MSG profile = ".profile"; +- ++CMSG nullstr = ""; ++CMSG sptbnl = " \t\n"; ++CMSG defpath = _PATH_DEFPATH; ++CMSG colon = ": "; ++CMSG minus = "-"; ++CMSG endoffile = "end of file"; ++CMSG endofline = "newline or ;"; ++CMSG unexpected = " unexpected"; ++CMSG atline = " at line "; ++CMSG devnull = _PATH_DEVNULL; ++CMSG execpmsg = "+ "; ++CMSG readmsg = "> "; ++CMSG stdprompt = "$ "; ++CMSG supprompt = "# "; ++CMSG profile = _PATH_DOTPROFILE; ++#if defined(SYSIII) ++CMSG sysprofile = _PATH_ETCPROFILE; ++#endif + + /* tables */ +-SYSTAB reserved { ++SYSTAB reserved={ + {"in", INSYM}, + {"esac", ESSYM}, + {"case", CASYM}, +@@ -83,19 +107,19 @@ + {"until", UNSYM}, + { "{", BRSYM}, + { "}", KTSYM}, +- {0, 0}, ++ {0, 0} + }; + +-STRING sysmsg[] { ++CSTRING sysmsg[]={ + 0, + "Hangup", + 0, /* Interrupt */ + "Quit", + "Illegal instruction", + "Trace/BPT trap", +- "IOT trap", ++ "Abort trap", /* IOT trap */ + "EMT trap", +- "Floating exception", ++ "Floating point exception", + "Killed", + "Bus error", + "Memory fault", +@@ -103,25 +127,49 @@ + 0, /* Broken pipe */ + "Alarm call", + "Terminated", +- "Signal 16", ++ "Urgent I/O condition", ++ "Stopped", ++ "Stopped from terminal", ++ "Continued", ++ "Child exited", ++ "Stopped on terminal input", ++ "Stopped on terminal output", ++ "Asynchronous I/O", ++ "Cputime limit exceeded", ++ "Filesize limit exceeded", ++ "Virtual timer expired", ++ "Profiling timer expired", ++ "Window size changed", ++ "Information request", ++ "User defined signal 1", ++ "User defined signal 2", ++ "Thread interrupt" + }; ++#if defined(RENO) ++INT num_sysmsg = (sizeof sysmsg / sizeof sysmsg[0]); ++#endif ++ ++CMSG export = "export"; ++CMSG readonly = "readonly"; + +-MSG export = "export"; +-MSG readonly = "readonly"; +-SYSTAB commands { ++SYSTAB commands={ + {"cd", SYSCD}, + {"read", SYSREAD}, +-/* +- {"[", SYSTST}, +-*/ + {"set", SYSSET}, + {":", SYSNULL}, + {"trap", SYSTRAP}, ++#if defined(ULTRIX) ++ {"ulimit", SYSULIMIT}, ++#endif + {"login", SYSLOGIN}, + {"wait", SYSWAIT}, + {"eval", SYSEVAL}, + {".", SYSDOT}, ++#if defined(SYSIII) ++ {"newgrp", SYSNEWGRP}, ++#else /* V7 */ + {"newgrp", SYSLOGIN}, ++#endif + {readonly, SYSRDONLY}, + {export, SYSXPORT}, + {"chdir", SYSCD}, +@@ -132,5 +180,13 @@ + {"exec", SYSEXEC}, + {"times", SYSTIMES}, + {"umask", SYSUMASK}, +- {0, 0}, ++ {0, 0} ++}; ++ ++#if defined(SYSIII) ++SYSTAB builtins={ ++ {btest, TEST}, ++ {"[", TEST}, ++ {0, 0} + }; ++#endif diff --git a/shells/v7sh/files/patch-name.c b/shells/v7sh/files/patch-name.c new file mode 100644 index 000000000000..a17f5d115f99 --- /dev/null +++ b/shells/v7sh/files/patch-name.c @@ -0,0 +1,397 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ name.c.orig name.c +--- name.c.orig Fri Jun 4 02:51:02 2004 ++++ name.c Sat Jun 19 18:42:23 2004 +@@ -9,33 +9,36 @@ + + #include "defs.h" + +-PROC BOOL chkid(); ++LOCAL BOOL chkid(CSTRING); ++LOCAL VOID namwalk(NAMPTR); ++LOCAL STRING staknam(NAMPTR); ++LOCAL VOID countnam(NAMPTR); ++LOCAL VOID pushnam(NAMPTR); ++ ++NAMNOD ps2nod = { NIL, NIL, ps2name, NIL,NIL,0}, ++ fngnod = { NIL, NIL, fngname, NIL,NIL,0}, ++ pathnod = { NIL, NIL, pathname, NIL,NIL,0}, ++ ifsnod = { NIL, NIL, ifsname, NIL,NIL,0}, ++ ps1nod = { &pathnod, &ps2nod, ps1name, NIL,NIL,0}, ++ homenod = { &fngnod, &ifsnod, homename, NIL,NIL,0}, ++ mailnod = { &homenod, &ps1nod, mailname, NIL,NIL,0}; + +- +-NAMNOD ps2nod = { NIL, NIL, ps2name}, +- fngnod = { NIL, NIL, fngname}, +- pathnod = { NIL, NIL, pathname}, +- ifsnod = { NIL, NIL, ifsname}, +- ps1nod = { &pathnod, &ps2nod, ps1name}, +- homenod = { &fngnod, &ifsnod, homename}, +- mailnod = { &homenod, &ps1nod, mailname}; +- +-NAMPTR namep = &mailnod; ++LOCAL NAMPTR namep = &mailnod; + + + /* ======== variable and string handling ======== */ + +-syslook(w,syswds) ++INT syslook(w,syswds) + STRING w; + SYSTAB syswds; + { +- REG CHAR first; +- REG STRING s; ++ REG INT first; ++ REG CSTRING s; + REG SYSPTR syscan; + + syscan=syswds; first = *w; + +- WHILE s=syscan->sysnam ++ WHILE (s=syscan->sysnam)!=NIL /* GCC */ + DO IF first == *s + ANDF eq(w,s) + THEN return(syscan->sysval); +@@ -45,7 +48,7 @@ + return(0); + } + +-setlist(arg,xp) ++VOID setlist(arg,xp) + REG ARGPTR arg; + INT xp; + { +@@ -60,52 +63,107 @@ + OD + } + ++#if defined(SYSIII) ++INT setname(argi, xp) ++#else /* V7 */ + VOID setname(argi, xp) ++#endif + STRING argi; + INT xp; + { ++#if defined(SYSIII) ++ INT rsflag=1; /* local restricted flag */ ++#endif + REG STRING argscan=argi; + REG NAMPTR n; + +- IF letter(*argscan) +- THEN WHILE alphanum(*argscan) DO argscan++ OD ++ IF letter((INT) *argscan) ++ THEN WHILE alphanum((INT) *argscan) DO argscan++ OD + IF *argscan=='=' ++ /* make name a cohesive string */ + THEN *argscan = 0; ++#if defined(SYSIII) ++ /* restricted stuff excluded from research */ ++ IF eq(argi, "SHELL") ANDF !(flags&rshflg) ++ THEN argscan++; ++ IF any('r', simple(argscan)) ++ THEN rsflag=0; /* restricted shell */ ++ FI ++ argscan--; ++ FI ++ IF eq(argi,pathname) ANDF (flags&rshflg) /* cannot set PATH */ ++ THEN failed(argi,restricted); ++ /*NOTREACHED*/ ++ ELIF eq(argi, "SHELL") ANDF (flags&rshflg) ++ THEN failed(argi, restricted); ++ /*NOTREACHED*/ ++ ELSE ++#endif + n=lookup(argi); + *argscan++ = '='; + attrib(n, xp); + IF xp&N_ENVNAM ++#if defined(RENO) ++ THEN ++ /* ++ * Importing IFS can be very dangerous ++ */ ++ IF !bcmp(argi, "IFS=", sizeof("IFS=") - 1) ++ THEN ++ UID uid; ++ IF (uid = getuid())!=geteuid() ORF !uid ++ THEN ++#if defined(SYSIII) ++ return(0); ++#else /* V7 */ ++ return; ++#endif ++ FI ++ FI ++ n->namenv = n->namval = argscan; ++#else /* V7 */ + THEN n->namenv = n->namval = argscan; ++#endif + ELSE assign(n, argscan); + FI ++#if defined(SYSIII) ++ return(rsflag); ++ FI ++#else /* V7 */ + return; ++#endif + FI + FI + failed(argi,notid); ++ /*NOTREACHED*/ ++#if defined(SYSIII) ++ return(0); ++#endif + } + +-replace(a, v) ++VOID replace(a, v) + REG STRING *a; +- STRING v; ++ CSTRING v; + { +- free(*a); *a=make(v); ++ free((BLKPTR) *a); *a=make(v); + } + +-dfault(n,v) ++VOID dfault(n,v) + NAMPTR n; +- STRING v; ++ CSTRING v; + { + IF n->namval==0 + THEN assign(n,v) + FI + } + +-assign(n,v) ++VOID assign(n,v) + NAMPTR n; +- STRING v; ++ CSTRING v; + { + IF n->namflg&N_RDONLY + THEN failed(n->namid,wtfailed); ++ /*NOTREACHED*/ + ELSE replace(&n->namval,v); + FI + } +@@ -114,18 +172,24 @@ + STRING *names; + { + FILEBLK fb; +- REG FILE f = &fb; +- REG CHAR c; ++ REG FILEPTR f = &fb; ++ REG INT c; + REG INT rc=0; + NAMPTR n=lookup(*names++); /* done now to avoid storage mess */ +- STKPTR rel=relstak(); ++ STKPTR rel=(STKPTR) relstak(); + + push(f); initf(dup(0)); +- IF lseek(0,0L,1)==-1 ++ IF lseek(0,(OFFSET) 0,SEEK_CUR)==-1 + THEN f->fsiz=1; + FI + ++#if defined(SYSIII) ++ /* strip leading IFS characters */ ++ WHILE (any((c=nextc(0)), ifsnod.namval)) ANDF !(eolchar(c)) DONE ++ LOOP ++#else /* V7 */ + LOOP c=nextc(0); ++#endif + IF (*names ANDF any(c, ifsnod.namval)) ORF eolchar(c) + THEN zerostak(); + assign(n,absstak(rel)); setstak(rel); +@@ -135,8 +199,16 @@ + FI + IF eolchar(c) + THEN break; ++#if defined(SYSIII) ++ ELSE /* strip imbedded IFS characters */ ++ WHILE (any((c=nextc(0)), ifsnod.namval)) ANDF ++ !(eolchar(c)) DONE ++#endif + FI + ELSE pushstak(c); ++#if defined(SYSIII) ++ c=nextc(0); ++#endif + FI + POOL + WHILE n +@@ -145,12 +217,12 @@ + OD + + IF eof THEN rc=1 FI +- lseek(0, (long)(f->fnxt-f->fend), 1); ++ lseek(0, (OFFSET) (f->fnxt-f->fend), SEEK_CUR); + pop(); + return(rc); + } + +-assnum(p, i) ++VOID assnum(p, i) + STRING *p; + INT i; + { +@@ -158,27 +230,28 @@ + } + + STRING make(v) +- STRING v; ++ CSTRING v; + { + REG STRING p; + + IF v +- THEN movstr(v,p=alloc(length(v))); ++ THEN movstr(v,p=(STRING) alloc((POS) length(v))); + return(p); + ELSE return(0); + FI + } + + +-NAMPTR lookup(nam) +- REG STRING nam; ++NAMPTR lookup(nam) ++ REG CSTRING nam; + { + REG NAMPTR nscan=namep; +- REG NAMPTR *prev; ++ REG NAMPTR *prev=NIL; /* GCC */ + INT LR; + + IF !chkid(nam) + THEN failed(nam,notid); ++ /*NOTREACHED*/ + FI + WHILE nscan + DO IF (LR=cf(nam,nscan->namid))==0 +@@ -191,7 +264,7 @@ + OD + + /* add name node */ +- nscan=alloc(sizeof *nscan); ++ nscan=(NAMPTR) alloc(sizeof *nscan); + nscan->namlft=nscan->namrgt=NIL; + nscan->namid=make(nam); + nscan->namval=0; nscan->namflg=N_DEFAULT; nscan->namenv=0; +@@ -199,14 +272,14 @@ + } + + LOCAL BOOL chkid(nam) +- STRING nam; ++ CSTRING nam; + { +- REG CHAR * cp=nam; ++ REG CSTRING cp=nam; + +- IF !letter(*cp) ++ IF !letter((INT) *cp) + THEN return(FALSE); + ELSE WHILE *++cp +- DO IF !alphanum(*cp) ++ DO IF !alphanum((INT) *cp) + THEN return(FALSE); + FI + OD +@@ -214,9 +287,10 @@ + return(TRUE); + } + +-LOCAL VOID (*namfn)(); +-namscan(fn) +- VOID (*fn)(); ++LOCAL VOID (*namfn)(NAMPTR); ++ ++VOID namscan(fn) ++ VOID (*fn)(NAMPTR); + { + namfn=fn; + namwalk(namep); +@@ -238,7 +312,7 @@ + REG STRING s; + + sigchk(); +- IF s=n->namval ++ IF (s=n->namval)!=NIL /* GCC */ + THEN prs(n->namid); + prc('='); prs(s); + newline(); +@@ -253,16 +327,16 @@ + p=movstr(n->namid,staktop); + p=movstr("=",p); + p=movstr(n->namval,p); +- return(getstak(p+1-ADR(stakbot))); ++ return(getstak((POS) (p+1-ADR(stakbot)))); + } + + VOID exname(n) + REG NAMPTR n; + { + IF n->namflg&N_EXPORT +- THEN free(n->namenv); ++ THEN free((BLKPTR) n->namenv); + n->namenv = make(n->namval); +- ELSE free(n->namval); ++ ELSE free((BLKPTR) n->namval); + n->namval = make(n->namenv); + FI + } +@@ -281,6 +355,16 @@ + FI + } + ++#if defined(SYSIII) ++INT getenv() ++{ ++ INT rsflag=1; /* local restricted flag */ ++ REG STRING *e=environ; ++ ++ WHILE *e DO rsflag=setname(*e++, N_ENVNAM) & rsflag OD ++ return(rsflag); ++} ++#else /* V7 */ + VOID getenv() + { + REG STRING *e=environ; +@@ -288,18 +372,20 @@ + WHILE *e + DO setname(*e++, N_ENVNAM) OD + } ++#endif + +-LOCAL INT namec; ++LOCAL POS namec; + +-VOID countnam(n) ++LOCAL VOID countnam(n) + NAMPTR n; + { ++ n=n; /* GCC */ + namec++; + } + + LOCAL STRING *argnam; + +-VOID pushnam(n) ++LOCAL VOID pushnam(n) + NAMPTR n; + { + IF n->namval +@@ -313,7 +399,7 @@ + + namec=0; + namscan(countnam); +- argnam = er = getstak(namec*BYTESPERWORD+BYTESPERWORD); ++ argnam = er = (STRING *) getstak(namec*BYTESPERWORD+BYTESPERWORD); + namscan(pushnam); + *argnam++ = 0; + return(er); diff --git a/shells/v7sh/files/patch-name.h b/shells/v7sh/files/patch-name.h new file mode 100644 index 000000000000..31e19e132250 --- /dev/null +++ b/shells/v7sh/files/patch-name.h @@ -0,0 +1,12 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ name.h.orig name.h +--- name.h.orig Fri Jun 4 02:51:02 2004 ++++ name.h Sat Jun 19 18:42:24 2004 +@@ -18,7 +18,7 @@ + struct namnod { + NAMPTR namlft; + NAMPTR namrgt; +- STRING namid; ++ CSTRING namid; + STRING namval; + STRING namenv; + INT namflg; diff --git a/shells/v7sh/files/patch-print.c b/shells/v7sh/files/patch-print.c new file mode 100644 index 000000000000..1bde66cf91a1 --- /dev/null +++ b/shells/v7sh/files/patch-print.c @@ -0,0 +1,138 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ print.c.orig print.c +--- print.c.orig Fri Jun 4 02:51:02 2004 ++++ print.c Sat Jun 19 18:42:24 2004 +@@ -9,20 +9,20 @@ + + #include "defs.h" + +-CHAR numbuf[6]; ++CHAR numbuf[12]; + + + /* printing and io conversion */ + +-newline() ++VOID newline() + { prc(NL); + } + +-blank() ++VOID blank() + { prc(SP); + } + +-prp() ++VOID prp() + { + IF (flags&prompt)==0 ANDF cmdadr + THEN prs(cmdadr); prs(colon); +@@ -30,47 +30,49 @@ + } + + VOID prs(as) +- STRING as; ++ CSTRING as; + { +- REG STRING s; ++ REG CSTRING s; + +- IF s=as +- THEN write(output,s,length(s)-1); ++ IF (s=as)!=NIL /* GCC */ ++ THEN write(output,s,(SIZE) length(s)-1); + FI + } + + VOID prc(c) +- CHAR c; ++ INT c; + { + IF c +- THEN write(output,&c,1); ++ THEN write(output,&c,(SIZE) 1); + FI + } + +-prt(t) +- L_INT t; ++VOID prt(t) ++ CLOCK t; + { +- REG INT hr, min, sec; ++ REG CLOCK hr, min, sec; + + t += 30; t /= 60; + sec=t%60; t /= 60; + min=t%60; +- IF hr=t/60 +- THEN prn(hr); prc('h'); ++ IF (hr=t/60)!=0 /* GCC */ ++ THEN prl(hr); prc('h'); + FI +- prn(min); prc('m'); +- prn(sec); prc('s'); ++ prl(min); prc('m'); ++ prl(sec); prc('s'); + } + +-prn(n) ++VOID prn(n) + INT n; + { + itos(n); prs(numbuf); + } + +-itos(n) ++VOID itos(n) ++ INT n; + { +- REG char *abuf; REG POS a, i; INT pr, d; ++ REG STRING abuf; REG POS a, i; INT pr, d; ++ + abuf=numbuf; pr=FALSE; a=n; + FOR i=10000; i!=1; i/=10 + DO IF (pr |= (d=a/i)) THEN *abuf++=d+'0' FI +@@ -80,18 +82,38 @@ + *abuf++=0; + } + +-stoi(icp) +-STRING icp; ++INT stoi(icp) ++ CSTRING icp; + { +- REG CHAR *cp = icp; ++ REG CSTRING cp = icp; + REG INT r = 0; +- REG CHAR c; ++ REG INT c; + + WHILE (c = *cp, digit(c)) ANDF c ANDF r>=0 + DO r = r*10 + c - '0'; cp++ OD + IF r<0 ORF cp==icp + THEN failed(icp,badnum); +- ELSE return(r); ++ /*NOTREACHED*/ + FI ++ return(r); + } + ++VOID prl(n) /* for ULIMIT */ ++ LONG n; ++{ ++ ltos(n); prs(numbuf); ++} ++ ++VOID ltos(n) ++ LONG n; ++{ ++ REG STRING abuf; REG POS a, i; INT pr, d; ++ ++ abuf=numbuf; pr=FALSE; a=n; ++ FOR i=1000000000; i!=1; i/=10 ++ DO IF (pr |= (d=(INT) (a/i))) THEN *abuf++=d+'0' FI ++ a %= i; ++ OD ++ *abuf++=a+'0'; ++ *abuf++=0; ++} diff --git a/shells/v7sh/files/patch-service.c b/shells/v7sh/files/patch-service.c new file mode 100644 index 000000000000..2bc6c3830b1b --- /dev/null +++ b/shells/v7sh/files/patch-service.c @@ -0,0 +1,440 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ service.c.orig service.c +--- service.c.orig Fri Jun 4 02:51:02 2004 ++++ service.c Sat Jun 19 18:42:24 2004 +@@ -10,20 +10,15 @@ + #include "defs.h" + + +-PROC VOID gsort(); + + #define ARGMK 01 + +-INT errno; +-STRING sysmsg[]; +- +-/* fault handling */ +-#define ENOMEM 12 +-#define ENOEXEC 8 +-#define E2BIG 7 +-#define ENOENT 2 +-#define ETXTBSY 26 +- ++LOCAL CSTRING execs(CSTRING, STRING *); ++LOCAL VOID gsort(STRING *, STRING *); ++LOCAL INT split(STRING); ++#if defined(GOCSH) /* RENO */ ++LOCAL VOID gocsh(STRING *, STRING, STRING *); ++#endif + + + /* service routines for `execute' */ +@@ -32,7 +27,7 @@ + IOPTR iop; + { + REG STRING ion; +- REG INT iof, fd; ++ REG INT iof, fd=-1; /* GCC */ + + IF iop + THEN iof=iop->iofile; +@@ -47,15 +42,23 @@ + close(iof&IOUFD); + ELIF (fd=stoi(ion))>=USERIO + THEN failed(ion,badfile); ++ /*NOTREACHED*/ + ELSE fd=dup(fd); + FI + ELIF (iof&IOPUT)==0 + THEN fd=chkopen(ion); + ELIF flags&rshflg + THEN failed(ion,restricted); +- ELIF iof&IOAPP ANDF (fd=open(ion,1))>=0 +- THEN lseek(fd, 0L, 2); ++ /*NOTREACHED*/ ++#if defined(RENO) ++ ELIF (iof&IOAPP)==0 ORF ++ (fd=open(ion,O_WRONLY|O_APPEND))<0 ++ THEN fd=create(ion); ++#else /* V7 */ ++ ELIF iof&IOAPP ANDF (fd=open(ion,O_WRONLY))>=0 ++ THEN lseek(fd, (OFFSET) 0, SEEK_END); + ELSE fd=create(ion); ++#endif + FI + IF fd>=0 + THEN rename(fd,iof&IOUFD); +@@ -65,38 +68,44 @@ + FI + } + +-STRING getpath(s) +- STRING s; ++CSTRING getpath(s) ++ CSTRING s; + { +- REG STRING path; ++ REG CSTRING path; ++ ++#if defined(SYSIII) ++ IF any('/',s) ORF any(('/'|QUOTE),s) ++#else /* V7 */ + IF any('/',s) ++#endif + THEN IF flags&rshflg + THEN failed(s, restricted); +- ELSE return(nullstr); ++ /*NOTREACHED*/ + FI + ELIF (path = pathnod.namval)==0 + THEN return(defpath); + ELSE return(cpystak(path)); + FI ++ return(nullstr); + } + + INT pathopen(path, name) +- REG STRING path, name; ++ REG CSTRING path, name; + { + REG UFD f; + + REP path=catpath(path,name); +- PER (f=open(curstak(),0))<0 ANDF path DONE ++ PER (f=open(curstak(),O_RDONLY))<0 ANDF path DONE + return(f); + } + +-STRING catpath(path,name) +- REG STRING path; +- STRING name; ++CSTRING catpath(path,name) ++ REG CSTRING path; ++ CSTRING name; + { + /* leaves result on top of stack */ +- REG STRING scanp = path, +- argp = locstak(); ++ REG CSTRING scanp = path; ++ REG STRING argp = locstak(); + + WHILE *scanp ANDF *scanp!=COLON DO *argp++ = *scanp++ OD + IF scanp!=path THEN *argp++='/' FI +@@ -106,29 +115,32 @@ + return(path); + } + +-LOCAL STRING xecmsg; ++LOCAL CSTRING xecmsg; + LOCAL STRING *xecenv; + + VOID execa(at) + STRING at[]; + { +- REG STRING path; ++ REG CSTRING path; + REG STRING *t = at; + + IF (flags&noexec)==0 + THEN xecmsg=notfound; path=getpath(*t); + namscan(exname); + xecenv=setenv(); +- WHILE path=execs(path,t) DONE ++ WHILE (path=execs(path,t))!=NIL DONE /* GCC */ + failed(*t,xecmsg); ++ /*NOTREACHED*/ + FI + } + +-LOCAL STRING execs(ap,t) +- STRING ap; ++ ++LOCAL CSTRING execs(ap,t) ++ CSTRING ap; + REG STRING t[]; + { +- REG STRING p, prefix; ++ REG STRING p; ++ REG CSTRING prefix; + + prefix=catpath(ap,t[0]); + trim(p=curstak()); +@@ -145,32 +157,67 @@ + close(output); output=2; + input=chkopen(p); + ++#if defined(GOCSH) /* RENO */ ++ /* band aid to get csh... 2/26/79 */ ++ BEGIN ++ CHAR c; ++ ++ IF !isatty(input) ++ THEN read(input, &c, 1); ++ IF c == '#' THEN gocsh(t, p, xecenv) FI ++ lseek(input, (OFFSET) 0, SEEK_SET); ++ FI ++ END ++#endif ++ + /* set up new args */ + setargs(t); + longjmp(subshell,1); ++ /*NOTREACHED*/ + + case ENOMEM: + failed(p,toobig); ++ /*NOTREACHED*/ + + case E2BIG: + failed(p,arglist); ++ /*NOTREACHED*/ + + case ETXTBSY: + failed(p,txtbsy); ++ /*NOTREACHED*/ + + default: + xecmsg=badexec; ++ /*FALLTHROUGH*/ ++ + case ENOENT: + return(prefix); + ENDSW + } + ++#if defined(GOCSH) /* RENO */ ++LOCAL VOID gocsh(t, cp, xecenv) ++ REG STRING *t, cp, *xecenv; ++{ ++ STRING *newt[1000]; ++ REG STRING *p; ++ REG INT i; ++ ++ FOR i = 0; t[i]; i++ DO newt[i+1] = t[i] OD ++ newt[i+1] = 0; ++ newt[0] = _PATH_CSHELL; ++ newt[1] = cp; ++ execve(_PATH_CSHELL, newt, xecenv); ++} ++#endif ++ + /* for processes to be waited for */ + #define MAXP 20 + LOCAL INT pwlist[MAXP]; + LOCAL INT pwc; + +-postclr() ++VOID postclr() + { + REG INT *pw = pwlist; + +@@ -194,8 +241,13 @@ + FI + } + ++#if defined(SYSIII) ++VOID await(i, bckg) ++ INT i, bckg; ++#else /* V7 */ + VOID await(i) + INT i; ++#endif + { + INT rc=0, wx=0; + INT w; +@@ -206,28 +258,65 @@ + DO REG INT p; + REG INT sig; + INT w_hi; ++#if defined(SYSIII) ++ INT found = 0; ++#endif + + BEGIN + REG INT *pw=pwlist; ++#if defined(RENO) ++ IF setjmp(INTbuf) == 0 ++ THEN trapjmp[INTR] = 1; ++#endif + p=wait(&w); ++#if defined(SYSIII) ++ IF wasintr THEN ++ wasintr = 0; ++ IF bckg THEN break; FI ++ FI ++#endif ++#if defined(RENO) ++ ELSE p = -1; ++ FI ++ trapjmp[INTR] = 0; ++#endif + WHILE pw <= &pwlist[ipwc] + DO IF *pw==p + THEN *pw=0; pwc--; ++#if defined(SYSIII) ++ found++; ++#endif + ELSE pw++; + FI + OD + END + ++#if defined(SYSIII) ++ IF p == -1 ++ THEN IF bckg THEN ++ REG INT *pw =pwlist; ++ WHILE pw <= &pwlist[ipwc] ANDF i != *pw ++ DO pw++; OD ++ IF i == *pw THEN *pw = 0; pwc-- FI ++ FI ++ continue ++ FI ++#else /* V7 */ + IF p == -1 THEN continue FI ++#endif + + w_hi = (w>>8)&LOBYTE; + +- IF sig = w&0177 ++ IF (sig = w&0177)!=0 /* GCC */ + THEN IF sig == 0177 /* ptrace! return */ + THEN prs("ptrace: "); + sig = w_hi; + FI ++#if defined(RENO) ++ IF sig < num_sysmsg ANDF sysmsg[sig] ++#else /* V7 */ + IF sysmsg[sig] ++#endif + THEN IF i!=p ORF (flags&prompt)==0 THEN prp(); prn(p); blank() FI + prs(sysmsg[sig]); + IF w&0200 THEN prs(coredump) FI +@@ -235,29 +324,35 @@ + newline(); + FI + ++#if defined(SYSIII) ++ IF rc==0 ANDF found != 0 ++#else /* V7 */ + IF rc==0 ++#endif + THEN rc = (sig ? sig|SIGFLG : w_hi); + FI + wx |= w; ++#if defined(SYSIII) ++ IF p == i THEN break FI ++#endif + OD + + IF wx ANDF flags&errflg + THEN exitsh(rc); ++ /*NOTREACHED*/ + FI + exitval=rc; exitset(); + } + +-BOOL nosubst; +- +-trim(at) ++VOID trim(at) + STRING at; + { + REG STRING p; +- REG CHAR c; +- REG CHAR q=0; ++ REG INT c; ++ REG INT q=0; + +- IF p=at +- THEN WHILE c = *p ++ IF (p=at)!=NIL /* GCC */ ++ THEN WHILE (c = *p)!=0 /* GCC */ + DO *p++=c&STRIP; q |= c OD + FI + nosubst=q"E; +@@ -274,14 +369,15 @@ + STRING *scan(argn) + INT argn; + { +- REG ARGPTR argp = Rcheat(gchain)&~ARGMK; ++ REG ARGPTR argp = (ARGPTR) (Rcheat(gchain)&~ARGMK); + REG STRING *comargn, *comargm; + +- comargn=getstak(BYTESPERWORD*argn+BYTESPERWORD); comargm = comargn += argn; *comargn = ENDARGS; ++ comargn=(STRING *) getstak(BYTESPERWORD*argn+BYTESPERWORD); ++ comargm = comargn += argn; *comargn = ENDARGS; + + WHILE argp + DO *--comargn = argp->argval; +- IF argp = argp->argnxt ++ IF (argp = argp->argnxt)!=NIL /* GCC */ + THEN trim(*comargn); + FI + IF argp==0 ORF Rcheat(argp)&ARGMK +@@ -289,7 +385,7 @@ + comargm = comargn; + FI + /* Lcheat(argp) &= ~ARGMK; */ +- argp = Rcheat(argp)&~ARGMK; ++ argp = (ARGPTR) (Rcheat(argp)&~ARGMK); + OD + return(comargn); + } +@@ -327,7 +423,7 @@ + REG INT count=0; + REG COMPTR c; + +- IF c=ac ++ IF (c=ac)!=NIL /* GCC */ + THEN argp=c->comarg; + WHILE argp + DO count += split(macro(argp->argval)); +@@ -338,16 +434,17 @@ + } + + LOCAL INT split(s) ++ /* blank interpretation routine */ + REG STRING s; + { + REG STRING argp; + REG INT c; + INT count=0; + +- LOOP sigchk(); argp=locstak()+BYTESPERWORD; ++ LOOP sigchk(); argp=(STRING) (locstak()+BYTESPERWORD); + WHILE (c = *s++, !any(c,ifsnod.namval) && c) + DO *argp++ = c OD +- IF argp==staktop+BYTESPERWORD ++ IF argp==(STRING)(staktop+BYTESPERWORD) + THEN IF c + THEN continue; + ELSE return(count); +@@ -355,11 +452,27 @@ + ELIF c==0 + THEN s--; + FI +- IF c=expand((argp=endstak(argp))->argval,0) ++ /* file name generation */ ++ IF (c=expand(((ARGPTR) (argp=(STRING) endstak(argp)))->argval,0))!=0 /* GCC */ + THEN count += c; + ELSE /* assign(&fngnod, argp->argval); */ +- makearg(argp); count++; ++ makearg((ARGPTR) argp); count++; + FI + Lcheat(gchain) |= ARGMK; + POOL + } ++ ++#if defined(SYSIII) ++CSTRING simple(s) ++ CSTRING s; ++{ ++ CSTRING sname=s; ++ ++ LOOP ++ IF any('/', sname) ++ THEN WHILE *sname++ != '/' DONE ++ ELSE return(sname); ++ FI ++ POOL ++} ++#endif diff --git a/shells/v7sh/files/patch-setbrk.c b/shells/v7sh/files/patch-setbrk.c new file mode 100644 index 000000000000..e3cffed4bd67 --- /dev/null +++ b/shells/v7sh/files/patch-setbrk.c @@ -0,0 +1,16 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ setbrk.c.orig setbrk.c +--- setbrk.c.orig Fri Jun 4 02:51:02 2004 ++++ setbrk.c Sat Jun 19 18:42:24 2004 +@@ -9,9 +9,10 @@ + + #include "defs.h" + +-setbrk(incr) ++BYTPTR setbrk(incr) ++ INT incr; + { +- REG BYTPTR a=sbrk(incr); ++ REG BYTPTR a=(BYTPTR) sbrk(incr); + brkend=a+incr; + return(a); + } diff --git a/shells/v7sh/files/patch-stak.c b/shells/v7sh/files/patch-stak.c new file mode 100644 index 000000000000..3f83371c4a79 --- /dev/null +++ b/shells/v7sh/files/patch-stak.c @@ -0,0 +1,65 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ stak.c.orig stak.c +--- stak.c.orig Fri Jun 4 02:51:02 2004 ++++ stak.c Sat Jun 19 18:42:24 2004 +@@ -9,17 +9,19 @@ + + #include "defs.h" + +-STKPTR stakbot=nullstr; +- +- ++BLKPTR stakbsy; ++STKPTR stakbas; ++STKPTR brkend; ++STKPTR stakbot=(STKPTR) nullstr; ++STKPTR staktop; + + /* ======== storage allocation ======== */ + + STKPTR getstak(asize) +- INT asize; ++ POS asize; + { /* allocate requested stack */ + REG STKPTR oldstak; +- REG INT size; ++ REG POS size; + + size=round(asize,BYTESPERWORD); + oldstak=stakbot; +@@ -51,7 +53,7 @@ + { /* tidy up after `locstak' */ + REG STKPTR oldstak; + *argp++=0; +- oldstak=stakbot; stakbot=staktop=round(argp,BYTESPERWORD); ++ oldstak=stakbot; stakbot=staktop=(STKPTR) round(argp,BYTESPERWORD); + return(oldstak); + } + +@@ -59,15 +61,15 @@ + REG STKPTR x; + { + /* try to bring stack back to x */ +- WHILE ADR(stakbsy)>ADR(x) ++ WHILE ADR((STKPTR) stakbsy)>ADR(x) + DO free(stakbsy); + stakbsy = stakbsy->word; + OD + staktop=stakbot=max(ADR(x),ADR(stakbas)); +- rmtemp(x); ++ rmtemp((IOPTR) x); + } + +-stakchk() ++VOID stakchk() + { + IF (brkend-stakbas)>BRKINCR+BRKINCR + THEN setbrk(-BRKINCR); +@@ -75,7 +77,7 @@ + } + + STKPTR cpystak(x) +- STKPTR x; ++ CSTKPTR x; + { + return(endstak(movstr(x,locstak()))); + } diff --git a/shells/v7sh/files/patch-stak.h b/shells/v7sh/files/patch-stak.h new file mode 100644 index 000000000000..a802e41eabb8 --- /dev/null +++ b/shells/v7sh/files/patch-stak.h @@ -0,0 +1,58 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ stak.h.orig stak.h +--- stak.h.orig Fri Jun 4 02:51:02 2004 ++++ stak.h Sat Jun 19 18:42:24 2004 +@@ -34,7 +34,7 @@ + /* for local use only since it hands + * out a real address for the stack top + */ +-STKPTR locstak(); ++PROC STKPTR locstak(VOID); + + /* Will allocate the item being used and return its + * address (safe now). +@@ -44,33 +44,36 @@ + /* For use after `locstak' to hand back + * new stack top and then allocate item + */ +-STKPTR endstak(); ++PROC STKPTR endstak(STRING); + + /* Copy a string onto the stack and + * allocate the space. + */ +-STKPTR cpystak(); ++PROC STKPTR cpystak(CSTKPTR); + + /* Allocate given ammount of stack space */ +-STKPTR getstak(); ++PROC STKPTR getstak(POS); + + /* A chain of ptrs of stack blocks that + * have become covered by heap allocation. + * `tdystak' will return them to the heap. + */ +-BLKPTR stakbsy; ++EXTERN BLKPTR stakbsy; + + /* Base of the entire stack */ +-STKPTR stakbas; ++EXTERN STKPTR stakbas; + + /* Top of entire stack */ +-STKPTR brkend; ++EXTERN STKPTR brkend; + + /* Base of current item */ +-STKPTR stakbot; ++EXTERN STKPTR stakbot; + + /* Top of current item */ +-STKPTR staktop; ++EXTERN STKPTR staktop; + + /* Used with tdystak */ +-STKPTR savstak(); ++PROC STKPTR savstak(VOID); ++ ++PROC VOID tdystak(STKPTR); ++PROC VOID stakchk(VOID); diff --git a/shells/v7sh/files/patch-string.c b/shells/v7sh/files/patch-string.c new file mode 100644 index 000000000000..ee333b2f0e35 --- /dev/null +++ b/shells/v7sh/files/patch-string.c @@ -0,0 +1,53 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ string.c.orig string.c +--- string.c.orig Fri Jun 4 02:51:02 2004 ++++ string.c Sat Jun 19 18:42:24 2004 +@@ -14,19 +14,20 @@ + + + STRING movstr(a,b) +- REG STRING a, b; ++ REG CSTRING a; ++ REG STRING b; + { +- WHILE *b++ = *a++ DONE ++ WHILE (*b++ = *a++)!=0 DONE /* GCC */ + return(--b); + } + + INT any(c,s) +- REG CHAR c; +- STRING s; ++ REG INT c; ++ CSTRING s; + { +- REG CHAR d; ++ REG INT d; + +- WHILE d = *s++ ++ WHILE (d = *s++)!=0 /* GCC */ + DO IF d==c + THEN return(TRUE); + FI +@@ -35,7 +36,7 @@ + } + + INT cf(s1, s2) +- REG STRING s1, s2; ++ REG CSTRING s1, s2; + { + WHILE *s1++ == *s2 + DO IF *s2++==0 +@@ -46,10 +47,10 @@ + } + + INT length(as) +- STRING as; ++ CSTRING as; + { +- REG STRING s; ++ REG CSTRING s; + +- IF s=as THEN WHILE *s++ DONE FI ++ IF (s=as)!=NIL THEN WHILE *s++ DONE FI /* GCC */ + return(s-as); + } diff --git a/shells/v7sh/files/patch-sym.h b/shells/v7sh/files/patch-sym.h new file mode 100644 index 000000000000..5df426022ffb --- /dev/null +++ b/shells/v7sh/files/patch-sym.h @@ -0,0 +1,14 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ sym.h.orig sym.h +--- sym.h.orig Fri Jun 4 02:51:02 2004 ++++ sym.h Sat Jun 19 18:42:25 2004 +@@ -1,6 +1,10 @@ + # + /* + * UNIX shell ++ * ++ * S. R. Bourne ++ * Bell Telephone Laboratories ++ * + */ + + diff --git a/shells/v7sh/files/patch-test.c b/shells/v7sh/files/patch-test.c new file mode 100644 index 000000000000..9451b04d627e --- /dev/null +++ b/shells/v7sh/files/patch-test.c @@ -0,0 +1,223 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ test.c.orig test.c +--- test.c.orig Wed Jun 9 01:32:25 2004 ++++ test.c Sat Jun 19 18:42:25 2004 +@@ -3,24 +3,40 @@ + * [ expression ] + */ + ++#if defined(SYSIII) + #include "defs.h" +-#include <sys/types.h> +-#include <sys/stat.h> +-#define exp exp_ +- +-INT ap, ac; +-STRING *av; +- +-test(argn, com) +- STRING com[]; +- INT argn; +-{ + ++#undef eq ++#define eq(a,b) ((at=a)==0?0:cf(at,b)==0) + ++LOCAL STRING nxtarg(INT); ++#define exp exp_ ++LOCAL INT exp(VOID); ++LOCAL INT e1(VOID); ++LOCAL INT e2(VOID); ++LOCAL INT e3(VOID); ++LOCAL INT tio(STRING, INT); ++LOCAL INT ftype(STRING, INT); ++LOCAL INT fsizep(STRING); ++ ++LOCAL CMSG bramis = "] missing"; ++LOCAL CMSG argexp = "argument expected"; ++LOCAL CMSG braexp = ") expected"; ++ ++LOCAL INT ap, ac; ++LOCAL STRING *av; ++LOCAL STRING at; ++ ++ ++INT test(argn, com) ++ INT argn; ++ STRING com[]; ++{ + ac = argn; av = com; ap = 1; + IF eq(com[0],"[") + THEN IF !eq(com[--ac], "]") +- THEN failed("test", "] missing"); ++ THEN failed(btest, bramis); ++ /*NOTREACHED*/ + FI + FI + com[ac] = 0; +@@ -28,34 +44,33 @@ + return(exp()?0:1); + } + +-STRING nxtarg(mt) { +- ++LOCAL STRING nxtarg(mt) ++ INT mt; ++{ + IF ap >= ac + THEN IF mt + THEN ap++; + return(0); + FI +- failed("test", "argument expected"); ++ failed(btest, argexp); ++ /*NOTREACHED*/ + FI + return(av[ap++]); + } + +-exp() { +- INT p1; +- STRING p2; ++LOCAL INT exp() ++{ ++ INT p1; + + p1 = e1(); +- p2 = nxtarg(1); +- IF eq(p2, "-o") THEN return(p1 | exp()) FI +- IF (p2!=0)&&!eq(p2,"]")&&!eq(p2,")") +- THEN failed("test", synmsg); +- FI ++ IF eq(nxtarg(1), "-o") THEN return(p1 | exp()) FI + ap--; + return(p1); + } + +-e1() { +- INT p1; ++LOCAL INT e1() ++{ ++ INT p1; + + p1 = e2(); + IF eq(nxtarg(1), "-a") THEN return(p1 & e1()) FI +@@ -63,7 +78,8 @@ + return(p1); + } + +-e2() { ++LOCAL INT e2() ++{ + IF eq(nxtarg(0), "!") + THEN return(!e3()) + FI +@@ -71,26 +87,29 @@ + return(e3()); + } + +-e3() { +- INT p1; ++LOCAL INT e3() ++{ ++ INT p1; + REG STRING a; +- STRING p2; +- L_INT atol(); +- L_INT int1, int2; ++ STRING p2; ++ LONG int1, int2; + + a=nxtarg(0); + IF eq(a, "(") + THEN p1 = exp(); +- IF !eq(nxtarg(0), ")") THEN failed("test",") expected") FI ++ IF !eq(nxtarg(0), ")") ++ THEN failed(btest, braexp) ++ /*NOTREACHED*/ ++ FI + return(p1); + FI + + p2 = nxtarg(1); + ap--; + IF !eq(p2,"=")&&!eq(p2,"!=") +- THEN IF eq(a, "-r") THEN return(tio(nxtarg(0), 4)) FI +- IF eq(a, "-w") THEN return(tio(nxtarg(0), 2)) FI +- IF eq(a, "-x") THEN return(tio(nxtarg(0), 1)) FI ++ THEN IF eq(a, "-r") THEN return(tio(nxtarg(0), R_OK)) FI ++ IF eq(a, "-w") THEN return(tio(nxtarg(0), W_OK)) FI ++ IF eq(a, "-x") THEN return(tio(nxtarg(0), X_OK)) FI + IF eq(a, "-d") THEN return(ftype(nxtarg(0), S_IFDIR)) FI + IF eq(a, "-c") THEN return(ftype(nxtarg(0),S_IFCHR)) FI + IF eq(a, "-b") THEN return(ftype(nxtarg(0), S_IFBLK)) FI +@@ -106,7 +125,7 @@ + ORF eq(a, "-o") + THEN ap--; + return(isatty(1)); +- ELSE return(isatty(atol(a))); ++ ELSE return(isatty(atoi(a))); + FI + FI + IF eq(a, "-n") THEN return(!eq(nxtarg(0), "")) FI +@@ -121,7 +140,12 @@ + FI + IF eq(p2, "=") THEN return(eq(nxtarg(0), a)) FI + IF eq(p2, "!=") THEN return(!eq(nxtarg(0), a)) FI ++ IF eq(a, "-l") ++ THEN int1 = (LONG) length(p2) - 1; ++ p2 = nxtarg(0); ++ ELSE + int1 = atol(a); ++ FI + int2 = atol(nxtarg(0)); + IF eq(p2, "-eq") THEN return(int1==int2) FI + IF eq(p2, "-ne") THEN return(int1!=int2) FI +@@ -131,11 +155,13 @@ + IF eq(p2, "-le") THEN return(int1<=int2) FI + + bfailed(btest, badop, p2); ++ /*NOTREACHED*/ ++ return(0); /* GCC */ + } + +-tio(a, f) +- STRING a; +- INT f; ++LOCAL INT tio(a, f) ++ STRING a; ++ INT f; + { + IF access(a, f)==0 + THEN return(1); +@@ -143,11 +169,11 @@ + FI + } + +-ftype(f,field) +- STRING f; +- INT field; ++LOCAL INT ftype(f,field) ++ STRING f; ++ INT field; + { +- struct stat statb; ++ STATBUF statb; + + IF stat(f,&statb)<0 THEN return(0) FI + IF (statb.st_mode&field)==field +@@ -156,10 +182,12 @@ + FI + } + +-fsizep(f) +- STRING f; ++LOCAL INT fsizep(f) ++ STRING f; + { +- struct stat statb; ++ STATBUF statb; ++ + IF stat(f, &statb) <0 THEN return(0) FI + return(statb.st_size>0); + } ++#endif diff --git a/shells/v7sh/files/patch-timeout.h b/shells/v7sh/files/patch-timeout.h new file mode 100644 index 000000000000..378559c3db38 --- /dev/null +++ b/shells/v7sh/files/patch-timeout.h @@ -0,0 +1,9 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ timeout.h.orig timeout.h +--- timeout.h.orig Fri Jun 4 02:51:02 2004 ++++ timeout.h Sat Jun 19 18:42:25 2004 +@@ -7,4 +7,5 @@ + * + */ + ++/* seconds elapsing before log-off */ + #define TIMEOUT 0 diff --git a/shells/v7sh/files/patch-word.c b/shells/v7sh/files/patch-word.c new file mode 100644 index 000000000000..70545eed01c3 --- /dev/null +++ b/shells/v7sh/files/patch-word.c @@ -0,0 +1,157 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ word.c.orig word.c +--- word.c.orig Fri Jun 4 02:51:02 2004 ++++ word.c Sat Jun 19 18:42:25 2004 +@@ -10,19 +10,51 @@ + #include "defs.h" + #include "sym.h" + ++LOCAL INT readb(VOID); ++ ++INT wdval; ++INT wdnum; ++ARGPTR wdarg; ++INT wdset; ++BOOL reserv; ++INT peekc; ++BOOL rwait; ++ + + /* ======== character handling for command lines ========*/ + + +-word() ++INT word() + { +- REG CHAR c, d; +- REG CHAR *argp=locstak()+BYTESPERWORD; ++ REG INT c, d; ++ REG STRING argp=(STRING) (locstak()+BYTESPERWORD); ++ REG ARGPTR ap; + INT alpha=1; + + wdnum=0; wdset=0; + ++#if defined(SYSIII) ++ LOOP ++#endif + WHILE (c=nextc(0), space(c)) DONE ++#if defined(RENO) ++ IF c==COMCHAR ANDF ((flags&prompt)==0 ORF ((flags&ttyflg) ANDF ++ standin->fstak!=0)) ++ THEN WHILE (c=readc())!=EOF ANDF c!=NL DONE ++#if defined(SYSIII) ++ peekc=c; ++ ELSE break; /* out of comment - white space loop */ ++#endif ++ FI ++#endif ++#if defined(SYSIII) ++ IF c==COMCHAR ++ THEN WHILE (c=readc())!=EOF ANDF c!=NL DONE ++ peekc=c; ++ ELSE break; /* out of comment - white space loop */ ++ FI ++ POOL ++#endif + IF !eofmeta(c) + THEN REP IF c==LITERAL + THEN *argp++=(DQUOTE); +@@ -39,21 +71,29 @@ + FI + FI + PER (c=nextc(0), !eofmeta(c)) DONE +- argp=endstak(argp); +- IF !letter(argp->argval[0]) THEN wdset=0 FI ++ ap=(ARGPTR) endstak(argp); ++ IF !letter((INT) ap->argval[0]) THEN wdset=0 FI + + peekc=c|MARK; +- IF argp->argval[1]==0 ANDF (d=argp->argval[0], digit(d)) ANDF (c=='>' ORF c=='<') ++ IF ap->argval[1]==0 ANDF (d=ap->argval[0], digit(d)) ANDF (c=='>' ORF c=='<') + THEN word(); wdnum=d-'0'; + ELSE /*check for reserved words*/ +- IF reserv==FALSE ORF (wdval=syslook(argp->argval,reserved))==0 +- THEN wdarg=argp; wdval=0; ++ IF reserv==FALSE ORF (wdval=syslook(ap->argval,reserved))==0 ++ THEN wdarg=ap; wdval=0; + FI + FI + + ELIF dipchar(c) + THEN IF (d=nextc(0))==c + THEN wdval = c|SYMREP; ++#if defined(SYSIII) ++ IF c=='<' ++ THEN IF (d=nextc(0))=='-' ++ THEN stripflg++; ++ ELSE peekc = d|MARK; ++ FI ++ FI ++#endif + ELSE peekc = d|MARK; wdval = c; + FI + ELSE IF (wdval=c)==EOF +@@ -67,10 +107,10 @@ + return(wdval); + } + +-nextc(quote) +- CHAR quote; ++INT nextc(quote) ++ INT quote; + { +- REG CHAR c, d; ++ REG INT c, d; + IF (d=readc())==ESCAPE + THEN IF (c=readc())==NL + THEN chkpr(NL); d=nextc(quote); +@@ -82,15 +122,15 @@ + return(d); + } + +-readc() ++INT readc() + { +- REG CHAR c; ++ REG INT c; + REG INT len; +- REG FILE f; ++ REG FILEPTR f; + + retry: + IF peekc +- THEN c=peekc; peekc=0; ++ THEN c=peekc&STRIP; peekc=0; + ELIF (f=standin, f->fnxt!=f->fend) + THEN IF (c = *f->fnxt++)==0 + THEN IF f->feval +@@ -113,12 +153,26 @@ + return(c); + } + +-LOCAL readb() ++LOCAL INT readb() + { +- REG FILE f=standin; ++ REG FILEPTR f=standin; + REG INT len; + ++#if defined(RENO) ++ IF setjmp(INTbuf) == 0 THEN trapjmp[INTR] = 1; FI ++#endif ++#if defined(SYSIII) ++ REP IF trapnote&SIGSET ++ THEN newline(); sigchk(); ++ ELIF (trapnote&TRAPSET) ANDF (rwait>0) ++ THEN newline(); chktrap(); clearup(); ++ FI ++#else /* V7 */ + REP IF trapnote&SIGSET THEN newline(); sigchk() FI +- PER (len=read(f->fdes,f->fbuf,f->fsiz))<0 ANDF trapnote DONE ++#endif ++ PER (len=read(f->fdes,f->fbuf,(SIZE) f->fsiz))<0 ANDF trapnote DONE ++#if defined(RENO) ++ trapjmp[INTR] = 0; ++#endif + return(len); + } diff --git a/shells/v7sh/files/patch-xec.c b/shells/v7sh/files/patch-xec.c new file mode 100644 index 000000000000..4a793954cfe7 --- /dev/null +++ b/shells/v7sh/files/patch-xec.c @@ -0,0 +1,657 @@ +diff -u -x CVS -x work -x core -x *.core -x #* -x *~ -x *.orig -x *.rej -I $Id.*$ -I $.+BSD.*$ xec.c.orig xec.c +--- xec.c.orig Fri Jun 4 02:51:03 2004 ++++ xec.c Sat Jun 19 18:42:25 2004 +@@ -12,29 +12,36 @@ + + LOCAL INT parent; + +-SYSTAB commands; +- ++INT ioset; ++STRING pcsadr; ++INT loopcnt; ++INT breakcnt; ++BOOL execbrk; + + + /* ======== command execution ========*/ + + +-execute(argt, execflg, pf1, pf2) ++INT execute(argt, execflg, pf1, pf2) + TREPTR argt; ++ INT execflg; + INT *pf1, *pf2; + { + /* `stakbot' is preserved by this routine */ + REG TREPTR t; + STKPTR sav=savstak(); ++#if defined(SYSIII) ++ INT bltflg=0; ++#endif + + sigchk(); + + IF (t=argt) ANDF execbrk==0 + THEN REG INT treeflgs; + INT oldexit, type; +- REG STRING *com; ++ REG STRING *com=NIL; /* GCC */ + +- treeflgs = t->tretyp; type = treeflgs&COMMSK; ++ treeflgs = t->treio.tretyp; type = treeflgs&COMMSK; + oldexit=exitval; exitval=0; + + SWITCH type IN +@@ -42,16 +49,20 @@ + case TCOM: + BEGIN + STRING a1; +- INT argn, internal; ++ INT argn, internal=0; /* GCC */ + ARGPTR schain=gchain; +- IOPTR io=t->treio; ++ IOPTR io=t->treio.treio; + gchain=0; +- argn = getarg(t); ++ argn = getarg((COMPTR) t); + com=scan(argn); + a1=com[1]; gchain=schain; + ++#ifdef RENO ++ IF argn==0 ORF (internal=syslook(com[0],commands)) ++#else /* V7 */ + IF (internal=syslook(com[0],commands)) ORF argn==0 +- THEN setlist(t->comset, 0); ++#endif ++ THEN setlist(t->comnod.comset, 0); + FI + + IF argn ANDF (flags&noexec)==0 +@@ -71,44 +82,77 @@ + + IF (f=pathopen(getpath(a1), a1)) < 0 + THEN failed(a1,notfound); ++ /*NOTREACHED*/ + ELSE execexp(0,f); + FI + FI + break; + + case SYSTIMES: +- { +- L_INT t[4]; times(t); +- prt(t[2]); blank(); prt(t[3]); newline(); +- } ++ BEGIN ++ TIMEBUF timeb; times(&timeb); ++ prt(((CLOCK *)&timeb)[2]); blank(); ++ prt(((CLOCK *)&timeb)[3]); newline(); ++ END + break; + + case SYSEXIT: ++#if defined(SYSIII) ++ flags |= forked; /* force exit */ ++#endif + exitsh(a1?stoi(a1):oldexit); ++ /*NOTREACHED*/ + + case SYSNULL: + io=0; + break; + + case SYSCONT: ++#if defined(ULTRIX) ++ IF loopcnt ++ THEN execbrk = breakcnt = 1; ++ IF a1 ++ THEN breakcnt = stoi(a1) FI ++ breakcnt = breakcnt > loopcnt ? ++ loopcnt : -breakcnt; ++ FI ++ break; ++#elif defined(SYSIII) ++ IF (execbrk=-loopcnt)!=0 ANDF a1 ++ THEN breakcnt=stoi(a1); ++ FI ++ break; ++#else /* V7 */ + execbrk = -loopcnt; break; ++#endif + + case SYSBREAK: +- IF (execbrk=loopcnt) ANDF a1 ++#if defined(ULTRIX) ++ IF loopcnt ++ THEN execbrk = breakcnt = 1; ++ IF a1 ++ THEN breakcnt = stoi(a1) FI ++ IF breakcnt > loopcnt ++ THEN breakcnt = loopcnt FI ++ FI ++#else /* V7 */ ++ IF (execbrk=loopcnt)!=0 ANDF a1 /*GCC*/ + THEN breakcnt=stoi(a1); + FI ++#endif + break; + + case SYSTRAP: + IF a1 + THEN BOOL clear; +- IF (clear=digit(*a1))==0 ++ IF (clear=digit((INT) *a1))==0 + THEN ++com; + FI + WHILE *++com + DO INT i; + IF (i=stoi(*com))>=MAXTRAP ORF i<MINTRAP + THEN failed(*com,badtrap); ++ /*NOTREACHED*/ + ELIF clear + THEN clrsig(i); + ELSE replace(&trapcom[i],a1); +@@ -133,41 +177,67 @@ + com++; + initio(io); ioset=0; io=0; + IF a1==0 THEN break FI ++ /*FALLTHROUGH*/ + + case SYSLOGIN: ++#if !defined(SYSIII) + flags |= forked; ++#endif + oldsigs(); execa(com); done(); +- ++ /*NOTREACHED*/ ++#if defined(SYSIII) ++ case SYSNEWGRP: ++ IF flags&rshflg ++ THEN failed(com[0],restricted); ++ /*NOTREACHED*/ ++ ELSE /* force bad exec to terminate shell */ ++ flags |= forked; ++ oldsigs(); execa(com); done(); ++ /*NOTREACHED*/ ++ FI ++#endif + case SYSCD: + IF flags&rshflg + THEN failed(com[0],restricted); ++ /*NOTREACHED*/ ++#if defined(SYSIII) ++ ELIF (argn >2) ++ THEN failed(com[0],argcount); ++ /*NOTREACHED*/ ++#endif + ELIF (a1==0 ANDF (a1=homenod.namval)==0) ORF chdir(a1)<0 + THEN failed(a1,baddir); ++ /*NOTREACHED*/ + FI + break; + + case SYSSHFT: + IF dolc<1 + THEN error(badshift); ++ /*NOTREACHED*/ + ELSE dolv++; dolc--; + FI + assnum(&dolladr, dolc); + break; + + case SYSWAIT: ++#if defined(SYSIII) ++ await(a1?stoi(a1):-1,1); ++#else /* V7 */ + await(-1); ++#endif + break; + + case SYSREAD: ++#if defined(SYSIII) ++ rwait=1; ++#endif + exitval=readvar(&com[1]); ++#if defined(SYSIII) ++ rwait=0; ++#endif + break; + +-/* +- case SYSTST: +- exitval=testcmd(com); +- break; +-*/ +- + case SYSSET: + IF a1 + THEN INT argc; +@@ -175,7 +245,7 @@ + IF argc>1 + THEN setargs(com+argn-argc); + FI +- ELIF t->comset==0 ++ ELIF ((COMPTR) t)->comset==0 + THEN /*scan name chain and print*/ + namscan(printnam); + FI +@@ -183,6 +253,8 @@ + + case SYSRDONLY: + exitval=N_RDONLY; ++ /*FALLTHROUGH*/ ++ + case SYSXPORT: + IF exitval==0 THEN exitval=N_EXPORT; FI + +@@ -196,48 +268,120 @@ + + case SYSEVAL: + IF a1 +- THEN execexp(a1,&com[2]); ++ THEN execexp(a1,(UFD) &com[2]); + FI + break; +- ++#if defined(ULTRIX) ++ case SYSULIMIT: ++ BEGIN ++ LONG i = 0; ++ INT command = 2; ++ ++ IF **++com == '-' ++ THEN IF *(*com+1) != 'f' ++ THEN error(badopt) FI ++ com++; ++ FI ++ IF *com ++ THEN WHILE **com >= '0' && **com <= '9' ++ DO i *= 10; ++ i += **com - '0'; ++ IF i < 0 ++ THEN error(badulimit) FI ++ (*com)++; ++ OD ++ IF **com ++ THEN error(badulimit) FI ++ ELSE command--; ++ FI ++ i = ulimit(command,i); ++ IF i < 0 THEN error(badulimit) FI ++ IF command == i ++ THEN prl(i); newline(); FI ++ END ++ break; ++#endif + case SYSUMASK: +- if (a1) { +- int c, i ++ IF a1 ++ THEN INT c, i; + i = 0; +- while ((c = *a1++) >= '0' && ++ WHILE ((c = *a1++) >= '0' ANDF + c <= '7') +- i = (i << 3) + c - '0'; ++ DO i = (i << 3) + c - '0'; ++ OD + umask(i); +- } else { +- int i, j; ++ ELSE MODE i; INT j; + umask(i = umask(0)); + prc('0'); +- for (j = 6; j >= 0; j -= 3) +- prc(((i>>j)&07) + '0'); ++ FOR j = 6; j >= 0; j -= 3 ++ DO prc(((i>>j)&07) + '0'); ++ OD + newline(); +- } ++ FI + break; + + default: ++#if defined(SYSIII) ++ IF (internal=syslook(com[0],builtins))>0 ++ THEN builtin(internal, argn, com); ++ bltflg=1; ++ FI ++#else /* V7 */ + internal=builtin(argn,com); +- ++#endif + ENDSW + + IF internal ++#if defined(SYSIII) ++ THEN IF io ANDF !bltflg ++ THEN error(illegal); ++ /*NOTREACHED*/ ++ FI ++#else /* V7 */ + THEN IF io THEN error(illegal) FI ++#endif + chktrap(); + break; + FI +- ELIF t->treio==0 ++ ELIF t->treio.treio==0 ++#if defined(SYSIII) ++ THEN chktrap(); ++ break; ++#else /* V7 */ + THEN break; ++#endif + FI + END ++ /*FALLTHROUGH*/ + + case TFORK: + IF execflg ANDF (treeflgs&(FAMP|FPOU))==0 + THEN parent=0; ++#if defined(SYSIII) ++ ELSE UINT forkcnt=1; ++ /* FORKLIM is the max period between forks - ++ power of 2 usually. Currently shell tries ++ after 2,4,8,16, and 32 seconds and then quits */ ++ WHILE (parent=fork()) == -1 ++ DO IF (forkcnt=(forkcnt*2)) > FORKLIM /* 32 */ ++ THEN SWITCH errno IN ++ case ENOMEM: ++ error(noswap); ++ /*NOTREACHED*/ ++ break; ++ default: ++ /* case EAGAIN: */ ++ error(nofork); ++ /*NOTREACHED*/ ++ break; ++ ENDSW ++ FI ++ sigchk(); alarm(forkcnt); pause(); ++ OD ++#else /* V7 */ + ELSE WHILE (parent=fork()) == -1 + DO sigchk(); alarm(10); pause() OD ++#endif + FI + + IF parent +@@ -248,7 +392,11 @@ + FI + IF treeflgs&FPCL THEN closepipe(pf1) FI + IF (treeflgs&(FAMP|FPOU))==0 ++#if defined(SYSIII) ++ THEN await(parent,0); ++#else /* V7 */ + THEN await(parent); ++#endif + ELIF (treeflgs&FAMP)==0 + THEN post(parent); + ELSE assnum(&pcsadr, parent); +@@ -268,7 +416,8 @@ + /* except for those `lost' by trap */ + oldsigs(); + IF treeflgs&FINT +- THEN signal(INTR,1); signal(QUIT,1); ++ THEN signal(INTR,SIG_IGN); ++ signal(QUIT,SIG_IGN); + FI + + /* pipe in or out */ +@@ -287,111 +436,203 @@ + FI + + /* io redirection */ +- initio(t->treio); ++ initio(t->treio.treio); + IF type!=TCOM +- THEN execute(t->forktre,1); ++ THEN execute(t->forknod.forktre,1,0,0); + ELIF com[0]!=ENDARGS +- THEN setlist(t->comset,N_EXPORT); ++ THEN setlist(t->comnod.comset,N_EXPORT); + execa(com); + FI + done(); ++ /*NOTREACHED*/ + FI + + case TPAR: + rename(dup(2),output); +- execute(t->partre,execflg); ++ execute(t->parnod.partre,execflg,0,0); + done(); ++ /*NOTREACHED*/ + + case TFIL: + BEGIN + INT pv[2]; chkpipe(pv); +- IF execute(t->lstlef, 0, pf1, pv)==0 +- THEN execute(t->lstrit, execflg, pv, pf2); ++ IF execute(t->lstnod.lstlef, 0, pf1, pv)==0 ++ THEN execute(t->lstnod.lstrit, execflg, pv, pf2); + ELSE closepipe(pv); + FI + END + break; + + case TLST: +- execute(t->lstlef,0); +- execute(t->lstrit,execflg); ++ execute(t->lstnod.lstlef,0,0,0); ++ execute(t->lstnod.lstrit,execflg,0,0); + break; + + case TAND: +- IF execute(t->lstlef,0)==0 +- THEN execute(t->lstrit,execflg); ++ IF execute(t->lstnod.lstlef,0,0,0)==0 ++ THEN execute(t->lstnod.lstrit,execflg,0,0); + FI + break; + + case TORF: +- IF execute(t->lstlef,0)!=0 +- THEN execute(t->lstrit,execflg); ++ IF execute(t->lstnod.lstlef,0,0,0)!=0 ++ THEN execute(t->lstnod.lstrit,execflg,0,0); + FI + break; + + case TFOR: ++ /* for.. do */ + BEGIN +- NAMPTR n = lookup(t->fornam); ++ NAMPTR n = lookup(t->fornod.fornam); + STRING *args; + DOLPTR argsav=0; + +- IF t->forlst==0 ++ IF t->fornod.forlst==0 + THEN args=dolv+1; + argsav=useargs(); + ELSE ARGPTR schain=gchain; + gchain=0; +- trim((args=scan(getarg(t->forlst)))[0]); ++ trim((args=scan(getarg(t->fornod.forlst)))[0]); + gchain=schain; + FI + loopcnt++; ++#if defined(SYSIII) ++ WHILE *args!=ENDARGS ANDF execbrk<=0 ++#else /* V7 */ + WHILE *args!=ENDARGS ANDF execbrk==0 ++#endif + DO assign(n,*args++); +- execute(t->fortre,0); ++ execute(t->fornod.fortre,0,0,0); ++#if defined(ULTRIX) ++ IF breakcnt < 0 ++ THEN execbrk = (++breakcnt != 0) FI ++#elif defined(SYSIII) ++ IF execbrk ++ THEN IF breakcnt > 1 ORF execbrk > 0 ++ THEN break; ++ ELSE execbrk = breakcnt = 0; ++ FI ++ FI ++#else /* V7 */ + IF execbrk<0 THEN execbrk=0 FI ++#endif + OD ++#if defined(ULTRIX) ++ IF breakcnt > 0 ++ THEN execbrk = (--breakcnt != 0) FI ++ loopcnt--; ++#else /* V7 */ + IF breakcnt THEN breakcnt-- FI ++#if defined(SYSIII) ++ execbrk = (execbrk < 0 ? -breakcnt : breakcnt); ++ loopcnt--; ++#else /* V7 */ + execbrk=breakcnt; loopcnt--; +- argfor=freeargs(argsav); ++#endif ++#endif ++ argfor=(DOLPTR) freeargs(argsav); + END + break; + + case TWH: ++ /* while.. do */ + case TUN: ++ /* do.. until */ + BEGIN + INT i=0; ++#if defined(RENO) ++ INT saveflg; + ++ saveflg = flags&errflg; ++#endif + loopcnt++; +- WHILE execbrk==0 ANDF (execute(t->whtre,0)==0)==(type==TWH) +- DO i=execute(t->dotre,0); ++#if defined(RENO) ++#if defined(SYSIII) ++ WHILE execbrk<=0 ++#else /* RENO */ ++ WHILE execbrk==0 ++#endif ++ DO flags &= ~errflg; ++ i=execute(t->whnod.whtre,0,0,0); ++ flags |= saveflg; ++ IF (i==0)!=(type==TWH) THEN break FI ++ i=execute(t->whnod.dotre,0,0,0); ++#else /* V7 */ ++ WHILE execbrk==0 ANDF (execute(t->whnod.whtre,0,0,0)==0)==(type==TWH) ++ DO (i=execute(t->whnod.dotre,0,0,0))!=0; /* GCC */ ++#endif ++#if defined(ULTRIX) ++ IF breakcnt < 0 ++ THEN execbrk = (++breakcnt != 0) FI ++#elif defined(SYSIII) ++ IF execbrk ++ THEN IF breakcnt > 1 ORF execbrk > 0 ++ THEN break; ++ ELSE execbrk = breakcnt = 0; ++ FI ++ FI ++#else /* V7 */ + IF execbrk<0 THEN execbrk=0 FI ++#endif + OD ++#if defined(ULTRIX) ++ IF breakcnt > 0 ++ THEN execbrk = (--breakcnt != 0) FI ++ loopcnt--; exitval= i; ++#else /* V7 */ + IF breakcnt THEN breakcnt-- FI ++#if defined(SYSIII) ++ execbrk = (execbrk < 0 ? -breakcnt : breakcnt); ++ loopcnt--; exitval= i; ++#else /* V7 */ + execbrk=breakcnt; loopcnt--; exitval=i; ++#endif ++#endif + END + break; + + case TIF: +- IF execute(t->iftre,0)==0 +- THEN execute(t->thtre,execflg); +- ELSE execute(t->eltre,execflg); +- FI ++#if RENO ++ BEGIN ++ INT i, saveflg; ++ ++ saveflg = flags&errflg; ++ flags &= ~errflg; ++ i=execute(t->ifnod.iftre,0,0,0); ++ flags |= saveflg; ++ IF i==0 ++#else /* V7 */ ++ IF execute(t->ifnod.iftre,0,0,0)==0 ++#endif ++ THEN execute(t->ifnod.thtre,execflg,0,0); ++#if defined(SYSIII) ++ ELIF t->ifnod.eltre ++ THEN execute(t->ifnod.eltre,execflg,0,0); ++ ELSE exitval=0; /* force zero exit for if-then-fi */ ++#else /* V7 */ ++ ELSE execute(t->ifnod.eltre,execflg,0,0); ++#endif ++ FI ++#if RENO ++ END ++#endif + break; + + case TSW: + BEGIN +- REG STRING r = mactrim(t->swarg); +- t=t->swlst; +- WHILE t +- DO ARGPTR rex=t->regptr; ++ REG STRING r = mactrim(t->swnod.swarg); ++ REG REGPTR eg = t->swnod.swlst; ++ WHILE eg ++ DO ARGPTR rex=eg->regptr; + WHILE rex + DO REG STRING s; + IF gmatch(r,s=macro(rex->argval)) ORF (trim(s), eq(r,s)) +- THEN execute(t->regcom,0); ++ THEN execute(eg->regcom,0,0,0); + t=0; break; + ELSE rex=rex->argnxt; + FI + OD +- IF t THEN t=t->regnxt FI ++ IF eg THEN eg=eg->regnxt FI + OD + END + break; +@@ -405,17 +646,17 @@ + } + + +-execexp(s,f) ++VOID execexp(s,f) + STRING s; + UFD f; + { + FILEBLK fb; + push(&fb); + IF s +- THEN estabf(s); fb.feval=f; ++ THEN estabf(s); fb.feval=(STRING *)f; + ELIF f>=0 + THEN initf(f); + FI +- execute(cmd(NL, NLFLG|MTFLG),0); ++ execute(cmd(NL, NLFLG|MTFLG),0,0,0); + pop(); + } diff --git a/shells/v7sh/files/pathnames.h b/shells/v7sh/files/pathnames.h new file mode 100644 index 000000000000..4159c5ca9ebc --- /dev/null +++ b/shells/v7sh/files/pathnames.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that: (1) source distributions retain this entire copyright + * notice and comment, and (2) distributions including binaries display + * the following acknowledgement: ``This product includes software + * developed by the University of California, Berkeley and its contributors'' + * in the documentation or other materials provided with the distribution + * and in all advertising materials mentioning features or use of this + * software. Neither the name of the University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#)pathnames.h 5.2 (Berkeley) 5/31/90 + */ + +#include <paths.h> + +#define _PATH_DOTPROFILE ".bsh_profile" +#define _PATH_ETCPROFILE "/etc/bsh_profile" +#define _PATH_TMPOUT "/tmp/sh-" diff --git a/shells/v7sh/files/test.c b/shells/v7sh/files/test.c new file mode 100644 index 000000000000..dc4e54fabfda --- /dev/null +++ b/shells/v7sh/files/test.c @@ -0,0 +1,165 @@ +/* + * test expression + * [ expression ] + */ + +#include "defs.h" +#include <sys/types.h> +#include <sys/stat.h> +#define exp exp_ + +INT ap, ac; +STRING *av; + +test(argn, com) + STRING com[]; + INT argn; +{ + + + ac = argn; av = com; ap = 1; + IF eq(com[0],"[") + THEN IF !eq(com[--ac], "]") + THEN failed("test", "] missing"); + FI + FI + com[ac] = 0; + IF ac <= 1 THEN return(1) FI + return(exp()?0:1); +} + +STRING nxtarg(mt) { + + IF ap >= ac + THEN IF mt + THEN ap++; + return(0); + FI + failed("test", "argument expected"); + FI + return(av[ap++]); +} + +exp() { + INT p1; + STRING p2; + + p1 = e1(); + p2 = nxtarg(1); + IF eq(p2, "-o") THEN return(p1 | exp()) FI + IF (p2!=0)&&!eq(p2,"]")&&!eq(p2,")") + THEN failed("test", synmsg); + FI + ap--; + return(p1); +} + +e1() { + INT p1; + + p1 = e2(); + IF eq(nxtarg(1), "-a") THEN return(p1 & e1()) FI + ap--; + return(p1); +} + +e2() { + IF eq(nxtarg(0), "!") + THEN return(!e3()) + FI + ap--; + return(e3()); +} + +e3() { + INT p1; + REG STRING a; + STRING p2; + L_INT atol(); + L_INT int1, int2; + + a=nxtarg(0); + IF eq(a, "(") + THEN p1 = exp(); + IF !eq(nxtarg(0), ")") THEN failed("test",") expected") FI + return(p1); + FI + + p2 = nxtarg(1); + ap--; + IF !eq(p2,"=")&&!eq(p2,"!=") + THEN IF eq(a, "-r") THEN return(tio(nxtarg(0), 4)) FI + IF eq(a, "-w") THEN return(tio(nxtarg(0), 2)) FI + IF eq(a, "-x") THEN return(tio(nxtarg(0), 1)) FI + IF eq(a, "-d") THEN return(ftype(nxtarg(0), S_IFDIR)) FI + IF eq(a, "-c") THEN return(ftype(nxtarg(0),S_IFCHR)) FI + IF eq(a, "-b") THEN return(ftype(nxtarg(0), S_IFBLK)) FI + IF eq(a, "-f") THEN return(ftype(nxtarg(0), S_IFREG)) FI + IF eq(a, "-u") THEN return(ftype(nxtarg(0), S_ISUID)) FI + IF eq(a, "-g") THEN return(ftype(nxtarg(0), S_ISGID)) FI + IF eq(a, "-k") THEN return(ftype(nxtarg(0), S_ISVTX)) FI + IF eq(a, "-s") THEN return(fsizep(nxtarg(0))) FI + IF eq(a, "-t") + THEN IF ap >= ac /* no args */ + THEN return(isatty(1)); + ELIF eq((a=nxtarg(0)), "-a") + ORF eq(a, "-o") + THEN ap--; + return(isatty(1)); + ELSE return(isatty(atol(a))); + FI + FI + IF eq(a, "-n") THEN return(!eq(nxtarg(0), "")) FI + IF eq(a, "-z") THEN return(eq(nxtarg(0), "")) FI + FI + + p2 = nxtarg(1); + IF p2==0 THEN return(!eq(a, "")) FI + IF eq(p2, "-a") ORF eq(p2, "-o") + THEN ap--; + return(!eq(a, "")) + FI + IF eq(p2, "=") THEN return(eq(nxtarg(0), a)) FI + IF eq(p2, "!=") THEN return(!eq(nxtarg(0), a)) FI + int1 = atol(a); + int2 = atol(nxtarg(0)); + IF eq(p2, "-eq") THEN return(int1==int2) FI + IF eq(p2, "-ne") THEN return(int1!=int2) FI + IF eq(p2, "-gt") THEN return(int1>int2) FI + IF eq(p2, "-lt") THEN return(int1<int2) FI + IF eq(p2, "-ge") THEN return(int1>=int2) FI + IF eq(p2, "-le") THEN return(int1<=int2) FI + + bfailed(btest, badop, p2); +} + +tio(a, f) + STRING a; + INT f; +{ + IF access(a, f)==0 + THEN return(1); + ELSE return(0) + FI +} + +ftype(f,field) + STRING f; + INT field; +{ + struct stat statb; + + IF stat(f,&statb)<0 THEN return(0) FI + IF (statb.st_mode&field)==field + THEN return(1); + ELSE return(0) + FI +} + +fsizep(f) + STRING f; +{ + struct stat statb; + IF stat(f, &statb) <0 THEN return(0) FI + return(statb.st_size>0); +} diff --git a/shells/v7sh/files/ulimit.c b/shells/v7sh/files/ulimit.c new file mode 100644 index 000000000000..97b686c0bf04 --- /dev/null +++ b/shells/v7sh/files/ulimit.c @@ -0,0 +1,68 @@ +/*- + * Copyright (c) 2002 Kyle Martin <mkm@ieee.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/ulimit.c,v 1.1.2.1 2003/01/08 01:23:00 tjr Exp $ + */ + +#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> + +#include <errno.h> +#include <limits.h> +#include <stdarg.h> +#include "ulimit.h" + +long +ulimit(int cmd, ...) +{ + struct rlimit limit; + va_list ap; + long arg; + + if (cmd == UL_GETFSIZE) { + if (getrlimit(RLIMIT_FSIZE, &limit) == -1) + return (-1); + limit.rlim_cur /= 512; + if (limit.rlim_cur > LONG_MAX) + return (LONG_MAX); + return ((long)limit.rlim_cur); + } else if (cmd == UL_SETFSIZE) { + va_start(ap, cmd); + arg = va_arg(ap, long); + va_end(ap); + limit.rlim_max = limit.rlim_cur = (rlim_t)arg * 512; + + /* The setrlimit() function sets errno to EPERM if needed. */ + if (setrlimit(RLIMIT_FSIZE, &limit) == -1) + return (-1); + if (arg * 512 > LONG_MAX) + return (LONG_MAX); + return (arg); + } else { + errno = EINVAL; + return (-1); + } +} diff --git a/shells/v7sh/files/ulimit.h b/shells/v7sh/files/ulimit.h new file mode 100644 index 000000000000..c72cd0e2dca2 --- /dev/null +++ b/shells/v7sh/files/ulimit.h @@ -0,0 +1,41 @@ +/*- + * Copyright (c) 2002 Kyle Martin <mkm@ieee.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from FreeBSD: /repoman/r/ncvs/src/include/ulimit.h,v 1.1.2.1 2003/01/08 01:23:00 tjr Exp $ + */ + +#ifndef _ULIMIT_H_ +#define _ULIMIT_H_ + +#include <sys/cdefs.h> + +#define UL_GETFSIZE 1 +#define UL_SETFSIZE 2 + +__BEGIN_DECLS +long ulimit(int, ...); +__END_DECLS + +#endif /* !_ULIMIT_H_ */ diff --git a/shells/v7sh/pkg-descr b/shells/v7sh/pkg-descr new file mode 100644 index 000000000000..5262bc67cbe7 --- /dev/null +++ b/shells/v7sh/pkg-descr @@ -0,0 +1,23 @@ +The original Steve R. Bourne shell from the 7th edition Unix including +System III, 4.3BSD-Reno, Ultrix 3.1 and ``home made'' fixes and enhancements : + +* `--' end of options added (sysIII). `set +x' and such added (sysIII). + `/etc/bsh_profile' (sysIII) and `$HOME/.bsh_profile' (unsw) are + sourced at login time if they exist. Initially, only the `.profile' + located in the current directory was sourced at login time if it + exists. They have been `bsh_' prefixed to avoid conflicts w/ the + standards `profiles' which can contains unsupported expressions + such as shell functions. negation (! or ^) in `[]' added (sysIII). + `${x:-x}' and similar expressions added (sysIII). '<<-' (aka strip + leading tab in here document) added (sysIII). `#' comments are + allowed in shell scripts (sysIII/reno), but not on the command line + (reno) ! `break N' and `continue N' fixed (sysIII/ultrix). `if... + then... [elif... [else...]] fi' fixed (reno). `test' (sysIII) and + `ulimit' (ultrix) builtins added. +* ANSI-fication to permit an almost warning free compilation (home made). + `union trenod' taken from 4.3BSD-Reno. better signal handling and + error recovery (sysIII/reno). better restricted shell (sysIII) and + IFS protection (reno). +* functions aren't supported and command line input is not 8 bit clean. + +WWW: http://minnie.tuhs.org/UnixTree/V7/ diff --git a/shells/v7sh/pkg-plist b/shells/v7sh/pkg-plist new file mode 100644 index 000000000000..b0a0b315611c --- /dev/null +++ b/shells/v7sh/pkg-plist @@ -0,0 +1,3 @@ +bin/v7sh +@exec echo "updating /etc/shells"; cp /etc/shells /etc/shells.bak; (grep -v %D/%F /etc/shells.bak; echo %D/%F) >/etc/shells +@unexec echo "updating /etc/shells"; cp /etc/shells /etc/shells.bak; (grep -v %D/%F /etc/shells.bak) >/etc/shells |