From f56850a73c001eee730d4122335278c35adc9678 Mon Sep 17 00:00:00 2001 From: kraai Date: Mon, 1 Apr 2002 16:17:37 +0000 Subject: * editors/sed.c (process_file): Stop processing deleted lines. * testsuite/sed/sed-does-not-substitute-in-delete-line: New. git-svn-id: svn://busybox.net/trunk/busybox@4514 69ca8d6d-28ef-0310-b511-8ec308f3f277 --- editors/sed.c | 5 +++++ testsuite/sed/sed-does-not-substitute-in-deleted-line | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 testsuite/sed/sed-does-not-substitute-in-deleted-line diff --git a/editors/sed.c b/editors/sed.c index 31b9de055..5edcd482b 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -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 index 000000000..6f106e104 --- /dev/null +++ b/testsuite/sed/sed-does-not-substitute-in-deleted-line @@ -0,0 +1,2 @@ +echo foo | busybox sed -e /foo/d -e s/foo/bar/ >foo +cmp foo /dev/null -- cgit v1.2.3-55-g6feb