document distributed with 4.1BSD
[unix-history] / usr / src / usr.bin / ex / ex_v.c
index 8f4b1a4..a1cfc48 100644 (file)
@@ -1,5 +1,13 @@
-/* Copyright (c) 1980 Regents of the University of California */
-static char *sccsid = "@(#)ex_v.c      6.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_v.c      7.8 (Berkeley) %G%";
+#endif not lint
+
 #include "ex.h"
 #include "ex_re.h"
 #include "ex_tty.h"
 #include "ex.h"
 #include "ex_re.h"
 #include "ex_tty.h"
@@ -47,15 +55,31 @@ static char *sccsid = "@(#)ex_v.c   6.1 %G%";
  *             absolute motions, contextual displays, line depth determination
  */
 
  *             absolute motions, contextual displays, line depth determination
  */
 
+jmp_buf venv;
+int    winch();
+
 /*
  * Enter open mode
  */
 /*
  * Enter open mode
  */
+#ifdef u370
+char   atube[TUBESIZE+LBSIZE];
+#endif
 oop()
 {
        register char *ic;
 oop()
 {
        register char *ic;
+#ifndef u370
        char atube[TUBESIZE + LBSIZE];
        char atube[TUBESIZE + LBSIZE];
-       register ttymode f;
+#endif
+       ttymode f;      /* mjm: was register */
+       int resize;
 
 
+       if (resize = setjmp(venv)) {
+               setsize();
+               initev = (char *)0;
+               inopen = 0;
+               addr1 = addr2 = dot;
+       }
+       (void)signal(SIGWINCH, winch);
        ovbeg();
        if (peekchar() == '/') {
                ignore(compile(getchar(), 1));
        ovbeg();
        if (peekchar() == '/') {
                ignore(compile(getchar(), 1));
@@ -112,6 +136,7 @@ oop()
                vclean();
        Command = "open";
        ovend(f);
                vclean();
        Command = "open";
        ovend(f);
+       (void)signal(SIGWINCH, SIG_DFL);
 }
 
 ovbeg()
 }
 
 ovbeg()
@@ -153,8 +178,11 @@ ovend(f)
 vop()
 {
        register int c;
 vop()
 {
        register int c;
+#ifndef u370
        char atube[TUBESIZE + LBSIZE];
        char atube[TUBESIZE + LBSIZE];
-       register ttymode f;
+#endif
+       ttymode f;      /* mjm: was register */
+       int resize;
 
        if (!CA && UP == NOSTR) {
                if (initev) {
 
        if (!CA && UP == NOSTR) {
                if (initev) {
@@ -181,6 +209,13 @@ toopen:
                        goto toopen;
                error("Visual requires scrolling");
        }
                        goto toopen;
                error("Visual requires scrolling");
        }
+       if (resize = setjmp(venv)) {
+               setsize();
+               initev = (char *)0;
+               inopen = 0;
+               addr1 = addr2 = dot;
+       }
+       (void)signal(SIGWINCH, winch);
        ovbeg();
        bastate = VISUAL;
        c = 0;
        ovbeg();
        bastate = VISUAL;
        c = 0;
@@ -203,6 +238,7 @@ toopen:
        vmain();
        Command = "visual";
        ovend(f);
        vmain();
        Command = "visual";
        ovend(f);
+       (void)signal(SIGWINCH, SIG_DFL);
 }
 
 /*
 }
 
 /*
@@ -352,12 +388,18 @@ vok(atube)
 #ifdef CBREAK
 vintr()
 {
 #ifdef CBREAK
 vintr()
 {
+       extern jmp_buf readbuf;
+       extern int doingread;
 
        signal(SIGINT, vintr);
        if (vcatch)
                onintr();
        ungetkey(ATTN);
        draino();
 
        signal(SIGINT, vintr);
        if (vcatch)
                onintr();
        ungetkey(ATTN);
        draino();
+       if (doingread) {
+               doingread = 0;
+               longjmp(readbuf, 1);
+       }
 }
 #endif
 
 }
 #endif
 
@@ -380,3 +422,10 @@ vsetsiz(size)
        basWTOP = b;
        basWLINES = WBOT - b + 1;
 }
        basWTOP = b;
        basWLINES = WBOT - b + 1;
 }
+
+winch()
+{
+       vsave();
+       setty(normf);
+       longjmp(venv, 1);
+}