From 299f278421d9577cae984b8cf5e378de92f2e49b Mon Sep 17 00:00:00 2001 From: Mark Horton Date: Thu, 9 Jul 1981 05:36:48 -0800 Subject: [PATCH] release 3.7 - a few bug fixes and a few new features. SCCS-vsn: usr.bin/ex/ex.c 7.1 SCCS-vsn: usr.bin/ex/ex.h 7.1 SCCS-vsn: usr.bin/ex/ex_addr.c 7.1 SCCS-vsn: usr.bin/ex/ex_argv.h 7.1 SCCS-vsn: usr.bin/ex/ex_cmds.c 6.4 SCCS-vsn: usr.bin/ex/ex_cmds2.c 7.1 SCCS-vsn: usr.bin/ex/ex_cmdsub.c 7.1 SCCS-vsn: usr.bin/ex/ex_data.c 7.1 SCCS-vsn: usr.bin/ex/ex_get.c 7.1 SCCS-vsn: usr.bin/ex/ex_io.c 7.1 SCCS-vsn: usr.bin/ex/ex_put.c 7.1 SCCS-vsn: usr.bin/ex/ex_re.c 7.1 SCCS-vsn: usr.bin/ex/ex_re.h 7.1 SCCS-vsn: usr.bin/ex/ex_set.c 7.1 SCCS-vsn: usr.bin/ex/ex_subr.c 7.1 SCCS-vsn: usr.bin/ex/ex_temp.c 7.1 SCCS-vsn: usr.bin/ex/ex_temp.h 7.1 SCCS-vsn: usr.bin/ex/ex_tty.c 7.1 SCCS-vsn: usr.bin/ex/ex_tty.h 7.1 SCCS-vsn: usr.bin/ex/ex_tune.h 7.1 SCCS-vsn: usr.bin/ex/ex_v.c 7.1 SCCS-vsn: usr.bin/ex/ex_unix.c 7.1 SCCS-vsn: usr.bin/ex/ex_vadj.c 7.1 SCCS-vsn: usr.bin/ex/ex_vars.h 7.1 SCCS-vsn: usr.bin/ex/ex_vget.c 6.3 SCCS-vsn: usr.bin/ex/ex_vis.h 7.1 SCCS-vsn: usr.bin/ex/ex_vmain.c 7.1 SCCS-vsn: usr.bin/ex/ex_voper.c 7.1 SCCS-vsn: usr.bin/ex/ex_vops.c 7.1 SCCS-vsn: usr.bin/ex/ex_vops2.c 6.3 SCCS-vsn: usr.bin/ex/ex_vops3.c 7.1 SCCS-vsn: usr.bin/ex/ex_vput.c 7.1 SCCS-vsn: usr.bin/ex/ex_vwind.c 7.1 SCCS-vsn: usr.bin/ex/ex3.7preserve/ex3.7preserve.c 7.1 SCCS-vsn: usr.bin/ex/ex3.7recover/ex3.7recover.c 7.1 SCCS-vsn: usr.bin/ex/bcopy.c 7.1 SCCS-vsn: usr.bin/ex/Makefile 7.1 SCCS-vsn: usr.bin/ex/printf.c 7.1 --- usr/src/usr.bin/ex/Makefile | 10 +- usr/src/usr.bin/ex/bcopy.c | 4 +- usr/src/usr.bin/ex/ex.c | 18 +- usr/src/usr.bin/ex/ex.h | 188 ++++++++--------- .../usr.bin/ex/ex3.7preserve/ex3.7preserve.c | 14 +- .../usr.bin/ex/ex3.7recover/ex3.7recover.c | 23 +-- usr/src/usr.bin/ex/ex_addr.c | 4 +- usr/src/usr.bin/ex/ex_argv.h | 25 +-- usr/src/usr.bin/ex/ex_cmds.c | 4 +- usr/src/usr.bin/ex/ex_cmds2.c | 8 +- usr/src/usr.bin/ex/ex_cmdsub.c | 20 +- usr/src/usr.bin/ex/ex_data.c | 10 +- usr/src/usr.bin/ex/ex_get.c | 11 +- usr/src/usr.bin/ex/ex_io.c | 52 ++++- usr/src/usr.bin/ex/ex_put.c | 12 +- usr/src/usr.bin/ex/ex_re.c | 8 +- usr/src/usr.bin/ex/ex_re.h | 16 +- usr/src/usr.bin/ex/ex_set.c | 4 +- usr/src/usr.bin/ex/ex_subr.c | 5 +- usr/src/usr.bin/ex/ex_temp.c | 8 +- usr/src/usr.bin/ex/ex_temp.h | 33 +-- usr/src/usr.bin/ex/ex_tty.c | 12 +- usr/src/usr.bin/ex/ex_tty.h | 189 +++++++++--------- usr/src/usr.bin/ex/ex_tune.h | 12 +- usr/src/usr.bin/ex/ex_unix.c | 6 +- usr/src/usr.bin/ex/ex_v.c | 8 +- usr/src/usr.bin/ex/ex_vadj.c | 21 +- usr/src/usr.bin/ex/ex_vars.h | 2 +- usr/src/usr.bin/ex/ex_vget.c | 39 ++-- usr/src/usr.bin/ex/ex_vis.h | 135 ++++++------- usr/src/usr.bin/ex/ex_vmain.c | 4 +- usr/src/usr.bin/ex/ex_voper.c | 4 +- usr/src/usr.bin/ex/ex_vops.c | 6 +- usr/src/usr.bin/ex/ex_vops2.c | 14 +- usr/src/usr.bin/ex/ex_vops3.c | 4 +- usr/src/usr.bin/ex/ex_vput.c | 20 +- usr/src/usr.bin/ex/ex_vwind.c | 4 +- usr/src/usr.bin/ex/printf.c | 2 +- 38 files changed, 530 insertions(+), 429 deletions(-) diff --git a/usr/src/usr.bin/ex/Makefile b/usr/src/usr.bin/ex/Makefile index 43bcc26885..049c664470 100644 --- a/usr/src/usr.bin/ex/Makefile +++ b/usr/src/usr.bin/ex/Makefile @@ -1,6 +1,6 @@ -VERSION=3.6 +VERSION=3.7 # -# Ex skeletal makefile for VAX VM/Unix version 7 +# Ex skeletal makefile for VAX VM/Unix 4.1BSD # # NB: This makefile doesn't indicate any dependencies on header files. # @@ -36,7 +36,7 @@ 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 ex_io.o ex_put.o ex_re.o \ + ex_data.o ex_extern.o ex_get.o ex_io.o ex_put.o ex_re.o \ ex_set.o ex_subr.o ex_temp.o ex_tty.o ex_unix.o \ ex_v.o ex_vadj.o ex_vget.o ex_vmain.o ex_voper.o \ ex_vops.o ex_vops2.o ex_vops3.o ex_vput.o ex_vwind.o \ @@ -48,7 +48,7 @@ SRC3= ex_set.c ex_subr.c ex_temp.c ex_tty.c ex_unix.c SRC4= ex_v.c ex_vadj.c ex_vget.c ex_vmain.c ex_voper.c SRC5= ex_vops.c ex_vops2.c ex_vops3.c ex_vput.c ex_vwind.c SRC6= printf.c bcopy.c expreserve.c exrecover.c -MISC= makefile READ_ME :rofix +MISC= makefile READ_ME rofix VGRIND= csh /usr/ucb/vgrind VHDR= "Ex Version ${VERSION}" @@ -83,7 +83,7 @@ bcopy.o: bcopy.c strings.o: strings ${XSTR} ${CC} -c -S xs.c - ed - <:rofix xs.s + ed - 0) /* mjm */ *to++ = *from++; } #endif diff --git a/usr/src/usr.bin/ex/ex.c b/usr/src/usr.bin/ex/ex.c index c637da5fa1..169612f1cc 100644 --- a/usr/src/usr.bin/ex/ex.c +++ b/usr/src/usr.bin/ex/ex.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex.c 6.4 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex.c 7.1 %G%"; #include "ex.h" #include "ex_argv.h" #include "ex_temp.h" @@ -187,9 +187,11 @@ main(ac, av) tracef[9] = 0; } trace = fopen(tracef, "w"); +#define tracbuf NULL if (trace == NULL) printf("Trace create error\n"); - setbuf(trace, tracbuf); + else + setbuf(trace, tracbuf); break; #endif @@ -300,7 +302,7 @@ main(ac, av) setterm(cp); } } - if (setexit() == 0 && !fast && intty) + if (setexit() == 0 && !fast && intty) { if ((globp = getenv("EXINIT")) && *globp) commands(1,1); else { @@ -308,6 +310,14 @@ main(ac, av) if ((cp = getenv("HOME")) != 0 && *cp) source(strcat(strcpy(genbuf, cp), "/.exrc"), 1); } + /* + * Allow local .exrc too. This loses if . is $HOME, + * but nobody should notice unless they do stupid things + * like putting a version command in .exrc. Besides, + * they should be using EXINIT, not .exrc, right? + */ + source(".exrc", 1); + } init(); /* moved after prev 2 chunks to fix directory option */ /* diff --git a/usr/src/usr.bin/ex/ex.h b/usr/src/usr.bin/ex/ex.h index 5e93196506..bb48d3eaab 100644 --- a/usr/src/usr.bin/ex/ex.h +++ b/usr/src/usr.bin/ex/ex.h @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -/* sccs id: @(#)ex.h 6.1 %G% */ +/* Copyright (c) 1981 Regents of the University of California */ +/* sccs id: @(#)ex.h 7.1 %G% */ #ifdef V6 #include #endif @@ -100,7 +100,7 @@ struct option { #define value(a) options[a].ovalue #define svalue(a) options[a].osvalue -struct option options[NOPTS + 1]; +extern struct option options[NOPTS + 1]; /* @@ -117,10 +117,10 @@ struct option options[NOPTS + 1]; */ #ifdef TRACE # include - FILE *trace; - bool trubble; - bool techoin; - char tracbuf[BUFSIZ]; + extern FILE *trace; + extern bool trubble; + extern bool techoin; + extern char tracbuf[BUFSIZ]; # undef putchar # undef getchar #else @@ -152,67 +152,67 @@ struct option options[NOPTS + 1]; /* * Miscellaneous random variables used in more than one place */ -bool aiflag; /* Append/change/insert with autoindent */ -bool anymarks; /* We have used '[a-z] */ -int chng; /* Warn "No write" */ -char *Command; -short defwind; /* -w# change default window size */ -int dirtcnt; /* When >= MAXDIRT, should sync temporary */ +extern bool aiflag; /* Append/change/insert with autoindent */ +extern bool anymarks; /* We have used '[a-z] */ +extern int chng; /* Warn "No write" */ +extern char *Command; +extern short defwind; /* -w# change default window size */ +extern int dirtcnt; /* When >= MAXDIRT, should sync temporary */ #ifdef TIOCLGET -bool dosusp; /* Do SIGTSTP in visual when ^Z typed */ +extern bool dosusp; /* Do SIGTSTP in visual when ^Z typed */ #endif -bool edited; /* Current file is [Edited] */ -line *endcore; /* Last available core location */ -bool endline; /* Last cmd mode command ended with \n */ +extern bool edited; /* Current file is [Edited] */ +extern line *endcore; /* Last available core location */ +extern bool endline; /* Last cmd mode command ended with \n */ #ifndef VMUNIX -short erfile; /* Error message file unit */ +extern 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 */ -bool hush; /* Command line option - was given, hush up! */ -char *globp; /* (Untyped) input string to command mode */ -bool holdcm; /* Don't cursor address */ -bool inappend; /* in ex command append mode */ -bool inglobal; /* Inside g//... or v//... */ -char *initev; /* Initial : escape for visual */ -bool inopen; /* Inside open or visual */ -char *input; /* Current position in cmd line input buffer */ -bool intty; /* Input is a tty */ -short io; /* General i/o unit (auto-closed on error!) */ -short lastc; /* Last character ret'd from cmd input */ -bool laste; /* Last command was an "e" (or "rec") */ -char lastmac; /* Last macro called for ** */ -char lasttag[TAGSIZE]; /* Last argument to a tag command */ -char *linebp; /* Used in substituting in \n */ -char linebuf[LBSIZE]; /* The primary line buffer */ -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,' */ -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 oprompt; /* Saved during source */ -short ospeed; /* Output speed (from gtty) */ -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 */ -int pid; /* Process id of child */ -int ppid; /* Process id of parent (e.g. main ex proc) */ -jmp_buf resetlab; /* For error throws to top level (cmd mode) */ -int rpid; /* Pid returned from wait() */ -bool ruptible; /* Interruptible is normal state */ -bool seenprompt; /* 1 if have gotten user input */ -bool shudclob; /* Have a prompt to clobber (e.g. on ^D) */ -int status; /* Status returned from wait() */ -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 */ -bool writing; /* 1 if in middle of a file write */ -int xchng; /* Suppresses multiple "No writes" in !cmd */ +extern line *fendcore; /* First address in line pointer space */ +extern char file[FNSIZE]; /* Working file name */ +extern char genbuf[LBSIZE]; /* Working buffer when manipulating linebuf */ +extern bool hush; /* Command line option - was given, hush up! */ +extern char *globp; /* (Untyped) input string to command mode */ +extern bool holdcm; /* Don't cursor address */ +extern bool inappend; /* in ex command append mode */ +extern bool inglobal; /* Inside g//... or v//... */ +extern char *initev; /* Initial : escape for visual */ +extern bool inopen; /* Inside open or visual */ +extern char *input; /* Current position in cmd line input buffer */ +extern bool intty; /* Input is a tty */ +extern short io; /* General i/o unit (auto-closed on error!) */ +extern short lastc; /* Last character ret'd from cmd input */ +extern bool laste; /* Last command was an "e" (or "rec") */ +extern char lastmac; /* Last macro called for ** */ +extern char lasttag[TAGSIZE]; /* Last argument to a tag command */ +extern char *linebp; /* Used in substituting in \n */ +extern char linebuf[LBSIZE]; /* The primary line buffer */ +extern bool listf; /* Command should run in list mode */ +extern char *loc1; /* Where re began to match (in linebuf) */ +extern char *loc2; /* First char after re match (") */ +extern line names['z'-'a'+2]; /* Mark registers a-z,' */ +extern int notecnt; /* Count for notify (to visual from cmd) */ +extern bool numberf; /* Command should run in number mode */ +extern char obuf[BUFSIZ]; /* Buffer for tty output */ +extern short oprompt; /* Saved during source */ +extern short ospeed; /* Output speed (from gtty) */ +extern int otchng; /* Backup tchng to find changes in macros */ +extern short peekc; /* Peek ahead character (cmd mode input) */ +extern char *pkill[2]; /* Trim for put with ragged (LISP) delete */ +extern bool pfast; /* Have stty -nl'ed to go faster */ +extern int pid; /* Process id of child */ +extern int ppid; /* Process id of parent (e.g. main ex proc) */ +extern jmp_buf resetlab; /* For error throws to top level (cmd mode) */ +extern int rpid; /* Pid returned from wait() */ +extern bool ruptible; /* Interruptible is normal state */ +extern bool seenprompt; /* 1 if have gotten user input */ +extern bool shudclob; /* Have a prompt to clobber (e.g. on ^D) */ +extern int status; /* Status returned from wait() */ +extern int tchng; /* If nonzero, then [Modified] */ +extern short tfile; /* Temporary file unit */ +extern bool vcatch; /* Want to catch an error (open/visual) */ +extern jmp_buf vreslab; /* For error throws to a visual catch */ +extern bool writing; /* 1 if in middle of a file write */ +extern int xchng; /* Suppresses multiple "No writes" in !cmd */ /* * Macros @@ -244,11 +244,11 @@ int xchng; /* Suppresses multiple "No writes" in !cmd */ /* * Environment like memory */ -char altfile[FNSIZE]; /* Alternate file name */ -char direct[ONMSZ]; /* Temp file goes here */ -char shell[ONMSZ]; /* Copied to be settable */ -char ttytype[ONMSZ]; /* A long and pretty name */ -char uxb[UXBSIZE + 2]; /* Last !command for !! */ +extern char altfile[FNSIZE]; /* Alternate file name */ +extern char direct[ONMSZ]; /* Temp file goes here */ +extern char shell[ONMSZ]; /* Copied to be settable */ +extern char ttytype[ONMSZ]; /* A long and pretty name */ +extern char uxb[UXBSIZE + 2]; /* Last !command for !! */ /* * The editor data structure for accessing the current file consists @@ -263,14 +263,14 @@ char uxb[UXBSIZE + 2]; /* Last !command for !! */ * dol and unddol, a copy of the entire, pre-command buffer state * is saved between unddol and truedol. */ -line *addr1; /* First addressed line in a command */ -line *addr2; /* Second addressed line */ -line *dol; /* Last line in buffer */ -line *dot; /* Current line */ -line *one; /* First line */ -line *truedol; /* End of all lines, including saves */ -line *unddol; /* End of undo saved lines */ -line *zero; /* Points to empty slot before one */ +extern line *addr1; /* First addressed line in a command */ +extern line *addr2; /* Second addressed line */ +extern line *dol; /* Last line in buffer */ +extern line *dot; /* Current line */ +extern line *one; /* First line */ +extern line *truedol; /* End of all lines, including saves */ +extern line *unddol; /* End of undo saved lines */ +extern line *zero; /* Points to empty slot before one */ /* * Undo information @@ -286,12 +286,12 @@ line *zero; /* Points to empty slot before one */ * are lines saved between dol and unddol we don't stick these back * into the buffer. */ -short undkind; +extern short undkind; -line *unddel; /* Saved deleted lines go after here */ -line *undap1; /* Beginning of new lines */ -line *undap2; /* New lines end before undap2 */ -line *undadot; /* If we saved all lines, dot reverts here */ +extern line *unddel; /* Saved deleted lines go after here */ +extern line *undap1; /* Beginning of new lines */ +extern line *undap2; /* New lines end before undap2 */ +extern line *undadot; /* If we saved all lines, dot reverts here */ #define UNDCHANGE 0 #define UNDMOVE 1 @@ -305,13 +305,13 @@ line *undadot; /* If we saved all lines, dot reverts here */ */ #define KSIZE 9 /* key size for encryption */ #define KEYPROMPT "Key: " -int xflag; /* True if we are in encryption mode */ -int xtflag; /* True if the temp file is being encrypted */ -int kflag; /* True if the key has been accepted */ -char perm[768]; -char tperm[768]; -char *key; -char crbuf[CRSIZE]; +extern int xflag; /* True if we are in encryption mode */ +extern int xtflag; /* True if the temp file is being encrypted */ +extern int kflag; /* True if the key has been accepted */ +extern char perm[768]; +extern char tperm[768]; +extern char *key; +extern char crbuf[CRSIZE]; char *getpass(); #endif @@ -321,10 +321,10 @@ char *getpass(); #define NOSTR (char *) 0 #define NOLINE (line *) 0 -int (*Outchar)(); -int (*Pline)(); -int (*Putchar)(); -int (*oldhup)(); +extern int (*Outchar)(); +extern int (*Pline)(); +extern int (*Putchar)(); +extern int (*oldhup)(); int (*setlist())(); int (*setnorm())(); int (*setnorm())(); @@ -369,7 +369,7 @@ off_t lseek(); int normchar(); int normline(); int numbline(); -int (*oldquit)(); +extern int (*oldquit)(); int onhup(); int onintr(); int onsusp(); 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 ccac6399d3..a3774ccb67 100644 --- a/usr/src/usr.bin/ex/ex3.7preserve/ex3.7preserve.c +++ b/usr/src/usr.bin/ex/ex3.7preserve/ex3.7preserve.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex3.7preserve.c 6.1 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex3.7preserve.c 7.1 %G%"; #include #include #include @@ -7,11 +7,11 @@ static char *sccsid = "@(#)ex3.7preserve.c 6.1 %G%"; #include #include #include "local/uparm.h" + /* mjm: "/tmp" --> TMP */ +#define TMP "/3b/tmp" #ifdef VMUNIX #define HBLKS 2 -#else -#define HBLKS 1 #endif /* @@ -94,14 +94,14 @@ main(argc) */ if (chdir("/tmp") < 0) { perror("/tmp"); - exit(1); - } + if (chdir(TMP) < 0) { + perror(TMP); tf = fopen(".", "r"); if (tf == NULL) { perror("/tmp"); exit(1); - } + perror(TMP); while (fread((char *) &dirent, sizeof dirent, 1, tf) == 1) { if (dirent.d_ino == 0) continue; 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 97a23e6268..75a6b69725 100644 --- a/usr/src/usr.bin/ex/ex3.7recover/ex3.7recover.c +++ b/usr/src/usr.bin/ex/ex3.7recover/ex3.7recover.c @@ -1,21 +1,20 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex3.7recover.c 6.1 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex3.7recover.c 7.1 %G%"; +#include /* mjm: BUFSIZ: stdio = 512, VMUNIX = 1024 */ +#undef BUFSIZ /* mjm: BUFSIZ different */ +#undef EOF /* mjm: EOF and NULL effectively the same */ +#undef NULL #include "ex.h" #include "ex_temp.h" #include "ex_tty.h" #include "local/uparm.h" -#undef BUFSIZ -#undef EOF -#undef NULL +/* #undef BUFSIZ mjm: move to before ex.h */ +/* #undef EOF mjm: move to before ex.h */ +/* #undef NULL mjm: move to before ex.h */ -#include +/* #include mjm: move to before ex.h */ #include - -/* - * Ex recovery program - * exrecover dir name - * exrecover -r * * This program searches through the specified directory and then * the directory usrpath(preserve) looking for an instance of the specified @@ -139,7 +138,7 @@ main(argc, argv) */ if (dol > zero) { addr1 = one; addr2 = dol; io = 1; - putfile(); + putfile(0); } /* diff --git a/usr/src/usr.bin/ex/ex_addr.c b/usr/src/usr.bin/ex/ex_addr.c index 81d30321dd..d6cd3f6f5d 100644 --- a/usr/src/usr.bin/ex/ex_addr.c +++ b/usr/src/usr.bin/ex/ex_addr.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1979 Regents of the University of California */ -static char *sccsid = "@(#)ex_addr.c 6.1 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_addr.c 7.1 %G%"; #include "ex.h" #include "ex_re.h" diff --git a/usr/src/usr.bin/ex/ex_argv.h b/usr/src/usr.bin/ex/ex_argv.h index 963eda2c6e..4fded2d62e 100644 --- a/usr/src/usr.bin/ex/ex_argv.h +++ b/usr/src/usr.bin/ex/ex_argv.h @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -/* sccs id: @(#)ex_argv.h 6.1 %G% */ +/* Copyright (c) 1981 Regents of the University of California */ +/* sccs id: @(#)ex_argv.h 7.1 %G% */ /* * The current implementation of the argument list is poor, * using an argv even for internally done "next" commands. @@ -7,16 +7,16 @@ * space. The statically allocated glob structure could be replaced * by a dynamically allocated argument area space. */ -char **argv; -char **argv0; -char *args; -char *args0; -short argc; -short argc0; -short morargc; /* Used with "More files to edit..." */ +extern char **argv; +extern char **argv0; +extern char *args; +extern char *args0; +extern short argc; +extern short argc0; +extern short morargc; /* Used with "More files to edit..." */ -int firstln; /* From +lineno */ -char *firstpat; /* From +/pat */ +extern int firstln; /* From +lineno */ +extern char *firstpat; /* From +/pat */ /* Yech... */ struct glob { @@ -24,4 +24,5 @@ struct glob { short argc0; /* Number of arguments in argv */ char *argv[NARGS + 1]; /* WHAT A WASTE! */ char argspac[NCARGS + sizeof (int)]; -} frob; +}; +extern struct glob frob; diff --git a/usr/src/usr.bin/ex/ex_cmds.c b/usr/src/usr.bin/ex/ex_cmds.c index 8c8f9d5229..f85900c5e9 100644 --- a/usr/src/usr.bin/ex/ex_cmds.c +++ b/usr/src/usr.bin/ex/ex_cmds.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_cmds.c 6.3 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_cmds.c 6.4 %G%"; #include "ex.h" #include "ex_argv.h" #include "ex_temp.h" diff --git a/usr/src/usr.bin/ex/ex_cmds2.c b/usr/src/usr.bin/ex/ex_cmds2.c index ba014c5876..5f23ae2616 100644 --- a/usr/src/usr.bin/ex/ex_cmds2.c +++ b/usr/src/usr.bin/ex/ex_cmds2.c @@ -1,13 +1,13 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_cmds2.c 6.1 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_cmds2.c 7.1 %G%"; #include "ex.h" #include "ex_argv.h" #include "ex_temp.h" #include "ex_tty.h" #include "ex_vis.h" -bool pflag, nflag; -int poffset; +extern bool pflag, nflag; /* mjm: extern; also in ex_cmds.c */ +extern int poffset; /* mjm: extern; also in ex_cmds.c */ /* * Subroutines for major command loop. diff --git a/usr/src/usr.bin/ex/ex_cmdsub.c b/usr/src/usr.bin/ex/ex_cmdsub.c index d90aa9504c..70169bbd08 100644 --- a/usr/src/usr.bin/ex/ex_cmdsub.c +++ b/usr/src/usr.bin/ex/ex_cmdsub.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_cmdsub.c 6.1 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_cmdsub.c 7.1 %G%"; #include "ex.h" #include "ex_argv.h" #include "ex_temp.h" @@ -257,7 +257,7 @@ move() setdot(); } nonzero(); - adt = address(0); + adt = address((char*)0); if (adt == 0) serror("%s where?|%s requires a trailing address", Command); newline(); @@ -469,7 +469,7 @@ tagfind(quick) int tfcount = 0; int omagic; char *fn, *fne; -#ifdef VMUNIX +#ifdef STDIO /* mjm: was VMUNIX */ /* * We have lots of room so we bring in stdio and do * a binary search on the tags file. @@ -520,7 +520,7 @@ badtag: fne = 0; /* done, quit after this time */ else *fne = 0; /* null terminate filename */ -#ifdef VMUNIX +#ifdef STDIO /* mjm: was VMUNIX */ iof = fopen(fn, "r"); if (iof == NULL) continue; @@ -547,7 +547,7 @@ badtag: register char *lp = lasttag; char *oglobp; -#ifdef VMUNIX +#ifdef STDIO /* mjm: was VMUNIX */ mid = (top + bot) / 2; fseek(iof, mid, 0); if (mid > 0) /* to get first tag in file to work */ @@ -562,7 +562,7 @@ badtag: while (*cp && *lp == *cp) cp++, lp++; if ((*lp || !iswhite(*cp)) && (value(TAGLENGTH)==0 || lp-lasttag < value(TAGLENGTH))) { -#ifdef VMUNIX +#ifdef STDIO /* mjm: was VMUNIX */ if (*lp > *cp) bot = mid + 1; else @@ -576,7 +576,7 @@ goleft: /* * We found the tag. Decode the line in the file. */ -#ifdef VMUNIX +#ifdef STDIO /* mjm: was VMUNIX */ fclose(iof); #else close(io); @@ -658,7 +658,7 @@ badtags: /* * No such tag in this file. Close it and try the next. */ -#ifdef VMUNIX +#ifdef STDIO /* mjm: was VMUNIX */ fclose(iof); #else close(io); @@ -1069,7 +1069,7 @@ mapcmd(un, ab) { char lhs[100], rhs[100]; /* max sizes resp. */ register char *p; - register char c; + register int c; /* mjm: char --> int */ char *dname; struct maps *mp; /* the map structure we are working on */ diff --git a/usr/src/usr.bin/ex/ex_data.c b/usr/src/usr.bin/ex/ex_data.c index 355feda077..efe0f93486 100644 --- a/usr/src/usr.bin/ex/ex_data.c +++ b/usr/src/usr.bin/ex/ex_data.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_data.c 6.1 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_data.c 7.1 %G%"; #include "ex.h" #include "ex_tty.h" @@ -12,15 +12,17 @@ static char *sccsid = "@(#)ex_data.c 6.1 %G%"; * to confuse xstr so it will leave them alone. */ char direct[ONMSZ] = - { '/', 't', 'm', 'p' }; + {'/', 't', 'm', 'p'}; char paragraphs[ONMSZ] = { 'I', 'P', 'L', 'P', 'P', 'P', 'Q', 'P', /* -ms macros */ 'P', ' ', 'L', 'I', /* -mm macros */ + 'p', 'p', 'l', 'p', 'i', 'p', /* -me macros */ 'b', 'p' /* bare nroff */ }; char sections[ONMSZ] = { 'N', 'H', 'S', 'H', /* -ms macros */ - 'H', ' ', 'H', 'U' /* -mm macros */ + 'H', ' ', 'H', 'U', /* -mm macros */ + 'n', 'h', 's', 'h' /* -me macros */ }; char shell[ONMSZ] = { '/', 'b', 'i', 'n', '/', 's', 'h' }; diff --git a/usr/src/usr.bin/ex/ex_get.c b/usr/src/usr.bin/ex/ex_get.c index 9f41fab407..4fd513561e 100644 --- a/usr/src/usr.bin/ex/ex_get.c +++ b/usr/src/usr.bin/ex/ex_get.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_get.c 6.1 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_get.c 7.1 %G%"; #include "ex.h" #include "ex_tty.h" @@ -55,7 +55,6 @@ peekchar() peekcd() { - if (peekc == 0) peekc = getcd(); return (peekc); @@ -65,6 +64,7 @@ getach() { register int c; static char inline[128]; + struct stat statb; c = peekc; if (c != 0) { @@ -102,8 +102,11 @@ top: input = inline; goto top; } - if (read(0, (char *) &lastc, 1) != 1) +/* mjm: if (read(0, (char *) &lastc, 1) != 1) CHANGED and added else */ + if (read(0, inline, 1) != 1) lastc = EOF; + else /* mjm: lastc is a short! */ + lastc = inline[0]; /* mjm: in rightmost 8 bits ! */ return (lastc); } diff --git a/usr/src/usr.bin/ex/ex_io.c b/usr/src/usr.bin/ex/ex_io.c index f87721a7a0..a6754e8544 100644 --- a/usr/src/usr.bin/ex/ex_io.c +++ b/usr/src/usr.bin/ex/ex_io.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_io.c 6.2 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_io.c 7.1 %G%"; #include "ex.h" #include "ex_argv.h" #include "ex_temp.h" @@ -352,7 +352,7 @@ rop(c) break; switch (magic) { - case 0405: /* Interdata? overlay */ + case 0405: /* data overlay on exec */ case 0407: /* unshared */ case 0410: /* shared text */ case 0411: /* separate I/D */ @@ -406,10 +406,19 @@ rop(c) rop2() { + line *first, *last, *a; deletenone(); clrstats(); + first = addr2 + 1; ignore(append(getfile, addr2)); + last = dot; + for (a=first; a<=last; a++) { + if (a==first+5 && last-first > 10) + a = last - 4; + getline(*a); + checkmodeline(linebuf); + } } rop3(c) @@ -574,7 +583,7 @@ cre: lseek(io, 0l, 2); break; } - putfile(); + putfile(0); ignore(iostats()); if (c != 2 && addr1 == one && addr2 == dol) { if (eq(file, savedfile)) @@ -664,7 +673,8 @@ cntch); /* * Write a range onto the io stream. */ -putfile() +putfile(isfilter) +int isfilter; { line *a1; register char *fp, *lp; @@ -684,7 +694,7 @@ putfile() if (--nib < 0) { nib = fp - genbuf; #ifdef CRYPT - if(kflag) + if(kflag && !isfilter) crblock(perm, genbuf, nib, cntch); #endif if (write(io, genbuf, nib) != nib) { @@ -702,7 +712,7 @@ putfile() } while (a1 <= addr2); nib = fp - genbuf; #ifdef CRYPT - if(kflag) + if(kflag && !isfilter) crblock(perm, genbuf, nib, cntch); #endif if (write(io, genbuf, nib) != nib) { @@ -830,3 +840,31 @@ iostats() } return (cntnull != 0 || cntodd != 0); } + +#if USG | USG3TTY +/* It's so wonderful how we all speak the same language... */ +# define index strchr +# define rindex strrchr +#endif + +checkmodeline(line) +char *line; +{ + char *beg, *end; + char cmdbuf[1024]; + char *index(), *rindex(); + + beg = index(line, ':'); + if (beg == NULL) + return; + if (beg[-2] != 'e' && beg[-2] != 'v') return; + if (beg[-1] != 'x' && beg[-1] != 'i') return; + + strncpy(cmdbuf, beg+1, sizeof cmdbuf); + end = rindex(cmdbuf, ':'); + if (end == NULL) + return; + *end = 0; + globp = cmdbuf; + commands(1, 1); +} diff --git a/usr/src/usr.bin/ex/ex_put.c b/usr/src/usr.bin/ex/ex_put.c index 4bcdd0094b..16ec31bfc3 100644 --- a/usr/src/usr.bin/ex/ex_put.c +++ b/usr/src/usr.bin/ex/ex_put.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_put.c 6.4 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_put.c 7.1 %G%"; #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -300,7 +300,7 @@ flush1() outcol++; destcol++; if (XN && outcol % COLUMNS == 0) - putch('\n'); + putch('\r'), putch('\n'); } c = *lp++; if (c <= ' ') @@ -636,6 +636,8 @@ dontcr: if (!inopen || vtube[outline]==NULL || (i=vtube[outline][outcol]) < ' ') i = ' '; + if(i & QUOTE) /* mjm: no sign extension on 3B */ + i = ' '; if (insmode && ND) tputs(ND, 0, plodput); else @@ -735,6 +737,10 @@ putch(c) int c; { +#ifdef OLD3BTTY /* mjm */ + if(c == '\n') /* mjm: Fake "\n\r" for '\n' til fix in 3B firmware */ + putch('\r'); /* mjm: vi does "stty -icanon" => -onlcr !! */ +#endif *obp++ = c & 0177; if (obp >= &obuf[sizeof obuf]) flusho(); diff --git a/usr/src/usr.bin/ex/ex_re.c b/usr/src/usr.bin/ex/ex_re.c index c9c433a45b..de79356446 100644 --- a/usr/src/usr.bin/ex/ex_re.c +++ b/usr/src/usr.bin/ex/ex_re.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_re.c 6.2 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_re.c 7.1 %G%"; #include "ex.h" #include "ex_re.h" @@ -423,6 +423,10 @@ dosub() *sp++ = *lp++; casecnt = 0; while (c = *rp++) { + /* ^V from vi to split lines */ + if (c == '\r') + c = '\n'; + if (c & QUOTE) switch (c & TRIM) { diff --git a/usr/src/usr.bin/ex/ex_re.h b/usr/src/usr.bin/ex/ex_re.h index 9fcb977f5e..9452243c7d 100644 --- a/usr/src/usr.bin/ex/ex_re.h +++ b/usr/src/usr.bin/ex/ex_re.h @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -/* sccs id: @(#)ex_re.h 6.1 %G% */ +/* Copyright (c) 1981 Regents of the University of California */ +/* sccs id: @(#)ex_re.h 7.1 %G% */ /* * Regular expression definitions. * The regular expressions in ex are similar to those in ed, @@ -21,9 +21,9 @@ struct regexp { * It would be possible to get rid of "re" by making it a stack parameter * to the appropriate routines. */ -struct regexp re; /* Last re */ -struct regexp scanre; /* Last scanning re */ -struct regexp subre; /* Last substitute re */ +extern struct regexp re; /* Last re */ +extern struct regexp scanre; /* Last scanning re */ +extern struct regexp subre; /* Last substitute re */ /* * Defining circfl and expbuf like this saves us from having to change @@ -43,9 +43,9 @@ struct regexp subre; /* Last substitute re */ /* * Definitions for substitute */ -char *braslist[NBRA]; /* Starts of \(\)'ed text in lhs */ -char *braelist[NBRA]; /* Ends... */ -char rhsbuf[RHSSIZE]; /* Rhs of last substitute */ +extern char *braslist[NBRA]; /* Starts of \(\)'ed text in lhs */ +extern char *braelist[NBRA]; /* Ends... */ +extern char rhsbuf[RHSSIZE]; /* Rhs of last substitute */ /* * Definitions of codes for the compiled re's. diff --git a/usr/src/usr.bin/ex/ex_set.c b/usr/src/usr.bin/ex/ex_set.c index 67ddeeab22..e90be31dfa 100644 --- a/usr/src/usr.bin/ex/ex_set.c +++ b/usr/src/usr.bin/ex/ex_set.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_set.c 6.3 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_set.c 7.1 %G%"; #include "ex.h" #include "ex_temp.h" #include "ex_tty.h" diff --git a/usr/src/usr.bin/ex/ex_subr.c b/usr/src/usr.bin/ex/ex_subr.c index 9a85e559ca..ade400f95c 100644 --- a/usr/src/usr.bin/ex/ex_subr.c +++ b/usr/src/usr.bin/ex/ex_subr.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_subr.c 6.3 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_subr.c 7.1 %G%"; #include "ex.h" #include "ex_re.h" #include "ex_tty.h" @@ -875,6 +875,7 @@ onintr() #else signal(SIGINT, inopen ? vintr : onintr); #endif + alarm(0); /* in case we were called from map */ draino(); if (!inopen) { pstop(); diff --git a/usr/src/usr.bin/ex/ex_temp.c b/usr/src/usr.bin/ex/ex_temp.c index ffba5c1820..a6e551b6e5 100644 --- a/usr/src/usr.bin/ex/ex_temp.c +++ b/usr/src/usr.bin/ex/ex_temp.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_temp.c 6.2 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_temp.c 7.1 %G%"; #include "ex.h" #include "ex_temp.h" #include "ex_vis.h" @@ -15,7 +15,7 @@ static char *sccsid = "@(#)ex_temp.c 6.2 %G%"; char tfname[40]; char rfname[40]; int havetmp; -short tfile = -1; +/* short tfile = -1; mjm: in ex_space.c */ short rfile = -1; fileinit() @@ -331,7 +331,7 @@ oops: TSYNC() { - if (dirtcnt > 12) { + if (dirtcnt > MAXDIRT) { /* mjm: 12 --> MAXDIRT */ #ifdef VMUNIX if (stilinc) tflush(); diff --git a/usr/src/usr.bin/ex/ex_temp.h b/usr/src/usr.bin/ex/ex_temp.h index 40bd34bec1..e101ff6c0a 100644 --- a/usr/src/usr.bin/ex/ex_temp.h +++ b/usr/src/usr.bin/ex/ex_temp.h @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -/* sccs id: @(#)ex_temp.h 6.1 %G% */ +/* Copyright (c) 1981 Regents of the University of California */ +/* sccs id: @(#)ex_temp.h 7.1 %G% */ /* * The editor uses a temporary file for files being edited, in a structure * similar to that of ed. The first block of the file is used for a header @@ -64,23 +64,23 @@ * spends (spent) roughly 30% of its time in the system read routine, * this can be a big help. */ -bool hitin2; /* Last read hit was ibuff2 not ibuff */ -bool ichang2; /* Have actually changed ibuff2 */ -bool ichanged; /* Have actually changed ibuff */ -short iblock; /* Temp file block number of ibuff (or -1) */ -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) */ +extern bool hitin2; /* Last read hit was ibuff2 not ibuff */ +extern bool ichang2; /* Have actually changed ibuff2 */ +extern bool ichanged; /* Have actually changed ibuff */ +extern short iblock; /* Temp file block number of ibuff (or -1) */ +extern short iblock2; /* Temp file block number of ibuff2 (or -1) */ +extern short ninbuf; /* Number useful chars left in input buffer */ +extern short nleft; /* Number usable chars left in output buffer */ +extern short oblock; /* Temp file block number of obuff (or -1) */ #ifndef VMUNIX -short tline; /* Current temp file ptr */ +extern short tline; /* Current temp file ptr */ #else -int tline; +extern int tline; #endif -char ibuff[BUFSIZ]; -char ibuff2[BUFSIZ]; -char obuff[BUFSIZ]; +extern char ibuff[BUFSIZ]; +extern char ibuff2[BUFSIZ]; +extern char obuff[BUFSIZ]; /* * Structure of the descriptor block which resides @@ -107,7 +107,8 @@ struct header { #endif char Savedfile[FNSIZE]; /* The current file name */ short Blocks[LBLKS]; /* Blocks where line pointers stashed */ -} H; +}; +extern struct header H; #define uid H.Uid #define flines H.Flines diff --git a/usr/src/usr.bin/ex/ex_tty.c b/usr/src/usr.bin/ex/ex_tty.c index d84bbc0538..2f2509e560 100644 --- a/usr/src/usr.bin/ex/ex_tty.c +++ b/usr/src/usr.bin/ex/ex_tty.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_tty.c 6.2 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_tty.c 7.1 %G%"; #include "ex.h" #include "ex_tty.h" @@ -8,7 +8,7 @@ static char *sccsid = "@(#)ex_tty.c 6.2 %G%"; * and calculation of flags at entry or after * a shell escape which may change them. */ -short ospeed = -1; +/* short ospeed = -1; mjm: def also in tputs.c of termcap.a */ gettmode() { @@ -26,7 +26,7 @@ gettmode() #else if (ioctl(1, TCGETA, &tty) < 0) return; - if (ospeed != tty.c_cflag & CBAUD) + if (ospeed != (tty.c_cflag & CBAUD)) /* mjm */ value(SLOWOPEN) = (tty.c_cflag & CBAUD) < B1200; ospeed = tty.c_cflag & CBAUD; normf = tty; @@ -45,7 +45,7 @@ char **sstrs[] = { }; bool *sflags[] = { &AM, &BS, &DA, &DB, &EO, &HC, &HZ, &IN, &MI, &NC, &NS, &OS, &UL, - &XB, &XN, &XT, &XX + &XB, &XN, &XT, &XV, &XX }; char **fkeys[10] = { &F0, &F1, &F2, &F3, &F4, &F5, &F6, &F7, &F8, &F9 @@ -146,7 +146,7 @@ zap() register bool **fp; register char ***sp; - namp = "ambsdadbeohchzinmincnsosulxbxnxtxx"; + namp = "ambsdadbeohchzinmincnsosulxbxnxtxvxx"; fp = sflags; do { *(*fp++) = tgetflag(namp); diff --git a/usr/src/usr.bin/ex/ex_tty.h b/usr/src/usr.bin/ex/ex_tty.h index f4dd64c6f2..4f7a5bd6bd 100644 --- a/usr/src/usr.bin/ex/ex_tty.h +++ b/usr/src/usr.bin/ex/ex_tty.h @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -/* sccs id: @(#)ex_tty.h 6.1 %G% */ +/* Copyright (c) 1981 Regents of the University of California */ +/* sccs id: @(#)ex_tty.h 7.1 %G% */ /* * Capabilities from termcap * @@ -26,87 +26,88 @@ * before the capability to say 12 milliseconds per affected whatever * (currently always line). Capabilities where this makes sense say P*. */ -char tspace[256]; /* Space for capability strings */ -char *aoftspace; /* Address of tspace for relocation */ +extern char tspace[256]; /* Space for capability strings */ +extern char *aoftspace; /* Address of tspace for relocation */ -char *AL; /* P* Add new blank line */ -char *BC; /* Back cursor */ -char *BT; /* P Back tab */ -char *CD; /* P* Clear to end of display */ -char *CE; /* P Clear to end of line */ -char *CL; /* P* Clear screen */ -char *CM; /* P Cursor motion */ -char *xCR; /* P Carriage return */ -char *DC; /* P* Delete character */ -char *DL; /* P* Delete line sequence */ -char *DM; /* Delete mode (enter) */ -char *DO; /* Down line sequence */ -char *ED; /* End delete mode */ -char *EI; /* End insert mode */ -char *F0,*F1,*F2,*F3,*F4,*F5,*F6,*F7,*F8,*F9; +extern char *AL; /* P* Add new blank line */ +extern char *BC; /* Back cursor */ +extern char *BT; /* P Back tab */ +extern char *CD; /* P* Clear to end of display */ +extern char *CE; /* P Clear to end of line */ +extern char *CL; /* P* Clear screen */ +extern char *CM; /* P Cursor motion */ +extern char *xCR; /* P Carriage return */ +extern char *DC; /* P* Delete character */ +extern char *DL; /* P* Delete line sequence */ +extern char *DM; /* Delete mode (enter) */ +extern char *DO; /* Down line sequence */ +extern char *ED; /* End delete mode */ +extern char *EI; /* End insert mode */ +extern char *F0,*F1,*F2,*F3,*F4,*F5,*F6,*F7,*F8,*F9; /* Strings sent by various function keys */ -char *HO; /* Home cursor */ -char *IC; /* P Insert character */ -char *IM; /* Insert mode (give as ':im=:' if 'ic' */ -char *IP; /* P* Insert pad after char ins'd using IM+IE */ -char *KD; /* Keypad down arrow */ -char *KE; /* Keypad don't xmit */ -char *KH; /* Keypad home key */ -char *KL; /* Keypad left arrow */ -char *KR; /* Keypad right arrow */ -char *KS; /* Keypad start xmitting */ -char *KU; /* Keypad up arrow */ -char *LL; /* Quick to last line, column 0 */ -char *ND; /* Non-destructive space */ -char *xNL; /* Line feed (new line) */ -char PC; /* Pad character */ -char *SE; /* Standout end (may leave space) */ -char *SF; /* P Scroll forwards */ -char *SO; /* Stand out begin (may leave space) */ -char *SR; /* P Scroll backwards */ -char *TA; /* P Tab (other than ^I or with padding) */ -char *TE; /* Terminal end sequence */ -char *TI; /* Terminal initial sequence */ -char *UP; /* Upline */ -char *VB; /* Visible bell */ -char *VE; /* Visual end sequence */ -char *VS; /* Visual start sequence */ -bool AM; /* Automatic margins */ -bool BS; /* Backspace works */ -bool CA; /* Cursor addressible */ -bool DA; /* Display may be retained above */ -bool DB; /* Display may be retained below */ -bool EO; /* Can erase overstrikes with ' ' */ -bool GT; /* Gtty indicates tabs */ -bool HC; /* Hard copy terminal */ -bool HZ; /* Hazeltine ~ braindamage */ -bool IN; /* Insert-null blessing */ -bool MI; /* can move in insert mode */ -bool NC; /* No Cr - \r snds \r\n then eats \n (dm2500) */ -bool NS; /* No scroll - linefeed at bottom won't scroll */ -bool OS; /* Overstrike works */ -bool UL; /* Underlining works even though !os */ -bool XB; /* Beehive (no escape key, simulate with f1) */ -bool XN; /* A newline gets eaten after wrap (concept) */ -bool XT; /* Tabs are destructive */ -bool XX; /* Tektronix 4025 insert line */ +extern char *HO; /* Home cursor */ +extern char *IC; /* P Insert character */ +extern char *IM; /* Insert mode (give as ':im=:' if 'ic' */ +extern char *IP; /* P* Insert pad after char ins'd using IM+IE */ +extern char *KD; /* Keypad down arrow */ +extern char *KE; /* Keypad don't xmit */ +extern char *KH; /* Keypad home key */ +extern char *KL; /* Keypad left arrow */ +extern char *KR; /* Keypad right arrow */ +extern char *KS; /* Keypad start xmitting */ +extern char *KU; /* Keypad up arrow */ +extern char *LL; /* Quick to last line, column 0 */ +extern char *ND; /* Non-destructive space */ +extern char *xNL; /* Line feed (new line) */ +extern char PC; /* Pad character */ +extern char *SE; /* Standout end (may leave space) */ +extern char *SF; /* P Scroll forwards */ +extern char *SO; /* Stand out begin (may leave space) */ +extern char *SR; /* P Scroll backwards */ +extern char *TA; /* P Tab (other than ^I or with padding) */ +extern char *TE; /* Terminal end sequence */ +extern char *TI; /* Terminal initial sequence */ +extern char *UP; /* Upline */ +extern char *VB; /* Visible bell */ +extern char *VE; /* Visual end sequence */ +extern char *VS; /* Visual start sequence */ +extern bool AM; /* Automatic margins */ +extern bool BS; /* Backspace works */ +extern bool CA; /* Cursor addressible */ +extern bool DA; /* Display may be retained above */ +extern bool DB; /* Display may be retained below */ +extern bool EO; /* Can erase overstrikes with ' ' */ +extern bool GT; /* Gtty indicates tabs */ +extern bool HC; /* Hard copy terminal */ +extern bool HZ; /* Hazeltine ~ braindamage */ +extern bool IN; /* Insert-null blessing */ +extern bool MI; /* can move in insert mode */ +extern bool NC; /* No Cr - \r snds \r\n then eats \n (dm2500) */ +extern bool NS; /* No scroll - linefeed at bottom won't scroll */ +extern bool OS; /* Overstrike works */ +extern bool UL; /* Underlining works even though !os */ +extern bool XB; /* Beehive (no escape key, simulate with f1) */ +extern bool XN; /* A newline gets eaten after wrap (concept) */ +extern bool XT; /* Tabs are destructive */ +bool XV; /* VT100 - run AL and DL through tgoto */ +extern bool XX; /* Tektronix 4025 insert line */ /* X? is reserved for severely nauseous glitches */ /* If there are enough of these we may need bit masks! */ /* * From the tty modes... */ -bool NONL; /* Terminal can't hack linefeeds doing a CR */ -bool UPPERCASE; /* Ick! */ -short LINES; /* Number of lines on screen */ -short COLUMNS; -short OCOLUMNS; /* Save COLUMNS for a hack in open mode */ +extern bool NONL; /* Terminal can't hack linefeeds doing a CR */ +extern bool UPPERCASE; /* Ick! */ +extern short LINES; /* Number of lines on screen */ +extern short COLUMNS; +extern short OCOLUMNS; /* Save COLUMNS for a hack in open mode */ -short outcol; /* Where the cursor is */ -short outline; +extern short outcol; /* Where the cursor is */ +extern short outline; -short destcol; /* Where the cursor should be */ -short destline; +extern short destcol; /* Where the cursor should be */ +extern short destline; /* * There are several kinds of tty drivers to contend with. These include: @@ -125,32 +126,32 @@ short destline; * to stty. In USG V3 it's the whole tty structure. */ #ifdef USG3TTY /* USG V3 */ - struct termio tty; /* Use this one structure to change modes */ + extern struct termio tty; /* Use this one structure to change modes */ typedef struct termio ttymode; /* Mode to contain tty flags */ #else /* All others */ - struct sgttyb tty; /* Always stty/gtty using this one structure */ + extern struct sgttyb tty; /* Always stty/gtty using this one structure */ typedef int ttymode; /* Mode to contain tty flags */ # ifdef TIOCSETC /* V7 */ - struct tchars ottyc, nttyc; /* For V7 character masking */ + extern struct tchars ottyc, nttyc; /* For V7 character masking */ # endif # ifdef TIOCLGET /* Berkeley */ - struct ltchars olttyc, nlttyc; /* More of tchars style stuff */ + extern struct ltchars olttyc, nlttyc; /* More of tchars style stuff */ # endif #endif -ttymode normf; /* Restore tty flags to this (someday) */ -bool normtty; /* Have to restore normal mode from normf */ +extern ttymode normf; /* Restore tty flags to this (someday) */ +extern bool normtty; /* Have to restore normal mode from normf */ ttymode ostart(), setty(), unixex(); -short WBOT; -short WECHO; +extern short WBOT; +extern short WECHO; -short costCM; /* # chars to output a typical CM, with padding etc. */ -short costSR; /* likewise */ -short costAL; +extern short costCM; /* # chars to output a typical CM, with padding etc. */ +extern short costSR; /* likewise */ +extern short costAL; #ifdef VMUNIX # define MAXNOMACS 128 /* max number of macros of each kind */ @@ -164,13 +165,13 @@ struct maps { char *mapto; /* .. maps to this string */ char *descr; /* legible description of key */ }; -struct maps arrows[MAXNOMACS]; /* macro defs - 1st 5 built in */ -struct maps immacs[MAXNOMACS]; /* for while in insert mode */ -struct maps abbrevs[MAXNOMACS]; /* for word abbreviations */ -int ldisc; /* line discipline for ucb tty driver */ -char mapspace[MAXCHARMACS]; -char *msnext; /* next free location in mapspace */ -int maphopcnt; /* check for infinite mapping loops */ -bool anyabbrs; /* true if abbr or unabbr has been done */ -char ttynbuf[20]; /* result of ttyname() */ -int ttymesg; /* original mode of users tty */ +extern struct maps arrows[MAXNOMACS]; /* macro defs - 1st 5 built in */ +extern struct maps immacs[MAXNOMACS]; /* for while in insert mode */ +extern struct maps abbrevs[MAXNOMACS]; /* for word abbreviations */ +extern int ldisc; /* line discipline for ucb tty driver */ +extern char mapspace[MAXCHARMACS]; +extern char *msnext; /* next free location in mapspace */ +extern int maphopcnt; /* check for infinite mapping loops */ +extern bool anyabbrs; /* true if abbr or unabbr has been done */ +extern char ttynbuf[20]; /* result of ttyname() */ +extern int ttymesg; /* original mode of users tty */ diff --git a/usr/src/usr.bin/ex/ex_tune.h b/usr/src/usr.bin/ex/ex_tune.h index 7263f227fa..38e0226bab 100644 --- a/usr/src/usr.bin/ex/ex_tune.h +++ b/usr/src/usr.bin/ex/ex_tune.h @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -/* sccs id: @(#)ex_tune.h 6.2 %G% */ +/* Copyright (c) 1981 Regents of the University of California */ +/* sccs id: @(#)ex_tune.h 7.1 %G% */ /* * Definitions of editor parameters and limits */ @@ -11,10 +11,10 @@ * "/usr/lib/..." here, "/lib" will be tried only for strings. */ #include "local/uparm.h" -#define EXRECOVER libpath(ex3.6recover) -#define EXPRESERVE libpath(ex3.6preserve) +#define EXRECOVER libpath(ex3.7recover) +#define EXPRESERVE libpath(ex3.7preserve) #ifndef VMUNIX -#define EXSTRINGS libpath(ex3.6strings) +#define EXSTRINGS libpath(ex3.7strings) #endif /* @@ -109,5 +109,5 @@ * Attention is the interrupt character (normally 0177 -- delete). * Quit is the quit signal (normally FS -- control-\) and quits open/visual. */ -#define ATTN (-2) +#define ATTN (-2) /* mjm: (char) ?? */ #define QUIT ('\\' & 037) diff --git a/usr/src/usr.bin/ex/ex_unix.c b/usr/src/usr.bin/ex/ex_unix.c index 416ff26608..af103667e0 100644 --- a/usr/src/usr.bin/ex/ex_unix.c +++ b/usr/src/usr.bin/ex/ex_unix.c @@ -1,5 +1,5 @@ /* Copyright (c) 1979 Regents of the University of California */ -static char *sccsid = "@(#)ex_unix.c 6.1 %G%"; +static char *sccsid = "@(#)ex_unix.c 6.1 10/18/80"; #include "ex.h" #include "ex_temp.h" #include "ex_tty.h" @@ -232,7 +232,7 @@ filter(mode) register int mode; { static int pvec[2]; - register ttymode f; + ttymode f; /* mjm: was register */ register int lines = lineDOL(); mode++; @@ -251,7 +251,7 @@ filter(mode) setrupt(); io = pvec[1]; close(pvec[0]); - putfile(); + putfile(1); exit(0); } close(pvec[1]); diff --git a/usr/src/usr.bin/ex/ex_v.c b/usr/src/usr.bin/ex/ex_v.c index 8f4b1a40cb..721519281c 100644 --- a/usr/src/usr.bin/ex/ex_v.c +++ b/usr/src/usr.bin/ex/ex_v.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_v.c 6.1 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_v.c 7.1 %G%"; #include "ex.h" #include "ex_re.h" #include "ex_tty.h" @@ -54,7 +54,7 @@ oop() { register char *ic; char atube[TUBESIZE + LBSIZE]; - register ttymode f; + ttymode f; /* mjm: was register */ ovbeg(); if (peekchar() == '/') { @@ -154,7 +154,7 @@ vop() { register int c; char atube[TUBESIZE + LBSIZE]; - register ttymode f; + ttymode f; /* mjm: was register */ if (!CA && UP == NOSTR) { if (initev) { diff --git a/usr/src/usr.bin/ex/ex_vadj.c b/usr/src/usr.bin/ex/ex_vadj.c index 6e95554fb4..2f1c174fba 100644 --- a/usr/src/usr.bin/ex/ex_vadj.c +++ b/usr/src/usr.bin/ex/ex_vadj.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_vadj.c 6.2 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_vadj.c 7.1 %G%"; #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -255,9 +255,17 @@ vinslin(p, cnt, l) /* * Use insert line. */ - vgoto(p, 0), vputp(AL, WECHO + 1 - p); + vgoto(p, 0); + if (XV) + vputp(tgoto(AL, 0, p), WECHO + 1 - p); + else + vputp(AL, WECHO + 1 - p); for (i = cnt - 1; i > 0; i--) { - vgoto(outline+1, 0), vputp(AL, WECHO + 1 - outline); + vgoto(outline+1, 0); + if (XV) + vputp(tgoto(AL, 0, outline+1), WECHO + 1 - outline); + else + vputp(AL, WECHO + 1 - outline); if ((hold & HOLDAT) == 0) putchar('@'); } @@ -719,7 +727,10 @@ vdellin(p, cnt, l) */ vgoto(p, 0); for (i = 0; i < cnt; i++) - vputp(DL, WECHO - p); + if (XV) + vputp(tgoto(DL, 0, p), WECHO - p); + else + vputp(DL, WECHO - p); vadjDL(p, cnt); vcloseup(l, cnt); } diff --git a/usr/src/usr.bin/ex/ex_vars.h b/usr/src/usr.bin/ex/ex_vars.h index 239e403c4a..52220373c5 100644 --- a/usr/src/usr.bin/ex/ex_vars.h +++ b/usr/src/usr.bin/ex/ex_vars.h @@ -1,4 +1,4 @@ -/* sccs id @(#)ex_vars.h 6.1 %G% */ +/* sccs id @(#)ex_vars.h 7.1 %G% */ #define AUTOINDENT 0 #define AUTOPRINT 1 #define AUTOWRITE 2 diff --git a/usr/src/usr.bin/ex/ex_vget.c b/usr/src/usr.bin/ex/ex_vget.c index 12a3e9794b..5640277373 100644 --- a/usr/src/usr.bin/ex/ex_vget.c +++ b/usr/src/usr.bin/ex/ex_vget.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_vget.c 6.2 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_vget.c 6.3 %G%"; #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -15,7 +15,7 @@ static char *sccsid = "@(#)ex_vget.c 6.2 %G%"; * Return the key. */ ungetkey(c) - char c; + int c; /* mjm: char --> int */ { if (Peekkey != ATTN) @@ -27,7 +27,7 @@ ungetkey(c) */ getkey() { - register char c; + register int c; /* mjm: char --> int */ do { c = getbr(); @@ -64,6 +64,7 @@ getbr() char ch; register int c, d; register char *colp; + int cnt; #define BEEHIVE #ifdef BEEHIVE static char Peek2key; @@ -101,7 +102,7 @@ getATTN: } flusho(); again: - if (read(slevel == 0 ? 0 : ttyindes, &ch, 1) != 1) { + if ((c=read(slevel == 0 ? 0 : ttyindes, &ch, 1)) != 1) { if (errno == EINTR) goto getATTN; error("Input read error"); @@ -455,7 +456,7 @@ map(c,maps) if ((c=='#' ? peekkey() : fastpeekkey()) == 0) { #ifdef MDEBUG if (trace) - fprintf(trace,"fpk=0: return '%c'",c); + fprintf(trace,"fpk=0: will return '%c'",c); #endif /* * Nothing waiting. Push back @@ -467,7 +468,15 @@ map(c,maps) * to undo part of an insertion * so if in input mode don't. */ +#ifdef MDEBUG + if (trace) + fprintf(trace, "Call macpush, b %d %d %d\n", b[0], b[1], b[2]); +#endif macpush(&b[1],maps == arrows); +#ifdef MDEBUG + if (trace) + fprintf(trace, "return %d\n", c); +#endif return(c); } *q = getkey(); @@ -511,11 +520,7 @@ int canundo; if (st==0 || *st==0) return; -#ifdef notdef - if (!value(UNDOMACRO)) - canundo = 0; -#endif -#ifdef TRACE +#ifdef MDEBUG if (trace) fprintf(trace, "macpush(%s), canundo=%d\n",st,canundo); #endif @@ -629,9 +634,19 @@ fastpeekkey() * as separate. notimeout is provided for people who dislike such * nondeterminism. */ +#ifdef MDEBUG + if (trace) + fprintf(trace,"\nfastpeekkey: ",c); +#endif if (value(TIMEOUT) && inopen >= 0) { signal(SIGALRM, trapalarm); +#ifdef MDEBUG + alarm(10); + if (trace) + fprintf(trace, "set alarm "); +#else alarm(1); +#endif } CATCH c = peekkey(); @@ -644,7 +659,7 @@ fastpeekkey() c = 0; #ifdef MDEBUG if (trace) - fprintf(trace,"[TOUT]",c); + fprintf(trace,"[TIMEOUT]",c); #endif ENDCATCH #ifdef MDEBUG diff --git a/usr/src/usr.bin/ex/ex_vis.h b/usr/src/usr.bin/ex/ex_vis.h index 959037c6e1..d6b87a943c 100644 --- a/usr/src/usr.bin/ex/ex_vis.h +++ b/usr/src/usr.bin/ex/ex_vis.h @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -/* sccs id: @(#)ex_vis.h 6.1 %G% */ +/* Copyright (c) 1981 Regents of the University of California */ +/* sccs id: @(#)ex_vis.h 7.1 %G% */ /* * Ex version 3 * Mark Horton, UCB @@ -17,8 +17,8 @@ * line is longer than 80. */ -short bastate; -short state; +extern short bastate; +extern short state; #define VISUAL 0 #define CRTOPEN 1 @@ -38,20 +38,20 @@ short state; * If WBOT!=WECHO then WECHO will be the last line on the screen * and WBOT is the line before it. */ -short basWTOP; -short basWLINES; -short WTOP; -short WBOT; -short WLINES; -short WCOLS; -short WECHO; +extern short basWTOP; +extern short basWLINES; +extern short WTOP; +extern short WBOT; +extern short WLINES; +extern short WCOLS; +extern short WECHO; /* * When we are dealing with the echo area we consider the window * to be "split" and set the variable splitw. Otherwise, moving * off the bottom of the screen into WECHO causes a screen rollup. */ -bool splitw; +extern bool splitw; /* * Information about each line currently on the screen includes @@ -62,10 +62,11 @@ bool splitw; * appropriate juncture. */ struct vlinfo { - char vliny; /* Y coordinate */ - char vdepth; /* Depth of displayed line */ + short vliny; /* Y coordinate */ /* mjm: was char */ + short vdepth; /* Depth of displayed line */ /*mjm: was char */ short vflags; /* Is line potentially dirty ? */ -} vlinfo[TUBELINES + 2]; +}; +extern struct vlinfo vlinfo[TUBELINES + 2]; #define DEPTH(c) (vlinfo[c].vdepth) #define LINE(c) (vlinfo[c].vliny) @@ -92,8 +93,8 @@ struct vlinfo { * Vcline is intimately tied to the current value of dot, * and when command mode is used as a subroutine fancy footwork occurs. */ -short vcline; -short vcnt; +extern short vcline; +extern short vcnt; /* * To allow many optimizations on output, an exact image of the terminal @@ -103,8 +104,8 @@ short vcnt; * data itself. It is also rearranged during insert mode across line * boundaries to make incore work easier. */ -char *vtube[TUBELINES]; -char *vtube0; +extern char *vtube[TUBELINES]; +extern char *vtube0; /* * The current cursor position within the current line is kept in @@ -114,9 +115,9 @@ char *vtube0; * lines to mark the other end of the affected area, or the target * for a motion. */ -char *cursor; -char *wcursor; -line *wdot; +extern char *cursor; +extern char *wcursor; +extern line *wdot; /* * Undo information is saved in a LBSIZE buffer at "vutmp" for changes @@ -132,8 +133,8 @@ line *wdot; #define VMCHNG 4 #define VMANYINS 5 -short vundkind; /* Which kind of undo - from above */ -char *vutmp; /* Prev line image when "VCHNG" */ +extern short vundkind; /* Which kind of undo - from above */ +extern char *vutmp; /* Prev line image when "VCHNG" */ /* * State information for undoing of macros. The basic idea is that @@ -147,7 +148,7 @@ char *vutmp; /* Prev line image when "VCHNG" */ #define VC_ONECHANGE 2 /* In a macro, one change so far */ #define VC_MANYCHANGE 3 /* In a macro, at least 2 changes so far */ -short vch_mac; /* Change state - one of the above */ +extern short vch_mac; /* Change state - one of the above */ /* * For U undo's the line is grabbed by "vmove" after it first appears @@ -156,9 +157,9 @@ short vch_mac; /* Change state - one of the above */ * are made, i.e. after a 'J' join. This is because a 'JU' would * lose completely the text of the line just joined on. */ -char *vUNDcurs; /* Cursor just before 'U' */ -line *vUNDdot; /* The line address of line saved in vUNDsav */ -line vUNDsav; /* Grabbed initial "*dot" */ +extern char *vUNDcurs; /* Cursor just before 'U' */ +extern line *vUNDdot; /* The line address of line saved in vUNDsav */ +extern line vUNDsav; /* Grabbed initial "*dot" */ #define killU() vUNDdot = NOLINE @@ -188,8 +189,8 @@ line vUNDsav; /* Grabbed initial "*dot" */ * is actually needed is recorded in heldech, which says that a clear * of the echo area was actually held off. */ -short hold; -short holdupd; /* Hold off update when echo line is too long */ +extern short hold; +extern short holdupd; /* Hold off update when echo line is too long */ #define HOLDAT 1 #define HOLDDOL 2 @@ -202,43 +203,43 @@ short holdupd; /* Hold off update when echo line is too long */ /* * Miscellaneous variables */ -short CDCNT; /* Count of ^D's in insert on this line */ -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 */ -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) */ -short doomed; /* Disply chars right of cursor to be killed */ -bool gobblebl; /* Wrapmargin space generated nl, eat a space */ -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 */ -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 */ -short lastreg; /* Register with last command */ -char *ncols['z'-'a'+2]; /* Cursor positions of marks */ -char *notenam; /* Name to be noted with change count */ -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! */ -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 */ -char *vmcurs; /* Cursor for restore after undo d), e.g. */ -short vmovcol; /* Column to try to keep on arrow keys */ -bool vmoving; /* Are trying to keep vmovcol */ -char vreg; /* Register for this command */ -short wdkind; /* Liberal/conservative words? */ -char workcmd[5]; /* Temporary for lastcmd */ +extern short CDCNT; /* Count of ^D's in insert on this line */ +extern char DEL[VBSIZE]; /* Last deleted text */ +extern bool HADUP; /* This insert line started with ^ then ^D */ +extern bool HADZERO; /* This insert line started with 0 then ^D */ +extern char INS[VBSIZE]; /* Last inserted text */ +extern int Vlines; /* Number of file lines "before" vi command */ +extern int Xcnt; /* External variable holding last cmd's count */ +extern bool Xhadcnt; /* Last command had explicit count? */ +extern short ZERO; +extern short dir; /* Direction for search (+1 or -1) */ +extern short doomed; /* Disply chars right of cursor to be killed */ +extern bool gobblebl; /* Wrapmargin space generated nl, eat a space */ +extern bool hadcnt; /* (Almost) internal to vmain() */ +extern bool heldech; /* We owe a clear of echo area */ +extern bool insmode; /* Are in character insert mode */ +extern char lastcmd[5]; /* Chars in last command */ +extern int lastcnt; /* Count for last command */ +extern char *lastcp; /* Save current command here to repeat */ +extern bool lasthad; /* Last command had a count? */ +extern short lastvgk; /* Previous input key, if not from keyboard */ +extern short lastreg; /* Register with last command */ +extern char *ncols['z'-'a'+2]; /* Cursor positions of marks */ +extern char *notenam; /* Name to be noted with change count */ +extern char *notesgn; /* Change count from last command */ +extern char op; /* Operation of current command */ +extern short Peekkey; /* Peek ahead key */ +extern bool rubble; /* Line is filthy (in hardcopy open), redraw! */ +extern int vSCROLL; /* Number lines to scroll on ^D/^U */ +extern char *vglobp; /* Untyped input (e.g. repeat insert text) */ +extern char vmacbuf[VBSIZE]; /* Text of visual macro, hence nonnestable */ +extern char *vmacp; /* Like vglobp but for visual macros */ +extern char *vmcurs; /* Cursor for restore after undo d), e.g. */ +extern short vmovcol; /* Column to try to keep on arrow keys */ +extern bool vmoving; /* Are trying to keep vmovcol */ +extern short vreg; /* Reg for this command */ /* mjm: was char */ +extern short wdkind; /* Liberal/conservative words? */ +extern char workcmd[5]; /* Temporary for lastcmd */ /* diff --git a/usr/src/usr.bin/ex/ex_vmain.c b/usr/src/usr.bin/ex/ex_vmain.c index 2791881c1c..b26df64304 100644 --- a/usr/src/usr.bin/ex/ex_vmain.c +++ b/usr/src/usr.bin/ex/ex_vmain.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_vmain.c 6.2 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_vmain.c 7.1 %G%"; #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" diff --git a/usr/src/usr.bin/ex/ex_voper.c b/usr/src/usr.bin/ex/ex_voper.c index fb8df380c0..5f21d57eac 100644 --- a/usr/src/usr.bin/ex/ex_voper.c +++ b/usr/src/usr.bin/ex/ex_voper.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_voper.c 6.2 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_voper.c 7.1 %G%"; #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" diff --git a/usr/src/usr.bin/ex/ex_vops.c b/usr/src/usr.bin/ex/ex_vops.c index fc03b25192..9321100d60 100644 --- a/usr/src/usr.bin/ex/ex_vops.c +++ b/usr/src/usr.bin/ex/ex_vops.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_vops.c 6.3 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_vops.c 7.1 %G%"; #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -621,7 +621,7 @@ smallchange: * you are better off with slowopen. */ voOpen(c, cnt) - char c; + int c; /* mjm: char --> int */ register int cnt; { register int ind = 0, i; diff --git a/usr/src/usr.bin/ex/ex_vops2.c b/usr/src/usr.bin/ex/ex_vops2.c index a03cdbb10d..67f24b00c6 100644 --- a/usr/src/usr.bin/ex/ex_vops2.c +++ b/usr/src/usr.bin/ex/ex_vops2.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_vops2.c 6.2 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_vops2.c 6.3 %G%"; #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -9,8 +9,8 @@ static char *sccsid = "@(#)ex_vops2.c 6.2 %G%"; * and mostly, insert mode (and a subroutine * to read an input line, including in the echo area.) */ -char *vUA1, *vUA2; -char *vUD1, *vUD2; +extern char *vUA1, *vUA2; /* mjm: extern; also in ex_vops.c */ +extern char *vUD1, *vUD2; /* mjm: extern; also in ex_vops.c */ /* * Obleeperate characters in hardcopy @@ -104,7 +104,7 @@ bool gobbled; char *ogcursor; vappend(ch, cnt, indent) - char ch; + int ch; /* mjm: char --> int */ int cnt, indent; { register int i; @@ -807,8 +807,10 @@ vbackup: } def: if (!backsl) { + int cnt; putchar(c); - flush(); + if (ioctl(0, FIONREAD, &cnt) != 0 || cnt==0) + flush(); } if (gcursor > &genbuf[LBSIZE - 2]) error("Line too long"); diff --git a/usr/src/usr.bin/ex/ex_vops3.c b/usr/src/usr.bin/ex/ex_vops3.c index cd89a6eb8a..844f24ce0b 100644 --- a/usr/src/usr.bin/ex/ex_vops3.c +++ b/usr/src/usr.bin/ex/ex_vops3.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_vops3.c 6.2 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_vops3.c 7.1 %G%"; #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" diff --git a/usr/src/usr.bin/ex/ex_vput.c b/usr/src/usr.bin/ex/ex_vput.c index 3ee19dd494..dfb9d85e2b 100644 --- a/usr/src/usr.bin/ex/ex_vput.c +++ b/usr/src/usr.bin/ex/ex_vput.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_vput.c 6.1 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_vput.c 7.1 %G%"; #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" @@ -484,7 +484,7 @@ vmaktop(p, cp) * to make life simpler. */ vinschar(c) - char c; + int c; /* mjm: char --> int */ { register int i; register char *tp; @@ -829,7 +829,7 @@ vishft() * Now do the insert of the characters (finally). */ viin(c) - char c; + int c; /* mjm: char --> int */ { register char *tp, *up; register int i, j; @@ -1197,9 +1197,13 @@ def: * CONCEPT braindamage in early models: after a wraparound * the next newline is eaten. It's hungry so we just * feed it now rather than worrying about it. + * Fixed to use return linefeed to work right + * on vt100/tab132 as well as concept. */ - if (XN && outcol % WCOLS == 0) - vputc('\n'); + if (XN && outcol % WCOLS == 0) { + vputc('\r', 0); + vputc('\n', 0); + } } } @@ -1325,13 +1329,15 @@ tvliny() } tracec(c) - char c; + int c; /* mjm: char --> int */ { if (!techoin) trubble = 1; if (c == ESCAPE) fprintf(trace, "$"); + else if (c & QUOTE) /* mjm: for 3B (no sign extension) */ + fprintf(trace, "~%c", ctlof(c&TRIM)); else if (c < ' ' || c == DELETE) fprintf(trace, "^%c", ctlof(c)); else diff --git a/usr/src/usr.bin/ex/ex_vwind.c b/usr/src/usr.bin/ex/ex_vwind.c index 914a467555..3a6ac0a846 100644 --- a/usr/src/usr.bin/ex/ex_vwind.c +++ b/usr/src/usr.bin/ex/ex_vwind.c @@ -1,5 +1,5 @@ -/* Copyright (c) 1980 Regents of the University of California */ -static char *sccsid = "@(#)ex_vwind.c 6.1 %G%"; +/* Copyright (c) 1981 Regents of the University of California */ +static char *sccsid = "@(#)ex_vwind.c 7.1 %G%"; #include "ex.h" #include "ex_tty.h" #include "ex_vis.h" diff --git a/usr/src/usr.bin/ex/printf.c b/usr/src/usr.bin/ex/printf.c index d14ad0d65a..78abc981b8 100644 --- a/usr/src/usr.bin/ex/printf.c +++ b/usr/src/usr.bin/ex/printf.c @@ -1,7 +1,7 @@ /* The pwb version this is based on */ static char *printf_id = "@(#) printf.c:2.2 6/5/79"; /* The local sccs version within ex */ -static char *sccsid = "@(#)printf.c 6.1 %G%"; +static char *sccsid = "@(#)printf.c 7.1 %G%"; #include "varargs.h" /* * This version of printf is compatible with the Version 7 C -- 2.20.1