longjmp fixes
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 2 Mar 1993 09:01:24 +0000 (01:01 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Tue, 2 Mar 1993 09:01:24 +0000 (01:01 -0800)
SCCS-vsn: contrib/ed/ed.h 5.4
SCCS-vsn: contrib/ed/input_lines.c 5.5
SCCS-vsn: contrib/ed/main.c 5.5

usr/src/contrib/ed/ed.h
usr/src/contrib/ed/input_lines.c
usr/src/contrib/ed/main.c

index 802ef36..1845151 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)ed.h        5.3 (Berkeley) %G%
+ *     @(#)ed.h        5.4 (Berkeley) %G%
  */
 
 #define        FILENAME_LEN    PATH_MAX
  */
 
 #define        FILENAME_LEN    PATH_MAX
@@ -15,7 +15,8 @@
 #define        INTERUPT        (int)1
 #define        HANGUP          (int)2
 #define        SIGINT_ACTION   longjmp(ctrl_position, INTERUPT)
 #define        INTERUPT        (int)1
 #define        HANGUP          (int)2
 #define        SIGINT_ACTION   longjmp(ctrl_position, INTERUPT)
-#define SIGINT_ILACTION        longjmp(ctrl_position2, INTERUPT)
+#define SIGINT_ALACTION        longjmp(ctrl_position2, INTERUPT)
+#define SIGINT_ILACTION        longjmp(ctrl_position3, INTERUPT)
 #define        SIGHUP_ACTION   longjmp(ctrl_position, HANGUP)
 #define        NN_MAX_START    510
 #ifndef STDOUT_FILENO
 #define        SIGHUP_ACTION   longjmp(ctrl_position, HANGUP)
 #define        NN_MAX_START    510
 #ifndef STDOUT_FILENO
@@ -83,8 +84,8 @@ extern LINE *u_current, *u_top, *u_bottom;
 extern int u_set, line_length;
 extern struct d_layer *d_stk;
 
 extern int u_set, line_length;
 extern struct d_layer *d_stk;
 
-extern int sigint_flag, sighup_flag, sigspecial, sigspecial2;
-extern jmp_buf ctrl_position, ctrl_position2;
+extern int sigint_flag, sighup_flag, sigspecial, sigspecial2, sigspecial3;
+extern jmp_buf ctrl_position, ctrl_position2, ctrl_position3;
 
 #define RE_SEC 10
 extern regex_t RE_comp;
 
 #define RE_SEC 10
 extern regex_t RE_comp;
index df17bfe..396f772 100644 (file)
@@ -9,7 +9,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)input_lines.c      5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)input_lines.c      5.5 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -20,10 +20,6 @@ static char sccsid[] = "@(#)input_lines.c    5.4 (Berkeley) %G%";
 #include <stdlib.h>
 #include <string.h>
 
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef DBI
-#include <db.h>
-#endif
-
 #include "ed.h"
 #include "extern.h"
 
 #include "ed.h"
 #include "extern.h"
 
@@ -42,7 +38,7 @@ input_lines(fp, errnum)
        register char *l_text = text;
        LINE *l_temp_line, *l_temp1;
        long l_ttl = 0;
        register char *l_text = text;
        LINE *l_temp_line, *l_temp1;
        long l_ttl = 0;
-       int l_nn_max = nn_max;
+       int l_nn_max = nn_max, l_jmp_flag;
        char *l_text2;
 
        if (End_default)
        char *l_text2;
 
        if (End_default)
@@ -66,12 +62,15 @@ input_lines(fp, errnum)
                SIGINT_ACTION;
 
        sigspecial++;
                SIGINT_ACTION;
 
        sigspecial++;
+        if (l_jmp_flag = setjmp(ctrl_position3))
+                goto point;
 
        for (;;) {
                if (sigint_flag && (!sigspecial))
                        goto point;
 
        for (;;) {
                if (sigint_flag && (!sigspecial))
                        goto point;
-               /* If NULL or bit-8 high not text; chuck. */
+               sigspecial3 = 1;
                l_ss = getc(fp);
                l_ss = getc(fp);
+               sigspecial3 = 0;
                if (l_ss == EOF) {
                        if (add_flag) {
                                l_text[l_nn++] = '\0';
                if (l_ss == EOF) {
                        if (add_flag) {
                                l_text[l_nn++] = '\0';
@@ -79,7 +78,7 @@ input_lines(fp, errnum)
                        }
                        break;
                }
                        }
                        break;
                }
-               if ((!l_ss) || (l_ss > 127))
+               if (!l_ss) /* 8-bit okay, but NULL not */
                        continue;
                l_text[l_nn++] = (char)l_ss;
                if (l_ss == '\n') {
                        continue;
                l_text[l_nn++] = (char)l_ss;
                if (l_ss == '\n') {
@@ -89,7 +88,7 @@ input_lines(fp, errnum)
                        if ((l_nn == 2) && (l_text[0] == '.') && add_flag)
                                break;
 eof_mk:
                        if ((l_nn == 2) && (l_text[0] == '.') && add_flag)
                                break;
 eof_mk:
-                       nn_max_end = malloc(sizeof(LINE));
+                       nn_max_end = (LINE *)malloc(sizeof(LINE));
                        if (nn_max_end == NULL) {
                                *errnum = -1;
                                strcpy(help_msg, "out of memory error");
                        if (nn_max_end == NULL) {
                                *errnum = -1;
                                strcpy(help_msg, "out of memory error");
@@ -139,10 +138,10 @@ point:    current = nn_max_end;
                }
        change_flag = 1;
        sigspecial--;
                }
        change_flag = 1;
        sigspecial--;
+       sigspecial3 = 0;
        if (sigint_flag && (!sigspecial))
                SIGINT_ACTION;
        *errnum = 1;
        ss = l_ss;
        if (sigint_flag && (!sigspecial))
                SIGINT_ACTION;
        *errnum = 1;
        ss = l_ss;
-       sigspecial = 0;
        return (l_ttl);
 }
        return (l_ttl);
 }
index 811dc9d..5850e5f 100644 (file)
@@ -9,20 +9,19 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)main.c     5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.5 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 #include <sys/ioctl.h>
 
 #endif /* not lint */
 
 #include <sys/types.h>
 #include <sys/ioctl.h>
 
-#include <limits.h>
 #include <regex.h>
 #include <setjmp.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <regex.h>
 #include <setjmp.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
+#include <limits.h>
 
 #ifdef DBI
 #include <db.h>
 
 #ifdef DBI
 #include <db.h>
@@ -71,8 +70,8 @@ int ss; /* for the getc() */
 int explain_flag=1, g_flag=0, GV_flag=0, printsfx=0;
 long change_flag=0L;
 int line_length;
 int explain_flag=1, g_flag=0, GV_flag=0, printsfx=0;
 long change_flag=0L;
 int line_length;
-jmp_buf ctrl_position, ctrl_position2; /* For SIGnal handling. */
-int sigint_flag, sighup_flag, sigspecial=0, sigspecial2=0;
+jmp_buf ctrl_position, ctrl_position2, ctrl_position3; /* For SIGnal handling. */
+int sigint_flag, sighup_flag, sigspecial=0, sigspecial2=0, sigspecial3=0;
 
 static void sigint_handler __P((int));
 static void sighup_handler __P((int));
 
 static void sigint_handler __P((int));
 static void sighup_handler __P((int));
@@ -539,9 +538,13 @@ sigint_handler(signo)
        int signo;
 {
        sigint_flag = 1;
        int signo;
 {
        sigint_flag = 1;
+       if (sigspecial3) {
+               sigspecial3 = 0;
+               SIGINT_ILACTION;
+       }
        if (sigspecial2) {
                sigspecial2 = 0;
        if (sigspecial2) {
                sigspecial2 = 0;
-               SIGINT_ILACTION;
+               SIGINT_ALACTION;
        }
        else
                if (sigspecial);
        }
        else
                if (sigspecial);