summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Redaelli <drizzt@gentoo.org>2006-11-01 21:24:36 +0000
committerTimothy Redaelli <drizzt@gentoo.org>2006-11-01 21:24:36 +0000
commit7858661f5751285ffdb552dad2f0d2c2ea908cff (patch)
tree0bf6e60be3324d74c6e6d5fe6b9e4393f58f1dd8 /sys-apps
parentAdded asterisk 1.4.0-beta3 (diff)
downloaddrizzt-7858661f5751285ffdb552dad2f0d2c2ea908cff.tar.gz
drizzt-7858661f5751285ffdb552dad2f0d2c2ea908cff.tar.bz2
drizzt-7858661f5751285ffdb552dad2f0d2c2ea908cff.zip
Added grep with -Z e -J freebsd patches
svn path=/; revision=19
Diffstat (limited to 'sys-apps')
-rw-r--r--sys-apps/grep/Manifest64
-rw-r--r--sys-apps/grep/files/2.5.1-tests.patch45
-rw-r--r--sys-apps/grep/files/2.5.1-utf8-case.patch29
-rw-r--r--sys-apps/grep/files/digest-grep-2.5.1a-r23
-rw-r--r--sys-apps/grep/files/grep-2.5.1-bracket.patch11
-rw-r--r--sys-apps/grep/files/grep-2.5.1-color.patch10
-rw-r--r--sys-apps/grep/files/grep-2.5.1-fgrep.patch196
-rw-r--r--sys-apps/grep/files/grep-2.5.1-fix-devices-skip.patch55
-rw-r--r--sys-apps/grep/files/grep-2.5.1-i18n.patch305
-rw-r--r--sys-apps/grep/files/grep-2.5.1-libintl.patch99
-rw-r--r--sys-apps/grep/files/grep-2.5.1-manpage.patch21
-rw-r--r--sys-apps/grep/files/grep-2.5.1-oi.patch50
-rw-r--r--sys-apps/grep/files/grep-2.5.1-perl-segv.patch19
-rw-r--r--sys-apps/grep/files/grep-2.5.1-restrict_arr.patch11
-rw-r--r--sys-apps/grep/files/grep-2.5.1a-nls.patch39
-rw-r--r--sys-apps/grep/files/grep-onthefly.patch395
-rw-r--r--sys-apps/grep/grep-2.5.1a-r2.ebuild75
17 files changed, 1427 insertions, 0 deletions
diff --git a/sys-apps/grep/Manifest b/sys-apps/grep/Manifest
new file mode 100644
index 0000000..d0af67b
--- /dev/null
+++ b/sys-apps/grep/Manifest
@@ -0,0 +1,64 @@
+AUX 2.5.1-tests.patch 1786 RMD160 a95b24ce9b2d8c395e7396bc3ed15ec73b09088c SHA1 3c7bc0ac1993a2b91864df17fa3162cdbd677082 SHA256 c2392469fba6a6c434295b277099d19fa2b7500f69e2383bfb68e06816835f18
+MD5 16d6cd54c93041d4f4bef59a9e327d04 files/2.5.1-tests.patch 1786
+RMD160 a95b24ce9b2d8c395e7396bc3ed15ec73b09088c files/2.5.1-tests.patch 1786
+SHA256 c2392469fba6a6c434295b277099d19fa2b7500f69e2383bfb68e06816835f18 files/2.5.1-tests.patch 1786
+AUX 2.5.1-utf8-case.patch 933 RMD160 1619e4b6710047049e5776a45732b2709b117cfa SHA1 51c9ea9363370041b2c0a9b7dcc83bfd739a4723 SHA256 4f48ab49da2ec948f329dea2a133cc6f0e602e265958cf09efd554510640ae1e
+MD5 e39e9fd198a2c0a5984f2c7d188b3c49 files/2.5.1-utf8-case.patch 933
+RMD160 1619e4b6710047049e5776a45732b2709b117cfa files/2.5.1-utf8-case.patch 933
+SHA256 4f48ab49da2ec948f329dea2a133cc6f0e602e265958cf09efd554510640ae1e files/2.5.1-utf8-case.patch 933
+AUX grep-2.5.1-bracket.patch 339 RMD160 0333e5113b7285ce92b4a68d89d25ff7b81211f0 SHA1 7882dc95b6cb69d64e4c68425c3a44f0c324aa71 SHA256 1a0a64ce2cfaaeef687f5d2131d12358d4c8ae3dfeceb81cf6abf6ccf17d085c
+MD5 f8a3294b57d8e444692a04436b346517 files/grep-2.5.1-bracket.patch 339
+RMD160 0333e5113b7285ce92b4a68d89d25ff7b81211f0 files/grep-2.5.1-bracket.patch 339
+SHA256 1a0a64ce2cfaaeef687f5d2131d12358d4c8ae3dfeceb81cf6abf6ccf17d085c files/grep-2.5.1-bracket.patch 339
+AUX grep-2.5.1-color.patch 313 RMD160 b4c787993fc05065bb8ec4f7b3007778650c8958 SHA1 623c25f3686adc40287ea244dd079c1e50c55c64 SHA256 f628a2a1800c9374eeece94c39b561dffd80b7f8ec587f25d00bd6301b32321d
+MD5 ea125637c880aa0e2e6ae96e5a9a01d6 files/grep-2.5.1-color.patch 313
+RMD160 b4c787993fc05065bb8ec4f7b3007778650c8958 files/grep-2.5.1-color.patch 313
+SHA256 f628a2a1800c9374eeece94c39b561dffd80b7f8ec587f25d00bd6301b32321d files/grep-2.5.1-color.patch 313
+AUX grep-2.5.1-fgrep.patch 4994 RMD160 f10371083fe3350e4cc0f79dbf1c83362f444b94 SHA1 1f9adc6363f5a3fafbd12b544bf9f927da27de34 SHA256 cab6300f7c8263fdaa3b5a1d00e46b8237bec42d4c4b6b49a3dbacab80ab9071
+MD5 829ef0ec8616173674ded06d27e12632 files/grep-2.5.1-fgrep.patch 4994
+RMD160 f10371083fe3350e4cc0f79dbf1c83362f444b94 files/grep-2.5.1-fgrep.patch 4994
+SHA256 cab6300f7c8263fdaa3b5a1d00e46b8237bec42d4c4b6b49a3dbacab80ab9071 files/grep-2.5.1-fgrep.patch 4994
+AUX grep-2.5.1-fix-devices-skip.patch 1842 RMD160 c6000aa04f11dc00d37819f2f3f1a9c76bf0aa1e SHA1 0d45ff5971ff8a7ac9e10a3eca5b101fc6a2560f SHA256 9b6809efb0ff05256a77a9a30f295dfb2f212c0eb023638ee72fde31d1d43457
+MD5 26b2ee006a2293540cadc27d9d41267a files/grep-2.5.1-fix-devices-skip.patch 1842
+RMD160 c6000aa04f11dc00d37819f2f3f1a9c76bf0aa1e files/grep-2.5.1-fix-devices-skip.patch 1842
+SHA256 9b6809efb0ff05256a77a9a30f295dfb2f212c0eb023638ee72fde31d1d43457 files/grep-2.5.1-fix-devices-skip.patch 1842
+AUX grep-2.5.1-i18n.patch 8101 RMD160 a73a25a4c089260b26ef73024adc67754ef8a1ba SHA1 2e6150a54822d128e245bfeb467a3dfc6e4ce181 SHA256 cfad5a4e033888a35442fe234f995ebd6e101155e5fdb80be5c4d02afae12ee5
+MD5 d93f52bd287bb18a64178ac3e6077677 files/grep-2.5.1-i18n.patch 8101
+RMD160 a73a25a4c089260b26ef73024adc67754ef8a1ba files/grep-2.5.1-i18n.patch 8101
+SHA256 cfad5a4e033888a35442fe234f995ebd6e101155e5fdb80be5c4d02afae12ee5 files/grep-2.5.1-i18n.patch 8101
+AUX grep-2.5.1-libintl.patch 2662 RMD160 03431703a1d375b0c0bb8a78b3b00951252d0111 SHA1 4131dddf515b04e2b8d424da6d5d9ca8c369b6dc SHA256 919e4f3bbbb07990ecf0f73a9f3eded397b67a14f40e5ec41159ecebef8f0161
+MD5 af3a45582aa7c857f0500c63c823bd52 files/grep-2.5.1-libintl.patch 2662
+RMD160 03431703a1d375b0c0bb8a78b3b00951252d0111 files/grep-2.5.1-libintl.patch 2662
+SHA256 919e4f3bbbb07990ecf0f73a9f3eded397b67a14f40e5ec41159ecebef8f0161 files/grep-2.5.1-libintl.patch 2662
+AUX grep-2.5.1-manpage.patch 612 RMD160 1ba80343c963b6830a8bb258b3317b8e7c3ccfcc SHA1 9a7577e7ad1c62dd44d87c78161599f6712b2f66 SHA256 3af50dc156cceba0605c6862ff5cf9b329fa46592247323e99e06356f696e2de
+MD5 66d2f58ded24ee5351a8a79a2d709cf8 files/grep-2.5.1-manpage.patch 612
+RMD160 1ba80343c963b6830a8bb258b3317b8e7c3ccfcc files/grep-2.5.1-manpage.patch 612
+SHA256 3af50dc156cceba0605c6862ff5cf9b329fa46592247323e99e06356f696e2de files/grep-2.5.1-manpage.patch 612
+AUX grep-2.5.1-oi.patch 1715 RMD160 af03849546ee0122883fb7efe2e45960f1636673 SHA1 8cde3d2ef33d88a24ea8bf0dee9c27b7a1b91d03 SHA256 c6c35e6b6b6ebe8f198240b85ec2acd6154e95fdc3a314dec10614fca2e3399d
+MD5 626d4c9efc866039f6893735b6f4940e files/grep-2.5.1-oi.patch 1715
+RMD160 af03849546ee0122883fb7efe2e45960f1636673 files/grep-2.5.1-oi.patch 1715
+SHA256 c6c35e6b6b6ebe8f198240b85ec2acd6154e95fdc3a314dec10614fca2e3399d files/grep-2.5.1-oi.patch 1715
+AUX grep-2.5.1-perl-segv.patch 410 RMD160 e5310adbd2befa5d30001f634f7142366cc20d00 SHA1 6a1d5bfaec46180fa56bb1c42f0fd86ea7b52509 SHA256 bc7d84e7c6ce9ecfbe3ff9a1d91a6d12183ca7553fe3eebfaa4a7f15157662e4
+MD5 b6da5288895ddd97074deb10f48b4364 files/grep-2.5.1-perl-segv.patch 410
+RMD160 e5310adbd2befa5d30001f634f7142366cc20d00 files/grep-2.5.1-perl-segv.patch 410
+SHA256 bc7d84e7c6ce9ecfbe3ff9a1d91a6d12183ca7553fe3eebfaa4a7f15157662e4 files/grep-2.5.1-perl-segv.patch 410
+AUX grep-2.5.1-restrict_arr.patch 410 RMD160 cfb62007664e37e4a3b193af0452808d0c2eb798 SHA1 ff2f1c38b487e30d958aab29033b4568116267b8 SHA256 458a43f9e069df1ef12e47ca879d0b9db5707b22080ccc7cd31bb8e6bcdc05aa
+MD5 1eee743f3bf8a7926c07f9a0307a6b64 files/grep-2.5.1-restrict_arr.patch 410
+RMD160 cfb62007664e37e4a3b193af0452808d0c2eb798 files/grep-2.5.1-restrict_arr.patch 410
+SHA256 458a43f9e069df1ef12e47ca879d0b9db5707b22080ccc7cd31bb8e6bcdc05aa files/grep-2.5.1-restrict_arr.patch 410
+AUX grep-2.5.1a-nls.patch 1227 RMD160 c49d3604ff65b586ace6fa75a478c367cf6a0c62 SHA1 fdd1ac6d076640489fd11c405c73f490b372c414 SHA256 a92c1e75d95fadee1f4af86e818637cf54bcf9b01ece08653d23e4c31bc7c279
+MD5 55251575c3b22b67167f7de065072b8f files/grep-2.5.1a-nls.patch 1227
+RMD160 c49d3604ff65b586ace6fa75a478c367cf6a0c62 files/grep-2.5.1a-nls.patch 1227
+SHA256 a92c1e75d95fadee1f4af86e818637cf54bcf9b01ece08653d23e4c31bc7c279 files/grep-2.5.1a-nls.patch 1227
+AUX grep-onthefly.patch 11164 RMD160 bafa12774c6507c8f1d7e96f9bb8d1fb12b96ec0 SHA1 6d9981d95e434cd02826b7b6aacf3dca43516628 SHA256 8362e7bd930368b0b069c7253a0908ce676ada339f29955ea1c94601819f8a59
+MD5 f1536479d5fbe3a6e6aa5fb9bad15c4e files/grep-onthefly.patch 11164
+RMD160 bafa12774c6507c8f1d7e96f9bb8d1fb12b96ec0 files/grep-onthefly.patch 11164
+SHA256 8362e7bd930368b0b069c7253a0908ce676ada339f29955ea1c94601819f8a59 files/grep-onthefly.patch 11164
+DIST grep-2.5.1a.tar.bz2 527386 RMD160 f02c36c5a1efe805eafb0b4c0171ddb7ff15fbeb SHA1 2cd082775d30be463c0ac674a00595eb56fda22e SHA256 38c8a2bb9223d1fb1b10bdd607cf44830afc92fd451ac4cd07619bf92bdd3132
+EBUILD grep-2.5.1a-r2.ebuild 2263 RMD160 3158266f35aaafe025b2add7ae25be305cc30f2d SHA1 41c6f453daf26c71635717b227577bda0bee2037 SHA256 3f567156a32241b1a6278ec85fcd7128e3e17425f8a5fa5fb6b2c038381ebf59
+MD5 4a7877e02bb343859607ff66d55e9a45 grep-2.5.1a-r2.ebuild 2263
+RMD160 3158266f35aaafe025b2add7ae25be305cc30f2d grep-2.5.1a-r2.ebuild 2263
+SHA256 3f567156a32241b1a6278ec85fcd7128e3e17425f8a5fa5fb6b2c038381ebf59 grep-2.5.1a-r2.ebuild 2263
+MD5 aa75d543de9cdb9d9a86269a7f2216c8 files/digest-grep-2.5.1a-r2 238
+RMD160 ed247f3fb6af7fd98d06b4cb2228706e4640a22b files/digest-grep-2.5.1a-r2 238
+SHA256 855e142dd76e809d8ae1f95394f7adb8ccb2d8b4c9bb79336d1966ae225f8e84 files/digest-grep-2.5.1a-r2 238
diff --git a/sys-apps/grep/files/2.5.1-tests.patch b/sys-apps/grep/files/2.5.1-tests.patch
new file mode 100644
index 0000000..5d29d59
--- /dev/null
+++ b/sys-apps/grep/files/2.5.1-tests.patch
@@ -0,0 +1,45 @@
+glibc has changed the error code it returns from '1' to '2'. The
+included grep regex library returns '1' still though, so spencer
+test #55 incorrectly fails. For now, we update the test to match
+the glibc regex since that is what we're using ;).
+
+http://bugs.gentoo.org/show_bug.cgi?id=76192
+http://linuxfromscratch.org/pipermail/lfs-dev/2003-February/032543.html
+
+
+glibc has a sweet bug where it can go to town (and never come back)
+with some complicated regex's. this has been fixed in glibc cvs,
+but our latest releases don't have the patch. so let's add a simple
+workaround from upstream grep cvs.
+
+http://bugs.gentoo.org/show_bug.cgi?id=76879
+
+Index: tests/spencer1.tests
+===================================================================
+RCS file: /cvsroot/grep/grep/tests/spencer1.tests,v
+retrieving revision 1.1
+retrieving revision 1.2
+diff -u -r1.1 -r1.2
+--- tests/spencer1.tests 3 Nov 1998 21:39:05 -0000 1.1
++++ tests/spencer1.tests 12 Jun 2003 15:26:15 -0000 1.2
+@@ -52,3 +52,3 @@
+ 0@$*@-
+-1@(*)b@-
++2@(*)b@-
+ 1@$b@b
+Index: tests/backref.sh
+===================================================================
+RCS file: /cvsroot/grep/grep/tests/backref.sh,v
+retrieving revision 1.3
+retrieving revision 1.4
+diff -u -r1.3 -r1.4
+--- tests/backref.sh 23 Jul 2003 05:15:51 -0000 1.3
++++ tests/backref.sh 19 Nov 2004 14:00:18 -0000 1.4
+@@ -14,5 +14,6 @@
+
+ # hit hard with the `Bond' tests
+-echo "civic" | ${GREP} -E -e '^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?).?\9\8\7\6\5\4\3\2\1$' > /dev/null 2>&1
++# For now, remove the ``?'' in the last parentheses, so that new glibc can do it. --Stepan
++echo "civic" | ${GREP} -E -e '^(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.?)(.).?\9\8\7\6\5\4\3\2\1$' > /dev/null 2>&1
+ if test $? -ne 0 ; then
+ echo "Options: Bond, test \#2 failed"
diff --git a/sys-apps/grep/files/2.5.1-utf8-case.patch b/sys-apps/grep/files/2.5.1-utf8-case.patch
new file mode 100644
index 0000000..c884270
--- /dev/null
+++ b/sys-apps/grep/files/2.5.1-utf8-case.patch
@@ -0,0 +1,29 @@
+Grabbed from Debian:
+http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=249245
+
+To fix Gentoo bug:
+http://bugs.gentoo.org/show_bug.cgi?id=76192
+
+--- grep-2.5.1.orig/src/dfa.c 2004-10-19 02:07:23.000000000 +0900
++++ grep-2.5.1/src/dfa.c 2004-10-19 02:24:28.000000000 +0900
+@@ -652,6 +652,20 @@
+ REALLOC_IF_NECESSARY(work_mbc->chars, wchar_t, chars_al,
+ work_mbc->nchars + 1);
+ work_mbc->chars[work_mbc->nchars++] = (wchar_t)wc;
++ if (case_fold && (iswlower((wint_t) wc) || iswupper((wint_t) wc)))
++ {
++ wint_t altcase;
++
++ altcase = wc; /* keeps compiler happy */
++ if (iswlower((wint_t) wc))
++ altcase = towupper((wint_t) wc);
++ else if (iswupper((wint_t) wc))
++ altcase = towlower((wint_t) wc);
++
++ REALLOC_IF_NECESSARY(work_mbc->chars, wchar_t, chars_al,
++ work_mbc->nchars + 1);
++ work_mbc->chars[work_mbc->nchars++] = (wchar_t) altcase;
++ }
+ }
+ }
+ while ((wc = wc1) != L']');
diff --git a/sys-apps/grep/files/digest-grep-2.5.1a-r2 b/sys-apps/grep/files/digest-grep-2.5.1a-r2
new file mode 100644
index 0000000..86f3e91
--- /dev/null
+++ b/sys-apps/grep/files/digest-grep-2.5.1a-r2
@@ -0,0 +1,3 @@
+MD5 52202fe462770fa6be1bb667bd6cf30c grep-2.5.1a.tar.bz2 527386
+RMD160 f02c36c5a1efe805eafb0b4c0171ddb7ff15fbeb grep-2.5.1a.tar.bz2 527386
+SHA256 38c8a2bb9223d1fb1b10bdd607cf44830afc92fd451ac4cd07619bf92bdd3132 grep-2.5.1a.tar.bz2 527386
diff --git a/sys-apps/grep/files/grep-2.5.1-bracket.patch b/sys-apps/grep/files/grep-2.5.1-bracket.patch
new file mode 100644
index 0000000..f99571c
--- /dev/null
+++ b/sys-apps/grep/files/grep-2.5.1-bracket.patch
@@ -0,0 +1,11 @@
+--- grep-2.5.1/src/dfa.c.bracket 2003-10-30 16:21:14.000000000 +0000
++++ grep-2.5.1/src/dfa.c 2003-10-30 16:22:38.000000000 +0000
+@@ -586,7 +586,7 @@
+ work_mbc->coll_elems[work_mbc->ncoll_elems++] = elem;
+ }
+ }
+- wc = -1;
++ wc1 = wc = -1;
+ }
+ else
+ /* We treat '[' as a normal character here. */
diff --git a/sys-apps/grep/files/grep-2.5.1-color.patch b/sys-apps/grep/files/grep-2.5.1-color.patch
new file mode 100644
index 0000000..f54c258
--- /dev/null
+++ b/sys-apps/grep/files/grep-2.5.1-color.patch
@@ -0,0 +1,10 @@
+--- grep-2.5.1/src/grep.c.color 2004-11-16 16:46:22.845505847 +0000
++++ grep-2.5.1/src/grep.c 2004-11-16 16:46:27.961530537 +0000
+@@ -607,6 +607,7 @@
+ fputs ("\33[00m", stdout);
+ beg = b + match_size;
+ }
++ fputs ("\33[K", stdout);
+ }
+ fwrite (beg, 1, lim - beg, stdout);
+ if (ferror (stdout))
diff --git a/sys-apps/grep/files/grep-2.5.1-fgrep.patch b/sys-apps/grep/files/grep-2.5.1-fgrep.patch
new file mode 100644
index 0000000..49edf4a
--- /dev/null
+++ b/sys-apps/grep/files/grep-2.5.1-fgrep.patch
@@ -0,0 +1,196 @@
+--- grep-2.5.1/src/search.c
++++ grep-2.5.1/src/search.c
+@@ -360,13 +360,7 @@
+ /* Find a possible match using the KWset matcher. */
+ size_t offset = kwsexec (kwset, beg, buflim - beg, &kwsm);
+ if (offset == (size_t) -1)
+- {
+-#ifdef MBS_SUPPORT
+- if (MB_CUR_MAX > 1)
+- free(mb_properties);
+-#endif
+- return (size_t)-1;
+- }
++ goto failure;
+ beg += offset;
+ /* Narrow down to the line containing the candidate, and
+ run it through DFA. */
+@@ -379,7 +373,7 @@
+ while (beg > buf && beg[-1] != eol)
+ --beg;
+ if (kwsm.index < kwset_exact_matches)
+- goto success;
++ goto success_in_beg_and_end;
+ if (dfaexec (&dfa, beg, end - beg, &backref) == (size_t) -1)
+ continue;
+ }
+@@ -398,7 +392,7 @@
+ }
+ /* Successful, no backreferences encountered! */
+ if (!backref)
+- goto success;
++ goto success_in_beg_and_end;
+ }
+ else
+ end = beg + size;
+@@ -413,14 +407,11 @@
+ end - beg - 1, &(patterns[i].regs))))
+ {
+ len = patterns[i].regs.end[0] - start;
+- if (exact)
+- {
+- *match_size = len;
+- return start;
+- }
++ if (exact && !match_words)
++ goto success_in_start_and_len;
+ if ((!match_lines && !match_words)
+ || (match_lines && len == end - beg - 1))
+- goto success;
++ goto success_in_beg_and_end;
+ /* If -w, check if the match aligns with word boundaries.
+ We do this iteratively because:
+ (a) the line may contain more than one occurence of the
+@@ -434,7 +425,7 @@
+ if ((start == 0 || !WCHAR ((unsigned char) beg[start - 1]))
+ && (len == end - beg - 1
+ || !WCHAR ((unsigned char) beg[start + len])))
+- goto success;
++ goto success_in_start_and_len;
+ if (len > 0)
+ {
+ /* Try a shorter length anchored at the same place. */
+@@ -461,19 +452,26 @@
+ }
+ } /* for Regex patterns. */
+ } /* for (beg = end ..) */
++
++ failure:
+ #ifdef MBS_SUPPORT
+ if (MB_CUR_MAX > 1 && mb_properties)
+ free (mb_properties);
+ #endif /* MBS_SUPPORT */
+ return (size_t) -1;
+
+- success:
++ success_in_beg_and_end:
++ len = end - beg;
++ start = beg - buf;
++ /* FALLTHROUGH */
++
++ success_in_start_and_len:
+ #ifdef MBS_SUPPORT
+ if (MB_CUR_MAX > 1 && mb_properties)
+ free (mb_properties);
+ #endif /* MBS_SUPPORT */
+- *match_size = end - beg;
+- return beg - buf;
++ *match_size = len;
++ return start;
+ }
+
+ static void
+@@ -516,28 +514,15 @@
+ {
+ size_t offset = kwsexec (kwset, beg, buf + size - beg, &kwsmatch);
+ if (offset == (size_t) -1)
+- {
+-#ifdef MBS_SUPPORT
+- if (MB_CUR_MAX > 1)
+- free(mb_properties);
+-#endif /* MBS_SUPPORT */
+- return offset;
+- }
++ goto failure;
+ #ifdef MBS_SUPPORT
+ if (MB_CUR_MAX > 1 && mb_properties[offset+beg-buf] == 0)
+ continue; /* It is a part of multibyte character. */
+ #endif /* MBS_SUPPORT */
+ beg += offset;
+ len = kwsmatch.size[0];
+- if (exact)
+- {
+- *match_size = len;
+-#ifdef MBS_SUPPORT
+- if (MB_CUR_MAX > 1)
+- free (mb_properties);
+-#endif /* MBS_SUPPORT */
+- return beg - buf;
+- }
++ if (exact && !match_words)
++ goto success_in_beg_and_len;
+ if (match_lines)
+ {
+ if (beg > buf && beg[-1] != eol)
+@@ -547,31 +532,37 @@
+ goto success;
+ }
+ else if (match_words)
+- for (try = beg; len; )
+- {
+- if (try > buf && WCHAR((unsigned char) try[-1]))
+- break;
+- if (try + len < buf + size && WCHAR((unsigned char) try[len]))
+- {
+- offset = kwsexec (kwset, beg, --len, &kwsmatch);
+- if (offset == (size_t) -1)
+- {
+-#ifdef MBS_SUPPORT
+- if (MB_CUR_MAX > 1)
+- free (mb_properties);
+-#endif /* MBS_SUPPORT */
+- return offset;
+- }
+- try = beg + offset;
+- len = kwsmatch.size[0];
+- }
+- else
+- goto success;
+- }
++ {
++ while (offset >= 0)
++ {
++ if ((offset == 0 || !WCHAR ((unsigned char) beg[-1]))
++ && (len == end - beg - 1 || !WCHAR ((unsigned char) beg[len])))
++ {
++ if (!exact)
++ /* Returns the whole line now we know there's a word match. */
++ goto success;
++ else
++ /* Returns just this word match. */
++ goto success_in_beg_and_len;
++ }
++ if (len > 0)
++ {
++ /* Try a shorter length anchored at the same place. */
++ --len;
++ offset = kwsexec (kwset, beg, len, &kwsmatch);
++ if (offset == -1) {
++ break; /* Try a different anchor. */
++ }
++ beg += offset;
++ len = kwsmatch.size[0];
++ }
++ }
++ }
+ else
+ goto success;
+ }
+
++ failure:
+ #ifdef MBS_SUPPORT
+ if (MB_CUR_MAX > 1)
+ free (mb_properties);
+@@ -583,7 +574,11 @@
+ end++;
+ while (buf < beg && beg[-1] != eol)
+ --beg;
+- *match_size = end - beg;
++ len = end - beg;
++ /* FALLTHROUGH */
++
++ success_in_beg_and_len:
++ *match_size = len;
+ #ifdef MBS_SUPPORT
+ if (MB_CUR_MAX > 1)
+ free (mb_properties);
diff --git a/sys-apps/grep/files/grep-2.5.1-fix-devices-skip.patch b/sys-apps/grep/files/grep-2.5.1-fix-devices-skip.patch
new file mode 100644
index 0000000..aff800c
--- /dev/null
+++ b/sys-apps/grep/files/grep-2.5.1-fix-devices-skip.patch
@@ -0,0 +1,55 @@
+http://bugs.gentoo.org/113640
+
+2004-11-20 Benno Schulenberg <benno@nietvergeten.nl> (tiny change)
+
+ * src/grep.c (reset): Move the stat check ...
+ (grepfile): ... here, and also check for a fifo.
+
+Index: src/grep.c
+===================================================================
+RCS file: /cvsroot/grep/grep/src/grep.c,v
+retrieving revision 1.83
+retrieving revision 1.84
+diff -u -p -r1.83 -r1.84
+--- src/grep.c 20 Nov 2004 16:15:57 -0000 1.83
++++ src/grep.c 20 Nov 2004 16:20:38 -0000 1.84
+@@ -255,19 +255,6 @@ reset (int fd, char const *file, struct
+ bufbeg[-1] = eolbyte;
+ bufdesc = fd;
+
+- if (fstat (fd, &stats->stat) != 0)
+- {
+- error (0, errno, "fstat");
+- return 0;
+- }
+- if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode))
+- return 0;
+-#ifndef DJGPP
+- if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode)))
+-#else
+- if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode)))
+-#endif
+- return 0;
+ if (S_ISREG (stats->stat.st_mode))
+ {
+ if (file)
+@@ -928,6 +915,19 @@ grepfile (char const *file, struct stats
+ }
+ else
+ {
++ if (stat (file, &stats->stat) != 0)
++ {
++ suppressible_error (file, errno);
++ return 1;
++ }
++ if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode))
++ return 1;
++#ifndef DJGPP
++ if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode) || S_ISFIFO(stats->stat.st_mode)))
++#else
++ if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode)))
++#endif
++ return 1;
+ while ((desc = open (file, O_RDONLY)) < 0 && errno == EINTR)
+ continue;
+
diff --git a/sys-apps/grep/files/grep-2.5.1-i18n.patch b/sys-apps/grep/files/grep-2.5.1-i18n.patch
new file mode 100644
index 0000000..6c08140
--- /dev/null
+++ b/sys-apps/grep/files/grep-2.5.1-i18n.patch
@@ -0,0 +1,305 @@
+Ripped from Fedora
+
+--- grep-2.5.1/src/dfa.c 2004-02-26 13:09:54.000000000 +0000
++++ grep-2.5.1/src/dfa.c 2004-05-18 16:43:31.189200479 +0100
+@@ -414,7 +414,7 @@
+
+ /* This function fetch a wide character, and update cur_mb_len,
+ used only if the current locale is a multibyte environment. */
+-static wchar_t
++static wint_t
+ fetch_wc (char const *eoferr)
+ {
+ wchar_t wc;
+@@ -423,7 +423,7 @@
+ if (eoferr != 0)
+ dfaerror (eoferr);
+ else
+- return -1;
++ return WEOF;
+ }
+
+ cur_mb_len = mbrtowc(&wc, lexptr, lexleft, &mbs);
+@@ -459,7 +459,7 @@
+ static void
+ parse_bracket_exp_mb ()
+ {
+- wchar_t wc, wc1, wc2;
++ wint_t wc, wc1, wc2;
+
+ /* Work area to build a mb_char_classes. */
+ struct mb_char_classes *work_mbc;
+@@ -496,7 +496,7 @@
+ work_mbc->invert = 0;
+ do
+ {
+- wc1 = -1; /* mark wc1 is not initialized". */
++ wc1 = WEOF; /* mark wc1 is not initialized". */
+
+ /* Note that if we're looking at some other [:...:] construct,
+ we just treat it as a bunch of ordinary characters. We can do
+@@ -586,7 +586,7 @@
+ work_mbc->coll_elems[work_mbc->ncoll_elems++] = elem;
+ }
+ }
+- wc1 = wc = -1;
++ wc1 = wc = WEOF;
+ }
+ else
+ /* We treat '[' as a normal character here. */
+@@ -600,7 +600,7 @@
+ wc = fetch_wc(("Unbalanced ["));
+ }
+
+- if (wc1 == -1)
++ if (wc1 == WEOF)
+ wc1 = fetch_wc(_("Unbalanced ["));
+
+ if (wc1 == L'-')
+@@ -630,17 +630,17 @@
+ }
+ REALLOC_IF_NECESSARY(work_mbc->range_sts, wchar_t,
+ range_sts_al, work_mbc->nranges + 1);
+- work_mbc->range_sts[work_mbc->nranges] = wc;
++ work_mbc->range_sts[work_mbc->nranges] = (wchar_t)wc;
+ REALLOC_IF_NECESSARY(work_mbc->range_ends, wchar_t,
+ range_ends_al, work_mbc->nranges + 1);
+- work_mbc->range_ends[work_mbc->nranges++] = wc2;
++ work_mbc->range_ends[work_mbc->nranges++] = (wchar_t)wc2;
+ }
+- else if (wc != -1)
++ else if (wc != WEOF)
+ /* build normal characters. */
+ {
+ REALLOC_IF_NECESSARY(work_mbc->chars, wchar_t, chars_al,
+ work_mbc->nchars + 1);
+- work_mbc->chars[work_mbc->nchars++] = wc;
++ work_mbc->chars[work_mbc->nchars++] = (wchar_t)wc;
+ }
+ }
+ while ((wc = wc1) != L']');
+@@ -2552,6 +2552,8 @@
+ }
+
+ /* match with a character? */
++ if (case_fold)
++ wc = towlower (wc);
+ for (i = 0; i<work_mbc->nchars; i++)
+ {
+ if (wc == work_mbc->chars[i])
+--- grep-2.5.1/src/grep.c.i18n 2002-03-26 15:54:12.000000000 +0000
++++ grep-2.5.1/src/grep.c 2004-02-26 13:09:54.000000000 +0000
+@@ -30,6 +30,12 @@
+ # include <sys/time.h>
+ # include <sys/resource.h>
+ #endif
++#if defined HAVE_WCTYPE_H && defined HAVE_WCHAR_H && defined HAVE_MBRTOWC
++/* We can handle multibyte string. */
++# define MBS_SUPPORT
++# include <wchar.h>
++# include <wctype.h>
++#endif
+ #include <stdio.h>
+ #include "system.h"
+ #include "getopt.h"
+@@ -1697,6 +1703,37 @@
+ if (!install_matcher (matcher) && !install_matcher ("default"))
+ abort ();
+
++#ifdef MBS_SUPPORT
++ if (MB_CUR_MAX != 1 && match_icase)
++ {
++ wchar_t wc;
++ mbstate_t cur_state, prev_state;
++ int i, len = strlen(keys);
++
++ memset(&cur_state, 0, sizeof(mbstate_t));
++ for (i = 0; i <= len ;)
++ {
++ size_t mbclen;
++ mbclen = mbrtowc(&wc, keys + i, len - i, &cur_state);
++ if (mbclen == (size_t) -1 || mbclen == (size_t) -2 || mbclen == 0)
++ {
++ /* An invalid sequence, or a truncated multibyte character.
++ We treat it as a singlebyte character. */
++ mbclen = 1;
++ }
++ else
++ {
++ if (iswupper((wint_t)wc))
++ {
++ wc = towlower((wint_t)wc);
++ wcrtomb(keys + i, wc, &cur_state);
++ }
++ }
++ i += mbclen;
++ }
++ }
++#endif /* MBS_SUPPORT */
++
+ (*compile)(keys, keycc);
+
+ if ((argc - optind > 1 && !no_filenames) || with_filenames)
+--- grep-2.5.1/src/search.c.i18n 2004-02-26 13:09:54.000000000 +0000
++++ grep-2.5.1/src/search.c 2004-02-26 13:17:12.000000000 +0000
+@@ -149,15 +149,16 @@
+ static char*
+ check_multibyte_string(char const *buf, size_t size)
+ {
+- char *mb_properties = malloc(size);
++ char *mb_properties = xmalloc(size);
+ mbstate_t cur_state;
++ wchar_t wc;
+ int i;
+ memset(&cur_state, 0, sizeof(mbstate_t));
+ memset(mb_properties, 0, sizeof(char)*size);
+ for (i = 0; i < size ;)
+ {
+ size_t mbclen;
+- mbclen = mbrlen(buf + i, size - i, &cur_state);
++ mbclen = mbrtowc(&wc, buf + i, size - i, &cur_state);
+
+ if (mbclen == (size_t) -1 || mbclen == (size_t) -2 || mbclen == 0)
+ {
+@@ -165,6 +166,14 @@
+ We treat it as a singlebyte character. */
+ mbclen = 1;
+ }
++ else if (match_icase)
++ {
++ if (iswupper((wint_t)wc))
++ {
++ wc = towlower((wint_t)wc);
++ wcrtomb(buf + i, wc, &cur_state);
++ }
++ }
+ mb_properties[i] = mbclen;
+ i += mbclen;
+ }
+@@ -233,7 +242,7 @@
+ static char const line_end[] = "\\)$";
+ static char const word_beg[] = "\\(^\\|[^[:alnum:]_]\\)\\(";
+ static char const word_end[] = "\\)\\([^[:alnum:]_]\\|$\\)";
+- char *n = malloc (sizeof word_beg - 1 + size + sizeof word_end);
++ char *n = xmalloc (sizeof word_beg - 1 + size + sizeof word_end);
+ size_t i;
+ strcpy (n, match_lines ? line_beg : word_beg);
+ i = strlen (n);
+@@ -316,7 +325,7 @@
+ static char const line_end[] = ")$";
+ static char const word_beg[] = "(^|[^[:alnum:]_])(";
+ static char const word_end[] = ")([^[:alnum:]_]|$)";
+- char *n = malloc (sizeof word_beg - 1 + size + sizeof word_end);
++ char *n = xmalloc (sizeof word_beg - 1 + size + sizeof word_end);
+ size_t i;
+ strcpy (n, match_lines ? line_beg : word_beg);
+ i = strlen(n);
+@@ -339,14 +348,20 @@
+ char eol = eolbyte;
+ int backref, start, len;
+ struct kwsmatch kwsm;
+- size_t i;
++ size_t i, ret_val;
+ #ifdef MBS_SUPPORT
+ char *mb_properties = NULL;
+-#endif /* MBS_SUPPORT */
+-
+-#ifdef MBS_SUPPORT
+- if (MB_CUR_MAX > 1 && kwset)
+- mb_properties = check_multibyte_string(buf, size);
++ if (MB_CUR_MAX > 1)
++ {
++ if (match_icase)
++ {
++ char *case_buf = xmalloc(size);
++ memcpy(case_buf, buf, size);
++ buf = case_buf;
++ }
++ if (kwset)
++ mb_properties = check_multibyte_string(buf, size);
++ }
+ #endif /* MBS_SUPPORT */
+
+ buflim = buf + size;
+@@ -455,8 +470,13 @@
+
+ failure:
+ #ifdef MBS_SUPPORT
+- if (MB_CUR_MAX > 1 && mb_properties)
+- free (mb_properties);
++ if (MB_CUR_MAX > 1)
++ {
++ if (mb_properties)
++ free (mb_properties);
++ if (match_icase)
++ free ((char *) buf);
++ }
+ #endif /* MBS_SUPPORT */
+ return (size_t) -1;
+
+@@ -467,8 +487,13 @@
+
+ success_in_start_and_len:
+ #ifdef MBS_SUPPORT
+- if (MB_CUR_MAX > 1 && mb_properties)
+- free (mb_properties);
++ if (MB_CUR_MAX > 1)
++ {
++ if (mb_properties)
++ free (mb_properties);
++ if (match_icase)
++ free ((char *) buf);
++ }
+ #endif /* MBS_SUPPORT */
+ *match_size = len;
+ return start;
+@@ -504,10 +529,19 @@
+ register size_t len;
+ char eol = eolbyte;
+ struct kwsmatch kwsmatch;
++ size_t ret_val;
+ #ifdef MBS_SUPPORT
+- char *mb_properties;
++ char *mb_properties = NULL;
+ if (MB_CUR_MAX > 1)
+- mb_properties = check_multibyte_string (buf, size);
++ {
++ if (match_icase)
++ {
++ char *case_buf = xmalloc(size);
++ memcpy(case_buf, buf, size);
++ buf = case_buf;
++ }
++ mb_properties = check_multibyte_string(buf, size);
++ }
+ #endif /* MBS_SUPPORT */
+
+ for (beg = buf; beg <= buf + size; ++beg)
+@@ -565,7 +599,12 @@
+ failure:
+ #ifdef MBS_SUPPORT
+ if (MB_CUR_MAX > 1)
+- free (mb_properties);
++ {
++ if (match_icase)
++ free((char *) buf);
++ if (mb_properties)
++ free(mb_properties);
++ }
+ #endif /* MBS_SUPPORT */
+ return -1;
+
+@@ -581,7 +620,12 @@
+ *match_size = len;
+ #ifdef MBS_SUPPORT
+ if (MB_CUR_MAX > 1)
+- free (mb_properties);
++ {
++ if (mb_properties)
++ free (mb_properties);
++ if (match_icase)
++ free ((char *) buf);
++ }
+ #endif /* MBS_SUPPORT */
+ return beg - buf;
+ }
diff --git a/sys-apps/grep/files/grep-2.5.1-libintl.patch b/sys-apps/grep/files/grep-2.5.1-libintl.patch
new file mode 100644
index 0000000..0bf601c
--- /dev/null
+++ b/sys-apps/grep/files/grep-2.5.1-libintl.patch
@@ -0,0 +1,99 @@
+Add libintl detection for BSD systems.
+
+Patch by Diego Pettenò.
+http://bugs.gentoo.org/92586
+
+ #--- configure.in
+ #+++ configure.in
+ #@@ -72,6 +72,7 @@
+ # dnl I18N feature
+ # ALL_LINGUAS="cs de el eo es et fr gl hr id it ja ko nl no pl pt_BR ru sl sv"
+ # AM_GNU_GETTEXT
+ #+AC_CHECK_LIB(intl, libintl_gettext)
+ #
+ # dnl DOS file name convention
+ # dnl sets HAVE_DOS_FILE_NAMES
+
+--- configure
++++ configure
+@@ -7754,6 +8827,80 @@
+
+
+
++echo "$as_me:$LINENO: checking for libintl_gettext in -lintl" >&5
++echo $ECHO_N "checking for libintl_gettext in -lintl... $ECHO_C" >&6
++if test "${ac_cv_lib_intl_libintl_gettext+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ ac_check_lib_save_LIBS=$LIBS
++LIBS="-lintl $LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char libintl_gettext ();
++int
++main ()
++{
++libintl_gettext ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_intl_libintl_gettext=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_intl_libintl_gettext=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_intl_libintl_gettext" >&5
++echo "${ECHO_T}$ac_cv_lib_intl_libintl_gettext" >&6
++if test $ac_cv_lib_intl_libintl_gettext = yes; then
++ cat >>confdefs.h <<_ACEOF
++#define HAVE_LIBINTL 1
++_ACEOF
++
++ LIBS="-lintl $LIBS"
++
++fi
++
++
+
+ echo "$as_me:$LINENO: checking for dos file convention" >&5
+ echo $ECHO_N "checking for dos file convention... $ECHO_C" >&6
diff --git a/sys-apps/grep/files/grep-2.5.1-manpage.patch b/sys-apps/grep/files/grep-2.5.1-manpage.patch
new file mode 100644
index 0000000..2f7145f
--- /dev/null
+++ b/sys-apps/grep/files/grep-2.5.1-manpage.patch
@@ -0,0 +1,21 @@
+Ripped from Fedora
+
+--- grep-2.5.1/doc/grep.1.manpage 2002-01-22 13:20:04.000000000 +0000
++++ grep-2.5.1/doc/grep.1 2003-10-08 09:37:32.000000000 +0100
+@@ -191,6 +191,7 @@
+ .I PATTERN
+ as a list of fixed strings, separated by newlines,
+ any of which is to be matched.
++.TP
+ .BR \-P ", " \-\^\-perl-regexp
+ Interpret
+ .I PATTERN
+@@ -302,7 +303,7 @@
+ This is especially useful for tools like zgrep, e.g.
+ .B "gzip -cd foo.gz |grep --label=foo something"
+ .TP
+-.BR \-\^\-line-buffering
++.BR \-\^\-line-buffered
+ Use line buffering, it can be a performance penality.
+ .TP
+ .BR \-q ", " \-\^\-quiet ", " \-\^\-silent
diff --git a/sys-apps/grep/files/grep-2.5.1-oi.patch b/sys-apps/grep/files/grep-2.5.1-oi.patch
new file mode 100644
index 0000000..563c837
--- /dev/null
+++ b/sys-apps/grep/files/grep-2.5.1-oi.patch
@@ -0,0 +1,50 @@
+Ripped from Fedora
+
+--- grep-2.5.1/lib/posix/regex.h.oi 2004-01-05 12:09:12.984391131 +0000
++++ grep-2.5.1/lib/posix/regex.h 2004-01-05 12:09:24.717990622 +0000
+@@ -109,6 +109,10 @@
+ If not set, \{, \}, {, and } are literals. */
+ #define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
+
++/* If this bit is set, then ignore case when matching.
++ If not set, then case is significant. */
++#define RE_ICASE (RE_INVALID_INTERVAL_ORD << 1)
++
+ /* If this bit is set, +, ? and | aren't recognized as operators.
+ If not set, they are. */
+ #define RE_LIMITED_OPS (RE_INTERVALS << 1)
+--- grep-2.5.1/src/search.c.oi 2004-01-05 12:07:00.550199415 +0000
++++ grep-2.5.1/src/search.c 2004-01-05 12:07:00.566197505 +0000
+@@ -31,7 +31,7 @@
+
+ #include "system.h"
+ #include "grep.h"
+-#include "regex.h"
++#include <regex.h>
+ #include "dfa.h"
+ #include "kwset.h"
+ #include "error.h"
+@@ -190,7 +190,7 @@
+ size_t total = size;
+ char const *motif = pattern;
+
+- re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE);
++ re_set_syntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE | (match_icase ? RE_ICASE : 0));
+ dfasyntax (RE_SYNTAX_GREP | RE_HAT_LISTS_NOT_NEWLINE, match_icase, eolbyte);
+
+ /* For GNU regex compiler we have to pass the patterns separately to detect
+@@ -268,12 +268,12 @@
+
+ if (strcmp (matcher, "awk") == 0)
+ {
+- re_set_syntax (RE_SYNTAX_AWK);
++ re_set_syntax (RE_SYNTAX_AWK | (match_icase ? RE_ICASE : 0));
+ dfasyntax (RE_SYNTAX_AWK, match_icase, eolbyte);
+ }
+ else
+ {
+- re_set_syntax (RE_SYNTAX_POSIX_EGREP);
++ re_set_syntax (RE_SYNTAX_POSIX_EGREP | (match_icase ? RE_ICASE : 0));
+ dfasyntax (RE_SYNTAX_POSIX_EGREP, match_icase, eolbyte);
+ }
+
diff --git a/sys-apps/grep/files/grep-2.5.1-perl-segv.patch b/sys-apps/grep/files/grep-2.5.1-perl-segv.patch
new file mode 100644
index 0000000..46218a1
--- /dev/null
+++ b/sys-apps/grep/files/grep-2.5.1-perl-segv.patch
@@ -0,0 +1,19 @@
+Fix from upstream to fix a corner case segfault.
+
+http://bugs.gentoo.org/95495
+
+--- grep-2.5.1/src/search.c
++++ grep-2.5.1/src/search.c
+@@ -701,8 +701,10 @@
+ char eol = eolbyte;
+ if (!exact)
+ {
+- end = memchr (end, eol, buflim - end);
+- end++;
++ if (!(end = memchr (end, eol, buflim - end)))
++ end = buflim;
++ else
++ end++;
+ while (buf < beg && beg[-1] != eol)
+ --beg;
+ }
diff --git a/sys-apps/grep/files/grep-2.5.1-restrict_arr.patch b/sys-apps/grep/files/grep-2.5.1-restrict_arr.patch
new file mode 100644
index 0000000..2294e9c
--- /dev/null
+++ b/sys-apps/grep/files/grep-2.5.1-restrict_arr.patch
@@ -0,0 +1,11 @@
+--- lib/posix/regex.h
++++ lib/posix/regex.h
+@@ -533,7 +533,8 @@ extern int re_exec _RE_ARGS ((const char
+ /* For now unconditionally define __restrict_arr to expand to nothing.
+ Ideally we would have a test for the compiler which allows defining
+ it to restrict. */
++#undef __restrict_arr
+ #define __restrict_arr
+
+ /* POSIX compatibility. */
+ extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
diff --git a/sys-apps/grep/files/grep-2.5.1a-nls.patch b/sys-apps/grep/files/grep-2.5.1a-nls.patch
new file mode 100644
index 0000000..91fb497
--- /dev/null
+++ b/sys-apps/grep/files/grep-2.5.1a-nls.patch
@@ -0,0 +1,39 @@
+Index: grep-2.5.1a/src/dfa.c
+===================================================================
+--- grep-2.5.1a.orig/src/dfa.c
++++ grep-2.5.1a/src/dfa.c
+@@ -102,7 +102,7 @@ extern void free();
+ /* If we (don't) have I18N. */
+ /* glibc defines _ */
+ #ifndef _
+-# ifdef HAVE_LIBINTL_H
++# if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H)
+ # include <libintl.h>
+ # ifndef _
+ # define _(Str) gettext (Str)
+Index: grep-2.5.1a/lib/obstack.c
+===================================================================
+--- grep-2.5.1a.orig/lib/obstack.c
++++ grep-2.5.1a/lib/obstack.c
+@@ -451,7 +451,7 @@ _obstack_memory_used (h)
+
+ /* Define the error handler. */
+ #ifndef _
+-# ifdef HAVE_LIBINTL_H
++# if defined(ENABLE_NLS) && defined(HAVE_LIBINTL_H)
+ # include <libintl.h>
+ # ifndef _
+ # define _(Str) gettext (Str)
+Index: grep-2.5.1a/lib/regex.c
+===================================================================
+--- grep-2.5.1a.orig/lib/regex.c
++++ grep-2.5.1a/lib/regex.c
+@@ -112,7 +112,7 @@
+ #endif
+
+ /* This is for other GNU distributions with internationalized messages. */
+-#if HAVE_LIBINTL_H || defined _LIBC
++#if ENABLE_NLS && (HAVE_LIBINTL_H || defined _LIBC)
+ # include <libintl.h>
+ # ifdef _LIBC
+ # undef gettext
diff --git a/sys-apps/grep/files/grep-onthefly.patch b/sys-apps/grep/files/grep-onthefly.patch
new file mode 100644
index 0000000..38a72cc
--- /dev/null
+++ b/sys-apps/grep/files/grep-onthefly.patch
@@ -0,0 +1,395 @@
+--- grep-2.5.1a/configure.in 2002-03-26 16:48:16.000000000 +0100
++++ /home/drizzt/grep-2.5.1a/configure.in 2006-10-14 14:57:51.000000000 +0200
+@@ -141,4 +141,39 @@
+ AC_CHECK_LIB(pcre, pcre_exec)
+ fi
+
++dnl check for bzip2 and zlib
++AC_ARG_ENABLE(bzip2,
++AC_HELP_STRING([--enable-bzip2], [Enable bzip2 support. (default: yes)]),
++ bzip2=$enableval, bzip2=yes)
++
++AC_ARG_ENABLE(gzip,
++AC_HELP_STRING([--enable-gzip], [Enable gzip support. (default: yes)]),
++ gzip=$enableval, gzip=yes)
++
++dnl bz2
++if test "$bzip2" = yes; then
++ AC_CHECK_LIB(bz2, BZ2_bzopen, bzip_l=yes, bzip_l=no)
++ AC_CHECK_HEADER(bzlib.h, bzip_h=yes, bzip_h=no)
++ if test "$bzip_l" = yes && test "$bzip_h" = yes; then
++ AC_MSG_NOTICE([bzip2 support is enabled.])
++ AC_DEFINE(HAVE_LIBBZ2,,[Enable bzip2 support])
++ LIBS+=" -lbz2"
++ else
++ AC_MSG_NOTICE([bzip2 support is disabled.])
++ fi
++fi
++
++dnl gz
++if test "$gzip" = yes; then
++ AC_CHECK_LIB(z, gzopen, gzip_l=yes, gzip_l=no)
++ AC_CHECK_HEADER(zlib.h, gzip_h=yes, gzip_h=no)
++ if test "$gzip_l" = yes && test "$gzip_h" = yes; then
++ AC_MSG_NOTICE([gzip support is enabled.])
++ AC_DEFINE(HAVE_LIBZ,,[Enable gzip support])
++ LIBS+=" -lz"
++ else
++ AC_MSG_NOTICE([gzip support is disabled.])
++ fi
++fi
++
+ AC_OUTPUT(Makefile lib/Makefile lib/posix/Makefile src/Makefile tests/Makefile po/Makefile.in intl/Makefile doc/Makefile m4/Makefile vms/Makefile bootstrap/Makefile, [sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile; echo timestamp > stamp-h])
+--- grep-2.5.1a/src/grep.c 2006-10-14 15:03:03.000000000 +0200
++++ /home/drizzt/grep-2.5.1a/src/grep.c 2006-10-14 14:54:41.000000000 +0200
+@@ -17,6 +17,9 @@
+ 02111-1307, USA. */
+
+ /* Written July 1992 by Mike Haertel. */
++/* Builtin decompression 1997 by Wolfram Schneider <wosch@FreeBSD.org>. */
++
++/* $FreeBSD: src/gnu/usr.bin/grep/grep.c,v 1.31.2.1 2005/10/26 21:13:30 jkim Exp $ */
+
+ #ifdef HAVE_CONFIG_H
+ # include <config.h>
+@@ -72,6 +75,9 @@
+ /* If nonzero, use mmap if possible. */
+ static int mmap_option;
+
++/* If zero, output nulls after filenames. */
++static int filename_mask;
++
+ /* If nonzero, use grep_color marker. */
+ static int color_option;
+
+@@ -86,7 +92,11 @@
+ static struct exclude *included_patterns;
+ /* Short options. */
+ static char const short_options[] =
++#if defined(HAVE_LIBBZ2)
++"0123456789A:B:C:D:EFGHIJPUVX:abcd:e:f:hiKLlm:noqRrsuvwxyZz";
++#else
+ "0123456789A:B:C:D:EFGHIPUVX:abcd:e:f:hiKLlm:noqRrsuvwxyZz";
++#endif
+
+ /* Non-boolean long options that have no corresponding short equivalents. */
+ enum
+@@ -133,7 +143,15 @@
+ {"mmap", no_argument, &mmap_option, 1},
+ {"no-filename", no_argument, NULL, 'h'},
+ {"no-messages", no_argument, NULL, 's'},
++#if defined(HAVE_LIBBZ2)
++ {"bz2decompress", no_argument, NULL, 'J'},
++#endif
++#if defined(HAVE_LIBZ)
++ {"decompress", no_argument, NULL, 'Z'},
++ {"null", no_argument, &filename_mask, 0},
++#else
+ {"null", no_argument, NULL, 'Z'},
++#endif
+ {"null-data", no_argument, NULL, 'z'},
+ {"only-matching", no_argument, NULL, 'o'},
+ {"perl-regexp", no_argument, NULL, 'P'},
+@@ -236,6 +254,17 @@
+ # define bufmapped 0
+ #endif
+
++#if defined(HAVE_LIBBZ2)
++#include <bzlib.h>
++static BZFILE* bzbufdesc; /* libbz2 file handle. */
++static int BZflag; /* uncompress before searching. */
++#endif
++#if defined(HAVE_LIBZ)
++#include <zlib.h>
++static gzFile gzbufdesc; /* zlib file descriptor. */
++static int Zflag; /* uncompress before searching. */
++#endif
++
+ /* Return VAL aligned to the next multiple of ALIGNMENT. VAL can be
+ an integer or a pointer. Both args must be free of side effects. */
+ #define ALIGN_TO(val, alignment) \
+@@ -256,12 +285,48 @@
+ bufalloc = ALIGN_TO (INITIAL_BUFSIZE, pagesize) + pagesize + 1;
+ buffer = xmalloc (bufalloc);
+ }
++#if defined(HAVE_LIBBZ2)
++ if (BZflag)
++ {
++ bzbufdesc = BZ2_bzdopen(fd, "r");
++ if (bzbufdesc == NULL)
++ error(2, 0, _("memory exhausted"));
++ }
++#endif
++#if defined(HAVE_LIBZ)
++ if (Zflag)
++ {
++ gzbufdesc = gzdopen(fd, "r");
++ if (gzbufdesc == NULL)
++ error(2, 0, _("memory exhausted"));
++ }
++#endif
+
+ bufbeg = buflim = ALIGN_TO (buffer + 1, pagesize);
+ bufbeg[-1] = eolbyte;
+ bufdesc = fd;
+
+- if (S_ISREG (stats->stat.st_mode))
++ if (fstat (fd, &stats->stat) != 0)
++ {
++ error (0, errno, "fstat");
++ return 0;
++ }
++ if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode))
++ return 0;
++#ifndef DJGPP
++ if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode)))
++#else
++ if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode)))
++#endif
++ return 0;
++ if (
++#if defined(HAVE_LIBBZ2)
++ BZflag ||
++#endif
++#if defined(HAVE_LIBZ)
++ Zflag ||
++#endif
++ S_ISREG (stats->stat.st_mode))
+ {
+ if (file)
+ bufoffset = 0;
+@@ -401,9 +466,38 @@
+ if (! fillsize)
+ {
+ ssize_t bytesread;
+- while ((bytesread = read (bufdesc, readbuf, readsize)) < 0
+- && errno == EINTR)
+- continue;
++ do
++#if defined(HAVE_LIBBZ2)
++ if (BZflag && bzbufdesc)
++ {
++ int bzerr;
++ bytesread = BZ2_bzRead (&bzerr, bzbufdesc, readbuf, readsize);
++
++ switch (bzerr)
++ {
++ case BZ_OK:
++ case BZ_STREAM_END:
++ /* ok */
++ break;
++ case BZ_DATA_ERROR_MAGIC:
++ BZ2_bzReadClose (&bzerr, bzbufdesc); bzbufdesc = NULL;
++ lseek (bufdesc, 0, SEEK_SET);
++ bytesread = read (bufdesc, readbuf, readsize);
++ break;
++ default:
++ bytesread = 0;
++ break;
++ }
++ }
++ else
++#endif
++#if defined(HAVE_LIBZ)
++ if (Zflag)
++ bytesread = gzread (gzbufdesc, readbuf, readsize);
++ else
++#endif
++ bytesread = read (bufdesc, readbuf, readsize);
++ while (bytesread < 0 && errno == EINTR);
+ if (bytesread < 0)
+ cc = 0;
+ else
+@@ -551,33 +645,6 @@
+ {
+ size_t match_size;
+ size_t match_offset;
+- if(match_icase)
+- {
+- /* Yuck, this is tricky */
+- char *buf = (char*) xmalloc (lim - beg);
+- char *ibeg = buf;
+- char *ilim = ibeg + (lim - beg);
+- int i;
+- for (i = 0; i < lim - beg; i++)
+- ibeg[i] = tolower (beg[i]);
+- while ((match_offset = (*execute) (ibeg, ilim-ibeg, &match_size, 1))
+- != (size_t) -1)
+- {
+- char const *b = beg + match_offset;
+- if (b == lim)
+- break;
+- fwrite (beg, sizeof (char), match_offset, stdout);
+- printf ("\33[%sm", grep_color);
+- fwrite (b, sizeof (char), match_size, stdout);
+- fputs ("\33[00m", stdout);
+- beg = b + match_size;
+- ibeg = ibeg + match_offset + match_size;
+- }
+- fwrite (beg, 1, lim - beg, stdout);
+- free (buf);
+- lastout = lim;
+- return;
+- }
+ while (lim-beg && (match_offset = (*execute) (beg, lim - beg, &match_size, 1))
+ != (size_t) -1)
+ {
+@@ -763,6 +830,16 @@
+ {
+ /* Close fd now, so that we don't open a lot of file descriptors
+ when we recurse deeply. */
++#if defined(HAVE_LIBBZ2)
++ if (BZflag && bzbufdesc)
++ BZ2_bzclose(bzbufdesc);
++ else
++#endif
++#if defined(HAVE_LIBZ)
++ if (Zflag)
++ gzclose(gzbufdesc);
++ else
++#endif
+ if (close (fd) != 0)
+ error (0, errno, "%s", file);
+ return grepdir (file, stats) - 2;
+@@ -889,19 +966,6 @@
+ }
+ else
+ {
+- if (stat (file, &stats->stat) != 0)
+- {
+- suppressible_error (file, errno);
+- return 1;
+- }
+- if (directories == SKIP_DIRECTORIES && S_ISDIR (stats->stat.st_mode))
+- return 1;
+-#ifndef DJGPP
+- if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode) || S_ISSOCK(stats->stat.st_mode) || S_ISFIFO(stats->stat.st_mode)))
+-#else
+- if (devices == SKIP_DEVICES && (S_ISCHR(stats->stat.st_mode) || S_ISBLK(stats->stat.st_mode)))
+-#endif
+- return 1;
+ while ((desc = open (file, O_RDONLY)) < 0 && errno == EINTR)
+ continue;
+
+@@ -968,6 +1032,16 @@
+ if (list_files == 1 - 2 * status)
+ printf ("%s%c", filename, '\n' & filename_mask);
+
++#if defined(HAVE_LIBBZ2)
++ if (BZflag && bzbufdesc)
++ BZ2_bzclose(bzbufdesc);
++ else
++#endif
++#if defined(HAVE_LIBZ)
++ if (Zflag)
++ gzclose(gzbufdesc);
++ else
++#endif
+ if (! file)
+ {
+ off_t required_offset = outleft ? bufoffset : after_last_match;
+@@ -1003,7 +1077,7 @@
+ && ancestor->stat.st_dev == stats->stat.st_dev)
+ {
+ if (!suppress_errors)
+- error (0, 0, _("warning: %s: %s\n"), dir,
++ error (0, 0, _("warning: %s: %s"), dir,
+ _("recursive directory loop"));
+ return 1;
+ }
+@@ -1084,6 +1158,8 @@
+ -v, --invert-match select non-matching lines\n\
+ -V, --version print version information and exit\n\
+ --help display this help and exit\n\
++ -J, --bz2decompress decompress bzip2'ed input before searching\n\
++ -Z, --decompress decompress input before searching\n\
+ --mmap use memory-mapped input if possible\n"));
+ printf (_("\
+ \n\
+@@ -1112,7 +1188,7 @@
+ -L, --files-without-match only print FILE names containing no match\n\
+ -l, --files-with-matches only print FILE names containing matches\n\
+ -c, --count only print a count of matching lines per FILE\n\
+- -Z, --null print 0 byte after FILE name\n"));
++ --null print 0 byte after FILE name\n"));
+ printf (_("\
+ \n\
+ Context control:\n\
+@@ -1130,7 +1206,7 @@
+ With no FILE, or when FILE is -, read standard input. If less than\n\
+ two FILEs given, assume -h. Exit status is 0 if match, 1 if no match,\n\
+ and 2 if trouble.\n"));
+- printf (_("\nReport bugs to <bug-grep@gnu.org>.\n"));
++ printf (_("\nReport bugs to <bug-gnu-utils@gnu.org>.\n"));
+ }
+ exit (status);
+ }
+@@ -1301,10 +1377,18 @@
+ if (program_name && strrchr (program_name, '/'))
+ program_name = strrchr (program_name, '/') + 1;
+
+- if (!strcmp(program_name, "egrep"))
+- setmatcher ("egrep");
+- if (!strcmp(program_name, "fgrep"))
+- setmatcher ("fgrep");
++#if defined(HAVE_LIBBZ2)
++ if (program_name[0] == 'b' && program_name[1] == 'z') {
++ BZflag = 1;
++ program_name += 2;
++ }
++#endif
++#if defined(HAVE_LIBZ)
++ else if (program_name[0] == 'z') {
++ Zflag = 1;
++ ++program_name;
++ }
++#endif
+
+ #if defined(__MSDOS__) || defined(_WIN32)
+ /* DOS and MS-Windows use backslashes as directory separators, and usually
+@@ -1408,6 +1492,18 @@
+ case 'I':
+ binary_files = WITHOUT_MATCH_BINARY_FILES;
+ break;
++ case 'J':
++#if defined(HAVE_LIBZ)
++ if (Zflag)
++ {
++ printf (_("Cannot mix -Z and -J.\n"));
++ usage (2);
++ }
++#endif
++#if defined(HAVE_LIBBZ2)
++ BZflag = 1;
++#endif
++ break;
+
+ case 'U':
+ #if defined(HAVE_DOS_FILE_CONTENTS)
+@@ -1556,7 +1652,16 @@
+ break;
+
+ case 'Z':
+- filename_mask = 0;
++#if defined(HAVE_LIBBZ2)
++ if (BZflag)
++ {
++ printf (_("Cannot mix -J and -Z.\n"));
++ usage (2);
++ }
++#endif
++#if defined(HAVE_LIBZ)
++ Zflag = 1;
++#endif
+ break;
+
+ case 'z':
+@@ -1662,7 +1767,7 @@
+ }
+
+ if (! matcher)
+- matcher = "grep";
++ matcher = program_name;
+
+ if (show_version)
+ {
diff --git a/sys-apps/grep/grep-2.5.1a-r2.ebuild b/sys-apps/grep/grep-2.5.1a-r2.ebuild
new file mode 100644
index 0000000..154ffa0
--- /dev/null
+++ b/sys-apps/grep/grep-2.5.1a-r2.ebuild
@@ -0,0 +1,75 @@
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-apps/grep/grep-2.5.1a-r1.ebuild,v 1.3 2006/10/17 11:24:47 uberlord Exp $
+
+inherit flag-o-matic eutils autotools
+
+DESCRIPTION="GNU regular expression matcher"
+HOMEPAGE="http://www.gnu.org/software/grep/grep.html"
+SRC_URI="mirror://gnu/${PN}/${P}.tar.bz2
+ mirror://gentoo/${P}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="alpha ~amd64 arm hppa ia64 m68k ~mips ppc ~ppc-macos ppc64 s390 sh ~sparc ~sparc-fbsd ~x86 ~x86-fbsd"
+IUSE="nls pcre static vanilla"
+
+RDEPEND="nls? ( virtual/libintl )"
+DEPEND="${RDEPEND}
+ pcre? ( dev-libs/libpcre )
+ nls? ( sys-devel/gettext )
+ vanilla? ( sys-libs/zlib
+ app-arch/bzip2 )"
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+
+ # work around a weird sparc32 compiler bug
+ echo "" >> src/dfa.h
+
+ epatch "${FILESDIR}"/${PN}-2.5.1-manpage.patch
+ epatch "${FILESDIR}"/${PN}-2.5.1-fgrep.patch
+ epatch "${FILESDIR}"/${PN}-2.5.1-color.patch
+ epatch "${FILESDIR}"/${PN}-2.5.1-bracket.patch
+ epatch "${FILESDIR}"/${PN}-2.5.1-i18n.patch
+ epatch "${FILESDIR}"/${PN}-2.5.1-oi.patch
+ epatch "${FILESDIR}"/${PN}-2.5.1-restrict_arr.patch
+ epatch "${FILESDIR}"/2.5.1-utf8-case.patch
+ epatch "${FILESDIR}"/${PN}-2.5.1-perl-segv.patch #95495
+ epatch "${FILESDIR}"/${PN}-2.5.1-fix-devices-skip.patch #113640
+ epatch "${FILESDIR}"/${P}-nls.patch
+ if ! use vanilla; then
+ epatch "${FILESDIR}"/${PN}-onthefly.patch
+ AT_M4DIR="./m4" eautoreconf || die
+ fi
+
+ # retarded
+ sed -i 's:__mempcpy:mempcpy:g' lib/*.c || die
+}
+
+src_compile() {
+ local myconf="--bindir=/bin \
+ $(use_enable nls) \
+ $(use_enable pcre perl-regexp)"
+
+ use static && append-ldflags -static
+ use vanilla || myconf="${myconf} --enable-bzip2 --enable-gzip"
+
+ econf ${myconf} || die "econf failed"
+
+ use static || sed -i 's:-lpcre:-Wl,-Bstatic -lpcre -Wl,-Bdynamic:g' src/Makefile
+
+ emake || die "emake failed"
+}
+
+src_install() {
+ make DESTDIR="${D}" install || die "make install failed"
+
+ # Override the default shell scripts... grep knows how to act
+ # based on how it's called
+ ln -sfn grep "${D}"/bin/egrep || die "ln egrep failed"
+ ln -sfn grep "${D}"/bin/fgrep || die "ln fgrep failed"
+
+ dodoc AUTHORS ChangeLog NEWS README THANKS TODO
+}