# To unbundle, sh this file
echo mkbun 1>&2
sed 's/.//' >mkbun <<'//GO.SYSIN DD mkbun'
-bundle mkbun Makefile *.h *.c qed.1
//GO.SYSIN DD mkbun
echo Makefile 1>&2
sed 's/.//' >Makefile <<'//GO.SYSIN DD Makefile'
-
-FILES=\
-	address.o blkio.o com.o getchar.o getfile.o glob.o main.o \
-	misc.o move.o pattern.o putchar.o setaddr.o string.o subs.o
-
-SRCS=   address.c blkio.c com.c getchar.c getfile.c glob.c main.c \
-	misc.c move.c pattern.c putchar.c setaddr.c string.c subs.c
-
-qed: $(FILES)
-	$(CC) -o qed $(FILES)
-
-$(FILES): vars.h
-
-lint: $(SRCS)
-	lint -s -fd -errchk=%all -Ncheck=%all -Nlevel=3 $(SRCS)
-
-clean:
-	rm -rf $(FILES)
//GO.SYSIN DD Makefile
echo vars.h 1>&2
sed 's/.//' >vars.h <<'//GO.SYSIN DD vars.h'
-/*
- * general definitions for qed
- */
-
-#define	TRUE	1
-#define FALSE	0
-
-#define	LBSIZE	1024		/* max line size */
-#define	BLKSIZE	4096		/* IO buffer block size */
-#define RHSIZE	(LBSIZE/4)	/* ed says /2; but that's unreasonable! */
-#define	NBRA	9
-
-#define	EOF	(-1)
-#define	FILERR	0200	/* print filename on error */
-
-/*
- * save filename in e or r?  arg to newfile
- */
-#define	SAVENEVER	0
-#define	SAVEIFFIRST	1
-#define	SAVEALWAYS	2
-
-/*
- * Stack types.  Must appear in the order as in cspec[]/getchar.
- * XTTY, GLOB and BRWS are special types with no corresponding special 
-character.
- * Special is never used directly - it is just used in tracing
- *	pushinp()/getchar.c can be called with a negative index for cspec[]
- */
-/*
- * bug: special[] is used only in getchar.c,
- * but the values that are offsets into it are used in a few other files
- */
-#define	cspec	(special + 3)
-#define	XTTY		0175
-#define	GLOB		0176
-#define	BRWS		0177
-#define	BUF		0
-#define	CURBN		1
-#define	QUOTE		2
-#define	FILEN		3
-#define	BFILEN		4
-#define	TTY		5
-#define	PAT		6
-#define	RHS		7
-#define	STRING		8
-#define	NEWL		9
-#define	NOTHING		10
-#define	BACKSLASH	11
-#define	LITERAL		12
-
-/*
- * Getchar-linked macros
- */
-#define ungetchar(c)	(peekc = (c))
-#define nextchar()	(peekc = getchar())
-
-/*
- * Magic cookie for a line
- */
-typedef struct Line {
-	unsigned int glob:1;
-	int offset:31;
-} Line;
-
-/*
- * The buffer structure.  All info associated with each buffer stored here
- */
-#define	NBUFS	56
-#define	PREVBUF	NBUFS	/* : */
-#define	NEWBUF	NBUFS+1	/* @ */
-struct buffer{
-	Line *zero;
-	Line *dot;
-	Line *dol;
-	char cflag;
-	char gmark;
-};
-
-extern struct buffer buffer[NBUFS];
-extern struct buffer *curbuf;
-
-/*
- * The string structure
- * The first NBUFS strings are the registers
- * The next NBUFS are the file names
- * The next two are the saved pattern and saved right hand side
- * The next is the special register for browsing (the `ob' command)
- * The next is a file buffer.
- * Strings are stored in the `strarea' area and garbage collected
- * when the area is full.  The NSTRCHARS parameter can be increased
- * if you've got lots of core.
- * The first two characters of `strarea' form the null string.
- * The third and subsequent characters are the storage for non null
- * strings.
- * The null string has to be stored in this area so that
- * the R and S commands write out valid pointers to the null string.
- * The last entry in the string structure is used to store the pointer
- * to the next free position.
- * In string.c strfree is defined as "string[NSTRING].str".
- */
-#define	NSTRING	(NBUFS+NBUFS+4)
-struct string{
-	int len;
-	char *str;
-};
-
-extern struct string string[NSTRING+1];
-
-/*
- * registers with special internal meaning
- */
-#define	COUNT	(26+'C'-'A')
-#define	TRUTH	(26+'T'-'A')
-#define	UNIX	(26+'U'-'A')
-#define	FILE(z)	(NBUFS+(z))
-#define	SAVPAT	(NBUFS+NBUFS)
-#define	SAVRHS	(SAVPAT+1)
-#define	BROWSE	(SAVRHS+1)
-#define	FILEBUF	(BROWSE+1)
-
-#define NSTRCHARS 4096
-extern char strarea[NSTRCHARS + 2];
-#define	nullstr strarea
-#define	strchars (&strarea[2])
-
-/*
- * The getchar stack.
- */
-#define STACKSIZE 16
-struct stack{
-	char type;
-	char literal;
-	union{
-		struct buffer *u1bufptr;
-		char *u1globp;
-	}u1;
-	union{
-		int u2lineno;
-		int u2strname;
-	}u2;
-	int charno;
-};
-extern struct stack stack[];
-
-#define	bufptr	u1.u1bufptr
-#define	globp	u1.u1globp
-#define	lineno	u2.u2lineno
-#define	strname	u2.u2strname
-extern struct stack *stackp;
-
-extern int	peekc;		/* char to read next */
-extern int	lastc;		/* last char read */
-
-extern int	savedfile;
-extern char	linebuf[LBSIZE];
-
-extern Line	*zero;
-extern Line	*dot;
-extern Line	*dol;
-extern Line 	*lastdol;
-extern Line	*endcore;
-extern Line	*fendcore;
-extern Line	*addr1;
-extern Line	*addr2;
-extern char	*linebp;
-extern int	ninbuf;
-extern int	io;
-extern int	lasterr;
-#define	PAGESIZE	22
-extern int	pagesize;
-extern char bformat;	/* = 'p' */
-extern int	appflag;
-extern int	cflag;
-extern int	cprflag;
-extern int	dflag;
-extern int	eflag;
-extern int	gflag;
-extern int	biggflag;
-extern int	iflag;
-extern int	prflag;
-extern int	tflag;
-extern int	uflag;
-extern int	vflag;
-extern int	qok;
-extern int	eok;
-extern int	initflag;
-extern int	nestlevel;
-extern int	lastttyc;
-extern int	listf;
-extern int	tfile;
-extern int	tfile2;
-extern char	tfname[];
-extern char	*loc1;
-extern char	*loc2;
-extern long	names[NBUFS];
-extern char	*braslist[NBRA];
-extern char	*braelist[NBRA];
-extern int	nbra;
-extern int	oneline;
-extern char	bname[]; /* 
-="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~:@" */
-extern char	lchars[];	/* = "pPlL" */
-extern int	bbempty;	/* whether getc's internal buffer buffer needs 
-reloading */
-
-/*
- * in some (most?) worlds, signal returns void (*)();
- * in others, int (*)();
- * pick the former, make sure signal-handling routines match,
- * and glue it together with casts for the latter world
- * hackish but probably near enough
- */
-typedef void Sigret;
-typedef Sigret (*Sigtype)();
-
-/*
- * prototypes
- */
-	/* address.c */
-Line *address(void);
-	/* blkio.c */
-void initio(void);
-char *getline(Line, char *);
-Line qputline(void);
-	/* com.c */
-void jump(void);
-void setapp(void);
-int append(int (*)(void), Line *);
-void bcom(void);
-void delete(void);
-void allnums(void);
-void numset(int, int);
-void strcom(int);
-void strinc(int, int);
-void ncom(int);
-void allstrs(void);
-	/* getchar.c */
-int getnum(void);
-int getsigned(void);
-int alldigs(char *);
-int getname(int, int);
-int getaz(int, int);
-int getchar(void);
-int getc(void);
-int posn(int, char *);
-void pushinp(int, int, char *, int);
-void popinp(void);
-int gettty(void);
-int getquote(char *, int (*)(void));
-	/* getfile.c */
-int newfile(int, int, char *);
-void exfile(void);
-int getfile(void);
-void putfile(void);
-void Unix(int);
-	/* glob.c */
-void until(int, int);
-void global(int);
-void globuf(int);
-	/* main.c */
-void lock(void);
-void unlock(void (*)(void));
-int main(int, char **);
-void reset(void);
-void restorsig(void);
-void commands(void);
-	/* misc.c */
-void chngbuf(int);
-int bufname(int);
-void newbuf(int);
-void fixbufs(int, int);
-void syncbuf(void);
-void error(int);
-void init(void);
-void comment(void);
-void settruth(int);
-void setcount(int);
-int truth(void);
-void modified(void);
-	/* move.c */
-void move(int);
-	/* pattern.c */
-void compile(int);
-int getsvc(void);
-int execute(Line *);
-	/* qputchar.c */
-void qputlong(unsigned long);
-void qputl(char *);
-void qputs(char *);
-void display(int);
-void qputct(int);
-void qputchar(int);
-void flush(void);
-void outreset(void);
-	/* setaddr.c */
-void setdot(void);
-void setall(void);
-void setnoaddr(void);
-void nonzero(void);
-	/* string.c */
-void startstring(void);
-void addstring(int);
-void dropstring(void);
-void clearstring(int);
-void copystring(char *);
-int eqstr(char *, char *);
-void dupstring(int);
-void setstring(int);
-int savestring(int);
-int reststring(int);
-	/* subs.c */
-void substitute(int, int);
-int compsub(int, int *);
-void undo(void);
-void join(void);
-void xform(void);
//GO.SYSIN DD vars.h
echo address.c 1>&2
sed 's/.//' >address.c <<'//GO.SYSIN DD address.c'
-#include "vars.h"
-
-Line *
-address(void)
-{
-	int sign;
-	Line *a;
-	int opcnt, nextopand;
-	Line *b;
-	int c;
-	long desname;
-
-	nextopand = -1;
-	sign = 1;
-	opcnt = 0;
-	a = dot;
-	do {
-		do c = getchar(); while (c==' ' || c=='\t');
-		if ('0'<=c && c<='9') {
-			peekc = c;
-			if (!opcnt)
-				a = zero;
-			a += sign*getnum();
-		} else switch (c) {
-		case '$':
-			a = dol;
-			/* fall through */
-		case '.':
-			if (opcnt)
-				error('a');
-			break;
-		case '\'':
-			c = getchar();
-			if (opcnt)
-				error('a');
-			if((c = posn(c, bname))<0 || c >= NBUFS)
-				error('k');
-			desname = names[c];	/* speedup */
-			for (a = zero + 1; a <= dol; a++)
-				if (a->offset == desname)
-					break;
-			break;
-		case '?':
-			sign = -sign;
-			/* fall through */
-		case '/':
-			compile(c);
-			b = a;
-			for (;;) {
-				a += sign;
-				if (a<zero)
-					a = dol;
-				if (a>dol)
-					a = zero;
-				if (execute(a))
-					break;
-				if (a==b)
-					error('/');
-			}
-			break;
-		default:
-			if (nextopand == opcnt) {
-				a += sign;
-				if (a<zero || dol<a)
-					continue;       /* error('$'); */
-			}
-			if (c!='+' && c!='-' && c!='^') {
-				peekc = c;
-				if (opcnt==0)
-					a = 0;
-				return (a);
-			}
-			sign = 1;
-			if (c!='+')
-				sign = -sign;
-			nextopand = ++opcnt;
-			continue;
-		}
-		sign = 1;
-		opcnt++;
-	} while (zero<=a && a<=dol);
-	error('$');
-	/*NOTREACHED*/
-	return (a);		/* calm the compiler */
-}
//GO.SYSIN DD address.c
echo blkio.c 1>&2
sed 's/.//' >blkio.c <<'//GO.SYSIN DD blkio.c'
-#include <stdlib.h>
-#include <unistd.h>
-#include "vars.h"
-
-char linebuf[LBSIZE];
-char *linebp;
-int io;
-
-/*
- * IO to/from the tempfile
- * getline fetches the line identified by `tl' into `lbuf'
- * qputline adds the contents of (global) linebuf to the tempfile,
- * and returns a new line identifier
- * there is no garbage collection on the tempfile;
- * every line stored is added to the end,
- * space abandoned (e.g. deleted) is lost
- *
- * lines in the tempfile are aligned on 4-byte boundaries.  why?
- */
-static char	ibuff[BLKSIZE];
-static long	iblock = -1;
-static long	oblock = 0;
-static char	obuff[BLKSIZE];
-static int	ooff;		/* offset of next byte in obuff */
-
-void
-initio(void)
-{
-	lock();
-	iblock = -1;
-	oblock = 0;
-	ooff = 0;
-	unlock(NULL);
-}
-
-static void 
-blkread(long b, char *buf)
-{
-	if (b < 0		/* sanity check for wraparound */
-	||  lseek(tfile, b * BLKSIZE, 0) < 0L
-	||  read(tfile, buf, BLKSIZE) != BLKSIZE) {
-		error('T');
-	}
-}
-
-static void 
-blkwrite(long b, char *buf)
-{
-	if (b < 0		/* sanity check for wraparound */
-	||  lseek(tfile, b * BLKSIZE, 0) < 0L
-	||  write(tfile, buf, BLKSIZE) != BLKSIZE) {
-		error('T');
-	}
-}
-
-char *
-getline(Line tl, char *lbuf)
-{
-	char *bp, *lp;
-	int off;
-	long blk;
-
-	lp = lbuf;
-	off = -(tl.offset % BLKSIZE);
-	blk = tl.offset / BLKSIZE;
-	do {
-		if (off<=0) {
-			if (blk==oblock)
-				bp = obuff;
-			else {
-				bp = ibuff;
-				if (blk!=iblock) {
-					iblock = -1;	/* signal protection */
-					blkread(blk, bp);
-					iblock = blk;
-				}
-			}
-			blk++;
-			bp -= off;
-			off += BLKSIZE;
-		}
-		off--;
-	} while ((*lp++ = *bp++) != 0);
-	return(lbuf);
-}
-
-Line
-qputline(void)
-{
-	char *op, *lp;
-	Line r;
-
-	modified();
-	lp = linebuf;
-	r.offset = (oblock*BLKSIZE) + ooff;	/* ooff may be BLKSIZE! */
-	r.glob = 0;			/* safety */
-	op = obuff + ooff;
-	lock();
-	do {
-		if (op >= obuff+BLKSIZE) {
-			/* delay updating oblock until after blkwrite succeeds */
-			op = obuff;
-			blkwrite(oblock, op);
-			oblock++;
-			ooff = 0;
-		}
-		if((*op = *lp++) == '\n') {
-			*op++ = '\0';
-			linebp = lp;
-			break;
-		}
-	} while (*op++);
-	ooff = op - obuff;
-	unlock(NULL);
-	return (r);
-}
//GO.SYSIN DD blkio.c
echo com.c 1>&2
sed 's/.//' >com.c <<'//GO.SYSIN DD com.c'
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include "vars.h"
-
-int oneline;
-static char genbuf[LBSIZE];
-
-#define	OUT	10
-#define	BACKWARD 11
-#define FORWARD 12
-
-static char	jumpcs[] = "0123456789o`'";
-
-/* forward */
-static void search(int);
-static void clean(int);
-
-static void
-stacktype(int t)
-{
-	if(stackp->type != t)
-		error('y');
-}
-
-static 
-void getlabel(void)
-{
-	char *p, c;
-	p = genbuf;
-	for(c=getchar(); posn(c," \"\t\n")<0; c=getchar()){
-		*p++ = c;
-		*p = '\0';
-	}
-	if(p==genbuf)
-		error('y');
-}
-
-void
-jump(void)	/* this should be pronounced with a Swedish accent */
-{
-	int i;
-	int cond;
-	int c;
-
-	if(stackp->type==TTY)
-		error('y');
-	c = getchar();
-	cond = TRUE;
-	if(c=='t' || c=='f'){
-		cond = ((c=='t') == truth());
-		c = getchar();
-	}
-	i = posn(c, jumpcs);
-	if(i==-1){	/* to handle y[tf] without labels for globals */
-		ungetchar(c);
-		if(cond){
-			while((c = getc())!='\n')
-				if(c==EOF)
-					return;
-		}
-	}
-	else if(i<=9){
-		stacktype(BUF);
-		ungetchar(c);
-		i = getnum();
-		stacktype(BUF);		/* we may have popped stack! */
-		if(cond){
-			/* getchar will handle problems if off end of buffer */
-			bbempty = TRUE;
-			stackp->lineno = i;
-			stackp->charno = 0;
-		}
-	}
-	else if(i==OUT){
-		if(cond){
-			if(stackp==stack)
-				error('y');
-			if(stackp->type==GLOB){
-				--nestlevel;
-				stackp->globp = "";
-			}else
-				popinp();
-		}
-	}
-	else if(i==FORWARD || i==BACKWARD){
-		stacktype(BUF);
-		getlabel();	/* must eat label even if not yumping */
-		stacktype(BUF);
-		if(cond)
-			search(i==FORWARD);
-	}
-}
-
-static Line *
-looper(Line *a1, Line *a2, char *str, int dir)
-{
-	char *p1;
-	char *p2;
-	while(dir ? a1<=a2 : a1>=a2){
-		p2 = getline(*a1, linebuf);
-		while(*p2==' ' || *p2=='\t')
-			p2++;
-		if(*p2++=='"' && *p2!=' ' && *p2!='\t' && *p2!='\0') {
-			for(p1=str; *p2 && (*p1 == *p2); p2++)
-				p1++;
-			if(*p1==0 && (*p2==0 || *p2==' ' || *p2=='\t'))
-				return(a1);
-		}
-		if(dir)
-			a1++;
-		else
-			--a1;
-	}
-	return((Line *)0);
-}
-
-static void 
-search(int forward)
-{
-	Line *a1;
-	struct buffer *bufp;
-
-	bufp = stackp->bufptr;
-	if(forward){
-		if((a1 = looper(bufp->zero + (stackp->lineno + 1),
-			bufp->dol,genbuf,1))==0){
-			a1 = looper(bufp->zero + 1,bufp->zero + (stackp->lineno 
-- 1),genbuf,1);
-		}
-	}else{
-		if((a1 = looper(bufp->zero + (stackp->lineno - 1),
-			bufp->zero + 1,genbuf,0))==0){
-			a1 = looper(bufp->dol,bufp->zero + stackp->lineno + 
-1,genbuf,0);
-		}
-	}
-	if(a1){
-		stackp->lineno = a1 - bufp->zero;
-		stackp->charno = 0;
-	}
-}
-
-static int pchar;
-
-void 
-setapp(void)
-{
-	int c;
-	c=getchar();
-	if(posn(c, lchars)>=0) {
-		pchar = c;
-		c = getchar();
-	}
-	if(c==' ' || c=='\t'){
-		oneline++;
-		if(c=='\t')
-			ungetchar(c);
-	}
-	else if(c!='\n')
-		error('x');
-}
-
-#define	LDCHUNK	512
-
-/*
- * appfix and notfile
- * are admittedly a cheap hack,
- * but they double the speed of reading in a file
- */
-static void
-appfix(void)
-{
-	fixbufs(0, 1);
-}
-
-int 
-append(int(*f)(void), Line *a)
-{
-	Line *a1, *a2, *rdot;
-	Line tl;
-	int nline;
-	int notfile;
-
-	appflag++;
-	nline = 0;
-	dot = a;
-	notfile = (f != getfile);
-	while ((*f)()==0) {
-		if (lastdol>=endcore) {
-			if (sbrk(LDCHUNK*(sizeof *endcore))==(char *)-1)
-				error('c');
-			endcore += LDCHUNK;
-		}
-		tl = qputline();
-		nline++;
-		lock();
-		++dol;
-		a1 = ++lastdol;
-		fixbufs(1, notfile);	/* deferred if f == getfile */
-		a2 = a1+1;
-		rdot = ++dot;
-		while (a1 > rdot)
-			*--a2 = *--a1;
-		*rdot = tl;
-		unlock(appfix);
-		if(oneline)
-			break;
-	}
-	fixbufs(0, 1);	/* run any pending updates */
-	appflag=0;
-	oneline=0;
-	if(pchar) {
-		a1 = addr1; addr1 = dot;
-		a2 = addr2; addr2 = dot;
-		display(pchar);
-		pchar = 0;
-		addr1 = a1; addr2 = a2;
-	}
-	return(nline);
-}
-
-char bformat = 'p';
-
-void
-bcom(void)
-{
-	int dir, n;
-	int psize;
-	Line *olddot=addr2;	/* for b. */
-
-	dir=1;
-	if((peekc=getchar())!='\n'){	/* really nextchar() */
-		if (peekc=='-' || peekc=='+' || peekc=='.') {
-			if(peekc=='-')
-				dir= -1;
-			else if(peekc=='.')
-				dir=0;
-			getchar();	/* eat peekc */
-		}
-		if((n=getnum())>0)
-			pagesize=n;
-	}
-	psize=pagesize;
-	if(dir==0)
-		psize/=2;
-	if(posn(nextchar(), lchars)>=0)
-		bformat=getchar();
-	if(dir<=0) {
-		if((addr1=addr2-(psize-1))<=zero)
-			addr1=zero+1;
-		if(dir==0){
-			display(bformat);
-			qputs("^^^^^");
-			addr2++;
-		}
-	}
-	if (dir>=0) {
-		addr1=addr2;
-		if((addr2+=(psize-1))>dol)
-			addr2=dol;
-	}
-	display(bformat);
-	if(dir==0)
-		dot=olddot;
-}
-
-void
-delete(void)
-{
-	Line *a1, *a2, *a3;
-	setdot();
-	a1 = addr1;
-	a2 = addr2;
-	if(a1==zero) {
-		if(a2!=zero)
-			a1++;
-		else
-			return;		/* 0,$d on an empty buffer */
-	}
-	a2++;
-	a3 = lastdol;
-	lock();
-	dol -= a2 - a1;
-	lastdol -= a2 - a1;
-	fixbufs(a1-a2, 1);
-	do
-		*a1++ = *a2++;
-	while (a2<=a3);
-	a1 = addr1;
-	if (a1 > dol)
-		a1 = dol;
-	dot = a1;
-	unlock(NULL);
-	modified();
-}
-
-void
-allnums(void)
-{
-	int i;
-	char *p;
-	setdot();
-	for(i=0; i<NBUFS; i++){
-		p = string[i].str;
-		if(*p!='\0' && alldigs(p)){
-			qputct(bname[i]);
-			qputs(p);
-		}
-	}
-}
-
-
-static int 
-condition(int n, int m, int cond, int negate)
-{
-	int retval;
-	if(cond=='=')
-		retval = (n==m);
-	else if(cond=='<')
-		retval = (n<m);
-	else if(cond=='>')
-		retval = (n>m);
-	else
-		error('!');
-	return(negate^retval);
-}
-
-static void
-numcom(int z)
-{
-	int n;
-	struct string *sp;
-	char *l;
-	char c;
-	int numeric;
-
-	/*
-	 * Must generate error if attempt is made to do arithmetic on
-	 * a which is not numeric; this is done by remembering
-	 * (via `numeric') whether the initial string was numeric or not.
-	 */
-	sp = &string[z];
-	numeric = alldigs(sp->str);
-	n = atoi(sp->str);
-	for(;;){
-		switch(c=getchar()){
-		default:
-			goto Done;
-		case ':':
-			n=getsigned();
-			goto Not_numeric;
-		case 'a':
-			n=addr2-zero;
-			goto Not_numeric;
-		case 'r':
-			if(z+1>=NBUFS)
-				error('z');
-			n = addr1-zero;
-			numset(z+1, addr2-zero);
-			goto Not_numeric;
-		case 'n':
-			nonzero();
-			l = getline(*addr2,linebuf);
-			do; while(*l++);
-			n = l - linebuf - 1;
-			goto Not_numeric;
-		case 'P':
-			n = getpid();
-		Not_numeric:
-			numeric = TRUE;		/* It's numeric now! */
-			break;
-
-		case 'p':
-			if(n<0)
-				qputchar('-');
-			qputlong((unsigned long)abs(n));
-			goto Numeric;
-		case '+':
-			n += getsigned();
-			goto Numeric;
-		case '-':
-			n -= getsigned();
-			goto Numeric;
-		case '*':
-			n *= getsigned();
-			goto Numeric;
-		case '/':
-			n /= getsigned();
-			goto Numeric;
-		case '%':
-			n %= getsigned();
-			goto Numeric;
-		case '!':
-			if(posn(c=getchar(), "=><")<0)
-				error('#');
-			settruth(condition(n, getsigned(), c, 1));
-			goto Numeric;
-		case '<':
-		case '>':
-		case '=':
-			settruth(condition(n, getsigned(), c, 0));
-		Numeric:
-			if(numeric == FALSE)
-				error('#');
-			break;
-		}
-	}
-  Done:
-	ungetchar(c);
-	numset(z, n);
-}
-
-static void 
-numbuild(int n)
-{
-	int i;
-	if(n<0){
-		addstring('-');
-		n = -n;
-	}
-	i = n/10;
-	if(i)
-		numbuild(i);
-	addstring(n%10+'0');
-}
-
-void
-numset(int z, int n)
-{
-	startstring();
-	numbuild(n);
-	setstring(z);
-}
-
-void 
-strcom(int z)
-{
-	char *q;
-	int n;
-	struct string *sp;
-	int cond, c, negate;
-	setdot();
-	sp = &string[z];
-	if(nextchar()=='#'){
-		getchar();	/* eat the '#' */
-		numcom(z);
-		return;
-	}
-	negate=FALSE;
-	switch(cond=getchar()){
-	default:
-		error('x');
-		/* fall through */
-	case 'p':
-		qputs(sp->str);
-		break;
-	case 'l':
-		qputl(sp->str);
-		break;
-	case ':':
-		startstring();
-		for(;;){
-			c = getquote("\n", getchar);
-			if(c=='\n'){
-				setstring(z);
-				return;
-			}
-			addstring(c&0177);
-		}
-	case '\'':
-		startstring();
-		dupstring(getname('z', 0));
-		setstring(z);
-		break;
-	case '.':
-		nonzero();
-		startstring();
-		copystring(getline(*addr2, linebuf));
-		setstring(z);
-		break;
-	case '/':
-		nonzero();
-		compile('/');
-		if(execute(addr2)==0){
-			clearstring(z);
-			settruth(FALSE);
-			return;
-		}
-		q = loc1;
-		startstring();
-		while(q < loc2)
-			addstring(*q++);
-		setstring(z);
-		settruth(TRUE);
-		return;
-	case 's':
-		substitute(stackp!=&stack[0], z);
-		return;
-	case '+':
-		strinc(z, getsigned());
-		break;
-	case '-':
-		strinc(z, -getsigned());
-		break;
-	case 'n':
-		setcount(sp->len);
-		break;
-	case 'e':
-		startstring();
-		addstring(lasterr);
-		setstring(z);
-		break;
-	case '(':
-		n=getsigned();
-		if(abs(n) > sp->len)
-			error('[');
-		if(n>=0){
-			sp->str += n;
-			sp->len -= n;
-		}
-		else{
-			sp->str += sp->len+n;
-			sp->len = -n;
-		}
-		break;
-	case ')':
-		n=getsigned();
-		if(abs(n) > sp->len)
-			error('[');
-		if(n<0){
-			sp->str[sp->len+n]='\0';
-			sp->len += n;
-		} else if(n==0)
-			clearstring(z);
-		else {
-			sp->str[n]='\0';
-			sp->len=n;
-		}
-		break;
-	case '[':
-		strcpy(linebuf, sp->str);
-		loc2=0;	/* Tell execute that it's already in linebuf */
-		compile(getchar());
-		if(execute((Line *)0)==0){
-			settruth(FALSE);
-			setcount(-1);
-		} else {
-			settruth(TRUE);
-			setcount(loc2-linebuf-1);
-		}
-		return;
-	case 'C':
-		startstring();
-		clean(z);
-		setstring(z);
-		break;
-	case '!':
-		if(posn(cond=getchar(), "=><")<0)
-			error('x');
-		negate=TRUE;
-		/* fall through */
-	case '=':
-	case '<':
-	case '>':
-		settruth(FALSE);
-		q=sp->str;
-		for(;;){
-			c=getchar();
-			if(c=='\n' && *q==0){
-				if(cond == '=')
-					settruth(!negate);
-				return;
-			}
-			if(*q++!=c){
-				if(cond=='<')
-					settruth(negate ^ (*--q < c));
-				else if(cond=='>')
-					settruth(negate ^ (*--q > c));
-				while(c!='\n')
-					c=getchar();
-				return;
-			}
-		}
-	case '{':
-		q = genbuf;
-		while(posn(c=getchar(), "} \t\n")<0 && c!=EOF)
-			*q++ = (char) c;
-		*q = '\0';
-		if((q=getenv(genbuf)) == 0)
-			clearstring(z);
-		else{
-			startstring();
-			copystring(q);
-			setstring(z);
-		}
-		break;
-	/* end of switch */
-	}
-}
-
-void 
-strinc(int z, int n)
-{
-	char *q;
-	q=string[z].str;
-	while(*q)
-		*q++ += n;
-}
-
-#define	EMPTY	(TRUE+1)	/* ==> ignore this buf in G/V */
-
-void 
-ncom(int c)
-{
-	struct buffer *bufp;
-	struct buffer *stop;
-	char *f, *lp;
-	int globflag;
-
-	setnoaddr();
-	syncbuf();
-	globflag = FALSE;
-	if(c == 'f')
-		stop = bufp = curbuf;
-	else{
-		bufp = buffer;
-		stop = buffer+NBUFS-1;
-		if(c=='G')
-			globflag = TRUE;
-	}
-	do{
-		lp = linebuf;
-		f = string[FILE(bufp-buffer)].str;
-		if(c=='N' && (!bufp->cflag || *f==0))
-			continue;
-		if(bufp->dol==bufp->zero && *f=='\0'){
-			if(globflag)
-				bufp->gmark = EMPTY;
-			if(globflag || bufp!=curbuf)
-				continue;
-		}
-		*lp++ = bname[bufp-buffer];
-		*lp++ = (bufp->cflag) ? '\'' : ' ';
-		*lp++ = (bufp==curbuf) ? '.' : ' ';
-		numset(FILEBUF, bufp->dol-bufp->zero);
-		strcpy(lp, string[FILEBUF].str);
-		lp += string[FILEBUF].len;
-		f = string[FILE(bufp-buffer)].str;	/* in case strings got 
-g.c.'d */
-		if(*f)
-			*lp++ = '\t';
-		if(globflag){
-			strcpy(lp, f);
-			loc2 = 0;	/* ==> we are about to search for 1st 
-time */
-			bufp->gmark = execute((Line *)0);
-		} else {
-			*lp = '\0';
-			lp = linebuf;
-			while(*lp)
-				qputchar(*lp++);
-			qputl(f);
-		}
-	}while(bufp++!=stop);
-}
-
-void
-allstrs(void)
-{
-	int i;
-	char *p;
-	setdot();
-	for(i=0; i<NBUFS; i++){
-		p=string[i].str;
-		if(*p!=0){
-			qputct(bname[i]);
-			qputl(p);
-		}
-	}
-	qputct('P');
-	qputl(string[SAVPAT].str);
-	qputct('R');
-	qputl(string[SAVRHS].str);
-	if(*string[BROWSE].str) {
-		qputct('B');
-		qputl(string[BROWSE].str);
-	}
-}
-
-/*
- *	clean (string) to support zaC
- *	strips leading and trailing white space from a string
- *	and replaces interior white space by single blanks
- */
-static void 
-clean(int z)
-{
-	char *s;
-	char *d;
-	char c;
-	d = genbuf;
-	for (s = string[z].str; (c = *s) == ' ' || c == '\t'; s++)
-		;
-	while (c = *s++) {
-		if (c == ' ' || c == '\t') {
-			*d++ = ' ';
-			while(*s == ' ' || *s == '\t')
-				s++;
-		} else {
-			*d++ = c;
-		}
-	}
-	while (d > genbuf && d[-1] == ' ')
-		--d;
-	*d = 0;
-	copystring(genbuf);
-}
//GO.SYSIN DD com.c
echo getchar.c 1>&2
sed 's/.//' >getchar.c <<'//GO.SYSIN DD getchar.c'
-#include <stdlib.h>
-#include <unistd.h>
-#include "vars.h"
-
-struct stack stack[STACKSIZE];
-struct stack *stackp;
-int peekc, lastc;
-int bbempty;
-
-/* forward */
-static int getnm(int, int, int (*)(void));
-static int ttyc(void);
-
-char digits[] = "0123456789";	/* getnum() & atoi() work even on non-ASCII 
-systems */
-
-int 
-getnum(void)
-{
-	int n, i;
-	n=0;
-	while((i=posn(nextchar(), digits)) >= 0){
-		getchar();
-		n = n*10 + i;
-	}
-	return(n);
-}
-
-int 
-getsigned(void)
-{
-	int sign;
-	if(nextchar()=='-'){
-		getchar();
-		sign = -1;
-	}
-	else
-		sign = 1;
-	return(getnum()*sign);
-}
-
-int 
-alldigs(char *s)
-{
-	if(*s == '-')
-		s++;
-	while(*s)
-		if(posn(*s++, digits) < 0)
-			return(FALSE);
-	return(TRUE);
-}
-
-char bname[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~:@";
-
-/*
- * b nonzero if names > NBUF ok (buffer names :, @)
- */
-int 
-getname(int e, int b)
-{
-	return(getnm(e, b, getc));
-}
-
-int 
-getaz(int e, int b)
-{
-	return(getnm(e, b, getchar));
-}
-
-static int 
-getnm(int e, int b, int (*f)(void))
-{
-	int i;
-	i = posn((*f)(), bname);
-	if (i < 0)
-		error(e);
-	if (b == 0 && i >= NBUFS)
-		error(e);
-	return(i);
-}
-
-static char	special[] = "xgBbBcfFlprzN\"\\'";
-
-static int	qcount;
-static int	afterq;
-
-int 
-getchar(void)
-{
-	int c;
-	int peek;
-
-	peek=peekc;
-	c=getc();
-	if(tflag && !peek && stackp!= &stack[0]){
-		if(c==EOF)
-			qputs("[*EOF*]");
-		else
-			qputchar(c);
-	}
-	return(c);
-}
-
-int 
-getc(void)
-{
-	int c;
-	struct buffer *bufp;
-	struct stack *sp;
-	Line *lp;
-	int numeric;
-	int delta;
-	int literal;
-	int i;
-	char *p;
-	static char bufbuf[LBSIZE];
-
-	if((c = peekc) != 0)
-		peekc = 0;
-	else if(qcount) {
-		--qcount;
-		c = '\\';
-	} else if((c = afterq) != 0)
-		afterq = 0;
-	else {
-		for(;;popinp()){
-			sp=stackp;
-			switch(sp->type){
-			case TTY:
-			case XTTY:
-				if(cprflag && sp == &stack[0] &&
-					lastttyc == '\n')
-					(void)write(2, "*", 1);
-				c = ttyc();
-				if(sp != &stack[0] && c == '\n') {
-					if(stackp->type == TTY)
-						continue;
-					else		/* XTTY */
-						popinp();
-				}
-				break;
-			case GLOB:
-				if ((c = *stackp->globp++) == 0){
-					popinp();
-					c = EOF;
-				}
-				break;
-			case STRING:
-			case BFILEN:
-			case PAT:
-			case RHS:
-			case BRWS:
-			case FILEN:
-				if(string[sp->strname].len < sp->charno){
-					c=EOF;
-					continue;
-				}
-				c=string[sp->strname].str[sp->charno++];
-				if(c==0)
-					continue;
-				break;
-			case BUF:
-				bufp=sp->bufptr;
-				if(bufp==curbuf)
-					syncbuf();
-				lp=bufp->zero+sp->lineno;
-				if(bbempty){
-					if(lp>bufp->dol)
-						continue;
-					p = getline(*lp, bufbuf);
-					bbempty = FALSE;
-					for(i=sp->charno; i-- && *p; p++)
-						;
-				} else
-					p = bufbuf+sp->charno;
-				sp->charno++;
-				if((c = *p) == '\0'){
-					/*
-					 * Leave the last newline in the buffer 
-out.
-					 */
-					bbempty = TRUE;
-					if(lp>=bufp->dol)
-						continue;
-					sp->lineno++;
-					sp->charno=0;
-					c='\n';
-				}
-			}
-			break;
-		}
-		literal = FALSE;
-		if(c == '\\' && !stackp->literal){
-		Getc:
-			c = getc();
-			i = posn(c, cspec);
-			switch(i) {
-			case LITERAL:
-				if(posn(peekc=getc(), "bfFlprz!") >= 0)
-					literal = TRUE;
-				goto Getc;	/* business as usual... */
-			case QUOTE:
-				c = '\\';
-				break;
-			case NEWL:
-				c = '\n';
-				break;
-			case STRING:
-				delta = 0;
-				numeric = 0;
-				c = getc();
-				if(c == '#'){
-					numeric++;
-					c = getc();
-				}
-				if(c == '+' || c == '-'){
-					delta = 1;
-					if(c == '-')
-						delta = -delta;
-					c=getc();
-				}
-				ungetchar(c);
-				c = getname('z', 0);
-				if(delta){
-					if(numeric){
-						if(!alldigs(string[c].str))
-							error('#');
-						numset(c, 
-atoi(string[c].str)+delta);
-					} else
-						strinc(c, delta);
-				}
-				pushinp(i, c, (char *)0, literal);
-				literal = FALSE;
-				c=getc();
-				break;
-			case BUF:
-			case BFILEN:
-				c = bufname(getname(cspec[i], 1));
-				if(i == BUF)
-					bbempty = TRUE;
-				/* fall through */
-			case TTY:
-			case FILEN:
-			case PAT:
-			case RHS:
-				pushinp(i, c, (char *)0, literal);
-				literal = FALSE;
-				/* fall through */
-			case NOTHING:
-				c = getc();
-				break;
-			case CURBN:
-				c = bname[curbuf-buffer];
-				break;
-			case BACKSLASH:
-				qcount++;
-				break;
-			default:
-				afterq = c;
-				c = '\\';
-				break;
-			}
-		}
-	}
-	lastc = c;
-	return(c);
-}
-
-static int 
-ttyc(void)
-{
-	char c;
-	initflag = 0;
-	if(read(0, &c, 1) > 0)
-		lastttyc = c&0177;
-	else
-		lastttyc = EOF;
-	return(lastttyc);
-}
-
-int 
-posn(int c, char *s)
-{
-	char *is;
-	is = s;
-	while(*s)
-		if(c == *s++)
-			return(s - is - 1);
-	return(-1);
-}
-
-void
-pushinp(int type, int iarg, char *sarg, int literal)
-{
-	struct stack *s;
-
-	s = ++stackp;
-	if(s == stack+STACKSIZE)
-		error('l');
-	stackp->literal = literal;
-	if(tflag){
-		qputchar('[');
-		if(literal)
-			qputchar('\'');
-		qputchar(cspec[type]);
-	}
-	s->type=type;
-	s->charno = 0;
-	switch(type){
-	case BFILEN:
-		s->strname = FILE(iarg);
-		break;
-	case STRING:
-		s->strname = iarg;
-		break;
-	case FILEN:
-		s->strname = savedfile;
-		break;
-	case PAT:
-		s->strname = SAVPAT;
-		break;
-	case RHS:
-		s->strname = SAVRHS;
-		break;
-	case BRWS:
-		s->strname = BROWSE;
-		break;
-	case BUF:
-		if((s->bufptr=buffer+iarg) == curbuf && appflag)
-			error('\\');
-		s->lineno=1;
-		break;
-	case GLOB:
-		s->globp = sarg;
-		break;
-	}
-	if(tflag){
-		if(type==BFILEN || type==STRING || type==BUF)
-			qputchar(bname[iarg]);
-		qputchar('=');
-	}
-}
-
-void 
-popinp(void)
-{
-	if(stackp->type == BUF)
-		bbempty = TRUE;
-	if(tflag){
-		qputchar(']');
-		flush();
-	}
-	--stackp;
-}
-
-int 
-gettty(void)
-{
-	int c, gf;
-	char *p;
-	p = linebuf;
-	gf = stackp->type;
-	while((c=getchar()) != '\n') {
-		if (c==EOF) {
-			if (gf == GLOB)
-				peekc=c;
-			return(c);
-		}
-		if (c == 0)
-			continue;
-		*p++ = (char) c;
-		if (p >= &linebuf[LBSIZE-2])
-			error('l');
-	}
-	*p++ = 0;
-	if (!oneline && linebuf[0]=='.' && linebuf[1]==0)
-		return(EOF);
-	return(0);
-}
-
-int 
-getquote(char *p, int (*f)(void))
-{
-	int c;
-	c = (*f)();
-	if(c == '\\') {
-		if(peekc == 0)
-			nextchar();	/* prime peekc */
-		if(posn(peekc, p) >= 0) {
-			c = peekc | 0200;
-			(*f)();		/* clear peekc */
-		}
-	}
-	return(c);
-}
//GO.SYSIN DD getchar.c
echo getfile.c 1>&2
sed 's/.//' >getfile.c <<'//GO.SYSIN DD getfile.c'
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include "vars.h"
-
-static unsigned long	count;
-
-/*
- * newfile: read a new file name (if given) from command line.
- *
- *	nullerr: if true, error if file is null.
- *	savspec: decides if string[savedfile] is set.
- *		If savspec==SAVEIFFIRST, only save if deffile is null.
- *	deffile: default file name.
- *
- *	return value: string[FILEBUF]!=deffile
- *		      (unless SAVEIFFIRST && deffile null ==> return FALSE)
- *	side effects:
- *		can set string[savedfile]
- *		always sets string[FILEBUF]
- *		zeroes count
- */
-int
-newfile(int nullerr, int savspec, char *deffile)
-{
-	char c;
-	char savbuf[LBSIZE];
-
-	count = 0L;
-	strcpy(savbuf, deffile);	/* in case we strcompact() */
-	startstring();
-	c = getchar();
-	if(c == '\n')
-		copystring(savbuf);
-	else {
-		if(c != ' ')
-			error('f');
-		do  c = getchar();  while(c == ' ');
-		while(posn(c, " \t\n") < 0){
-			if(c<' ' || c=='\177')
-				error('f');
-			addstring(c);
-			c = getchar();
-		}
-	}
-	setstring(FILEBUF);
-	if(nullerr && string[FILEBUF].str[0]=='\0')
-		error('f');
-	if(savspec==SAVEALWAYS || (savspec==SAVEIFFIRST && savbuf[0]=='\0')){
-		startstring();
-		dupstring(FILEBUF);
-		setstring(savedfile);
-		if(savspec==SAVEIFFIRST && savbuf[0]=='\0')
-			return(FALSE);
-	}
-	return(!eqstr(savbuf, string[FILEBUF].str));
-}
-
-void
-exfile(void)
-{
-	close(io);
-	io = -1;
-	if (vflag && initflag)
-		ncom('f');
-	else if (vflag) {
-		qputlong(count);
-		qputchar('\n');
-	}
-	setcount((int)count);
-}
-
-/*
- * fetch the next line from the current input file
- * return EOF if none, 0 if OK
- * line returned in linebuf
- *
- * --bug: NULs are no longer silently removed;
- * they may cause confusion elsewhere in the program
- */
-
-int ninbuf;	/* global so main.c can reset it after an error */
-
-int
-getfile(void)
-{
-	char *lp, *fp, *ep;
-	static char buf[BLKSIZE + 1];	/* room for sentinel */
-	static char *nextip;
-	int n;
-
-	lp = linebuf;
-	fp = nextip;
-	do {
-		if (ninbuf <= 0) {
-			if ((ninbuf = read(io, buf, BLKSIZE)) <= 0) {
-				if(ninbuf < 0)
-					error('r');
-				if(lp != linebuf)
-					error('N');
-				return(EOF);
-			}
-			buf[ninbuf] = 0;	/* sentinel */
-			fp = buf;
-		}
-		if ((ep = memchr(fp, '\n', ninbuf)) == NULL)
-			ep = fp + ninbuf;
-		n = ep - fp;
-		if (lp + n >= &linebuf[LBSIZE-1])
-			error('l');
-		memcpy(lp, fp, n);
-		lp += n;
-		ninbuf -= n + 1;	/* swallow newline */
-		fp += n + 1;
-	} while (*ep != '\n');
-	count++;
-	*lp = 0;
-	nextip = fp;
-	return(0);
-}
-
-/*
- * copy [addr1, addr2] to the current output file
- */
-void
-putfile(void)
-{
-	Line *a1;
-	char *fp, *lp, *ebuf;
-	char buf[BLKSIZE];
-
-	fp = buf;
-	ebuf = fp + sizeof(buf);
-	a1 = addr1;
-	if(a1 == zero)
-		a1++;
-	while(a1 <= addr2){
-		lp = getline(*a1++, linebuf);
-		for(;;){
-			if (fp >= ebuf) {
-				if(write(io, buf, fp-buf) < 0)
-					error('w');
-				fp = buf;
-			}
-			if ((*fp++ = *lp++) == 0) {
-				fp[-1] = '\n';
-				count++;
-				break;
-			}
-		}
-	}
-	if (fp > buf)
-		if (write(io, buf, fp-buf) < 0)
-			error('w');
-}
-
-void
-Unix(int type) /* was char type */
-{
-	int pid, rpid;
-	char *s;
-	int c;
-	Sigtype onbpipe, savint;
-	int retcode;
-	char unixbuf[BLKSIZE];
-	int	pipe1[2];
-	int	pipe2[2];
-	Line	 *a, *a1, *a2, *ndot;
-
-	startstring();	/* for the \zU */
-	if(type == '!')
-		setnoaddr();
-	else {
-		if(type == '>' || type == '|')
-			nonzero();
-		count = 0L;
-		if(pipe(pipe1) == -1){
-			lastc = '\n';
-			error('|');
-		}
-	}
-	/* Quick hack: if char is doubled, push \'zU */
-	if(nextchar()==type){
-		getchar();	/* throw it away */
-		pushinp(STRING, UNIX, (char *)0, TRUE);
-	}
-	/*
-	 * Use c not *s as EOF and getchar() are int's
-	 */
-	for(s=unixbuf;(c=getquote("\n", getsvc))!='\n' && c!=EOF;*s++=(c&0177)){
-		if(s>=unixbuf+sizeof(unixbuf))
-			error('l');
-	}
-	dropstring();	/* drop the newline */
-	setstring(UNIX);
-	*s='\0';
-	a1 = addr1;
-	a2 = addr2;
-	if ((pid = fork()) == 0) {
-		restorsig();
-		if(type=='<' || type=='|'){
-			close(1);
-			dup(pipe1[1]);
-		}else if(type == '>'){
-			close(0);
-			dup(pipe1[0]);
-		}
-		if (type != '!') {
-			close(pipe1[0]);
-			close(pipe1[1]);
-		}
-		if(type == '|'){
-			if(pipe(pipe2) == -1){
-				qputs("?|");
-				exit(1);
-			}
-			if((pid=fork()) == 0){
-				close(1);
-				dup(pipe2[1]);
-				close(pipe2[0]);
-				close(pipe2[1]);
-				tfile = tfile2;	/* ugh */
-				/*
-				 * It's ok if we get SIGBPIPE here
-				 */
-				display('p');
-				exit(0);
-			}
-			if(pid == -1){
-				qputs("Can't fork\n?!");
-				exit(1);
-			}
-			close(0);
-			dup(pipe2[0]);
-			close(pipe2[0]);
-			close(pipe2[1]);
-		}
-		close(tfile);
-		close(tfile2);
-		if (*unixbuf)
-			execl("/bin/sh", "sh", "-c", unixbuf, 0);
-		else
-			execl("/bin/sh", "sh", 0);
-		exit(-1);
-	}
-	if(pid == -1){
-		qputs("Can't fork");
-		error('!');
-	}
-	savint = (Sigtype)signal(SIGINT, SIG_IGN);
-	if(type=='<' || type=='|') {
-		close(pipe1[1]);
-		io = pipe1[0];
-		ninbuf = 0;
-		append(getfile,addr2);
-		close(io);
-		io = -1;
-		ndot = dot;
-	} else if(type == '>') {
-		onbpipe = (Sigtype)signal(SIGPIPE, SIG_IGN);
-		close(pipe1[0]);
-		for (a = addr1; a <= addr2; a++) {
-			s = getline(*a, linebuf);
-			while (*s)
-				s++;
-			*s++ = '\n';
-			if (write(pipe1[1], linebuf, s - linebuf) < 0) {
-				qputs("?o");
-				break;
-			}
-		}
-		close(pipe1[1]);
-		signal(SIGPIPE, onbpipe);
-	}
-	while ((rpid = wait(&retcode)) != pid && rpid != -1)
-		;
-	retcode = (retcode>>8)&0377;
-	settruth(retcode);
-	signal(SIGINT, savint);
-	if(type == '|'){
-		if(retcode == 0){
-			addr1 = a1;
-			addr2 = a2;
-			delete();
-			dot = ndot - (a2-a1+1);
-		} else
-			error('0');
-	}
-	if(vflag)
-		qputs("!");
-}
//GO.SYSIN DD getfile.c
echo glob.c 1>&2
sed 's/.//' >glob.c <<'//GO.SYSIN DD glob.c'
-#include "vars.h"
-
-int biggflag;
-int nestlevel;
-
-#define	ALWAYS	2
-#define GBSIZE	256
-
-/* forward */
-static void getglob(char []);
-static int exglob(char *, char *);
-
-void
-until(int nfl, int n)
-{
-	int c, type;
-	char ubuf[GBSIZE];
-
-	c = getchar();
-	type=posn(c, "ft ");
-	if(type < 0){
-		if(nfl==0)
-			error('x');
-		ungetchar(c);
-	}
-	getglob(ubuf);
-	settruth(FALSE);
-	if(nfl && n<=0)
-		return;	/* do it zero times */
-	do ; while (exglob(ubuf, ubuf) &&
-		   !((nfl && --n==0) || 
-		     (type != ALWAYS && type == truth())))
-		;
-}
-
-void
-global(int k)
-{
-	Line *a1;
-	char globuf[GBSIZE];
-	struct buffer *startbuf;
-
-	if(gflag++)
-		error('g');
-	setall();
-	if(nextchar() == '\n')
-		error('x');
-	compile(getchar());
-	getglob(globuf);
-	for (a1=zero+1; a1<=dol; a1++) {
-		a1->glob = 0;
-		if (a1>=addr1 && a1<=addr2 && execute(a1)==k)
-			a1->glob = 1;
-	}
-	startbuf = curbuf;
-	for (a1=zero+1; a1<=dol; a1++) {
-		if (a1->glob) {
-			a1->glob = 0;
-			dot = a1;
-			if (!exglob(globuf, "p"))
-				break;
-			chngbuf(startbuf-buffer);
-			a1 = zero;	/* ??? */
-		}
-	}
-	chngbuf(startbuf-buffer);
-	gflag=FALSE;
-}
-
-void
-globuf(int k)
-{
-	struct buffer *bp;
-	char globbuf[GBSIZE];
-
-	if (biggflag++)
-		error('G');
-	if (nextchar() =='\n')
-		error('x');
-	compile(getchar());
-	getglob(globbuf);
-	for (bp=buffer; bp < &buffer[NBUFS]; bp++)
-		bp->gmark = FALSE;
-	ncom('G');	/* mark interesting buffers */
-	for (bp=buffer; bp < &buffer[NBUFS]; bp++)
-		if (bp->gmark == k) {
-			chngbuf(bp-buffer);
-			if (!exglob(globbuf, "f\n"))
-				break;
-		}
-	biggflag = FALSE;
-}
-
-static void
-getglob(char gbuf[])
-{
-	char *gp;
-	int c;
-	gp = gbuf;
-	while ((c = getquote("\n", getchar)) != '\n') {
-		if (c==EOF)
-			error('x');
-		*gp++ = c & 0177;
-		if (gp >= &gbuf[GBSIZE-2])
-			error('l');
-	}
-	*gp++ = '\n';
-	*gp++ = 0;
-}
-
-static int 
-exglob(char *cmd, char *dflt)
-{
-	int nesting;
-
-	pushinp(GLOB, 0, eqstr(cmd,"\n")? dflt : cmd, FALSE);
-	nesting = ++nestlevel;
-	commands();
-	if (nesting!=nestlevel)
-		return(FALSE);
-	nestlevel--;
-	return(TRUE);
-}
//GO.SYSIN DD glob.c
echo main.c 1>&2
sed 's/.//' >main.c <<'//GO.SYSIN DD main.c'
-#include <stdlib.h>
-#include <unistd.h>
-#include <setjmp.h>
-#include <signal.h>
-
-#include "vars.h"
-
-char lchars[]="pPlL";
-struct buffer buffer[NBUFS];
-struct buffer *curbuf = buffer;
-int savedfile;
-Line *zero, *dot, *dol, *lastdol, *endcore, *fendcore;
-Line *addr1, *addr2;
-int	appflag;
-int	pagesize = PAGESIZE;
-int	prflag;	/* prflag==1 ==> much code to get it right. use the startup 
-buffer */
-int	lastttyc = '\n';
-int	cflag;
-int	cprflag;
-int	eflag;
-int	gflag;
-int	iflag;
-int	tflag;
-int	vflag;	/* initialization code turns it on */
-int	uflag = 's';
-int	dflag;
-int	initflag = 1;
-int	*option[] = {
-	&cflag,	&dflag,	&eflag,	&iflag,	&prflag,&tflag,	&vflag,
-};
-
-int	qok;
-int	eok;
-static char	opcs[] = "cdeipTv";
-long names[NBUFS];
-
-static Sigtype pending;
-static int intrlock;	/* don't interrupt yet */
-
-/* forward */
-static void savall(void);
-static void setreset(int *);
-static void delall(void);
-
-static Sigret
-rescue(s)
-int s;
-{
-	/* Save in qed.hup:[ab]q on hangup */
-	signal(SIGHUP,SIG_IGN);
-	if (intrlock) {
-		pending = rescue;
-		return;
-	}
-	startstring();
-	copystring("qed.hup");
-	setstring(FILEBUF);
-	savall();
-	exit(SIGHUP);
-}
-
-static char *
-filea(void)
-{
-	struct string *sp;
-	int i, d;
-	char c;
-
-	sp = &string[FILEBUF];
-	startstring();
-	d = 0;
-	i = 0;
-	while((c=sp->str[i]) != '\0'){
-		addstring(c);
-		i++;
-		if(c == '/')
-			d = i;
-	}
-	if((i-d) > 12)		/* file name is >= 13 characters long */
-		string[NSTRING].str -= (i-(d+12));	/* truncate string */
-	copystring(":aq");
-	setstring(FILEBUF);
-	return(sp->str);
-}
-
-static char *
-fileb(void)
-{
-	struct string *sp;
-
-	sp = &string[FILEBUF];
-	sp->str[sp->len-2] = 'b';
-	return(sp->str);
-}
-
-static void
-savall(void)
-{
-	int fi;
-
-	lock();
-	syncbuf();
-	addr1 = buffer[0].zero + 1;
-	addr2 = buffer[NBUFS-1].dol;
-	if(addr1 > addr2){
-		error('$');
-		return;
-	}
-	if((io = creat(filea(), 0644)) < 0)
-		error('o'|FILERR);
-	putfile();
-	exfile();
-	if((fi = creat(fileb(), 0644)) < 0)
-		error('o'|FILERR);
-	if (write(fi, (char *)buffer, sizeof buffer) < 0)
-		error('w'|FILERR);
-	if (savestring(fi) < 0)
-		error('w'|FILERR);
-	close(fi);
-	unlock(NULL);
-}
-
-static void
-restor(void)
-{
-	int t;
-	struct buffer *b;
-	Line *oz, *nz;
-	int fi;
-
-	curbuf = buffer;
-	oz = curbuf->zero;
-	if((t = open(filea(), 0)) < 0){
-		lastc = '\n';
-		error('o'|FILERR);
-	}
-	initio();
-	init();
-	io = t;
-	ninbuf = 0;
-	append(getfile, dol);
-	exfile();
-	if((fi = open(fileb(),0)) < 0)
-		error('o'|FILERR);
-	lock();
-	if(read(fi,(char *)buffer,sizeof buffer) != sizeof buffer
-	|| reststring(fi) < 0)
-		error('R');
-	close(fi);
-	/*
-	 * fixup line addresses to match current core contents
-	 */
-	nz = buffer[0].zero;
-	if(oz != nz){
-		t = oz - nz;
-		for(b = buffer;b <= &buffer[NBUFS-1];b++){
-			b->zero += t;
-			b->dot += t;
-			b->dol += t;
-		}
-	}
-	newbuf(0);
-	error(0);	/* ==> error, but don't print anything. calls unlock() 
-*/
-}
-
-/*
- *	On INTR, generate error '?'
- */
-
-static Sigret
-interrupt(s)
-int s;
-{
-	signal(SIGINT, interrupt);
-	if (intrlock) {
-		pending = interrupt;
-		return;
-	}
-	if(iflag){
-		unlink(tfname);
-		exit(SIGINT);
-	}
-	outreset();
-	qputchar('\n');
-	lastc = '\n';
-	error('?');
-}
-
-/*
- * lock a critical section
- * interrupts will just store themselves in pending
- */
-void
-lock(void)
-{
-	intrlock++;
-}
-
-/*
- * Unlock: exit a critical section, invoking any pending signal routines.
- * f is a cleanup routine supplied by the caller
- */
-void
-unlock(void (*f)(void))
-{
-	Sigtype p;
-
-	p = pending;
-	pending = 0;
-	intrlock = 0;
-	if (p) {
-		if (f)
-			(*f)();
-		(*p)();
-	}
-}
-
-static jmp_buf errjmp;
-
-/*
- * why all the casts? because Sigtype might be slightly wrong
- */
-static Sigtype onintr, onhup, onquit;
-
-int
-main(int argc, char **argv)
-{
-	int i;
-	int rvflag;
-	char *startup=(char *)0;
-
-	argv++;
-	argc--;		/* beware: argc and argv adjusted */
-	onquit = (Sigtype)signal(SIGQUIT, SIG_IGN);
-	onhup = (Sigtype)signal(SIGHUP, SIG_IGN);
-	onintr = (Sigtype)signal(SIGINT, SIG_IGN);
-	rvflag = 1;
-	for(i=0;i!=NSTRING;i++){
-		string[i].str = nullstr;
-		string[i].len=0;
-	}
-	/* initialize strfree */
-	string[NSTRING].str = strchars;
-	for (i = 0; i < NBUFS; i++)
-		names[i] = -1;		/* not a real line */
-	while(argc > 0 && **argv=='-'){
-		switch(argv[0][1]){
-		casedefault:
-		default:
-			rvflag = 0;
-			break;
-		case 'q':
-		/* allow debugging quits? */
-			signal(SIGQUIT, SIG_DFL);
-			break;
-		case 'i':
-		/* allow interrupt quits? */
-			iflag++;
-			break;
-		case 'e':
-		/* Exit on error? */
-			eflag++;
-			break;
-		case 'x':
-			if(argc == 1)
-				goto casedefault;
-			startup = argv[1];
-			argv++;
-			--argc;
-		}
-		argv++;
-		--argc;
-	}
-	if(startup==0)
-		startup = getenv("QEDFILE");
-	fendcore = (Line *)sbrk(0);
-	curbuf = &buffer[0];
-	init();
-	/*
-	 * Build the initialization code in z~
-	 * - if there's a startup file, read and execute
-	 * - G/^[abcdef....].+\t./r to read in files
-	 * - set to buffer a, zap the startup code
-	 * install arguments as filenames for buffers,
-	 * rather than as literals in the startup string,
-	 * to save space and to allow startup buffers
-	 * to read the arguments for other purposes
-	 */
-	startstring();
-	if (startup) {
-		copystring("b~ r ");
-		copystring(startup);
-		copystring("\n\\b~\n");
-	}
-	copystring("ov");
-	addstring("rs"[rvflag]);
-	if (argc > 0) {
-		if (argc > 26+26) {	/* buffers a-zA-Z */
-			qputs("?i");	/* too early for real errors */
-			argc = 0;
-		} else {
-			copystring("G/^[");
-			for (i = 0; i < argc; i++)
-				addstring(bname[i]);
-			copystring("].+\t./r\n");
-		}
-	}
-	copystring("ba z~:\n");
-	setstring(NBUFS-1);
-	for (i = 0; i < argc; i++) {
-		startstring();
-		copystring(argv[i]);
-		setstring(FILE(i));
-	}
-	pushinp(STRING, NBUFS-1, (char *)0, FALSE);
-	/*
-	 * return here on errors
-	 * signals reset every time mostly because |<>!
-	 * might have left SIGINT ignored
-	 */
-	setjmp(errjmp);	/* return here on errors */
-	if (onhup != (Sigtype)SIG_IGN)
-		signal(SIGHUP, rescue);
-	if (onintr != (Sigtype)SIG_IGN)
-		signal(SIGINT, interrupt);
-	lastttyc = '\n';
-	commands();
-	unlink(tfname);
-	return(lasterr);
-}
-
-/*
- * restart at command level after an error
- */
-void
-reset(void)
-{
-	longjmp(errjmp, 0);
-}
-
-/*
- * restore signals we changed
- * called before calling another program
- */
-void
-restorsig(void)
-{
-	signal(SIGINT, onintr);
-	signal(SIGQUIT, onquit);
-	signal(SIGHUP, onhup);
-}
-
-int	noaddr;
-
-void
-commands(void)
-{
-	Line *a;
-	int c, lastsep;
-	int r;
-	int changed;
-	long locn;
-	int startline;
-
-	for (;;) {
-	startline = (lastttyc == '\n' && peekc == 0);
-	cprflag=prflag;
-	c = '\n';
-	for (addr1=0;;) {
-		lastsep = c;
-		a=address();
-		c=getchar();
-		if (c!=',' && c!=';')
-			break;
-		if (lastsep==',')
-			error('a');
-		if (a==0) {
-			a = zero+1;
-			if (a>dol)
-				--a;
-		}
-		addr1 = a;
-		if (c==';')
-			dot = a;
-	}
-	if (lastsep!='\n' && a==0)
-		a=dol;
-	if((addr2=a) == 0) {
-		addr2=dot;
-		noaddr = TRUE;
-	} else
-		noaddr = FALSE;
-
-	if(addr1 == 0)
-		addr1 = addr2;
-
-	cprflag=FALSE;
-	switch(c){
-	case 'a':
-		setdot();
-		setapp();
-		append(gettty, addr2);
-		continue;
-	case 'b':
-		if(posn((c=nextchar()), bname)<0){	/* browse command */
-			setdot();
-			nonzero();
-			bcom();
-			continue;
-		}
-		c = getaz('b', 1);
-		setnoaddr();
-		chngbuf(c);
-		continue;
-	case 'c':
-		setdot();
-		nonzero();
-		setapp();
-		append(gettty, addr2);
-		a = dot-(addr2-addr1+1);
-		delete();
-		dot = a;
-		continue;
-	case 'd':
-		if(posn(nextchar(),"\377\npPlL \t") < 0)
-			error('x');
-		delete();
-		continue;
-	case 'E':
-	case 'e':
-		setnoaddr();
-		if(c=='e' && !eok && cflag){
-			eok=TRUE;
-			error('e');
-		}
-		newfile(TRUE, SAVEALWAYS, "");
-		delall();
-		addr1 = zero;
-		addr2 = zero;
-		cflag = FALSE;
-		goto caseread;
-	case 'f':
-		setnoaddr();
-		if((c = getchar()) != '\n'){
-			ungetchar(c);
-			if(newfile(FALSE, SAVEALWAYS, string[savedfile].str))
-				modified();
-			if(vflag)
-				ncom('f');
-		}
-		else
-			ncom('f');
-		continue;
-	case 'g':
-		global(TRUE);
-		continue;
-	case 'G':
-		globuf(TRUE);
-		continue;
-	case 'h':
-		setnoaddr();
-		if(nextchar()=='\n')
-			error('x');
-		if('0'<=peekc && peekc<='9')
-			until(TRUE, getnum());
-		else
-			until(FALSE, 0);
-		continue;
-	case 'i':
-		setdot();
-		nonzero();
-		setapp();
-		append(gettty, addr2-1);
-		continue;
-	case 'j':
-		setdot();
-		if (addr1 == addr2 && lastsep == '\n'){
-			addr1--;
-			if(addr1 <= zero)
-				error('$');
-		}
-		nonzero();
-		join();
-		continue;
-	case 'k':
-		c = getaz(c, 0);
-		setdot();
-		nonzero();
-		names[c] = addr2->offset;	/* shouldn't know offset */
-		continue;
-	case 'm':
-		move(FALSE);
-		continue;
-	case 'n':
-	case 'N':
-		ncom(c);
-		continue;
-	case 'o':
-		setnoaddr();
-		c = getchar();
-		r=posn(c, opcs);
-		if(r >= 0)
-			setreset(option[r]);
-		else switch(c) {
-		case 'B':
-			if(nextchar() == '\n')
-				clearstring(BROWSE);
-			else {
-				startstring();
-				while((c=getchar()) != '\n')
-					addstring(c);
-				copystring("\\N");
-				setstring(BROWSE);
-			}
-			break;
-		case '?':
-			if ((r = posn(getchar(), opcs)) < 0)
-				error('O');
-			settruth(*option[r]);
-			break;
-		case 'q':
-			c = getchar();
-			if (c == 's')
-				signal(SIGQUIT, SIG_DFL);
-			else if (c == 'r')
-				signal(SIGQUIT, SIG_IGN);
-			else
-				error('x');
-			break;
-		case 'u':
-			c = getchar();
-			if(c == 'r')
-				uflag = 0;
-			else if(posn(c, "slu") >= 0)
-				uflag = c;
-			else
-				error('x');
-			break;
-		case 'b':
-			if((r=getnum()) > 0)
-				pagesize = r;
-			if(posn(nextchar(), lchars) >=0)
-				bformat = getchar();
-			break;
-		default:
-			error('x');
-		}
-		continue;
-	case '\n':
-		if (a==0) {
-			if(stackp != &stack[0] || !startline)
-				continue;
-			if(*string[BROWSE].str){
-				pushinp(BRWS, 0, (char *)0, FALSE);
-				continue;
-			}
-			a = dot+1;
-			addr2 = a;
-			addr1 = a;
-		}
-		if (lastsep==';')
-			addr1 = a;
-		c = 'p';
-		/* fall through */
-	case 'L':
-	case 'l':
-	case 'p':
-	case 'P':
-		display(c);
-		continue;
-	case EOF:
-		return;
-	case 'Q':
-	case 'q':
-		setnoaddr();
-		if(c!=EOF && (!startline || getchar()!='\n'))
-			error('x');
-		if(c!='Q' && !qok){
-			struct buffer *bp;
-			syncbuf();
-			qok=TRUE;
-			for(bp=buffer; bp<&buffer[NBUFS]; bp++)
-				if(bp->cflag && (bp->dol>bp->zero ||
-					string[FILE(bp-buffer)].str[0]))
-					error('q');
-		}
-		unlink(tfname);
-		exit(lasterr);
-		break;
-	case 'r':
-		newfile(TRUE, SAVEIFFIRST, string[savedfile].str);
-	caseread:
-		if((io = open(string[FILEBUF].str, 0)) < 0){
-			if(initflag){
-				qputchar('?');
-				qputchar('o');
-				qputchar(' ');
-				qputs(string[FILEBUF].str);
-				continue;
-			}
-			lastc = '\n';
-			error('o'|FILERR);
-		}
-		setall();
-		changed = (zero!=dol);
-		ninbuf = 0;
-		append(getfile, addr2);
-		if(eqstr(string[savedfile].str, string[FILEBUF].str))
-			if((cflag = changed) != 0)
-				modified();
-		/* else append got cflag right */
-		exfile();
-		continue;
-	case 'R':
-		setnoaddr();
-		newfile(TRUE, SAVENEVER, "q");
-		restor();
-		continue;
-	case 's':
-		setdot();
-		nonzero();
-		substitute(stackp != &stack[0], -1);
-		continue;
-	case 'S':
-		setnoaddr();
-		newfile(TRUE, SAVENEVER, "q");
-		savall();
-		continue;
-	case 't':
-		move(TRUE);
-		continue;
-	case 'u':
-		setnoaddr();
-		undo();
-		modified();
-		continue;
-	case 'v':
-		global(FALSE);
-		continue;
-	case 'V':
-		globuf(FALSE);
-		continue;
-	case 'W':
-	case 'w':
-		if(addr2==0 && dol==zero)
-			error('$');
-		setall();
-		if(newfile(TRUE, SAVEIFFIRST, string[savedfile].str))
-			changed = cflag;
-		else
-			changed = (addr1>(zero+1) || addr2!=dol);
-		if(c=='w' || (io=open(string[FILEBUF].str,1))==-1){
-		  Create:
-			if ((io = creat(string[FILEBUF].str, 0666)) < 0)
-				error('o'|FILERR);
-		}else{
-			if((locn=lseek(io, 0L, 2)) == -1L)
-				goto Create;
-			if(locn != 0L)	/* W on non-empty file */
-				changed = TRUE;	/* PHEW! figured it out */
-		}
-		putfile();
-		if((cflag = changed) != 0)
-			modified();
-		exfile();
-		continue;
-	case 'x':
-		setdot();
-		nonzero();
-		xform();
-		continue;
-	case 'y':
-		jump();
-		continue;
-	case 'z':
-		strcom(getaz('z', 0));
-		continue;
-	case 'Z':
-		setnoaddr();
-		if((c=getchar())!=' ' && c!='\n')
-			error('x');
-		delall();
-		cflag=FALSE;
-		clearstring(savedfile);
-		continue;
-	case '"':
-		setdot();
-		dot=addr2;
-		comment();
-		continue;
-	case '=':
-		setall();
-		qputlong((unsigned long)(addr2-zero));
-		qputchar('\n');
-		continue;
-	case '>':
-	case '<':
-	case '|':
-		setall();
-		/* fall through */
-	case '!':
-		Unix(c);
-		continue;
-	case '#':
-		setnoaddr();
-		allnums();
-		continue;
-	case '%':
-		setnoaddr();
-		allstrs();
-		continue;
-	}
-	error('x');
-	}
-}
-
-static void
-setreset(int *opt)
-{
-	int c;
-
-	c = getchar();
-	if(c!='s' && c!= 'r')
-		error('x');
-	*opt = (c=='s');
-}
-
-static void
-delall(void)
-{
-	if(dol!=zero){
-		addr1=zero+1;
-		addr2=dol;
-		delete();
-	}
-}
//GO.SYSIN DD main.c
echo misc.c 1>&2
sed 's/.//' >misc.c <<'//GO.SYSIN DD misc.c'
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include "vars.h"
-
-int lasterr;
-
-/* forward */
-static void canttmp(char *, char *);
-
-/*
- * optimization
- * to speed up append;
- * noticeable mainly when reading a file
- */
-static int pendfix;
-
-static void
-bufinit(Line *n)
-{
-	struct buffer *bufp;
-	Line *fend;
-
-	fend=n;
-	for(bufp=buffer;bufp!=buffer+NBUFS;bufp++){
-		bufp->zero=fend;
-		bufp->dot=fend;
-		bufp->dol=fend;
-		bufp->cflag = FALSE;
-	}
-}
-
-void
-chngbuf(int bb)
-{
-	syncbuf();
-	newbuf(bufname(bb));
-	savedfile = FILE(curbuf-buffer);
-}
-
-static int prevbuf = 0;	/* a at start */
-
-/*
- * fixbufs call protects us in case
- * input stream for append contains \b
- */
-int
-bufname(int bb)
-{
-	int nb;
-	struct buffer *bp;
-
-	if (pendfix)
-		fixbufs(0, 1);
-	if (bb < NBUFS)
-		return (bb);
-	if (bb == PREVBUF)
-		return (prevbuf);
-	if (bb == NEWBUF)
-		for (nb = 0, bp = buffer; nb < NBUFS; nb++, bp++)
-			if (bp->zero >= bp->dol && string[FILE(nb)].str[0] == 0)
-				return (nb);
-	error('B');
-	/* NOTREACHED */
-	return (bb);	/* calm the compiler */
-}
-
-void
-newbuf(int bb)
-{
-
-	if (bb != curbuf - buffer)
-		prevbuf = curbuf - buffer;
-	curbuf = buffer+bb;
-	zero=curbuf->zero;
-	dot=curbuf->dot;
-	dol=curbuf->dol;
-	cflag = curbuf->cflag;
-}
-
-/*
- * beware--should be called only when locked
- */
-
-void
-fixbufs(int n, int force)
-{
-	struct buffer *bufp;
-
-	pendfix += n;
-	if (force == 0 || pendfix == 0)
-		return;
-	for(bufp = curbuf+1; bufp != buffer+NBUFS; bufp++) {
-		bufp->zero += pendfix;
-		bufp->dot += pendfix;
-		bufp->dol += pendfix;
-	}
-	pendfix = 0;
-}
-
-void
-syncbuf(void)
-{
-/*	curbuf->zero = zero;	*/	/* never changed once initialized */
-	curbuf->dot=dot;
-	curbuf->dol=dol;
-	curbuf->cflag = cflag!=FALSE;	/* Normalize to fit in a char */
-}
-
-void
-error(int code)
-{
-	unlock(NULL);
-	if(code){
-		for(;stackp != stack ;--stackp)
-			if(stackp->type == BUF || stackp->type == STRING){
-				qputchar('?');
-				if(stackp->type == BUF){
-					qputchar('b');
-					qputchar(bname[stackp->bufptr - buffer]);
-					qputlong((unsigned long)stackp->lineno);
-					qputchar('.');
-				}else{
-					qputchar('z');
-					qputchar(bname[stackp->lineno]);
-				}
-				qputlong((unsigned long)stackp->charno);
-				qputchar(' ');
-			}
-		qputchar('?');
-		qputchar(lasterr=(code&~FILERR));
-		if(code&FILERR){
-			qputchar(' ');
-			qputl(string[FILEBUF].str);
-		} else
-			qputchar('\n');
-	}
-	if(eflag && code)
-		exit(code);
-	nestlevel = 0;
-	listf = FALSE;
-	gflag = FALSE;
-	biggflag = FALSE;
-	stackp = stack;
-	peekc = 0;
-	if(code && code!='?'){		/* if '?', system cleared tty input buf 
-*/
-		while(lastttyc!='\n' && lastttyc!=EOF){
-			getchar();
-		}
-	}
-	lseek(0, 0L, 2);
-	if (io > 0) {
-		close(io);
-		io = -1;
-		cflag = TRUE;	/* well, maybe not, but better be safe */
-	}
-	appflag=0;
-	reset();
-}
-
-extern char digits[];
-
-#define	TFUDGE	8	/* room for PID in decimal */
-#define	TMPDIR	50	/* max size of tmp dir name */
-char tfname[TMPDIR+2+TFUDGE+1];	/* $TMPDIR 'q' '/' TFUDGE '\0' */
-int tfile = -1;
-int tfile2;
-
-/*
- * two tmpfile descriptors because of the | command:
- * with only one descriptor, two processes are seeking and reading/writing
- * the same (shared) fd in parallel, and there may be races
- * see getfile.c/Unix
- */
-void
-init(void)
-{
-	char *p, *q;
-	int pid;
-	int n;
-
-	lock();
-	if (tfile > 0)
-		close(tfile);
-	if ((p = getenv("TMPDIR")) == (char *)0)
-		p = "/tmp";
-	if ((n = strlen(p)) > TMPDIR)
-		canttmp("$TMPDIR too long", (char *)0);	/* just use /tmp 
-instead? */
-	strcpy(tfname, p);
-	p = tfname + n;
-	*p++ = '/';
-	*p++ = 'q';
-	pid = getpid();
-	for (q = p + TFUDGE - 1; q >= p; q--) {
-		*q = digits[pid%10];
-		pid /= 10;
-	}
-	if ((n = creat(tfname, 0600)) < 0)
-		canttmp("creat failed", tfname);
-	close(n);
-	if ((tfile = open(tfname, 2)) < 0
-	||  (tfile2 = open(tfname, 2)) < 0)
-		canttmp("reopen failed", tfname);
-	brk(fendcore);
-	bufinit(fendcore);
-	newbuf(0);
-	lastdol=dol;
-	endcore = fendcore - 2;
-	stackp=stack;
-	stackp->type=TTY;
-	unlock(NULL);
-}
-
-static void
-canttmp(char *s1, char *s2)
-{
-	strcpy(linebuf, "can't make tempfile: ");
-	if (s2) {
-		strcat(linebuf, s2);
-		strcat(linebuf, ": ");
-	}
-	strcat(linebuf, s1);
-	strcat(linebuf, "\n");
-	write(2, linebuf, strlen(linebuf));
-	exit(1);
-}
-
-void
-comment(void)
-{
-	int c, mesg;
-
-	c = getchar();
-	mesg = 0;
-	if(c == '\"') {
-		mesg++;
-		c = getchar();
-	}
-	while(c != '\n' && c != '\"') {
-		if(mesg)
-			qputchar(c);
-		c = getchar();
-	}
-	if(mesg) {
-		if(c == '\n')
-			qputchar(c);
-		flush();
-	}
-}
-
-/*
- * Slow, but avoids garbage collection
- */
-void
-settruth(int t)
-{
-	if(atoi(string[TRUTH].str) != t)
-		numset(TRUTH, t);
-}
-
-void
-setcount(int c)
-{
-	if(atoi(string[COUNT].str) != c)
-		numset(COUNT, c);
-}
-
-int
-truth(void)
-{
-	return(atoi(string[TRUTH].str) != FALSE);
-}
-
-void
-modified(void)
-{
-	cflag=TRUE;
-	eok=FALSE;
-	qok=FALSE;
-}
//GO.SYSIN DD misc.c
echo move.c 1>&2
sed 's/.//' >move.c <<'//GO.SYSIN DD move.c'
-#include <stddef.h>
-#include "vars.h"
-
-/* forward */
-static int getcopy(void);
-static void fixup(int, int, int);
-static void reverse(Line *, Line *);
-
-void
-move(int copyflag)
-{
-	Line *adt, *ad1, *ad2;
-	int fb, tb;
-	int todot;
-	int tonewdot;
-	int totmved;
-	int temp;
-
-	setdot();
-	nonzero();
-	fb = curbuf - buffer;
-	temp = getchar();
-	tb = posn(temp, bname);
-	if(tb >= 0) {
-		chngbuf(tb);
-		tb = curbuf - buffer;	/* in case of : or @ magic */
-	} else {
-		ungetchar(temp);
-		tb = fb;
-	}
-	if ((adt = address())==0){
-		chngbuf(fb);
-		error('x');
-	}
-	todot = adt - buffer[tb].zero;	/* syncbuf not needed! */
-	chngbuf(fb);
-	ad1 = addr1;
-	ad2 = addr2;
-	totmved = ad2 - ad1 + 1;
-	lock();
-	if (copyflag) {
-		tonewdot = addr2 - buffer[fb].zero;
-		/*
-		 * NOTE: in the copy command
-		 *	copies of the lines are created using append
-		 *	and then moved to the target position.
-		 *	They are appended at the dollar of their
-		 *	original buffer. (guarenteed to be higher address)
-		 *	They are NOT appended at the target position
-		 *	since, if the target position was lower than their
-		 *	source position, getcopy would have to account
-		 *	for the shift of the addresses due to the insert
-		 *	of the copies.
-		 */
-		ad1 = dol;
-		temp = cflag;
-		append(getcopy, ad1++);
-		cflag = temp;
-		ad2 = dol;
-	} else
-		tonewdot = addr1 - buffer[fb].zero - 1;
-	ad2++;
-	adt = buffer[tb].zero + todot;
-	chngbuf(tb);
-	if (adt<ad1) {
-		if ((++adt)!=ad1){
-			reverse(adt, ad1);
-			reverse(ad1, ad2);
-			reverse(adt, ad2);
-		}
-	} else {
-		if (adt++ >= ad2) {
-			reverse(ad1, ad2);
-			reverse(ad2, adt);
-			reverse(ad1, adt);
-		} else {
-			if(ad2 != zero + 1){
-				error('m');
-			}
-		}
-	}
-	fixup(fb, tb, totmved);
-	buffer[fb].dot = buffer[fb].zero + tonewdot;
-	if(copyflag == 0 && fb == tb && todot >= tonewdot){
-		todot -= totmved;
-	}
-	if(!copyflag)
-		buffer[fb].cflag = TRUE;
-	modified();
-	dot = buffer[tb].dot = buffer[tb].zero + todot + totmved;
-	zero = buffer[tb].zero;
-	dol = buffer[tb].dol;
-	unlock(NULL);
-}
-
-static void
-fixup(int from, int to, int tot)
-{
-	int b;
-	int n;
-	int lo;
-	int hi;
-	if(to == from){
-		return;
-	}
-	if(to < from){
-		n = tot;
-		lo = to;
-		hi = from;
-	} else {
-		n = -tot;
-		lo = from;
-		hi = to;
-	}
-	buffer[lo].dol += n;
-	for(b = lo;++b < hi;){
-		buffer[b].zero += n;
-		buffer[b].dot += n;
-		buffer[b].dol += n;
-	}
-	buffer[hi].zero += n;
-}
-
-static void
-reverse(Line *a1, Line *a2)
-{
-	Line t;
-
-	for (;;) {
-		t = *--a2;
-		if (a2 <= a1)
-			return;
-		*a2 = *a1;
-		*a1++ = t;
-	}
-}
-
-static int 
-getcopy(void)
-{
-	if (addr1 > addr2)
-		return(EOF);
-	getline(*addr1++, linebuf);
-	return(0);
-}
//GO.SYSIN DD move.c
echo pattern.c 1>&2
sed 's/.//' >pattern.c <<'//GO.SYSIN DD pattern.c'
-#include "vars.h"
-#include <ctype.h>
-
-char *loc1, *loc2;
-char *braslist[NBRA];
-char *braelist[NBRA];
-int nbra;
-
-#define ESIZE	128	/* ESIZE-1 must fit in a signed byte */
-static char	expbuf[ESIZE+4];
-static int	expgood	/*0*/;		/* flag indicating if compiled exp is 
-good */
-#define	CCHR	2
-#define	CDOT	4
-#define	CCL	6
-#define	NCCL	8
-#define CFUNNY	10
-#define	CALT	12
-#define	CBACK	14
-
-#define	STAR	01
-#define STARABLE CBACK
-
-#define	CKET	16
-#define	CDOL	17
-#define	CEOF	18
-#define	CBRA	19
-#define CBOI	20
-#define CEOI	21
-#define CSPACE	22
-static int	circfl;
-static char	pmagic[] = "/.$^*+\\()<|>{}[!_123456789";
-
-/* forward */
-static int advance(char *, char *);
-static int backref(int, char *);
-static int alfmatch(int, int);
-static int cclass(char *, int, int);
-
-void
-compile(int eof)
-{
-	int c;
-	char *ep, *penultep;
-	char *lastep, *bracketp, bracket[NBRA];
-
-	struct{
-		char	*althd;		/* start of code for < ... > */
-		char	*altlast;	/* start of code for last < or | */
-		char	*bpstart;	/* bracketp at start of < and | */
-		char	*bpend;		/* bracketp at end of > or | */
-		int	nbstart;	/* nbra at start of < and | */
-		int	nbend;		/* nbra at end of > or | */
-		int	firstalt;	/* is this the first alternative? */
-	} *asp, altstk[NBRA];
-
-	if(eof == '\n')
-		error('x');
-	pmagic[0] = eof;
-	if ((c=nextchar()) == eof || c=='\n') {
-		if (!expgood)
-			goto cerror;
-		if(c!='\n')
-			getchar();	/* eat the eof character */
-		return;
-	}
-	expgood = FALSE;
-	ep = expbuf;
-	lastep = 0;
-	bracketp = bracket;
-	nbra = 0;
-	asp = altstk - 1;
-	startstring();	/* for the saved pattern */
-	circfl = 0;
-	if (c=='^') {
-		getsvc();	/* save the caret */
-		circfl++;
-	}
-	for (;;) {
-		c = getquote(pmagic, getsvc);
-		if (c==eof || c=='\n') {
-			if (bracketp!=bracket || asp>=altstk)
-				goto cerror;
-			*ep++ = CEOF;
-			expgood = TRUE;
-			dropstring();	/* lose the eof character */
-			setstring(SAVPAT);
-			if(c=='\n')
-				ungetchar(c);
-			return;
-		}
-		if (ep >= &expbuf[ESIZE-5])
-			goto cerror;
-		penultep = lastep;
-		lastep = ep;
-
-		if(c != (eof|0200)) switch (c) {
-		case '('|0200:
-			if (nbra >= NBRA)
-				goto cerror;
-			*bracketp++ = nbra;
-			*ep++ = CBRA;
-			*ep++ = nbra++;
-			continue;
-		case ')'|0200:
-			if (bracketp <= bracket)
-				goto cerror;
-			*ep++ = CKET;
-			*ep++ = *--bracketp;
-			continue;
-		case '{'|0200:
-			*ep++ = CBOI;
-			continue;
-		case '}'|0200:
-			*ep++ = CEOI;
-			continue;
-		case '_'|0200:
-			*ep++ = CSPACE;
-			continue;
-		case '!'|0200:
-			*ep++ = CFUNNY;
-			continue;
-		case '<':
-			if (++asp >= &altstk[NBRA])
-				goto cerror;
-			*ep++ = CALT;
-			asp->althd = ep;
-			ep++;
-			asp->bpstart = bracketp;
-			asp->nbstart = nbra;
-			asp->firstalt = TRUE;
-			asp->altlast = ep++;
-			lastep = 0;
-			continue;
-		case '|':
-			if (asp<altstk)
-				break;
-			if (asp->firstalt) {
-				asp->bpend = bracketp;
-				asp->nbend = nbra;
-			}
-			if (bracketp!=asp->bpend || nbra!=asp->nbend)
-				goto cerror;
-			*ep++ = CEOF;
-			asp->altlast[0] = ep-asp->altlast;
-			asp->firstalt = FALSE;
-			bracketp = asp->bpstart;
-			nbra = asp->nbstart;
-			asp->altlast = ep++;
-			lastep = 0;
-			continue;
-		case '>':
-			if (asp<altstk)
-				break;
-			if (!asp->firstalt &&
-			    (bracketp!=asp->bpend || nbra!=asp->nbend))
-				goto cerror;
-			*ep++ = CEOF;
-			asp->altlast[0] = ep-asp->altlast;
-			lastep = asp->althd;
-			*lastep = ep-lastep;
-			lastep--;
-			if (bracketp!=asp->bpstart || nbra!=asp->nbstart)
-				lastep = 0;
-			asp--;
-			continue;
-		case '*':
-		case '+':
-			if (penultep==0){
-				*ep++ = CCHR;
-				*ep++ = c;
-			} else {
-				if(*penultep>STARABLE)
-					goto cerror;
-				if(c == '+'){
-					if((ep-penultep)+ep >= &expbuf[ESIZE-1])
-						goto cerror;
-					do
-						*ep++ = *penultep++;
-					while (penultep!=lastep);
-				}
-				*penultep |= STAR;
-				lastep = 0;
-			}
-			continue;
-		case '.':
-			*ep++ = CDOT;
-			continue;
-
-		case '[':
-			penultep = ep;
-			*ep++ = CCL;
-			*ep++ = 0;
-			if ((c=getsvc()) == '^') {
-				c = getsvc();
-				ep[-2] = NCCL;
-			}
-			do {
-				if (c == EOF || c == '\n')
-					goto cerror;
-				*ep++ = c;
-				if ((lastc=getsvc()) == '-') {
-					c=getsvc();
-					if (c == EOF || c == '\n' || c<=ep[-1])
-						goto cerror;
-					ep[-1] |= 0200;
-					*ep++ = c;
-					lastc = getsvc();	/* prime lastc 
-*/
-				} else if (dflag&&'a'<=(c|' ')&&(c|' ')<='z')
-					*ep++ = c^' ';
-				if (ep >= &expbuf[ESIZE-1])
-					goto cerror;
-			} while ((c=lastc) != ']');
-			penultep[1] = ep-penultep-1;
-			continue;
-
-
-		case '$':
-			if (nextchar() == eof || peekc=='\n') {
-				*ep++ = CDOL;
-				continue;
-			}
-			/* fall through */
-		default:
-			break;
-		}
-		/* if fell through switch, match literal character */
-		/* Goddamned sign extension! */
-		if ((c&0200) && (c&0177)>='1' && (c&0177)<='9') {
-			*ep++ = CBACK;
-			*ep++ = c-('1'|0200);
-			continue;
-		}
-		c &= ~0200;
-		if(dflag && isalpha(c)) {
-			*ep++ = CCL;
-			*ep++ = 3;
-			*ep++ = c;
-			*ep++ = isupper(c) ? tolower(c) : toupper(c);
-		}
-		else{
-			*ep++ = CCHR;
-			*ep++ = c;
-		}
-	}
-   cerror:
-	error('p');
-}
-
-int 
-getsvc(void)
-{
-	int c;
-	addstring(c=getchar());
-	return(c);
-}
-
-int 
-execute(Line *addr)
-{
-	char *p1, *p2;
-
-	if (addr==0) {
-		if((p1=loc2) == 0)	/* G command */
-			p1 = linebuf;
-		else if (circfl)	/* not first search in substitute */
-			return(FALSE);
-	} else {
-		if (addr==zero)
-			return(FALSE);
-		p1 = getline(*addr, linebuf);
-	}
-	p2 = expbuf;
-	if (circfl) {
-		loc1 = p1;
-		return(advance(p1, p2));
-	}
-	do {
-		if (*p2 != CCHR  ||  p2[1] == *p1) {
-			if (advance(p1, p2)) {
-				loc1 = p1;
-				return(TRUE);
-			}
-		}
-	} while (*p1++);
-	return(FALSE);
-}
-
-static int 
-advance(char *lp, char *ep)
-{
-	char *curlp;
-	char *althd, *altend;
-
-	for (;;) {
-		curlp = lp;
-		switch (*ep++) {
-
-		case CCHR:
-			if (*ep++ == *lp++)
-				continue;
-			return(FALSE);
-
-		case CCHR|STAR:
-			do ; while (*lp++ == *ep);
-			ep++;
-			break;
-
-		case CDOT:
-			if (*lp++)
-				continue;
-			return(FALSE);
-
-		case CDOT|STAR:
-			do ; while (*lp++);
-			break;
-
-		case CCL:
-		case NCCL:
-			if (cclass(ep, *lp++, ep[-1]==CCL)) {
-				ep += *ep;
-				continue;
-			}
-			return(FALSE);
-
-		case CCL|STAR:
-		case NCCL|STAR:
-			do ; while (cclass(ep, *lp++, ep[-1]==(CCL|STAR)));
-			ep += *ep;
-			break;
-
-		case CFUNNY:
-			if (*lp>=' ' && *lp!='\177' || *lp=='\t' || *lp=='\0')
-				return(FALSE);
-			lp++;
-			continue;
-
-		case CFUNNY|STAR:
-			while (*lp<' ' && *lp && *lp!='\t'  ||  *lp=='\177')
-				lp++;
-			lp++;
-			break;
-
-		case CBACK:
-			if (braelist[*ep]==0)
-				error('p');
-			if (backref(*ep++, lp)) {
-				lp += braelist[ep[-1]] - braslist[ep[-1]];
-				continue;
-			}
-			return(FALSE);
-	
-		case CBACK|STAR:
-			if (braelist[*ep] == 0)
-				error('p');
-			curlp = lp;
-			while (backref(*ep, lp))
-				lp += braelist[*ep] - braslist[*ep];
-			while (lp >= curlp) {
-				if (advance(lp, ep+1))
-					return(TRUE);
-				lp -= braelist[*ep] - braslist[*ep];
-			}
-			ep++;
-			continue;
-
-		case CBRA:
-			braslist[*ep++] = lp;
-			continue;
-
-		case CKET:
-			braelist[*ep++] = lp;
-			continue;
-
-		case CDOL:
-			if (*lp==0)
-				continue;
-			return(FALSE);
-
-		case CEOF:
-			loc2 = lp;
-			return(TRUE);
-
-		case CBOI:
-			if (alfmatch(*lp,0)
-			    && (lp==linebuf || !alfmatch(lp[-1],1)))
-				continue;
-			return(FALSE);
-
-		case CEOI:
-			if (!alfmatch(*lp,1)
-			    && lp!=linebuf && alfmatch(lp[-1],1))
-				continue;
-			return(FALSE);
-
-		case CSPACE:
-			if (*lp==' ' || *lp=='\t') {
-				while (*lp == ' ' || *lp=='\t')
-					lp++;
-				continue;
-				}
-			return(FALSE);
-
-		case CALT:
-			althd = ep-1;
-			altend = ep + *ep;
-			for(ep++; ; ep+= *ep) {
-				if(ep == altend)
-					return(FALSE);
-				if(advance(lp,ep+1) && advance(loc2,altend))
-					return(TRUE);
-			}
-
-		case CALT|STAR:
-			althd = ep-1;
-			altend = ep + *ep;
-			for(ep++; ep!=altend; ep+= *ep){
-				if(advance(lp, ep+1)){
-					if(loc2 == lp)
-						break;
-					if(advance(loc2, althd))
-						return(TRUE);
-				}
-			}
-			/* return (advance(lp,altend)) */
-			continue;
-
-		default:
-			error('!');
-		}
-		/* star logic: executed by falling out of switch */
-		do {
-			lp--;
-			if (advance(lp, ep))
-				return(TRUE);
-		} while (lp > curlp);
-		return(FALSE);
-	}
-}
-
-static int 
-backref(int i, char *lp)
-{
-	char *bp;
-
-	bp = braslist[i];
-	while (*bp++ == *lp++)
-		if (bp >= braelist[i])
-			return(TRUE);
-	return(FALSE);
-}
-
-static int 
-alfmatch(int c, int tail)
-{
-	return (('a' <= c && c <= 'z')  ||
-		('A' <= c && c <= 'Z')  ||
-		(c == '_') ||
-		(tail && '0' <= c && c<= '9'));
-}
-
-static int 
-cclass(char *set, int c, int f)
-{
-	int n;
-	if (c == 0)
-		return(0);
-	n = *set++;
-	while (--n) {
-		if (*set&0200) {
-			if ((*set++ & 0177) <= c) {
-				if (c <= *set++)
-					return(f);
-			} else
-				set++;
-			--n;
-		} else if (*set++ == c)
-			return(f);
-	}
-	return(!f);
-}
//GO.SYSIN DD pattern.c
echo putchar.c 1>&2
sed 's/.//' >putchar.c <<'//GO.SYSIN DD putchar.c'
-#include <stdlib.h>
-#include <unistd.h>
-#include "vars.h"
-
-static char line[512];	/* output buffer */
-static char *linp = line;	/* current pos in buffer */
-static int col;
-
-int listf;
-
-void
-qputlong(unsigned long i)
-{
-	int r;
-	r = i%10;
-	i /= 10;
-	if(i)
-		qputlong(i);
-	qputchar('0'+r);
-}
-
-void
-qputl(char *sp)
-{
-	listf++;
-	qputs(sp);
-	listf = FALSE;
-}
-
-void
-qputs(char *sp)
-{
-	col = 0;
-	while (*sp)
-		qputchar(*sp++);
-	qputchar('\n');
-}
-
-void
-display(int lf)
-{
-	Line *a1;
-	unsigned long r;
-	char *p;
-	int i;
-	int nf;
-
-	listf = (lf == 'l' || lf == 'L');
-	nf = (lf == 'P' || lf == 'L');
-	lf = listf;
-	setdot();
-	nonzero();
-	a1 = addr1;
-	r = (unsigned long)(a1 - zero);
-	do{
-		col = 0;
-		if(nf){
-			qputlong(r++);
-			for(i=0; i<NBUFS; i++)
-				if(a1->offset == names[i]){
-					qputchar('\'');
-					qputchar(bname[i]);
-				}
-			listf = 0;
-			qputchar('\t');
-			col = 8;
-			listf = lf;
-		}
-		for(p = getline(*a1++,linebuf);*p;qputchar(*p++))
-			;
-		qputchar('\n');
-	} while (a1 <= addr2);
-	dot = addr2;
-	listf = FALSE;
-}
-
-void
-qputct(int c)
-{
-	qputchar(c);
-	qputchar('\t');
-}
-
-/*
- * print a character;
- * complicated because the l stuff happens here
- */
-void
-qputchar(int c)
-{
-	char *lp;
-
-	lp = linp;
-	if (listf) {
-		if (c=='\n') {
-			if(linp!=line && linp[-1]==' ') {
-				*lp++ = '\\';
-				*lp++ = 'n';
-			}
-		} else {
-			if (col >= (72-4-2)) {
-				*lp++ = '\\';
-				*lp++ = '\n';
-				*lp++ = '\t';
-				col = 8;
-			}
-			col++;
-			if (c=='\b' || c=='\\' || c=='\t') {
-				*lp++ = '\\';
-				c = c=='\b'? 'b' : c=='\t'? 't' : '\\';
-				col++;
-			} else if ((c&0200) || c<' ' || c=='\177') {
-				*lp++ = '\\';
-				*lp++ = ((c>>6)&03)+'0';
-				*lp++ = ((c>>3)&07)+'0';
-				c     = ( c    &07)+'0';
-				col += 3;
-			}
-		}
-	}
-	*lp++ = c;
-	if(c == '\n' || lp >= &line[(sizeof line)-2-4]) {
-		linp = lp;
-		flush();
-		lp = linp;
-	}
-	linp = lp;
-}
-
-/*
- * force out pending output
- * --what to do if write error?
- */
-void
-flush(void)
-{
-	if(linp != line){
-		(void)write(1, line, linp-line);
-		linp = line;
-	}
-}
-
-/*
- * discard pending output; called after interrupt
- */
-void
-outreset(void)
-{
-	linp = line;
-}
//GO.SYSIN DD putchar.c
echo setaddr.c 1>&2
sed 's/.//' >setaddr.c <<'//GO.SYSIN DD setaddr.c'
-#include "vars.h"
-
-extern int noaddr;
-
-void
-setdot(void)
-{
-	if (addr2 == 0)
-		addr1 = addr2 = dot;
-	if (addr1 > addr2)
-		error('$');
-}
-
-void
-setall(void)
-{
-	if (noaddr) {
-		addr1 = zero+1;
-		addr2 = dol;
-		if (dol==zero)
-			addr1 = zero;
-	}
-	setdot();
-}
-
-void
-setnoaddr(void)
-{
-	if (noaddr == FALSE)
-		error('$');
-}
-
-void
-nonzero(void)
-{
-	if (addr1<=zero || addr2>dol)
-		error('$');
-}
//GO.SYSIN DD setaddr.c
echo string.c 1>&2
sed 's/.//' >string.c <<'//GO.SYSIN DD string.c'
-#include <stddef.h>
-#include <string.h>
-#include "vars.h"
-
-struct string string[NSTRING+1];
-char strarea[NSTRCHARS+2];
-#define	strfree string[NSTRING].str
-static char *strstart;
-
-/* forward */
-static void strcompact(void);
-
-void
-startstring(void)
-{
-	strstart=strfree;
-}
-
-void
-addstring(int c)
-{
-	if(strfree==strchars+NSTRCHARS)
-		strcompact();
-	*strfree++ = c;
-}
-
-void
-dropstring(void)
-{
-	--strfree;
-}
-
-void
-clearstring(int z)
-{
-	string[z].len = 0;
-	string[z].str = nullstr;
-}
-
-void
-copystring(char *s)
-{
-	while(*s)
-		addstring(*s++);
-}
-
-int
-eqstr(char *a, char *b)
-{
-	while(*a)
-		if(*a++ != *b++)
-			return(FALSE);
-	return(*b=='\0');
-}
-
-/*
- * dupstring duplicates a string.
- * Because we may strcompact(), we do it first if necessary.
- */
-void
-dupstring(int z)
-{
-	if(strfree+string[z].len > strchars+NSTRCHARS)
-		strcompact();	/* if insufficient, will get error when we copystring() */
-	copystring(string[z].str);
-}
-
-void
-setstring(int n)
-{
-	addstring('\0');
-	if((string[n].len = strlen(strstart)) == 0)
-		string[n].str = nullstr;
-	else
-		string[n].str = strstart;
-	if(strfree >= strchars + NSTRCHARS)
-		strcompact();
-}
-
-static void
-strcompact(void)
-{
-	struct string *cursor;
-	struct string *thisstr;
-	char *s, *t;
-	lock();
-	s=strchars;
-	for(;;){
-		t=strchars+NSTRCHARS;
-		for(cursor=string;cursor!=string+NSTRING;cursor++)
-			if(s<=cursor->str && cursor->str<t){
-				t = cursor->str;
-				thisstr = cursor;
-			}
-		if(t==strchars+NSTRCHARS)
-			break;
-		thisstr->str=s;
-		do;while(*s++ = *t++);
-	}
-	t=strstart;
-	strstart=s;
-	while(t!=strfree)
-		*s++ = *t++;
-	strfree=s;
-	if(s==strchars+NSTRCHARS){
-		strfree=strstart;
-		error('Z');
-	}
-	unlock(NULL);
-}
-
-/*
- * write the current strings to fd;
- * for S
- */
-int 
-savestring(int fd)
-{
-	struct string *sp;
-	int nw;
-
-	for (sp = string; sp <= string + NSTRING; sp++)
-		sp->str -= strarea - (char *)0;
-	nw = write(fd, (char *)string, sizeof(string));
-	for (sp = string; sp <= string + NSTRING; sp++)
-		sp->str += strarea - (char *)0;
-	if (nw != sizeof(string)
-	||  write(fd, strarea, sizeof(strarea)) != sizeof(strarea))
-		return (-1);
-	return (0);
-}
-
-/*
- * recover the strings from fd, for R
- */
-int 
-reststring(int fd)
-{
-	struct string *sp;
-
-	if (read(fd, (char *)string, sizeof(string)) != sizeof(string)
-	||  read(fd, strarea, sizeof(strarea)) != sizeof(strarea))
-		return (-1);	/* core dump likely now--corrupted string; oh 
-well */
-	for (sp = string; sp <= string + NSTRING; sp++)
-		sp->str += strarea - (char *)0;
-	return (0);
-}
//GO.SYSIN DD string.c
echo subs.c 1>&2
sed 's/.//' >subs.c <<'//GO.SYSIN DD subs.c'
-#include <string.h>
-#include "vars.h"
-
-static char *next_new;
-static char *next_old;
-static char subsbuf[LBSIZE];
-static Line new_line, old_line;
-static char rhsbuf[RHSIZE];
-
-/* forward */
-static void dosub(void);
-static int getsub(void);
-static void place(char *, char *, int);
-static void replace(Line *, Line);
-
-void
-substitute(int inglob, int reg)
-{
-	int n, m;
-	char *p;
-	char *q;
-	Line *a1;
-	int gsubf;
-	int t, count, autop=0;
-
-	count=0;
-	t = FALSE;
-	n=getnum();
-	gsubf = compsub(TRUE, &autop);
-	if(reg!= -1){	/* Substitution in a */
-		strcpy(linebuf, string[reg].str);
-		loc2=0;	/* signal execute to take line from linebuf */
-		a1=0;
-		goto Do_it;
-	}
-	for (a1 = addr1; a1 <= addr2 && reg==-1; a1++) {
-	Do_it:
-		if (execute(a1)) {
-			next_old=linebuf;
-			next_new=subsbuf;
-			m=n;
-			do {
-				if (--m <= 0) {
-					dosub();
-					t = TRUE;
-					count++;
-					if (!gsubf)
-			break;
-				}
-				/* can't find something at EOL twice */
-				if (*loc2=='\0')
-			break;
-				/* can't match same location twice */
-				if (loc1==loc2)
-					loc2++;
-			} while (execute((Line *)0));
-			if (m<=0) {
-				inglob |= TRUE;
-				p=next_old;
-				do ; while (*p++);
-				place(next_old,p,0);
-				if(reg==-1){
-					p=linebuf;
-					q=subsbuf;
-					do ; while (*p++ = *q++);
-					replace(a1,qputline());
-					m=append(getsub,a1);
-					a1 += m;
-					addr2 += m;
-				}else{
-					startstring();
-					copystring(subsbuf);
-					setstring(reg);
-				}
-			}
-		}
-	}
-	if (!inglob)
-		error('s');
-	settruth(t);
-	setcount(count);
-	if(autop)
-		if(reg>=0)
-			qputs(string[reg].str);
-		else{
-			addr1=addr2=dot;
-			display('p');
-		}
-}
-
-int 
-compsub(int subbing, int *autop)
-{
-	int seof, c;
-	char *rhsmagic;
-	char *p;
-	static char rhssub[] = "/&^\n\\123456789";
-	static char rhsnotsub[] = "/\\\n";
-
-	*autop=FALSE;
-	seof = getchar();
-	if(subbing) {
-		compile(seof);
-		rhsmagic = rhssub;
-	}
-	else
-		rhsmagic = rhsnotsub;
-	rhsmagic[0] = seof;
-	p = rhsbuf;
-	startstring();
-	for (;;) {
-		c = getquote(rhsmagic, getsvc);
-		if (c=='\n' || c==EOF){
-			*autop=TRUE;
-			ungetchar('\n');
-			break;
-		}
-		if (c==seof)
-			break;
-		*p++ = c;
-		if (p >= &rhsbuf[RHSIZE])
-			error('l');
-	}
-	*p = 0;
-	dropstring();
-	setstring(SAVRHS);
-	if (subbing && nextchar() == 'g') {
-		getchar();	/* clear 'g' */
-		return(1);
-	}
-	return(0);
-}
-
-static int 
-getsub(void)
-{
-	char *p1, *p2;
-
-	p1 = linebuf;
-	if ((p2 = linebp) == 0)
-		return(EOF);
-	do ; while (*p1++ = (*p2++ & 0177));
-	linebp = 0;
-	return(0);
-}
-
-static void
-dosub(void)
-{
-	int c;
-	char *p;
-
-	place(next_old,loc1,0);
-	next_old=loc2;
-	p=rhsbuf;
-	while ((c = *p++) != 0) {
-		if (c=='&' || (c == '^' && uflag))
-			place(loc1,loc2,c=='^');
-		else if ((c&0200) && (c &= 0177)>='1' && c<'1'+nbra)
-			place(braslist[c-'1'],braelist[c-'1'], 0);
-		else {
-			*next_new++ = c;
-			if (next_new >= subsbuf+LBSIZE)
-				error('l');
-		}
-	}
-}
-
-static void
-place(char *l1, char *l2, int ucase)
-{
-	char *sp;
-	int c;
-
-	sp = next_new;
-	while (l1 < l2) {
-		*sp++ = (*l1++ & 0177);
-		if (sp >= &subsbuf[LBSIZE])
-			error('l');
-	}
-	if(ucase){
-		for(l1 = next_new;l1 < sp;){
-			c = (*l1 & 0177);
-			if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')){
-				switch(uflag){
-				case 's':
-					*l1++ ^= 040;
-					break;
-				case 'u':
-					*l1++ &= ~040;
-					break;
-				case 'l':
-					*l1++ |= 040;
-					break;
-				default:
-					l1++;
-				}
-			}else{
-				l1++;
-			}
-		}
-	}
-	next_new = sp;
-}
-
-void
-undo(void)
-{
-	Line *l;
-
-	for (l=zero+1; l<=dol && l->offset!=new_line.offset; l++)
-		;
-	if (l>dol)
-		error('u');
-	replace(l,old_line);
-	dot=l;
-}
-
-/*
- * the pointer/non-pointer arg mix is historic and should be fixed
- */
-static void
-replace(Line *olp, Line nline)
-{
-	long *p;
-
-	for (p=names; p<names+NBUFS; p++)
-		if (*p == olp->offset)
-			*p = nline.offset;
-	old_line = *olp;
-	*olp = nline;
-	new_line = nline;
-}
-
-void
-join(void)
-{
-	Line *l;
-	char *p, *q;
-	int rep;
-	int autop=FALSE;
-
-	rep=FALSE;
-	if(nextchar() == '/'){
-		compsub(FALSE, &autop);
-		rep=TRUE;
-	}
-	p = subsbuf;
-	for (l=addr1; ;) {
-		q = getline(*l++, linebuf);
-		while (*q) {
-			*p++ = *q++;
-			if (p >= subsbuf + LBSIZE)
-				error('l');
-		}
-		if(l > addr2)
-			break;
-		if(rep) {
-			q = string[SAVRHS].str;
-			while (*q) {
-				*p++ = *q++;
-				if (p >= subsbuf + LBSIZE)
-					error('l');
-			}
-		}
-	}
-	*p = '\0';
-	linebp=p=linebuf;
-	q=subsbuf;
-	do ; while (*p++ = *q++);
-	getsub();
-	*(l=addr1++)=qputline();
-	/*
-	 * if you want marks preserved for join, change the above line to
-	 * the one commented out here.
-	 * problem: undo then undoes the join, but gets it wrong.  Your choice.
-	replace(l=addr1++, qputline());
-	*/
-	if(l != addr2)
-		delete();
-	append(getsub, l);
-	if(autop){
-		addr1=addr2=dot;
-		display('p');
-	}
-}
-
-static int
-next_col(int col, char *cp, int input)
-{
-	int c;
-
-	c = *cp;
-	if (c=='\t')
-		col |= 07;
-	else if (c<' ' || c=='\177')
-		error('t'); /* invalid character in x data */
-	return (++col);
-}
-
-void
-xform(void)
-{
-	char *i, *m, *o;
-	int insert, change, ic, mc, c;
-	Line *line;
-	char *tf, *tl;
-
-	if(getchar() != '\n')
-		error('x');
-	for (line=addr1; line<=addr2; line++) {
-		getline(*line, linebuf);
-		change=FALSE;
-		dot=line;
-		for(;;){
-			qputs(linebuf);
-			pushinp(XTTY, 0, (char *)0, FALSE);
-			m=rhsbuf;
-			while ((c = getchar())!='\n') {
-				if (c == EOF)
-					error('t');  /* unexpected EOF */
-				*m++ = c;
-				if (m==rhsbuf+RHSIZE-1)
-					error('l'); /* out of space */
-			}
-			*m='\0';
-			if (m==rhsbuf)
-				break;
-			change++;
-			i=linebuf;
-			o=subsbuf;
-			do ; while (*o++ = *i++);
-			if (i+(m-rhsbuf) > linebuf+LBSIZE)
-				error('l'); /* out of space */
-			i=subsbuf;
-			o=linebuf;
-			m=rhsbuf;
-			insert=FALSE;
-			ic=0;
-			mc=0;
-			while (*i && *m && !insert) {
-				if(*i=='\t' && *m!='#' && *m!='^' && *m!='$') {
-					ic=next_col(ic,i,FALSE);
-					tf=m;
-					tl=m;
-					do {
-						if (*m!=' ' && *m!='\t') {
-							if(*m=='%')
-								*m=' ';
-							tl=m+1;
-						}
-						mc=next_col(mc,m++,TRUE);
-					} while (ic>mc && *m && *m!='#' &&
-						 *m!='^' && *m!='$');
-					if (ic>mc) {
-						ic=mc;
-						if (*m)
-							tl=m;
-					} else {
-						if (tl==m)
-							i++;
-						else
-							ic--;
-					}
-					while (tf!=tl)
-						*o++ = *tf++;
-				} else {
-					mc=next_col(mc,m,TRUE);
-					*o = *m;
-					switch (*m++) {
-					case ' ':
-					case '\t':
-						break;
-					case '^':
-						mc=ic;
-						insert++;
-						break;
-					case '$':
-						i="";
-						break;
-					case '#':
-						ic=next_col(ic,i++,FALSE);
-						while(*m=='#' && ic>mc)
-						      mc=next_col(mc,m++,TRUE);
-						if (ic!=mc)
-							error('t');
-						break;
-					case '%':
-						*o = ' ';
-						/* fall through */
-					default:
-						o++;
-						ic=next_col(ic,i++,FALSE);
-					} /* switch */
-				} /* else */
-				for (;;) {
-					if (ic>mc && *m) {
-						if (*m!=' ' && *m!='\t')
-							error('t');
-						mc=next_col(mc,m++,TRUE);
-					} else if (mc>ic && *i) {
-						ic=next_col(ic,i,FALSE);
-						*o++ = *i++;
-					} else
-						break;
-				}
-			} /* while */
-			if (mc>ic && m[-1]=='\t')
-				*o++ = '\t';
-			if (insert && (*o++ = *m++) == '\0') {
-				replace(line,qputline());
-				linebp=i;
-				append(getsub,line);
-				line++;
-				addr2++;
-				change = FALSE;
-			} else {
-				while (*m)
-					*o++ = *m++;
-				do ; while (*o++ = *i++);
-			}
-		}
-		if (change)
-			replace(line,qputline());
-	} /* for */
-}
//GO.SYSIN DD subs.c
echo qed.1 1>&2
sed 's/.//' >qed.1 <<'//GO.SYSIN DD qed.1'
-.TH "QED" 1 
-.	\" /*% nroff -man %
-.if t .ds q \(aa
-.if n .ds q '
-.SH NAME
-qed \- multi-file text editor
-.SH SYNOPSIS
-.B qed
-[
-.B \-
-] [
-.B \-i
-] [
-.B \-q
-] [
-.B \-e
-] [
-.B \-x
-startupfile
-] [ filename1 filename2 ... ]
-.SH DESCRIPTION
-\fIQed\fP
-is a multiple-file programmable text editor based on
-.IR ed .
-.PP
-.I Qed
-operates on a copy of any file it is editing; changes made
-in the copy have no effect on the file until a \fIw\fR
-or \fIW\fR (write)
-command is given.
-The copy of the text being edited resides
-in a scratch area called a
-.I buffer.
-There are 56 buffers, labeled by alphabetics `a' to `z' and `A' to `Z',
-and the characters `{', `|', `}' and `~'
-(the four ASCII characters following `z').
-These 56 characters are called, for notational efficiency,
-.I bnames.
-The buffers can contain any ASCII character except NUL.
-.PP
-If
-.I file
-arguments are given,
-.I qed
-simulates an
-.I r
-command (see below) on each of the named files; that is to say,
-the files are read into
-.I qed's
-buffers so that they can be edited.
-The first is read into buffer `a', the second into buffer `b',
-through `z',
-then from `A' to `Z',
-up to a maximum of 52 files.
-The optional
-.B \-
-puts
-.I qed
-in non-\c
-.I verbose
-mode (described with the
-.I o
-command).
-The
-\fB\-q\fR, \fB\-e\fR
-and
-.B \-i
-are equivalent to performing an initial
-`oqs', `oes' or `ois' command (see the
-.I o
-command below).
-.PP
-When \fIqed\fP starts up,
-the file named by the environment variable
-.B QEDFILE
-is read into
-buffer `~' and executed
-(i.e. read as command input), before
-reading in files and accepting commands from the terminal.
-The argument
-.I filename\c
-s are set in the buffers before the startup file is executed,
-so the startup file can treat the \fIfilenames\fR as arguments.
-The default startup file may be overridden with the \fB\-x\fR option.
-.PP
-Input to
-.I qed
-can be redirected, at any time,
-to come from storage such as a buffer
-by use of a
-.I special
-.I character
-such as ``\eb''.
-All the
-.I qed special character
-sequences are discussed in detail below;
-they all begin with a
-backslash `\\'.
-.PP
-.I Qed
-has a 
-.I truth flag
-which is set according to the success of certain commands
-and which can be tested for conditional execution, and a
-.I count
-which is set to such values as the number of successful substitutions
-performed in an
-.I s
-command.
-Each buffer has associated with it a
-(possibly null) filename and a
-.I changed
-flag, which is
-set if the contents of the buffer are known to differ
-from the contents of the named file in that buffer.
-.PP
-Commands to
-.I qed
-have a simple and regular structure: zero or
-more
-.I addresses
-followed by a single character
-\fIcommand\fP,
-possibly
-followed by parameters to the command.
-These addresses specify one or more lines in the buffer.
-Every command which requires addresses has default addresses,
-so that the addresses can often be omitted.
-.PP
-In general, any number of commands can appear on a line.
-Some commands require that the character following
-the command be a separator, such as blank, tab or newline.
-Usually, a
-.I display
-.IR character ,
-.IR p ,
-.IR P ,
-.IR l ,
-or
-.I L
-may precede the separator,
-causing the resulting line to be displayed in the specified format
-after the command.
-Certain commands allow the input of text for placement in the buffer.
-This text can be supplied in two forms:
-either
-on the same line, after the command,
-or on lines following the command,
-terminated by a line containing only a period `\fB.\fP'.
-If the text is on the command line,
-it is separated from the command by a space or a tab.
-If the tab is used, it is considered part of the text.
-.PP
-.I Qed
-supports a limited form of
-\fIregular\fP \fIexpression\fP
-notation.
-A regular expression specifies
-a set of strings of characters.
-A member of this set of strings is said to be
-.I matched
-by the regular expression.
-Regular expressions in
-.I qed
-are delimited by enclosing them in a pair of identical characters,
-frequently slashes `/'.
-In the following specification for regular expressions the word `character'
-means any character but newline.
-Note that special character interpretation always occurs
-.I before
-executing a command.
-Thus, the backslashes mentioned below are those present
-after special characters have been interpreted.
-.IP 1.
-Any character except a metacharacter matches itself.
-Metacharacters are the regular expression delimiter plus
-< [ \fB.\fP and \e | > ^ * \+ $
-when another rule gives them a meaning.
-.IP 2.
-A \fB.\fP matches any character.
-.IP 3.
-A backslash \\ followed by
-any metacharacter in the list given in rule 1
-is a regular expression and matches that character.
-A backslash followed by one of
-! _ { } (  )
-or a non-zero digit
-has a special meaning discussed below;
-otherwise, backslashes have literal meaning in regular expressions.
-.IP 4.
-The metacharacter \e\|! matches any control character
-except tab or newline.
-.IP 5.
-A non-empty string
-.I s
-enclosed in square brackets
-[\fIs\fP] (or [^\fIs\fP]) matches any character in (or not in) \fIs\fP.
-In
-.IR s ,
-\\ has no special meaning, and ] may only appear as the first character.
-A substring
-.IR a \- b ,
-with
-.I a
-and
-.I b
-in ascending ASCII order, stands for the inclusive range of ASCII characters.
-.IP 6.
-A regular expression,
-of the form <\fIx1\fP> or <\fIx1\fR|\|\fIx2\fR|\|...|\|\fIxn\fR>,
-where the \fIx\fR's are regular expressions of form 1-12, matches what
-the leftmost successful \fIx\fR
-matches.
-.IP 7.
-A backslash followed by a non-zero digit
-.I n
-matches a copy of the string that the bracketed regular expression
-(see rule 11)
-beginning with the \fIn\fPth \e\|( matched.
-.IP 8.
-A regular expression of form 1-7 followed by * (\+)
-matches a sequence of zero (one) or more matches of the regular expression.
-.IP 9.
-The metacharacter \\\|_ matches a non-empty
-maximal-length sequence of blanks and tabs.
-.IP 10.
-The metacharacter \\\|{ (\\\|}) matches the empty string at the beginning
-(end) of an identifier.  An identifier is defined to be
-an underscore _ or alphabetic followed by zero or more
-underscores, alphabetics or digits.
-.IP 11.
-A regular expression,
-.IR x ,
-of form 1-12, bracketed \e\|(\|\fIx\fP\|\e\|) matches what
-.I x
-matches.
-The nesting of these brackets in each regular expression of an
-alternation (rule 6) must be identical.
-An alternation with these brackets may not be iterated (rule 8).
-.IP 12.
-A regular expression of form 1-12,
-.IR x ,
-followed by a regular expression of form 1-11,
-.IR y ,
-matches a match for
-.I x
-followed by a match for
-.IR y ,
-with the
-.I x
-match being as long as possible while still permitting a
-.I y
-match.
-.IP 13.
-A regular expression of form 1-12 preceded by ^ (followed by $) is constrained
-to matches that begin at the left (end at the right) end of a line.
-.IP 14.
-A regular expression of form 1-13 picks out the longest among the leftmost 
-matches
-in a line.
-.IP 15.
-An empty regular expression stands for a copy of the last regular expression 
-encountered.
-.PP
-.i0
-Regular expressions are used in addresses and the
-.I g
-and
-.I v
-commands
-to specify
-lines, in the
-.I s
-command
-to specify a portion of a line which is to be replaced,
-in the
-.I G
-and
-.I V
-commands to refer to buffers in which to perform commands,
-and in general whenever text
-is being specified.
-.PP
-To understand addressing in
-.I qed
-it is necessary to know that at any time there is a
-\fIcurrent buffer\fR
-and a
-\fIcurrent line.\fR
-When
-.I qed
-is invoked,
-the current buffer is
-buffer `a',
-but may be changed at any time by a
-.I b
-(change buffer) command.
-All addresses refer to lines in the current buffer,
-except for a special case described under the
-.I m
-(move) command.
-.PP
-Generally speaking, the current line is
-the last line affected by a command; however,
-the exact effect on the current line
-is discussed under the description of
-the command.
-Addresses are constructed as follows.
-.IP 1.
-The character `\fB.\fR' addresses the current line.
-.IP 2.
-The character `$' addresses the last line of the buffer.
-.IP 3.
-A decimal number
-.I n
-addresses the
-\fIn\fR-th
-line of the buffer.
-.IP 4.
-`\*q\fIx\fR' addresses the line marked with the
-mark name character \fIx\fR,
-which must be a bname.
-Lines are marked with the
-.I k
-command described below.
-It is an error for the marked line to be outside of the current buffer.
-.IP 5.
-A regular expression enclosed in slashes `/' addresses
-the first matching line
-found by searching forwards from the line after the current line.
-If necessary, the search wraps around to the beginning of the
-buffer.
-If the trailing `/' would be followed by a newline,
-it may be omitted.
-.IP 6.
-A regular expression enclosed in queries `?' addresses
-the first matching line
-found by searching backwards from the line before
-the current line.
-If necessary
-the search wraps around to the end of the buffer.
-If the trailing `?' would be followed by a newline,
-it may be omitted.
-.IP 7.
-An address followed by a plus sign `+'
-or a minus sign `\-' followed by a decimal number specifies that address plus
-(resp. minus) the indicated number of lines.
-The plus sign may be omitted.
-.IP 8.
-An address followed by `+' or `\-' followed by a
-regular expression enclosed in slashes specifies the first
-matching line following (resp. preceding) that address.
-The search wraps around if necessary.
-The `+' may be omitted.
-Enclosing the regular expression in `?' reverses the search direction.
-.IP 9.
-If an address begins with `+' or `\-'
-the addition or subtraction is taken with respect to the current line;
-e.g. `\-5' is understood to mean `\fB.\fR\-5'.
-.IP 10.
-If an address ends with a `+' (or `\-') 1 is added (resp. subtracted).
-As a consequence of this rule and rule 9,
-the address `\-' refers to the line before the current line.
-Moreover, trailing `+' and `\-' characters have cumulative effect, so `\-\-'
-refers to the current line less 2.
-.IP 11.
-To maintain compatibility with earlier versions of the editor,
-the character `^' in addresses is entirely
-equivalent to `\-'.
-.PP
-.i0
-Commands may require zero, one, or two addresses.
-Commands which require no addresses regard the presence
-of an address as an error.
-Commands which accept one or two addresses
-assume default addresses when none is given.
-If more addresses are given than the command requires,
-the last one or two (depending on what is accepted) are used.
-The last addressed line must not precede the second-last addressed line.
-.PP
-Typically, addresses are separated from each other by a comma `,'.
-They may instead be separated by a semicolon `;'
-in which case the current line `\fB.\fR' is set to the first address
-before the second address is interpreted.
-The second of two separated addresses may not be a line
-earlier in the buffer than the first.
-If the address on the left (right) side of a comma or semicolon
-is absent, it defaults to the first (resp. last) line.
-.PP
-Filename operands of commands may be made up of printing characters only.
-However, when the filename appears as the argument to the invocation of
-\fIqed\fP,
-non-printing characters may be included.
-When a filename is specified for a command,
-it is terminated at the first blank, tab or newline.
-.PP
-In the following list of
-.I qed
-commands, the default addresses
-are shown in parentheses.
-The parentheses are not part of
-the address, but are used to show that the given addresses are
-the default.
-.TP 5
-( \fB. \fR)\|a <text>
-The append command accepts input text
-and appends it after the addressed line.
-`\fB.\fR' is left
-on the last line input, if there
-were any, otherwise at the addressed line.
-Address `0' is legal for this command; text is placed
-at the beginning of the buffer.
-.TP 5
-b<bname>
-The change buffer command sets the current buffer
-to be that named.
-`\fB.\fR', `$' and the remembered
-.I filename
-are set to those of the new buffer;
-upon return to a previously used buffer,
-`\fB.\fR' will be set to its value when the buffer was last used.
-.TP 5
-( \fB. \fR)\|b[+\-\^\fB.\fP\^][pagesize][display character]
-The browse command provides page-oriented printing.
-The optional `+', `\-', or
-.RB ` . '
-specifies whether the next,
-previous,
-or surrounding page
-is to be printed; if absent, `+' is assumed.
-.IB b .
-also prints several carets `^^^^^'
-immediately below the current line.
-If a pagesize is given, it is used for the current browse
-command and remembered as the default.
-The pagesize is initially 22 lines.
-If a display character is given,
-the lines are printed in the specified format,
-and the format is remembered as the default.
-Initially, `p' is the default.
-For
-.I b+
-and
-.IR b\- ,
-`\fB.\fP' is left at the last line displayed;
-for
-\fIb\fP\fB.\fP,
-it is unchanged.
-NOTE: The browse and change buffer commands are the same character!
-The two commands can be syntactically distinguished
-in all cases except for `b<display\ char>';
-this ambiguity may be resolved by typing the (implicit) `+'
-after the `b'.
-.TP 5
-( \fB. \fR, \fB. \fR)\|c <text>
-The change
-command deletes the addressed lines, then accepts input
-text which replaces these lines.
-`\fB.\fR' is left at the last line input; if there were none,
-it is left at the line preceding the deleted lines.
-If an interrupt signal (usually ASCII DEL) is received during a
-change command, the old lines are not deleted.
-.TP 5
-( \fB. \fR, \fB. \fR)\|d
-The delete command deletes the addressed lines from the buffer.
-The line after the deleted section becomes the current line;
-if the deleted lines were originally at the end,
-the new last line becomes the current line.
-The character after the `d' can only be one of
-a blank, newline, tab, or display character.
-Line 0 is a valid address for deletion;
-deleting line 0 has no affect on any lines in the buffer.
-.TP 5
-e filename
-The edit
-command causes the entire contents of the current buffer to be deleted,
-and then the named file to be read in.
-`\fB.\fR' is set to the last line of the buffer.
-The number of characters read is typed
-if
-.I qed
-is in
-.I verbose
-mode.
-The \fIfilename\fP is remembered for possible use as a default file name
-in a subsequent
-\fIf\fP, \fIr\fR, \fIw\fR, or \fIW\fR command.
-.TP 5
-E filename
-The
-.I E
-command is like
-.IR e ,
-except that
-.I qed
-does not check to see
-if the buffer has been modified
-since the last
-.I w
-command.
-.TP 5
-f filename
-The filename command prints information about the current buffer,
-in the format used by the \fIn\fR command.
-If \fIfilename\fP is given,
-the currently remembered file name is changed to \fIfilename\fP.
-If
-.I qed
-is not in verbose mode,
-the information is only printed if the
-.I filename
-is not specified.
-If it is not desired to set the
-.I filename,
-the character immediately after the f must be a newline.
-Otherwise, the first token
-(which may be the null string)
-on the line, after a mandatory non-empty sequence of blanks and tabs,
-is taken to be the
-.I filename.
-These rules apply to all
-.I filename\c
--using commands,
-.I e,
-.I f,
-.I r,
-.I R,
-.I S,
-.I w
-and
-.I W,
-although some regard specification of an explicitly null \fIfilename\fP as an
-error.
-.TP 5
-( 1 , $ )\|g/regular expression/command list
-In the global
-command, the first step is to mark every line in the range which matches
-the regular expression.
-Then for every such line, the
-command list is executed with `\fB.\fR' initially set to that line.
-Any embedded newlines in the command list
-must be escaped with a backslash.
-The
-\fIa\fP,
-\fIi\fP,
-and
-.I c
-commands and associated input are permitted;
-the `\fB.\fR' terminating input mode may be omitted if it would be on the
-last line of the command list.
-The commands
-.I g
-and
-.I v
-are not permitted in the command list.
-If the command list is empty, `\fB.\fPp' is assumed.
-The regular expression may be delimited by any character other than newline.
-.TP 5
-G/regular expression/command list
-In the globuf
-command, the first step is to mark every active buffer
-whose output from an
-.I f
-command
-(with the
-.I filename
-printed literally)
-would match the regular expression.
-(An active buffer is one which has either some text or
-a remembered file name.)\ 
-Then for every such buffer, the
-command list is executed with the current buffer set to that buffer.
-In other respects it is like the global command,
-except that only the commands
-.I G
-and
-.I V
-are not permitted in the command list.
-If the command list is empty, `f' is assumed.
-.TP 5
-h<option> command list
-The until command provides a simple looping mechanism.
-The command list is a newline-terminated command sequence which forms
-the body of the loop; embedded newlines must be escaped with a backslash.
-The option specifies the exit condition for the loop,
-and is specified by the character(s) immediately following the `h':
-.RS
-.IP h[\fIN\fP]t 6
-The loop is executed until the truth flag is true.
-.PD 0
-.IP h[\fIN\fP]f 6
-The loop is executed until the truth flag is false.
-.IP h[\fIN\fP] 6
-The loop is executed indefinitely.
-.RE
-.PD
-.IP
-The loop condition is tested
-.I after
-execution, so the `ht' and `hf' forms execute at least once.
-.I N
-denotes an optional non-negative number which indicates the
-maximum number of times to execute the loop.
-.TP 5
-( \fB. \fR)\|i <text>
-The insert command accepts input text
-and inserts it before the addressed line.
-`\fB.\fR' is left at the last line input; if there were none,
-at the line before the addressed line.
-This command differs from the
-.I a
-command only in the placement of the
-text.
-.TP 5
-( \fB.\fR\-1 , \fB. \fR)\|j
-.PD 0
-.TP 5
-( \fB.\fR\-1 , \fB. \fR)\|j\|/replacement/
-.PD
-The join command collapses all addressed lines into a single line by
-deleting intermediate newlines.
-The
-.I replacement
-(if any) is placed between joined lines.
-Newlines, backslashes `\\', and slashes `/' within
-.I replacement
-must be preceded by a backslash.
-Only slashes may delimit \fIreplacement\fP.
-`\fB.\fP' is left at the resulting line.
-NOTE: The join command in
-.I qed
-has a different default addressing from that in
-.I ed.
-.TP 5
-( \fB. \fR)\|k<bname>
-The mark command marks the addressed line with
-the given bname.
-(The bname used in the mark has no relation to any buffer;
-it is just a label.)\ 
-The address form `\*q<bname>'
-then addresses this line.
-`\fB.\fR' is not changed.
-The marks are global to
-.I qed\c
-; marking a line `x' erases any previous mark `x' in any buffer.
-.TP 5
-( \fB. \fR, \fB. \fR)\|l
-The list command
-prints the addressed lines in an unambiguous way:
-a tab is printed as `\et', a backspace as `\\b',
-a backslash as `\e\e',
-a non-printing character is
-printed as a backslash followed by three octal digits,
-and a long line is folded,
-with the second and subsequent sub-lines indented one tab stop.
-If the last character in the line is a blank,
-it is followed by `\\n'.
-.TP 5
-( \fB. \fR, \fB. \fR)\|L
-The \fIL\fP command
-is similar to the \fIl\fP command,
-but each line displayed is preceded by its line number,
-any marks it has (which appear as `\*q\fIx\fR'),
-and a tab.
-.TP 5
-( \fB. \fR, \fB. \fR)\|m\fIa\fR
-The move command repositions the addressed lines after the line
-addressed by
-\fIa\fP.
-The last of the moved lines becomes the current line.
-The address \fIa\fP can also be of the form
-<bname>address,
-in which case the text is moved after the address in the named
-buffer.
-The buffer to which the text was moved becomes the current buffer.
-The original buffer (if different) has `\fB.\fR' left at the line before the 
-moved lines.
-.TP 5
-n
-The names command displays the bname,
-dollar
-and \fIfilename\fR (in `l' format) of the current buffer and all active 
-buffers.
-If the buffer's changed flag is set, an apostrophe `\*q' is printed
-after the bname.
-The current buffer is indicated by a period `\fB.\fP' before the
-dollar value.
-If present, the
-.I filename
-is preceded by a tab.
-.TP 5
-N
-The \fIN\fP command is similar to the \fIn\fP command,
-but the display is only given for those buffers
-which have a \fIfilename\fP and for which the changed flag is set.
-.TP 5
-o\fIps\fP
-The option command allows various options to be set.
-The first argument, \fIp\fP,
-specifies which option is being set.
-The rest of the command, \fIs\fP,
-specifies the setting.
-Most options can be either enabled or disabled;
-\fIs\fP is `s' to set the option,
-or `r' to reset it.
-The following table describes the available options.
-The default setting is shown after the option's letter.
-.RS
-.IP b22p 5
-Set the length and format of the page printed by the browse command.
-Either the length or the format may be omitted.
-.PD 0
-.IP "B<null string>" 5
-Set the default command sequence to be
-performed when a newline command is typed at the terminal.
-The command sequence is set by following the `B' with a newline-terminated
-string.
-If the string is null, the newline command resumes its default behaviour.
-.IP cr 5
-Set the changed flag of the current buffer.
-.IP dr 5
-Dualcase search mode
-affects rule one of regular expression construction
-so that a letter is matched without regard to its case.
-.IP er 5
-Error exit mode causes
-.I qed
-to exit if an error occurs (see the DIAGNOSTICS section).
-This option is mainly intended for use of qed in shell files.
-.IP ir 5
-Interrupt catching mode causes
-.I qed
-to exit when interrupted. (This includes removing the temporary file).
-.IP pr 5
-Prompting mode causes `*' to be typed
-immediately before a command (as opposed to text)
-is read from the terminal.
-.IP qr 5
-Quit catching mode causes
-.I qed
-to dump core, leaving the temporary file intact,
-when a QUIT signal is received.
-.IP Tr 5
-Tracing mode causes
-all commands not typed directly by the user to be echoed on the terminal.
-When a special character (other than `\eB or `\eN')
-is encountered, a `[' is typed,
-followed by a code specifying the character \(em
-`za' for register `a', `g' for global command list,
-`l' for `\el', `B' for browse pseudo-register, etc.
-Then, an `=' is typed, followed by the interpretation
-of the special character, followed by a `]'.
-.IP us 5
-Uppercase conversion mode enables case transformation in
-substitute commands.
-If the `u' flag is set, the character caret (`^') 
-becomes non-literal in the replacement text of a substitution.
-It behaves just like `&', but with case switching of alphabetics
-in the replaced text.
-If the flag is `u', all alphabetics are mapped to upper case;
-if `l', lower case; and if `s', the case is switched.
-.IP vs 5
-Verbose mode causes character counts to be typed
-after
-\fIe\fP,
-\fIr\fP,
-\fIw\fP,
-\fIR\fP,
-\fIS\fP,
-and
-.I W
-commands.
-It also causes `!' to be typed upon completion of the \fI!\fR,
-\fI<\fR, \fI|\fR  and \fI>\fR commands.
-.IP ?\fIc\fP 5
-\fIc\fP must be one of
-`c', `d', `i', `p', `T' or `v'.
-The value of the corresponding flag is stored in the truth.
-.PD
-.RE
-.TP 5
-( \fB. \fR, \fB. \fR)\|p
-The print command prints the addressed lines.
-`\fB.\fR' is left at the last line printed.
-.TP 5
-( \fB. \fR, \fB. \fR)\|P
-The PRINT command is similar to the print command,
-but each line displayed is preceded by its line number,
-any marks it has (which appear as `\*q\fIx\fR'),
-and a tab.
-.TP 5
-q
-The quit command causes
-.I qed
-to exit.
-No automatic write
-of a file is done.
-If the changed flag is set
-in any buffer,
-.I qed
-prints `?q'
-and refuses to quit.
-A second
-.I q
-or a
-.I Q
-will get out regardless,
-as will an end-of-file
-on the standard input.
-.TP 5
-Q
-Like
-.IR q ,
-but changed flags
-are not checked.
-.TP 5
-( $ )\|r filename
-The read command
-reads in the given file after the addressed line.
-If no \fIfilename\fP is given,
-the remembered \fIfilename\fP is used
-(see
-.I e
-and
-.I f
-commands).
-The \fIfilename\fP is remembered if there was not already a
-remembered \fIfilename\fP in the current buffer.
-Address `0' is legal for
-.I r
-and causes the
-file to be read at the beginning of the buffer.
-If
-.I qed
-is in
-.I verbose
-mode and the read is successful, the number of characters
-read is typed,
-except while
-.I qed
-is starting up,
-in which case an
-.I f
-command is performed.
-`\fB.\fR' is left at the last line read in from the file.
-.TP 5
-R filename
-The restore command restores an environment saved by a save (\fIS\fR) command.
-The changed flag in each buffer is restored from the files; all other flags
-are unaffected.
-The input stack is reset to the top (teletype input) level,
-and the current buffer becomes `a'.
-`\fB.\fP' is left at the saved value of `\fB.\fP' in buffer `a'\fB.\fP
-If the \fIfilename\fP is not specified, `q' is used.
-.TP 5
-( \fB. \fR, \fB. \fR)\|s\fIn\fR/regular expression/replacement/
-.PD 0
-.TP 5
-( \fB. \fR, \fB. \fR)\|s\fIn\fR/regular expression/replacement/g
-.PD
-The substitute command searches each addressed
-line for occurrences of the specified regular expression.
-The decimal number \fIn\fP defaults to 1 if missing.
-On each line in which
-.I n
-matches are found,
-the \fIn\fPth matched string is replaced with
-\fIreplacement\fP.
-If the global replacement indicator `g' follows the command,
-all subsequent matches on the line are also replaced.
-Within a line, a search starts from the character following the last match,
-unless the last match was an empty string,
-in which case the search starts at
-the second character following the empty string
-(to ensure a match is not repeated).
-It is an error for the substitution to fail on all addressed lines
-unless it is in a global command.
-`\fB.\fR' is left at the last line substituted.
-.PP
-.RS
-Any character other than newline or a numeral
-may be used instead of `/' to delimit the regular expression
-and \fIreplacement\fP.
-If the trailing delimiter is missing
-(i.e., an unescaped newline
-in the
-.IR replacement ),
-its presence is assumed,
-and the last line affected is printed,
-as if the
-substitute
-was followed by a
-.I p
-command.
-If delimiter following the expression
-is omitted as well,
-an empty
-.I replacement
-is assumed.
-.PP
-An ampersand `&' appearing in \fIreplacement\fP
-is replaced by the string matching the regular expression.
-As a more general feature,
-the characters
-`\\\fIn\fR',
-where
-.I n
-is a digit,
-are replaced by the text matched by the
-\fIn\fR-th
-regular subexpression
-enclosed between `\e\|(' and `\e\|)'.
-When nested parenthesized subexpressions are present,
-.I n
-is determined by counting occurrences of `\e\|(' starting from the left.
-.PP
-A caret `^' appearing in \fIreplacement\fP
-behaves much like an ampersand,
-but provides a mechanism for case switching of alphabetics,
-as discussed under the \fIo\fR command.
-To include an ampersand `&', caret `^', backslash `\\', newline,
-or the delimiter literally in
-\fIreplacement\fP,
-the character must be preceded by a backslash.
-Lines may be split by substituting newline characters into them.
-.RE
-.TP 5
-S filename
-The save command saves the full buffer and register information in two
-files called `filename:aq' and `filename:bq'.
-If the filename is absent, `q' is used.
-If the filename has more than 12 characters after the last slash `/',
-it is truncated to 12 characters to avoid overwriting the file.
-.TP 5
-( \fB.\fR , \fB.\fR )\|t\fIa\fR
-The copy command acts just like the move
-.I m
-command except that a copy of the addressed lines is placed after address
-\fIa\fP.
-`\fB.\fR' is left on the last line of the copy.
-The buffer to which the text was copied becomes the current buffer.
-.TP 5
-u
-The undo command restores the last line changed by a
-\fIs\fP,
-\fIu\fP,
-or
-.I x
-command.
-Any new lines created by splitting the original are left.
-It is an error if the line is not in the current buffer.
-`\fB.\fP' is left at the restored line.
-.TP 5
-( 1 , $ )\|v/regular expression/command list
-This command is the same as the global command
-except that the command list is executed
-with `\fB.\fR' initially set to every line
-.I except
-those
-matching the regular expression.
-.TP 5
-V/regular expression/command list
-This command is the same as the globuf command
-except that the command list is executed
-with the current buffer initially set to every active buffer
-.I except
-those
-matching the regular expression.
-.TP 5
-( 1 , $ )\|w filename
-The write command writes the addressed lines onto
-the given file.
-If the file does not exist,
-it is created.
-The filename is remembered if there was not already a
-remembered file name in the current buffer.
-If no file name is given,
-the remembered file name is used.
-`\fB.\fR' is unchanged.
-If
-.I qed
-is in
-.I verbose
-mode and
-the command is successful, the number of characters written is
-typed.
-.TP 5
-( 1 , $ )\|W
-The \fIW\fP command is the same as the \fIw\fP command except that
-the addressed lines are appended to the file.
-.PP
-.TP 5
-( \fB. \fR, \fB. \fR)\|x
-.RS
-The xform command allows one line at a time to be modified according to
-graphical requests.
-The line to be modified is typed out,
-and then the modify request is read from the terminal
-(even if the xform command is in a global command or other
-nested input source).
-Generally each character in the request specifies how to
-modify the character immediately above it, in the original line,
-as described in the following table.
-.IP # 5
-Delete the above character.
-.PD 0
-.IP % 5
-Replace the above character with a space.
-.IP ^ 5
-Insert the rest of the request line before the above character.
-If the rest of the request line is empty, insert a newline character.
-.IP $ 5
-Delete the characters in the above line from this position on;
-replace them with the rest of the request line.
-.IP "space or tab:" 5
-Leave above character(s) unchanged.
-.IP "any other:" 5
-This character replaces the one above it.
-.PD
-.PP
-If the request line is longer than the line to be modified,
-the overhang is added to the end of the line
-without interpretation,
-that is, without treating `#', `%', `^' or `$' specially.
-Any characters after a `^' or `$' request are not interpreted either.
-.PP
-Xform will not process control characters other
-than tab and newline,
-except in contexts where it need not know their width
-(that is, after a `^' or `$' request, or in the part of
-either the request or the line that overhangs the other).
-Remember that the ERASE character (processed by the system)
-erases the last character typed,
-not the last column.
-.PP
-Some characters take more than one column of the terminal
-to enter or display.
-For example, entering the ERASE or KILL characters literally
-takes two columns because they must be escaped.
-To delete a multi-column character,
-one must type `#' under all its columns.
-To replace a multicolumn character,
-the replacement must be typed under the first column of the character.
-Similarly, if a replacement character is multi-columned,
-it replaces the character in its first column.
-.PP
-The tab character prints as a sequence of spaces, and may be
-modified as if it were that sequence.
-As long as the last space is unmodified, it and the
-remaining contiguous spaces will represent a tab.
-.PP
-The modification process is repeated until the request is empty.
-Only a newline may immediately follow the `x'.
-.RE
-.TP 5
-y<condition><type>
-The jump command controls execution nested input sources.
-The condition is compared to the truth flag to see if the jump
-should be performed;
-if a `t', the jump is performed if the truth flag is true,
-if an `f', the jump is performed if the truth flag is false,
-if absent the jump is always performed.
-Several types of jumps exist:
-.RS
-.IP y[tf]o
-Jump out of the current input source.
-If the current input source is the command line
-for a \fIg\fR, \fIG\fP, \fIv\fR, \fIV\fR or \fIh\fR command, the command is 
-terminated.
-.PD 0
-.IP y[tf]\fIN\fR
-Control is transferred to absolute line \fIN\fR (an integer)
-in the executing buffer.
-The current input source must be a buffer.
-.IP y[tf]\(aa<label>
-Control is transferred to the first line found,
-searching forward in the buffer,
-that begins with a comment "<label>.
-The match of the labels must be exact;
-regular expressions are not used to define the control label.
-(A tab, blank or newline after the double quote specifies a null label:
-a line beginning `"\ \ LAB' cannot be transferred to by this form of jump.)\ 
-If no such label is found,
-control resumes at the character after the label in the jump command.
-The current input source must be a buffer.
-.IP y[tf]\(ga<label>
-Similar to `y\(aa<label>',
-but the search is in the opposite (reverse) direction.
-.IP y[tf]
-If no
-recognized type is given,
-input is skipped up to the next newline.
-.PD
-.RE
-.IP
-It is an error if reading the label or line number for a jump command
-causes the current input source (i.e. buffer) to be `popped.'\ 
-This can happen if the label is the last word in the buffer,
-but can be circumvented by putting an extra blank or newline after
-the jump command.
-.TP 5
-( \fB.\fR , \fB.\fR )\|z\fIXc\fR
-\fIQed\fP has 56 registers labeled by bnames.
-Three of these,
-registers `T', `C', and `U',
-are reserved:
-`T' is the truth flag, `C' is the count,
-`U' contains the
-.SM UNIX
-command from the most recent
-bang, crunch, zap, or pipe command.
-The contents of register \fIX\fP,
-where \fIX\fR is a bname,
-can be inserted into the input
-stream with the special character ``\ez\fIX\fP''.
-The command ``z\fIX\fR''
-specifies register \fIX\fR
-as the argument to
-the operation character (signified above by \fIc\fR) that follows it.
-In the description below,
-\fIN\fR stands for a possibly signed decimal integer
-and \fIS\fR stands for a newline-terminated string.
-Newlines may be embedded in registers by escaping
-them with a backslash.
-Although some of the register commands refer to addressed lines,
-`\fB.\fP' is unaffected by a
-.I z
-command.
-The operations are as follows:
-.RS
-.IP p
-Print the contents of the register in `p' format.
-.PD 0
-.IP l
-Print the contents of the register in `l' format.
-.IP \fB.\fP
-Set the register to the contents of the addressed line.
-.IP /reg-exp/
-Set the register to the portion of
-current line that matches the regular expression in slashes.
-If no such pattern is found,
-the register is cleared.
-The truth flag is set according to whether a
-match was found.
-.IP \fB:\fR\fIS\fR
-Set register to the string following the colon.
-.IP \&\(aa\fIY\fR
-Make a direct copy of register \fIY\fR in register \fIX\fR,
-without interpreting special characters.
-\fIY\fR is any register bname.
-.IP +\fIN\fR
-Increment by \fIN\fR the ASCII value of each character in the register.
-Similarly, a `\-' decrements each character.
-.IP =\fIS\fR
-(Or `<' or `>' or `!=' or `!<' or `!>'.)\ 
-Set truth flag to the result of the lexical comparison
-of the register and the string \fIS\fR.
-.IP n
-Set the count to the length of the register.
-.IP )\|\fIN\fR
-(Or '('.)\ 
-`Take'
-the first \fIN\fR characters of the register, i.e. truncate at the \fIN\fR+1'th
-character.
-`(' (`drop') is the complementary operator;
-it deletes the first \fIN\fP characters from the register.
-If \fIN\fP is negative, the break point is |\|\fIN\fP| from the end.
-.IP [/reg-exp/
-Set the count to the starting index of the regular expression in
-the register.
-Set the truth to whether the expression matches any of the register.
-.IP s\fIn\fP/reg-exp/replacement/
-.IP s\fIn\fP/reg-exp/replacement/g
-Perform a substitute command with semantics identical to the \fIs\fR command,
-but in the text of the register, not a line of the buffer.
-.IP C
-`Clean' the register: collapse each occurrence of `white space' in the register
-to a single blank, and delete initial and trailing white space.
-.IP {\|\fIS\fR
-Set the register to the value of the shell environment variable \fIS\fR,
-whose name may be terminated by a space, tab, newline or `}'.
-.PD
-.PP
-The registers can also be manipulated as decimal numbers.
-Numerical operations are indicated by a number sign `#'
-after the register name:
-e.g. `zx#+2'.
-It is an error to attempt to perform arithmetic on a
-register containing non-numeric text other than a leading minus sign.
-The numerical operations are:
-.IP a
-Set the value of the register to be the value of
-the address given to the command; e.g. `$za#a' sets register `a'
-to the number of lines in the buffer.
-.PD 0
-.IP r
-Set register \fIX\fR to be the first address
-given the command,
-and \fIX\fR+1 to be the second.  If \fIX\fR is `~', an error is generated.
-For example, `5,$zi#r' sets register `i' to 5, and
-register `j' to the value of `$'.
-`\fB.\fP' is unchanged.
-This command is usually used to pass addresses to a command buffer.
-.IP n
-Set register to the length of the addressed line.
-.IP \fB:\fIN\fR
-Set register to \fIN\fR.
-Scanning of the number stops at the first non-numeric character,
-not at the end of the line.
-.IP +\fIN\fR
-Increment register by \fIN\fR. `\-', `*', `/', and `%'
-decrement, multiply, divide, or modulo the register by \fIN\fR.
-.IP P
-Set register to the decimal value of the process id of
-.I qed.
-.IP =\fIN\fR
-(Or `<' or `>' or `!=' or `!<' or `!>'.)\ 
-Set truth flag to the result of the numeric comparison of the register
-and the number
-.I N.
-.PD
-.PP
-Several numerical operations may be combined in one command
-(and it is more efficient to do so when possible.)
-For example, `$zd#a\-3' sets register `d' to three less than the value
-of `$'.
-.RE
-.TP 5
-Z
-The zero command clears the current buffer.
-The contents, filename and all flags for the buffer are zeroed.
-The character after the `Z' must be a blank, tab or newline.
-.TP 5
-( $ )\|=
-The line number of the addressed line is typed.
-`\fB.\fR' is unchanged.
-.TP 5
-!\|<\s-2UNIX\s+2 command>
-The bang command sends the
-command line after the `!'
-to the UNIX shell to be interpreted as a command.
-Embedded newlines must be preceded by a backslash.
-The signals INTR, QUIT, and HUP are enabled or disabled
-as on entry to
-\fIqed\fP.
-At the completion of the command,
-if
-.I qed
-is in
-.I verbose
-mode, an `!' is typed.
-The return status of the command is stored in the truth flag.
-`\fB.\fR' is unchanged.
-.IP
-The
-command line
-is stored in register `U'.
-If a second `!' immediately follows the first,
-it is replaced with the uninterpreted contents
-of this register.
-Thus `!!' repeats the most recent bang command,
-and `!! \(or wc'
-repeats the command with an additional pipeline element added.
-.TP 5
-( 1 , $ )\|>\|<\s-2UNIX\s+2 command>
-The zap command is similar
-to the bang command,
-but the addressed lines become the default standard input of the command.
-The command is stored in register `U',
-as for bang;
-`>>' corresponds to `!!'.
-.TP 5
-( $ )\|<\|<\s-2UNIX\s+2 command>
-The crunch command is similar to the bang command,
-but the standard output of the command is appended to the current buffer
-after the addressed line, as though read with an \fIr\fR command
-from a temporary file.
-The command is stored in register `U'
-as for bang;
-`<<' corresponds to `!!'.
-`\fB.\fP' is left at the last line read.
-.TP 5
-( 1 , $ )\||\|<\s-2UNIX\s+2 command>
-The pipe command is similar to the bang command,
-but the addressed lines become the default standard input of the command,
-and are replaced by the standard output of the command.
-The command is stored in register `U'
-as for bang;
-`|\||' corresponds to `!!'.
-If the command returns non-zero status, the original lines are not deleted.
-`\fB.\fP' is left at the last line read.
-.TP 5
-( \fB.\fR )"
-The comment command sets dot to the addressed line, and ignores
-the rest of the line up to the first following double quote or newline.
-If, however, the character immediately after the double quote is
-a second double quote (i.e. the command is ``""''),
-the text which would normally be ignored is typed on the standard output.
-Special characters in the text will be interpreted, whether or not
-the text is printed,
-so to print a message such as ``Type \\bx'' requires the command
-``"\|"\|Type \\cbx''.
-Commented lines are used as labels by the
-.I y
-(jump) command.
-.TP 5
-%
-The register print command displays the name and value of all defined
-registers,
-followed by the \\p (`P') and \\r (`R') pseudo-registers,
-and the browse (`B') pseudo-register, if defined.
-.TP 5
-#
-The numeric register print command displays the name and value of all
-defined registers with numeric values.
-.TP 5
-( \fB.\fR+1 , \fB.\fR+1 )<newline>
-An address or addresses alone on a line
-cause the addressed lines to be printed.
-If the last address separator before the newline was `;',
-only the final addressed line is printed.
-A blank line alone causes the contents of the
-browse pseudo-register (described with the
-.I o
-command) to be executed.
-If the register is null, as it is initially,
-the newline command behaves as though the register contains
-`\fB.\fP+1p'.
-.PP
-.ul
-Special Characters
-.PP
-\fIQed\fP has some special character sequences with non-literal
-interpretations.
-These sequences are processed at the
-.I lowest
-level of input, so their interpretation is completely transparent
-to the actual commands.
-Whenever input from the user is expected, a special character can appear and
-will be processed.
-Special characters can be nested in the sense that, for example,
-a buffer invoked by `\eb' can contain a register invocation `\e\|z'.
-Backslashed escape sequences such as `\e\|(' in regular expressions
-are
-.I not
-special characters, so are not interpreted at input.
-The sequence `\e\|(' is left untouched by the input mechanism of
-.I qed;
-any special meaning it receives is given it during regular expression
-processing.
-The special characters are:
-.RS
-.IP \eb<bname>
-The `b' must be followed by a bname.
-When `\eb\fIX\fR' is typed,
-the contents of buffer \fIX\fR, up to but \fInot including\fP the last
-newline, are read as if they were entered from the keyboard.
-Typically, the missing newline is replaced by the newline which
-appears after the buffer invocation.
-Changing the contents of an executing buffer may have bizarre effects.
-.PD 0
-.IP \e\|B
-Equivalent to current buffer's bname.
-.IP \ec
-The sequence \ec is replaced by a single backslash,
-which is not re-scanned.
-The effect of the `c' is to delay interpretation of a special
-character.
-.IP \e\|f
-Equivalent to current buffer's file name.
-.IP \e\|F<bname>
-Equivalent to the file name in the named buffer.
-.IP \e\|l
-One line is read from the standard input up to, but \fInot including\fP
-the terminal newline, which is discarded.
-Note that the first invocation will read the remainder of the last
-line entered from the keyboard.
-For example, if a buffer is invoked by typing the line:
-.br
-.ti +5
-\ebxjunk
-.br
-the first \e\|l in buffer `x' will return the string `junk'.
-.IP \e\|N
-Equivalent to a newline.
-Primarily useful when delayed.
-.IP \ep
-Equivalent to the most recent regular expression used.
-.IP \e\|r
-Equivalent to the replacement text of
-the most recent substitute or join command.
-.IP \e\|z<bname>
-Equivalent to the contents of register `\e\|z\fIX\fR'.
-If the register changes during execution, the changes appear immediately
-and affect execution.
-If a `+' (`\-') appears between the `z' and the bname,
-the ASCII values of the characters in the register are
-incremented (decremented) by one before interpretation.
-If a `#' precedes the `+' (`\-')
-the contents of the register are numerically incremented (decremented).
-.IP \e"
-The sequence \e" means `no character at all'!
-It is primarily used to delay interpretation of a period
-that terminates an append, until the second or third time
-it is read (e.g. in loading execution buffers):
-the sequence \ec"\fB.\fP at the beginning of a line
-puts a period on the line which will terminate
-an append the second time it is read.
-.IP \e\*q[bfFlprz]\ 
-If an apostrophe
-appears between the backslash and the identifying character
-for one of the special characters `\eb', `\e\|f', `\e\|F', `\e\|l', `\e\|p',
-`\e\|r' or `\e\|z', interpretation is as usual except that
-any further special characters \fIembedded\fP
-in the buffer, register, etc. are \fInot\fP interpreted.
-Actually, any special character may be quoted, but in forms such as
-`\e\*q\|B', the quote has no effect.
-.RE
-.PD
-.PP
-A special character is interpreted immediately when it appears
-in the input stream,
-whether it is currently coming from
-the teletype, a buffer, a register, etc.
-(This includes characters read when typing a special character:
-`\e\*qb\eza', with register `a' containing the character `X',
-invokes the literal contents of buffer `X'.)\ 
-Thus, interpretation is recursive unless the special character
-is `\ec'.
-Special characters appearing in text processed in a command such
-as move, read or write, are \fInot\fP interpreted.
-If the backslash-character pair is not a special character
-from the above list, it is passed unchanged.
-Interpretation may be delayed using `\ec'; for example,
-if a `\ebx' is to be appended to a buffer for later interpretation,
-the user must type `\ecbx'.
-To delay interpretation \fIn\fP times, \fIn\fP c's must be placed between the
-backslash and the identifying character.
-In regular expressions and substitutes,
-a backslash preceding a metacharacter turns off its special meaning.
-Even in these cases,
-a backslash preceding an ordinary character is not deleted,
-unlike in \fIed\fP.
-For example, since the `g' command must read its entire line,
-a `\e\|zx' in a substitute driven by a global must be delayed
-if the contents of the register are to be different for each line,
-but since `\e&' is not a special character except to the substitute,
-its interpretation need not be delayed:
-.sp
-.in +5
-zA#:1
-.br
-g/\|\e$/ s\|/\|\e.xyz\|/\|\eczA \e&/p  zA#+1
-.sp
-.in
-globally searches for lines with a literal currency sign,
-and on each one substitutes for `.xyz' the contents
-of register `A'
-at the time of substitution,
-followed by a space and a literal ampersand,
-prints the result and increments register `A'.
-As a second example, the substitute
-.ti +5
-.sp
-s\|/xyz\|/\|\e\e\|N&/
-.sp
-replaces `xyz' with a newline followed by `xyz'.
-Note that the `\e\e\|N' is interpreted as
-`backslash followed by newline,'
-as the sequence `\\\\'
-.ft I
-has no special meaning in qed
-.ft R
-outside of regular expressions
-and replacement text.
-However,
-to match, say, `\e\e\|z' using a regular expression, it must be entered
-as `\e\e\ecz'.
-.PP
-.PP
-If an interrupt signal (ASCII DEL) is sent,
-.I qed
-prints `??' and returns to its command level.
-If a hangup signal is received,
-.I qed
-executes the command `S qed.hup'.
-.PP
-Some size limitations:
-512 characters per line,
-256 characters per global command list,
-1024 characters of string storage area,
-used for storing registers, file names and regular expressions,
-16 levels of input nesting,
-and 128K characters in the temporary file.
-The limit on the number of lines depends on the amount of core:
-each line takes 1 word.
-.SH FILES
-/tmp/q#, temporary;
-`#' is the process number (six decimal digits).
-.SH DIAGNOSTICS
-Diagnostics are in the form of `?' followed by a single letter code.
-If the diagnostic is because of an inaccessible file,
-the offending file name is also displayed.
-If input is not from the highest level (i.e. the standard input,
-usually the terminal), a traceback is printed, starting with the
-lowest level.
-The elements of the traceback
-are of the form ?b\fIXM.N\fR or ?z\fIXN\fR,
-where \fIX\fR is the buffer or register being executed when the
-error was encountered,
-\fIM\fR is the line number in the buffer and \fIN\fR is the character
-number in the line or register.
-The possible errors are:
-.PD 0
-.IP 0
-non-zero status return in \fI|\fR command
-.IP F
-bad bname for \e\|F
-.IP G
-nested globuf commands
-.IP N
-last line of input did not end with newline
-.IP O
-unknown option in the \fIo?c\fP command
-.IP R
-restore (\fIR\fR) command failed
-(file not found or bad format)
-.IP T
-I/O error or overflow in tempfile
-.IP Z
-out of string space; clear a few registers or file names
-.IP a
-address syntax
-.IP b
-bad bname in a \fIb\fR command or for \\b
-.IP c
-ran out of core
-.IP f
-filename syntax error
-.IP g
-nested global commands
-.IP i
-more than 52 files in initialization argument list
-.IP k
-bad bname in \fIk\fR command
-.IP l
-an internal table length was exceeded
-.IP m
-tried to move to an illegal place (e.g. 1,6m4)
-.IP o
-error opening or creating a file
-.IP p
-bad regular expression (pattern) syntax
-.IP q
-.I e
-with the current changed flag set,
-or
-.I q
-with any changed flag set
-.IP r
-read error from file
-.IP s
-no substitutions found
-.IP t
-bad \fIx\fR command data or single-case terminal
-.IP u
-no line for \fIu\fR command to undo
-.IP x
-command syntax error
-.IP w
-write error on file
-.IP y
-bad jump command (including popping the input buffer while scanning the label)
-.IP z
-bad register bname
-.IP |
-failure to create pipe for \fI<\fR, \fI|\fR or \fI>\fR command
-.IP #
-bad numeric register operation
-.IP $
-line address out of range
-.IP ?
-interrupt
-.IP /
-line search failed
-.IP [
-bad index in a register take or drop command
-.IP \e
-attempt to recursively append a buffer
-.IP !
-jackpot \(em you found a bug in regular expression matching
-.PD
-.PP
-.SH "SEE ALSO"
-qedbufs(1)
-.br
-A Tutorial Introduction to the ED Text Editor
-(B. W. Kernighan)
-.br
-Programming in
-.IR Qed :
-a Tutorial
-(Robert Pike)
-.br
-ed(1)
-.SH "U of T INFO"
-Written at U of T,
-based on several incarnations of
-.I ed,
-with contributions from
-Tom Duff, Robert Pike, Hugh Redelmeier and David Tilbrook.
-.SH BUGS
-The changed flag is not omniscient; changing the contents of
-the file outside of
-.I qed
-will fool it.
-.br
-Xform \fIcould\fP work on single-case terminals, but backslashes
-become very confusing for the user.
-.br
-On the PDP-11, numeric registers are 16-bit integers, but the
-count is a 32-bit integer.
//GO.SYSIN DD qed.1
