summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core
diff options
context:
space:
mode:
authorDengke Du <dengke.du@windriver.com>2016-09-01 05:42:10 -0400
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-03 23:45:54 +0100
commit08acf585720c1a2d925a7b85f21d98a854447277 (patch)
tree45695e096dd636809b0b5f9913f881595dd9cda6 /meta/recipes-core
parent104eb5794aa94b3c67f006cd9fdb49dd2b67aab9 (diff)
downloadpoky-08acf585720c1a2d925a7b85f21d98a854447277.tar.gz
busybox: fix "sed n (flushes pattern space, terminates early)" testcase failure
It is a busybox upstream known bug. When the busybox sed sub-command 'n' hit the files EOF, it print an extra character that have been printed, but the GNU sed would not print it. In busybox source code ../editors/sed.c ------------------------------------------------------------------------ case 'n': if (!G.be_quiet) sed_puts(pattern_space, last_gets_char); if (next_line) { free(pattern_space); pattern_space = next_line; last_gets_char = next_gets_char; next_line = get_next_line(&next_gets_char, &last_puts_char, last_gets_char); substituted = 0; linenum++; break; } /* fall through */ /* Quit. End of script, end of input. */ case 'q': /* Exit the outer while loop */ free(next_line); next_line = NULL; goto discard_commands; ------------------------------------------------------------------------ when read at the end of the file, the 'next_line' is null, it would go "case 'q'" and goto discard_commands, the discard_commands would print the old pattern space which have been printed. So in order to comply with GNU sed, in case 'n', when the next_line is null I add "else" at the end of the second "if": "goto again;" and send it to the busybox upstream, the busybox maintainer adopt it and make a little changes to the patch, we can see it at: His reply: http://lists.busybox.net/pipermail/busybox/2016-September/084613.html The new patch on busybox master branch: https://git.busybox.net/busybox/commit/?id=76d72376e0244a5cafd4880cdc623e37d86a75e4 (From OE-Core rev: 5a680c267454d7c135c4bfe4e551a780f38a5087) Signed-off-by: Dengke Du <dengke.du@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-core')
-rw-r--r--meta/recipes-core/busybox/busybox/0001-sed-fix-sed-n-flushes-pattern-space-terminates-early.patch72
-rw-r--r--meta/recipes-core/busybox/busybox_1.24.1.bb1
2 files changed, 73 insertions, 0 deletions
diff --git a/meta/recipes-core/busybox/busybox/0001-sed-fix-sed-n-flushes-pattern-space-terminates-early.patch b/meta/recipes-core/busybox/busybox/0001-sed-fix-sed-n-flushes-pattern-space-terminates-early.patch
new file mode 100644
index 0000000000..4f539848cb
--- /dev/null
+++ b/meta/recipes-core/busybox/busybox/0001-sed-fix-sed-n-flushes-pattern-space-terminates-early.patch
@@ -0,0 +1,72 @@
1From 903542f7331c58007a3ef938d41e1c55fc329648 Mon Sep 17 00:00:00 2001
2From: Dengke Du <dengke.du@windriver.com>
3Date: Wed, 31 Aug 2016 23:40:43 -0400
4Subject: [PATCH] sed: fix "sed n (flushes pattern space, terminates early)"
5 testcase failure
6
7This patch fix "sed n (flushes pattern space, terminates early)"
8testcase failure. We can see it at:
9
10 https://git.busybox.net/busybox/commit/?id=76d72376e0244a5cafd4880cdc623e37d86a75e4
11
12Upstream-Status: Backport
13
14Signed-off-by: Dengke Du <dengke.du@windriver.com>
15---
16 editors/sed.c | 19 ++++++++++---------
17 testsuite/sed.tests | 6 +-----
18 2 files changed, 11 insertions(+), 14 deletions(-)
19
20diff --git a/editors/sed.c b/editors/sed.c
21index 7bbf820..259c39c 100644
22--- a/editors/sed.c
23+++ b/editors/sed.c
24@@ -1274,16 +1274,17 @@ static void process_files(void)
25 case 'n':
26 if (!G.be_quiet)
27 sed_puts(pattern_space, last_gets_char);
28- if (next_line) {
29- free(pattern_space);
30- pattern_space = next_line;
31- last_gets_char = next_gets_char;
32- next_line = get_next_line(&next_gets_char, &last_puts_char, last_gets_char);
33- substituted = 0;
34- linenum++;
35- break;
36+ if (next_line == NULL) {
37+ /* If no next line, jump to end of script and exit. */
38+ goto discard_line;
39 }
40- /* fall through */
41+ free(pattern_space);
42+ pattern_space = next_line;
43+ last_gets_char = next_gets_char;
44+ next_line = get_next_line(&next_gets_char, &last_puts_char, last_gets_char);
45+ substituted = 0;
46+ linenum++;
47+ break;
48
49 /* Quit. End of script, end of input. */
50 case 'q':
51diff --git a/testsuite/sed.tests b/testsuite/sed.tests
52index 34479e5..96ff7a5 100755
53--- a/testsuite/sed.tests
54+++ b/testsuite/sed.tests
55@@ -73,13 +73,9 @@ testing "sed t (test/branch clears test bit)" "sed -e 's/a/b/;:loop;t loop'" \
56 testing "sed T (!test/branch)" "sed -e 's/a/1/;T notone;p;: notone;p'" \
57 "1\n1\n1\nb\nb\nc\nc\n" "" "a\nb\nc\n"
58
59-test x"$SKIP_KNOWN_BUGS" = x"" && {
60-# Normal sed end-of-script doesn't print "c" because n flushed the pattern
61-# space. If n hits EOF, pattern space is empty when script ends.
62-# Query: how does this interact with no newline at EOF?
63 testing "sed n (flushes pattern space, terminates early)" "sed -e 'n;p'" \
64 "a\nb\nb\nc\n" "" "a\nb\nc\n"
65-}
66+
67 # non-GNU sed: N does _not_ flush pattern space, therefore c is eaten @ script end
68 # GNU sed: N flushes pattern space, therefore c is printed too @ script end
69 testing "sed N (flushes pattern space (GNU behavior))" "sed -e 'N;p'" \
70--
712.8.1
72
diff --git a/meta/recipes-core/busybox/busybox_1.24.1.bb b/meta/recipes-core/busybox/busybox_1.24.1.bb
index e8265cd9f5..f370451a3c 100644
--- a/meta/recipes-core/busybox/busybox_1.24.1.bb
+++ b/meta/recipes-core/busybox/busybox_1.24.1.bb
@@ -50,6 +50,7 @@ SRC_URI = "http://www.busybox.net/downloads/busybox-${PV}.tar.bz2;name=tarball \
50 file://ip_fix_problem_on_mips64_n64_big_endian_musl_systems.patch \ 50 file://ip_fix_problem_on_mips64_n64_big_endian_musl_systems.patch \
51 file://makefile-fix-backport.patch \ 51 file://makefile-fix-backport.patch \
52 file://parallel-make-fix.patch \ 52 file://parallel-make-fix.patch \
53 file://0001-sed-fix-sed-n-flushes-pattern-space-terminates-early.patch \
53" 54"
54SRC_URI_append_libc-musl = " file://musl.cfg " 55SRC_URI_append_libc-musl = " file://musl.cfg "
55 56