diff --git a/grep-2.5.1a-pcrewrap.patch b/grep-2.5.1a-pcrewrap.patch new file mode 100644 index 0000000..2f61f68 --- /dev/null +++ b/grep-2.5.1a-pcrewrap.patch @@ -0,0 +1,101 @@ +Fix https://bugzilla.redhat.com/show_bug.cgi?id=324781 +See the code comments for details. + +Lubomir Rintel + +--- grep-2.5.1a/src/search.c.pcrewrap 2008-10-01 16:38:20.000000000 +0200 ++++ grep-2.5.1a/src/search.c 2008-10-01 16:38:20.000000000 +0200 +@@ -1241,8 +1241,31 @@ + is just for performance improvement in pcre_exec. */ + int sub[300]; + +- int e = pcre_exec (cre, extra, buf, size, 0, 0, +- sub, sizeof sub / sizeof *sub); ++ char *line_buf = buf; ++ int line_size = 0; ++ int e = 0; ++ ++ /* PCRE can't limit the matching to space between newlines (i.e ++ [^a] will allways match newline, see pcreposix(3) for details), ++ therefore whe have to match each line in the buffer separately */ ++ do { ++ /* We're not at the of buffer or end of line, get another char */ ++ if (line_buf + line_size < buf + size && line_buf[line_size++] != eolbyte) { ++ continue; ++ } ++ ++ /* Match the part of buffer that constitutes a line */ ++ e = pcre_exec (cre, extra, line_buf, line_size - 1, 0, 0, ++ sub, sizeof sub / sizeof *sub); ++ ++ /* Don't try other lines if this one matched or returned an error */ ++ if (e != PCRE_ERROR_NOMATCH) ++ break; ++ ++ /* Wrap up */ ++ line_buf += line_size; ++ line_size = 0; ++ } while (line_buf < buf + size); + + if (e <= 0) + { +@@ -1261,8 +1284,8 @@ + else + { + /* Narrow down to the line we've found. */ +- char const *beg = buf + sub[0]; +- char const *end = buf + sub[1]; ++ char const *beg = line_buf + sub[0]; ++ char const *end = line_buf + sub[1]; + char const *buflim = buf + size; + char eol = eolbyte; + if (!exact) +--- grep-2.5.1a/tests/Makefile.am.pcrewrap 2008-10-01 16:47:01.000000000 +0200 ++++ grep-2.5.1a/tests/Makefile.am 2008-10-01 16:47:26.000000000 +0200 +@@ -4,7 +4,7 @@ + + TESTS = warning.sh khadafy.sh spencer1.sh bre.sh ere.sh \ + status.sh empty.sh options.sh backref.sh file.sh \ +- fmbtest.sh ++ fmbtest.sh pcrewrap.sh + EXTRA_DIST = $(TESTS) \ + khadafy.lines khadafy.regexp \ + spencer1.awk spencer1.tests \ +--- grep-2.5.1a/tests/Makefile.in.pcrewrap 2008-10-01 16:47:01.000000000 +0200 ++++ grep-2.5.1a/tests/Makefile.in 2008-10-01 16:47:34.000000000 +0200 +@@ -98,7 +98,7 @@ + + TESTS = warning.sh khadafy.sh spencer1.sh bre.sh ere.sh \ + status.sh empty.sh options.sh backref.sh file.sh \ +- fmbtest.sh ++ fmbtest.sh pcrewrap.sh + + EXTRA_DIST = $(TESTS) \ + khadafy.lines khadafy.regexp \ +--- grep-2.5.1a/tests/pcrewrap.sh 2008-09-30 09:16:44.037543374 +0200 ++++ grep-2.5.1a/tests/pcrewrap.sh 2008-10-01 16:45:45.000000000 +0200 +@@ -0,0 +1,23 @@ ++#!/bin/sh ++# Test for bug https://bugzilla.redhat.com/show_bug.cgi?id=324781 ++# Lubomir Rintel ++ ++: ${srcdir=.} ++ ++failures=0 ++ ++echo -ne "a\na" | ${GREP} -P '[^a]' > /dev/null 2>&1 ++if test $? -ne 1 ++then ++ echo "PCRE Wrap: Wrong status code, test \#1 failed" ++ failures=1 ++fi ++ ++echo -ne "a\na" | ${GREP} -P '[^b].[^b]' > /dev/null 2>&1 ++if test $? -ne 1 ++then ++ echo "PCRE Wrap: Wrong status code, test \#2 failed" ++ failures=1 ++fi ++ ++exit $failures + diff --git a/grep-2.5.1a-utf8.patch b/grep-2.5.1a-utf8.patch new file mode 100644 index 0000000..fd55f6a --- /dev/null +++ b/grep-2.5.1a-utf8.patch @@ -0,0 +1,14 @@ +From latin1 to utf8 + +diff -up grep-2.5.1a/AUTHORS.utf8 grep-2.5.1a/AUTHORS +--- grep-2.5.1a/AUTHORS.utf8 2008-10-01 18:42:53.000000000 +0200 ++++ grep-2.5.1a/AUTHORS 2008-10-01 18:43:12.000000000 +0200 +@@ -40,7 +40,7 @@ send me email. + + Alain Magloire maintained GNU grep until version 2.5e. + +-Bernhard "Bero" Rosenkr�nzer maintained GNU grep until ++Bernhard "Bero" Rosenkränzer maintained GNU grep until + version 2.5.1, ie. from Sep 2001 till 2003. + + Stepan Kasal maintains GNU grep since Feb 2004. diff --git a/grep.spec b/grep.spec index 637db49..8132541 100644 --- a/grep.spec +++ b/grep.spec @@ -1,10 +1,10 @@ Summary: The GNU versions of grep pattern matching utilities Name: grep -Version: 2.5.1 -Release: 60%{?dist} +Version: 2.5.1a +Release: 61%{?dist} License: GPLv2+ Group: Applications/Text -Source: ftp://ftp.gnu.org/pub/gnu/grep/grep-%{version}a.tar.bz2 +Source: ftp://ftp.gnu.org/pub/gnu/grep/grep-%{version}.tar.bz2 Patch0: grep-2.5.1-fgrep.patch Patch1: grep-2.5.1-bracket.patch Patch2: grep-2.5-i18n.patch @@ -20,6 +20,8 @@ Patch13: grep-2.5.1-w.patch Patch14: grep-P.patch Patch15: grep-mem-exhausted.patch Patch16: grep-empty-pattern.patch +Patch17: grep-2.5.1a-pcrewrap.patch +Patch18: grep-2.5.1a-utf8.patch URL: http://www.gnu.org/software/grep/ Requires(post): /sbin/install-info Requires(preun): /sbin/install-info @@ -36,7 +38,7 @@ You should install grep on your system, because it is a very useful utility for searching through text. %prep -%setup -q -n %{name}-%{version}a +%setup -q %patch0 -p1 -b .fgrep %patch1 -p1 -b .bracket %patch2 -p1 -b .i18n @@ -52,7 +54,10 @@ utility for searching through text. %patch14 -p1 -b .P %patch15 -p1 -b .mem-exhausted %patch16 -p1 -b .empty-pattern +%patch17 -p1 -b .pcrewrap +%patch18 -p1 -b .utf8 chmod a+x tests/fmbtest.sh +chmod a+x tests/pcrewrap.sh %build [ ! -e configure ] && ./autogen.sh @@ -103,6 +108,11 @@ fi %{_mandir}/*/* %changelog +* Wed Oct 1 2008 Lubomir Rintel 2.5.1a-61 +- Fix pcre-mode (-P) line wrapping (bug #324781) +- Match the version with upstream +- Recode AUTHORS to utf8 + * Fri Jul 25 2008 Tom "spot" Callaway - 2.5.1-60 - fix license tag