summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertrand Jacquin <beber@meleeweb.net>2009-05-13 19:36:00 +0200
committerBertrand Jacquin <beber@meleeweb.net>2009-05-13 19:36:00 +0200
commitcccf1d015849b841c0322c0be76b5d76660fb0da (patch)
treeb90bc34ac552f175b87922dd58163a0ddc528d33
parentglib: add patchs to make it cross-compile (_C99_SOURCE) (diff)
downloadportage-cccf1d015849b841c0322c0be76b5d76660fb0da.tar.xz
grep: fix pcre-config host use by using PKG_CONFIG in autofoo
-rw-r--r--sys-apps/grep/Manifest18
-rw-r--r--sys-apps/grep/files/2.5.1-utf8-case.patch29
-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-BJA-pcre-pkgconfig.diff17
-rw-r--r--sys-apps/grep/files/grep-2.5.1a-nls.patch39
-rw-r--r--sys-apps/grep/files/grep-2.5.3-nls.patch50
-rw-r--r--sys-apps/grep/files/grep-2.5.3-po-builddir-fix.patch10
-rw-r--r--sys-apps/grep/files/grep-2.5.3-yesno-test-fix.patch32
-rw-r--r--sys-apps/grep/grep-2.5.1a-r1.ebuild72
18 files changed, 1044 insertions, 0 deletions
diff --git a/sys-apps/grep/Manifest b/sys-apps/grep/Manifest
new file mode 100644
index 00000000..90f29efa
--- /dev/null
+++ b/sys-apps/grep/Manifest
@@ -0,0 +1,18 @@
+AUX 2.5.1-utf8-case.patch 933 RMD160 1619e4b6710047049e5776a45732b2709b117cfa SHA1 51c9ea9363370041b2c0a9b7dcc83bfd739a4723 SHA256 4f48ab49da2ec948f329dea2a133cc6f0e602e265958cf09efd554510640ae1e
+AUX grep-2.5.1-bracket.patch 339 RMD160 0333e5113b7285ce92b4a68d89d25ff7b81211f0 SHA1 7882dc95b6cb69d64e4c68425c3a44f0c324aa71 SHA256 1a0a64ce2cfaaeef687f5d2131d12358d4c8ae3dfeceb81cf6abf6ccf17d085c
+AUX grep-2.5.1-color.patch 313 RMD160 b4c787993fc05065bb8ec4f7b3007778650c8958 SHA1 623c25f3686adc40287ea244dd079c1e50c55c64 SHA256 f628a2a1800c9374eeece94c39b561dffd80b7f8ec587f25d00bd6301b32321d
+AUX grep-2.5.1-fgrep.patch 4994 RMD160 f10371083fe3350e4cc0f79dbf1c83362f444b94 SHA1 1f9adc6363f5a3fafbd12b544bf9f927da27de34 SHA256 cab6300f7c8263fdaa3b5a1d00e46b8237bec42d4c4b6b49a3dbacab80ab9071
+AUX grep-2.5.1-fix-devices-skip.patch 1842 RMD160 c6000aa04f11dc00d37819f2f3f1a9c76bf0aa1e SHA1 0d45ff5971ff8a7ac9e10a3eca5b101fc6a2560f SHA256 9b6809efb0ff05256a77a9a30f295dfb2f212c0eb023638ee72fde31d1d43457
+AUX grep-2.5.1-i18n.patch 8101 RMD160 a73a25a4c089260b26ef73024adc67754ef8a1ba SHA1 2e6150a54822d128e245bfeb467a3dfc6e4ce181 SHA256 cfad5a4e033888a35442fe234f995ebd6e101155e5fdb80be5c4d02afae12ee5
+AUX grep-2.5.1-libintl.patch 2662 RMD160 03431703a1d375b0c0bb8a78b3b00951252d0111 SHA1 4131dddf515b04e2b8d424da6d5d9ca8c369b6dc SHA256 919e4f3bbbb07990ecf0f73a9f3eded397b67a14f40e5ec41159ecebef8f0161
+AUX grep-2.5.1-manpage.patch 612 RMD160 1ba80343c963b6830a8bb258b3317b8e7c3ccfcc SHA1 9a7577e7ad1c62dd44d87c78161599f6712b2f66 SHA256 3af50dc156cceba0605c6862ff5cf9b329fa46592247323e99e06356f696e2de
+AUX grep-2.5.1-oi.patch 1715 RMD160 af03849546ee0122883fb7efe2e45960f1636673 SHA1 8cde3d2ef33d88a24ea8bf0dee9c27b7a1b91d03 SHA256 c6c35e6b6b6ebe8f198240b85ec2acd6154e95fdc3a314dec10614fca2e3399d
+AUX grep-2.5.1-perl-segv.patch 410 RMD160 e5310adbd2befa5d30001f634f7142366cc20d00 SHA1 6a1d5bfaec46180fa56bb1c42f0fd86ea7b52509 SHA256 bc7d84e7c6ce9ecfbe3ff9a1d91a6d12183ca7553fe3eebfaa4a7f15157662e4
+AUX grep-2.5.1-restrict_arr.patch 410 RMD160 cfb62007664e37e4a3b193af0452808d0c2eb798 SHA1 ff2f1c38b487e30d958aab29033b4568116267b8 SHA256 458a43f9e069df1ef12e47ca879d0b9db5707b22080ccc7cd31bb8e6bcdc05aa
+AUX grep-2.5.1a-BJA-pcre-pkgconfig.diff 459 RMD160 41a8126d5ddf2868c15c48274e1bee1969c9fa8a SHA1 1d8fa446399e868a77f1f9a94797cd8df556a8fe SHA256 3d096dc3214d92c2f2fa20f4f29f45d27739f97bb9a8876c69838edf545684f7
+AUX grep-2.5.1a-nls.patch 1227 RMD160 c49d3604ff65b586ace6fa75a478c367cf6a0c62 SHA1 fdd1ac6d076640489fd11c405c73f490b372c414 SHA256 a92c1e75d95fadee1f4af86e818637cf54bcf9b01ece08653d23e4c31bc7c279
+AUX grep-2.5.3-nls.patch 1339 RMD160 1f395f9bea5097c92a258cf4b06ff186a8a8710b SHA1 c72efe2cc35295acf5611b11369c827489575edf SHA256 fbeab3c37dcea3905aad14b87eddc14d035532af6fa0f3a126c52d0ca709edea
+AUX grep-2.5.3-po-builddir-fix.patch 252 RMD160 e2d58380b32de1ba6ecf47a4d2f93bd25186cbb5 SHA1 0cf165687ae45c3a79f37497a0dc7bf40ed3fa7a SHA256 5475ff7cb45b1b744618b5687ea8e130a4922888bd222f230a6f2856fc0c8b4a
+AUX grep-2.5.3-yesno-test-fix.patch 1553 RMD160 31871333dc9595bbedc70571ff7453bc7bf5479f SHA1 1068fd1f5b6f346a8ea73487f6bebf12e79437d2 SHA256 0b366ffa3f13aedfdb714e2151486476bd50d784176b564c0ddabd5943a97f25
+DIST grep-2.5.1a.tar.bz2 527386 RMD160 f02c36c5a1efe805eafb0b4c0171ddb7ff15fbeb SHA1 2cd082775d30be463c0ac674a00595eb56fda22e SHA256 38c8a2bb9223d1fb1b10bdd607cf44830afc92fd451ac4cd07619bf92bdd3132
+EBUILD grep-2.5.1a-r1.ebuild 2103 RMD160 4ca1dd228f668e40dd89e3bcb9087e6b0b6cbb60 SHA1 e0061bcbd23984a514a36a26565a1e451545a46b SHA256 383c9a303fbdc4f6366d04a854bd83558317cb2375d666e0a0be06a84ea5adac
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 00000000..c8842709
--- /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/grep-2.5.1-bracket.patch b/sys-apps/grep/files/grep-2.5.1-bracket.patch
new file mode 100644
index 00000000..f99571c0
--- /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 00000000..f54c258e
--- /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 00000000..49edf4a7
--- /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 00000000..aff800c3
--- /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 00000000..6c081400
--- /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 00000000..0bf601ca
--- /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 00000000..2f7145f0
--- /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 00000000..563c8372
--- /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 00000000..46218a1f
--- /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 00000000..2294e9c2
--- /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-BJA-pcre-pkgconfig.diff b/sys-apps/grep/files/grep-2.5.1a-BJA-pcre-pkgconfig.diff
new file mode 100644
index 00000000..8e167619
--- /dev/null
+++ b/sys-apps/grep/files/grep-2.5.1a-BJA-pcre-pkgconfig.diff
@@ -0,0 +1,17 @@
+--- configure.in.ori 2002-03-26 16:48:16.000000000 +0100
++++ configure.in 2009-05-13 19:05:10.000000000 +0200
+@@ -134,10 +134,10 @@
+
+ # support for pcre
+ if test x"$testpcre" = x"yes"; then
+- if pcre-config --cflags >/dev/null 2>&1; then
+- CFLAGS="$CFLAGS `pcre-config --cflags`"
+- LIBS="$LIBS `pcre-config --libs`"
+- fi
++ PKG_CHECK_MODULES(pcre, [libpcre])
++ CFLAGS="$CFLAGS $pcre_CFLAGS"
++ LIBS="$LIBS $pcre_LIBS"
++
+ AC_CHECK_LIB(pcre, pcre_exec)
+ fi
+
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 00000000..91fb4979
--- /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-2.5.3-nls.patch b/sys-apps/grep/files/grep-2.5.3-nls.patch
new file mode 100644
index 00000000..eec06be4
--- /dev/null
+++ b/sys-apps/grep/files/grep-2.5.3-nls.patch
@@ -0,0 +1,50 @@
+Fixes compilation with -nls useflag on FreeBSD (and probably others).
+
+See http://bugs.gentoo.org/253777.
+
+--- grep-2.5.3.orig/lib/error.c
++++ grep-2.5.3/lib/error.c
+@@ -26,8 +26,8 @@
+ #endif
+
+ #include <stdio.h>
+-#if HAVE_LIBINTL_H
+-# include <libintl.h>
++#if defined(HAVE_LIBINTL_H) && defined(ENABLE_NLS)
++# include <libintl.h>
+ #endif
+
+ #if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
+--- grep-2.5.3.orig/lib/getopt.c
++++ grep-2.5.3/lib/getopt.c
+@@ -77,7 +77,7 @@
+ #ifndef _
+ /* This is for other GNU distributions with internationalized messages.
+ When compiling libc, the _ macro is predefined. */
+-# ifdef HAVE_LIBINTL_H
++# if defined(HAVE_LIBINTL_H) && defined(ENABLE_NLS)
+ # include <libintl.h>
+ # define _(msgid) gettext (msgid)
+ # else
+--- grep-2.5.3.orig/lib/obstack.c
++++ grep-2.5.3/lib/obstack.c
+@@ -451,7 +451,7 @@
+
+ /* Define the error handler. */
+ #ifndef _
+-# ifdef HAVE_LIBINTL_H
++# if defined(HAVE_LIBINTL_H) && defined(ENABLE_NLS)
+ # include <libintl.h>
+ # ifndef _
+ # define _(Str) gettext (Str)
+--- grep-2.5.3.orig/lib/regex.c
++++ grep-2.5.3/lib/regex.c
+@@ -116,7 +116,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-2.5.3-po-builddir-fix.patch b/sys-apps/grep/files/grep-2.5.3-po-builddir-fix.patch
new file mode 100644
index 00000000..7d3e334f
--- /dev/null
+++ b/sys-apps/grep/files/grep-2.5.3-po-builddir-fix.patch
@@ -0,0 +1,10 @@
+--- grep-2.5.3/po/Makefile.in.in.orig 2006-11-24 20:53:21 -0300
++++ grep-2.5.3/po/Makefile.in.in 2008-10-26 18:31:06 -0200
+@@ -13,6 +13,7 @@
+ @SET_MAKE@
+
+ srcdir = @srcdir@
++top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ VPATH = @srcdir@
+
diff --git a/sys-apps/grep/files/grep-2.5.3-yesno-test-fix.patch b/sys-apps/grep/files/grep-2.5.3-yesno-test-fix.patch
new file mode 100644
index 00000000..3c6e1ab7
--- /dev/null
+++ b/sys-apps/grep/files/grep-2.5.3-yesno-test-fix.patch
@@ -0,0 +1,32 @@
+Fix from upstream CVS disabling tests that are known to fail.
+
+--- tests/yesno.sh 2005/11/13 08:15:16 1.1
++++ tests/yesno.sh 2008/02/07 03:43:27 1.2
+@@ -63,7 +63,6 @@
+ '-m,4,-C,1,-o' "$c$d$e$h$z0$XI$XJ$XK$XL$XM$XN" \
+ '-m,5' "$C$D$E$H$I$z0$XJ$XK$XL$XM$XN" \
+ '-m,5,-o' "$c$d$e$h$i$z0$XJ$XK$XL$XM$XN" \
+- '-m,5,-C,1' "$rB$C$D$E$rF$rG$H$I$z0$XJ$XK$XL$XM$XN" \
+ '-m,5,-C,1,-o' "$c$d$e$h$i$z0$XJ$XK$XL$XM$XN" \
+ '-m,6' "$C$D$E$H$I$M$z0$XN" \
+ '-m,6,-o' "$c$d$e$h$i$m$z0$XN" \
+@@ -79,14 +78,17 @@
+ '-m,1,-v,-C,1,-o' "$z0$XB$XC$XD$XE$XF$XG$XH$XI$XJ$XK$XL$XM$XN" \
+ '-m,2,-v' "$A$B$z0$XC$XD$XE$XF$XG$XH$XI$XJ$XK$XL$XM$XN" \
+ '-m,2,-v,-o' "$z0$XC$XD$XE$XF$XG$XH$XI$XJ$XK$XL$XM$XN" \
+- '-m,2,-v,-C,1' "$A$B$z0$XC$XD$XE$XF$XG$XH$XI$XJ$XK$XL$XM$XN" \
+- '-m,2,-v,-C,1,-o' "$z0$XC$XD$XE$XF$XG$XH$XI$XJ$XK$XL$XM$XN" \
+ '-m,3,-v' "$A$B$F$z0$XG$XH$XI$XJ$XK$XL$XM$XN" \
+ '-m,3,-v,-o' "$z0$XG$XH$XI$XJ$XK$XL$XM$XN" \
+ '-m,3,-v,-C,1' "$A$B$rC$s$rE$F$z0$XG$XH$XI$XJ$XK$XL$XM$XN" \
+ '-m,3,-v,-C,1,-o' "$rc$s$re$z0$XG$XH$XI$XJ$XK$XL$XM$XN" \
+ x
+ shift
++# Comment out cases that are known to fail. These should be uncommented after the 2.5.4 release. TAA.
++# These should be added back in above and fixed in the code. TAA.
++# '-m,5,-C,1' "$rB$C$D$E$rF$rG$H$I$z0$XJ$XK$XL$XM$XN" \
++# '-m,2,-v,-C,1' "$A$B$z0$XC$XD$XE$XF$XG$XH$XI$XJ$XK$XL$XM$XN" \
++# '-m,2,-v,-C,1,-o' "$z0$XC$XD$XE$XF$XG$XH$XI$XJ$XK$XL$XM$XN" \
+
+ # Test execution and reporting.
+ t=1
diff --git a/sys-apps/grep/grep-2.5.1a-r1.ebuild b/sys-apps/grep/grep-2.5.1a-r1.ebuild
new file mode 100644
index 00000000..4e521d27
--- /dev/null
+++ b/sys-apps/grep/grep-2.5.1a-r1.ebuild
@@ -0,0 +1,72 @@
+# Copyright 1999-2009 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.9 2009/04/09 16:09:35 loki_val 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 ppc64 s390 sh sparc ~sparc-fbsd x86 ~x86-fbsd"
+IUSE="nls pcre static"
+
+RDEPEND="nls? ( virtual/libintl )"
+DEPEND="${RDEPEND}
+ pcre? ( <=dev-libs/libpcre-7.8 )
+ nls? ( sys-devel/gettext )"
+
+WANT_AUTOMAKE="1.5"
+
+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
+ epatch "${FILESDIR}"/${P}-BJA-pcre-pkgconfig.diff
+
+ # retarded
+ sed -i 's:__mempcpy:mempcpy:g' lib/*.c || die
+ AT_M4DIR=m4 eautoreconf
+}
+
+src_compile() {
+ use static && append-ldflags -static
+
+ econf \
+ --bindir=/bin \
+ $(use_enable nls) \
+ $(use_enable pcre perl-regexp) \
+ || 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
+}