Flush out the last dregs in the terminal before quitting when
[unix-history] / usr / src / usr.bin / ex / ex_cmds.c
index c92fe13..64c3919 100644 (file)
@@ -1,5 +1,13 @@
-/* Copyright (c) 1981 Regents of the University of California */
-static char *sccsid = "@(#)ex_cmds.c   5.3.1.1 %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_cmds.c   7.12 (Berkeley) %G%";
+#endif not lint
+
 #include "ex.h"
 #include "ex_argv.h"
 #include "ex_temp.h"
 #include "ex.h"
 #include "ex_argv.h"
 #include "ex_temp.h"
@@ -69,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();
@@ -83,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 == ',')
@@ -106,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.
@@ -123,7 +131,7 @@ error("Offset out-of-bounds|Offset after command too large");
                 * the set of available commands here to save work below.
                 */
                if (inopen) {
                 * the set of available commands here to save work below.
                 */
                if (inopen) {
-                       if (c=='\n' || c=='\r' || c==CTRL(d) || c==EOF) {
+                       if (c=='\n' || c=='\r' || c==CTRL('d') || c==EOF) {
                                if (addr2)
                                        dot = addr2;
                                if (c == EOF)
                                if (addr2)
                                        dot = addr2;
                                if (c == EOF)
@@ -134,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':
@@ -229,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;
@@ -247,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;
 
@@ -268,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;
 
@@ -333,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();
@@ -462,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') {
@@ -504,7 +511,7 @@ quit:
                                        init();
                                        addr2 = zero;
                                        laste++;
                                        init();
                                        addr2 = zero;
                                        laste++;
-                                       sync();
+                                       ex_sync();
                                        recover();
                                        rop2();
                                        revocer();
                                        recover();
                                        rop2();
                                        revocer();
@@ -664,7 +671,7 @@ suspend:
 /* version */
                                tail("version");
                                setNAEOL();
 /* version */
                                tail("version");
                                setNAEOL();
-                               printf("@(#) Version 3.5, %G%."+5);
+                               ex_printf("@(#) Version 3.7, 6/7/85."+5);
                                noonl();
                                continue;
 
                                noonl();
                                continue;
 
@@ -737,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"))
@@ -763,7 +770,7 @@ caseline:
                        notempty();
                        if (addr2 == 0) {
                                if (UP != NOSTR && c == '\n' && !inglobal)
                        notempty();
                        if (addr2 == 0) {
                                if (UP != NOSTR && c == '\n' && !inglobal)
-                                       c = CTRL(k);
+                                       c = CTRL('k');
                                if (inglobal)
                                        addr1 = addr2 = dot;
                                else {
                                if (inglobal)
                                        addr1 = addr2 = dot;
                                else {
@@ -777,7 +784,7 @@ caseline:
                        if (seensemi)
                                addr1 = addr2;
                        getline(*addr1);
                        if (seensemi)
                                addr1 = addr2;
                        getline(*addr1);
-                       if (c == CTRL(k)) {
+                       if (c == CTRL('k')) {
                                flush1();
                                destline--;
                                if (hadpr)
                                flush1();
                                destline--;
                                if (hadpr)
@@ -805,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;
 
@@ -840,7 +847,7 @@ numberit:
 
 /* ^D */
 /* EOF */
 
 /* ^D */
 /* EOF */
-               case CTRL(d):
+               case CTRL('d'):
                case EOF:
                        if (exitoneof) {
                                if (addr2 != 0)
                case EOF:
                        if (exitoneof) {
                                if (addr2 != 0)