diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-28 17:59:01 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-02-28 17:59:01 +0000 |
commit | f39c7c0c86d9f263f372be7c305bffa51af3c21e (patch) | |
tree | 2cc58af337e3c01d04ad27126a890422af2283f6 | |
parent | cd174d1f31632884b717eba69048d338605e7e70 (diff) | |
download | busybox-w32-f39c7c0c86d9f263f372be7c305bffa51af3c21e.tar.gz busybox-w32-f39c7c0c86d9f263f372be7c305bffa51af3c21e.tar.bz2 busybox-w32-f39c7c0c86d9f263f372be7c305bffa51af3c21e.zip |
sed: n cmd must reset "we had successful subst" flag. closes bug 1214.
-rw-r--r-- | editors/sed.c | 5 | ||||
-rwxr-xr-x | testsuite/sed.tests | 6 |
2 files changed, 9 insertions, 2 deletions
diff --git a/editors/sed.c b/editors/sed.c index e55bcafc4..c2b9e94b6 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -865,7 +865,7 @@ static void process_files(void) | |||
865 | next_line = get_next_line(&next_gets_char); | 865 | next_line = get_next_line(&next_gets_char); |
866 | 866 | ||
867 | /* go through every line in each file */ | 867 | /* go through every line in each file */ |
868 | again: | 868 | again: |
869 | substituted = 0; | 869 | substituted = 0; |
870 | 870 | ||
871 | /* Advance to next line. Stop if out of lines. */ | 871 | /* Advance to next line. Stop if out of lines. */ |
@@ -877,7 +877,7 @@ again: | |||
877 | * the '$' address */ | 877 | * the '$' address */ |
878 | next_line = get_next_line(&next_gets_char); | 878 | next_line = get_next_line(&next_gets_char); |
879 | linenum++; | 879 | linenum++; |
880 | restart: | 880 | restart: |
881 | /* for every line, go through all the commands */ | 881 | /* for every line, go through all the commands */ |
882 | for (sed_cmd = G.sed_cmd_head.next; sed_cmd; sed_cmd = sed_cmd->next) { | 882 | for (sed_cmd = G.sed_cmd_head.next; sed_cmd; sed_cmd = sed_cmd->next) { |
883 | int old_matched, matched; | 883 | int old_matched, matched; |
@@ -1053,6 +1053,7 @@ restart: | |||
1053 | pattern_space = next_line; | 1053 | pattern_space = next_line; |
1054 | last_gets_char = next_gets_char; | 1054 | last_gets_char = next_gets_char; |
1055 | next_line = get_next_line(&next_gets_char); | 1055 | next_line = get_next_line(&next_gets_char); |
1056 | substituted = 0; | ||
1056 | linenum++; | 1057 | linenum++; |
1057 | break; | 1058 | break; |
1058 | } | 1059 | } |
diff --git a/testsuite/sed.tests b/testsuite/sed.tests index 7471ed5fc..4cdbaa687 100755 --- a/testsuite/sed.tests +++ b/testsuite/sed.tests | |||
@@ -201,4 +201,10 @@ testing "sed s/xxx/[/" "sed -e 's/xxx/[/'" "[\n" "" "xxx\n" | |||
201 | #testing "sed -g (exhaustive)" "sed -e 's/[[:space:]]*/,/g'" ",1,2,3,4,5," \ | 201 | #testing "sed -g (exhaustive)" "sed -e 's/[[:space:]]*/,/g'" ",1,2,3,4,5," \ |
202 | # "" "12345" | 202 | # "" "12345" |
203 | 203 | ||
204 | # testing "description" "arguments" "result" "infile" "stdin" | ||
205 | |||
206 | testing "sed n command must reset 'substituted' bit" \ | ||
207 | "sed 's/1/x/;T;n;: next;s/3/y/;t quit;n;b next;: quit;q'" \ | ||
208 | "0\nx\n2\ny\n" "" "0\n1\n2\n3\n" | ||
209 | |||
204 | exit $FAILCOUNT | 210 | exit $FAILCOUNT |