* editors/sed.c (process_file): Stop processing deleted lines.
authorMatt Kraai <kraai@debian.org>
Mon, 1 Apr 2002 16:17:37 +0000 (16:17 -0000)
committerMatt Kraai <kraai@debian.org>
Mon, 1 Apr 2002 16:17:37 +0000 (16:17 -0000)
* testsuite/sed/sed-does-not-substitute-in-delete-line: New.

editors/sed.c
testsuite/sed/sed-does-not-substitute-in-deleted-line [new file with mode: 0644]

index 31b9de0556046a954cab688db5891dc8aee97273..5edcd482babcf43ccb3e61d661471e2c8e182067 100644 (file)
@@ -659,6 +659,7 @@ static void process_file(FILE *file)
                                        /* we are currently within the beginning & ending address range */
                                        still_in_range
                           ) {
+                               int deleted = 0;
 
                                /*
                                 * actual sedding
@@ -671,6 +672,7 @@ static void process_file(FILE *file)
 
                                        case 'd':
                                                altered++;
+                                               deleted = 1;
                                                break;
 
                                        case 's':
@@ -772,6 +774,9 @@ static void process_file(FILE *file)
                                else {
                                        still_in_range = 1;
                                }
+
+                               if (deleted)
+                                       break;
                        }
                }
 
diff --git a/testsuite/sed/sed-does-not-substitute-in-deleted-line b/testsuite/sed/sed-does-not-substitute-in-deleted-line
new file mode 100644 (file)
index 0000000..6f106e1
--- /dev/null
@@ -0,0 +1,2 @@
+echo foo | busybox sed -e /foo/d -e s/foo/bar/ >foo
+cmp foo /dev/null