Applied patch from Anthony Towns that he posted to Debian bug tracking.
authorMark Whitley <markw@lineo.com>
Mon, 26 Mar 2001 16:47:57 +0000 (16:47 -0000)
committerMark Whitley <markw@lineo.com>
Mon, 26 Mar 2001 16:47:57 +0000 (16:47 -0000)
editors/sed.c
sed.c

index a18f6e5222033abe76c542d23b9b3db7e28f4db7..897c290d5cf73ce6b23420ab856ebe798787aad4 100644 (file)
@@ -622,9 +622,10 @@ static void process_file(FILE *file)
                        if (sed_cmds[i].beg_match && sed_cmds[i].end_match) {
                                if (still_in_range || regexec(sed_cmds[i].beg_match, line, 0, NULL, 0) == 0) {
                                        line_altered += do_sed_command(&sed_cmds[i], line);
-                                       still_in_range = 1; 
-                                       if (regexec(sed_cmds[i].end_match, line, 0, NULL, 0) == 0)
+                                       if (still_in_range && regexec(sed_cmds[i].end_match, line, 0, NULL, 0) == 0)
                                                still_in_range = 0;
+                                       else
+                                               still_in_range = 1;
                                }
                        }
 
diff --git a/sed.c b/sed.c
index a18f6e5222033abe76c542d23b9b3db7e28f4db7..897c290d5cf73ce6b23420ab856ebe798787aad4 100644 (file)
--- a/sed.c
+++ b/sed.c
@@ -622,9 +622,10 @@ static void process_file(FILE *file)
                        if (sed_cmds[i].beg_match && sed_cmds[i].end_match) {
                                if (still_in_range || regexec(sed_cmds[i].beg_match, line, 0, NULL, 0) == 0) {
                                        line_altered += do_sed_command(&sed_cmds[i], line);
-                                       still_in_range = 1; 
-                                       if (regexec(sed_cmds[i].end_match, line, 0, NULL, 0) == 0)
+                                       if (still_in_range && regexec(sed_cmds[i].end_match, line, 0, NULL, 0) == 0)
                                                still_in_range = 0;
+                                       else
+                                               still_in_range = 1;
                                }
                        }