some lint, some bug fixes, ^C handling improvements
[unix-history] / usr / src / contrib / ed / m.c
index 681106a..a28a448 100644 (file)
@@ -9,17 +9,20 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)m.c        5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)m.c        5.3 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/types.h>
 
 #endif /* not lint */
 
 #include <sys/types.h>
 
-#include <db.h>
 #include <regex.h>
 #include <setjmp.h>
 #include <stdio.h>
 #include <string.h>
 
 #include <regex.h>
 #include <setjmp.h>
 #include <stdio.h>
 #include <string.h>
 
+#ifdef DBI
+#include <db.h>
+#endif
+
 #include "ed.h"
 #include "extern.h"
 
 #include "ed.h"
 #include "extern.h"
 
@@ -32,7 +35,7 @@ m(inputt, errnum)
        FILE *inputt;
        int *errnum;
 {
        FILE *inputt;
        int *errnum;
 {
-       LINE *l_dest, *l_old_top, *l_old_bottom;
+       LINE *l_dest=NULL, *l_old_top, *l_old_bottom;
 
        /* Set l_dest here. */
        if (((ss = getc(inputt)) != '\n') && (ss != EOF)) {
 
        /* Set l_dest here. */
        if (((ss = getc(inputt)) != '\n') && (ss != EOF)) {
@@ -46,8 +49,6 @@ m(inputt, errnum)
                l_dest = address_conv(NULL, inputt, errnum);
        } else
                (ungetc(ss, inputt), *errnum = -1);
                l_dest = address_conv(NULL, inputt, errnum);
        } else
                (ungetc(ss, inputt), *errnum = -1);
-       if (sigint_flag)
-               SIGINT_ACTION;
        if (*errnum < 0) {
                strcpy(help_msg, "bad destination address");
                return;
        if (*errnum < 0) {
                strcpy(help_msg, "bad destination address");
                return;
@@ -62,13 +63,11 @@ m(inputt, errnum)
                if (start_default)
                        start = End;
        if (start == NULL) {
                if (start_default)
                        start = End;
        if (start == NULL) {
-               strcpy(help_msg, "bad address");
+               strcpy(help_msg, "buffer empty");
                *errnum = -1;
                return;
        }
        start_default = End_default = 0;
                *errnum = -1;
                return;
        }
        start_default = End_default = 0;
-       if (sigint_flag)
-               SIGINT_ACTION;
 
        /* Do some address checking. */
        if ((l_dest) && ((l_dest == start) ||
 
        /* Do some address checking. */
        if ((l_dest) && ((l_dest == start) ||
@@ -87,16 +86,20 @@ m(inputt, errnum)
         * Some more address checking. These are "legal" command constructions
         * but are kind-a useless since the buffer doesn't change.
         */
         * Some more address checking. These are "legal" command constructions
         * but are kind-a useless since the buffer doesn't change.
         */
+       *errnum = 1;
        if ((start == l_dest) || (End == l_dest))
                return;
        if ((start == top) && (End == bottom))
                return;
        if ((start == top) && (l_dest == NULL))
                return;
        if ((start == l_dest) || (End == l_dest))
                return;
        if ((start == top) && (End == bottom))
                return;
        if ((start == top) && (l_dest == NULL))
                return;
+       *errnum = 0;
 
        l_old_top = top;
        l_old_bottom = bottom;
 
 
        l_old_top = top;
        l_old_bottom = bottom;
 
+       sigspecial++;
+
        if (start == top) {
                top = End->below;
                u_add_stk(&(End->below->above));
        if (start == top) {
                top = End->below;
                u_add_stk(&(End->below->above));
@@ -145,5 +148,7 @@ m(inputt, errnum)
                l_dest->below = start;
        current = start;
 
                l_dest->below = start;
        current = start;
 
+       sigspecial--;
+
        *errnum = 1;
 }
        *errnum = 1;
 }