do longjmp's only when we should
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Sun, 19 Jun 1983 08:24:57 +0000 (00:24 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Sun, 19 Jun 1983 08:24:57 +0000 (00:24 -0800)
SCCS-vsn: usr.bin/ex/ex_v.c 7.4
SCCS-vsn: usr.bin/ex/ex_vget.c 6.5

usr/src/usr.bin/ex/ex_v.c
usr/src/usr.bin/ex/ex_vget.c

index e94e29f..717d998 100644 (file)
@@ -1,5 +1,5 @@
 /* Copyright (c) 1981 Regents of the University of California */
 /* Copyright (c) 1981 Regents of the University of California */
-static char *sccsid = "@(#)ex_v.c      7.3 %G%";
+static char *sccsid = "@(#)ex_v.c      7.4 %G%";
 #include "ex.h"
 #include "ex_re.h"
 #include "ex_tty.h"
 #include "ex.h"
 #include "ex_re.h"
 #include "ex_tty.h"
@@ -360,13 +360,17 @@ vok(atube)
 vintr()
 {
        extern jmp_buf readbuf;
 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();
-       longjmp(readbuf, 1);
+       if (doingread) {
+               doingread = 0;
+               longjmp(readbuf, 1);
+       }
 }
 #endif
 
 }
 #endif
 
index 08fc010..a1c28d3 100644 (file)
@@ -1,5 +1,5 @@
 /* Copyright (c) 1981 Regents of the University of California */
 /* Copyright (c) 1981 Regents of the University of California */
-static char *sccsid = "@(#)ex_vget.c   6.4 %G%";
+static char *sccsid = "@(#)ex_vget.c   6.5 %G%";
 #include "ex.h"
 #include "ex_tty.h"
 #include "ex_vis.h"
 #include "ex.h"
 #include "ex_tty.h"
 #include "ex_vis.h"
@@ -49,6 +49,7 @@ peekbr()
 
 short  precbksl;
 jmp_buf        readbuf;
 
 short  precbksl;
 jmp_buf        readbuf;
+int    doingread = 0;
 
 /*
  * Get a keystroke, including a ^@.
 
 /*
  * Get a keystroke, including a ^@.
@@ -105,7 +106,10 @@ getATTN:
 again:
        if (setjmp(readbuf))
                goto getATTN;
 again:
        if (setjmp(readbuf))
                goto getATTN;
-       if ((c=read(slevel == 0 ? 0 : ttyindes, &ch, 1)) != 1) {
+       doingread = 1;
+       c = read(slevel == 0 ? 0 : ttyindes, &ch, 1);
+       doingread = 0;
+       if (c != 1) {
                if (errno == EINTR)
                        goto getATTN;
                error("Input read error");
                if (errno == EINTR)
                        goto getATTN;
                error("Input read error");