From 44232d5b51d0e89cd8d1dac22e80bc97c44dbc70 Mon Sep 17 00:00:00 2001 From: Mark Horton Date: Fri, 1 Aug 1980 06:22:42 -0800 Subject: [PATCH] release 3.2, Jan 4, 1980 SCCS-vsn: usr.bin/ex/ex.c 2.1 SCCS-vsn: usr.bin/ex/ex.h 2.1 SCCS-vsn: usr.bin/ex/ex_addr.c 2.1 SCCS-vsn: usr.bin/ex/ex_argv.h 2.1 SCCS-vsn: usr.bin/ex/ex_cmds.c 2.1 SCCS-vsn: usr.bin/ex/ex_cmds2.c 2.1 SCCS-vsn: usr.bin/ex/ex_cmdsub.c 2.1 SCCS-vsn: usr.bin/ex/ex_data.c 2.1 SCCS-vsn: usr.bin/ex/ex_get.c 2.1 SCCS-vsn: usr.bin/ex/ex_io.c 2.1 SCCS-vsn: usr.bin/ex/ex_put.c 2.1 SCCS-vsn: usr.bin/ex/ex_re.c 2.1 SCCS-vsn: usr.bin/ex/ex_re.h 2.1 SCCS-vsn: usr.bin/ex/ex_set.c 2.1 SCCS-vsn: usr.bin/ex/ex_subr.c 2.1 SCCS-vsn: usr.bin/ex/ex_temp.c 2.1 SCCS-vsn: usr.bin/ex/ex_temp.h 2.1 SCCS-vsn: usr.bin/ex/ex_tty.c 2.1 SCCS-vsn: usr.bin/ex/ex_tty.h 2.1 SCCS-vsn: usr.bin/ex/ex_tune.h 2.1 SCCS-vsn: usr.bin/ex/ex_v.c 2.1 SCCS-vsn: usr.bin/ex/ex_vadj.c 2.1 SCCS-vsn: usr.bin/ex/ex_vars.h 2.1 SCCS-vsn: usr.bin/ex/ex_vget.c 2.1 SCCS-vsn: usr.bin/ex/ex_vis.h 2.1 SCCS-vsn: usr.bin/ex/ex_vmain.c 2.1 SCCS-vsn: usr.bin/ex/ex_voper.c 2.1 SCCS-vsn: usr.bin/ex/ex_vops.c 2.1 SCCS-vsn: usr.bin/ex/ex_vops2.c 2.1 SCCS-vsn: usr.bin/ex/ex_vops3.c 2.1 SCCS-vsn: usr.bin/ex/ex_vput.c 2.1 SCCS-vsn: usr.bin/ex/ex_vwind.c 2.1 SCCS-vsn: usr.bin/ex/ex3.7preserve/ex3.7preserve.c 2.1 SCCS-vsn: usr.bin/ex/ex3.7recover/ex3.7recover.c 2.1 SCCS-vsn: usr.bin/ex/Makefile 2.1 SCCS-vsn: usr.bin/ex/OTHER/makefile.70 2.1 SCCS-vsn: usr.bin/ex/makeoptions 2.1 SCCS-vsn: usr.bin/ex/printf.c 2.1 --- usr/src/usr.bin/ex/Makefile | 136 +++++++++++------- usr/src/usr.bin/ex/OTHER/makefile.70 | 136 +++++++++++------- usr/src/usr.bin/ex/ex.c | 6 + usr/src/usr.bin/ex/ex.h | 22 ++- .../usr.bin/ex/ex3.7preserve/ex3.7preserve.c | 16 ++- .../usr.bin/ex/ex3.7recover/ex3.7recover.c | 8 +- usr/src/usr.bin/ex/ex_argv.h | 2 +- usr/src/usr.bin/ex/ex_cmds.c | 4 +- usr/src/usr.bin/ex/ex_cmdsub.c | 16 ++- usr/src/usr.bin/ex/ex_data.c | 2 +- usr/src/usr.bin/ex/ex_io.c | 12 +- usr/src/usr.bin/ex/ex_re.c | 2 +- usr/src/usr.bin/ex/ex_subr.c | 20 ++- usr/src/usr.bin/ex/ex_temp.c | 8 +- usr/src/usr.bin/ex/ex_temp.h | 36 +++-- usr/src/usr.bin/ex/ex_tune.h | 42 ++++-- usr/src/usr.bin/ex/ex_vars.h | 4 +- usr/src/usr.bin/ex/ex_vget.c | 32 +++-- usr/src/usr.bin/ex/ex_vis.h | 8 +- usr/src/usr.bin/ex/ex_vmain.c | 7 +- usr/src/usr.bin/ex/ex_vops2.c | 2 +- 21 files changed, 354 insertions(+), 167 deletions(-) diff --git a/usr/src/usr.bin/ex/Makefile b/usr/src/usr.bin/ex/Makefile index 09953ec4fc..c62b9d799b 100644 --- a/usr/src/usr.bin/ex/Makefile +++ b/usr/src/usr.bin/ex/Makefile @@ -1,34 +1,43 @@ -VERSION=3.1 +VERSION=3.2 # -# Ex skeletal makefile for Version 7 +# Ex skeletal makefile for version 7 # # NB: This makefile doesn't indicate any dependencies on header files. # -# Compiles in the LISPCODE code within the editor; -# take this out of CFLAGS to make some -# breathing room in the text space if necessary. If you take out -DLISPCODE -# you should move ex_vars.nolisp to ex_vars.h +# Ex is very large - it may not fit on PDP-11's depending on the operating +# system and the cflags you turn on. Things that can be turned off to save +# space include LISPCODE (-l flag, showmatch and lisp options), UCVISUAL +# (visual \ nonsense on upper case only terminals), CHDIR (the undocumented +# chdir command.) +# +# Don't define VFORK unless your system has the VFORK system call, +# which is like fork but the two processes have only one data space until the +# child execs. This speeds up ex by saving the memory copy. +# -DVMUNIX makes an ex which can edit very large files (eg the w2a dictionary) +# this allows 200000 lines and about 16M byte temp files. # # If your system expands tabs to 4 spaces you should -DTABS=4 below # -# Ex wants stdio only to get the doprnt.o routine; if other stdio stuff -# gets dragged in that is a mistake. +# Ex is likely to overflow the symbol table in your C compiler. +# It can use -t0 which is (purportedly) a C compiler with a larger +# symbol table. The -t1 flag to the C compiler is for a C compiler +# which puts switch code in I space, increasing the text space size +# to the benefit of per-user data space. If you don't have this it +# doesn't matter much. Another method, which works on v7 pdp-11's, +# is to use pcc for ex_io.c instead of cc. # -.c.o: - ${MKSTR} - ex${VERSION}strings x $*.c - ${CC} -E ${CFLAGS} x$*.c | ${XSTR} -c - - rm -f x$*.c - ${CC} ${CFLAGS} -O -c x.c - mv x.o $*.o -BINDIR= /usr/bin +BINDIR= /usr/ucb +NBINDIR=/usr/new LIBDIR= /usr/lib -FOLD= /usr/bin/fold -CTAGS= /usr/ucb/ctags -AS= -as -XSTR= /usr/ucb/xstr -CFLAGS= -DTABS=8 -DLISPCODE -MKSTR= /usr/ucb/mkstr -CXREF= /usr/ucb/cxref +FOLD= ${BINDIR}/fold +CTAGS= ${BINDIR}/ctags +XSTR= ${BINDIR}/xstr +DEBUGFLAGS= -DTRACE +NONDEBUGFLAGS= -O +CFLAGS= -DTABS=8 -DLISPCODE -DCHDIR -DUCVISUAL -DMACROS -DVFORK -DVMUNIX ${NONDEBUGFLAGS} +TERMLIB= -ltermlib +MKSTR= ${BINDIR}/mkstr +CXREF= ${BINDIR}/cxref INCLUDE=/usr/include PR= pr OBJS= ex.o ex_addr.o ex_cmds.o ex_cmds2.o ex_cmdsub.o ex_data.o ex_get.o \ @@ -37,48 +46,74 @@ OBJS= ex.o ex_addr.o ex_cmds.o ex_cmds2.o ex_cmdsub.o ex_data.o ex_get.o \ ex_vops.o ex_vops2.o ex_vops3.o ex_vput.o ex_vwind.o \ printf.o strings.o -all: a.out expreserve exrecover +all: a.out exrecover expreserve tags + +.c.o: +# ${MKSTR} - ex${VERSION}strings x $*.c + ${CC} -E ${CFLAGS} $*.c | ${XSTR} -c - +# rm -f x$*.c + ${CC} ${CFLAGS} -c x.c + mv x.o $*.o -a.out: ${OBJS} tags - ${CC} -i ${OBJS} -ltermlib +a.out: ${OBJS} + cc -i ${OBJS} ${TERMLIB} tags: - ../bin/csh ${CTAGS} ex.c ex_*.c + ${CTAGS} -w *.h *.c + +${OBJS}: ex_vars.h + +ex_vars.h: + csh makeoptions ${CFLAGS} strings.o: strings ${XSTR} - ${CC} -c xs.c - mv xs.o strings.o + ${CC} -c -S xs.c + ed - <:rofix xs.s + as -o strings.o xs.s + rm xs.s exrecover: exrecover.o - ${CC} -o exrecover exrecover.o + ${CC} ${CFLAGS} exrecover.o -o exrecover -exrecover.o: +exrecover.o: exrecover.c ${CC} ${CFLAGS} -c -O exrecover.c -expreserve: expreserve.o popen.c - ${CC} -o expreserve expreserve.o +expreserve: expreserve.o + ${CC} expreserve.o -o expreserve expreserve.o: - ${CC} ${CFLAGS} -c expreserve.c + ${CC} ${CFLAGS} -c -O expreserve.c clean: - -rm a.out exrecover expreserve ex${VERSION}strings strings errs core trace - -rm *.o x*.[cs] +# If we dont have ex we cant make it so dont rm ex_vars.h + -rm -f a.out exrecover expreserve ex${VERSION}strings strings core trace tags + -rm -f *.o x*.[cs] -install: a.out installutil - -chmod 755 ${BINDIR}/ex - -${BINDIR}/ex /dev/null @${PR} READ* BUGS - @${PR} make* + @${PR} makefile* + @${PR} /etc/termcap @(size -l a.out ; size *.o) | ${PR} -h sizes - @${PR} termcap @${PR} -h errno.h ${INCLUDE}/errno.h - @${PR} -h pwd.h ${INCLUDE}/pwd.h @${PR} -h setjmp.h ${INCLUDE}/setjmp.h @${PR} -h sgtty.h ${INCLUDE}/sgtty.h @${PR} -h signal.h ${INCLUDE}/signal.h - @${PR} -h sys/dir.h ${INCLUDE}/sys/dir.h @${PR} -h sys/stat.h ${INCLUDE}/sys/stat.h @${PR} -h sys/types.h ${INCLUDE}/sys/types.h @ls -ls | ${PR} diff --git a/usr/src/usr.bin/ex/OTHER/makefile.70 b/usr/src/usr.bin/ex/OTHER/makefile.70 index 09953ec4fc..c62b9d799b 100644 --- a/usr/src/usr.bin/ex/OTHER/makefile.70 +++ b/usr/src/usr.bin/ex/OTHER/makefile.70 @@ -1,34 +1,43 @@ -VERSION=3.1 +VERSION=3.2 # -# Ex skeletal makefile for Version 7 +# Ex skeletal makefile for version 7 # # NB: This makefile doesn't indicate any dependencies on header files. # -# Compiles in the LISPCODE code within the editor; -# take this out of CFLAGS to make some -# breathing room in the text space if necessary. If you take out -DLISPCODE -# you should move ex_vars.nolisp to ex_vars.h +# Ex is very large - it may not fit on PDP-11's depending on the operating +# system and the cflags you turn on. Things that can be turned off to save +# space include LISPCODE (-l flag, showmatch and lisp options), UCVISUAL +# (visual \ nonsense on upper case only terminals), CHDIR (the undocumented +# chdir command.) +# +# Don't define VFORK unless your system has the VFORK system call, +# which is like fork but the two processes have only one data space until the +# child execs. This speeds up ex by saving the memory copy. +# -DVMUNIX makes an ex which can edit very large files (eg the w2a dictionary) +# this allows 200000 lines and about 16M byte temp files. # # If your system expands tabs to 4 spaces you should -DTABS=4 below # -# Ex wants stdio only to get the doprnt.o routine; if other stdio stuff -# gets dragged in that is a mistake. +# Ex is likely to overflow the symbol table in your C compiler. +# It can use -t0 which is (purportedly) a C compiler with a larger +# symbol table. The -t1 flag to the C compiler is for a C compiler +# which puts switch code in I space, increasing the text space size +# to the benefit of per-user data space. If you don't have this it +# doesn't matter much. Another method, which works on v7 pdp-11's, +# is to use pcc for ex_io.c instead of cc. # -.c.o: - ${MKSTR} - ex${VERSION}strings x $*.c - ${CC} -E ${CFLAGS} x$*.c | ${XSTR} -c - - rm -f x$*.c - ${CC} ${CFLAGS} -O -c x.c - mv x.o $*.o -BINDIR= /usr/bin +BINDIR= /usr/ucb +NBINDIR=/usr/new LIBDIR= /usr/lib -FOLD= /usr/bin/fold -CTAGS= /usr/ucb/ctags -AS= -as -XSTR= /usr/ucb/xstr -CFLAGS= -DTABS=8 -DLISPCODE -MKSTR= /usr/ucb/mkstr -CXREF= /usr/ucb/cxref +FOLD= ${BINDIR}/fold +CTAGS= ${BINDIR}/ctags +XSTR= ${BINDIR}/xstr +DEBUGFLAGS= -DTRACE +NONDEBUGFLAGS= -O +CFLAGS= -DTABS=8 -DLISPCODE -DCHDIR -DUCVISUAL -DMACROS -DVFORK -DVMUNIX ${NONDEBUGFLAGS} +TERMLIB= -ltermlib +MKSTR= ${BINDIR}/mkstr +CXREF= ${BINDIR}/cxref INCLUDE=/usr/include PR= pr OBJS= ex.o ex_addr.o ex_cmds.o ex_cmds2.o ex_cmdsub.o ex_data.o ex_get.o \ @@ -37,48 +46,74 @@ OBJS= ex.o ex_addr.o ex_cmds.o ex_cmds2.o ex_cmdsub.o ex_data.o ex_get.o \ ex_vops.o ex_vops2.o ex_vops3.o ex_vput.o ex_vwind.o \ printf.o strings.o -all: a.out expreserve exrecover +all: a.out exrecover expreserve tags + +.c.o: +# ${MKSTR} - ex${VERSION}strings x $*.c + ${CC} -E ${CFLAGS} $*.c | ${XSTR} -c - +# rm -f x$*.c + ${CC} ${CFLAGS} -c x.c + mv x.o $*.o -a.out: ${OBJS} tags - ${CC} -i ${OBJS} -ltermlib +a.out: ${OBJS} + cc -i ${OBJS} ${TERMLIB} tags: - ../bin/csh ${CTAGS} ex.c ex_*.c + ${CTAGS} -w *.h *.c + +${OBJS}: ex_vars.h + +ex_vars.h: + csh makeoptions ${CFLAGS} strings.o: strings ${XSTR} - ${CC} -c xs.c - mv xs.o strings.o + ${CC} -c -S xs.c + ed - <:rofix xs.s + as -o strings.o xs.s + rm xs.s exrecover: exrecover.o - ${CC} -o exrecover exrecover.o + ${CC} ${CFLAGS} exrecover.o -o exrecover -exrecover.o: +exrecover.o: exrecover.c ${CC} ${CFLAGS} -c -O exrecover.c -expreserve: expreserve.o popen.c - ${CC} -o expreserve expreserve.o +expreserve: expreserve.o + ${CC} expreserve.o -o expreserve expreserve.o: - ${CC} ${CFLAGS} -c expreserve.c + ${CC} ${CFLAGS} -c -O expreserve.c clean: - -rm a.out exrecover expreserve ex${VERSION}strings strings errs core trace - -rm *.o x*.[cs] +# If we dont have ex we cant make it so dont rm ex_vars.h + -rm -f a.out exrecover expreserve ex${VERSION}strings strings core trace tags + -rm -f *.o x*.[cs] -install: a.out installutil - -chmod 755 ${BINDIR}/ex - -${BINDIR}/ex /dev/null @${PR} READ* BUGS - @${PR} make* + @${PR} makefile* + @${PR} /etc/termcap @(size -l a.out ; size *.o) | ${PR} -h sizes - @${PR} termcap @${PR} -h errno.h ${INCLUDE}/errno.h - @${PR} -h pwd.h ${INCLUDE}/pwd.h @${PR} -h setjmp.h ${INCLUDE}/setjmp.h @${PR} -h sgtty.h ${INCLUDE}/sgtty.h @${PR} -h signal.h ${INCLUDE}/signal.h - @${PR} -h sys/dir.h ${INCLUDE}/sys/dir.h @${PR} -h sys/stat.h ${INCLUDE}/sys/stat.h @${PR} -h sys/types.h ${INCLUDE}/sys/types.h @ls -ls | ${PR} diff --git a/usr/src/usr.bin/ex/ex.c b/usr/src/usr.bin/ex/ex.c index 72fa653c72..e74b5c046c 100644 --- a/usr/src/usr.bin/ex/ex.c +++ b/usr/src/usr.bin/ex/ex.c @@ -70,7 +70,9 @@ main(ac, av) register int ac; register char *av[]; { +#ifndef VMUNIX char *erpath = EXSTRINGS; +#endif register char *cp; register int c; bool recov = 0; @@ -99,8 +101,10 @@ main(ac, av) * For debugging take files out of . if name is a.out. * If a 'd' in our name, then set options for edit. */ +#ifndef VMUNIX if (av[0][0] == 'a') erpath = tailpath(erpath); +#endif if (ivis) { #ifdef notdef options[BEAUTIFY].odefault = value(BEAUTIFY) = 1; @@ -115,10 +119,12 @@ main(ac, av) * Open the error message file. */ draino(); +#ifndef VMUNIX erfile = open(erpath+4, 0); if (erfile < 0) { erfile = open(erpath, 0); } +#endif pstop(); /* diff --git a/usr/src/usr.bin/ex/ex.h b/usr/src/usr.bin/ex/ex.h index 0a83eef678..9493541ce1 100644 --- a/usr/src/usr.bin/ex/ex.h +++ b/usr/src/usr.bin/ex/ex.h @@ -50,7 +50,11 @@ extern int errno; +#ifndef VMUNIX typedef short line; +#else +typedef int line; +#endif typedef short bool; #include "ex_tune.h" @@ -104,7 +108,11 @@ struct option options[NOPTS + 1]; # undef putchar # undef getchar #else +#ifdef VMUNIX +# define BUFSIZ 1024 +#else # define BUFSIZ 512 +#endif # define NULL 0 # define EOF -1 #endif @@ -130,14 +138,16 @@ struct option options[NOPTS + 1]; */ bool aiflag; /* Append/change/insert with autoindent */ bool anymarks; /* We have used '[a-z] */ -short chng; /* Warn "No write" */ +int chng; /* Warn "No write" */ char *Command; short defwind; /* -w# change default window size */ -short dirtcnt; /* When >= MAXDIRT, should sync temporary */ +int dirtcnt; /* When >= MAXDIRT, should sync temporary */ bool edited; /* Current file is [Edited] */ line *endcore; /* Last available core location */ bool endline; /* Last cmd mode command ended with \n */ +#ifndef VMUNIX short erfile; /* Error message file unit */ +#endif line *fendcore; /* First address in line pointer space */ char file[FNSIZE]; /* Working file name */ char genbuf[LBSIZE]; /* Working buffer when manipulating linebuf */ @@ -160,11 +170,11 @@ bool listf; /* Command should run in list mode */ char *loc1; /* Where re began to match (in linebuf) */ char *loc2; /* First char after re match (") */ line names['z'-'a'+2]; /* Mark registers a-z,' */ -short notecnt; /* Count for notify (to visual from cmd) */ +int notecnt; /* Count for notify (to visual from cmd) */ bool numberf; /* Command should run in number mode */ char obuf[BUFSIZ]; /* Buffer for tty output */ short ospeed; /* Output speed (from gtty) */ -short otchng; /* Backup tchng to find changes in macros */ +int otchng; /* Backup tchng to find changes in macros */ short peekc; /* Peek ahead character (cmd mode input) */ char *pkill[2]; /* Trim for put with ragged (LISP) delete */ bool pfast; /* Have stty -nl'ed to go faster */ @@ -175,11 +185,11 @@ int rpid; /* Pid returned from wait() */ bool ruptible; /* Interruptible is normal state */ bool shudclob; /* Have a prompt to clobber (e.g. on ^D) */ int status; /* Status returned from wait() */ -short tchng; /* If nonzero, then [Modified] */ +int tchng; /* If nonzero, then [Modified] */ short tfile; /* Temporary file unit */ bool vcatch; /* Want to catch an error (open/visual) */ jmp_buf vreslab; /* For error throws to a visual catch */ -short xchng; /* Suppresses multiple "No writes" in !cmd */ +int xchng; /* Suppresses multiple "No writes" in !cmd */ /* * Macros diff --git a/usr/src/usr.bin/ex/ex3.7preserve/ex3.7preserve.c b/usr/src/usr.bin/ex/ex3.7preserve/ex3.7preserve.c index c915b6bc14..373aa699c0 100644 --- a/usr/src/usr.bin/ex/ex3.7preserve/ex3.7preserve.c +++ b/usr/src/usr.bin/ex/ex3.7preserve/ex3.7preserve.c @@ -7,6 +7,12 @@ #include #include "local/uparm.h" +#ifdef VMUNIX +#define HBLKS 2 +#else +#define HBLKS 1 +#endif + /* * Expreserve - preserve a file in usrpath(preserve) * Bill Joy UCB November 13, 1977 @@ -24,13 +30,21 @@ * temporaries. */ +#ifndef VMUNIX #define LBLKS 125 +#else +#define LBLKS 900 +#endif #define FNSIZE 128 struct header { time_t Time; /* Time temp file last updated */ short Uid; /* This users identity */ +#ifndef VMUNIX short Flines; /* Number of lines in file */ +#else + int Flines; +#endif char Savedfile[FNSIZE]; /* The current file name */ short Blocks[LBLKS]; /* Blocks where line pointers stashed */ } H; @@ -170,7 +184,7 @@ format: #endif goto format; } - if (H.Blocks[0] != 1 || H.Blocks[1] != 2) { + if (H.Blocks[0] != HBLKS || H.Blocks[1] != HBLKS+1) { #ifdef DEBUG fprintf(stderr, "Blocks %d %d\n", H.Blocks[0], H.Blocks[1]); #endif diff --git a/usr/src/usr.bin/ex/ex3.7recover/ex3.7recover.c b/usr/src/usr.bin/ex/ex3.7recover/ex3.7recover.c index 17660b4c01..9781fb9f8d 100644 --- a/usr/src/usr.bin/ex/ex3.7recover/ex3.7recover.c +++ b/usr/src/usr.bin/ex/ex3.7recover/ex3.7recover.c @@ -488,7 +488,7 @@ nope: * puts a word LOST in the header block, so that lost lines * can be made to point at it. */ - ignorl(lseek(tfile, 504l, 0)); + ignorl(lseek(tfile, (long)(BUFSIZ*HBLKS-8), 0)); ignore(write(tfile, "LOST", 5)); return (1); } @@ -522,7 +522,7 @@ scrapbad() ignore(fstat(tfile, &stbuf)); size = stbuf.st_size; - maxt = (size >> SHFT) | 7; + maxt = (size >> SHFT) | (BNDRY-1); bno = (maxt >> OFFBTS) & BLKMSK; #ifdef DEBUG fprintf(stderr, "size %ld, maxt %o, bno %d\n", size, maxt, bno); @@ -564,7 +564,7 @@ null: #endif if (was == 0) was = ip - zero; - *ip = 504 >> SHFT; + *ip = ((HBLKS*BUFSIZ)-8) >> SHFT; } else if (was) { if (bad == 0) fprintf(stderr, " [Lost line(s):"); @@ -738,7 +738,7 @@ blkio(b, buf, iofcn) { lseek(tfile, (long) (unsigned) b * BUFSIZ, 0); - if ((*iofcn)(tfile, buf, BUFSIZ) != 512) + if ((*iofcn)(tfile, buf, BUFSIZ) != BUFSIZ) syserror(); } diff --git a/usr/src/usr.bin/ex/ex_argv.h b/usr/src/usr.bin/ex/ex_argv.h index 7ce9dba5eb..666045b3a5 100644 --- a/usr/src/usr.bin/ex/ex_argv.h +++ b/usr/src/usr.bin/ex/ex_argv.h @@ -14,7 +14,7 @@ short argc; short argc0; short morargc; /* Used with "More files to edit..." */ -short firstln; /* From +lineno */ +int firstln; /* From +lineno */ char *firstpat; /* From +/pat */ /* Yech... */ diff --git a/usr/src/usr.bin/ex/ex_cmds.c b/usr/src/usr.bin/ex/ex_cmds.c index 3939db575d..d577f8976c 100644 --- a/usr/src/usr.bin/ex/ex_cmds.c +++ b/usr/src/usr.bin/ex/ex_cmds.c @@ -260,7 +260,9 @@ doecmd: setnoaddr(); filename(c); noonl(); +/* synctmp(); +*/ continue; /* global */ @@ -596,7 +598,7 @@ quit: tail("version"); setNAEOL(); /* should use SCCS subst here */ - printf("Version 3.1, November 11, 1979"); + printf("Version 3.2, January 4, 1980"); noonl(); continue; diff --git a/usr/src/usr.bin/ex/ex_cmdsub.c b/usr/src/usr.bin/ex/ex_cmdsub.c index b630e8b0f4..09c01d9d2f 100644 --- a/usr/src/usr.bin/ex/ex_cmdsub.c +++ b/usr/src/usr.bin/ex/ex_cmdsub.c @@ -456,7 +456,6 @@ tagfind(quick) short omagic; omagic = value(MAGIC); - value(MAGIC) = 0; /* force nomagic mode for tags */ if (!skipend()) { register char *lp = lasttag; @@ -531,9 +530,15 @@ badtags: strcat(cmdbuf2, filebuf); globp = cmdbuf2; d = peekc; ungetchar(0); + /* + * BUG: if it isn't found (user edited header + * line) we get left in nomagic mode. + */ + value(MAGIC) = 0; commands(1, 1); peekc = d; globp = oglobp; + value(MAGIC) = omagic; samef = 0; } oglobp = globp; @@ -541,6 +546,7 @@ badtags: d = peekc; ungetchar(0); if (samef) markpr(dot); + value(MAGIC) = 0; commands(1, 1); peekc = d; globp = oglobp; @@ -1031,13 +1037,13 @@ addmac(src,dest,dname) if (dest) { /* Make sure user doesn't screw himself */ /* - * Prevent head and tail recursion. We really should be - * checking to see if src is a prefix or suffix of dest + * Prevent tail recursion. We really should be + * checking to see if src is a suffix of dest * but we are too lazy here, so we don't bother unless * src is only 1 char long. */ - if (src[1] == 0 && (src[0] == dest[0] || src[0] == dest[strlen(dest)-1])) - error("No recursion"); + if (src[1] == 0 && src[0] == dest[strlen(dest)-1]) + error("No tail recursion"); /* * We don't let the user rob himself of ":", and making * multi char words is a bad idea so we don't allow it. diff --git a/usr/src/usr.bin/ex/ex_data.c b/usr/src/usr.bin/ex/ex_data.c index 5336782c50..402d208b28 100644 --- a/usr/src/usr.bin/ex/ex_data.c +++ b/usr/src/usr.bin/ex/ex_data.c @@ -38,8 +38,8 @@ struct option options[NOPTS + 1] = { "ignorecase", "ic", ONOFF, 0, 0, 0, "lisp", 0, ONOFF, 0, 0, 0, "list", 0, ONOFF, 0, 0, 0, - "mapinput", "mi", ONOFF, 0, 0, 0, "magic", 0, ONOFF, 1, 1, 0, + "mapinput", "mi", ONOFF, 0, 0, 0, "number", "nu", ONOFF, 0, 0, 0, "open", 0, ONOFF, 1, 1, 0, "optimize", "opt", ONOFF, 0, 0, 0, diff --git a/usr/src/usr.bin/ex/ex_io.c b/usr/src/usr.bin/ex/ex_io.c index d89f1fff02..d22f82ef87 100644 --- a/usr/src/usr.bin/ex/ex_io.c +++ b/usr/src/usr.bin/ex/ex_io.c @@ -13,12 +13,16 @@ * Following remember where . was in the previous file for return * on file switching. */ -short altdot; -short oldadot; +int altdot; +int oldadot; bool wasalt; long cntch; /* Count of characters on unit io */ +#ifndef VMUNIX short cntln; /* Count of lines " */ +#else +int cntln; +#endif long cntnull; /* Count of nulls " */ long cntodd; /* Count of non-ascii characters " */ @@ -476,7 +480,9 @@ bool dofname; /* if 1 call filename, else use savedfile */ error(" Use \"w!\" to write partial buffer"); } cre: +/* synctmp(); +*/ #ifdef V6 io = creat(file, 0644); #else @@ -689,7 +695,9 @@ unixex(opt, up, newstdin, mode) close(io); if (tfile) close(tfile); +#ifndef VMUNIX close(erfile); +#endif signal(SIGHUP, oldhup); signal(SIGQUIT, oldquit); if (ruptible) diff --git a/usr/src/usr.bin/ex/ex_re.c b/usr/src/usr.bin/ex/ex_re.c index a980ca9792..93abfaa00b 100644 --- a/usr/src/usr.bin/ex/ex_re.c +++ b/usr/src/usr.bin/ex/ex_re.c @@ -410,7 +410,7 @@ dosub() *sp++ = c & TRIM; if (sp >= &genbuf[LBSIZE]) ovflo: - error("Line overflow@in substitute - limit 512 chars"); + error("Line overflow@in substitute"); } lp = loc2; loc2 = sp + (linebuf - genbuf); diff --git a/usr/src/usr.bin/ex/ex_subr.c b/usr/src/usr.bin/ex/ex_subr.c index a5ccf85161..1e17f4cb29 100644 --- a/usr/src/usr.bin/ex/ex_subr.c +++ b/usr/src/usr.bin/ex/ex_subr.c @@ -316,10 +316,14 @@ mesg(str) /*VARARGS2*/ merror(seekpt, i) -#ifdef lint +#ifdef VMUNIX char *seekpt; #else +# ifdef lint + char *seekpt; +# else int seekpt; +# endif #endif int i; { @@ -340,16 +344,24 @@ merror(seekpt, i) } merror1(seekpt) -#ifdef lint +#ifdef VMUNIX char *seekpt; #else +# ifdef lint + char *seekpt; +# else int seekpt; +# endif #endif { +#ifdef VMUNIX + strcpy(linebuf, seekpt); +#else lseek(erfile, (long) seekpt, 0); if (read(erfile, linebuf, 128) < 2) CP(linebuf, "ERROR"); +#endif } morelines() @@ -584,7 +596,11 @@ smerror(seekpt, cp) #ifdef lint char *std_errlist[] = { #else +#ifdef VMUNIX +char *std_errlist[] = { +#else short std_errlist[] = { +#endif #endif error("Error 0"), error("Not super-user"), diff --git a/usr/src/usr.bin/ex/ex_temp.c b/usr/src/usr.bin/ex/ex_temp.c index 340b0bef0f..e8f87804f3 100644 --- a/usr/src/usr.bin/ex/ex_temp.c +++ b/usr/src/usr.bin/ex/ex_temp.c @@ -23,13 +23,13 @@ fileinit() register int i, j; struct stat stbuf; - if (tline == INCRMT * 3) + if (tline == INCRMT * (HBLKS+2)) return; cleanup(0); close(tfile); - tline = INCRMT * 3; - blocks[0] = 1; - blocks[1] = 2; + tline = INCRMT * (HBLKS+2); + blocks[0] = HBLKS; + blocks[1] = HBLKS+1; blocks[2] = -1; dirtcnt = 0; iblock = -1; diff --git a/usr/src/usr.bin/ex/ex_temp.h b/usr/src/usr.bin/ex/ex_temp.h index 438367a940..7d4c751807 100644 --- a/usr/src/usr.bin/ex/ex_temp.h +++ b/usr/src/usr.bin/ex/ex_temp.h @@ -4,9 +4,9 @@ * similar to that of ed. The first block of the file is used for a header * block which guides recovery after editor/system crashes. * Lines are represented in core by a pointer into the temporary file which - * is packed into 16 bits. 15 of these bits index the temporary file, - * the 16'th is used by global commands. The parameters below control - * how much the 15 bits are shifted left before they index the temp file. + * is packed into 16 bits (32 on VMUNIX). All but the low bit index the temp + * file; the last is used by global commands. The parameters below control + * how much the other bits are shifted left before they index the temp file. * Larger shifts give more slop in the temp file but allow larger files * to be edited. * @@ -21,10 +21,12 @@ * * The following temp file parameters allow 256k bytes in the temporary * file. By changing to the numbers in comments you can get 512k. - * By typedefing line to long (32 bit) integers you could get much more - * space in the temp file with (then) no waste. This would double core - * requirements and would probably require some editor debugging. + * For VMUNIX you get more than you could ever want. + * VMUNIX uses long (32 bit) integers giving much more + * space in the temp file and no waste. This doubles core + * requirements but allows files of essentially unlimited size to be edited. */ +#ifndef VMUNIX #define BLKMSK 0777 /* 01777 */ #define BNDRY 8 /* 16 */ #define INCRMT 0200 /* 0100 */ @@ -33,12 +35,22 @@ #define OFFBTS 7 /* 6 */ #define OFFMSK 0177 /* 077 */ #define SHFT 2 /* 3 */ +#else +#define BLKMSK 077777 +#define BNDRY 2 +#define INCRMT 02000 +#define LBTMSK 01776 +#define NMBLKS 077770 +#define OFFBTS 10 +#define OFFMSK 01777 +#define SHFT 0 +#endif /* * The editor uses three buffers into the temporary file (ed uses two * and is very similar). These are two read buffers and one write buffer. - * Basically, the editor deals with the file as a sequence of 512 character - * blocks (BUFSIZ). Each block contains some number of lines (and lines + * Basically, the editor deals with the file as a sequence of BUFSIZ character + * blocks. Each block contains some number of lines (and lines * can run across block boundaries. * * New lines are written into the last block in the temporary file @@ -59,7 +71,11 @@ short iblock2; /* Temp file block number of ibuff2 (or -1) */ short ninbuf; /* Number useful chars left in input buffer */ short nleft; /* Number usable chars left in output buffer */ short oblock; /* Temp file block number of obuff (or -1) */ +#ifndef VMUNIX short tline; /* Current temp file ptr */ +#else +int tline; +#endif char ibuff[BUFSIZ]; char ibuff2[BUFSIZ]; @@ -83,7 +99,11 @@ char obuff[BUFSIZ]; struct header { time_t Time; /* Time temp file last updated */ short Uid; +#ifndef VMUNIX short Flines; /* Number of lines in file */ +#else + int Flines; +#endif char Savedfile[FNSIZE]; /* The current file name */ short Blocks[LBLKS]; /* Blocks where line pointers stashed */ } H; diff --git a/usr/src/usr.bin/ex/ex_tune.h b/usr/src/usr.bin/ex/ex_tune.h index d025bb0965..192e9b8fe7 100644 --- a/usr/src/usr.bin/ex/ex_tune.h +++ b/usr/src/usr.bin/ex/ex_tune.h @@ -10,9 +10,11 @@ * "/usr/lib/..." here, "/lib" will be tried only for strings. */ #include "local/uparm.h" -#define EXRECOVER libpath(ex3.1recover) -#define EXPRESERVE libpath(ex3.1preserve) -#define EXSTRINGS libpath(ex3.1strings) +#define EXRECOVER libpath(ex3.2recover) +#define EXPRESERVE libpath(ex3.2preserve) +#ifndef VMUNIX +#define EXSTRINGS libpath(ex3.2strings) +#endif #define MASTERTAGS libpath(tags) /* @@ -27,12 +29,17 @@ * Maximums * * The definition of LBSIZE should be the same as BUFSIZ (512 usually). - * Most other defitions are quite generous. + * Most other definitions are quite generous. */ /* FNSIZE is also defined in expreserve.c */ #define FNSIZE 128 /* File name size */ +#ifdef VMUNIX +#define LBSIZE 1024 +#define ESIZE 512 +#else #define LBSIZE 512 /* Line length */ #define ESIZE 128 /* Size of compiled re */ +#endif #define RHSSIZE 256 /* Size of rhs of substitute */ #define NBRA 9 /* Number of re \( \) pairs */ #define TAGSIZE 32 /* Tag length */ @@ -41,13 +48,19 @@ #define UXBSIZE 128 /* Unix command buffer size */ #define VBSIZE 128 /* Partial line max size in visual */ /* LBLKS is also defined in expreserve.c */ +#ifndef VMUNIX #define LBLKS 125 /* Line pointer blocks in temp file */ +#define HBLKS 1 /* struct header fits in BUFSIZ*HBLKS */ +#else +#define LBLKS 900 +#define HBLKS 2 +#endif #define MAXDIRT 12 /* Max dirtcnt before sync tfile */ #define TCBUFSIZE 1024 /* Max entry size in termcap, see also termlib and termcap */ /* - * These are a ridiculously small due to the + * Except on VMUNIX, these are a ridiculously small due to the * lousy arglist processing implementation which fixes core * proportional to them. Argv (and hence NARGS) is really unnecessary, * and argument character space not needed except when @@ -55,22 +68,33 @@ * of the incore line information and could then * be reasonably large. */ +#ifndef VMUNIX #define NARGS 100 /* Maximum number of names in "next" */ -#define NCARGS 512 /* Maximum arglist chars in "next" */ +#define NCARGS LBSIZE /* Maximum arglist chars in "next" */ +#else +#define NCARGS 5120 +#define NARGS (NCARGS/6) +#endif /* * Note: because the routine "alloca" is not portable, TUBESIZE * bytes are allocated on the stack each time you go into visual - * and then never freed by the system. Thus if you have not terminals + * and then never freed by the system. Thus if you have no terminals * which are larger than 24 * 80 you may well want to make TUBESIZE * smaller. TUBECOLS should stay at 160 since this defines the maximum * length of opening on hardcopies and allows two lines of open on * terminals like adm3's (glass tty's) where it switches to pseudo * hardcopy mode when a line gets longer than 80 characters. */ -#define TUBELINES 36 /* Number of screen lines for visual */ +#ifndef VMUNIX +#define TUBELINES 40 /* Number of screen lines for visual */ #define TUBECOLS 160 /* Number of screen columns for visual */ -#define TUBESIZE 2880 /* Maximum screen size for visual */ +#define TUBESIZE 3400 /* Maximum screen size for visual */ +#else +#define TUBELINES 66 +#define TUBECOLS 160 +#define TUBESIZE 6600 /* 66 * 100 */ +#endif /* * Output column (and line) are set to this value on cursor addressible diff --git a/usr/src/usr.bin/ex/ex_vars.h b/usr/src/usr.bin/ex/ex_vars.h index b7b1fbd460..c3bd859427 100644 --- a/usr/src/usr.bin/ex/ex_vars.h +++ b/usr/src/usr.bin/ex/ex_vars.h @@ -9,8 +9,8 @@ #define IGNORECASE 8 #define LISP 9 #define LIST 10 -#define MAPINPUT 11 -#define MAGIC 12 +#define MAGIC 11 +#define MAPINPUT 12 #define NUMBER 13 #define OPEN 14 #define OPTIMIZE 15 diff --git a/usr/src/usr.bin/ex/ex_vget.c b/usr/src/usr.bin/ex/ex_vget.c index c1d1828c58..a4645a03e4 100644 --- a/usr/src/usr.bin/ex/ex_vget.c +++ b/usr/src/usr.bin/ex/ex_vget.c @@ -81,8 +81,9 @@ getATTN: return(*vmacp++); /* End of a macro or set of nested macros */ vmacp = 0; + if (inopen == -1) /* don't screw up undo for esc esc */ + vundkind = VMANY; inopen = 1; /* restore old setting now that macro done */ - vundkind = VMANY; } #ifdef TRACE if (trace) @@ -410,7 +411,7 @@ map(c,maps) if (trace) fprintf(trace,"fpk=0: return %c",c); #endif - macpush(&b[1]); + macpush(&b[1],1); return(c); } *q = getkey(); @@ -419,7 +420,7 @@ map(c,maps) if (*p != *q) goto contin; } - macpush(maps[d].mapto); + macpush(maps[d].mapto,1); c = getkey(); #ifdef MDEBUG if (trace) @@ -433,7 +434,7 @@ map(c,maps) if (trace) fprintf(trace,"Fail: return %c",c); /* DEBUG */ #endif - macpush(&b[1]); + macpush(&b[1],0); return(c); } @@ -442,9 +443,13 @@ map(c,maps) * worry about where vmacp was previously pointing. We also have to * check for overflow (which is typically from a recursive macro) * Finally we have to set a flag so the whole thing can be undone. + * canundo is 1 iff we want to be able to undo the macro. This + * is false for, for example, pushing back lookahead from fastpeekkey(), + * since otherwise two fast escapes can clobber our undo. */ -macpush(st) +macpush(st, canundo) char *st; +int canundo; { char tmpbuf[BUFSIZ]; @@ -456,17 +461,22 @@ char *st; #endif if (strlen(vmacp) + strlen(st) > BUFSIZ) error("Macro too long@ - maybe recursive?"); - if (vmacp) + if (vmacp) { strcpy(tmpbuf, vmacp); + canundo = 0; /* can't undo inside a macro anyway */ + } strcpy(vmacbuf, st); if (vmacp) strcat(vmacbuf, tmpbuf); vmacp = vmacbuf; /* arrange to be able to undo the whole macro */ - inopen = -1; /* no need to save since it had to be 1 or -1 before */ - otchng = tchng; - saveall(); - vundkind = VMANY; + if (canundo) { + inopen = -1; /* no need to save since it had to be 1 or -1 before */ + otchng = tchng; + vsave(); + saveall(); + vundkind = VMANY; + } #ifdef TRACE if (trace) fprintf(trace, "saveall for macro: undkind=%d, unddel=%d, undap1=%d, undap2=%d, dol=%d, unddol=%d, truedol=%d\n", undkind, lineno(unddel), lineno(undap1), lineno(undap2), lineno(dol), lineno(unddol), lineno(truedol)); @@ -505,6 +515,8 @@ fastpeekkey() int trapalarm(); register int c; + if (inopen == -1) /* don't work inside macros! */ + return (0); signal(SIGALRM, trapalarm); alarm(1); CATCH diff --git a/usr/src/usr.bin/ex/ex_vis.h b/usr/src/usr.bin/ex/ex_vis.h index b1a40cd060..9fac3bcfcb 100644 --- a/usr/src/usr.bin/ex/ex_vis.h +++ b/usr/src/usr.bin/ex/ex_vis.h @@ -192,8 +192,8 @@ char DEL[VBSIZE]; /* Last deleted text */ bool HADUP; /* This insert line started with ^ then ^D */ bool HADZERO; /* This insert line started with 0 then ^D */ char INS[VBSIZE]; /* Last inserted text */ -short Vlines; /* Number of file lines "before" vi command */ -short Xcnt; /* External variable holding last cmd's count */ +int Vlines; /* Number of file lines "before" vi command */ +int Xcnt; /* External variable holding last cmd's count */ bool Xhadcnt; /* Last command had explicit count? */ short ZERO; short dir; /* Direction for search (+1 or -1) */ @@ -203,7 +203,7 @@ bool hadcnt; /* (Almost) internal to vmain() */ bool heldech; /* We owe a clear of echo area */ bool insmode; /* Are in character insert mode */ char lastcmd[5]; /* Chars in last command */ -short lastcnt; /* Count for last command */ +int lastcnt; /* Count for last command */ char *lastcp; /* Save current command here to repeat */ bool lasthad; /* Last command had a count? */ short lastvgk; /* Previous input key, if not from keyboard */ @@ -214,7 +214,7 @@ char *notesgn; /* Change count from last command */ char op; /* Operation of current command */ short Peekkey; /* Peek ahead key */ bool rubble; /* Line is filthy (in hardcopy open), redraw! */ -short vSCROLL; /* Number lines to scroll on ^D/^U */ +int vSCROLL; /* Number lines to scroll on ^D/^U */ char *vglobp; /* Untyped input (e.g. repeat insert text) */ char vmacbuf[VBSIZE]; /* Text of visual macro, hence nonnestable */ char *vmacp; /* Like vglobp but for visual macros */ diff --git a/usr/src/usr.bin/ex/ex_vmain.c b/usr/src/usr.bin/ex/ex_vmain.c index 66bc38997d..e894dee246 100644 --- a/usr/src/usr.bin/ex/ex_vmain.c +++ b/usr/src/usr.bin/ex/ex_vmain.c @@ -644,6 +644,7 @@ insrt: case 'P': case 'p': vmoving = 0; + forbid (inopen < 0); /* * If previous delete was partial line, use an * append or insert to put it back so as to @@ -762,7 +763,10 @@ pfixup: vsave(); ckaw(); oglobp = globp; - globp = "e! #"; + if (value(AUTOWRITE)) + globp = "e! #"; + else + globp = "e #"; goto gogo; /* @@ -1000,6 +1004,7 @@ fixup: fonfon: beep(); vmacp = 0; + inopen = 1; /* might have been -1 */ continue; } diff --git a/usr/src/usr.bin/ex/ex_vops2.c b/usr/src/usr.bin/ex/ex_vops2.c index 23554f32aa..86334bc437 100644 --- a/usr/src/usr.bin/ex/ex_vops2.c +++ b/usr/src/usr.bin/ex/ex_vops2.c @@ -752,7 +752,7 @@ vgetsplit() /* * Vmaxrep determines the maximum repetitition factor * allowed that will yield total line length less than - * 512 characters and also does hacks for the R command. + * LBSIZE characters and also does hacks for the R command. */ vmaxrep(ch, cnt) char ch; -- 2.20.1