perl 3.0 beta kit [12/23]

Larry Wall lwall at jato.Jpl.Nasa.Gov
Mon Sep 4 05:00:07 AEST 1989


#! /bin/sh

# Make a new directory for the perl sources, cd to it, and run kits 1
# thru 23 through sh.  When all 23 kits have been run, read README.

echo "This is perl 3.0 kit 12 (of 23).  If kit 12 is complete, the line"
echo '"'"End of kit 12 (of 23)"'" will echo at the end.'
echo ""
export PATH || (echo "You didn't use sh, you clunch." ; kill $$)
mkdir  2>/dev/null
echo Extracting regcomp.c
sed >regcomp.c <<'!STUFFY!FUNK!' -e 's/X//'
X/* NOTE: this is derived from Henry Spencer's regexp code, and should not
X * confused with the original package (see point 3 below).  Thanks, Henry!
X */
X
X/* Additional note: this code is very heavily munged from Henry's version
X * in places.  In some spots I've traded clarity for efficiency, so don't
X * blame Henry for some of the lack of readability.
X */
X
X/* $Header: regexp.c,v 2.0.1.5 88/09/07 17:02:10 lwall Locked $
X *
X * $Log:	regexp.c,v $
X */
X
X/*
X * regcomp and regexec -- regsub and regerror are not used in perl
X *
X *	Copyright (c) 1986 by University of Toronto.
X *	Written by Henry Spencer.  Not derived from licensed software.
X *
X *	Permission is granted to anyone to use this software for any
X *	purpose on any computer system, and to redistribute it freely,
X *	subject to the following restrictions:
X *
X *	1. The author is not responsible for the consequences of use of
X *		this software, no matter how awful, even if they arise
X *		from defects in it.
X *
X *	2. The origin of this software must not be misrepresented, either
X *		by explicit claim or by omission.
X *
X *	3. Altered versions must be plainly marked as such, and must not
X *		be misrepresented as being the original software.
X *
X *
X ****    Alterations to Henry's code are...
X ****
X ****    Copyright (c) 1989, Larry Wall
X ****
X ****    You may distribute under the terms of the GNU General Public License
X ****    as specified in the README file that comes with the perl 3.0 kit.
X *
X * Beware that some of this code is subtly aware of the way operator
X * precedence is structured in regular expressions.  Serious changes in
X * regular-expression syntax might require a total rethink.
X */
X#include "EXTERN.h"
X#include "perl.h"
X#include "INTERN.h"
X#include "regcomp.h"
X
X#ifndef STATIC
X#define	STATIC	static
X#endif
X
X#define	ISMULT1(c)	((c) == '*' || (c) == '+' || (c) == '?')
X#define	ISMULT2(s)	((*s) == '*' || (*s) == '+' || (*s) == '?' || \
X	((*s) == '{' && regcurly(s)))
X#define	META	"^$.[()|?+*\\"
X
X/*
X * Flags to be passed up and down.
X */
X#define	HASWIDTH	01	/* Known never to match null string. */
X#define	SIMPLE		02	/* Simple enough to be STAR/PLUS operand. */
X#define	SPSTART		04	/* Starts with * or +. */
X#define	WORST		0	/* Worst case. */
X
X/*
X * Global work variables for regcomp().
X */
Xstatic char *regprecomp;		/* uncompiled string. */
Xstatic char *regparse;		/* Input-scan pointer. */
Xstatic char *regxend;		/* End of input for compile */
Xstatic int regnpar;		/* () count. */
Xstatic char *regcode;		/* Code-emit pointer; &regdummy = don't. */
Xstatic long regsize;		/* Code size. */
Xstatic int regfold;
Xstatic int regsawbracket;	/* Did we do {d,d} trick? */
X
X/*
X * Forward declarations for regcomp()'s friends.
X */
XSTATIC int regcurly();
XSTATIC char *reg();
XSTATIC char *regbranch();
XSTATIC char *regpiece();
XSTATIC char *regatom();
XSTATIC char *regclass();
XSTATIC char *regnode();
XSTATIC void regc();
XSTATIC void reginsert();
XSTATIC void regtail();
XSTATIC void regoptail();
X
X/*
X - regcomp - compile a regular expression into internal code
X *
X * We can't allocate space until we know how big the compiled form will be,
X * but we can't compile it (and thus know how big it is) until we've got a
X * place to put the code.  So we cheat:  we compile it twice, once with code
X * generation turned off and size counting turned on, and once "for real".
X * This also means that we don't allocate space until we are sure that the
X * thing really will compile successfully, and we never have to move the
X * code and thus invalidate pointers into it.  (Note that it has to be in
X * one piece because free() must be able to free it all.) [NB: not true in perl]
X *
X * Beware that the optimization-preparation code in here knows about some
X * of the structure of the compiled regexp.  [I'll say.]
X */
Xregexp *
Xregcomp(exp,xend,fold,rare)
Xchar *exp;
Xchar *xend;
Xint fold;
Xint rare;
X{
X	register regexp *r;
X	register char *scan;
X	register STR *longest;
X	register int len;
X	register char *first;
X	int flags;
X	int back;
X	int curback;
X	extern char *safemalloc();
X	extern char *savestr();
X
X	if (exp == NULL)
X		fatal("NULL regexp argument");
X
X	/* First pass: determine size, legality. */
X	regfold = fold;
X	regparse = exp;
X	regxend = xend;
X	regprecomp = nsavestr(exp,xend-exp);
X	regsawbracket = 0;
X	regnpar = 1;
X	regsize = 0L;
X	regcode = ®dummy;
X	regc(MAGIC);
X	if (reg(0, &flags) == NULL) {
X		Safefree(regprecomp);
X		return(NULL);
X	}
X
X	/* Small enough for pointer-storage convention? */
X	if (regsize >= 32767L)		/* Probably could be 65535L. */
X		FAIL("regexp too big");
X
X	/* Allocate space. */
X	Newc(1001, r, sizeof(regexp) + (unsigned)regsize, char, regexp);
X	if (r == NULL)
X		FAIL("regexp out of space");
X
X	/* Second pass: emit code. */
X	if (regsawbracket)
X	    bcopy(regprecomp,exp,xend-exp);
X	r->precomp = regprecomp;
X	r->subbase = NULL;
X	regparse = exp;
X	regnpar = 1;
X	regcode = r->program;
X	regc(MAGIC);
X	if (reg(0, &flags) == NULL)
X		return(NULL);
X
X	/* Dig out information for optimizations. */
X	r->regstart = Nullstr;	/* Worst-case defaults. */
X	r->reganch = 0;
X	r->regmust = Nullstr;
X	r->regback = -1;
X	r->regstclass = Nullch;
X	scan = r->program+1;			/* First BRANCH. */
X	if (OP(regnext(scan)) == END) {/* Only one top-level choice. */
X		scan = NEXTOPER(scan);
X
X		first = scan;
X		while ((OP(first) > OPEN && OP(first) < CLOSE) ||
X		    (OP(first) == BRANCH && OP(regnext(first)) != BRANCH) ||
X		    (OP(first) == PLUS) )
X			first = NEXTOPER(first);
X
X		/* Starting-point info. */
X		if (OP(first) == EXACTLY) {
X			r->regstart =
X			    str_make(OPERAND(first)+1,*OPERAND(first));
X			if (r->regstart->str_cur > !(sawstudy|fold))
X				fbmcompile(r->regstart,fold);
X		}
X		else if ((exp = index(simple,OP(first))) && exp > simple)
X			r->regstclass = first;
X		else if (OP(first) == BOUND || OP(first) == NBOUND)
X			r->regstclass = first;
X		else if (OP(first) == BOL)
X			r->reganch++;
X
X#ifdef DEBUGGING
X		if (debug & 512)
X		    fprintf(stderr,"first %d next %d offset %d\n",
X		      OP(first), OP(NEXTOPER(first)), first - scan);
X#endif
X		/*
X		 * If there's something expensive in the r.e., find the
X		 * longest literal string that must appear and make it the
X		 * regmust.  Resolve ties in favor of later strings, since
X		 * the regstart check works with the beginning of the r.e.
X		 * and avoiding duplication strengthens checking.  Not a
X		 * strong reason, but sufficient in the absence of others.
X		 * [Now we resolve ties in favor of the earlier string if
X		 * it happens that curback has been invalidated, since the
X		 * earlier string may buy us something the later one won't.]
X		 */
X		longest = str_make("",0);
X		len = 0;
X		curback = 0;
X		back = 0;
X		while (scan != NULL) {
X			if (OP(scan) == BRANCH) {
X			    if (OP(regnext(scan)) == BRANCH) {
X				curback = -30000;
X				while (OP(scan) == BRANCH)
X				    scan = regnext(scan);
X			    }
X			    else	/* single branch is ok */
X				scan = NEXTOPER(scan);
X			}
X			if (OP(scan) == EXACTLY) {
X			    first = scan;
X			    while (OP(regnext(scan)) >= CLOSE)
X				scan = regnext(scan);
X			    if (curback - back == len) {
X				str_ncat(longest, OPERAND(first)+1,
X				    *OPERAND(first));
X				len += *OPERAND(first);
X				curback += *OPERAND(first);
X				first = regnext(scan);
X			    }
X			    else if (*OPERAND(first) >= len + (curback >= 0)) {
X				len = *OPERAND(first);
X				str_nset(longest, OPERAND(first)+1,len);
X				back = curback;
X				curback += len;
X				first = regnext(scan);
X			    }
X			    else
X				curback += *OPERAND(first);
X			}
X			else if (index(varies,OP(scan)))
X				curback = -30000;
X			else if (index(simple,OP(scan)))
X				curback++;
X			scan = regnext(scan);
X		}
X		if (len) {
X			r->regmust = longest;
X			if (back < 0)
X				back = -1;
X			r->regback = back;
X			if (len > !(sawstudy||fold||OP(first)==EOL))
X				fbmcompile(r->regmust,fold);
X			r->regmust->str_u.str_useful = 100;
X			if (OP(first) == EOL) /* is match anchored to EOL? */
X			    r->regmust->str_pok |= SP_TAIL;
X		}
X		else
X			str_free(longest);
X	}
X
X	r->do_folding = fold;
X	r->nparens = regnpar - 1;
X#ifdef DEBUGGING
X	if (debug & 512)
X		regdump(r);
X#endif
X	return(r);
X}
X
X/*
X - reg - regular expression, i.e. main body or parenthesized thing
X *
X * Caller must absorb opening parenthesis.
X *
X * Combining parenthesis handling with the base level of regular expression
X * is a trifle forced, but the need to tie the tails of the branches to what
X * follows makes it hard to avoid.
X */
Xstatic char *
Xreg(paren, flagp)
Xint paren;			/* Parenthesized? */
Xint *flagp;
X{
X	register char *ret;
X	register char *br;
X	register char *ender;
X	register int parno;
X	int flags;
X
X	*flagp = HASWIDTH;	/* Tentatively. */
X
X	/* Make an OPEN node, if parenthesized. */
X	if (paren) {
X		if (regnpar >= NSUBEXP)
X			FAIL("too many () in regexp");
X		parno = regnpar;
X		regnpar++;
X		ret = regnode(OPEN+parno);
X	} else
X		ret = NULL;
X
X	/* Pick up the branches, linking them together. */
X	br = regbranch(&flags);
X	if (br == NULL)
X		return(NULL);
X	if (ret != NULL)
X		regtail(ret, br);	/* OPEN -> first. */
X	else
X		ret = br;
X	if (!(flags&HASWIDTH))
X		*flagp &= ~HASWIDTH;
X	*flagp |= flags&SPSTART;
X	while (*regparse == '|') {
X		regparse++;
X		br = regbranch(&flags);
X		if (br == NULL)
X			return(NULL);
X		regtail(ret, br);	/* BRANCH -> BRANCH. */
X		if (!(flags&HASWIDTH))
X			*flagp &= ~HASWIDTH;
X		*flagp |= flags&SPSTART;
X	}
X
X	/* Make a closing node, and hook it on the end. */
X	ender = regnode((paren) ? CLOSE+parno : END);	
X	regtail(ret, ender);
X
X	/* Hook the tails of the branches to the closing node. */
X	for (br = ret; br != NULL; br = regnext(br))
X		regoptail(br, ender);
X
X	/* Check for proper termination. */
X	if (paren && *regparse++ != ')') {
X		FAIL("unmatched () in regexp");
X	} else if (!paren && regparse < regxend) {
X		if (*regparse == ')') {
X			FAIL("unmatched () in regexp");
X		} else
X			FAIL("junk on end of regexp");	/* "Can't happen". */
X		/* NOTREACHED */
X	}
X
X	return(ret);
X}
X
X/*
X - regbranch - one alternative of an | operator
X *
X * Implements the concatenation operator.
X */
Xstatic char *
Xregbranch(flagp)
Xint *flagp;
X{
X	register char *ret;
X	register char *chain;
X	register char *latest;
X	int flags;
X
X	*flagp = WORST;		/* Tentatively. */
X
X	ret = regnode(BRANCH);
X	chain = NULL;
X	while (regparse < regxend && *regparse != '|' && *regparse != ')') {
X		latest = regpiece(&flags);
X		if (latest == NULL)
X			return(NULL);
X		*flagp |= flags&HASWIDTH;
X		if (chain == NULL)	/* First piece. */
X			*flagp |= flags&SPSTART;
X		else
X			regtail(chain, latest);
X		chain = latest;
X	}
X	if (chain == NULL)	/* Loop ran zero times. */
X		(void) regnode(NOTHING);
X
X	return(ret);
X}
X
X/*
X - regpiece - something followed by possible [*+?]
X *
X * Note that the branching code sequences used for ? and the general cases
X * of * and + are somewhat optimized:  they use the same NOTHING node as
X * both the endmarker for their branch list and the body of the last branch.
X * It might seem that this node could be dispensed with entirely, but the
X * endmarker role is not redundant.
X */
Xstatic char *
Xregpiece(flagp)
Xint *flagp;
X{
X	register char *ret;
X	register char op;
X	register char *next;
X	int flags;
X	char *origparse = regparse;
X	int orignpar = regnpar;
X	char *max;
X	int iter;
X	char ch;
X
X	ret = regatom(&flags);
X	if (ret == NULL)
X		return(NULL);
X
X	op = *regparse;
X
X	/* Here's a total kludge: if after the atom there's a {\d+,?\d*}
X	 * then we decrement the first number by one and reset our
X	 * parsing back to the beginning of the same atom.  If the first number
X	 * is down to 0, decrement the second number instead and fake up
X	 * a ? after it.  Given the way this compiler doesn't keep track
X	 * of offsets on the first pass, this is the only way to replicate
X	 * a piece of code.  Sigh.
X	 */
X	if (op == '{' && regcurly(regparse)) {
X	    next = regparse + 1;
X	    max = Nullch;
X	    while (isdigit(*next) || *next == ',') {
X		if (*next == ',') {
X		    if (max)
X			break;
X		    else
X			max = next;
X		}
X		next++;
X	    }
X	    if (*next == '}') {		/* got one */
X		regsawbracket++;	/* remember we clobbered exp */
X		if (!max)
X		    max = next;
X		regparse++;
X		iter = atoi(regparse);
X		if (iter > 0) {
X		    ch = *max;
X		    sprintf(regparse,"%0*d", max-regparse, iter - 1);
X		    *max = ch;
X		    if (*max == ',' && atoi(max+1) > 0) {
X			ch = *next;
X			sprintf(max+1,"%0*d", next-(max+1), atoi(max+1) - 1);
X			*next = ch;
X		    }
X		    if (iter != 1 || (*max == ',' || atoi(max+1))) {
X			regparse = origparse;	/* back up input pointer */
X			regnpar = orignpar;	/* don't make more parens */
X		    }
X		    else {
X			regparse = next;
X			goto nest_check;
X		    }
X		    *flagp = flags;
X		    return ret;
X		}
X		if (*max == ',') {
X		    max++;
X		    iter = atoi(max);
X		    if (max == next) {		/* any number more? */
X			regparse = next;
X			op = '*';		/* fake up one with a star */
X		    }
X		    else if (iter > 0) {
X			op = '?';		/* fake up optional atom */
X			ch = *next;
X			sprintf(max,"%0*d", next-max, iter - 1);
X			*next = ch;
X			if (iter == 1)
X			    regparse = next;
X			else {
X			    regparse = origparse - 1; /* offset ++ below */
X			    regnpar = orignpar;
X			}
X		    }
X		    else
X			fatal("Can't do {n,0}");
X		}
X		else
X		    fatal("Can't do {0}");
X	    }
X	}
X
X	if (!ISMULT1(op)) {
X		*flagp = flags;
X		return(ret);
X	}
X
X	if (!(flags&HASWIDTH) && op != '?')
X		FAIL("regexp *+ operand could be empty");
X	*flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH);
X
X	if (op == '*' && (flags&SIMPLE))
X		reginsert(STAR, ret);
X	else if (op == '*') {
X		/* Emit x* as (x&|), where & means "self". */
X		reginsert(BRANCH, ret);			/* Either x */
X		regoptail(ret, regnode(BACK));		/* and loop */
X		regoptail(ret, ret);			/* back */
X		regtail(ret, regnode(BRANCH));		/* or */
X		regtail(ret, regnode(NOTHING));		/* null. */
X	} else if (op == '+' && (flags&SIMPLE))
X		reginsert(PLUS, ret);
X	else if (op == '+') {
X		/* Emit x+ as x(&|), where & means "self". */
X		next = regnode(BRANCH);			/* Either */
X		regtail(ret, next);
X		regtail(regnode(BACK), ret);		/* loop back */
X		regtail(next, regnode(BRANCH));		/* or */
X		regtail(ret, regnode(NOTHING));		/* null. */
X	} else if (op == '?') {
X		/* Emit x? as (x|) */
X		reginsert(BRANCH, ret);			/* Either x */
X		regtail(ret, regnode(BRANCH));		/* or */
X		next = regnode(NOTHING);		/* null. */
X		regtail(ret, next);
X		regoptail(ret, next);
X	}
X      nest_check:
X	regparse++;
X	if (ISMULT2(regparse))
X		FAIL("nested *?+ in regexp");
X
X	return(ret);
X}
X
X/*
X - regatom - the lowest level
X *
X * Optimization:  gobbles an entire sequence of ordinary characters so that
X * it can turn them into a single node, which is smaller to store and
X * faster to run.  Backslashed characters are exceptions, each becoming a
X * separate node; the code is simpler that way and it's not worth fixing.
X *
X * [Yes, it is worth fixing, some scripts can run twice the speed.]
X */
Xstatic char *
Xregatom(flagp)
Xint *flagp;
X{
X	register char *ret;
X	int flags;
X
X	*flagp = WORST;		/* Tentatively. */
X
X	switch (*regparse++) {
X	case '^':
X		ret = regnode(BOL);
X		break;
X	case '$':
X		ret = regnode(EOL);
X		break;
X	case '.':
X		ret = regnode(ANY);
X		*flagp |= HASWIDTH|SIMPLE;
X		break;
X	case '[':
X		ret = regclass();
X		*flagp |= HASWIDTH|SIMPLE;
X		break;
X	case '(':
X		ret = reg(1, &flags);
X		if (ret == NULL)
X			return(NULL);
X		*flagp |= flags&(HASWIDTH|SPSTART);
X		break;
X	case '|':
X	case ')':
X		FAIL("internal urp in regexp");	/* Supposed to be caught earlier. */
X		break;
X	case '?':
X	case '+':
X	case '*':
X		FAIL("?+* follows nothing in regexp");
X		break;
X	case '\\':
X		switch (*regparse) {
X		case 'w':
X			ret = regnode(ALNUM);
X			*flagp |= HASWIDTH|SIMPLE;
X			regparse++;
X			break;
X		case 'W':
X			ret = regnode(NALNUM);
X			*flagp |= HASWIDTH|SIMPLE;
X			regparse++;
X			break;
X		case 'b':
X			ret = regnode(BOUND);
X			*flagp |= SIMPLE;
X			regparse++;
X			break;
X		case 'B':
X			ret = regnode(NBOUND);
X			*flagp |= SIMPLE;
X			regparse++;
X			break;
X		case 's':
X			ret = regnode(SPACE);
X			*flagp |= HASWIDTH|SIMPLE;
X			regparse++;
X			break;
X		case 'S':
X			ret = regnode(NSPACE);
X			*flagp |= HASWIDTH|SIMPLE;
X			regparse++;
X			break;
X		case 'd':
X			ret = regnode(DIGIT);
X			*flagp |= HASWIDTH|SIMPLE;
X			regparse++;
X			break;
X		case 'D':
X			ret = regnode(NDIGIT);
X			*flagp |= HASWIDTH|SIMPLE;
X			regparse++;
X			break;
X		case 'n':
X		case 'r':
X		case 't':
X		case 'f':
X			goto defchar;
X		case '0': case '1': case '2': case '3': case '4':
X		case '5': case '6': case '7': case '8': case '9':
X			if (isdigit(regparse[1]))
X				goto defchar;
X			else {
X				ret = regnode(REF + *regparse++ - '0');
X				*flagp |= SIMPLE;
X			}
X			break;
X		case '\0':
X			if (regparse >= regxend)
X			    FAIL("trailing \\ in regexp");
X			/* FALL THROUGH */
X		default:
X			goto defchar;
X		}
X		break;
X	default: {
X			register int len;
X			register char ender;
X			register char *p;
X			char *oldp;
X			int foo;
X
X		    defchar:
X			ret = regnode(EXACTLY);
X			regc(0);		/* save spot for len */
X			for (len=0, p=regparse-1;
X			  len < 127 && p < regxend;
X			  len++)
X			{
X			    oldp = p;
X			    switch (*p) {
X			    case '^':
X			    case '$':
X			    case '.':
X			    case '[':
X			    case '(':
X			    case ')':
X			    case '|':
X				goto loopdone;
X			    case '\\':
X				switch (*++p) {
X				case 'w':
X				case 'W':
X				case 'b':
X				case 'B':
X				case 's':
X				case 'S':
X				case 'd':
X				case 'D':
X				    --p;
X				    goto loopdone;
X				case 'n':
X					ender = '\n';
X					p++;
X					break;
X				case 'r':
X					ender = '\r';
X					p++;
X					break;
X				case 't':
X					ender = '\t';
X					p++;
X					break;
X				case 'f':
X					ender = '\f';
X					p++;
X					break;
X				case '0': case '1': case '2': case '3':case '4':
X				case '5': case '6': case '7': case '8':case '9':
X				    if (isdigit(p[1])) {
X					foo = *p++ - '0';
X					foo <<= 3;
X					foo += *p - '0';
X					if (isdigit(p[1]))
X					    foo = (foo<<3) + *++p - '0';
X					ender = foo;
X					p++;
X				    }
X				    else {
X					--p;
X					goto loopdone;
X				    }
X				    break;
X				case '\0':
X				    if (p >= regxend)
X					FAIL("trailing \\ in regexp");
X				    /* FALL THROUGH */
X				default:
X				    ender = *p++;
X				    break;
X				}
X				break;
X			    default:
X				ender = *p++;
X				break;
X			    }
X			    if (regfold && isupper(ender))
X				    ender = tolower(ender);
X			    if (ISMULT2(p)) { /* Back off on ?+*. */
X				if (len)
X				    p = oldp;
X				else {
X				    len++;
X				    regc(ender);
X				}
X				break;
X			    }
X			    regc(ender);
X			}
X		    loopdone:
X			regparse = p;
X			if (len <= 0)
X				FAIL("internal disaster in regexp");
X			*flagp |= HASWIDTH;
X			if (len == 1)
X				*flagp |= SIMPLE;
X			if (regcode != &regdummy)
X			    *OPERAND(ret) = len;
X			regc('\0');
X		}
X		break;
X	}
X
X	return(ret);
X}
X
Xstatic void
Xregset(bits,def,c)
Xchar *bits;
Xint def;
Xregister int c;
X{
X	if (regcode == &regdummy)
X	    return;
X	if (def)
X		bits[c >> 3] &= ~(1 << (c & 7));
X	else
X		bits[c >> 3] |=  (1 << (c & 7));
X}
X
Xstatic char *
Xregclass()
X{
X	register char *bits;
X	register int class;
X	register int lastclass;
X	register int range = 0;
X	register char *ret;
X	register int def;
X
X	if (*regparse == '^') {	/* Complement of range. */
X		ret = regnode(ANYBUT);
X		regparse++;
X		def = 0;
X	} else {
X		ret = regnode(ANYOF);
X		def = 255;
X	}
X	bits = regcode;
X	for (class = 0; class < 32; class++)
X	    regc(def);
X	if (*regparse == ']' || *regparse == '-')
X		regset(bits,def,lastclass = *regparse++);
X	while (regparse < regxend && *regparse != ']') {
X		class = UCHARAT(regparse++);
X		if (class == '\\') {
X			class = UCHARAT(regparse++);
X			switch (class) {
X			case 'w':
X				for (class = 'a'; class <= 'z'; class++)
X					regset(bits,def,class);
X				for (class = 'A'; class <= 'Z'; class++)
X					regset(bits,def,class);
X				for (class = '0'; class <= '9'; class++)
X					regset(bits,def,class);
X				regset(bits,def,'_');
X				lastclass = 1234;
X				continue;
X			case 's':
X				regset(bits,def,' ');
X				regset(bits,def,'\t');
X				regset(bits,def,'\r');
X				regset(bits,def,'\f');
X				regset(bits,def,'\n');
X				lastclass = 1234;
X				continue;
X			case 'd':
X				for (class = '0'; class <= '9'; class++)
X					regset(bits,def,class);
X				lastclass = 1234;
X				continue;
X			case 'n':
X				class = '\n';
X				break;
X			case 'r':
X				class = '\r';
X				break;
X			case 't':
X				class = '\t';
X				break;
X			case 'f':
X				class = '\f';
X				break;
X			case 'b':
X				class = '\b';
X				break;
X			case '0': case '1': case '2': case '3': case '4':
X			case '5': case '6': case '7': case '8': case '9':
X				class -= '0';
X				if (isdigit(*regparse)) {
X					class <<= 3;
X					class += *regparse++ - '0';
X				}
X				if (isdigit(*regparse)) {
X					class <<= 3;
X					class += *regparse++ - '0';
X				}
X				break;
X			}
X		}
X		if (!range && class == '-' && regparse < regxend &&
X		    *regparse != ']') {
X			range = 1;
X			continue;
X		}
X		if (range) {
X			if (lastclass > class)
X				FAIL("invalid [] range in regexp");
X		}
X		else
X			lastclass = class - 1;
X		range = 0;
X		for (lastclass++; lastclass <= class; lastclass++) {
X			regset(bits,def,lastclass);
X			if (regfold && isupper(lastclass))
X				regset(bits,def,tolower(lastclass));
X		}
X		lastclass = class;
X	}
X	if (*regparse != ']')
X		FAIL("unmatched [] in regexp");
X	regset(bits,0,0);		/* always bomb out on null */
X	regparse++;
X	return ret;
X}
X
X/*
X - regnode - emit a node
X */
Xstatic char *			/* Location. */
Xregnode(op)
Xchar op;
X{
X	register char *ret;
X	register char *ptr;
X
X	ret = regcode;
X	if (ret == &regdummy) {
X#ifdef REGALIGN
X		if (!(regsize & 1))
X			regsize++;
X#endif
X		regsize += 3;
X		return(ret);
X	}
X
X#ifdef REGALIGN
X#ifndef lint
X	if (!((long)ret & 1))
X	    *ret++ = 127;
X#endif
X#endif
X	ptr = ret;
X	*ptr++ = op;
X	*ptr++ = '\0';		/* Null "next" pointer. */
X	*ptr++ = '\0';
X	regcode = ptr;
X
X	return(ret);
X}
X
X/*
X - regc - emit (if appropriate) a byte of code
X */
Xstatic void
Xregc(b)
Xchar b;
X{
X	if (regcode != &regdummy)
X		*regcode++ = b;
X	else
X		regsize++;
X}
X
X/*
X - reginsert - insert an operator in front of already-emitted operand
X *
X * Means relocating the operand.
X */
Xstatic void
Xreginsert(op, opnd)
Xchar op;
Xchar *opnd;
X{
X	register char *src;
X	register char *dst;
X	register char *place;
X
X	if (regcode == &regdummy) {
X#ifdef REGALIGN
X		regsize += 4;
X#else
X		regsize += 3;
X#endif
X		return;
X	}
X
X	src = regcode;
X#ifdef REGALIGN
X	regcode += 4;
X#else
X	regcode += 3;
X#endif
X	dst = regcode;
X	while (src > opnd)
X		*--dst = *--src;
X
X	place = opnd;		/* Op node, where operand used to be. */
X	*place++ = op;
X	*place++ = '\0';
X	*place++ = '\0';
X}
X
X/*
X - regtail - set the next-pointer at the end of a node chain
X */
Xstatic void
Xregtail(p, val)
Xchar *p;
Xchar *val;
X{
X	register char *scan;
X	register char *temp;
X	register int offset;
X
X	if (p == &regdummy)
X		return;
X
X	/* Find last node. */
X	scan = p;
X	for (;;) {
X		temp = regnext(scan);
X		if (temp == NULL)
X			break;
X		scan = temp;
X	}
X
X#ifdef REGALIGN
X	offset = val - scan;
X#ifndef lint
X	*(short*)(scan+1) = offset;
X#else
X	offset = offset;
X#endif
X#else
X	if (OP(scan) == BACK)
X		offset = scan - val;
X	else
X		offset = val - scan;
X	*(scan+1) = (offset>>8)&0377;
X	*(scan+2) = offset&0377;
X#endif
X}
X
X/*
X - regoptail - regtail on operand of first argument; nop if operandless
X */
Xstatic void
Xregoptail(p, val)
Xchar *p;
Xchar *val;
X{
X	/* "Operandless" and "op != BRANCH" are synonymous in practice. */
X	if (p == NULL || p == &regdummy || OP(p) != BRANCH)
X		return;
X	regtail(NEXTOPER(p), val);
X}
X
X/*
X - regcurly - a little FSA that accepts {\d+,?\d*}
X */
XSTATIC int
Xregcurly(s)
Xregister char *s;
X{
X    if (*s++ != '{')
X	return FALSE;
X    if (!isdigit(*s))
X	return FALSE;
X    while (isdigit(*s))
X	s++;
X    if (*s == ',')
X	s++;
X    while (isdigit(*s))
X	s++;
X    if (*s != '}')
X	return FALSE;
X    return TRUE;
X}
X
X#ifdef DEBUGGING
X
X/*
X - regdump - dump a regexp onto stdout in vaguely comprehensible form
X */
Xvoid
Xregdump(r)
Xregexp *r;
X{
X	register char *s;
X	register char op = EXACTLY;	/* Arbitrary non-END op. */
X	register char *next;
X	extern char *index();
X
X
X	s = r->program + 1;
X	while (op != END) {	/* While that wasn't END last time... */
X#ifdef REGALIGN
X		if (!((long)s & 1))
X			s++;
X#endif
X		op = OP(s);
X		printf("%2d%s", s-r->program, regprop(s));	/* Where, what. */
X		next = regnext(s);
X		if (next == NULL)		/* Next ptr. */
X			printf("(0)");
X		else 
X			printf("(%d)", (s-r->program)+(next-s));
X		s += 3;
X		if (op == ANYOF || op == ANYBUT) {
X			s += 32;
X		}
X		if (op == EXACTLY) {
X			/* Literal string, where present. */
X			s++;
X			while (*s != '\0') {
X				(void)putchar(*s);
X				s++;
X			}
X			s++;
X		}
X		(void)putchar('\n');
X	}
X
X	/* Header fields of interest. */
X	if (r->regstart)
X		printf("start `%s' ", r->regstart->str_ptr);
X	if (r->regstclass)
X		printf("stclass `%s' ", regprop(r->regstclass));
X	if (r->reganch)
X		printf("anchored ");
X	if (r->regmust != NULL)
X		printf("must have \"%s\" back %d ", r->regmust->str_ptr,
X		  r->regback);
X	printf("\n");
X}
X
X/*
X - regprop - printable representation of opcode
X */
Xchar *
Xregprop(op)
Xchar *op;
X{
X	register char *p;
X
X	(void) strcpy(buf, ":");
X
X	switch (OP(op)) {
X	case BOL:
X		p = "BOL";
X		break;
X	case EOL:
X		p = "EOL";
X		break;
X	case ANY:
X		p = "ANY";
X		break;
X	case ANYOF:
X		p = "ANYOF";
X		break;
X	case ANYBUT:
X		p = "ANYBUT";
X		break;
X	case BRANCH:
X		p = "BRANCH";
X		break;
X	case EXACTLY:
X		p = "EXACTLY";
X		break;
X	case NOTHING:
X		p = "NOTHING";
X		break;
X	case BACK:
X		p = "BACK";
X		break;
X	case END:
X		p = "END";
X		break;
X	case ALNUM:
X		p = "ALNUM";
X		break;
X	case NALNUM:
X		p = "NALNUM";
X		break;
X	case BOUND:
X		p = "BOUND";
X		break;
X	case NBOUND:
X		p = "NBOUND";
X		break;
X	case SPACE:
X		p = "SPACE";
X		break;
X	case NSPACE:
X		p = "NSPACE";
X		break;
X	case DIGIT:
X		p = "DIGIT";
X		break;
X	case NDIGIT:
X		p = "NDIGIT";
X		break;
X	case REF:
X	case REF+1:
X	case REF+2:
X	case REF+3:
X	case REF+4:
X	case REF+5:
X	case REF+6:
X	case REF+7:
X	case REF+8:
X	case REF+9:
X		(void)sprintf(buf+strlen(buf), "REF%d", OP(op)-REF);
X		p = NULL;
X		break;
X	case OPEN+1:
X	case OPEN+2:
X	case OPEN+3:
X	case OPEN+4:
X	case OPEN+5:
X	case OPEN+6:
X	case OPEN+7:
X	case OPEN+8:
X	case OPEN+9:
X		(void)sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN);
X		p = NULL;
X		break;
X	case CLOSE+1:
X	case CLOSE+2:
X	case CLOSE+3:
X	case CLOSE+4:
X	case CLOSE+5:
X	case CLOSE+6:
X	case CLOSE+7:
X	case CLOSE+8:
X	case CLOSE+9:
X		(void)sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE);
X		p = NULL;
X		break;
X	case STAR:
X		p = "STAR";
X		break;
X	case PLUS:
X		p = "PLUS";
X		break;
X	default:
X		FAIL("corrupted regexp opcode");
X	}
X	if (p != NULL)
X		(void) strcat(buf, p);
X	return(buf);
X}
X#endif /* DEBUGGING */
X
Xregfree(r)
Xstruct regexp *r;
X{
X	if (r->precomp)
X		Safefree(r->precomp);
X	if (r->subbase)
X		Safefree(r->subbase);
X	if (r->regmust)
X		str_free(r->regmust);
X	if (r->regstart)
X		str_free(r->regstart);
X	Safefree(r);
X}
!STUFFY!FUNK!
echo Extracting Copying
sed >Copying <<'!STUFFY!FUNK!' -e 's/X//'
X		    GNU GENERAL PUBLIC LICENSE
X		     Version 1, February 1989
X
X Copyright (C) 1989 Free Software Foundation, Inc.
X                    675 Mass Ave, Cambridge, MA 02139, USA
X Everyone is permitted to copy and distribute verbatim copies
X of this license document, but changing it is not allowed.
X
X			    Preamble
X
X  The license agreements of most software companies try to keep users
Xat the mercy of those companies.  By contrast, our General Public
XLicense is intended to guarantee your freedom to share and change free
Xsoftware--to make sure the software is free for all its users.  The
XGeneral Public License applies to the Free Software Foundation's
Xsoftware and to any other program whose authors commit to using it.
XYou can use it for your programs, too.
X
X  When we speak of free software, we are referring to freedom, not
Xprice.  Specifically, the General Public License is designed to make
Xsure that you have the freedom to give away or sell copies of free
Xsoftware, that you receive source code or can get it if you want it,
Xthat you can change the software or use pieces of it in new free
Xprograms; and that you know you can do these things.
X
X  To protect your rights, we need to make restrictions that forbid
Xanyone to deny you these rights or to ask you to surrender the rights.
XThese restrictions translate to certain responsibilities for you if you
Xdistribute copies of the software, or if you modify it.
X
X  For example, if you distribute copies of a such a program, whether
Xgratis or for a fee, you must give the recipients all the rights that
Xyou have.  You must make sure that they, too, receive or can get the
Xsource code.  And you must tell them their rights.
X
X  We protect your rights with two steps: (1) copyright the software, and
X(2) offer you this license which gives you legal permission to copy,
Xdistribute and/or modify the software.
X
X  Also, for each author's protection and ours, we want to make certain
Xthat everyone understands that there is no warranty for this free
Xsoftware.  If the software is modified by someone else and passed on, we
Xwant its recipients to know that what they have is not the original, so
Xthat any problems introduced by others will not reflect on the original
Xauthors' reputations.
X
X  The precise terms and conditions for copying, distribution and
Xmodification follow.
X
X		    GNU GENERAL PUBLIC LICENSE
X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
X
X  0. This License Agreement applies to any program or other work which
Xcontains a notice placed by the copyright holder saying it may be
Xdistributed under the terms of this General Public License.  The
X"Program", below, refers to any such program or work, and a "work based
Xon the Program" means either the Program or any work containing the
XProgram or a portion of it, either verbatim or with modifications.  Each
Xlicensee is addressed as "you".
X
X  1. You may copy and distribute verbatim copies of the Program's source
Xcode as you receive it, in any medium, provided that you conspicuously and
Xappropriately publish on each copy an appropriate copyright notice and
Xdisclaimer of warranty; keep intact all the notices that refer to this
XGeneral Public License and to the absence of any warranty; and give any
Xother recipients of the Program a copy of this General Public License
Xalong with the Program.  You may charge a fee for the physical act of
Xtransferring a copy.
X
X  2. You may modify your copy or copies of the Program or any portion of
Xit, and copy and distribute such modifications under the terms of Paragraph
X1 above, provided that you also do the following:
X
X    a) cause the modified files to carry prominent notices stating that
X    you changed the files and the date of any change; and
X
X    b) cause the whole of any work that you distribute or publish, that
X    in whole or in part contains the Program or any part thereof, either
X    with or without modifications, to be licensed at no charge to all
X    third parties under the terms of this General Public License (except
X    that you may choose to grant warranty protection to some or all
X    third parties, at your option).
X
X    c) If the modified program normally reads commands interactively when
X    run, you must cause it, when started running for such interactive use
X    in the simplest and most usual way, to print or display an
X    announcement including an appropriate copyright notice and a notice
X    that there is no warranty (or else, saying that you provide a
X    warranty) and that users may redistribute the program under these
X    conditions, and telling the user how to view a copy of this General
X    Public License.
X
X    d) You may charge a fee for the physical act of transferring a
X    copy, and you may at your option offer warranty protection in
X    exchange for a fee.
X
XMere aggregation of another independent work with the Program (or its
Xderivative) on a volume of a storage or distribution medium does not bring
Xthe other work under the scope of these terms.
X
X  3. You may copy and distribute the Program (or a portion or derivative of
Xit, under Paragraph 2) in object code or executable form under the terms of
XParagraphs 1 and 2 above provided that you also do one of the following:
X
X    a) accompany it with the complete corresponding machine-readable
X    source code, which must be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    b) accompany it with a written offer, valid for at least three
X    years, to give any third party free (except for a nominal charge
X    for the cost of distribution) a complete machine-readable copy of the
X    corresponding source code, to be distributed under the terms of
X    Paragraphs 1 and 2 above; or,
X
X    c) accompany it with the information you received as to where the
X    corresponding source code may be obtained.  (This alternative is
X    allowed only for noncommercial distribution and only if you
X    received the program in object code or executable form alone.)
X
XSource code for a work means the preferred form of the work for making
Xmodifications to it.  For an executable file, complete source code means
Xall the source code for all modules it contains; but, as a special
Xexception, it need not include source code for modules which are standard
Xlibraries that accompany the operating system on which the executable
Xfile runs, or for standard header files or definitions files that
Xaccompany that operating system.
X
X  4. You may not copy, modify, sublicense, distribute or transfer the
XProgram except as expressly provided under this General Public License.
XAny attempt otherwise to copy, modify, sublicense, distribute or transfer
Xthe Program is void, and will automatically terminate your rights to use
Xthe Program under this License.  However, parties who have received
Xcopies, or rights to use copies, from you under this General Public
XLicense will not have their licenses terminated so long as such parties
Xremain in full compliance.
X
X  5. By copying, distributing or modifying the Program (or any work based
Xon the Program) you indicate your acceptance of this license to do so,
Xand all its terms and conditions.
X
X  6. Each time you redistribute the Program (or any work based on the
XProgram), the recipient automatically receives a license from the original
Xlicensor to copy, distribute or modify the Program subject to these
Xterms and conditions.  You may not impose any further restrictions on the
Xrecipients' exercise of the rights granted herein.
X
X  7. The Free Software Foundation may publish revised and/or new versions
Xof the General Public License from time to time.  Such new versions will
Xbe similar in spirit to the present version, but may differ in detail to
Xaddress new problems or concerns.
X
XEach version is given a distinguishing version number.  If the Program
Xspecifies a version number of the license which applies to it and "any
Xlater version", you have the option of following the terms and conditions
Xeither of that version or of any later version published by the Free
XSoftware Foundation.  If the Program does not specify a version number of
Xthe license, you may choose any version ever published by the Free Software
XFoundation.
X
X  8. If you wish to incorporate parts of the Program into other free
Xprograms whose distribution conditions are different, write to the author
Xto ask for permission.  For software which is copyrighted by the Free
XSoftware Foundation, write to the Free Software Foundation; we sometimes
Xmake exceptions for this.  Our decision will be guided by the two goals
Xof preserving the free status of all derivatives of our free software and
Xof promoting the sharing and reuse of software generally.
X
X			    NO WARRANTY
X
X  9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
XREPAIR OR CORRECTION.
X
X  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
XPOSSIBILITY OF SUCH DAMAGES.
X
X		     END OF TERMS AND CONDITIONS
X
X	Appendix: How to Apply These Terms to Your New Programs
X
X  If you develop a new program, and you want it to be of the greatest
Xpossible use to humanity, the best way to achieve this is to make it
Xfree software which everyone can redistribute and change under these
Xterms.
X
X  To do so, attach the following notices to the program.  It is safest to
Xattach them to the start of each source file to most effectively convey
Xthe exclusion of warranty; and each file should have at least the
X"copyright" line and a pointer to where the full notice is found.
X
X    <one line to give the program's name and a brief idea of what it does.>
X    Copyright (C) 19yy  <name of author>
X
X    This program is free software; you can redistribute it and/or modify
X    it under the terms of the GNU General Public License as published by
X    the Free Software Foundation; either version 1, or (at your option)
X    any later version.
X
X    This program is distributed in the hope that it will be useful,
X    but WITHOUT ANY WARRANTY; without even the implied warranty of
X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
X    GNU General Public License for more details.
X
X    You should have received a copy of the GNU General Public License
X    along with this program; if not, write to the Free Software
X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
X
XAlso add information on how to contact you by electronic and paper mail.
X
XIf the program is interactive, make it output a short notice like this
Xwhen it starts in an interactive mode:
X
X    Gnomovision version 69, Copyright (C) 19xx name of author
X    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
X    This is free software, and you are welcome to redistribute it
X    under certain conditions; type `show c' for details.
X
XThe hypothetical commands `show w' and `show c' should show the
Xappropriate parts of the General Public License.  Of course, the
Xcommands you use may be called something other than `show w' and `show
Xc'; they could even be mouse-clicks or menu items--whatever suits your
Xprogram.
X
XYou should also get your employer (if you work as a programmer) or your
Xschool, if any, to sign a "copyright disclaimer" for the program, if
Xnecessary.  Here a sample; alter the names:
X
X  Yoyodyne, Inc., hereby disclaims all copyright interest in the
X  program `Gnomovision' (a program to direct compilers to make passes
X  at assemblers) written by James Hacker.
X
X  <signature of Ty Coon>, 1 April 1989
X  Ty Coon, President of Vice
X
XThat's all there is to it!
!STUFFY!FUNK!
echo Extracting evalargs.xc
sed >evalargs.xc <<'!STUFFY!FUNK!' -e 's/X//'
X/* This file is included by eval.c.  It's separate from eval.c to keep
X * kit sizes from getting too big.
X */
X
X/* $Header$
X *
X * $Log$
X */
X
X    for (anum = 1; anum <= maxarg; anum++) {
X	argflags = arg[anum].arg_flags;
X	argtype = arg[anum].arg_type;
X	argptr = arg[anum].arg_ptr;
X      re_eval:
X	switch (argtype) {
X	default:
X	    st[++sp] = &str_undef;
X#ifdef DEBUGGING
X	    tmps = "NULL";
X#endif
X	    break;
X	case A_EXPR:
X#ifdef DEBUGGING
X	    if (debug & 8) {
X		tmps = "EXPR";
X		deb("%d.EXPR =>\n",anum);
X	    }
X#endif
X	    sp = eval(argptr.arg_arg,
X		(argflags & AF_ARYOK) ? G_ARRAY : G_SCALAR, sp);
X	    st = stack->ary_array;	/* possibly reallocated */
X	    break;
X	case A_CMD:
X#ifdef DEBUGGING
X	    if (debug & 8) {
X		tmps = "CMD";
X		deb("%d.CMD (%lx) =>\n",anum,argptr.arg_cmd);
X	    }
X#endif
X	    sp = cmd_exec(argptr.arg_cmd, gimme, sp);
X	    st = stack->ary_array;	/* possibly reallocated */
X	    break;
X	case A_LARYSTAB:
X	    ++sp;
X	    str = afetch(stab_array(argptr.arg_stab),
X		arg[anum].arg_len - arybase, TRUE);
X#ifdef DEBUGGING
X	    if (debug & 8) {
X		(void)sprintf(buf,"LARYSTAB $%s[%d]",stab_name(argptr.arg_stab),
X		    arg[anum].arg_len);
X		tmps = buf;
X	    }
X#endif
X	    goto do_crement;
X	case A_ARYSTAB:
X	    st[++sp] = afetch(stab_array(argptr.arg_stab),
X		arg[anum].arg_len - arybase, FALSE);
X	    if (!st[sp])
X		st[sp] = &str_undef;
X#ifdef DEBUGGING
X	    if (debug & 8) {
X		(void)sprintf(buf,"ARYSTAB $%s[%d]",stab_name(argptr.arg_stab),
X		    arg[anum].arg_len);
X		tmps = buf;
X	    }
X#endif
X	    break;
X	case A_STAR:
X	    st[++sp] = (STR*)argptr.arg_stab;
X#ifdef DEBUGGING
X	    if (debug & 8) {
X		(void)sprintf(buf,"STAR *%s",stab_name(argptr.arg_stab));
X		tmps = buf;
X	    }
X#endif
X	    break;
X	case A_LSTAR:
X	    str = st[++sp] = (STR*)argptr.arg_stab;
X#ifdef DEBUGGING
X	    if (debug & 8) {
X		(void)sprintf(buf,"LSTAR *%s",stab_name(argptr.arg_stab));
X		tmps = buf;
X	    }
X#endif
X	    break;
X	case A_STAB:
X	    st[++sp] = STAB_STR(argptr.arg_stab);
X#ifdef DEBUGGING
X	    if (debug & 8) {
X		(void)sprintf(buf,"STAB $%s",stab_name(argptr.arg_stab));
X		tmps = buf;
X	    }
X#endif
X	    break;
X	case A_LEXPR:
X#ifdef DEBUGGING
X	    if (debug & 8) {
X		tmps = "LEXPR";
X		deb("%d.LEXPR =>\n",anum);
X	    }
X#endif
X	    if (argflags & AF_ARYOK) {
X		sp = eval(argptr.arg_arg, G_ARRAY, sp);
X		st = stack->ary_array;	/* possibly reallocated */
X	    }
X	    else {
X		sp = eval(argptr.arg_arg, G_SCALAR, sp);
X		st = stack->ary_array;	/* possibly reallocated */
X		str = st[sp];
X		goto do_crement;
X	    }
X	    break;
X	case A_LVAL:
X#ifdef DEBUGGING
X	    if (debug & 8) {
X		(void)sprintf(buf,"LVAL $%s",stab_name(argptr.arg_stab));
X		tmps = buf;
X	    }
X#endif
X	    ++sp;
X	    str = STAB_STR(argptr.arg_stab);
X	    if (!str)
X		fatal("panic: A_LVAL");
X	  do_crement:
X	    assigning = TRUE;
X	    if (argflags & AF_PRE) {
X		if (argflags & AF_UP)
X		    str_inc(str);
X		else
X		    str_dec(str);
X		STABSET(str);
X		st[sp] = str;
X		str = arg->arg_ptr.arg_str;
X	    }
X	    else if (argflags & AF_POST) {
X		st[sp] = str_static(str);
X		if (argflags & AF_UP)
X		    str_inc(str);
X		else
X		    str_dec(str);
X		STABSET(str);
X		str = arg->arg_ptr.arg_str;
X	    }
X	    else
X		st[sp] = str;
X	    break;
X	case A_LARYLEN:
X	    ++sp;
X	    stab = argptr.arg_stab;
X	    str = stab_array(argptr.arg_stab)->ary_magic;
X	    if (argflags & (AF_PRE|AF_POST))
X		str_numset(str,(double)(stab_array(stab)->ary_fill+arybase));
X#ifdef DEBUGGING
X	    tmps = "LARYLEN";
X#endif
X	    if (!str)
X		fatal("panic: A_LEXPR");
X	    goto do_crement;
X	case A_ARYLEN:
X	    stab = argptr.arg_stab;
X	    st[++sp] = stab_array(stab)->ary_magic;
X	    str_numset(st[sp],(double)(stab_array(stab)->ary_fill+arybase));
X#ifdef DEBUGGING
X	    tmps = "ARYLEN";
X#endif
X	    break;
X	case A_SINGLE:
X	    st[++sp] = argptr.arg_str;
X#ifdef DEBUGGING
X	    tmps = "SINGLE";
X#endif
X	    break;
X	case A_DOUBLE:
X	    (void) interp(str,argptr.arg_str,sp);
X	    st = stack->ary_array;
X	    st[++sp] = str;
X#ifdef DEBUGGING
X	    tmps = "DOUBLE";
X#endif
X	    break;
X	case A_BACKTICK:
X	    tmps = str_get(interp(str,argptr.arg_str,sp));
X	    st = stack->ary_array;
X#ifdef TAINT
X	    taintproper("Insecure dependency in ``");
X#endif
X	    fp = mypopen(tmps,"r");
X	    str_set(str,"");
X	    if (fp) {
X		while (str_gets(str,fp,str->str_cur) != Nullch)
X		    ;
X		statusvalue = mypclose(fp);
X	    }
X	    else
X		statusvalue = -1;
X
X	    st[++sp] = str;
X#ifdef DEBUGGING
X	    tmps = "BACK";
X#endif
X	    break;
X	case A_INDREAD:
X	    last_in_stab = stabent(str_get(STAB_STR(argptr.arg_stab)),TRUE);
X	    old_record_separator = record_separator;
X	    goto do_read;
X	case A_GLOB:
X	    argflags |= AF_POST;	/* enable newline chopping */
X	    last_in_stab = argptr.arg_stab;
X	    old_record_separator = record_separator;
X	    if (csh > 0)
X		record_separator = 0;
X	    else
X		record_separator = '\n';
X	    goto do_read;
X	case A_READ:
X	    last_in_stab = argptr.arg_stab;
X	    old_record_separator = record_separator;
X	  do_read:
X	    ++sp;
X	    fp = Nullfp;
X	    if (stab_io(last_in_stab)) {
X		fp = stab_io(last_in_stab)->ifp;
X		if (!fp) {
X		    if (stab_io(last_in_stab)->flags & IOF_ARGV) {
X			if (stab_io(last_in_stab)->flags & IOF_START) {
X			    stab_io(last_in_stab)->flags &= ~IOF_START;
X			    stab_io(last_in_stab)->lines = 0;
X			    if (alen(stab_array(last_in_stab)) < 0) {
X				tmpstr = str_make("-",1); /* assume stdin */
X				(void)apush(stab_array(last_in_stab), tmpstr);
X			    }
X			}
X			fp = nextargv(last_in_stab);
X			if (!fp)  /* Note: fp != stab_io(last_in_stab)->ifp */
X			    (void)do_close(last_in_stab,FALSE); /* now it does*/
X		    }
X		    else if (argtype == A_GLOB) {
X			(void) interp(str,stab_val(last_in_stab),sp);
X			st = stack->ary_array;
X			tmpstr = str_new(0);
X			if (csh > 0) {
X			    str_set(tmpstr,"/bin/csh -cf 'set nonomatch; glob ");
X			    str_scat(tmpstr,str);
X			    str_cat(tmpstr,"'|");
X			}
X			else {
X			    str_set(tmpstr, "echo ");
X			    str_scat(tmpstr,str);
X			    str_cat(tmpstr,
X			      "|tr -s ' \t\f\r' '\\012\\012\\012\\012'|");
X			}
X			(void)do_open(last_in_stab,tmpstr->str_ptr);
X			fp = stab_io(last_in_stab)->ifp;
X		    }
X		}
X	    }
X	    if (!fp && dowarn)
X		warn("Read on closed filehandle <%s>",stab_name(last_in_stab));
X	  keepgoing:
X	    if (!fp)
X		st[sp] = &str_undef;
X	    else if (!str_gets(str,fp, optype == O_RCAT ? str->str_cur : 0)) {
X		clearerr(fp);
X		if (stab_io(last_in_stab)->flags & IOF_ARGV) {
X		    fp = nextargv(last_in_stab);
X		    if (fp)
X			goto keepgoing;
X		    (void)do_close(last_in_stab,FALSE);
X		    stab_io(last_in_stab)->flags |= IOF_START;
X		}
X		else if (argflags & AF_POST) {
X		    (void)do_close(last_in_stab,FALSE);
X		}
X		st[sp] = &str_undef;
X		record_separator = old_record_separator;
X		if (gimme == G_ARRAY) {
X		    --sp;
X		    goto array_return;
X		}
X		break;
X	    }
X	    else {
X		stab_io(last_in_stab)->lines++;
X		st[sp] = str;
X#ifdef TAINT
X		str->str_tainted = 1; /* Anything from the outside world...*/
X#endif
X		if (argflags & AF_POST) {
X		    if (str->str_cur > 0)
X			str->str_cur--;
X		    if (str->str_ptr[str->str_cur] == record_separator)
X			str->str_ptr[str->str_cur] = '\0';
X		    else
X			str->str_cur++;
X		    for (tmps = str->str_ptr; *tmps; tmps++)
X			if (!isalpha(*tmps) && !isdigit(*tmps) &&
X			    index("$&*(){}[]'\";\\|?<>~`",*tmps))
X				break;
X		    if (*tmps && stat(str->str_ptr,&statbuf) < 0)
X			goto keepgoing;		/* unmatched wildcard? */
X		}
X		if (gimme == G_ARRAY) {
X		    st[sp] = str_static(st[sp]);
X		    if (++sp > stack->ary_max) {
X			astore(stack, sp, Nullstr);
X			st = stack->ary_array;
X		    }
X		    goto keepgoing;
X		}
X	    }
X	    record_separator = old_record_separator;
X#ifdef DEBUGGING
X	    tmps = "READ";
X#endif
X	    break;
X	}
X#ifdef DEBUGGING
X	if (debug & 8)
X	    deb("%d.%s = '%s'\n",anum,tmps,str_peek(st[sp]));
X#endif
X	if (anum < 8)
X	    arglast[anum] = sp;
X    }
!STUFFY!FUNK!
echo ""
echo "End of kit 12 (of 23)"
cat /dev/null >kit12isdone
run=''
config=''
for iskit in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23; do
    if test -f kit${iskit}isdone; then
	run="$run $iskit"
    else
	todo="$todo $iskit"
    fi
done
case $todo in
    '')
	echo "You have run all your kits.  Please read README and then type Configure."
	chmod 755 Configure
	;;
    *)  echo "You have run$run."
	echo "You still need to run$todo."
	;;
esac
: Someone might mail this, so...
exit



More information about the Alt.sources mailing list