Gentoo Archives: gentoo-commits

From: Mike Frysinger <vapier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-apps/grep/files/, sys-apps/grep/
Date: Tue, 27 Dec 2016 23:05:01
Message-Id: 1482879876.31c16e6d30301f4f5076e9f598a2271b82136621.vapier@gentoo
1 commit: 31c16e6d30301f4f5076e9f598a2271b82136621
2 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
3 AuthorDate: Tue Dec 27 23:04:30 2016 +0000
4 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
5 CommitDate: Tue Dec 27 23:04:36 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=31c16e6d
7
8 sys-apps/grep: add upstream fix for splice errors
9
10 sys-apps/grep/files/grep-2.27-splice.patch | 60 ++++++++++++++++++++++
11 .../grep/{grep-2.27.ebuild => grep-2.27-r1.ebuild} | 1 +
12 2 files changed, 61 insertions(+)
13
14 diff --git a/sys-apps/grep/files/grep-2.27-splice.patch b/sys-apps/grep/files/grep-2.27-splice.patch
15 new file mode 100644
16 index 00000000..6c36fe0
17 --- /dev/null
18 +++ b/sys-apps/grep/files/grep-2.27-splice.patch
19 @@ -0,0 +1,60 @@
20 +http://lists.gnu.org/archive/html/bug-grep/2016-12/msg00036.html
21 +
22 +From 7ad47abbcb070946000771a829b51224720b8cef Mon Sep 17 00:00:00 2001
23 +From: Paul Eggert <eggert@×××××××.edu>
24 +Date: Tue, 27 Dec 2016 11:16:32 -0800
25 +Subject: [PATCH] grep: fix bug with '... | grep pat >> /dev/null'
26 +MIME-Version: 1.0
27 +Content-Type: text/plain; charset=UTF-8
28 +Content-Transfer-Encoding: 8bit
29 +
30 +Problem reported by Benno Fünfstück (Bug#25283).
31 +* NEWS: Document this.
32 +* src/grep.c (drain_input) [SPLICE_F_MOVE]:
33 +Don't assume /dev/null is always acceptable output to splice.
34 +* tests/grep-dev-null-out: Test for the bug.
35 +---
36 + NEWS | 7 ++++---
37 + src/grep.c | 14 +++++++++-----
38 + tests/grep-dev-null-out | 2 ++
39 + 3 files changed, 15 insertions(+), 8 deletions(-)
40 +
41 +diff --git a/src/grep.c b/src/grep.c
42 +index f28f3c287609..aebab2060308 100644
43 +--- a/src/grep.c
44 ++++ b/src/grep.c
45 +@@ -1728,11 +1728,15 @@ drain_input (int fd, struct stat const *st)
46 + {
47 + #ifdef SPLICE_F_MOVE
48 + /* Should be faster, since it need not copy data to user space. */
49 +- while ((nbytes = splice (fd, NULL, STDOUT_FILENO, NULL,
50 +- INITIAL_BUFSIZE, SPLICE_F_MOVE)))
51 +- if (nbytes < 0)
52 +- return false;
53 +- return true;
54 ++ nbytes = splice (fd, NULL, STDOUT_FILENO, NULL,
55 ++ INITIAL_BUFSIZE, SPLICE_F_MOVE);
56 ++ if (0 <= nbytes || errno != EINVAL)
57 ++ {
58 ++ while (0 < nbytes)
59 ++ nbytes = splice (fd, NULL, STDOUT_FILENO, NULL,
60 ++ INITIAL_BUFSIZE, SPLICE_F_MOVE);
61 ++ return nbytes == 0;
62 ++ }
63 + #endif
64 + }
65 + while ((nbytes = safe_read (fd, buffer, bufalloc)))
66 +diff --git a/tests/grep-dev-null-out b/tests/grep-dev-null-out
67 +index 13a4843957a6..c8128d5cc6a4 100755
68 +--- a/tests/grep-dev-null-out
69 ++++ b/tests/grep-dev-null-out
70 +@@ -8,4 +8,6 @@ require_timeout_
71 + ${AWK-awk} 'BEGIN {while (1) print "x"}' </dev/null |
72 + returns_ 124 timeout 1 grep x >/dev/null || fail=1
73 +
74 ++echo abc | grep b >>/dev/null || fail=1
75 ++
76 + Exit $fail
77 +--
78 +2.11.0
79 +
80
81 diff --git a/sys-apps/grep/grep-2.27.ebuild b/sys-apps/grep/grep-2.27-r1.ebuild
82 similarity index 97%
83 rename from sys-apps/grep/grep-2.27.ebuild
84 rename to sys-apps/grep/grep-2.27-r1.ebuild
85 index 845de1d..f294f20 100644
86 --- a/sys-apps/grep/grep-2.27.ebuild
87 +++ b/sys-apps/grep/grep-2.27-r1.ebuild
88 @@ -28,6 +28,7 @@ DEPEND="${RDEPEND}
89 DOCS=( AUTHORS ChangeLog NEWS README THANKS TODO )
90
91 src_prepare() {
92 + epatch "${FILESDIR}"/${P}-splice.patch
93 sed -i \
94 -e "s:@SHELL@:${EPREFIX}/bin/sh:g" \
95 src/egrep.sh || die #523898