make ex/vi work on vms
authorConrad Huang <conrad@ucbvax.Berkeley.EDU>
Tue, 10 Mar 1987 04:47:26 +0000 (20:47 -0800)
committerConrad Huang <conrad@ucbvax.Berkeley.EDU>
Tue, 10 Mar 1987 04:47:26 +0000 (20:47 -0800)
SCCS-vsn: usr.bin/ex/ex_cmds2.c 7.5
SCCS-vsn: usr.bin/ex/printf.c 7.4
SCCS-vsn: usr.bin/ex/bcopy.c 7.4
SCCS-vsn: usr.bin/ex/ex_vwind.c 7.4
SCCS-vsn: usr.bin/ex/ex_vops3.c 7.4
SCCS-vsn: usr.bin/ex/ex_vmain.c 7.8
SCCS-vsn: usr.bin/ex/ex_vops2.c 6.9
SCCS-vsn: usr.bin/ex/ex_vget.c 6.9
SCCS-vsn: usr.bin/ex/ex_unix.c 7.7
SCCS-vsn: usr.bin/ex/ex_vis.h 7.5
SCCS-vsn: usr.bin/ex/ex_vars.h 7.6
SCCS-vsn: usr.bin/ex/ex_v.c 7.9
SCCS-vsn: usr.bin/ex/ex_set.c 7.5
SCCS-vsn: usr.bin/ex/ex_subr.c 7.11
SCCS-vsn: usr.bin/ex/ex_vadj.c 7.10
SCCS-vsn: usr.bin/ex/ex_addr.c 7.4
SCCS-vsn: usr.bin/ex/ex_get.c 7.7
SCCS-vsn: usr.bin/ex/ex.c 7.6
SCCS-vsn: usr.bin/ex/ex_data.c 7.6
SCCS-vsn: usr.bin/ex/ex_vput.c 7.5
SCCS-vsn: usr.bin/ex/ex_put.c 7.10
SCCS-vsn: usr.bin/ex/ex.h 7.8
SCCS-vsn: usr.bin/ex/ex_tune.h 7.11
SCCS-vsn: usr.bin/ex/ex_temp.c 7.6
SCCS-vsn: usr.bin/ex/ex_tty.h 7.7
SCCS-vsn: usr.bin/ex/ex_cmdsub.c 7.8
SCCS-vsn: usr.bin/ex/ex_io.c 7.13
SCCS-vsn: usr.bin/ex/ex_voper.c 7.5
SCCS-vsn: usr.bin/ex/ex_vops.c 7.8
SCCS-vsn: usr.bin/ex/ex_cmds.c 7.11
SCCS-vsn: usr.bin/ex/ex_tty.c 7.11
SCCS-vsn: usr.bin/ex/ex_re.c 7.6
SCCS-vsn: usr.bin/ex/Makefile 7.14
SCCS-vsn: usr.bin/ex/ex_tagio.c 7.4

34 files changed:
usr/src/usr.bin/ex/Makefile
usr/src/usr.bin/ex/bcopy.c
usr/src/usr.bin/ex/ex.c
usr/src/usr.bin/ex/ex.h
usr/src/usr.bin/ex/ex_addr.c
usr/src/usr.bin/ex/ex_cmds.c
usr/src/usr.bin/ex/ex_cmds2.c
usr/src/usr.bin/ex/ex_cmdsub.c
usr/src/usr.bin/ex/ex_data.c
usr/src/usr.bin/ex/ex_get.c
usr/src/usr.bin/ex/ex_io.c
usr/src/usr.bin/ex/ex_put.c
usr/src/usr.bin/ex/ex_re.c
usr/src/usr.bin/ex/ex_set.c
usr/src/usr.bin/ex/ex_subr.c
usr/src/usr.bin/ex/ex_tagio.c
usr/src/usr.bin/ex/ex_temp.c
usr/src/usr.bin/ex/ex_tty.c
usr/src/usr.bin/ex/ex_tty.h
usr/src/usr.bin/ex/ex_tune.h
usr/src/usr.bin/ex/ex_unix.c
usr/src/usr.bin/ex/ex_v.c
usr/src/usr.bin/ex/ex_vadj.c
usr/src/usr.bin/ex/ex_vars.h
usr/src/usr.bin/ex/ex_vget.c
usr/src/usr.bin/ex/ex_vis.h
usr/src/usr.bin/ex/ex_vmain.c
usr/src/usr.bin/ex/ex_voper.c
usr/src/usr.bin/ex/ex_vops.c
usr/src/usr.bin/ex/ex_vops2.c
usr/src/usr.bin/ex/ex_vops3.c
usr/src/usr.bin/ex/ex_vput.c
usr/src/usr.bin/ex/ex_vwind.c
usr/src/usr.bin/ex/printf.c

index 0b0a9d4..d0ffc10 100644 (file)
@@ -3,21 +3,21 @@
 # All rights reserved.  The Berkeley software License Agreement
 # specifies the terms and conditions for redistribution.
 #
 # All rights reserved.  The Berkeley software License Agreement
 # specifies the terms and conditions for redistribution.
 #
-#      @(#)Makefile    7.13.1.1 (Berkeley) %G%
+#      @(#)Makefile    7.14 (Berkeley) %G%
 #
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
 # specifies the terms and conditions for redistribution.
 #
 #
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
 # specifies the terms and conditions for redistribution.
 #
-#      @(#)Makefile    7.13.1.1 (Berkeley) %G%
+#      @(#)Makefile    7.14 (Berkeley) %G%
 #
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
 # specifies the terms and conditions for redistribution.
 #
 #
 #
 # Copyright (c) 1980 Regents of the University of California.
 # All rights reserved.  The Berkeley software License Agreement
 # specifies the terms and conditions for redistribution.
 #
-#      @(#)Makefile    7.13.1.1 (Berkeley) %G%
+#      @(#)Makefile    7.14 (Berkeley) %G%
 #
 VERSION=3.7
 #
 #
 VERSION=3.7
 #
@@ -95,7 +95,7 @@ tags: /tmp
 
 ${OBJS}: ${HDRS}
 
 
 ${OBJS}: ${HDRS}
 
-ex_vars.h:
+ex_vars.h:     ex_data.c
        csh makeoptions ${CFLAGS}
 
 bcopy.o:       bcopy.c
        csh makeoptions ${CFLAGS}
 
 bcopy.o:       bcopy.c
index 1f344d7..8720cfd 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)bcopy.c     7.3 (Berkeley) %G%";
+static char *sccsid = "@(#)bcopy.c     7.4 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -15,7 +15,7 @@ static char *sccsid = "@(#)bcopy.c    7.3 (Berkeley) %G%";
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)bcopy.c    7.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)bcopy.c    7.4 (Berkeley) %G%";
 #endif not lint
 
 /* block copy from from to to, count bytes */
 #endif not lint
 
 /* block copy from from to to, count bytes */
@@ -24,8 +24,12 @@ bcopy(from, to, count)
        char *from, *to;
        int count;
 {
        char *from, *to;
        int count;
 {
-
+#ifndef vms
        asm("   movc3   12(ap),*4(ap),*8(ap)");
        asm("   movc3   12(ap),*4(ap),*8(ap)");
+       /* ARGSUSED */
+#else
+       lib$movc3(&count, from, to);
+#endif
 }
 #else
        register char *from, *to;
 }
 #else
        register char *from, *to;
index 5f71fa7..114bf17 100644 (file)
@@ -11,7 +11,7 @@ char *copyright =
 #endif not lint
 
 #ifndef lint
 #endif not lint
 
 #ifndef lint
-static char *sccsid = "@(#)ex.c        7.5.1.1 (Berkeley) %G%";
+static char *sccsid = "@(#)ex.c        7.6 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -20,8 +20,12 @@ static char *sccsid = "@(#)ex.c      7.5.1.1 (Berkeley) %G%";
 #include "ex_tty.h"
 
 #ifdef TRACE
 #include "ex_tty.h"
 
 #ifdef TRACE
+#ifdef vms
+char   tttrace[]       = { 't','r','a','c','e','.','l','i','s' };
+#else
 char   tttrace[]       = { '/','d','e','v','/','t','t','y','x','x',0 };
 #endif
 char   tttrace[]       = { '/','d','e','v','/','t','t','y','x','x',0 };
 #endif
+#endif
 
 /*
  * The code for ex is divided as follows:
 
 /*
  * The code for ex is divided as follows:
@@ -86,7 +90,7 @@ main(ac, av)
        register int ac;
        register char *av[];
 {
        register int ac;
        register char *av[];
 {
-#ifndef VMUNIX
+#ifdef EXSTRINGS
        char *erpath = EXSTRINGS;
 #endif
        register char *cp;
        char *erpath = EXSTRINGS;
 #endif
        register char *cp;
@@ -96,15 +100,23 @@ main(ac, av)
        bool itag = 0;
        bool fast = 0;
        extern int onemt();
        bool itag = 0;
        bool fast = 0;
        extern int onemt();
+#ifdef UNIX_SBRK
+       extern char *sbrk();
+#else
+       extern char *malloc();
+#endif
 #ifdef TRACE
        register char *tracef;
 #endif
 #ifdef TRACE
        register char *tracef;
 #endif
+#ifdef vms
+       char termtype[20];
+#endif
 
        /*
         * Immediately grab the tty modes so that we wont
         * get messed up if an interrupt comes in quickly.
         */
 
        /*
         * Immediately grab the tty modes so that we wont
         * get messed up if an interrupt comes in quickly.
         */
-       gTTY(1);
+       ex_gTTY(1);
 #ifndef USG3TTY
        normf = tty.sg_flags;
 #else
 #ifndef USG3TTY
        normf = tty.sg_flags;
 #else
@@ -115,7 +127,21 @@ main(ac, av)
         * Defend against d's, v's, w's, and a's in directories of
         * path leading to our true name.
         */
         * Defend against d's, v's, w's, and a's in directories of
         * path leading to our true name.
         */
+#ifndef        vms
        av[0] = tailpath(av[0]);
        av[0] = tailpath(av[0]);
+#else
+       /*
+        * This program has to be invoked by using the following
+        * string definitions:
+        *
+        * vi == "$dir:ex.exe vi"
+        * view == "$dir:ex.exe view"
+        * ex == "$dir:ex.exe ex"
+        * edit == "$dir:ex.exe edit"
+        */
+       ac--;
+       av++;
+#endif
 
        /*
         * Figure out how we were invoked: ex, edit, vi, view.
 
        /*
         * Figure out how we were invoked: ex, edit, vi, view.
@@ -129,7 +155,7 @@ main(ac, av)
                value(MAGIC) = 0;
        }
 
                value(MAGIC) = 0;
        }
 
-#ifndef VMUNIX
+#ifdef EXSTRINGS
        /*
         * For debugging take files out of . if name is a.out.
         */
        /*
         * For debugging take files out of . if name is a.out.
         */
@@ -140,7 +166,7 @@ main(ac, av)
         * Open the error message file.
         */
        draino();
         * Open the error message file.
         */
        draino();
-#ifndef VMUNIX
+#ifdef EXSTRINGS
        erfile = open(erpath+4, 0);
        if (erfile < 0) {
                erfile = open(erpath, 0);
        erfile = open(erpath+4, 0);
        if (erfile < 0) {
                erfile = open(erpath, 0);
@@ -192,7 +218,7 @@ main(ac, av)
                        trace = fopen(tracef, "w");
 #define tracbuf NULL
                        if (trace == NULL)
                        trace = fopen(tracef, "w");
 #define tracbuf NULL
                        if (trace == NULL)
-                               printf("Trace create error\n");
+                               ex_printf("Trace create error\n");
                        else
                                setbuf(trace, tracbuf);
                        break;
                        else
                                setbuf(trace, tracbuf);
                        break;
@@ -238,17 +264,6 @@ main(ac, av)
                ac--, av++;
        }
 
                ac--, av++;
        }
 
-       /*
-        * Initialize end of core pointers.
-        * Normally we avoid breaking back to fendcore after each
-        * file since this can be expensive (much core-core copying).
-        * If your system can scatter load processes you could do
-        * this as ed does, saving a little core, but it will probably
-        * not often make much difference.
-        */
-       fendcore = (line *) sbrk(0);
-       endcore = fendcore - 2;
-
 #ifdef SIGTSTP
        if (!hush && signal(SIGTSTP, SIG_IGN) == SIG_DFL)
                signal(SIGTSTP, onsusp), dosusp++;
 #ifdef SIGTSTP
        if (!hush && signal(SIGTSTP, SIG_IGN) == SIG_DFL)
                signal(SIGTSTP, onsusp), dosusp++;
@@ -273,7 +288,7 @@ main(ac, av)
                        setrupt();
                        execl(EXRECOVER, "exrecover", "-r", 0);
                        filioerr(EXRECOVER);
                        setrupt();
                        execl(EXRECOVER, "exrecover", "-r", 0);
                        filioerr(EXRECOVER);
-                       exit(1);
+                       ex_exit(1);
                }
                CP(savedfile, *av++), ac--;
        }
                }
                CP(savedfile, *av++), ac--;
        }
@@ -294,18 +309,38 @@ main(ac, av)
                setrupt();
                intty = isatty(0);
                value(PROMPT) = intty;
                setrupt();
                intty = isatty(0);
                value(PROMPT) = intty;
+#ifndef        vms
                if (cp = getenv("SHELL"))
                if (cp = getenv("SHELL"))
+#else
+               if (cp = getlog("SHELL"))
+#endif
                        CP(shell, cp);
                if (fast || !intty)
                        setterm("dumb");
                else {
                        gettmode();
                        CP(shell, cp);
                if (fast || !intty)
                        setterm("dumb");
                else {
                        gettmode();
+#ifndef        vms
                        if ((cp = getenv("TERM")) != 0 && *cp)
                                setterm(cp);
                        if ((cp = getenv("TERM")) != 0 && *cp)
                                setterm(cp);
+#else
+                       if ((cp = getlog("TERM")) != 0 && *cp) {
+                               /*
+                                * Can't just use it directly since getlog
+                                * returns a pointer to a static buffer that
+                                * tgetent() will eventually use
+                                */
+                               CP(termtype, cp);
+                               setterm(termtype);
+                       }
+#endif
                }
        }
        if (setexit() == 0 && !fast && intty) {
                }
        }
        if (setexit() == 0 && !fast && intty) {
+#ifndef        vms
                if ((globp = getenv("EXINIT")) && *globp)
                if ((globp = getenv("EXINIT")) && *globp)
+#else
+               if ((globp = getlog("EXINIT")) && *globp)
+#endif
                        commands(1,1);
                else {
                        globp = 0;
                        commands(1,1);
                else {
                        globp = 0;
@@ -324,6 +359,37 @@ main(ac, av)
                 if (iownit(".exrc"))
                        source(".exrc", 1);
        }
                 if (iownit(".exrc"))
                        source(".exrc", 1);
        }
+#ifdef UNIX_SBRK
+       /*
+        * Initialize end of core pointers.
+        * Normally we avoid breaking back to fendcore after each
+        * file since this can be expensive (much core-core copying).
+        * If your system can scatter load processes you could do
+        * this as ed does, saving a little core, but it will probably
+        * not often make much difference.
+        */
+       fendcore = (line *) sbrk(0);
+       endcore = fendcore - 2;
+#else
+       /*
+        * Allocate all the memory we will ever use in one chunk.
+        * This is for system such as VMS where sbrk() does not
+        * guarantee that the memory allocated beyond the end is
+        * consecutive.  VMS's RMS does all sorts of memory allocation
+        * and screwed up ex royally because ex assumes that all
+        * memory up to "endcore" belongs to it and RMS has different
+        * ideas.
+        */
+       fendcore = (line *) malloc((unsigned)
+               value(LINELIMIT) * sizeof (line *));
+       if (fendcore == NULL) {
+               lprintf("ex: cannot handle %d lines\n", value(LINELIMIT));
+               lprintf("ex: set \"linelimit\" lower\n");
+               flush();
+               ex_exit(1);
+       }
+       endcore = fendcore + (value(LINELIMIT) - 1);
+#endif
        init(); /* moved after prev 2 chunks to fix directory option */
 
        /*
        init(); /* moved after prev 2 chunks to fix directory option */
 
        /*
@@ -379,7 +445,7 @@ main(ac, av)
        setexit();
        commands(0, 0);
        cleanup(1);
        setexit();
        commands(0, 0);
        cleanup(1);
-       exit(0);
+       ex_exit(0);
 }
 
 /*
 }
 
 /*
index 63de93b..85c37be 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)ex.h        7.7.1.1 (Berkeley) %G%
+ *     @(#)ex.h        7.8 (Berkeley) %G%
  */
 
 #ifdef V6
  */
 
 #ifdef V6
  * of additional terminal descriptions you add to the termcap data base.
  */
 
  * of additional terminal descriptions you add to the termcap data base.
  */
 
+#ifndef        vms
 #include <sys/param.h>
 #include <sys/param.h>
+#else
+#define        MAXBSIZE        1024    /* Maximum block size */
+#include <types.h>
+#endif
 #include <ctype.h>
 #include <errno.h>
 #include <signal.h>
 #include <setjmp.h>
 #include <ctype.h>
 #include <errno.h>
 #include <signal.h>
 #include <setjmp.h>
+#ifndef        vms
 #include <sys/stat.h>
 #include <sys/stat.h>
+#else
+#include <stat.h>
+#endif
 
 #ifndef var
 #define var    extern
 
 #ifndef var
 #define var    extern
 #include <termio.h>
 #define CBREAK xxxxx
 #else
 #include <termio.h>
 #define CBREAK xxxxx
 #else
+#ifndef        vms
 #include <sgtty.h>
 #include <sgtty.h>
+#else
+#include "vmstty.h"
+#endif
 #endif
 
 extern int errno;
 #endif
 
 extern int errno;
@@ -111,6 +124,11 @@ struct     option {
 
 extern  struct option options[NOPTS + 1];
 
 
 extern  struct option options[NOPTS + 1];
 
+#ifdef vms
+#define        st_blksize      st_fab_mrs
+#define        _exit(n)        vms_exit(n)
+#define        fork()          vfork()
+#endif
 
 /*
  * The editor does not normally use the standard i/o library.  Because
 
 /*
  * The editor does not normally use the standard i/o library.  Because
@@ -125,13 +143,11 @@ extern     struct option options[NOPTS + 1];
  * are not debugging.  Such a modified printf exists in "printf.c" here.
  */
 #ifdef TRACE
  * are not debugging.  Such a modified printf exists in "printf.c" here.
  */
 #ifdef TRACE
-#      include <stdio.h>
+# include <stdio.h>
        var     FILE    *trace;
        var     bool    trubble;
        var     bool    techoin;
        var     char    tracbuf[BUFSIZ];
        var     FILE    *trace;
        var     bool    trubble;
        var     bool    techoin;
        var     char    tracbuf[BUFSIZ];
-#      undef   putchar
-#      undef   getchar
 #else
 # ifdef        VMUNIX
 #      define  BUFSIZ  1024
 #else
 # ifdef        VMUNIX
 #      define  BUFSIZ  1024
@@ -156,7 +172,9 @@ extern       struct option options[NOPTS + 1];
  */
 #define        QUOTE   0200
 #define        TRIM    0177
  */
 #define        QUOTE   0200
 #define        TRIM    0177
+#ifndef vms
 #undef CTRL
 #undef CTRL
+#endif
 #define        CTRL(c) ('c' & 037)
 #define        NL      CTRL(j)
 #define        CR      CTRL(m)
 #define        CTRL(c) ('c' & 037)
 #define        NL      CTRL(j)
 #define        CR      CTRL(m)
@@ -178,7 +196,7 @@ var bool    dosusp;         /* Do SIGTSTP in visual when ^Z typed */
 var    bool    edited;         /* Current file is [Edited] */
 var    line    *endcore;       /* Last available core location */
 extern  bool   endline;        /* Last cmd mode command ended with \n */
 var    bool    edited;         /* Current file is [Edited] */
 var    line    *endcore;       /* Last available core location */
 extern  bool   endline;        /* Last cmd mode command ended with \n */
-#ifndef VMUNIX
+#ifdef EXSTRINGS
 var    short   erfile;         /* Error message file unit */
 #endif
 var    line    *fendcore;      /* First address in line pointer space */
 var    short   erfile;         /* Error message file unit */
 #endif
 var    line    *fendcore;      /* First address in line pointer space */
@@ -323,7 +341,7 @@ var line    *undadot;       /* If we saved all lines, dot reverts here */
 
 extern int     (*Outchar)();
 extern int     (*Pline)();
 
 extern int     (*Outchar)();
 extern int     (*Pline)();
-extern int     (*Putchar)();
+extern int     (*Put_char)();
 var    int     (*oldhup)();
 int    (*setlist())();
 int    (*setnorm())();
 var    int     (*oldhup)();
 int    (*setlist())();
 int    (*setnorm())();
@@ -334,6 +352,9 @@ char        *cgoto();
 char   *genindent();
 char   *getblock();
 char   *getenv();
 char   *genindent();
 char   *getblock();
 char   *getenv();
+#ifdef vms
+char   *getlog();
+#endif
 line   *getmark();
 char   *longname();
 char   *mesg();
 line   *getmark();
 char   *longname();
 char   *mesg();
@@ -357,7 +378,7 @@ char        *vskipwh();
 int    put();
 int    putreg();
 int    YANKreg();
 int    put();
 int    putreg();
 int    YANKreg();
-int    delete();
+int    ex_delete();
 int    execl();
 int    filter();
 int    getfile();
 int    execl();
 int    filter();
 int    getfile();
index a01a8f2..4b8fef0 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_addr.c   7.3 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_addr.c   7.4 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -88,7 +88,7 @@ getnum()
        register int cnt;
 
        for (cnt = 0; isdigit(peekcd());)
        register int cnt;
 
        for (cnt = 0; isdigit(peekcd());)
-               cnt = cnt * 10 + getchar() - '0';
+               cnt = cnt * 10 + ex_getchar() - '0';
        return (cnt);
 }
 
        return (cnt);
 }
 
@@ -261,7 +261,7 @@ error("No match to TOP|Address search hit TOP without matching pattern");
                        continue;
 
                case '\'':
                        continue;
 
                case '\'':
-                       c = markreg(getchar());
+                       c = markreg(ex_getchar());
                        if (c == 0)
                                error("Marks are ' and a-z");
                        addr = getmark(c);
                        if (c == 0)
                                error("Marks are ' and a-z");
                        addr = getmark(c);
index ba0fd47..9fd1788 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_cmds.c   7.10 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_cmds.c   7.11 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -77,7 +77,7 @@ error("Offset out-of-bounds|Offset after command too large");
                if (inglobal == 0) {
                        flush();
                        if (!hush && value(PROMPT) && !globp && !noprompt && endline) {
                if (inglobal == 0) {
                        flush();
                        if (!hush && value(PROMPT) && !globp && !noprompt && endline) {
-                               putchar(':');
+                               ex_putchar(':');
                                hadpr = 1;
                        }
                        TSYNC();
                                hadpr = 1;
                        }
                        TSYNC();
@@ -91,7 +91,7 @@ error("Offset out-of-bounds|Offset after command too large");
                given = seensemi = 0;
                do {
                        addr1 = addr2;
                given = seensemi = 0;
                do {
                        addr1 = addr2;
-                       addr = address(0);
+                       addr = address((char *) 0);
                        c = getcd();
                        if (addr == 0)
                                if (c == ',')
                        c = getcd();
                        if (addr == 0)
                                if (c == ',')
@@ -114,12 +114,12 @@ error("Offset out-of-bounds|Offset after command too large");
                        addr1 = one;
                        addr2 = dol;
                        given = 2;
                        addr1 = one;
                        addr2 = dol;
                        given = 2;
-                       c = getchar();
+                       c = ex_getchar();
                }
                if (addr1 == 0)
                        addr1 = addr2;
                if (c == ':')
                }
                if (addr1 == 0)
                        addr1 = addr2;
                if (c == ':')
-                       c = getchar();
+                       c = ex_getchar();
 
                /*
                 * Set command name for special character commands.
 
                /*
                 * Set command name for special character commands.
@@ -142,7 +142,6 @@ error("Offset out-of-bounds|Offset after command too large");
 notinvis:
                                tailprim(Command, 1, 1);
                }
 notinvis:
                                tailprim(Command, 1, 1);
                }
-choice:
                switch (c) {
 
                case 'a':
                switch (c) {
 
                case 'a':
@@ -237,7 +236,7 @@ changdir:
                        setCNL();
                        vmacchng(0);
                        setin(addr1);
                        setCNL();
                        vmacchng(0);
                        setin(addr1);
-                       delete(0);
+                       ex_delete(0);
                        inappend = 1;
                        ignore(append(gettty, addr1 - 1));
                        inappend = 0;
                        inappend = 1;
                        ignore(append(gettty, addr1 - 1));
                        inappend = 0;
@@ -255,7 +254,7 @@ changdir:
                        vmacchng(0);
                        if (c)
                                YANKreg(c);
                        vmacchng(0);
                        if (c)
                                YANKreg(c);
-                       delete(0);
+                       ex_delete(0);
                        appendnone();
                        continue;
 
                        appendnone();
                        continue;
 
@@ -276,13 +275,13 @@ doecmd:
                        init();
                        addr2 = zero;
                        laste++;
                        init();
                        addr2 = zero;
                        laste++;
-                       sync();
+                       ex_sync();
                        rop(c);
 #ifdef VMUNIX
                        tlaste();
 #endif
                        laste = 0;
                        rop(c);
 #ifdef VMUNIX
                        tlaste();
 #endif
                        laste = 0;
-                       sync();
+                       ex_sync();
                        nochng();
                        continue;
 
                        nochng();
                        continue;
 
@@ -341,7 +340,7 @@ doecmd:
                case 'k':
 casek:
                        pastwh();
                case 'k':
 casek:
                        pastwh();
-                       c = getchar();
+                       c = ex_getchar();
                        if (endcmd(c))
                                serror("Mark what?|%s requires following letter", Command);
                        newline();
                        if (endcmd(c))
                                serror("Mark what?|%s requires following letter", Command);
                        newline();
@@ -470,10 +469,10 @@ quit:
                                        tostop();
                                }
                                flush();
                                        tostop();
                                }
                                flush();
-                               setty(normf);
+                               ignore(setty(normf));
                        }
                        cleanup(1);
                        }
                        cleanup(1);
-                       exit(0);
+                       ex_exit(0);
 
                case 'r':
                        if (peekchar() == 'e') {
 
                case 'r':
                        if (peekchar() == 'e') {
@@ -512,7 +511,7 @@ quit:
                                        init();
                                        addr2 = zero;
                                        laste++;
                                        init();
                                        addr2 = zero;
                                        laste++;
-                                       sync();
+                                       ex_sync();
                                        recover();
                                        rop2();
                                        revocer();
                                        recover();
                                        rop2();
                                        revocer();
@@ -672,7 +671,7 @@ suspend:
 /* version */
                                tail("version");
                                setNAEOL();
 /* version */
                                tail("version");
                                setNAEOL();
-                               printf("@(#) Version 3.7, %G%."+5);
+                               ex_printf("@(#) Version 3.7, 6/7/85."+5);
                                noonl();
                                continue;
 
                                noonl();
                                continue;
 
@@ -745,7 +744,7 @@ wq:
 /* @ */
                case '*':
                case '@':
 /* @ */
                case '*':
                case '@':
-                       c = getchar();
+                       c = ex_getchar();
                        if (c=='\n' || c=='\r')
                                ungetchar(c);
                        if (any(c, "@*\n\r"))
                        if (c=='\n' || c=='\r')
                                ungetchar(c);
                        if (any(c, "@*\n\r"))
@@ -813,7 +812,7 @@ numberit:
                        setall();
                        if (inglobal == 2)
                                pofix();
                        setall();
                        if (inglobal == 2)
                                pofix();
-                       printf("%d", lineno(addr2));
+                       ex_printf("%d", lineno(addr2));
                        noonl();
                        continue;
 
                        noonl();
                        continue;
 
index cd9ce7e..a267543 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_cmds2.c  7.4 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_cmds2.c  7.5 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -30,7 +30,7 @@ cmdreg()
        register int wh = skipwh();
 
        if (wh && isalpha(peekchar()))
        register int wh = skipwh();
 
        if (wh && isalpha(peekchar()))
-               c = getchar();
+               c = ex_getchar();
        return (c);
 }
 
        return (c);
 }
 
@@ -72,10 +72,14 @@ eol()
  */
 /*VARARGS2*/
 error(str, i)
  */
 /*VARARGS2*/
 error(str, i)
-#ifdef lint
-       register char *str;
+#ifndef EXSTRINGS
+       char *str;
 #else
 #else
-       register int str;
+# ifdef lint
+       char *str;
+# else
+       int str;
+# endif
 #endif
        int i;
 {
 #endif
        int i;
 {
@@ -99,9 +103,9 @@ erewind()
        argv = argv0;
        args = args0;
        if (argc > 1 && !hush) {
        argv = argv0;
        args = args0;
        if (argc > 1 && !hush) {
-               printf(mesg("%d files@to edit"), argc);
+               ex_printf(mesg("%d files@to edit"), argc);
                if (inopen)
                if (inopen)
-                       putchar(' ');
+                       ex_putchar(' ');
                else
                        putNFL();
        }
                else
                        putNFL();
        }
@@ -183,7 +187,7 @@ error1(str)
        if (str && !vcatch)
                putNFL();
        if (die)
        if (str && !vcatch)
                putNFL();
        if (die)
-               exit(1);
+               ex_exit(1);
        lseek(0, 0L, 2);
        if (inglobal)
                setlastchar('\n');
        lseek(0, 0L, 2);
        if (inglobal)
                setlastchar('\n');
@@ -263,7 +267,7 @@ newline()
 
        resetflav();
        for (;;) {
 
        resetflav();
        for (;;) {
-               c = getchar();
+               c = ex_getchar();
                switch (c) {
 
                case '^':
                switch (c) {
 
                case '^':
@@ -336,7 +340,7 @@ quickly()
                chng = 0;
 */
                xchng = 0;
                chng = 0;
 */
                xchng = 0;
-               error("No write@since last change (:%s! overrides)", Command);
+               serror("No write@since last change (:%s! overrides)", Command);
        }
        return (0);
 }
        }
        return (0);
 }
@@ -385,8 +389,8 @@ setflav()
 
        if (inopen)
                return;
 
        if (inopen)
                return;
-       setnumb(nflag || value(NUMBER));
-       setlist(listf || value(LIST));
+       ignorf(setnumb(nflag || value(NUMBER)));
+       ignorf(setlist(listf || value(LIST)));
        setoutt();
 }
 
        setoutt();
 }
 
@@ -444,7 +448,7 @@ tailprim(comm, i, notinvis)
        for (cp = tcommand; i > 0; i--)
                *cp++ = *comm++;
        while (*comm && peekchar() == *comm)
        for (cp = tcommand; i > 0; i--)
                *cp++ = *comm++;
        while (*comm && peekchar() == *comm)
-               *cp++ = getchar(), comm++;
+               *cp++ = ex_getchar(), comm++;
        c = peekchar();
        if (notinvis || isalpha(c)) {
                /*
        c = peekchar();
        if (notinvis || isalpha(c)) {
                /*
@@ -456,7 +460,7 @@ tailprim(comm, i, notinvis)
                if (tcommand[0] == 's' && any(c, "gcr"))
                        goto ret;
                while (cp < &tcommand[19] && isalpha(peekchar()))
                if (tcommand[0] == 's' && any(c, "gcr"))
                        goto ret;
                while (cp < &tcommand[19] && isalpha(peekchar()))
-                       *cp++ = getchar();
+                       *cp++ = ex_getchar();
                *cp = 0;
                if (notinvis)
                        serror("What?|%s: No such command from open/visual", tcommand);
                *cp = 0;
                if (notinvis)
                        serror("What?|%s: No such command from open/visual", tcommand);
@@ -522,7 +526,7 @@ vcontin(ask)
                        }
                }
                vclrech(1);
                        }
                }
                vclrech(1);
-               if (Peekkey != ':') {
+               if (Peek_key != ':') {
                        putpad(TI);
                        tostart();
                        /* replaced by ostart.
                        putpad(TI);
                        tostart();
                        /* replaced by ostart.
index d22d6b3..bec0d1a 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_cmdsub.c 7.7 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_cmdsub.c 7.8 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -91,12 +91,12 @@ pargs()
 
        for (ac = 0; ac < argc0; ac++) {
                if (ac != 0)
 
        for (ac = 0; ac < argc0; ac++) {
                if (ac != 0)
-                       putchar(' ' | QUOTE);
+                       ex_putchar(' ' | QUOTE);
                if (ac + argc == argc0 - 1)
                if (ac + argc == argc0 - 1)
-                       printf("[");
+                       ex_printf("[");
                lprintf("%s", as);
                if (ac + argc == argc0 - 1)
                lprintf("%s", as);
                if (ac + argc == argc0 - 1)
-                       printf("]");
+                       ex_printf("]");
                as = av ? *++av : strend(as) + 1;
        }
        noonl();
                as = av ? *++av : strend(as) + 1;
        }
        noonl();
@@ -106,7 +106,7 @@ pargs()
  * Delete lines; two cases are if we are really deleting,
  * more commonly we are just moving lines to the undo save area.
  */
  * Delete lines; two cases are if we are really deleting,
  * more commonly we are just moving lines to the undo save area.
  */
-delete(hush)
+ex_delete(hush)
        bool hush;
 {
        register line *a1, *a2;
        bool hush;
 {
        register line *a1, *a2;
@@ -230,7 +230,7 @@ join(c)
                cp--;
        }
        strcLIN(genbuf);
                cp--;
        }
        strcLIN(genbuf);
-       delete(0);
+       ex_delete(0);
        jcount = 1;
        if (FIXUNDO)
                undap1 = undap2 = addr1;
        jcount = 1;
        if (FIXUNDO)
                undap1 = undap2 = addr1;
@@ -491,7 +491,7 @@ tagfind(quick)
 
                while (!iswhite(peekchar()) && !endcmd(peekchar()))
                        if (lp < &lasttag[sizeof lasttag - 2])
 
                while (!iswhite(peekchar()) && !endcmd(peekchar()))
                        if (lp < &lasttag[sizeof lasttag - 2])
-                               *lp++ = getchar();
+                               *lp++ = ex_getchar();
                        else
                                ignchar();
                *lp++ = 0;
                        else
                                ignchar();
                *lp++ = 0;
@@ -500,7 +500,7 @@ badtag:
                        error("Bad tag|Give one tag per line");
        } else if (lasttag[0] == 0)
                error("No previous tag");
                        error("Bad tag|Give one tag per line");
        } else if (lasttag[0] == 0)
                error("No previous tag");
-       c = getchar();
+       c = ex_getchar();
        if (!endcmd(c))
                goto badtag;
        if (c == EOF)
        if (!endcmd(c))
                goto badtag;
        if (c == EOF)
@@ -564,7 +564,7 @@ badtag:
                        if(tgets(linebuf, sizeof linebuf, iof)==NULL)
                                goto goleft;
 #ifdef TDEBUG
                        if(tgets(linebuf, sizeof linebuf, iof)==NULL)
                                goto goleft;
 #ifdef TDEBUG
-                       printf("tag: %o %o %o %s\n", bot, mid, top, linebuf);
+                       ex_printf("tag: %o %o %o %s\n", bot, mid, top, linebuf);
 #endif
 #endif
                        while (*cp && *lp == *cp)
 #endif
 #endif
                        while (*cp && *lp == *cp)
@@ -718,7 +718,7 @@ zop(hadpr)
        znoclear = 0;
        zweight = 0;
        excl = exclam();
        znoclear = 0;
        zweight = 0;
        excl = exclam();
-       switch (c = op = getchar()) {
+       switch (c = op = ex_getchar()) {
 
        case '^':
                zweight = 1;
 
        case '^':
                zweight = 1;
@@ -730,7 +730,7 @@ zop(hadpr)
                }
        case '=':
        case '.':
                }
        case '=':
        case '.':
-               c = getchar();
+               c = ex_getchar();
                break;
 
        case EOF:
                break;
 
        case EOF:
@@ -744,7 +744,7 @@ zop(hadpr)
        if (isdigit(c)) {
                lines = c - '0';
                for(;;) {
        if (isdigit(c)) {
                lines = c - '0';
                for(;;) {
-                       c = getchar();
+                       c = ex_getchar();
                        if (!isdigit(c))
                                break;
                        lines *= 10;
                        if (!isdigit(c))
                                break;
                        lines *= 10;
@@ -830,7 +830,7 @@ zop2(lines, op)
                return;
        if (op == EOF && zhadpr) {
                getline(*addr1);
                return;
        if (op == EOF && zhadpr) {
                getline(*addr1);
-               putchar('\r' | QUOTE);
+               ex_putchar('\r' | QUOTE);
                shudclob = 1;
        } else if (znoclear == 0 && CL != NOSTR && !inopen) {
                flush1();
                shudclob = 1;
        } else if (znoclear == 0 && CL != NOSTR && !inopen) {
                flush1();
@@ -854,7 +854,7 @@ splitit()
        register int l;
 
        for (l = COLUMNS > 80 ? 40 : COLUMNS / 2; l > 0; l--)
        register int l;
 
        for (l = COLUMNS > 80 ? 40 : COLUMNS / 2; l > 0; l--)
-               putchar('-');
+               ex_putchar('-');
        putnl();
 }
 
        putnl();
 }
 
@@ -870,7 +870,7 @@ plines(adr1, adr2, movedot)
                getline(*addr);
                pline(lineno(addr));
                if (inopen)
                getline(*addr);
                pline(lineno(addr));
                if (inopen)
-                       putchar('\n' | QUOTE);
+                       ex_putchar('\n' | QUOTE);
                if (movedot)
                        dot = addr;
        }
                if (movedot)
                        dot = addr;
        }
@@ -1096,9 +1096,9 @@ mapcmd(un, ab)
                for (i=0; mp[i].mapto; i++)
                        if (mp[i].cap) {
                                lprintf("%s", mp[i].descr);
                for (i=0; mp[i].mapto; i++)
                        if (mp[i].cap) {
                                lprintf("%s", mp[i].descr);
-                               putchar('\t');
+                               ex_putchar('\t');
                                lprintf("%s", mp[i].cap);
                                lprintf("%s", mp[i].cap);
-                               putchar('\t');
+                               ex_putchar('\t');
                                lprintf("%s", mp[i].mapto);
                                putNFL();
                        }
                                lprintf("%s", mp[i].mapto);
                                putNFL();
                        }
@@ -1107,9 +1107,9 @@ mapcmd(un, ab)
 
        ignore(skipwh());
        for (p=lhs; ; ) {
 
        ignore(skipwh());
        for (p=lhs; ; ) {
-               c = getchar();
+               c = ex_getchar();
                if (c == CTRL(v)) {
                if (c == CTRL(v)) {
-                       c = getchar();
+                       c = ex_getchar();
                } else if (!un && any(c, " \t")) {
                        /* End of lhs */
                        break;
                } else if (!un && any(c, " \t")) {
                        /* End of lhs */
                        break;
@@ -1130,9 +1130,9 @@ mapcmd(un, ab)
        if (skipend())
                error("Missing rhs");
        for (p=rhs; ; ) {
        if (skipend())
                error("Missing rhs");
        for (p=rhs; ; ) {
-               c = getchar();
+               c = ex_getchar();
                if (c == CTRL(v)) {
                if (c == CTRL(v)) {
-                       c = getchar();
+                       c = ex_getchar();
                } else if (endcmd(c) && c!='"') {
                        ungetchar(c);
                        break;
                } else if (endcmd(c) && c!='"') {
                        ungetchar(c);
                        break;
index e506137..f42550e 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_data.c   7.5 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_data.c   7.6 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -20,7 +20,11 @@ static char *sccsid = "@(#)ex_data.c 7.5 (Berkeley) %G%";
  * to confuse xstr so it will leave them alone.
  */
 char   direct[ONMSZ] =
  * to confuse xstr so it will leave them alone.
  */
 char   direct[ONMSZ] =
+#ifdef vms
+       {'t', 'm', 'p', ':'}; 
+#else
        {'/', 't', 'm', 'p'}; 
        {'/', 't', 'm', 'p'}; 
+#endif
 char   paragraphs[ONMSZ] = {
        'I', 'P', 'L', 'P', 'P', 'P', 'Q', 'P',         /* -ms macros */
        'P', ' ', 'L', 'I',                             /* -mm macros */
 char   paragraphs[ONMSZ] = {
        'I', 'P', 'L', 'P', 'P', 'P', 'Q', 'P',         /* -ms macros */
        'P', ' ', 'L', 'I',                             /* -mm macros */
@@ -54,6 +58,9 @@ struct        option options[NOPTS + 1] = {
        "errorbells",   "eb",   ONOFF,          0,      0,      0,
        "hardtabs",     "ht",   NUMERIC,        8,      8,      0,
        "ignorecase",   "ic",   ONOFF,          0,      0,      0,
        "errorbells",   "eb",   ONOFF,          0,      0,      0,
        "hardtabs",     "ht",   NUMERIC,        8,      8,      0,
        "ignorecase",   "ic",   ONOFF,          0,      0,      0,
+#ifndef        UNIX_SBRK
+       "linelimit",    "ll",   NUMERIC,        2000,   2000,   0,
+#endif
        "lisp",         0,      ONOFF,          0,      0,      0,
        "list",         0,      ONOFF,          0,      0,      0,
        "magic",        0,      ONOFF,          1,      1,      0,
        "lisp",         0,      ONOFF,          0,      0,      0,
        "list",         0,      ONOFF,          0,      0,      0,
        "magic",        0,      ONOFF,          1,      1,      0,
index 2901b5c..7dbcc91 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_get.c    7.6 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_get.c    7.7 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -21,10 +21,10 @@ short       lastc = '\n';
 
 ignchar()
 {
 
 ignchar()
 {
-       ignore(getchar());
+       ignore(ex_getchar());
 }
 
 }
 
-getchar()
+ex_getchar()
 {
        register int c;
 
 {
        register int c;
 
@@ -57,7 +57,7 @@ peekchar()
 {
 
        if (peekc == 0)
 {
 
        if (peekc == 0)
-               peekc = getchar();
+               peekc = ex_getchar();
        return (peekc);
 }
 
        return (peekc);
 }
 
@@ -72,7 +72,6 @@ getach()
 {
        register int c;
        static char inline[BUFSIZ];
 {
        register int c;
        static char inline[BUFSIZ];
-       struct stat statb;
 
        c = peekc;
        if (c != 0) {
 
        c = peekc;
        if (c != 0) {
@@ -137,7 +136,7 @@ gettty()
        if (intty && !inglobal) {
                if (offset) {
                        holdcm = 1;
        if (intty && !inglobal) {
                if (offset) {
                        holdcm = 1;
-                       printf("  %4d  ", lineDOT() + 1);
+                       ex_printf("  %4d  ", lineDOT() + 1);
                        flush();
                        holdcm = 0;
                }
                        flush();
                        holdcm = 0;
                }
@@ -165,13 +164,13 @@ gettty()
                                        if (c == '0')
                                                lastin = 0;
                                        if (!OS) {
                                        if (c == '0')
                                                lastin = 0;
                                        if (!OS) {
-                                               putchar('\b' | QUOTE);
-                                               putchar(' ' | QUOTE);
-                                               putchar('\b' | QUOTE);
+                                               ex_putchar('\b' | QUOTE);
+                                               ex_putchar(' ' | QUOTE);
+                                               ex_putchar('\b' | QUOTE);
                                        }
                                        tab(offset);
                                        hadup = 1;
                                        }
                                        tab(offset);
                                        hadup = 1;
-                                       c = getchar();
+                                       c = ex_getchar();
                                } else
                                        ungetchar(ch);
                                break;
                                } else
                                        ungetchar(ch);
                                break;
@@ -194,12 +193,12 @@ gettty()
                holdcm = 0;
        }
        if (c == 0)
                holdcm = 0;
        }
        if (c == 0)
-               c = getchar();
+               c = ex_getchar();
        while (c != EOF && c != '\n') {
                if (cp > &genbuf[LBSIZE - 2])
                        error("Input line too long");
                *cp++ = c;
        while (c != EOF && c != '\n') {
                if (cp > &genbuf[LBSIZE - 2])
                        error("Input line too long");
                *cp++ = c;
-               c = getchar();
+               c = ex_getchar();
        }
        if (c == EOF) {
                if (inglobal)
        }
        if (c == EOF) {
                if (inglobal)
index 62f7324..d3d9663 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_io.c     7.12 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_io.c     7.13 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -47,7 +47,7 @@ filename(comm)
        register int c = comm, d;
        register int i;
 
        register int c = comm, d;
        register int i;
 
-       d = getchar();
+       d = ex_getchar();
        if (endcmd(d)) {
                if (savedfile[0] == 0 && comm != 'f')
                        error("No file|No current filename");
        if (endcmd(d)) {
                if (savedfile[0] == 0 && comm != 'f')
                        error("No file|No current filename");
@@ -98,19 +98,19 @@ filename(comm)
                lprintf("\"%s\"", file);
                if (comm == 'f') {
                        if (value(READONLY))
                lprintf("\"%s\"", file);
                if (comm == 'f') {
                        if (value(READONLY))
-                               printf(" [Read only]");
+                               ex_printf(" [Read only]");
                        if (!edited)
                        if (!edited)
-                               printf(" [Not edited]");
+                               ex_printf(" [Not edited]");
                        if (tchng)
                        if (tchng)
-                               printf(" [Modified]");
+                               ex_printf(" [Modified]");
                }
                flush();
        } else
                }
                flush();
        } else
-               printf("No file ");
+               ex_printf("No file ");
        if (comm == 'f') {
                if (!(i = lineDOL()))
                        i++;
        if (comm == 'f') {
                if (!(i = lineDOL()))
                        i++;
-               printf(" line %d of %d --%ld%%--", lineDOT(), lineDOL(),
+               ex_printf(" line %d of %d --%ld%%--", lineDOT(), lineDOL(),
                    (long) 100 * lineDOT() / i);
        }
 }
                    (long) 100 * lineDOT() / i);
        }
 }
@@ -128,11 +128,11 @@ getargs()
        pastwh();
        if (peekchar() == '+') {
                for (cp = fpatbuf;;) {
        pastwh();
        if (peekchar() == '+') {
                for (cp = fpatbuf;;) {
-                       c = *cp++ = getchar();
+                       c = *cp++ = ex_getchar();
                        if (cp >= &fpatbuf[sizeof(fpatbuf)])
                                error("Pattern too long");
                        if (c == '\\' && isspace(peekchar()))
                        if (cp >= &fpatbuf[sizeof(fpatbuf)])
                                error("Pattern too long");
                        if (c == '\\' && isspace(peekchar()))
-                               c = getchar();
+                               c = ex_getchar();
                        if (c == EOF || isspace(c)) {
                                ungetchar(c);
                                *--cp = 0;
                        if (c == EOF || isspace(c)) {
                                ungetchar(c);
                                *--cp = 0;
@@ -145,7 +145,7 @@ getargs()
                return (0);
        CP(genbuf, "echo "); cp = &genbuf[5];
        for (;;) {
                return (0);
        CP(genbuf, "echo "); cp = &genbuf[5];
        for (;;) {
-               c = getchar();
+               c = ex_getchar();
                if (endcmd(c)) {
                        ungetchar(c);
                        break;
                if (endcmd(c)) {
                        ungetchar(c);
                        break;
@@ -154,7 +154,7 @@ getargs()
 
                case '\\':
                        if (any(peekchar(), "#%|"))
 
                case '\\':
                        if (any(peekchar(), "#%|"))
-                               c = getchar();
+                               c = ex_getchar();
                        /* fall into... */
 
                default:
                        /* fall into... */
 
                default:
@@ -221,7 +221,7 @@ glob(gp)
        }
        if (pipe(pvec) < 0)
                error("Can't make pipe to glob");
        }
        if (pipe(pvec) < 0)
                error("Can't make pipe to glob");
-       pid = fork();
+       pid = vfork();
        io = pvec[0];
        if (pid < 0) {
                close(pvec[1]);
        io = pvec[0];
        if (pid < 0) {
                close(pvec[1]);
@@ -234,9 +234,12 @@ glob(gp)
                dup(pvec[1]);
                close(pvec[0]);
                close(2);       /* so errors don't mess up the screen */
                dup(pvec[1]);
                close(pvec[0]);
                close(2);       /* so errors don't mess up the screen */
-               open("/dev/null", 1);
+               ignore(open("/dev/null", 1));
                execl(svalue(SHELL), "sh", "-c", genbuf, 0);
                execl(svalue(SHELL), "sh", "-c", genbuf, 0);
-               oerrno = errno; close(1); dup(2); errno = oerrno;
+               oerrno = errno;
+               close(1);
+               dup(2);
+               errno = oerrno;
                filioerr(svalue(SHELL));
        }
        close(pvec[1]);
                filioerr(svalue(SHELL));
        }
        close(pvec[1]);
@@ -274,12 +277,17 @@ glob(gp)
  */
 gscan()
 {
  */
 gscan()
 {
+#ifndef        vms
        register char *cp;
 
        for (cp = genbuf; *cp; cp++)
        register char *cp;
 
        for (cp = genbuf; *cp; cp++)
+               if (any(*cp, "~{[*?$`'\"\\"))
                if (any(*cp, "~{[*?$`'\"\\"))
                        return (1);
        return (0);
                if (any(*cp, "~{[*?$`'\"\\"))
                        return (1);
        return (0);
+#else
+       return 0;       /* Never have meta-characters in vms */
+#endif
 }
 
 /*
 }
 
 /*
@@ -298,7 +306,6 @@ getone()
        str = G.argv[G.argc0 - 1];
        if (strlen(str) > FNSIZE - 4)
                error("Filename too long");
        str = G.argv[G.argc0 - 1];
        if (strlen(str) > FNSIZE - 4)
                error("Filename too long");
-samef:
        CP(file, str);
 }
 
        CP(file, str);
 }
 
@@ -325,7 +332,7 @@ rop(c)
                         * this is ugly, and it screws up the + option.
                         */
                        if (!seenprompt) {
                         * this is ugly, and it screws up the + option.
                         */
                        if (!seenprompt) {
-                               printf(" [New file]");
+                               ex_printf(" [New file]");
                                noonl();
                                return;
                        }
                                noonl();
                                return;
                        }
@@ -354,6 +361,7 @@ rop(c)
                lseek(io, 0l, 0);
                if (i != sizeof(magic))
                        break;
                lseek(io, 0l, 0);
                if (i != sizeof(magic))
                        break;
+#ifndef vms
                switch (magic) {
 
                case 0405:      /* data overlay on exec */
                switch (magic) {
 
                case 0405:      /* data overlay on exec */
@@ -388,6 +396,7 @@ rop(c)
                                error(" Non-ascii file");
                        break;
                }
                                error(" Non-ascii file");
                        break;
                }
+#endif
        }
        if (c != 'r') {
                if (value(READONLY) && denied) {
        }
        if (c != 'r') {
                if (value(READONLY) && denied) {
@@ -401,7 +410,7 @@ rop(c)
                }
        }
        if (value(READONLY)) {
                }
        }
        if (value(READONLY)) {
-               printf(" [Read only]");
+               ex_printf(" [Read only]");
                flush();
        }
        if (c == 'r')
                flush();
        }
        if (c == 'r')
@@ -586,9 +595,9 @@ cre:
                writing = 1;
                if (hush == 0)
                        if (nonexist)
                writing = 1;
                if (hush == 0)
                        if (nonexist)
-                               printf(" [New file]");
+                               ex_printf(" [New file]");
                        else if (value(WRITEANY) && edfile() != EDF)
                        else if (value(WRITEANY) && edfile() != EDF)
-                               printf(" [Existing file]");
+                               ex_printf(" [Existing file]");
                break;
 
        case 2:
                break;
 
        case 2:
@@ -602,12 +611,14 @@ cre:
                break;
        }
        putfile(0);
                break;
        }
        putfile(0);
+#ifndef        vms
        (void) fsync(io);
        (void) fsync(io);
+#endif
        ignore(iostats());
        if (c != 2 && addr1 == one && addr2 == dol) {
                if (eq(file, savedfile))
                        edited = 1;
        ignore(iostats());
        if (c != 2 && addr1 == one && addr2 == dol) {
                if (eq(file, savedfile))
                        edited = 1;
-               sync();
+               ex_sync();
        }
        if (!dofname) {
                addr1 = saddr1;
        }
        if (!dofname) {
                addr1 = saddr1;
@@ -644,11 +655,11 @@ getfile()
        fp = nextip;
        do {
                if (--ninbuf < 0) {
        fp = nextip;
        do {
                if (--ninbuf < 0) {
-                       ninbuf = read(io, genbuf, bsize) - 1;
+                       ninbuf = read(io, genbuf, (int) bsize) - 1;
                        if (ninbuf < 0) {
                                if (lp != linebuf) {
                                        lp++;
                        if (ninbuf < 0) {
                                if (lp != linebuf) {
                                        lp++;
-                                       printf(" [Incomplete last line]");
+                                       ex_printf(" [Incomplete last line]");
                                        break;
                                }
                                return (EOF);
                                        break;
                                }
                                return (EOF);
@@ -681,6 +692,7 @@ getfile()
 /*
  * Write a range onto the io stream.
  */
 /*
  * Write a range onto the io stream.
  */
+/* ARGSUSED */
 putfile(isfilter)
 int isfilter;
 {
 putfile(isfilter)
 int isfilter;
 {
@@ -829,20 +841,20 @@ iostats()
        io = -1;
        if (hush == 0) {
                if (value(TERSE))
        io = -1;
        if (hush == 0) {
                if (value(TERSE))
-                       printf(" %d/%D", cntln, cntch);
+                       ex_printf(" %d/%D", cntln, cntch);
                else
                else
-                       printf(" %d line%s, %D character%s", cntln, plural((long) cntln),
+                       ex_printf(" %d line%s, %D character%s", cntln, plural((long) cntln),
                            cntch, plural(cntch));
                if (cntnull || cntodd) {
                            cntch, plural(cntch));
                if (cntnull || cntodd) {
-                       printf(" (");
+                       ex_printf(" (");
                        if (cntnull) {
                        if (cntnull) {
-                               printf("%D null", cntnull);
+                               ex_printf("%D null", cntnull);
                                if (cntodd)
                                if (cntodd)
-                                       printf(", ");
+                                       ex_printf(", ");
                        }
                        if (cntodd)
                        }
                        if (cntodd)
-                               printf("%D non-ASCII", cntodd);
-                       putchar(')');
+                               ex_printf("%D non-ASCII", cntodd);
+                       ex_putchar(')');
                }
                noonl();
                flush();
                }
                noonl();
                flush();
@@ -850,8 +862,15 @@ iostats()
        return (cntnull != 0 || cntodd != 0);
 }
 
        return (cntnull != 0 || cntodd != 0);
 }
 
-#if USG | USG3TTY
-/* It's so wonderful how we all speak the same language... */
+#ifdef USG
+# define index strchr
+# define rindex strrchr
+#endif
+#ifdef USG3TTY
+# define index strchr
+# define rindex strrchr
+#endif
+#ifdef vms
 # define index strchr
 # define rindex strrchr
 #endif
 # define index strchr
 # define rindex strrchr
 #endif
@@ -861,7 +880,7 @@ char *line;
 {
        char *beg, *end;
        char cmdbuf[1024];
 {
        char *beg, *end;
        char cmdbuf[1024];
-       char *index(), *rindex();
+       char *index(), *rindex(), *strncpy();
 
        beg = index(line, ':');
        if (beg == NULL)
 
        beg = index(line, ':');
        if (beg == NULL)
index f2fa23f..601b40b 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_put.c    7.9 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_put.c    7.10 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -29,7 +29,7 @@ static char *sccsid = "@(#)ex_put.c   7.9 (Berkeley) %G%";
  * routines in the file ex_vput.c (vputchar, vinschar, etc.).
  */
 int    (*Outchar)() = termchar;
  * routines in the file ex_vput.c (vputchar, vinschar, etc.).
  */
 int    (*Outchar)() = termchar;
-int    (*Putchar)() = normchar;
+int    (*Put_char)() = normchar;
 int    (*Pline)() = normline;
 
 int (*
 int    (*Pline)() = normline;
 
 int (*
@@ -39,8 +39,8 @@ setlist(t))()
        register int (*P)();
 
        listf = t;
        register int (*P)();
 
        listf = t;
-       P = Putchar;
-       Putchar = t ? listchar : normchar;
+       P = Put_char;
+       Put_char = t ? listchar : normchar;
        return (P);
 }
 
        return (P);
 }
 
@@ -118,7 +118,7 @@ normchar(c)
                        c &= TRIM;
                }
        else if (c < ' ' && (c != '\b' || !OS) && c != '\n' && c != '\t' || c == DELETE)
                        c &= TRIM;
                }
        else if (c < ' ' && (c != '\b' || !OS) && c != '\n' && c != '\t' || c == DELETE)
-               putchar('^'), c = ctlof(c);
+               ex_putchar('^'), c = ctlof(c);
        else if (UPPERCASE)
                if (isupper(c)) {
                        outchar('\\');
        else if (UPPERCASE)
                if (isupper(c)) {
                        outchar('\\');
@@ -144,7 +144,7 @@ numbline(i)
 
        if (shudclob)
                slobber(' ');
 
        if (shudclob)
                slobber(' ');
-       printf("%6d  ", i);
+       ex_printf("%6d  ", i);
        normline();
 }
 
        normline();
 }
 
@@ -160,9 +160,9 @@ normline()
        /* pdp-11 doprnt is not reentrant so can't use "printf" here
           in case we are tracing */
        for (cp = linebuf; *cp;)
        /* pdp-11 doprnt is not reentrant so can't use "printf" here
           in case we are tracing */
        for (cp = linebuf; *cp;)
-               putchar(*cp++);
+               ex_putchar(*cp++);
        if (!inopen)
        if (!inopen)
-               putchar('\n' | QUOTE);
+               ex_putchar('\n' | QUOTE);
 }
 
 /*
 }
 
 /*
@@ -178,7 +178,7 @@ slobber(c)
        switch (c) {
 
        case '\t':
        switch (c) {
 
        case '\t':
-               if (Putchar == listchar)
+               if (Put_char == listchar)
                        return;
                break;
 
                        return;
                break;
 
@@ -217,11 +217,11 @@ static    bool phadnl;
 /*
  * Indirect to current definition of putchar.
  */
 /*
  * Indirect to current definition of putchar.
  */
-putchar(c)
+ex_putchar(c)
        int c;
 {
 
        int c;
 {
 
-       (*Putchar)(c);
+       (*Put_char)(c);
 }
 
 /*
 }
 
 /*
@@ -771,7 +771,11 @@ flusho()
 {
 
        if (obp != obuf) {
 {
 
        if (obp != obuf) {
+#ifndef vms
                write(1, obuf, obp - obuf);
                write(1, obuf, obp - obuf);
+#else
+               vms_write(1, obuf, obp - obuf);
+#endif
                obp = obuf;
        }
 }
                obp = obuf;
        }
 }
@@ -779,10 +783,10 @@ flusho()
 putnl()
 {
 
 putnl()
 {
 
-       putchar('\n');
+       ex_putchar('\n');
 }
 
 }
 
-putS(cp)
+ex_putS(cp)
        char *cp;
 {
 
        char *cp;
 {
 
@@ -833,15 +837,15 @@ setoutt()
 /*
  * Printf (temporarily) in list mode.
  */
 /*
  * Printf (temporarily) in list mode.
  */
-/*VARARGS2*/
+/*VARARGS1*/
 lprintf(cp, dp)
        char *cp, *dp;
 {
        register int (*P)();
 
        P = setlist(1);
 lprintf(cp, dp)
        char *cp, *dp;
 {
        register int (*P)();
 
        P = setlist(1);
-       printf(cp, dp);
-       Putchar = P;
+       ex_printf(cp, dp);
+       Put_char = P;
 }
 
 /*
 }
 
 /*
@@ -877,7 +881,7 @@ pstart()
        tty.c_oflag &= ~(ONLCR|TAB3);
        tty.c_lflag &= ~ECHO;
 #endif
        tty.c_oflag &= ~(ONLCR|TAB3);
        tty.c_lflag &= ~ECHO;
 #endif
-       sTTY(1);
+       ex_sTTY(1);
 }
 
 /*
 }
 
 /*
@@ -905,7 +909,7 @@ ostart()
 
        if (!intty)
                error("Open and visual must be used interactively");
 
        if (!intty)
                error("Open and visual must be used interactively");
-       gTTY(1);
+       ex_gTTY(1);
        normtty++;
 #ifndef USG3TTY
        f = tty.sg_flags;
        normtty++;
 #ifndef USG3TTY
        f = tty.sg_flags;
@@ -928,7 +932,7 @@ ostart()
        tty.c_cc[VTIME] = 1;
        ttcharoff();
 #endif
        tty.c_cc[VTIME] = 1;
        ttcharoff();
 #endif
-       sTTY(1);
+       ex_sTTY(1);
        tostart();
        pfast |= 2;
        return (f);
        tostart();
        pfast |= 2;
        return (f);
@@ -1043,7 +1047,7 @@ vcook()
 {
 
        tty.sg_flags &= ~RAW;
 {
 
        tty.sg_flags &= ~RAW;
-       sTTY(1);
+       ex_sTTY(1);
 }
 
 /*
 }
 
 /*
@@ -1053,7 +1057,7 @@ vraw()
 {
 
        tty.sg_flags |= RAW;
 {
 
        tty.sg_flags |= RAW;
-       sTTY(1);
+       ex_sTTY(1);
 }
 #endif
 
 }
 #endif
 
@@ -1065,7 +1069,7 @@ normal(f)
 {
 
        if (normtty > 0) {
 {
 
        if (normtty > 0) {
-               setty(f);
+               ignore(setty(f));
                normtty--;
        }
 }
                normtty--;
        }
 }
@@ -1085,6 +1089,7 @@ setty(f)
 #endif
 
 #ifndef USG3TTY
 #endif
 
 #ifndef USG3TTY
+# ifdef TIOCGETC
        if (f == normf) {
                nttyc = ottyc;
 # ifdef TIOCLGET
        if (f == normf) {
                nttyc = ottyc;
 # ifdef TIOCLGET
@@ -1092,40 +1097,41 @@ setty(f)
 # endif
        } else
                ttcharoff();
 # endif
        } else
                ttcharoff();
+# endif
        tty.sg_flags = f;
 #else
        if (tty.c_lflag & ICANON)
                ttcharoff();
        tty = f;
 #endif
        tty.sg_flags = f;
 #else
        if (tty.c_lflag & ICANON)
                ttcharoff();
        tty = f;
 #endif
-       sTTY(1);
+       ex_sTTY(1);
        return (ot);
 }
 
        return (ot);
 }
 
-gTTY(i)
+ex_gTTY(i)
        int i;
 {
 
 #ifndef USG3TTY
        ignore(gtty(i, &tty));
 # ifdef TIOCGETC
        int i;
 {
 
 #ifndef USG3TTY
        ignore(gtty(i, &tty));
 # ifdef TIOCGETC
-       ioctl(i, TIOCGETC, &ottyc);
+       ioctl(i, TIOCGETC, (char *) &ottyc);
        nttyc = ottyc;
 # endif
 # ifdef TIOCGLTC
        nttyc = ottyc;
 # endif
 # ifdef TIOCGLTC
-       ioctl(i, TIOCGLTC, &olttyc);
+       ioctl(i, TIOCGLTC, (char *) &olttyc);
        nlttyc = olttyc;
 # endif
 #else
        nlttyc = olttyc;
 # endif
 #else
-       ioctl(i, TCGETA, &tty);
+       ioctl(i, TCGETA, (char *) &tty);
 #endif
 }
 
 /*
 #endif
 }
 
 /*
- * sTTY: set the tty modes on file descriptor i to be what's
+ * ex_sTTY: set the tty modes on file descriptor i to be what's
  * currently in global "tty".  (Also use nttyc if needed.)
  */
  * currently in global "tty".  (Also use nttyc if needed.)
  */
-sTTY(i)
+ex_sTTY(i)
        int i;
 {
 
        int i;
 {
 
@@ -1138,7 +1144,7 @@ sTTY(i)
 
 # ifdef TIOCSETN
        /* Don't flush typeahead if we don't have to */
 
 # ifdef TIOCSETN
        /* Don't flush typeahead if we don't have to */
-       ioctl(i, TIOCSETN, &tty);
+       ioctl(i, TIOCSETN, (char *) &tty);
 # else
        /* We have to.  Too bad. */
        stty(i, &tty);
 # else
        /* We have to.  Too bad. */
        stty(i, &tty);
@@ -1146,15 +1152,15 @@ sTTY(i)
 
 # ifdef TIOCGETC
        /* Update the other random chars while we're at it. */
 
 # ifdef TIOCGETC
        /* Update the other random chars while we're at it. */
-       ioctl(i, TIOCSETC, &nttyc);
+       ioctl(i, TIOCSETC, (char *) &nttyc);
 # endif
 # ifdef TIOCSLTC
 # endif
 # ifdef TIOCSLTC
-       ioctl(i, TIOCSLTC, &nlttyc);
+       ioctl(i, TIOCSLTC, (char *) &nlttyc);
 # endif
 
 #else
        /* USG 3 very simple: just set everything */
 # endif
 
 #else
        /* USG 3 very simple: just set everything */
-       ioctl(i, TCSETAW, &tty);
+       ioctl(i, TCSETAW, (char *) &tty);
 #endif
 }
 
 #endif
 }
 
@@ -1164,5 +1170,5 @@ sTTY(i)
 noonl()
 {
 
 noonl()
 {
 
-       putchar(Outchar != termchar ? ' ' : '\n');
+       ex_putchar(Outchar != termchar ? ' ' : '\n');
 }
 }
index d86e63c..c12d077 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_re.c     7.5 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_re.c     7.6 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -44,11 +44,11 @@ global(k)
        nonzero();
        if (skipend())
                error("Global needs re|Missing regular expression for global");
        nonzero();
        if (skipend())
                error("Global needs re|Missing regular expression for global");
-       c = getchar();
+       c = ex_getchar();
        ignore(compile(c, 1));
        savere(scanre);
        gp = globuf;
        ignore(compile(c, 1));
        savere(scanre);
        gp = globuf;
-       while ((c = getchar()) != '\n') {
+       while ((c = ex_getchar()) != '\n') {
                switch (c) {
 
                case EOF:
                switch (c) {
 
                case EOF:
@@ -56,7 +56,7 @@ global(k)
                        goto brkwh;
 
                case '\\':
                        goto brkwh;
 
                case '\\':
-                       c = getchar();
+                       c = ex_getchar();
                        switch (c) {
 
                        case '\\':
                        switch (c) {
 
                        case '\\':
@@ -78,7 +78,6 @@ global(k)
        }
 brkwh:
        ungetchar(c);
        }
 brkwh:
        ungetchar(c);
-out:
        newline();
        *gp++ = c;
        *gp++ = 0;
        newline();
        *gp++ = c;
        *gp++ = 0;
@@ -224,7 +223,7 @@ compsub(ch)
 
        case 's':
                ignore(skipwh());
 
        case 's':
                ignore(skipwh());
-               seof = getchar();
+               seof = ex_getchar();
                if (endcmd(seof) || any(seof, "gcr")) {
                        ungetchar(seof);
                        goto redo;
                if (endcmd(seof) || any(seof, "gcr")) {
                        ungetchar(seof);
                        goto redo;
@@ -250,7 +249,7 @@ compsub(ch)
                break;
        }
        for (;;) {
                break;
        }
        for (;;) {
-               c = getchar();
+               c = ex_getchar();
                switch (c) {
 
                case 'g':
                switch (c) {
 
                case 'g':
@@ -288,13 +287,13 @@ comprhs(seof)
        rp = rhsbuf;
        CP(orhsbuf, rp);
        for (;;) {
        rp = rhsbuf;
        CP(orhsbuf, rp);
        for (;;) {
-               c = getchar();
+               c = ex_getchar();
                if (c == seof)
                        break;
                switch (c) {
 
                case '\\':
                if (c == seof)
                        break;
                switch (c) {
 
                case '\\':
-                       c = getchar();
+                       c = ex_getchar();
                        if (c == EOF) {
                                ungetchar(c);
                                break;
                        if (c == EOF) {
                                ungetchar(c);
                                break;
@@ -377,7 +376,7 @@ confirmed(a)
        pofix();
        pline(lineno(a));
        if (inopen)
        pofix();
        pline(lineno(a));
        if (inopen)
-               putchar('\n' | QUOTE);
+               ex_putchar('\n' | QUOTE);
        c = column(loc1 - 1);
        ugo(c - 1 + (inopen ? 1 : 0), ' ');
        ugo(column(loc2 - 1) - c, '^');
        c = column(loc1 - 1);
        ugo(c - 1 + (inopen ? 1 : 0), ' ');
        ugo(column(loc2 - 1) - c, '^');
@@ -387,7 +386,7 @@ again:
        if (c == '\r')
                c = '\n';
        if (inopen)
        if (c == '\r')
                c = '\n';
        if (inopen)
-               putchar(c), flush();
+               ex_putchar(c), flush();
        if (c != '\n' && c != EOF) {
                c = getkey();
                goto again;
        if (c != '\n' && c != EOF) {
                c = getkey();
                goto again;
@@ -412,7 +411,7 @@ ugo(cnt, with)
 
        if (cnt > 0)
                do
 
        if (cnt > 0)
                do
-                       putchar(with);
+                       ex_putchar(with);
                while (--cnt > 0);
 }
 
                while (--cnt > 0);
 }
 
@@ -526,9 +525,9 @@ snote(total, lines)
 
        if (!notable(total))
                return;
 
        if (!notable(total))
                return;
-       printf(mesg("%d subs|%d substitutions"), total);
+       ex_printf(mesg("%d subs|%d substitutions"), total);
        if (lines != 1 && lines != total)
        if (lines != 1 && lines != total)
-               printf(" on %d lines", lines);
+               ex_printf(" on %d lines", lines);
        noonl();
        flush();
 }
        noonl();
        flush();
 }
@@ -546,7 +545,7 @@ compile(eof, oknl)
        if (isalpha(eof) || isdigit(eof))
                error("Regular expressions cannot be delimited by letters or digits");
        ep = expbuf;
        if (isalpha(eof) || isdigit(eof))
                error("Regular expressions cannot be delimited by letters or digits");
        ep = expbuf;
-       c = getchar();
+       c = ex_getchar();
        if (eof == '\\')
                switch (c) {
 
        if (eof == '\\')
                switch (c) {
 
@@ -579,7 +578,7 @@ error("No previous substitute re|No previous substitute regular expression");
        nbra = 0;
        circfl = 0;
        if (c == '^') {
        nbra = 0;
        circfl = 0;
        if (c == '^') {
-               c = getchar();
+               c = ex_getchar();
                circfl++;
        }
        ungetchar(c);
                circfl++;
        }
        ungetchar(c);
@@ -587,7 +586,7 @@ error("No previous substitute re|No previous substitute regular expression");
                if (ep >= &expbuf[ESIZE - 2])
 complex:
                        cerror("Re too complex|Regular expression too complicated");
                if (ep >= &expbuf[ESIZE - 2])
 complex:
                        cerror("Re too complex|Regular expression too complicated");
-               c = getchar();
+               c = ex_getchar();
                if (c == eof || c == EOF) {
                        if (bracketp != bracket)
 cerror("Unmatched \\(|More \\('s than \\)'s in regular expression");
                if (c == eof || c == EOF) {
                        if (bracketp != bracket)
 cerror("Unmatched \\(|More \\('s than \\)'s in regular expression");
@@ -605,7 +604,7 @@ cerror("Unmatched \\(|More \\('s than \\)'s in regular expression");
                switch (c) {
 
                case '\\':
                switch (c) {
 
                case '\\':
-                       c = getchar();
+                       c = ex_getchar();
                        switch (c) {
 
                        case '(':
                        switch (c) {
 
                        case '(':
@@ -670,23 +669,23 @@ cerror("Illegal *|Can't * a \\n in regular expression");
                                *ep++ = CCL;
                                *ep++ = 0;
                                cclcnt = 1;
                                *ep++ = CCL;
                                *ep++ = 0;
                                cclcnt = 1;
-                               c = getchar();
+                               c = ex_getchar();
                                if (c == '^') {
                                if (c == '^') {
-                                       c = getchar();
+                                       c = ex_getchar();
                                        ep[-2] = NCCL;
                                }
                                if (c == ']')
 cerror("Bad character class|Empty character class '[]' or '[^]' cannot match");
                                while (c != ']') {
                                        if (c == '\\' && any(peekchar(), "]-^\\"))
                                        ep[-2] = NCCL;
                                }
                                if (c == ']')
 cerror("Bad character class|Empty character class '[]' or '[^]' cannot match");
                                while (c != ']') {
                                        if (c == '\\' && any(peekchar(), "]-^\\"))
-                                               c = getchar() | QUOTE;
+                                               c = ex_getchar() | QUOTE;
                                        if (c == '\n' || c == EOF)
                                                cerror("Missing ]");
                                        *ep++ = c;
                                        cclcnt++;
                                        if (ep >= &expbuf[ESIZE])
                                                goto complex;
                                        if (c == '\n' || c == EOF)
                                                cerror("Missing ]");
                                        *ep++ = c;
                                        cclcnt++;
                                        if (ep >= &expbuf[ESIZE])
                                                goto complex;
-                                       c = getchar();
+                                       c = ex_getchar();
                                }
                                lastep[1] = cclcnt;
                                continue;
                                }
                                lastep[1] = cclcnt;
                                continue;
@@ -761,6 +760,7 @@ same(a, b)
 
 char   *locs;
 
 
 char   *locs;
 
+/* VARARGS1 */
 execute(gf, addr)
        line *addr;
 {
 execute(gf, addr)
        line *addr;
 {
@@ -814,8 +814,6 @@ advance(lp, ep)
        register char *lp, *ep;
 {
        register char *curlp;
        register char *lp, *ep;
 {
        register char *curlp;
-       char *sp, *sp1;
-       int c;
 
        for (;;) switch (*ep++) {
 
 
        for (;;) switch (*ep++) {
 
index 31af3bd..315f4f1 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_set.c    7.4 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_set.c    7.5 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -36,7 +36,7 @@ set()
                cp = optname;
                do {
                        if (cp < &optname[ONMSZ - 2])
                cp = optname;
                do {
                        if (cp < &optname[ONMSZ - 2])
-                               *cp++ = getchar();
+                               *cp++ = ex_getchar();
                } while (isalnum(peekchar()));
                *cp = 0;
                cp = optname;
                } while (isalnum(peekchar()));
                *cp = 0;
                cp = optname;
@@ -55,7 +55,7 @@ set()
                if (eq(cp, "w300")) {
                        if (ospeed >= B1200) {
 dontset:
                if (eq(cp, "w300")) {
                        if (ospeed >= B1200) {
 dontset:
-                               ignore(getchar());      /* = */
+                               ignore(ex_getchar());   /* = */
                                ignore(getnum());       /* value */
                                continue;
                        }
                                ignore(getnum());       /* value */
                                continue;
                        }
@@ -92,7 +92,7 @@ printone:
                        serror("Option %s is not a toggle", op->oname);
                if (c != 0 || setend())
                        goto printone;
                        serror("Option %s is not a toggle", op->oname);
                if (c != 0 || setend())
                        goto printone;
-               if (getchar() != '=')
+               if (ex_getchar() != '=')
                        serror("Missing =@in assignment to option %s", op->oname);
                switch (op->otype) {
 
                        serror("Missing =@in assignment to option %s", op->oname);
                switch (op->otype) {
 
@@ -118,9 +118,9 @@ printone:
                                if (cp >= &optname[ONMSZ])
                                        error("String too long@in option assignment");
                                /* adb change:  allow whitepace in strings */
                                if (cp >= &optname[ONMSZ])
                                        error("String too long@in option assignment");
                                /* adb change:  allow whitepace in strings */
-                               if( (*cp = getchar()) == '\\')
+                               if( (*cp = ex_getchar()) == '\\')
                                        if( peekchar() != EOF)
                                        if( peekchar() != EOF)
-                                               *cp = getchar();
+                                               *cp = ex_getchar();
                                cp++;
                        }
                        *cp = 0;
                                cp++;
                        }
                        *cp = 0;
@@ -204,7 +204,7 @@ propts()
                        break;
                }
                propt(op);
                        break;
                }
                propt(op);
-               putchar(' ');
+               ex_putchar(' ');
        }
        noonl();
        flush();
        }
        noonl();
        flush();
@@ -220,16 +220,16 @@ propt(op)
        switch (op->otype) {
 
        case ONOFF:
        switch (op->otype) {
 
        case ONOFF:
-               printf("%s%s", op->ovalue ? "" : "no", name);
+               ex_printf("%s%s", op->ovalue ? "" : "no", name);
                break;
 
        case NUMERIC:
                break;
 
        case NUMERIC:
-               printf("%s=%d", name, op->ovalue);
+               ex_printf("%s=%d", name, op->ovalue);
                break;
 
        case STRING:
        case OTERM:
                break;
 
        case STRING:
        case OTERM:
-               printf("%s=%s", name, op->osvalue);
+               ex_printf("%s=%s", name, op->osvalue);
                break;
        }
 }
                break;
        }
 }
index 1b7b33c..d513862 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_subr.c   7.10 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_subr.c   7.11 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -74,7 +74,7 @@ comment()
        register int c;
 
        do {
        register int c;
 
        do {
-               c = getchar();
+               c = ex_getchar();
        } while (c != '\n' && c != EOF);
        if (c == EOF)
                ungetchar(c);
        } while (c != '\n' && c != EOF);
        if (c == EOF)
                ungetchar(c);
@@ -95,7 +95,6 @@ copyw(to, from, size)
        register line *from, *to;
        register int size;
 {
        register line *from, *to;
        register int size;
 {
-
        if (size > 0)
                do
                        *to++ = *from++;
        if (size > 0)
                do
                        *to++ = *from++;
@@ -199,7 +198,7 @@ getn(cp)
 
 ignnEOF()
 {
 
 ignnEOF()
 {
-       register int c = getchar();
+       register int c = ex_getchar();
 
        if (c == EOF)
                ungetchar(c);
 
        if (c == EOF)
                ungetchar(c);
@@ -251,12 +250,12 @@ killcnt(cnt)
        }
        if (!notable(cnt))
                return;
        }
        if (!notable(cnt))
                return;
-       printf("%d lines", cnt);
+       ex_printf("%d lines", cnt);
        if (value(TERSE) == 0) {
        if (value(TERSE) == 0) {
-               printf(" %c%s", Command[0] | ' ', Command + 1);
+               ex_printf(" %c%s", Command[0] | ' ', Command + 1);
                if (Command[strlen(Command) - 1] != 'e')
                if (Command[strlen(Command) - 1] != 'e')
-                       putchar('e');
-               putchar('d');
+                       ex_putchar('e');
+               ex_putchar('d');
        }
        putNFL();
 }
        }
        putNFL();
 }
@@ -342,7 +341,7 @@ mesg(str)
 
 /*VARARGS2*/
 merror(seekpt, i)
 
 /*VARARGS2*/
 merror(seekpt, i)
-#ifdef VMUNIX
+#ifndef EXSTRINGS
        char *seekpt;
 #else
 # ifdef lint
        char *seekpt;
 #else
 # ifdef lint
@@ -364,13 +363,13 @@ merror(seekpt, i)
                vclreol();
        if (SO && SE)
                putpad(SO);
                vclreol();
        if (SO && SE)
                putpad(SO);
-       printf(mesg(cp), i);
+       ex_printf(mesg(cp), i);
        if (SO && SE)
                putpad(SE);
 }
 
 merror1(seekpt)
        if (SO && SE)
                putpad(SE);
 }
 
 merror1(seekpt)
-#ifdef VMUNIX
+#ifndef EXSTRINGS
        char *seekpt;
 #else
 # ifdef lint
        char *seekpt;
 #else
 # ifdef lint
@@ -381,7 +380,7 @@ merror1(seekpt)
 #endif
 {
 
 #endif
 {
 
-#ifdef VMUNIX
+#ifndef EXSTRINGS
        strcpy(linebuf, seekpt);
 #else
        lseek(erfile, (long) seekpt, 0);
        strcpy(linebuf, seekpt);
 #else
        lseek(erfile, (long) seekpt, 0);
@@ -392,11 +391,20 @@ merror1(seekpt)
 
 morelines()
 {
 
 morelines()
 {
+#ifdef UNIX_SBRK
+       char *sbrk();
 
        if ((int) sbrk(1024 * sizeof (line)) == -1)
                return (-1);
        endcore += 1024;
        return (0);
 
        if ((int) sbrk(1024 * sizeof (line)) == -1)
                return (-1);
        endcore += 1024;
        return (0);
+#else
+       /*
+        * We can never be guaranteed that we can get more memory
+        * beyond "endcore".  So we just punt every time.
+        */
+       return -1;
+#endif
 }
 
 nonzero()
 }
 
 nonzero()
@@ -447,7 +455,7 @@ netchange(i)
        }
        if (!notable(i))
                return;
        }
        if (!notable(i))
                return;
-       printf(mesg("%d %slines@in file after %s"), i, cp, Command);
+       ex_printf(mesg("%d %slines@in file after %s"), i, cp, Command);
        putNFL();
 }
 
        putNFL();
 }
 
@@ -501,7 +509,7 @@ qcolumn(lim, gp)
                lim[1] = x;
        if (gp)
                while (*gp)
                lim[1] = x;
        if (gp)
                while (*gp)
-                       putchar(*gp++);
+                       ex_putchar(*gp++);
        Outchar = OO;
        return (vcntcol);
 }
        Outchar = OO;
        return (vcntcol);
 }
@@ -549,7 +557,11 @@ save(a1, a2)
        more = (a2 - a1 + 1) - (unddol - dol);
        while (more > (endcore - truedol))
                if (morelines() < 0)
        more = (a2 - a1 + 1) - (unddol - dol);
        while (more > (endcore - truedol))
                if (morelines() < 0)
+#ifdef UNIX_SBRK
                        error("Out of memory@saving lines for undo - try using ed");
                        error("Out of memory@saving lines for undo - try using ed");
+#else
+                       error("Out of memory@saving lines for undo - try increasing linelimit");
+#endif
        if (more)
                (*(more > 0 ? copywR : copyw))(unddol + more + 1, unddol + 1,
                    (truedol - unddol));
        if (more)
                (*(more > 0 ? copywR : copyw))(unddol + more + 1, unddol + 1,
                    (truedol - unddol));
@@ -584,7 +596,7 @@ span()
        return (addr2 - addr1 + 1);
 }
 
        return (addr2 - addr1 + 1);
 }
 
-sync()
+ex_sync()
 {
 
        chng = 0;
 {
 
        chng = 0;
@@ -647,14 +659,26 @@ strcLIN(dp)
 syserror()
 {
        register int e = errno;
 syserror()
 {
        register int e = errno;
+#ifndef        vms
        extern int sys_nerr;
        extern char *sys_errlist[];
        extern int sys_nerr;
        extern char *sys_errlist[];
+#else
+       extern noshare int sys_nerr;
+       extern noshare char *sys_errlist[];
+#endif
 
        dirtcnt = 0;
 
        dirtcnt = 0;
-       putchar(' ');
+       ex_putchar(' ');
        if (e >= 0 && e <= sys_nerr)
                error(sys_errlist[e]);
        else
        if (e >= 0 && e <= sys_nerr)
                error(sys_errlist[e]);
        else
+#ifdef vms
+               if (e == EVMSERR) {
+                       error("VMS system error %d", vaxc$errno);
+                       perror("vmserror");
+               }
+               else
+#endif
                error("System error %d", e);
 }
 
                error("System error %d", e);
 }
 
@@ -687,7 +711,7 @@ vfindcol(i)
        Outchar = qcount;
        ignore(qcolumn(linebuf - 1, NOSTR));
        for (cp = linebuf; *cp && vcntcol < i; cp++)
        Outchar = qcount;
        ignore(qcolumn(linebuf - 1, NOSTR));
        for (cp = linebuf; *cp && vcntcol < i; cp++)
-               putchar(*cp);
+               ex_putchar(*cp);
        if (cp != linebuf)
                cp--;
        Outchar = OO;
        if (cp != linebuf)
                cp--;
        Outchar = OO;
@@ -772,10 +796,7 @@ markit(addr)
 int _ovno;
 onemt()
 {
 int _ovno;
 onemt()
 {
-       int oovno;
-
        signal(SIGEMT, onemt);
        signal(SIGEMT, onemt);
-       oovno = _ovno;
        /* 2 and 3 are valid on 11/40 type vi, so */
        if (_ovno < 0 || _ovno > 3)
                _ovno = 0;
        /* 2 and 3 are valid on 11/40 type vi, so */
        if (_ovno < 0 || _ovno > 3)
                _ovno = 0;
@@ -802,15 +823,15 @@ onhup()
        signal(SIGHUP, SIG_IGN);
        if (chng == 0) {
                cleanup(1);
        signal(SIGHUP, SIG_IGN);
        if (chng == 0) {
                cleanup(1);
-               exit(0);
+               ex_exit(0);
        }
        if (setexit() == 0) {
                if (preserve()) {
                        cleanup(1);
        }
        if (setexit() == 0) {
                if (preserve()) {
                        cleanup(1);
-                       exit(0);
+                       ex_exit(0);
                }
        }
                }
        }
-       exit(1);
+       ex_exit(1);
 }
 
 /*
 }
 
 /*
@@ -871,14 +892,14 @@ preserve()
        tflush();
 #endif
        synctmp();
        tflush();
 #endif
        synctmp();
-       pid = fork();
+       pid = vfork();
        if (pid < 0)
                return (0);
        if (pid == 0) {
                close(0);
                dup(tfile);
                execl(EXPRESERVE, "expreserve", (char *) 0);
        if (pid < 0)
                return (0);
        if (pid == 0) {
                close(0);
                dup(tfile);
                execl(EXPRESERVE, "expreserve", (char *) 0);
-               exit(1);
+               ex_exit(1);
        }
        waitfor();
        if (rpid == pid && status == 0)
        }
        waitfor();
        if (rpid == pid && status == 0)
@@ -887,7 +908,7 @@ preserve()
 }
 
 #ifndef V6
 }
 
 #ifndef V6
-exit(i)
+ex_exit(i)
        int i;
 {
 
        int i;
 {
 
@@ -906,7 +927,6 @@ exit(i)
 onsusp()
 {
        ttymode f;
 onsusp()
 {
        ttymode f;
-       int omask;
        struct winsize win;
 
        f = setty(normf);
        struct winsize win;
 
        f = setty(normf);
@@ -922,14 +942,16 @@ onsusp()
 
        signal(SIGTSTP, onsusp);
        vcontin(0);
 
        signal(SIGTSTP, onsusp);
        vcontin(0);
-       setty(f);
+       ignore(setty(f));
        if (!inopen)
        if (!inopen)
-               error(0);
+               error((char *) 0);
        else {
        else {
+#ifdef TIOCGWINSZ
                if (ioctl(0, TIOCGWINSZ, &win) >= 0)
                        if (win.ws_row != winsz.ws_row ||
                            win.ws_col != winsz.ws_col)
                                winch();
                if (ioctl(0, TIOCGWINSZ, &win) >= 0)
                        if (win.ws_row != winsz.ws_row ||
                            win.ws_col != winsz.ws_col)
                                winch();
+#endif
                if (vcnt < 0) {
                        vcnt = -vcnt;
                        if (state == VISUAL)
                if (vcnt < 0) {
                        vcnt = -vcnt;
                        if (state == VISUAL)
index d47df8a..28c7ce9 100644 (file)
@@ -9,10 +9,14 @@
 
 #ifdef FASTTAG
 #ifndef lint
 
 #ifdef FASTTAG
 #ifndef lint
-static char *sccsid = "@(#)ex_tagio.c  7.3 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_tagio.c  7.4 (Berkeley) %G%";
 #endif
 
 #endif
 
+#ifndef vms
 #include <sys/file.h>
 #include <sys/file.h>
+#else
+#include <file.h>
+#endif
 #include "ex.h"
 
 static long offset = -1;
 #include "ex.h"
 
 static long offset = -1;
index 5eeb71d..e0f6870 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_temp.c   7.5.1.1 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_temp.c   7.6 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -20,6 +20,12 @@ static char *sccsid = "@(#)ex_temp.c 7.5.1.1 (Berkeley) %G%";
 #define        READ    0
 #define        WRITE   1
 
 #define        READ    0
 #define        WRITE   1
 
+#ifndef vms
+#define        EPOSITION       7
+#else
+#define        EPOSITION       13
+#endif
+
 char   tfname[40];
 char   rfname[40];
 int    havetmp;
 char   tfname[40];
 char   rfname[40];
 int    havetmp;
@@ -35,7 +41,8 @@ fileinit()
        if (tline == INCRMT * (HBLKS+2))
                return;
        cleanup(0);
        if (tline == INCRMT * (HBLKS+2))
                return;
        cleanup(0);
-       close(tfile);
+       if (tfile >= 0)
+               close(tfile);
        tline = INCRMT * (HBLKS+2);
        blocks[0] = HBLKS;
        blocks[1] = HBLKS+1;
        tline = INCRMT * (HBLKS+2);
        blocks[0] = HBLKS;
        blocks[1] = HBLKS+1;
@@ -45,24 +52,41 @@ fileinit()
        iblock2 = -1;
        oblock = -1;
        CP(tfname, svalue(DIRECTORY));
        iblock2 = -1;
        oblock = -1;
        CP(tfname, svalue(DIRECTORY));
-       if (stat(tfname, &stbuf)) {
+#ifndef vms
+       if (stat(tfname, &stbuf))
+#else
+       goto vms_no_check_dir;
+#endif
+       {
 dumbness:
                if (setexit() == 0)
                        filioerr(tfname);
                else
                        putNFL();
                cleanup(1);
 dumbness:
                if (setexit() == 0)
                        filioerr(tfname);
                else
                        putNFL();
                cleanup(1);
-               exit(1);
+               ex_exit(1);
        }
        }
+#ifndef        vms
        if ((stbuf.st_mode & S_IFMT) != S_IFDIR) {
                errno = ENOTDIR;
                goto dumbness;
        }
        if ((stbuf.st_mode & S_IFMT) != S_IFDIR) {
                errno = ENOTDIR;
                goto dumbness;
        }
+#else
+vms_no_check_dir:
+#endif
        ichanged = 0;
        ichang2 = 0;
        ichanged = 0;
        ichang2 = 0;
+#ifndef        vms
        ignore(strcat(tfname, "/ExXXXXX"));
        ignore(strcat(tfname, "/ExXXXXX"));
+#else
+       ignore(strcat(tfname, "ExXXXXX"));
+#endif
        for (p = strend(tfname), i = 5, j = getpid(); i > 0; i--, j /= 10)
                *--p = j % 10 | '0';
        for (p = strend(tfname), i = 5, j = getpid(); i > 0; i--, j /= 10)
                *--p = j % 10 | '0';
+#ifdef vms
+       ignore(strcat(tfname, ".txt.1"));
+       unlink(tfname);
+#endif
        tfile = creat(tfname, 0600);
        if (tfile < 0)
                goto dumbness;
        tfile = creat(tfname, 0600);
        if (tfile < 0)
                goto dumbness;
@@ -73,11 +97,14 @@ dumbness:
        }
 #endif
        havetmp = 1;
        }
 #endif
        havetmp = 1;
-       close(tfile);
+       if (tfile >= 0)
+               close(tfile);
        tfile = open(tfname, 2);
        if (tfile < 0)
                goto dumbness;
        tfile = open(tfname, 2);
        if (tfile < 0)
                goto dumbness;
+#ifdef UNIX_SBRK
 /*     brk((char *)fendcore); */
 /*     brk((char *)fendcore); */
+#endif
 }
 
 cleanup(all)
 }
 
 cleanup(all)
@@ -87,12 +114,16 @@ cleanup(all)
                putpad(TE);
                flush();
        }
                putpad(TE);
                flush();
        }
-       if (havetmp)
+       if (havetmp) {
+               if (tfile >= 0)
+                       close(tfile);
                unlink(tfname);
                unlink(tfname);
+       }
        havetmp = 0;
        if (all && rfile >= 0) {
        havetmp = 0;
        if (all && rfile >= 0) {
+               if (rfile >= 0)
+                       close(rfile);
                unlink(rfname);
                unlink(rfname);
-               close(rfile);
                rfile = -1;
        }
 }
                rfile = -1;
        }
 }
@@ -152,8 +183,10 @@ getblock(atl, iof)
        int iof;
 {
        register int bno, off;
        int iof;
 {
        register int bno, off;
+#ifdef CRYPT
         register char *p1, *p2;
         register int n;
         register char *p1, *p2;
         register int n;
+#endif
        
        bno = (atl >> OFFBTS) & BLKMSK;
        off = (atl << SHFT) & LBTMSK;
        
        bno = (atl >> OFFBTS) & BLKMSK;
        off = (atl << SHFT) & LBTMSK;
@@ -200,7 +233,11 @@ getblock(atl, iof)
 }
 
 #ifdef VMUNIX
 }
 
 #ifdef VMUNIX
+#ifdef vms
+#define        INCORB  32
+#else
 #define        INCORB  64
 #define        INCORB  64
+#endif
 char   incorb[INCORB+1][BUFSIZ];
 #define        pagrnd(a)       ((char *)(((int)a)&~(BUFSIZ-1)))
 int    stilinc;        /* up to here not written yet */
 char   incorb[INCORB+1][BUFSIZ];
 #define        pagrnd(a)       ((char *)(((int)a)&~(BUFSIZ-1)))
 int    stilinc;        /* up to here not written yet */
@@ -310,8 +347,10 @@ oops:
         * but can result in pregnant pauses between commands
         * when the TSYNC call is made, so...
         */
         * but can result in pregnant pauses between commands
         * when the TSYNC call is made, so...
         */
+#ifndef vms
        (void) fsync(tfile);
 #endif
        (void) fsync(tfile);
 #endif
+#endif
 }
 
 TSYNC()
 }
 
 TSYNC()
@@ -372,12 +411,13 @@ regio(b, iofcn)
 
        if (rfile == -1) {
                CP(rfname, tfname);
 
        if (rfile == -1) {
                CP(rfname, tfname);
-               *(strend(rfname) - 7) = 'R';
+               *(strend(rfname) - EPOSITION) = 'R';
                rfile = creat(rfname, 0600);
                if (rfile < 0)
 oops:
                        filioerr(rfname);
                rfile = creat(rfname, 0600);
                if (rfile < 0)
 oops:
                        filioerr(rfname);
-               close(rfile);
+               else
+                       close(rfile);
                rfile = open(rfname, 2);
                if (rfile < 0)
                        goto oops;
                rfile = open(rfname, 2);
                if (rfile < 0)
                        goto oops;
@@ -402,7 +442,7 @@ REGblk()
                                j++, m >>= 1;
                        rused[i] |= (1 << j);
 #ifdef RDEBUG
                                j++, m >>= 1;
                        rused[i] |= (1 << j);
 #ifdef RDEBUG
-                       printf("allocating block %d\n", i * 16 + j);
+                       ex_printf("allocating block %d\n", i * 16 + j);
 #endif
                        return (i * 16 + j);
                }
 #endif
                        return (i * 16 + j);
                }
@@ -435,7 +475,7 @@ KILLreg(c)
        sp->rg_flags = sp->rg_nleft = 0;
        while (rblock != 0) {
 #ifdef RDEBUG
        sp->rg_flags = sp->rg_nleft = 0;
        while (rblock != 0) {
 #ifdef RDEBUG
-               printf("freeing block %d\n", rblock);
+               ex_printf("freeing block %d\n", rblock);
 #endif
                rused[rblock / 16] &= ~(1 << (rblock % 16));
                regio(rblock, shread);
 #endif
                rused[rblock / 16] &= ~(1 << (rblock % 16));
                regio(rblock, shread);
index 8e09d25..19da7b1 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_tty.c    7.10 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_tty.c    7.11 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -32,7 +32,7 @@ gettmode()
        GT = (tty.sg_flags & XTABS) != XTABS && !XT;
        NONL = (tty.sg_flags & CRMOD) == 0;
 #else
        GT = (tty.sg_flags & XTABS) != XTABS && !XT;
        NONL = (tty.sg_flags & CRMOD) == 0;
 #else
-       if (ioctl(1, TCGETA, &tty) < 0)
+       if (ioctl(1, TCGETA, (char *) &tty) < 0)
                return;
        if (ospeed != (tty.c_cflag & CBAUD))    /* mjm */
                value(SLOWOPEN) = (tty.c_cflag & CBAUD) < B1200;
                return;
        if (ospeed != (tty.c_cflag & CBAUD))    /* mjm */
                value(SLOWOPEN) = (tty.c_cflag & CBAUD) < B1200;
@@ -106,9 +106,9 @@ setterm(type)
         */
        {
                static char sc[2];
         */
        {
                static char sc[2];
-               int i, fnd;
+               int i;
 
 
-               ioctl(0, TIOCGETD, &ldisc);
+               ioctl(0, TIOCGETD, (char *) &ldisc);
                if (ldisc == NTTYDISC) {
                        sc[0] = olttyc.t_suspc;
                        sc[1] = 0;
                if (ldisc == NTTYDISC) {
                        sc[0] = olttyc.t_suspc;
                        sc[1] = 0;
@@ -116,7 +116,8 @@ setterm(type)
                                for (i=0; i<=4; i++)
                                        if (arrows[i].cap &&
                                            arrows[i].cap[0] == CTRL(z))
                                for (i=0; i<=4; i++)
                                        if (arrows[i].cap &&
                                            arrows[i].cap[0] == CTRL(z))
-                                               addmac(sc, NULL, NULL, arrows);
+                                               addmac(sc, (char *) NULL,
+                                                       (char *) NULL, arrows);
                        } else
                                addmac(sc, "\32", "susp", arrows);
                }
                        } else
                                addmac(sc, "\32", "susp", arrows);
                }
@@ -149,11 +150,14 @@ setterm(type)
 setsize()
 {
        register int l, i;
 setsize()
 {
        register int l, i;
+#ifdef TIOCGWINSZ
        struct winsize win;
 
        struct winsize win;
 
-       if (ioctl(0, TIOCGWINSZ, &win) < 0) {
+       if (ioctl(0, TIOCGWINSZ, (char *) &win) < 0) {
+#endif
                i = LINES = tgetnum("li");
                COLUMNS = tgetnum("co");
                i = LINES = tgetnum("li");
                COLUMNS = tgetnum("co");
+#ifdef TIOCGWINSZ
        } else {
                if ((LINES = winsz.ws_row = win.ws_row) == 0)
                        LINES = tgetnum("li");
        } else {
                if ((LINES = winsz.ws_row = win.ws_row) == 0)
                        LINES = tgetnum("li");
@@ -161,6 +165,7 @@ setsize()
                if ((COLUMNS = winsz.ws_col = win.ws_col) == 0)
                        COLUMNS = tgetnum("co");
        }
                if ((COLUMNS = winsz.ws_col = win.ws_col) == 0)
                        COLUMNS = tgetnum("co");
        }
+#endif
        if (LINES <= 5)
                LINES = 24;
        if (LINES > TUBELINES)
        if (LINES <= 5)
                LINES = 24;
        if (LINES > TUBELINES)
index 7f3cdeb..5edcec2 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)ex_tty.h    7.6 (Berkeley) %G%
+ *     @(#)ex_tty.h    7.7 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -116,7 +116,9 @@ var bool    UPPERCASE;      /* Ick! */
 extern short   LINES;          /* Number of lines on screen */
 extern short   COLUMNS;
 var    short   OCOLUMNS;       /* Save COLUMNS for a hack in open mode */
 extern short   LINES;          /* Number of lines on screen */
 extern short   COLUMNS;
 var    short   OCOLUMNS;       /* Save COLUMNS for a hack in open mode */
+#ifdef TIOCGWINSZ
 var    struct winsize winsz;   /* Save window size for stopping comparisons */
 var    struct winsize winsz;   /* Save window size for stopping comparisons */
+#endif
 
 var    short   outcol;         /* Where the cursor is */
 var    short   outline;
 
 var    short   outcol;         /* Where the cursor is */
 var    short   outline;
@@ -136,7 +138,7 @@ var short   destline;
  *
  * The following attempts to decide what we are on, and declare
  * some variables in the appropriate format.  The wierd looking one (ttymode)
  *
  * The following attempts to decide what we are on, and declare
  * some variables in the appropriate format.  The wierd looking one (ttymode)
- * is the thing we pass to sTTY and family to turn "RAW" mode on or off
+ * is the thing we pass to ex_sTTY and family to turn "RAW" mode on or off
  * when we go into or out of visual mode.  In V7/V6 it's just the flags word
  * to stty.  In USG V3 it's the whole tty structure.
  */
  * when we go into or out of visual mode.  In V7/V6 it's just the flags word
  * to stty.  In USG V3 it's the whole tty structure.
  */
index caaa0e5..d52937b 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)ex_tune.h   7.10 (Berkeley) %G%
+ *     @(#)ex_tune.h   7.11 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
 #define loclibpath(file) "/usr/local/lib/file"
 #define binpath(file) "/usr/ucb/file"
 #define usrpath(file) "/usr/file"
 #define loclibpath(file) "/usr/local/lib/file"
 #define binpath(file) "/usr/ucb/file"
 #define usrpath(file) "/usr/file"
+#ifndef        vms
 #define E_TERMCAP      "/etc/termcap"
 #define E_TERMCAP      "/etc/termcap"
+#else
+#define E_TERMCAP      "etc:termcap."
+#endif
 #define B_CSH          "/bin/csh"
 #define        EXRECOVER       libpath(ex3.7recover)
 #define        EXPRESERVE      libpath(ex3.7preserve)
 #ifndef VMUNIX
 #define B_CSH          "/bin/csh"
 #define        EXRECOVER       libpath(ex3.7recover)
 #define        EXPRESERVE      libpath(ex3.7preserve)
 #ifndef VMUNIX
+#ifndef        vms
 #define        EXSTRINGS       libpath(ex3.7strings)
 #endif
 #define        EXSTRINGS       libpath(ex3.7strings)
 #endif
+#endif
 
 /*
  * If your system believes that tabs expand to a width other than
 
 /*
  * If your system believes that tabs expand to a width other than
 #define ESIZE          512
 #define CRSIZE         4096
 #else
 #define ESIZE          512
 #define CRSIZE         4096
 #else
+#ifdef vms
+#define LBSIZE         1024
+#define        ESIZE           512
+#define        CRSIZE          1024
+#else
 #define        LBSIZE          512             /* Line length */
 #define        ESIZE           128             /* Size of compiled re */
 #define CRSIZE         512
 #endif
 #endif
 #define        LBSIZE          512             /* Line length */
 #define        ESIZE           128             /* Size of compiled re */
 #define CRSIZE         512
 #endif
 #endif
+#endif
 #define        RHSSIZE         256             /* Size of rhs of substitute */
 #define        NBRA            9               /* Number of re \( \) pairs */
 #define        TAGSIZE         128             /* Tag length */
 #define        RHSSIZE         256             /* Size of rhs of substitute */
 #define        NBRA            9               /* Number of re \( \) pairs */
 #define        TAGSIZE         128             /* Tag length */
@@ -87,7 +99,9 @@
  * of the incore line information and could then
  * be reasonably large.
  */
  * of the incore line information and could then
  * be reasonably large.
  */
+#ifndef        vms
 #undef NCARGS
 #undef NCARGS
+#endif
 #ifndef VMUNIX
 #define        NARGS   100             /* Maximum number of names in "next" */
 #define        NCARGS  LBSIZE          /* Maximum arglist chars in "next" */
 #ifndef VMUNIX
 #define        NARGS   100             /* Maximum number of names in "next" */
 #define        NCARGS  LBSIZE          /* Maximum arglist chars in "next" */
index bc1b693..a60c6ed 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_unix.c   7.6 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_unix.c   7.7 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -30,7 +30,7 @@ unix0(warn)
 
        printub = 0;
        CP(puxb, uxb);
 
        printub = 0;
        CP(puxb, uxb);
-       c = getchar();
+       c = ex_getchar();
        if (c == '\n' || c == EOF)
                error("Incomplete shell escape command@- use 'shell' to get a shell");
        up = uxb;
        if (c == '\n' || c == EOF)
                error("Incomplete shell escape command@- use 'shell' to get a shell");
        up = uxb;
@@ -39,7 +39,7 @@ unix0(warn)
 
                case '\\':
                        if (any(peekchar(), "%#!"))
 
                case '\\':
                        if (any(peekchar(), "%#!"))
-                               c = getchar();
+                               c = ex_getchar();
                default:
                        if (up >= &uxb[UXBSIZE]) {
 tunix:
                default:
                        if (up >= &uxb[UXBSIZE]) {
 tunix:
@@ -86,7 +86,7 @@ uexp:
                        }
                        break;
                }
                        }
                        break;
                }
-               c = getchar();
+               c = ex_getchar();
        } while (c == '"' || c == '|' || !endcmd(c));
        if (c == EOF)
                ungetchar(c);
        } while (c == '"' || c == '|' || !endcmd(c));
        if (c == EOF)
                ungetchar(c);
@@ -98,7 +98,7 @@ uexp:
        if (warn && hush == 0 && chng && xchng != chng && value(WARN) && dol > zero) {
                xchng = chng;
                vnfl();
        if (warn && hush == 0 && chng && xchng != chng && value(WARN) && dol > zero) {
                xchng = chng;
                vnfl();
-               printf(mesg("[No write]|[No write since last change]"));
+               ex_printf(mesg("[No write]|[No write since last change]"));
                noonl();
                flush();
        } else
                noonl();
                flush();
        } else
@@ -148,7 +148,7 @@ unixex(opt, up, newstdin, mode)
        if ((mode & 1) && pipe(pvec) < 0) {
                /* Newstdin should be io so it will be closed */
                if (inopen)
        if ((mode & 1) && pipe(pvec) < 0) {
                /* Newstdin should be io so it will be closed */
                if (inopen)
-                       setty(f);
+                       ignore(setty(f));
                error("Can't make pipe for filter");
        }
 #ifndef VFORK
                error("Can't make pipe for filter");
        }
 #ifndef VFORK
@@ -184,7 +184,7 @@ unixex(opt, up, newstdin, mode)
                        close(io);
                if (tfile)
                        close(tfile);
                        close(io);
                if (tfile)
                        close(tfile);
-#ifndef VMUNIX
+#ifdef EXSTRINGS
                close(erfile);
 #endif
                signal(SIGHUP, oldhup);
                close(erfile);
 #endif
                signal(SIGHUP, oldhup);
@@ -192,7 +192,7 @@ unixex(opt, up, newstdin, mode)
                if (ruptible)
                        signal(SIGINT, SIG_DFL);
                execl(svalue(SHELL), "sh", opt, up, (char *) 0);
                if (ruptible)
                        signal(SIGINT, SIG_DFL);
                execl(svalue(SHELL), "sh", opt, up, (char *) 0);
-               printf("No %s!\n", svalue(SHELL));
+               ex_printf("No %s!\n", svalue(SHELL));
                error(NOSTR);
        }
        if (mode & 1) {
                error(NOSTR);
        }
        if (mode & 1) {
@@ -220,10 +220,10 @@ unixwt(c, f)
                signal(SIGTSTP, onsusp);
 #endif
        if (inopen)
                signal(SIGTSTP, onsusp);
 #endif
        if (inopen)
-               setty(f);
+               ignore(setty(f));
        setrupt();
        if (!inopen && c && hush == 0) {
        setrupt();
        if (!inopen && c && hush == 0) {
-               printf("!\n");
+               ex_printf("!\n");
                flush();
                termreset();
                gettmode();
                flush();
                termreset();
                gettmode();
@@ -261,7 +261,7 @@ filter(mode)
                        io = pvec[1];
                        close(pvec[0]);
                        putfile(1);
                        io = pvec[1];
                        close(pvec[0]);
                        putfile(1);
-                       exit(0);
+                       ex_exit(0);
                }
                close(pvec[1]);
                io = pvec[0];
                }
                close(pvec[1]);
                io = pvec[0];
@@ -269,7 +269,7 @@ filter(mode)
        }
        f = unixex("-c", uxb, (mode & 2) ? pvec[0] : 0, mode);
        if (mode == 3) {
        }
        f = unixex("-c", uxb, (mode & 2) ? pvec[0] : 0, mode);
        if (mode == 3) {
-               delete(0);
+               ex_delete(0);
                addr2 = addr1 - 1;
        }
        if (mode & 1) {
                addr2 = addr1 - 1;
        }
        if (mode & 1) {
index a1cfc48..175fe88 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_v.c      7.8 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_v.c      7.9 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -71,18 +71,19 @@ oop()
        char atube[TUBESIZE + LBSIZE];
 #endif
        ttymode f;      /* mjm: was register */
        char atube[TUBESIZE + LBSIZE];
 #endif
        ttymode f;      /* mjm: was register */
-       int resize;
 
 
-       if (resize = setjmp(venv)) {
+       if (setjmp(venv)) {
                setsize();
                initev = (char *)0;
                inopen = 0;
                addr1 = addr2 = dot;
        }
                setsize();
                initev = (char *)0;
                inopen = 0;
                addr1 = addr2 = dot;
        }
+#ifdef SIGWINCH
        (void)signal(SIGWINCH, winch);
        (void)signal(SIGWINCH, winch);
+#endif
        ovbeg();
        if (peekchar() == '/') {
        ovbeg();
        if (peekchar() == '/') {
-               ignore(compile(getchar(), 1));
+               ignore(compile(ex_getchar(), 1));
                savere(scanre);
                if (execute(0, dot) == 0)
                        error("Fail|Pattern not found on addressed line");
                savere(scanre);
                if (execute(0, dot) == 0)
                        error("Fail|Pattern not found on addressed line");
@@ -136,7 +137,9 @@ oop()
                vclean();
        Command = "open";
        ovend(f);
                vclean();
        Command = "open";
        ovend(f);
+#ifdef SIGWINCH
        (void)signal(SIGWINCH, SIG_DFL);
        (void)signal(SIGWINCH, SIG_DFL);
+#endif
 }
 
 ovbeg()
 }
 
 ovbeg()
@@ -182,7 +185,6 @@ vop()
        char atube[TUBESIZE + LBSIZE];
 #endif
        ttymode f;      /* mjm: was register */
        char atube[TUBESIZE + LBSIZE];
 #endif
        ttymode f;      /* mjm: was register */
-       int resize;
 
        if (!CA && UP == NOSTR) {
                if (initev) {
 
        if (!CA && UP == NOSTR) {
                if (initev) {
@@ -209,18 +211,20 @@ toopen:
                        goto toopen;
                error("Visual requires scrolling");
        }
                        goto toopen;
                error("Visual requires scrolling");
        }
-       if (resize = setjmp(venv)) {
+       if (setjmp(venv)) {
                setsize();
                initev = (char *)0;
                inopen = 0;
                addr1 = addr2 = dot;
        }
                setsize();
                initev = (char *)0;
                inopen = 0;
                addr1 = addr2 = dot;
        }
+#ifdef SIGWINCH
        (void)signal(SIGWINCH, winch);
        (void)signal(SIGWINCH, winch);
+#endif
        ovbeg();
        bastate = VISUAL;
        c = 0;
        if (any(peekchar(), "+-^."))
        ovbeg();
        bastate = VISUAL;
        c = 0;
        if (any(peekchar(), "+-^."))
-               c = getchar();
+               c = ex_getchar();
        pastwh();
        vsetsiz(isdigit(peekchar()) ? getnum() : value(WINDOW));
        setwind();
        pastwh();
        vsetsiz(isdigit(peekchar()) ? getnum() : value(WINDOW));
        setwind();
@@ -238,7 +242,9 @@ toopen:
        vmain();
        Command = "visual";
        ovend(f);
        vmain();
        Command = "visual";
        ovend(f);
+#ifdef SIGWINCH
        (void)signal(SIGWINCH, SIG_DFL);
        (void)signal(SIGWINCH, SIG_DFL);
+#endif
 }
 
 /*
 }
 
 /*
@@ -254,7 +260,7 @@ fixzero()
 
                vdoappend("");
                if (!ochng)
 
                vdoappend("");
                if (!ochng)
-                       sync();
+                       ex_sync();
                addr1 = addr2 = one;
        } else if (addr2 == zero)
                addr2 = one;
                addr1 = addr2 = one;
        } else if (addr2 == zero)
                addr2 = one;
@@ -321,7 +327,7 @@ setwind()
 
        case HARDOPEN:
                basWTOP = WTOP = WBOT = WECHO = 0;
 
        case HARDOPEN:
                basWTOP = WTOP = WBOT = WECHO = 0;
-               ZERO = 0;
+               ex_ZERO = 0;
                holdcm++;
                break;
 
                holdcm++;
                break;
 
@@ -330,10 +336,10 @@ setwind()
                /* fall into */
 
        case VISUAL:
                /* fall into */
 
        case VISUAL:
-               ZERO = LINES - TUBESIZE / WCOLS;
-               if (ZERO < 0)
-                       ZERO = 0;
-               if (ZERO > basWTOP)
+               ex_ZERO = LINES - TUBESIZE / WCOLS;
+               if (ex_ZERO < 0)
+                       ex_ZERO = 0;
+               if (ex_ZERO > basWTOP)
                        error("Screen too large for internal buffer");
                WTOP = basWTOP; WBOT = LINES - 2; WECHO = LINES - 1;
                break;
                        error("Screen too large for internal buffer");
                WTOP = basWTOP; WBOT = LINES - 2; WECHO = LINES - 1;
                break;
@@ -356,12 +362,12 @@ vok(atube)
                serror("Don't know enough about your terminal to use %s", Command);
        if (WCOLS > TUBECOLS)
                error("Terminal too wide");
                serror("Don't know enough about your terminal to use %s", Command);
        if (WCOLS > TUBECOLS)
                error("Terminal too wide");
-       if (WLINES >= TUBELINES || WCOLS * (WECHO - ZERO + 1) > TUBESIZE)
+       if (WLINES >= TUBELINES || WCOLS * (WECHO - ex_ZERO + 1) > TUBESIZE)
                error("Screen too large");
 
        vtube0 = atube;
                error("Screen too large");
 
        vtube0 = atube;
-       vclrbyte(atube, WCOLS * (WECHO - ZERO + 1));
-       for (i = 0; i < ZERO; i++)
+       vclrbyte(atube, WCOLS * (WECHO - ex_ZERO + 1));
+       for (i = 0; i < ex_ZERO; i++)
                vtube[i] = (char *) 0;
        for (; i <= WECHO; i++)
                vtube[i] = atube, atube += WCOLS;
                vtube[i] = (char *) 0;
        for (; i <= WECHO; i++)
                vtube[i] = atube, atube += WCOLS;
@@ -379,10 +385,10 @@ vok(atube)
        splitw = 0;
        doomed = 0;
        holdupd = 0;
        splitw = 0;
        doomed = 0;
        holdupd = 0;
-       Peekkey = 0;
+       Peek_key = 0;
        vcnt = vcline = 0;
        vcnt = vcline = 0;
-       if (vSCROLL == 0)
-               vSCROLL = (value(WINDOW)+1)/2;  /* round up so dft=6,11 */
+       if (ex_vSCROLL == 0)
+               ex_vSCROLL = (value(WINDOW)+1)/2; /* round up so dft=6,11 */
 }
 
 #ifdef CBREAK
 }
 
 #ifdef CBREAK
@@ -423,9 +429,11 @@ vsetsiz(size)
        basWLINES = WBOT - b + 1;
 }
 
        basWLINES = WBOT - b + 1;
 }
 
+#ifdef SIGWINCH
 winch()
 {
        vsave();
 winch()
 {
        vsave();
-       setty(normf);
+       ignore(setty(normf));
        longjmp(venv, 1);
 }
        longjmp(venv, 1);
 }
+#endif
index 66736f6..03e8c54 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_vadj.c   7.9 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_vadj.c   7.10 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -72,12 +72,12 @@ vopen(tp, p)
         * If we are opening at the top of the window, can try a window
         * expansion at the top.
         */
         * If we are opening at the top of the window, can try a window
         * expansion at the top.
         */
-       if (state == VISUAL && vcline == 0 && vcnt > 1 && p > ZERO) {
+       if (state == VISUAL && vcline == 0 && vcnt > 1 && p > ex_ZERO) {
                cnt = p + vdepth() - LINE(1);
                if (cnt > 0) {
                        p -= cnt;
                cnt = p + vdepth() - LINE(1);
                if (cnt > 0) {
                        p -= cnt;
-                       if (p < ZERO)
-                               p = ZERO;
+                       if (p < ex_ZERO)
+                               p = ex_ZERO;
                        WTOP = p;
                        WLINES = WBOT - WTOP + 1;
                }
                        WTOP = p;
                        WLINES = WBOT - WTOP + 1;
                }
@@ -128,8 +128,8 @@ vreopen(p, lineno, l)
         */
        if (hold & HOLDDOL)
                return (d);
         */
        if (hold & HOLDDOL)
                return (d);
-       if (Putchar == listchar)
-               putchar('$');
+       if (Put_char == listchar)
+               ex_putchar('$');
 
        /*
         * Optimization of cursor motion may prevent screen rollup if the
 
        /*
         * Optimization of cursor motion may prevent screen rollup if the
@@ -190,7 +190,7 @@ vglitchup(l, o)
        if (l < vcnt - 1) {
                need = p + vp->vdepth - (vp+1)->vliny;
                if (need > 0) {
        if (l < vcnt - 1) {
                need = p + vp->vdepth - (vp+1)->vliny;
                if (need > 0) {
-                       if (state == VISUAL && WTOP - ZERO >= need && AL && DL) {
+                       if (state == VISUAL && WTOP - ex_ZERO >= need && AL && DL) {
                                glitched++;
                                WTOP -= need;
                                WLINES = WBOT - WTOP + 1;
                                glitched++;
                                WTOP -= need;
                                WLINES = WBOT - WTOP + 1;
@@ -247,7 +247,7 @@ vinslin(p, cnt, l)
                for (i = cnt; i > 0; i--) {
                        vgoto(p, 0), vputp(SR, 0);
                        if (i > 1 && (hold & HOLDAT) == 0)
                for (i = cnt; i > 0; i--) {
                        vgoto(p, 0), vputp(SR, 0);
                        if (i > 1 && (hold & HOLDAT) == 0)
-                               putchar('@');
+                               ex_putchar('@');
                        /*
                         * If we are at the top of the screen, and the
                         * terminal retains display above, then we
                        /*
                         * If we are at the top of the screen, and the
                         * terminal retains display above, then we
@@ -284,7 +284,7 @@ vinslin(p, cnt, l)
                                vgoto(outline+1, 0);
                                vputp(AL, WECHO + 1 - outline);
                                if ((hold & HOLDAT) == 0)
                                vgoto(outline+1, 0);
                                vputp(AL, WECHO + 1 - outline);
                                if ((hold & HOLDAT) == 0)
-                                       putchar('@');
+                                       ex_putchar('@');
                        }
                }
                vadjAL(p, cnt);
                        }
                }
                vadjAL(p, cnt);
@@ -450,9 +450,9 @@ vscroll(cnt)
        if (cnt == 0)
                return;
        copy(tlines, vtube, sizeof vtube);
        if (cnt == 0)
                return;
        copy(tlines, vtube, sizeof vtube);
-       for (to = ZERO, from = ZERO + cnt; to <= WECHO - cnt; to++, from++)
+       for (to = ex_ZERO, from = ex_ZERO + cnt; to <= WECHO - cnt; to++, from++)
                vtube[to] = tlines[from];
                vtube[to] = tlines[from];
-       for (from = ZERO; to <= WECHO; to++, from++) {
+       for (from = ex_ZERO; to <= WECHO; to++, from++) {
                vtube[to] = tlines[from];
                vclrbyte(vtube[to], WCOLS);
        }
                vtube[to] = tlines[from];
                vclrbyte(vtube[to], WCOLS);
        }
@@ -473,7 +473,7 @@ vscrap()
 #endif
        if (splitw)
                return;
 #endif
        if (splitw)
                return;
-       if (vcnt && WBOT != WECHO && LINE(0) < WTOP && LINE(0) >= ZERO) {
+       if (vcnt && WBOT != WECHO && LINE(0) < WTOP && LINE(0) >= ex_ZERO) {
                WTOP = LINE(0);
                WLINES = WBOT - WTOP + 1;
        }
                WTOP = LINE(0);
                WLINES = WBOT - WTOP + 1;
        }
@@ -521,7 +521,7 @@ vrepaint(curs)
        /*
         * In open want to notify first.
         */
        /*
         * In open want to notify first.
         */
-       noteit(0);
+       ignore(noteit(0));
        vscrap();
 
        /*
        vscrap();
 
        /*
@@ -540,7 +540,7 @@ vrepaint(curs)
                if (odol == zero)
                        fixzero();
                vcontext(dot, '.');
                if (odol == zero)
                        fixzero();
                vcontext(dot, '.');
-               noteit(1);
+               ignore(noteit(1));
                if (noteit(1) == 0 && odol == zero) {
                        CATCH
                                error("No lines in buffer");
                if (noteit(1) == 0 && odol == zero) {
                        CATCH
                                error("No lines in buffer");
@@ -590,7 +590,7 @@ vrepaint(curs)
         * has to be done last or we may lose
         * the echo area with redisplay.
         */
         * has to be done last or we may lose
         * the echo area with redisplay.
         */
-       noteit(1);
+       ignore(noteit(1));
 
        /*
         * Finally.  Move the cursor onto the current line.
 
        /*
         * Finally.  Move the cursor onto the current line.
@@ -645,7 +645,7 @@ vredraw(p)
         */
        heldech = 0;
        hold |= HOLDECH;
         */
        heldech = 0;
        hold |= HOLDECH;
-       for (; l < vcnt && Peekkey != ATTN; l++) {
+       for (; l < vcnt && Peek_key != ATTN; l++) {
                if (l == vcline)
                        strcLIN(temp);
                else
                if (l == vcline)
                        strcLIN(temp);
                else
@@ -677,7 +677,7 @@ vredraw(p)
                                break;
                        }
                        FLAGS(l) &= ~VDIRT;
                                break;
                        }
                        FLAGS(l) &= ~VDIRT;
-                       vreopen(p, lineno(tp), l);
+                       ignore(vreopen(p, lineno(tp), l));
                        p = LINE(l) + DEPTH(l);
                } else
                        p += DEPTH(l);
                        p = LINE(l) + DEPTH(l);
                } else
                        p += DEPTH(l);
@@ -692,7 +692,7 @@ vredraw(p)
                int ovcline = vcline;
 
                vcline = l;
                int ovcline = vcline;
 
                vcline = l;
-               for (; tp <= dol && Peekkey != ATTN; tp++) {
+               for (; tp <= dol && Peek_key != ATTN; tp++) {
                        getline(*tp);
                        if (p + vdepth() - 1 > WBOT)
                                break;
                        getline(*tp);
                        if (p + vdepth() - 1 > WBOT)
                                break;
@@ -708,7 +708,7 @@ vredraw(p)
         * Now rest of lines (if any) get either a ~ if they
         * are past end of file, or an @ if the next line won't fit.
         */
         * Now rest of lines (if any) get either a ~ if they
         * are past end of file, or an @ if the next line won't fit.
         */
-       for (; p <= WBOT && Peekkey != ATTN; p++)                       
+       for (; p <= WBOT && Peek_key != ATTN; p++)                      
                vclrlin(p, tp);
        strcLIN(temp);
        hold = oldhold;
                vclrlin(p, tp);
        strcLIN(temp);
        hold = oldhold;
@@ -847,7 +847,7 @@ vsync1(p)
                l++, vp++;
        heldech = 0;
        hold |= HOLDECH;
                l++, vp++;
        heldech = 0;
        hold |= HOLDECH;
-       while (p <= WBOT && Peekkey != ATTN) {
+       while (p <= WBOT && Peek_key != ATTN) {
                /*
                 * Want to put a line here if not in visual and first line
                 * or if there are lies left and this line starts before
                /*
                 * Want to put a line here if not in visual and first line
                 * or if there are lies left and this line starts before
@@ -871,7 +871,7 @@ vsync1(p)
                                        if (p + vp->vdepth - 1 > WBOT)
                                                break;
                                }
                                        if (p + vp->vdepth - 1 > WBOT)
                                                break;
                                }
-                               vreopen(p, lineDOT() + (l - vcline), l);
+                               ignore(vreopen(p, lineDOT() + (l - vcline), l));
                        }
                        p = vp->vliny + vp->vdepth;
                        vp++;
                        }
                        p = vp->vliny + vp->vdepth;
                        vp++;
@@ -1068,7 +1068,7 @@ sethard()
        vup1();
        LINE(0) = WBOT;
        if (Pline == numbline)
        vup1();
        LINE(0) = WBOT;
        if (Pline == numbline)
-               vgoto(WBOT, 0), printf("%6d  ", lineDOT());
+               vgoto(WBOT, 0), ex_printf("%6d  ", lineDOT());
 }
 
 /*
 }
 
 /*
index d3026a1..b6598c2 100644 (file)
@@ -1,11 +1,4 @@
-/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- *
- *     @(#)ex_vars.h   7.5 (Berkeley) %G%
- */
-
+       /*  sccs id   @(#)  ex_vars.h  @(#)makeoptions  6.4 5/31/85  */
 #define AUTOINDENT      0
 #define AUTOPRINT       1
 #define AUTOWRITE       2
 #define AUTOINDENT      0
 #define AUTOPRINT       1
 #define AUTOWRITE       2
index 3e6cac3..cfe1e95 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)ex_vget.c  6.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)ex_vget.c  6.9 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -26,8 +26,8 @@ ungetkey(c)
        int c;          /* mjm: char --> int */
 {
 
        int c;          /* mjm: char --> int */
 {
 
-       if (Peekkey != ATTN)
-               Peekkey = c;
+       if (Peek_key != ATTN)
+               Peek_key = c;
 }
 
 /*
 }
 
 /*
@@ -51,8 +51,8 @@ getkey()
 peekbr()
 {
 
 peekbr()
 {
 
-       Peekkey = getbr();
-       return (Peekkey == 0);
+       Peek_key = getbr();
+       return (Peek_key == 0);
 }
 
 short  precbksl;
 }
 
 short  precbksl;
@@ -74,7 +74,6 @@ getbr()
        char ch;
        register int c, d;
        register char *colp;
        char ch;
        register int c, d;
        register char *colp;
-       int cnt;
 #define BEEHIVE
 #ifdef BEEHIVE
        static char Peek2key;
 #define BEEHIVE
 #ifdef BEEHIVE
        static char Peek2key;
@@ -82,9 +81,9 @@ getbr()
        extern short slevel, ttyindes;
 
 getATTN:
        extern short slevel, ttyindes;
 
 getATTN:
-       if (Peekkey) {
-               c = Peekkey;
-               Peekkey = 0;
+       if (Peek_key) {
+               c = Peek_key;
+               Peek_key = 0;
                return (c);
        }
 #ifdef BEEHIVE
                return (c);
        }
 #ifdef BEEHIVE
@@ -115,7 +114,11 @@ again:
        if (setjmp(readbuf))
                goto getATTN;
        doingread = 1;
        if (setjmp(readbuf))
                goto getATTN;
        doingread = 1;
+#ifndef        vms
        c = read(slevel == 0 ? 0 : ttyindes, &ch, 1);
        c = read(slevel == 0 ? 0 : ttyindes, &ch, 1);
+#else
+       c = vms_read(slevel == 0 ? 0 : ttyindes, &ch, 1);
+#endif
        doingread = 0;
        if (c != 1) {
                if (errno == EINTR)
        doingread = 0;
        if (c != 1) {
                if (errno == EINTR)
@@ -172,14 +175,14 @@ again:
                        }
                        if (precbksl == 2) {
                                if (!d) {
                        }
                        if (precbksl == 2) {
                                if (!d) {
-                                       Peekkey = c;
+                                       Peek_key = c;
                                        precbksl = 0;
                                        c = '\\';
                                }
                        } else if (d)
                                c = d;
                        else {
                                        precbksl = 0;
                                        c = '\\';
                                }
                        } else if (d)
                                c = d;
                        else {
-                               Peekkey = c;
+                               Peek_key = c;
                                precbksl = 0;
                                c = '\\';
                        }
                                precbksl = 0;
                                c = '\\';
                        }
@@ -235,8 +238,8 @@ getesc()
 peekkey()
 {
 
 peekkey()
 {
 
-       Peekkey = getkey();
-       return (Peekkey);
+       Peek_key = getkey();
+       return (Peek_key);
 }
 
 /*
 }
 
 /*
@@ -257,7 +260,7 @@ readecho(c)
                vclrech(0);
        splitw++;
        vgoto(WECHO, 0);
                vclrech(0);
        splitw++;
        vgoto(WECHO, 0);
-       putchar(c);
+       ex_putchar(c);
        vclreol();
        vgoto(WECHO, 1);
        cursor = linebuf; linebuf[0] = 0; genbuf[0] = c;
        vclreol();
        vgoto(WECHO, 1);
        cursor = linebuf; linebuf[0] = 0; genbuf[0] = c;
@@ -269,21 +272,21 @@ readecho(c)
        OP = Pline; Pline = normline;
        ignore(vgetline(0, genbuf + 1, &waste, c));
        if (Outchar == termchar)
        OP = Pline; Pline = normline;
        ignore(vgetline(0, genbuf + 1, &waste, c));
        if (Outchar == termchar)
-               putchar('\n');
+               ex_putchar('\n');
        vscrap();
        Pline = OP;
        vscrap();
        Pline = OP;
-       if (Peekkey != ATTN && Peekkey != QUIT && Peekkey != CTRL(h)) {
+       if (Peek_key != ATTN && Peek_key != QUIT && Peek_key != CTRL(h)) {
                cursor = sc;
                vclreol();
                return (0);
        }
 blewit:
                cursor = sc;
                vclreol();
                return (0);
        }
 blewit:
-       OPeek = Peekkey==CTRL(h) ? 0 : Peekkey; Peekkey = 0;
+       OPeek = Peek_key==CTRL(h) ? 0 : Peek_key; Peek_key = 0;
        splitw = 0;
        vclean();
        vshow(dot, NOLINE);
        vnline(sc);
        splitw = 0;
        vclean();
        vshow(dot, NOLINE);
        vnline(sc);
-       Peekkey = OPeek;
+       Peek_key = OPeek;
        return (1);
 }
 
        return (1);
 }
 
@@ -323,13 +326,13 @@ addtext(cp)
 setDEL()
 {
 
 setDEL()
 {
 
-       setBUF(DEL);
+       ex_setBUF(DEL);
 }
 
 /*
  * Put text from cursor upto wcursor in BUF.
  */
 }
 
 /*
  * Put text from cursor upto wcursor in BUF.
  */
-setBUF(BUF)
+ex_setBUF(BUF)
        register char *BUF;
 {
        register int c;
        register char *BUF;
 {
        register int c;
@@ -372,14 +375,14 @@ noteit(must)
        if (WBOT == WECHO)
                vmoveitup(1, 1);
        vigoto(WECHO, 0);
        if (WBOT == WECHO)
                vmoveitup(1, 1);
        vigoto(WECHO, 0);
-       printf("%d %sline", notecnt, notesgn);
+       ex_printf("%d %sline", notecnt, notesgn);
        if (notecnt > 1)
        if (notecnt > 1)
-               putchar('s');
+               ex_putchar('s');
        if (*notenam) {
        if (*notenam) {
-               printf(" %s", notenam);
+               ex_printf(" %s", notenam);
                if (*(strend(notenam) - 1) != 'e')
                if (*(strend(notenam) - 1) != 'e')
-                       putchar('e');
-               putchar('d');
+                       ex_putchar('e');
+               ex_putchar('d');
        }
        vclreol();
        notecnt = 0;
        }
        vclreol();
        notecnt = 0;
index 294333c..4f7781a 100644 (file)
@@ -3,7 +3,7 @@
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
  * All rights reserved.  The Berkeley software License Agreement
  * specifies the terms and conditions for redistribution.
  *
- *     @(#)ex_vis.h    7.4 (Berkeley) %G%
+ *     @(#)ex_vis.h    7.5 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -217,7 +217,7 @@ var char    INS[VBSIZE];    /* Last inserted text */
 var    int     Vlines;         /* Number of file lines "before" vi command */
 var    int     Xcnt;           /* External variable holding last cmd's count */
 var    bool    Xhadcnt;        /* Last command had explicit count? */
 var    int     Vlines;         /* Number of file lines "before" vi command */
 var    int     Xcnt;           /* External variable holding last cmd's count */
 var    bool    Xhadcnt;        /* Last command had explicit count? */
-var    short   ZERO;
+var    short   ex_ZERO;
 var    short   dir;            /* Direction for search (+1 or -1) */
 var    short   doomed;         /* Disply chars right of cursor to be killed */
 var    bool    gobblebl;       /* Wrapmargin space generated nl, eat a space */
 var    short   dir;            /* Direction for search (+1 or -1) */
 var    short   doomed;         /* Disply chars right of cursor to be killed */
 var    bool    gobblebl;       /* Wrapmargin space generated nl, eat a space */
@@ -234,9 +234,9 @@ var char    *ncols['z'-'a'+2];      /* Cursor positions of marks */
 var    char    *notenam;       /* Name to be noted with change count */
 var    char    *notesgn;       /* Change count from last command */
 var    char    op;             /* Operation of current command */
 var    char    *notenam;       /* Name to be noted with change count */
 var    char    *notesgn;       /* Change count from last command */
 var    char    op;             /* Operation of current command */
-var    short   Peekkey;        /* Peek ahead key */
+var    short   Peek_key;       /* Peek ahead key */
 var    bool    rubble;         /* Line is filthy (in hardcopy open), redraw! */
 var    bool    rubble;         /* Line is filthy (in hardcopy open), redraw! */
-var    int     vSCROLL;        /* Number lines to scroll on ^D/^U */
+var    int     ex_vSCROLL;     /* Number lines to scroll on ^D/^U */
 var    char    *vglobp;        /* Untyped input (e.g. repeat insert text) */
 var    char    vmacbuf[VBSIZE];   /* Text of visual macro, hence nonnestable */
 var    char    *vmacp;         /* Like vglobp but for visual macros */
 var    char    *vglobp;        /* Untyped input (e.g. repeat insert text) */
 var    char    vmacbuf[VBSIZE];   /* Text of visual macro, hence nonnestable */
 var    char    *vmacp;         /* Like vglobp but for visual macros */
index e739bc4..5bfba8e 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_vmain.c  7.7 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_vmain.c  7.8 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -79,7 +79,7 @@ vmain()
                                ignore(peekkey());
                        holdupd = 0;
 /*
                                ignore(peekkey());
                        holdupd = 0;
 /*
-                       if (LINE(0) < ZERO) {
+                       if (LINE(0) < ex_ZERO) {
                                vclear();
                                vcnt = 0;
                                i = 3;
                                vclear();
                                vcnt = 0;
                                i = 3;
@@ -302,8 +302,8 @@ reread:
                 */
                case CTRL(u):
                        if (hadcnt)
                 */
                case CTRL(u):
                        if (hadcnt)
-                               vSCROLL = cnt;
-                       cnt = vSCROLL;
+                               ex_vSCROLL = cnt;
+                       cnt = ex_vSCROLL;
                        if (state == VISUAL)
                                ind = vcline, cnt += ind;
                        else
                        if (state == VISUAL)
                                ind = vcline, cnt += ind;
                        else
@@ -322,8 +322,8 @@ reread:
                        fprintf(trace, "before vdown in ^D, dot=%d, wdot=%d, dol=%d\n", lineno(dot), lineno(wdot), lineno(dol));
 #endif
                        if (hadcnt)
                        fprintf(trace, "before vdown in ^D, dot=%d, wdot=%d, dol=%d\n", lineno(dot), lineno(wdot), lineno(dol));
 #endif
                        if (hadcnt)
-                               vSCROLL = cnt;
-                       cnt = vSCROLL;
+                               ex_vSCROLL = cnt;
+                       cnt = ex_vSCROLL;
                        if (state == VISUAL)
                                ind = vcnt - vcline - 1, cnt += ind;
                        else
                        if (state == VISUAL)
                                ind = vcnt - vcline - 1, cnt += ind;
                        else
@@ -565,7 +565,7 @@ appnd:
                case 'a':
                        if (*cursor) {
                                if (state == HARDOPEN)
                case 'a':
                        if (*cursor) {
                                if (state == HARDOPEN)
-                                       putchar(*cursor);
+                                       ex_putchar(*cursor);
                                cursor++;
                        }
                        goto insrt;
                                cursor++;
                        }
                        goto insrt;
@@ -936,7 +936,7 @@ doinit:
                                onumber = value(NUMBER);
                                olist = value(LIST);
                                OPline = Pline;
                                onumber = value(NUMBER);
                                olist = value(LIST);
                                OPline = Pline;
-                               OPutchar = Putchar;
+                               OPutchar = Put_char;
 #ifndef CBREAK
                                vcook();
 #endif
 #ifndef CBREAK
                                vcook();
 #endif
@@ -954,7 +954,7 @@ doinit:
                        ENDCATCH
                        fixol();
                        Pline = OPline;
                        ENDCATCH
                        fixol();
                        Pline = OPline;
-                       Putchar = OPutchar;
+                       Put_char = OPutchar;
                        ungetchar(d);
                        globp = oglobp;
 
                        ungetchar(d);
                        globp = oglobp;
 
@@ -964,7 +964,7 @@ doinit:
                         */
                        if (dot == zero) {
                                fixzero();
                         */
                        if (dot == zero) {
                                fixzero();
-                               sync();
+                               ex_sync();
                        }
                        splitw = 0;
 
                        }
                        splitw = 0;
 
@@ -972,9 +972,9 @@ doinit:
                         * Special case: did list/number options change?
                         */
                        if (onumber != value(NUMBER))
                         * Special case: did list/number options change?
                         */
                        if (onumber != value(NUMBER))
-                               setnumb(value(NUMBER));
+                               ignorf(setnumb(value(NUMBER)));
                        if (olist != value(LIST))
                        if (olist != value(LIST))
-                               setlist(value(LIST));
+                               ignorf(setlist(value(LIST)));
 
 fixup:
                        /*
 
 fixup:
                        /*
@@ -996,7 +996,7 @@ fixup:
                         * If we are about to do another :, hold off
                         * updating of screen.
                         */
                         * If we are about to do another :, hold off
                         * updating of screen.
                         */
-                       if (vcnt < 0 && Peekkey == ':') {
+                       if (vcnt < 0 && Peek_key == ':') {
                                getDOT();
                                shouldpo = 1;
                                continue;
                                getDOT();
                                shouldpo = 1;
                                continue;
@@ -1098,7 +1098,7 @@ fixup:
                 * U            restore current line to initial state.
                 */
                case 'U':
                 * U            restore current line to initial state.
                 */
                case 'U':
-                       vUndo();
+                       ex_vUndo();
                        continue;
 
 fonfon:
                        continue;
 
 fonfon:
index 725b474..8cbc780 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_voper.c  7.4 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_voper.c  7.5 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -161,7 +161,7 @@ nocount:
        case 'W':
        case 'w':
                wdkind = c & ' ';
        case 'W':
        case 'w':
                wdkind = c & ' ';
-               forbid(lfind(2, cnt, opf, 0) < 0);
+               forbid(lfind(2, cnt, opf, (line *) 0) < 0);
                vmoving = 0;
                break;
 
                vmoving = 0;
                break;
 
@@ -178,7 +178,7 @@ nocount:
        case 'e':
                wdkind = 1;
 ein:
        case 'e':
                wdkind = 1;
 ein:
-               forbid(lfind(3, cnt - 1, opf, 0) < 0);
+               forbid(lfind(3, cnt - 1, opf, (line *) 0) < 0);
                vmoving = 0;
                break;
 
                vmoving = 0;
                break;
 
@@ -715,6 +715,7 @@ slerr:
        if (vreg && wdot == 0)
                wdot = dot;
        (*opf)(c);
        if (vreg && wdot == 0)
                wdot = dot;
        (*opf)(c);
+flusho();
        wdot = NOLINE;
 }
 
        wdot = NOLINE;
 }
 
index 23fd3b2..7537cb2 100644 (file)
@@ -27,7 +27,7 @@
 char   *vUA1, *vUA2;
 char   *vUD1, *vUD2;
 
 char   *vUA1, *vUA2;
 char   *vUD1, *vUD2;
 
-vUndo()
+ex_vUndo()
 {
 
        /*
 {
 
        /*
@@ -142,7 +142,7 @@ bool show;  /* if true update the screen */
                vprepins();
                temp[vUA2 - linebuf] = 0;
                for (cp = &temp[vUA1 - linebuf]; *cp;)
                vprepins();
                temp[vUA2 - linebuf] = 0;
                for (cp = &temp[vUA1 - linebuf]; *cp;)
-                       putchar(*cp++);
+                       ex_putchar(*cp++);
                Outchar = OO; hold = oldhold;
                endim();
                physdc(cindent(), cindent() + doomed);
                Outchar = OO; hold = oldhold;
                endim();
                physdc(cindent(), cindent() + doomed);
@@ -173,8 +173,6 @@ bool fromvis;
        char *savecursor;
        char savelb[LBSIZE];
        int nlines, more;
        char *savecursor;
        char savelb[LBSIZE];
        int nlines, more;
-       register line *a1, *a2;
-       char ch;        /* DEBUG */
        int copyw(), copywR();
 
        if (!inopen)
        int copyw(), copywR();
 
        if (!inopen)
@@ -204,7 +202,13 @@ bool fromvis;
                CP(savelb, linebuf);
                nlines = dol - zero;
                while ((line *) endcore - truedol < nlines)
                CP(savelb, linebuf);
                nlines = dol - zero;
                while ((line *) endcore - truedol < nlines)
-                       morelines();
+                       if (morelines() < 0) {
+                               dot = savedot;
+                               dol = savedol;
+                               cursor = savecursor;
+                               CP(linebuf, savelb);
+                               error("Out of memory@- too many lines to undo");
+                       }
                copyw(truedol+1, zero+1, nlines);
                truedol += nlines;
 
                copyw(truedol+1, zero+1, nlines);
                truedol += nlines;
 
@@ -318,7 +322,7 @@ vmove()
                        c = *cp;
                        *cp = 0;
                        hold |= HOLDDOL;
                        c = *cp;
                        *cp = 0;
                        hold |= HOLDDOL;
-                       vreopen(WTOP, lineDOT(), vcline);
+                       ignore(vreopen(WTOP, lineDOT(), vcline));
                        hold = oldhold;
                        *cp = c;
                } else if (wcursor > cursor) {
                        hold = oldhold;
                        *cp = c;
                } else if (wcursor > cursor) {
@@ -326,7 +330,7 @@ vmove()
                        for (cp = cursor; *cp && cp < wcursor;) {
                                register int c = *cp++ & TRIM;
 
                        for (cp = cursor; *cp && cp < wcursor;) {
                                register int c = *cp++ & TRIM;
 
-                               putchar(c ? c : ' ');
+                               ex_putchar(c ? c : ' ');
                        }
                }
        }
                        }
                }
        }
@@ -359,7 +363,7 @@ vdelete(c)
                        vputchar('@');
                }
                wdot = dot;
                        vputchar('@');
                }
                wdot = dot;
-               vremote(i, delete, 0);
+               vremote(i, ex_delete, 0);
                notenam = "delete";
                DEL[0] = 0;
                killU();
                notenam = "delete";
                DEL[0] = 0;
                killU();
@@ -388,7 +392,7 @@ vdelete(c)
        }
        physdc(column(cursor - 1), i);
        DEPTH(vcline) = 0;
        }
        physdc(column(cursor - 1), i);
        DEPTH(vcline) = 0;
-       vreopen(LINE(vcline), lineDOT(), vcline);
+       ignore(vreopen(LINE(vcline), lineDOT(), vcline));
        vsyncCL();
        vsetcurs(cp);
 }
        vsyncCL();
        vsetcurs(cp);
 }
@@ -479,7 +483,7 @@ vchange(c)
                 * case we are told to put.
                 */
                addr = dot;
                 * case we are told to put.
                 */
                addr = dot;
-               vremote(cnt, delete, 0);
+               vremote(cnt, ex_delete, 0);
                setpk();
                notenam = "delete";
                if (c != 'd')
                setpk();
                notenam = "delete";
                if (c != 'd')
@@ -497,7 +501,7 @@ vchange(c)
                 */
                vreplace(vcline, cnt, 0);
                wdot = NOLINE;
                 */
                vreplace(vcline, cnt, 0);
                wdot = NOLINE;
-               noteit(0);
+               ignore(noteit(0));
                vcline--;
                if (addr <= dol)
                        dot--;
                vcline--;
                if (addr <= dol)
                        dot--;
@@ -537,7 +541,7 @@ vchange(c)
                        vcline = 0;
                vopen(dot, i);
                vsyncCL();
                        vcline = 0;
                vopen(dot, i);
                vsyncCL();
-               noteit(1);
+               ignore(noteit(1));
                if (c != 'd') {
                        if (ind >= 0) {
                                cursor = linebuf;
                if (c != 'd') {
                        if (ind >= 0) {
                                cursor = linebuf;
@@ -580,7 +584,7 @@ smallchange:
                bleep(i, cp);
        else {
                vcursbef(wcursor);
                bleep(i, cp);
        else {
                vcursbef(wcursor);
-               putchar('$');
+               ex_putchar('$');
                i = cindent();
        }
 
                i = cindent();
        }
 
@@ -624,11 +628,15 @@ voOpen(c, cnt)
 {
        register int ind = 0, i;
        short oldhold = hold;
 {
        register int ind = 0, i;
        short oldhold = hold;
+#ifdef SIGWINCH
        int oldmask;
        int oldmask;
+#endif
 
        if (value(SLOWOPEN) || value(REDRAW) && AL && DL)
                cnt = 1;
 
        if (value(SLOWOPEN) || value(REDRAW) && AL && DL)
                cnt = 1;
+#ifdef SIGWINCH
        oldmask = sigblock(sigmask(SIGWINCH));
        oldmask = sigblock(sigmask(SIGWINCH));
+#endif
        vsave();
        setLAST();
        if (value(AUTOINDENT))
        vsave();
        setLAST();
        if (value(AUTOINDENT))
@@ -653,8 +661,8 @@ voOpen(c, cnt)
                c = WBOT + 1;
        else {
                c = vcline < 0 ? WTOP - cnt : LINE(vcline) + DEPTH(vcline);
                c = WBOT + 1;
        else {
                c = vcline < 0 ? WTOP - cnt : LINE(vcline) + DEPTH(vcline);
-               if (c < ZERO)
-                       c = ZERO;
+               if (c < ex_ZERO)
+                       c = ex_ZERO;
                i = LINE(vcline + 1) - c;
                if (i < cnt && c <= WBOT && (!AL || !DL))
                        vinslin(c, cnt - i, vcline);
                i = LINE(vcline + 1) - c;
                if (i < cnt && c <= WBOT && (!AL || !DL))
                        vinslin(c, cnt - i, vcline);
@@ -676,7 +684,9 @@ voOpen(c, cnt)
        cursor = linebuf;
        linebuf[0] = 0;
        vappend('o', 1, ind);
        cursor = linebuf;
        linebuf[0] = 0;
        vappend('o', 1, ind);
+#ifdef SIGWINCH
        (void)sigsetmask(oldmask);
        (void)sigsetmask(oldmask);
+#endif
 }
 
 /*
 }
 
 /*
index 61325da..d9f2865 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)ex_vops2.c 6.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)ex_vops2.c 6.9 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -31,7 +31,7 @@ bleep(i, cp)
 
        i -= column(cp);
        do
 
        i -= column(cp);
        do
-               putchar('\\' | QUOTE);
+               ex_putchar('\\' | QUOTE);
        while (--i >= 0);
        rubble = 1;
 }
        while (--i >= 0);
        rubble = 1;
 }
@@ -75,7 +75,7 @@ takeout(BUF)
                wcursor = cursor;
                cursor = cp;
        }
                wcursor = cursor;
                cursor = cp;
        }
-       setBUF(BUF);
+       ex_setBUF(BUF);
        if ((BUF[0] & (QUOTE|TRIM)) == OVERBUF)
                beep();
 }
        if ((BUF[0] & (QUOTE|TRIM)) == OVERBUF)
                beep();
 }
@@ -120,7 +120,9 @@ vappend(ch, cnt, indent)
        bool escape;
        int repcnt, savedoomed;
        short oldhold = hold;
        bool escape;
        int repcnt, savedoomed;
        short oldhold = hold;
+#ifdef SIGWINCH
        int oldmask;
        int oldmask;
+#endif
 
        /*
         * Before a move in hardopen when the line is dirty
 
        /*
         * Before a move in hardopen when the line is dirty
@@ -210,7 +212,9 @@ vappend(ch, cnt, indent)
         */
        gobblebl = 0;
 
         */
        gobblebl = 0;
 
+#ifdef SIGWINCH
        oldmask = sigblock(sigmask(SIGWINCH));
        oldmask = sigblock(sigmask(SIGWINCH));
+#endif
        /*
         * Text gathering loop.
         * New text goes into genbuf starting at gcursor.
        /*
         * Text gathering loop.
         * New text goes into genbuf starting at gcursor.
@@ -270,7 +274,7 @@ vappend(ch, cnt, indent)
 
                                Outchar = vinschar;
                                hold |= HOLDQIK;
 
                                Outchar = vinschar;
                                hold |= HOLDQIK;
-                               printf("%s", genbuf);
+                               ex_printf("%s", genbuf);
                                hold = oldhold;
                                Outchar = vputchar;
                        }
                                hold = oldhold;
                                Outchar = vputchar;
                        }
@@ -388,7 +392,9 @@ vappend(ch, cnt, indent)
        doomed = 0;
        wcursor = cursor;
        vmove();
        doomed = 0;
        wcursor = cursor;
        vmove();
+#ifdef SIGWINCH
        (void)sigsetmask(oldmask);
        (void)sigsetmask(oldmask);
+#endif
 }
 
 /*
 }
 
 /*
@@ -470,7 +476,7 @@ vgetline(cnt, gcursor, aescaped, commch)
                        c &= (QUOTE|TRIM);
                ch = c;
                maphopcnt = 0;
                        c &= (QUOTE|TRIM);
                ch = c;
                maphopcnt = 0;
-               if (vglobp == 0 && Peekkey == 0 && commch != 'r')
+               if (vglobp == 0 && Peek_key == 0 && commch != 'r')
                        while ((ch = map(c, immacs)) != c) {
                                c = ch;
                                if (!value(REMAP))
                        while ((ch = map(c, immacs)) != c) {
                                c = ch;
                                if (!value(REMAP))
@@ -577,7 +583,7 @@ vbackup:
                         */
                        case '\\':
                                x = destcol, y = destline;
                         */
                        case '\\':
                                x = destcol, y = destline;
-                               putchar('\\');
+                               ex_putchar('\\');
                                vcsync();
                                c = getkey();
 #ifndef USG3TTY
                                vcsync();
                                c = getkey();
 #ifndef USG3TTY
@@ -607,7 +613,7 @@ vbackup:
                        case CTRL(q):
                        case CTRL(v):
                                x = destcol, y = destline;
                        case CTRL(q):
                        case CTRL(v):
                                x = destcol, y = destline;
-                               putchar('^');
+                               ex_putchar('^');
                                vgoto(y, x);
                                c = getkey();
 #ifdef TIOCSETC
                                vgoto(y, x);
                                c = getkey();
 #ifdef TIOCSETC
@@ -692,22 +698,22 @@ vbackup:
                 */
                cstr[0] = c;
                if (anyabbrs && gcursor > ogcursor && !wordch(cstr) && wordch(gcursor-1)) {
                 */
                cstr[0] = c;
                if (anyabbrs && gcursor > ogcursor && !wordch(cstr) && wordch(gcursor-1)) {
-                               int wdtype, abno;
-
-                               cstr[1] = 0;
-                               wdkind = 1;
-                               cp = gcursor - 1;
-                               for (wdtype = wordch(cp - 1);
-                                   cp > ogcursor && wordof(wdtype, cp - 1); cp--)
-                                       ;
-                               *gcursor = 0;
-                               for (abno=0; abbrevs[abno].mapto; abno++) {
-                                       if (eq(cp, abbrevs[abno].cap)) {
-                                               macpush(cstr, 0);
-                                               macpush(abbrevs[abno].mapto);
-                                               goto vbackup;
-                                       }
+                       int wdtype, abno;
+
+                       cstr[1] = 0;
+                       wdkind = 1;
+                       cp = gcursor - 1;
+                       for (wdtype = wordch(cp - 1);
+                           cp > ogcursor && wordof(wdtype, cp - 1); cp--)
+                               ;
+                       *gcursor = 0;
+                       for (abno=0; abbrevs[abno].mapto; abno++) {
+                               if (eq(cp, abbrevs[abno].cap)) {
+                                       macpush(cstr, 0);
+                                       macpush(abbrevs[abno].mapto, 1);
+                                       goto vbackup;
                                }
                                }
+                       }
                }
 
                switch (c) {
                }
 
                switch (c) {
@@ -818,8 +824,7 @@ vbackup:
                        }
 def:
                        if (!backsl) {
                        }
 def:
                        if (!backsl) {
-                               int cnt;
-                               putchar(c);
+                               ex_putchar(c);
                                flush();
                        }
                        if (gcursor > &genbuf[LBSIZE - 2])
                                flush();
                        }
                        if (gcursor > &genbuf[LBSIZE - 2])
index af1ef7a..185573d 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_vops3.c  7.3 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_vops3.c  7.4 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -155,7 +155,7 @@ begin:
                         */
                        if (linebuf[0] == 0 && !pastatom && 
                           (wdot != dot - 1 || cursor != linebuf)) {
                         */
                        if (linebuf[0] == 0 && !pastatom && 
                           (wdot != dot - 1 || cursor != linebuf)) {
-                               lnext();
+                               ignore(lnext());
                                goto ret;
                        }
                }
                                goto ret;
                        }
                }
@@ -223,11 +223,12 @@ ret:
 /*
  * Is this the end of a sentence?
  */
 /*
  * Is this the end of a sentence?
  */
+/* ARGSUSED */
 endsent(pastatom)
        bool pastatom;
 {
        register char *cp = wcursor;
 endsent(pastatom)
        bool pastatom;
 {
        register char *cp = wcursor;
-       register int c, d;
+       register int d;
 
        /*
         * If this is the beginning of a line, then
 
        /*
         * If this is the beginning of a line, then
@@ -242,7 +243,7 @@ endsent(pastatom)
         * or followed by 2 spaces.  Any number of intervening ) ] ' "
         * characters are allowed.
         */
         * or followed by 2 spaces.  Any number of intervening ) ] ' "
         * characters are allowed.
         */
-       if (!any(c = *cp, ".!?"))
+       if (!any(*cp, ".!?"))
                goto tryps;
        do
                if ((d = *++cp) == 0)
                goto tryps;
        do
                if ((d = *++cp) == 0)
index 95e3484..76abe0b 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_vput.c   7.4 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_vput.c   7.5 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -31,7 +31,7 @@ vclear()
        destline = 0;
        outline = 0;
        if (inopen)
        destline = 0;
        outline = 0;
        if (inopen)
-               vclrbyte(vtube0, WCOLS * (WECHO - ZERO + 1));
+               vclrbyte(vtube0, WCOLS * (WECHO - ex_ZERO + 1));
 }
 
 /*
 }
 
 /*
@@ -58,7 +58,7 @@ vclrlin(l, tp)
 
        vigoto(l, 0);
        if ((hold & HOLDAT) == 0)
 
        vigoto(l, 0);
        if ((hold & HOLDAT) == 0)
-               putchar(tp > dol ? ((UPPERCASE || HZ) ? '^' : '~') : '@');
+               ex_putchar(tp > dol ? ((UPPERCASE || HZ) ? '^' : '~') : '@');
        if (state == HARDOPEN)
                sethard();
        vclreol();
        if (state == HARDOPEN)
                sethard();
        vclreol();
@@ -111,7 +111,7 @@ vclrech(didphys)
        bool didphys;
 {
 
        bool didphys;
 {
 
-       if (Peekkey == ATTN)
+       if (Peek_key == ATTN)
                return;
        if (hold & HOLDECH) {
                heldech = !didphys;
                return;
        if (hold & HOLDECH) {
                heldech = !didphys;
@@ -472,7 +472,7 @@ vmaktop(p, cp)
 
        if (p < 0 || vtube[p] == cp)
                return;
 
        if (p < 0 || vtube[p] == cp)
                return;
-       for (i = ZERO; i <= WECHO; i++)
+       for (i = ex_ZERO; i <= WECHO; i++)
                if (vtube[i] == cp) {
                        copy(temp, vtube[i], WCOLS);
                        copy(vtube[i], vtube[p], WCOLS);
                if (vtube[i] == cp) {
                        copy(temp, vtube[i], WCOLS);
                        copy(vtube[i], vtube[p], WCOLS);
index 2b8c132..cfafad8 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)ex_vwind.c  7.3 (Berkeley) %G%";
+static char *sccsid = "@(#)ex_vwind.c  7.4 (Berkeley) %G%";
 #endif not lint
 
 #include "ex.h"
 #endif not lint
 
 #include "ex.h"
@@ -45,12 +45,12 @@ vjumpto(addr, curs, context)
        char context;
 {
 
        char context;
 {
 
-       noteit(0);
+       ignore(noteit(0));
        if (context != 0)
                vcontext(addr, context);
        else
                vshow(addr, NOLINE);
        if (context != 0)
                vcontext(addr, context);
        else
                vshow(addr, NOLINE);
-       noteit(1);
+       ignore(noteit(1));
        vnline(curs);
 }
 
        vnline(curs);
 }
 
@@ -104,9 +104,9 @@ vup(cnt, ind, scroll)
        if (hold & HOLDWIG)
                goto contxt;
        if (state == VISUAL && !AL && !SR &&
        if (hold & HOLDWIG)
                goto contxt;
        if (state == VISUAL && !AL && !SR &&
-           cnt <= WTOP - ZERO && vfit(dot - cnt, cnt) <= WTOP - ZERO)
+           cnt <= WTOP - ex_ZERO && vfit(dot - cnt, cnt) <= WTOP - ex_ZERO)
                goto okr;
                goto okr;
-       tot = WECHO - ZERO;
+       tot = WECHO - ex_ZERO;
        if (state != VISUAL || (!AL && !SR) || (!scroll && (cnt > tot || vfit(dot - cnt, cnt) > tot / 3 + 1))) {
                if (ind > basWLINES / 2)
                        ind = basWLINES / 3;
        if (state != VISUAL || (!AL && !SR) || (!scroll && (cnt > tot || vfit(dot - cnt, cnt) > tot / 3 + 1))) {
                if (ind > basWLINES / 2)
                        ind = basWLINES / 3;
@@ -154,7 +154,7 @@ vdown(cnt, ind, scroll)
        if (hold & HOLDWIG)
                goto dcontxt;
        if (!scroll) {
        if (hold & HOLDWIG)
                goto dcontxt;
        if (!scroll) {
-               tot = WECHO - ZERO;
+               tot = WECHO - ex_ZERO;
                if (state != VISUAL || cnt - tot > 0 || vfit(dot, cnt) > tot / 3 + 1) {
 dcontxt:
                        vcontext(dot + cnt, '.');
                if (state != VISUAL || cnt - tot > 0 || vfit(dot, cnt) > tot / 3 + 1) {
 dcontxt:
                        vcontext(dot + cnt, '.');
@@ -369,7 +369,7 @@ vroll(cnt)
        if (vcookit(cnt))
                fried++, vcook();
 #endif
        if (vcookit(cnt))
                fried++, vcook();
 #endif
-       for (; cnt > 0 && Peekkey != ATTN; cnt--) {
+       for (; cnt > 0 && Peek_key != ATTN; cnt--) {
                dot++, vcline++;
                vopen(dot, LASTLINE);
                vscrap();
                dot++, vcline++;
                vopen(dot, LASTLINE);
                vscrap();
@@ -390,7 +390,6 @@ vroll(cnt)
 vrollR(cnt)
        register int cnt;
 {
 vrollR(cnt)
        register int cnt;
 {
-       register bool fried = 0;
        short oldhold = hold;
 
 #ifdef ADEBUG
        short oldhold = hold;
 
 #ifdef ADEBUG
@@ -405,7 +404,7 @@ vrollR(cnt)
                vcnt = 0;
        heldech = 0;
        hold |= HOLDAT|HOLDECH;
                vcnt = 0;
        heldech = 0;
        hold |= HOLDAT|HOLDECH;
-       for (; cnt > 0 && Peekkey != ATTN; cnt--) {
+       for (; cnt > 0 && Peek_key != ATTN; cnt--) {
                dot--;
                vopen(dot, WTOP);
                vscrap();
                dot--;
                vopen(dot, WTOP);
                vscrap();
@@ -443,7 +442,7 @@ vdepth()
 {
        register int d;
 
 {
        register int d;
 
-       d = (column(NOSTR) + WCOLS - 1 + (Putchar == listchar) + IN) / WCOLS;
+       d = (column(NOSTR) + WCOLS - 1 + (Put_char == listchar) + IN) / WCOLS;
 #ifdef ADEBUG
        if (trace)
                tfixnl(), fprintf(trace, "vdepth returns %d\n", d == 0 ? 1 : d);
 #ifdef ADEBUG
        if (trace)
                tfixnl(), fprintf(trace, "vdepth returns %d\n", d == 0 ? 1 : d);
index 048ff09..71a8c2d 100644 (file)
@@ -5,12 +5,13 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)printf.c    7.3 (Berkeley) %G%";
-#endif not lint
-
+static char *sccsid = "@(#)printf.c    7.4 (Berkeley) %G%";
 /* The pwb version this is based on */
 static char *printf_id = "@(#) printf.c:2.2 6/5/79";
 /* The pwb version this is based on */
 static char *printf_id = "@(#) printf.c:2.2 6/5/79";
-#include "varargs.h"
+#endif not lint
+
+#include <varargs.h>
 /*
  * This version of printf is compatible with the Version 7 C
  * printf. The differences are only minor except that this
 /*
  * This version of printf is compatible with the Version 7 C
  * printf. The differences are only minor except that this
@@ -18,7 +19,6 @@ static char *printf_id = "@(#) printf.c:2.2 6/5/79";
  * printf is more general (and is much larger) and includes
  * provisions for floating point.
  */
  * printf is more general (and is much larger) and includes
  * provisions for floating point.
  */
 
 #define MAXOCT 11      /* Maximum octal digits in a long */
 #define MAXINT 32767   /* largest normal length positive integer */
 
 #define MAXOCT 11      /* Maximum octal digits in a long */
 #define MAXINT 32767   /* largest normal length positive integer */
@@ -29,7 +29,8 @@ static int width, sign, fill;
 
 char *_p_dconv();
 
 
 char *_p_dconv();
 
-printf(va_alist)
+/* VARARGS */
+ex_printf(va_alist)
        va_dcl
 {
        va_list ap;
        va_dcl
 {
        va_list ap;
@@ -50,7 +51,7 @@ printf(va_alist)
                        /* ordinary (non-%) character */
                        if (fcode=='\0')
                                return;
                        /* ordinary (non-%) character */
                        if (fcode=='\0')
                                return;
-                       putchar(fcode);
+                       ex_putchar(fcode);
                }
                /* length modifier: -1 for h, 1 for l, 0 for none */
                length = 0;
                }
                /* length modifier: -1 for h, 1 for l, 0 for none */
                length = 0;
@@ -180,8 +181,8 @@ printf(va_alist)
                                }
                                else
                                        if (!sign && fill <= 0) {
                                }
                                else
                                        if (!sign && fill <= 0) {
-                                               putchar('0');
-                                               putchar(fcode);
+                                               ex_putchar('0');
+                                               ex_putchar(fcode);
                                                width -= 2;
                                        }
                                        else {
                                                width -= 2;
                                        }
                                        else {
@@ -329,7 +330,7 @@ _p_emit(s, send)
        
        /* we may want to print a leading '-' before anything */
        if (*s == '-' && fill < 0) {
        
        /* we may want to print a leading '-' before anything */
        if (*s == '-' && fill < 0) {
-               putchar(*s++);
+               ex_putchar(*s++);
                alen--;
                width--;
        }
                alen--;
                width--;
        }
@@ -338,14 +339,14 @@ _p_emit(s, send)
        /* emit any leading pad characters */
        if (!sign)
                while (--npad >= 0)
        /* emit any leading pad characters */
        if (!sign)
                while (--npad >= 0)
-                       putchar(cfill);
+                       ex_putchar(cfill);
                        
        /* emit the string itself */
        while (--alen >= 0)
                        
        /* emit the string itself */
        while (--alen >= 0)
-               putchar(*s++);
+               ex_putchar(*s++);
                
        /* emit trailing pad characters */
        if (sign)
                while (--npad >= 0)
                
        /* emit trailing pad characters */
        if (sign)
                while (--npad >= 0)
-                       putchar(cfill);
+                       ex_putchar(cfill);
 }
 }