cleanups, add manual page
[unix-history] / usr / src / usr.bin / ex / ex_cmds2.c
index e50811f..6bb4c3a 100644 (file)
@@ -1,13 +1,21 @@
-/* Copyright (c) 1980 Regents of the University of California */
-static char *sccsid = "@(#)ex_cmds2.c  4.2 %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.
+ */
+
+#ifndef lint
+static char *sccsid = "@(#)ex_cmds2.c  7.6 (Berkeley) %G%";
+#endif not lint
+
 #include "ex.h"
 #include "ex_argv.h"
 #include "ex_temp.h"
 #include "ex_tty.h"
 #include "ex_vis.h"
 
 #include "ex.h"
 #include "ex_argv.h"
 #include "ex_temp.h"
 #include "ex_tty.h"
 #include "ex_vis.h"
 
-bool   pflag, nflag;
-int    poffset;
+extern bool    pflag, nflag;           /* mjm: extern; also in ex_cmds.c */
+extern int     poffset;                /* mjm: extern; also in ex_cmds.c */
 
 /*
  * Subroutines for major command loop.
 
 /*
  * Subroutines for major command loop.
@@ -22,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);
 }
 
@@ -64,16 +72,24 @@ 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;
 {
 
        error0();
        merror(str, i);
 #endif
        int i;
 {
 
        error0();
        merror(str, i);
+       if (writing) {
+               serror(" [Warning - %s is incomplete]", file);
+               writing = 0;
+       }
        error1(str);
 }
 
        error1(str);
 }
 
@@ -87,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();
        }
@@ -104,13 +120,6 @@ erewind()
 error0()
 {
 
 error0()
 {
 
-       if (laste) {
-#ifdef VMUNIX
-               tlaste();
-#endif
-               laste = 0;
-               sync();
-       }
        if (vcatch) {
                if (splitw == 0)
                        fixech();
        if (vcatch) {
                if (splitw == 0)
                        fixech();
@@ -178,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');
@@ -258,7 +267,7 @@ newline()
 
        resetflav();
        for (;;) {
 
        resetflav();
        for (;;) {
-               c = getchar();
+               c = ex_getchar();
                switch (c) {
 
                case '^':
                switch (c) {
 
                case '^':
@@ -331,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);
 }
@@ -380,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();
 }
 
@@ -439,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)) {
                /*
@@ -451,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);
@@ -506,7 +515,7 @@ vcontin(ask)
                         * Gobble ^Q/^S since the tty driver should be eating
                         * them (as far as the user can see)
                         */
                         * Gobble ^Q/^S since the tty driver should be eating
                         * them (as far as the user can see)
                         */
-                       while (peekkey() == CTRL(Q) || peekkey() == CTRL(S))
+                       while (peekkey() == CTRL('Q') || peekkey() == CTRL('S'))
                                ignore(getkey());
 #endif
                        if(getkey() == ':') {
                                ignore(getkey());
 #endif
                        if(getkey() == ':') {
@@ -517,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.