diff options
| author | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-09-16 01:46:36 +0000 |
|---|---|---|
| committer | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2003-09-16 01:46:36 +0000 |
| commit | 06cbc471880cb5ea8f3293eaaa0f0a4b0b49580f (patch) | |
| tree | a64e6ce8f21b19abda79932248d3439ed3e016e5 | |
| parent | e34d493f7529a6ba67b57ae331f920fa3db2a789 (diff) | |
| download | busybox-w32-06cbc471880cb5ea8f3293eaaa0f0a4b0b49580f.tar.gz busybox-w32-06cbc471880cb5ea8f3293eaaa0f0a4b0b49580f.tar.bz2 busybox-w32-06cbc471880cb5ea8f3293eaaa0f0a4b0b49580f.zip | |
Fix a bug that creapt in recently with substitution subprinting, and add
a test for it.
git-svn-id: svn://busybox.net/trunk/busybox@7534 69ca8d6d-28ef-0310-b511-8ec308f3f277
| -rw-r--r-- | editors/sed.c | 5 | ||||
| -rw-r--r-- | testsuite/sed/sed-subst-subprint | 9 |
2 files changed, 11 insertions, 3 deletions
diff --git a/editors/sed.c b/editors/sed.c index da15c4d06..a5a9d41a0 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
| @@ -914,7 +914,6 @@ static void process_file(FILE * file) | |||
| 914 | #endif | 914 | #endif |
| 915 | /* we print the pattern_space once, unless we were told to be quiet */ | 915 | /* we print the pattern_space once, unless we were told to be quiet */ |
| 916 | substituted |= do_subst_command(sed_cmd, &pattern_space); | 916 | substituted |= do_subst_command(sed_cmd, &pattern_space); |
| 917 | |||
| 918 | #ifdef CONFIG_FEATURE_SED_EMBEDED_NEWLINE | 917 | #ifdef CONFIG_FEATURE_SED_EMBEDED_NEWLINE |
| 919 | /* undo HACK: escape newlines twice so regex can match them */ | 918 | /* undo HACK: escape newlines twice so regex can match them */ |
| 920 | { | 919 | { |
| @@ -930,10 +929,10 @@ static void process_file(FILE * file) | |||
| 930 | || (sed_cmd->next->cmd != 's'))) { | 929 | || (sed_cmd->next->cmd != 's'))) { |
| 931 | force_print = 1; | 930 | force_print = 1; |
| 932 | } | 931 | } |
| 933 | |||
| 934 | /* we also print the line if we were given the 'p' flag | 932 | /* we also print the line if we were given the 'p' flag |
| 935 | * (this is quite possibly the second printing) */ | 933 | * (this is quite possibly the second printing) */ |
| 936 | if ((sed_cmd->sub_p) && altered) { | 934 | // if ((sed_cmd->sub_p) && (!altered || substituted)) { |
| 935 | if ((sed_cmd->sub_p) && (altered || substituted)) { | ||
| 937 | puts(pattern_space); | 936 | puts(pattern_space); |
| 938 | } | 937 | } |
| 939 | break; | 938 | break; |
diff --git a/testsuite/sed/sed-subst-subprint b/testsuite/sed/sed-subst-subprint new file mode 100644 index 000000000..24f8bad7d --- /dev/null +++ b/testsuite/sed/sed-subst-subprint | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | busybox sed 's/foo/bar/p'>output <<EOF | ||
| 2 | foo | ||
| 3 | bar | ||
| 4 | EOF | ||
| 5 | cmp -s output - <<EOF | ||
| 6 | bar | ||
| 7 | bar | ||
| 8 | bar | ||
| 9 | EOF | ||
