diff options
| author | Matt Kraai <kraai@debian.org> | 2002-04-01 16:17:37 +0000 |
|---|---|---|
| committer | Matt Kraai <kraai@debian.org> | 2002-04-01 16:17:37 +0000 |
| commit | 5c69cd84ffe92b3b51d1ca766c34b5cd028dd0ca (patch) | |
| tree | 7a6647361bb85fdf621cab6e222b07643b8e905d | |
| parent | 75ce8d7c8886886a2852ccfc44a962f43e1e8a71 (diff) | |
| download | busybox-w32-5c69cd84ffe92b3b51d1ca766c34b5cd028dd0ca.tar.gz busybox-w32-5c69cd84ffe92b3b51d1ca766c34b5cd028dd0ca.tar.bz2 busybox-w32-5c69cd84ffe92b3b51d1ca766c34b5cd028dd0ca.zip | |
* editors/sed.c (process_file): Stop processing deleted lines.
* testsuite/sed/sed-does-not-substitute-in-delete-line: New.
| -rw-r--r-- | editors/sed.c | 5 | ||||
| -rw-r--r-- | testsuite/sed/sed-does-not-substitute-in-deleted-line | 2 |
2 files changed, 7 insertions, 0 deletions
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) | |||
| 659 | /* we are currently within the beginning & ending address range */ | 659 | /* we are currently within the beginning & ending address range */ |
| 660 | still_in_range | 660 | still_in_range |
| 661 | ) { | 661 | ) { |
| 662 | int deleted = 0; | ||
| 662 | 663 | ||
| 663 | /* | 664 | /* |
| 664 | * actual sedding | 665 | * actual sedding |
| @@ -671,6 +672,7 @@ static void process_file(FILE *file) | |||
| 671 | 672 | ||
| 672 | case 'd': | 673 | case 'd': |
| 673 | altered++; | 674 | altered++; |
| 675 | deleted = 1; | ||
| 674 | break; | 676 | break; |
| 675 | 677 | ||
| 676 | case 's': | 678 | case 's': |
| @@ -772,6 +774,9 @@ static void process_file(FILE *file) | |||
| 772 | else { | 774 | else { |
| 773 | still_in_range = 1; | 775 | still_in_range = 1; |
| 774 | } | 776 | } |
| 777 | |||
| 778 | if (deleted) | ||
| 779 | break; | ||
| 775 | } | 780 | } |
| 776 | } | 781 | } |
| 777 | 782 | ||
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 @@ | |||
| 1 | echo foo | busybox sed -e /foo/d -e s/foo/bar/ >foo | ||
| 2 | cmp foo /dev/null | ||
