aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-01-11 22:01:44 -0600
committerRob Landley <rob@landley.net>2019-01-11 22:01:44 -0600
commit1f0cfeef3ca3421ca6dc4b1fdbd6aa3bc3087302 (patch)
tree9a4b9a245a988e83d07c7dcf6e22b6dd9d164cae
parent323779dde2a48b99f90f66670dec72f0bd31213a (diff)
downloadtoybox-1f0cfeef3ca3421ca6dc4b1fdbd6aa3bc3087302.tar.gz
Fix b ending with }
For a definition of "fix" that's even _more_ of a deviation from posix, but matches what debian does...
-rwxr-xr-xtests/sed.test8
-rw-r--r--toys/posix/sed.c2
2 files changed, 6 insertions, 4 deletions
diff --git a/tests/sed.test b/tests/sed.test
index 154b36a0..a7d5a6eb 100755
--- a/tests/sed.test
+++ b/tests/sed.test
@@ -2,9 +2,6 @@
#testing "name" "command" "result" "infile" "stdin"
-# toybox saying "no }" here broke the AOSP build.
-testing "Braces" "sed -n '/START/{:a;n;/END/q;p;ba}'" "b\nc\n" "" "a\nSTART\nb\nc\nEND\nd"
-
testing 'as cat' 'sed ""' "one\ntwo\nthree" "" "one\ntwo\nthree"
# This segfaults ubuntu 12.04's sed. No really.
SKIP_HOST=1 testing 'sed - - twice' 'sed "" - -' "hello\n" "" "hello\n"
@@ -163,4 +160,9 @@ testing "skip start of range" "sed -e n -e '1,2s/b/c/'" "a\nb\n" "" "a\nb\n"
testing "bonus backslashes" \
"sed -e 'a \l \x\' -e \"\$(echo -e 'ab\\\nc')\"" \
"hello\nl x\nab\nc\n" "" "hello\n"
+
+# toybox saying "no }" here broke the AOSP build.
+testing "end b with }" "sed -n '/START/{:a;n;/END/q;p;ba}'" "b\nc\n" \
+ "" "a\nSTART\nb\nc\nEND\nd"
+
# -i with $ last line test
diff --git a/toys/posix/sed.c b/toys/posix/sed.c
index 3073a69c..bab6fb00 100644
--- a/toys/posix/sed.c
+++ b/toys/posix/sed.c
@@ -944,7 +944,7 @@ resume_a:
command->hit = 0;
// btT: end with space or semicolon, aicrw continue to newline.
- if (!(end = strcspn(line, strchr(":btT", c) ? "; \t\r\n\v\f" : "\n"))) {
+ if (!(end = strcspn(line, strchr(":btT", c) ? "}; \t\r\n\v\f" : "\n"))) {
// Argument's optional for btT
if (strchr("btT", c)) continue;
else if (!command->arg1) break;