diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b22ef91
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+SOURCES/grep-2.20.tar.xz
diff --git a/.grep.metadata b/.grep.metadata
new file mode 100644
index 0000000..c128006
--- /dev/null
+++ b/.grep.metadata
@@ -0,0 +1 @@
+55aac6158b51baa505669cf8f86440bcc106ec65 SOURCES/grep-2.20.tar.xz
diff --git a/SOURCES/GREP_COLORS b/SOURCES/GREP_COLORS
new file mode 100644
index 0000000..1ef53a6
--- /dev/null
+++ b/SOURCES/GREP_COLORS
@@ -0,0 +1,4 @@
+# Configuration file for the color grep utility
+
+# 'none' shuts colorization off.
+#COLOR none
diff --git a/SOURCES/colorgrep.csh b/SOURCES/colorgrep.csh
new file mode 100644
index 0000000..b3152a6
--- /dev/null
+++ b/SOURCES/colorgrep.csh
@@ -0,0 +1,11 @@
+
+# color-grep initialization
+
+/usr/libexec/grepconf.sh -c
+if ( $status == 1 ) then
+    exit
+endif
+
+alias grep 'grep --color=auto'
+alias egrep 'egrep --color=auto'
+alias fgrep 'fgrep --color=auto'
diff --git a/SOURCES/colorgrep.sh b/SOURCES/colorgrep.sh
new file mode 100644
index 0000000..cd0539c
--- /dev/null
+++ b/SOURCES/colorgrep.sh
@@ -0,0 +1,7 @@
+# color-grep initialization
+
+/usr/libexec/grepconf.sh -c || return
+
+alias grep='grep --color=auto' 2>/dev/null
+alias egrep='egrep --color=auto' 2>/dev/null
+alias fgrep='fgrep --color=auto' 2>/dev/null
diff --git a/SOURCES/grep-2.20-CVE-2015-1345.patch b/SOURCES/grep-2.20-CVE-2015-1345.patch
new file mode 100644
index 0000000..d7e591d
--- /dev/null
+++ b/SOURCES/grep-2.20-CVE-2015-1345.patch
@@ -0,0 +1,90 @@
+--- a/THANKS
++++ b/THANKS
+@@ -70,6 +70,7 @@ Mike Frysinger             <vapier@gentoo.org>
+ Miles Bader                <miles@ccs.mt.nec.co.jp>
+ Mirraz Mirraz              <mirraz1@rambler.ru>
+ Nelson H. F. Beebe         <beebe@math.utah.edu>
++Nima Aghdaii               <naghdaii@fb.com>
+ Olaf Kirch                 <okir@ns.lst.de>
+ Paolo Bonzini              <bonzini@gnu.org>
+ Paul Eggert                <eggert@twinsun.com>
+--- a/src/kwset.c
++++ b/src/kwset.c
+@@ -643,6 +643,8 @@ bmexec_trans (kwset_t kwset, char const *text, size_t size)
+                     if (! tp)
+                       return -1;
+                     tp++;
++                    if (ep <= tp)
++                      break;
+                   }
+               }
+           }
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -72,6 +72,7 @@ TESTS =						\
+   inconsistent-range				\
+   invalid-multibyte-infloop			\
+   khadafy					\
++  kwset-abuse					\
+   long-line-vs-2GiB-read			\
+   max-count-overread				\
+   max-count-vs-context				\
+--- a/tests/Makefile.in
++++ b/tests/Makefile.in
+@@ -1371,6 +1371,7 @@ TESTS = \
+   inconsistent-range				\
+   invalid-multibyte-infloop			\
+   khadafy					\
++  kwset-abuse					\
+   long-line-vs-2GiB-read			\
+   max-count-overread				\
+   max-count-vs-context				\
+@@ -2021,6 +2022,13 @@ khadafy.log: khadafy
+ 	--log-file $$b.log --trs-file $$b.trs \
+ 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ 	"$$tst" $(AM_TESTS_FD_REDIRECT)
++kwset-abuse.log: kwset-abuse
++	@p='kwset-abuse'; \
++	b='kwset-abuse'; \
++	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
++	--log-file $$b.log --trs-file $$b.trs \
++	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
++	"$$tst" $(AM_TESTS_FD_REDIRECT)
+ long-line-vs-2GiB-read.log: long-line-vs-2GiB-read
+ 	@p='long-line-vs-2GiB-read'; \
+ 	b='long-line-vs-2GiB-read'; \
+--- a/dev/null
++++ b/tests/kwset-abuse
+@@ -0,0 +1,32 @@
++#! /bin/sh
++# Evoke a segfault in a hard-to-reach code path of kwset.c.
++# This bug affected grep versions 2.19 through 2.21.
++#
++# Copyright (C) 2015 Free Software Foundation, Inc.
++#
++# This program is free software: you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published by
++# the Free Software Foundation, either version 3 of the License, or
++# (at your option) any later version.
++
++# This program is distributed in the hope that it will be useful,
++# but WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++# GNU General Public License for more details.
++
++# You should have received a copy of the GNU General Public License
++# along with this program.  If not, see <http://www.gnu.org/licenses/>.
++
++. "${srcdir=.}/init.sh"; path_prepend_ ../src
++
++fail=0
++
++# This test case chooses a haystack of size 260,000, since prodding
++# with gdb showed a reallocation slightly larger than that in fillbuf.
++# To reach the buggy code, the needle must have length < 1/11 that of
++# the haystack, and 10,000 is a nice round number that fits the bill.
++printf '%0260000dXy\n' 0 | grep -F $(printf %010000dy 0)
++
++test $? = 1 || fail=1
++
++Exit $fail
diff --git a/SOURCES/grep-2.20-egrep-fgrep-symlinks.patch b/SOURCES/grep-2.20-egrep-fgrep-symlinks.patch
new file mode 100644
index 0000000..3ca0923
--- /dev/null
+++ b/SOURCES/grep-2.20-egrep-fgrep-symlinks.patch
@@ -0,0 +1,82 @@
+--- a/src/Makefile.am	
++++ a/src/Makefile.am	
+@@ -56,7 +56,8 @@ egrep fgrep: egrep.sh Makefile
+ 	sed -e 's|[@]SHELL@|$(SHELL)|g' \
+ 	    -e "$$edit_substring" \
+ 	    -e "s|[@]grep@|$$grep|g" \
+-	    -e "s|[@]option@|$$option|g" <$(srcdir)/egrep.sh >$@-t
++	    -e "s|[@]option@|$$option|g" \
++	    -e "s|[@]cmd@|$@|g" <$(srcdir)/egrep.sh >$@-t
+ 	$(AM_V_at)chmod +x $@-t
+ 	$(AM_V_at)mv $@-t $@
+ 
+--- a/src/Makefile.in	
++++ a/src/Makefile.in	
+@@ -1541,7 +1541,8 @@ egrep fgrep: egrep.sh Makefile
+ 	sed -e 's|[@]SHELL@|$(SHELL)|g' \
+ 	    -e "$$edit_substring" \
+ 	    -e "s|[@]grep@|$$grep|g" \
+-	    -e "s|[@]option@|$$option|g" <$(srcdir)/egrep.sh >$@-t
++	    -e "s|[@]option@|$$option|g" \
++	    -e "s|[@]cmd@|$@|g" <$(srcdir)/egrep.sh >$@-t
+ 	$(AM_V_at)chmod +x $@-t
+ 	$(AM_V_at)mv $@-t $@
+ 
+--- a/src/egrep.sh	
++++ a/src/egrep.sh	
+@@ -1,5 +1,6 @@ 
+ #!@SHELL@
+ grep=grep
++unset _EXECOPT _GREPOPT
+ case $0 in
+   */*)
+     dir=${0%/*}
+@@ -8,4 +9,9 @@ case $0 in
+       grep=@grep@
+     fi;;
+ esac
+-exec $grep @option@ "$@"
++if [ "$GREP_LEGACY_EGREP_FGREP_PS" = 1 ]; then
++  _EXECOPT="-a @cmd@"
++else
++  _GREPOPT=@option@
++fi
++exec $_EXECOPT $grep $_GREPOPT "$@"
+--- a/src/grep.c	
++++ a/src/grep.c	
+@@ -26,6 +26,7 @@ 
+ #include <fcntl.h>
+ #include <inttypes.h>
+ #include <stdio.h>
++#include <string.h>
+ #include "system.h"
+ 
+ #include "argmatch.h"
+@@ -1938,6 +1939,7 @@ fgrep_to_grep_pattern (size_t len, char const *keys,
+ int
+ main (int argc, char **argv)
+ {
++  char *ptr_c;
+   char *keys;
+   size_t keycc, oldcc, keyalloc;
+   int with_filenames;
+@@ -1984,6 +1986,19 @@ main (int argc, char **argv)
+   compile = matchers[0].compile;
+   execute = matchers[0].execute;
+ 
++  /* Check if executed through symlinks egrep/fgrep */
++  if (argv[0] != NULL)
++    {
++      ptr_c = strchrnul(argv[0], ' ');
++      if (ptr_c - argv[0] >= 5)
++        {
++          if (strncmp(ptr_c - 5, "egrep", 5) == 0)
++            setmatcher ("egrep");
++          else if (strncmp(ptr_c - 5, "fgrep", 5) == 0)
++            setmatcher ("fgrep");
++        }
++    }
++
+   while (prev_optind = optind,
+          (opt = get_nondigit_option (argc, argv, &default_context)) != -1)
+     switch (opt)
diff --git a/SOURCES/grep-2.20-help-align.patch b/SOURCES/grep-2.20-help-align.patch
new file mode 100644
index 0000000..cef6311
--- /dev/null
+++ b/SOURCES/grep-2.20-help-align.patch
@@ -0,0 +1,29 @@
+diff --git a/src/grep.c b/src/grep.c
+index 0fcc272..2208a4e 100644
+--- a/src/grep.c
++++ b/src/grep.c
+@@ -1579,16 +1579,19 @@ Output control:\n\
+   -D, --devices=ACTION      how to handle devices, FIFOs and sockets;\n\
+                             ACTION is 'read' or 'skip'\n\
+   -r, --recursive           like --directories=recurse\n\
+-  -R, --dereference-recursive  likewise, but follow all symlinks\n\
++  -R, --dereference-recursive\n\
++                            likewise, but follow all symlinks\n\
+ "));
+       printf (_("\
+-      --include=FILE_PATTERN  search only files that match FILE_PATTERN\n\
+-      --exclude=FILE_PATTERN  skip files and directories matching FILE_PATTERN\n\
++      --include=FILE_PATTERN\n\
++                            search only files that match FILE_PATTERN\n\
++      --exclude=FILE_PATTERN\n\
++                            skip files and directories matching FILE_PATTERN\n\
+       --exclude-from=FILE   skip files matching any file pattern from FILE\n\
+-      --exclude-dir=PATTERN  directories that match PATTERN will be skipped.\n\
++      --exclude-dir=PATTERN directories that match PATTERN will be skipped.\n\
+ "));
+       printf (_("\
+-  -L, --files-without-match  print only names of FILEs containing no match\n\
++  -L, --files-without-match print only names of FILEs containing no match\n\
+   -l, --files-with-matches  print only names of FILEs containing matches\n\
+   -c, --count               print only a count of matching lines per FILE\n\
+   -T, --initial-tab         make tabs line up (if needed)\n\
diff --git a/SOURCES/grep-2.20-long-pattern-speedup.patch b/SOURCES/grep-2.20-long-pattern-speedup.patch
new file mode 100644
index 0000000..bd7ccf9
--- /dev/null
+++ b/SOURCES/grep-2.20-long-pattern-speedup.patch
@@ -0,0 +1,119 @@
+diff --git a/src/dfa.c b/src/dfa.c
+index b9b7103..cd11db6 100644
+--- a/src/dfa.c
++++ b/src/dfa.c
+@@ -3894,13 +3894,13 @@ struct must
+ };
+ 
+ static must *
+-allocmust (must *mp)
++allocmust (must *mp, size_t size)
+ {
+   must *new_mp = xmalloc (sizeof *new_mp);
+   new_mp->in = xzalloc (sizeof *new_mp->in);
+-  new_mp->left = xzalloc (2);
+-  new_mp->right = xzalloc (2);
+-  new_mp->is = xzalloc (2);
++  new_mp->left = xzalloc (size);
++  new_mp->right = xzalloc (size);
++  new_mp->is = xzalloc (size);
+   new_mp->begline = false;
+   new_mp->endline = false;
+   new_mp->prev = mp;
+@@ -3933,24 +3933,23 @@ dfamust (struct dfa *d)
+ {
+   must *mp = NULL;
+   char const *result = "";
+-  size_t ri;
+   size_t i;
+   bool exact = false;
+   bool begline = false;
+   bool endline = false;
+   struct dfamust *dm;
+ 
+-  for (ri = 0; ri < d->tindex; ++ri)
++  for (size_t ri = 0; ri < d->tindex; ++ri)
+     {
+       token t = d->tokens[ri];
+       switch (t)
+         {
+         case BEGLINE:
+-          mp = allocmust (mp);
++          mp = allocmust (mp, 2);
+           mp->begline = true;
+           break;
+         case ENDLINE:
+-          mp = allocmust (mp);
++          mp = allocmust (mp, 2);
+           mp->endline = true;
+           break;
+         case LPAREN:
+@@ -3965,7 +3964,7 @@ dfamust (struct dfa *d)
+         case BACKREF:
+         case ANYCHAR:
+         case MBCSET:
+-          mp = allocmust (mp);
++          mp = allocmust (mp, 2);
+           break;
+ 
+         case STAR:
+@@ -4082,7 +4081,6 @@ dfamust (struct dfa *d)
+           goto done;
+ 
+         default:
+-          mp = allocmust (mp);
+           if (CSET <= t)
+             {
+               /* If T is a singleton, or if case-folding in a unibyte
+@@ -4095,7 +4093,10 @@ dfamust (struct dfa *d)
+                 if (tstbit (j, *ccl))
+                   break;
+               if (! (j < NOTCHAR))
+-                break;
++                {
++                  mp = allocmust (mp, 2);
++                  break;
++                }
+               t = j;
+               while (++j < NOTCHAR)
+                 if (tstbit (j, *ccl)
+@@ -4103,12 +4104,36 @@ dfamust (struct dfa *d)
+                           && toupper (j) == toupper (t)))
+                   break;
+               if (j < NOTCHAR)
+-                break;
++                {
++                  mp = allocmust (mp, 2);
++                  break;
++                }
+             }
++
++          size_t rj = ri + 2;
++          if (d->tokens[ri + 1] == CAT)
++            {
++              for (; rj < d->tindex - 1; rj += 2)
++                {
++                  if ((rj != ri && (d->tokens[rj] <= 0
++                                    || NOTCHAR <= d->tokens[rj]))
++                      || d->tokens[rj + 1] != CAT)
++                    break;
++                }
++            }
++          mp = allocmust (mp, ((rj - ri) >> 1) + 1);
+           mp->is[0] = mp->left[0] = mp->right[0]
+             = case_fold && !d->multibyte ? toupper (t) : t;
+-          mp->is[1] = mp->left[1] = mp->right[1] = '\0';
+-          mp->in = enlist (mp->in, mp->is, 1);
++
++          for (i = 1; ri + 2 < rj; i++)
++            {
++              ri += 2;
++              t = d->tokens[ri];
++              mp->is[i] = mp->left[i] = mp->right[i]
++                = case_fold && MB_CUR_MAX == 1 ? toupper (t) : t;
++            }
++          mp->is[i] = mp->left[i] = mp->right[i] = '\0';
++          mp->in = enlist (mp->in, mp->is, i - 1);
+           break;
+         }
+     }
diff --git a/SOURCES/grep-2.20-man-fix-gs.patch b/SOURCES/grep-2.20-man-fix-gs.patch
new file mode 100644
index 0000000..db3dd24
--- /dev/null
+++ b/SOURCES/grep-2.20-man-fix-gs.patch
@@ -0,0 +1,61 @@
+diff --git a/doc/grep.in.1 b/doc/grep.in.1
+index 58a6c0e..3e6a8cf 100644
+--- a/doc/grep.in.1
++++ b/doc/grep.in.1
+@@ -377,7 +377,7 @@ Print
+ .I NUM
+ lines of trailing context after matching lines.
+ Places a line containing a group separator
+-.RB ( \-\^\- )
++.RB "(described under " \-\^\-group\-separator )
+ between contiguous groups of matches.
+ With the
+ .B \-o
+@@ -390,7 +390,7 @@ Print
+ .I NUM
+ lines of leading context before matching lines.
+ Places a line containing a group separator
+-.RB ( \-\^\- )
++.RB "(described under " \-\^\-group\-separator )
+ between contiguous groups of matches.
+ With the
+ .B \-o
+@@ -403,13 +403,24 @@ Print
+ .I NUM
+ lines of output context.
+ Places a line containing a group separator
+-.RB ( \-\^\- )
++.RB "(described under " \-\^\-group\-separator )
+ between contiguous groups of matches.
+ With the
+ .B \-o
+ or
+ .B \-\^\-only\-matching
+ option, this has no effect and a warning is given.
++.TP
++.BI \-\^\-group\-separator= SEP
++Use
++.I SEP
++as a group separator. By default
++.I SEP
++is double hyphen
++.RB ( \-\^\- ).
++.TP
++.B \-\^\-no\-group-separator
++Use empty string as a group separator.
+ .SS "File and Directory Selection"
+ .TP
+ .BR \-a ", " \-\^\-text
+diff --git a/src/grep.c b/src/grep.c
+index 7c0f8a8..0fcc272 100644
+--- a/src/grep.c
++++ b/src/grep.c
+@@ -1602,6 +1602,8 @@ Context control:\n\
+ "));
+       printf (_("\
+   -NUM                      same as --context=NUM\n\
++      --group-separator=SEP use SEP as a group separator\n\
++      --no-group-separator  use empty string as a group separator\n\
+       --color[=WHEN],\n\
+       --colour[=WHEN]       use markers to highlight the matching strings;\n\
+                             WHEN is 'always', 'never', or 'auto'\n\
diff --git a/SOURCES/grep-2.20-man-fixed-regexp-option.patch b/SOURCES/grep-2.20-man-fixed-regexp-option.patch
new file mode 100644
index 0000000..93b1e7b
--- /dev/null
+++ b/SOURCES/grep-2.20-man-fixed-regexp-option.patch
@@ -0,0 +1,22 @@
+diff --git a/doc/grep.in.1 b/doc/grep.in.1
+index 3e6a8cf..480f205 100644
+--- a/doc/grep.in.1
++++ b/doc/grep.in.1
+@@ -97,13 +97,15 @@ as an extended regular expression (ERE, see below).
+ .RB ( \-E
+ is specified by \s-1POSIX\s0.)
+ .TP
+-.BR \-F ", " \-\^\-fixed\-strings
++.BR \-F ", " \-\^\-fixed\-strings ", " \-\^\-fixed\-regexp
+ Interpret
+ .I PATTERN
+ as a list of fixed strings, separated by newlines,
+ any of which is to be matched.
+ .RB ( \-F
+-is specified by \s-1POSIX\s0.)
++is specified by \s-1POSIX\s0,
++.BR \-\^\-fixed\-regexp
++is an obsoleted alias, please do not use it in new scripts.)
+ .TP
+ .BR \-G ", " \-\^\-basic\-regexp
+ Interpret
diff --git a/SOURCES/grep-2.20-pcre-backported-fixes.patch b/SOURCES/grep-2.20-pcre-backported-fixes.patch
new file mode 100644
index 0000000..008eae0
--- /dev/null
+++ b/SOURCES/grep-2.20-pcre-backported-fixes.patch
@@ -0,0 +1,389 @@
+diff --git a/src/grep.h b/src/grep.h
+index 4935872..729c906 100644
+--- a/src/grep.h
++++ b/src/grep.h
+@@ -27,4 +27,19 @@ extern int match_words;		/* -w */
+ extern int match_lines;		/* -x */
+ extern unsigned char eolbyte;	/* -z */
+ 
++/* An enum textbin describes the file's type, inferred from data read
++   before the first line is selected for output.  */
++enum textbin
++  {
++    /* Binary, as it contains null bytes and the -z option is not in effect,
++       or it contains encoding errors.  */
++    TEXTBIN_BINARY = -1,
++
++    /* Not known yet.  Only text has been seen so far.  */
++    TEXTBIN_UNKNOWN = 0,
++
++    /* Text.  */
++    TEXTBIN_TEXT = 1
++  };
++
+ #endif
+diff --git a/src/pcresearch.c b/src/pcresearch.c
+index 820dd00..9938ffc 100644
+--- a/src/pcresearch.c
++++ b/src/pcresearch.c
+@@ -33,13 +33,19 @@ static pcre *cre;
+ /* Additional information about the pattern.  */
+ static pcre_extra *extra;
+ 
+-# ifdef PCRE_STUDY_JIT_COMPILE
+-static pcre_jit_stack *jit_stack;
+-# else
++# ifndef PCRE_STUDY_JIT_COMPILE
+ #  define PCRE_STUDY_JIT_COMPILE 0
+ # endif
+ #endif
+ 
++/* Table, indexed by ! (flag & PCRE_NOTBOL), of whether the empty
++   string matches when that flag is used.  */
++static int empty_match[2];
++
++/* This must be at least 2; everything after that is for performance
++   in pcre_exec.  */
++enum { NSUB = 300 };
++
+ void
+ Pcompile (char const *pattern, size_t size)
+ {
+@@ -52,13 +58,17 @@ Pcompile (char const *pattern, size_t size)
+   char const *ep;
+   char *re = xnmalloc (4, size + 7);
+   int flags = (PCRE_MULTILINE
+-               | (match_icase ? PCRE_CASELESS : 0)
+-               | (using_utf8 () ? PCRE_UTF8 : 0));
++               | (match_icase ? PCRE_CASELESS : 0));
+   char const *patlim = pattern + size;
+   char *n = re;
+   char const *p;
+   char const *pnul;
+ 
++  if (using_utf8 ())
++    flags |= PCRE_UTF8;
++  else if (MB_CUR_MAX != 1)
++    error (EXIT_TROUBLE, 0, _("-P supports only unibyte and UTF-8 locales"));
++
+   /* FIXME: Remove these restrictions.  */
+   if (memchr (pattern, '\n', size))
+     error (EXIT_TROUBLE, 0, _("the -P option only supports a single pattern"));
+@@ -114,14 +124,20 @@ Pcompile (char const *pattern, size_t size)
+       /* A 32K stack is allocated for the machine code by default, which
+          can grow to 512K if necessary. Since JIT uses far less memory
+          than the interpreter, this should be enough in practice.  */
+-      jit_stack = pcre_jit_stack_alloc (32 * 1024, 512 * 1024);
++      pcre_jit_stack *jit_stack = pcre_jit_stack_alloc (32 * 1024, 512 * 1024);
+       if (!jit_stack)
+         error (EXIT_TROUBLE, 0,
+                _("failed to allocate memory for the PCRE JIT stack"));
+       pcre_assign_jit_stack (extra, NULL, jit_stack);
+     }
++
+ # endif
+   free (re);
++
++  int sub[NSUB];
++  empty_match[false] = pcre_exec (cre, extra, "", 0, 0,
++                                  PCRE_NOTBOL, sub, NSUB);
++  empty_match[true] = pcre_exec (cre, extra, "", 0, 0, 0, sub, NSUB);
+ #endif /* HAVE_LIBPCRE */
+ }
+ 
+@@ -134,36 +150,110 @@ Pexecute (char const *buf, size_t size, size_t *match_size,
+   error (EXIT_TROUBLE, 0, _("internal error"));
+   return -1;
+ #else
+-  /* This array must have at least two elements; everything after that
+-     is just for performance improvement in pcre_exec.  */
+-  int sub[300];
+-
+-  const char *line_buf, *line_end, *line_next;
++  int sub[NSUB];
++  char const *p = start_ptr ? start_ptr : buf;
++  bool bol = p[-1] == eolbyte;
++  char const *line_start = buf;
+   int e = PCRE_ERROR_NOMATCH;
+-  ptrdiff_t start_ofs = start_ptr ? start_ptr - buf : 0;
++  char const *line_end;
+ 
+-  /* PCRE can't limit the matching to single lines, therefore we have to
+-     match each line in the buffer separately.  */
+-  for (line_next = buf;
+-       e == PCRE_ERROR_NOMATCH && line_next < buf + size;
+-       start_ofs -= line_next - line_buf)
++  /* If the input type is unknown, the caller is still testing the
++     input, which means the current buffer cannot contain encoding
++     errors and a multiline search is typically more efficient.
++     Otherwise, a single-line search is typically faster, so that
++     pcre_exec doesn't waste time validating the entire input
++     buffer.  */
++  bool multiline = TEXTBIN_UNKNOWN;
++
++  for (; p < buf + size; p = line_start = line_end + 1)
+     {
+-      line_buf = line_next;
+-      line_end = memchr (line_buf, eolbyte, (buf + size) - line_buf);
+-      if (line_end == NULL)
+-        line_next = line_end = buf + size;
+-      else
+-        line_next = line_end + 1;
++      bool too_big;
+ 
+-      if (start_ptr && start_ptr >= line_end)
+-        continue;
++      if (multiline)
++        {
++          size_t pcre_size_max = MIN (INT_MAX, SIZE_MAX - 1);
++          size_t scan_size = MIN (pcre_size_max + 1, buf + size - p);
++          line_end = memrchr (p, eolbyte, scan_size);
++          too_big = ! line_end;
++        }
++      else
++        {
++          line_end = memchr (p, eolbyte, buf + size - p);
++          too_big = INT_MAX < line_end - p;
++        }
+ 
+-      if (INT_MAX < line_end - line_buf)
++      if (too_big)
+         error (EXIT_TROUBLE, 0, _("exceeded PCRE's line length limit"));
+ 
+-      e = pcre_exec (cre, extra, line_buf, line_end - line_buf,
+-                     start_ofs < 0 ? 0 : start_ofs, 0,
+-                     sub, sizeof sub / sizeof *sub);
++      for (;;)
++        {
++          /* Skip past bytes that are easily determined to be encoding
++             errors, treating them as data that cannot match.  This is
++             faster than having pcre_exec check them.  */
++          while (mbclen_cache[to_uchar (*p)] == (size_t) -1)
++            {
++              p++;
++              bol = false;
++            }
++
++          /* Check for an empty match; this is faster than letting
++             pcre_exec do it.  */
++          int search_bytes = line_end - p;
++          if (search_bytes == 0)
++            {
++              sub[0] = sub[1] = 0;
++              e = empty_match[bol];
++              break;
++            }
++
++          int options = 0;
++          if (!bol)
++            options |= PCRE_NOTBOL;
++          if (multiline)
++            options |= PCRE_NO_UTF8_CHECK;
++
++          e = pcre_exec (cre, extra, p, search_bytes, 0,
++                         options, sub, NSUB);
++          if (e != PCRE_ERROR_BADUTF8)
++            {
++              if (0 < e && multiline && sub[1] - sub[0] != 0)
++                {
++                  char const *nl = memchr (p + sub[0], eolbyte,
++                                           sub[1] - sub[0]);
++                  if (nl)
++                    {
++                      /* This match crosses a line boundary; reject it.  */
++                      p += sub[0];
++                      line_end = nl;
++                      continue;
++                    }
++                }
++              break;
++            }
++          int valid_bytes = sub[0];
++
++          /* Try to match the string before the encoding error.
++             Again, handle the empty-match case specially, for speed.  */
++          if (valid_bytes == 0)
++            {
++              sub[1] = 0;
++              e = empty_match[bol];
++            }
++          else
++            e = pcre_exec (cre, extra, p, valid_bytes, 0,
++                           options | PCRE_NO_UTF8_CHECK | PCRE_NOTEOL,
++                           sub, NSUB);
++          if (e != PCRE_ERROR_NOMATCH || valid_bytes < 0)
++            break;
++
++          /* Treat the encoding error as data that cannot match.  */
++          p += valid_bytes + 1;
++          bol = false;
++        }
++
++      if (e != PCRE_ERROR_NOMATCH)
++        break;
++      bol = true;
+     }
+ 
+   if (e <= 0)
+@@ -171,7 +261,7 @@ Pexecute (char const *buf, size_t size, size_t *match_size,
+       switch (e)
+         {
+         case PCRE_ERROR_NOMATCH:
+-          return -1;
++          break;
+ 
+         case PCRE_ERROR_NOMEMORY:
+           error (EXIT_TROUBLE, 0, _("memory exhausted"));
+@@ -180,10 +270,6 @@ Pexecute (char const *buf, size_t size, size_t *match_size,
+           error (EXIT_TROUBLE, 0,
+                  _("exceeded PCRE's backtracking limit"));
+ 
+-        case PCRE_ERROR_BADUTF8:
+-          error (EXIT_TROUBLE, 0,
+-                 _("invalid UTF-8 byte sequence in input"));
+-
+         default:
+           /* For now, we lump all remaining PCRE failures into this basket.
+              If anyone cares to provide sample grep usage that can trigger
+@@ -192,30 +278,33 @@ Pexecute (char const *buf, size_t size, size_t *match_size,
+           error (EXIT_TROUBLE, 0, _("internal PCRE error: %d"), e);
+         }
+ 
+-      /* NOTREACHED */
+       return -1;
+     }
+   else
+     {
+-      /* Narrow down to the line we've found.  */
+-      char const *beg = line_buf + sub[0];
+-      char const *end = line_buf + sub[1];
+-      char const *buflim = buf + size;
+-      char eol = eolbyte;
+-      if (!start_ptr)
++      char const *matchbeg = p + sub[0];
++      char const *matchend = p + sub[1];
++      char const *beg;
++      char const *end;
++      if (start_ptr)
+         {
+-          /* FIXME: The case when '\n' is not found indicates a bug:
+-             Since grep is line oriented, the match should never contain
+-             a newline, so there _must_ be a newline following.
+-           */
+-          if (!(end = memchr (end, eol, buflim - end)))
+-            end = buflim;
+-          else
+-            end++;
+-          while (buf < beg && beg[-1] != eol)
+-            --beg;
++          beg = matchbeg;
++          end = matchend;
++        }
++      else if (multiline)
++        {
++          char const *prev_nl = memrchr (line_start - 1, eolbyte,
++                                         matchbeg - (line_start - 1));
++          char const *next_nl = memchr (matchend, eolbyte,
++                                        line_end + 1 - matchend);
++          beg = prev_nl + 1;
++          end = next_nl + 1;
++        }
++      else
++        {
++          beg = line_start;
++          end = line_end + 1;
+         }
+-
+       *match_size = end - beg;
+       return beg - buf;
+     }
+diff --git a/src/search.h b/src/search.h
+index 14877bc..e671bea 100644
+--- a/src/search.h
++++ b/src/search.h
+@@ -45,6 +45,7 @@ extern void kwsinit (kwset_t *);
+ 
+ extern char *mbtoupper (char const *, size_t *, mb_len_map_t **);
+ extern void build_mbclen_cache (void);
++extern size_t mbclen_cache[];
+ extern ptrdiff_t mb_goback (char const **, char const *, char const *);
+ extern wint_t mb_prev_wc (char const *, char const *, char const *);
+ extern wint_t mb_next_wc (char const *, char const *);
+diff --git a/src/searchutils.c b/src/searchutils.c
+index 5eb9a12..aba9335 100644
+--- a/src/searchutils.c
++++ b/src/searchutils.c
+@@ -22,7 +22,7 @@
+ 
+ #define NCHAR (UCHAR_MAX + 1)
+ 
+-static size_t mbclen_cache[NCHAR];
++size_t mbclen_cache[NCHAR];
+ 
+ void
+ kwsinit (kwset_t *kwset)
+diff --git a/tests/pcre-infloop b/tests/pcre-infloop
+index 1b33e72..8054844 100755
+--- a/tests/pcre-infloop
++++ b/tests/pcre-infloop
+@@ -18,16 +18,16 @@
+ # along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ 
+ . "${srcdir=.}/init.sh"; path_prepend_ ../src
+-require_pcre_
+ require_timeout_
+ require_en_utf8_locale_
+ require_compiled_in_MB_support
++LC_ALL=en_US.UTF-8 require_pcre_
+ 
+ printf 'a\201b\r' > in || framework_failure_
+ 
+ fail=0
+ 
+ LC_ALL=en_US.UTF-8 timeout 3 grep -P 'a.?..b' in
+-test $? = 2 || fail_ "libpcre's match function appears to infloop"
++test $? = 1 || fail_ "libpcre's match function appears to infloop"
+ 
+ Exit $fail
+diff --git a/tests/pcre-invalid-utf8-input b/tests/pcre-invalid-utf8-input
+index 913e8ee..abcc7e8 100755
+--- a/tests/pcre-invalid-utf8-input
++++ b/tests/pcre-invalid-utf8-input
+@@ -8,14 +8,19 @@
+ # notice and this notice are preserved.
+ 
+ . "${srcdir=.}/init.sh"; path_prepend_ ../src
+-require_pcre_
++require_timeout_
+ require_en_utf8_locale_
++require_compiled_in_MB_support
++LC_ALL=en_US.UTF-8 require_pcre_
+ 
+ fail=0
+ 
+-printf 'j\202\nj\n' > in || framework_failure_
++printf 'j\202j\nj\nk\202\n' > in || framework_failure_
+ 
+-LC_ALL=en_US.UTF-8 grep -P j in
+-test $? -eq 2 || fail=1
++LC_ALL=en_US.UTF-8 timeout 3 grep -P j in
++test $? -eq 0 || fail=1
++
++LC_ALL=en_US.UTF-8 timeout 3 grep -P 'k$' in
++test $? -eq 1 || fail=1
+ 
+ Exit $fail
+diff --git a/tests/pcre-utf8 b/tests/pcre-utf8
+index 41676f4..2dda116 100755
+--- a/tests/pcre-utf8
++++ b/tests/pcre-utf8
+@@ -8,8 +8,8 @@
+ # notice and this notice are preserved.
+ 
+ . "${srcdir=.}/init.sh"; path_prepend_ ../src
+-require_pcre_
+ require_en_utf8_locale_
++LC_ALL=en_US.UTF-8 require_pcre_
+ 
+ fail=0
+ 
diff --git a/SOURCES/grep-2.20-w-multibyte-fix.patch b/SOURCES/grep-2.20-w-multibyte-fix.patch
new file mode 100644
index 0000000..403d9c0
--- /dev/null
+++ b/SOURCES/grep-2.20-w-multibyte-fix.patch
@@ -0,0 +1,145 @@
+--- a/src/dfa.c
++++ b/src/dfa.c
+@@ -1238,6 +1238,20 @@ parse_bracket_exp (void)
+   return CSET + charclass_index (ccl);
+ }
+ 
++#define PUSH_LEX_STATE(s)			\
++  do						\
++    {						\
++      char const *lexptr_saved = lexptr;	\
++      size_t lexleft_saved = lexleft;		\
++      lexptr = (s);				\
++      lexleft = strlen (lexptr)
++
++#define POP_LEX_STATE()				\
++      lexptr = lexptr_saved;			\
++      lexleft = lexleft_saved;			\
++    }						\
++  while (0)
++
+ static token
+ lex (void)
+ {
+@@ -1485,20 +1499,6 @@ lex (void)
+               return lasttok = CSET + charclass_index (ccl);
+             }
+ 
+-#define PUSH_LEX_STATE(s)			\
+-  do						\
+-    {						\
+-      char const *lexptr_saved = lexptr;	\
+-      size_t lexleft_saved = lexleft;		\
+-      lexptr = (s);				\
+-      lexleft = strlen (lexptr)
+-
+-#define POP_LEX_STATE()				\
+-      lexptr = lexptr_saved;			\
+-      lexleft = lexleft_saved;			\
+-    }						\
+-  while (0)
+-
+           /* FIXME: see if optimizing this, as is done with ANYCHAR and
+              add_utf8_anychar, makes sense.  */
+ 
+@@ -1518,14 +1518,33 @@ lex (void)
+         case 'W':
+           if (!backslash || (syntax_bits & RE_NO_GNU_OPS))
+             goto normal_char;
+-          zeroset (ccl);
+-          for (c2 = 0; c2 < NOTCHAR; ++c2)
+-            if (IS_WORD_CONSTITUENT (c2))
+-              setbit (c2, ccl);
+-          if (c == 'W')
+-            notset (ccl);
++
++          if (!dfa->multibyte)
++            {
++              zeroset (ccl);
++              for (c2 = 0; c2 < NOTCHAR; ++c2)
++                if (IS_WORD_CONSTITUENT (c2))
++                  setbit (c2, ccl);
++              if (c == 'W')
++                notset (ccl);
++              laststart = false;
++              return lasttok = CSET + charclass_index (ccl);
++            }
++
++          /* FIXME: see if optimizing this, as is done with ANYCHAR and
++             add_utf8_anychar, makes sense.  */
++
++          /* \w and \W are documented to be equivalent to [_[:alnum:]] and
++             [^_[:alnum:]] respectively, so tell the lexer to process those
++             strings, each minus its "already processed" '['.  */
++          PUSH_LEX_STATE (c == 'w' ? "_[:alnum:]]" : "^_[:alnum:]]");
++
++          lasttok = parse_bracket_exp ();
++
++          POP_LEX_STATE ();
++
+           laststart = false;
+-          return lasttok = CSET + charclass_index (ccl);
++          return lasttok;
+ 
+         case '[':
+           if (backslash)
+--- a/tests/Makefile.am
++++ b/tests/Makefile.am
+@@ -110,6 +110,7 @@ TESTS =						\
+   warn-char-classes				\
+   word-delim-multibyte				\
+   word-multi-file				\
++  word-multibyte				\
+   yesno
+ 
+ EXTRA_DIST =					\
+--- a/tests/Makefile.in
++++ b/tests/Makefile.in
+@@ -1409,6 +1409,7 @@ TESTS = \
+   warn-char-classes				\
+   word-delim-multibyte				\
+   word-multi-file				\
++  word-multibyte				\
+   yesno
+ 
+ EXTRA_DIST = \
+@@ -2286,6 +2287,13 @@ word-multi-file.log: word-multi-file
+ 	--log-file $$b.log --trs-file $$b.trs \
+ 	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ 	"$$tst" $(AM_TESTS_FD_REDIRECT)
++word-multibyte.log: word-multibyte
++	@p='word-multibyte'; \
++	b='word-multibyte'; \
++	$(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
++	--log-file $$b.log --trs-file $$b.trs \
++	$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
++	"$$tst" $(AM_TESTS_FD_REDIRECT)
+ yesno.log: yesno
+ 	@p='yesno'; \
+ 	b='yesno'; \
+--- a/dev/null
++++ a/tests/word-multibyte
+@@ -0,0 +1,23 @@ 
++#!/bin/sh
++# This would fail for grep-2.20
++. "${srcdir=.}/init.sh"; path_prepend_ ../src
++
++require_en_utf8_locale_
++
++printf '\xc3\xa1\n' > in || framework_failure_
++LC_ALL=en_US.UTF-8
++export LC_ALL
++
++fail=0
++
++for LOC in en_US.UTF-8 zh_CN $LOCALE_FR_UTF8; do
++  out=out1-$LOC
++  LC_ALL=$LOC grep '\w' in >$out || fail=1
++  compare in $out || fail=1
++
++  out=out2-$LOC
++  LC_ALL=$LOC grep '\W' in >$out && fail=1
++  compare /dev/null $out || fail=1
++done
++
++Exit $fail
diff --git a/SOURCES/grepconf.sh b/SOURCES/grepconf.sh
new file mode 100644
index 0000000..418af0b
--- /dev/null
+++ b/SOURCES/grepconf.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+case "$1" in
+    -c | --interactive-color)
+        ! grep -qsi "^COLOR.*none" /etc/GREP_COLORS
+        ;;
+    *)
+        echo >&2 "Invalid / no option passed, so far only -c | --interactive-color is supported."
+        exit 1
+        ;;
+esac
diff --git a/SPECS/grep.spec b/SPECS/grep.spec
new file mode 100644
index 0000000..2abc1fc
--- /dev/null
+++ b/SPECS/grep.spec
@@ -0,0 +1,647 @@
+%define _bindir /bin
+
+Summary: Pattern matching utilities
+Name: grep
+Version: 2.20
+Release: 3%{?dist}
+License: GPLv3+
+Group: Applications/Text
+Source: ftp://ftp.gnu.org/pub/gnu/grep/grep-%{version}.tar.xz
+Source1: colorgrep.sh
+Source2: colorgrep.csh
+Source3: GREP_COLORS
+Source4: grepconf.sh
+# upstream ticket 39444
+Patch0: grep-2.20-man-fix-gs.patch
+# upstream ticket 39445
+Patch1: grep-2.20-help-align.patch
+# rhbz#1159012
+Patch2: grep-2.20-w-multibyte-fix.patch
+# rhbz#1103259
+Patch3: grep-2.20-man-fixed-regexp-option.patch
+# rhbz#1217080
+Patch4: grep-2.20-pcre-backported-fixes.patch
+# rhbz#1194315
+Patch5: grep-2.20-CVE-2015-1345.patch
+Patch6: grep-2.20-egrep-fgrep-symlinks.patch
+# rhbz#1413029, backported from upstream
+Patch7: grep-2.20-long-pattern-speedup.patch
+URL: http://www.gnu.org/software/grep/
+Requires(post): /sbin/install-info
+Requires(preun): /sbin/install-info
+BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
+BuildRequires: pcre-devel >= 7.8-7, texinfo, gettext
+BuildRequires: autoconf automake
+# https://fedorahosted.org/fpc/ticket/174
+Provides: bundled(gnulib)
+
+%description
+The GNU versions of commonly used grep utilities. Grep searches through
+textual input for lines which contain a match to a specified pattern and then
+prints the matching lines. GNU's grep utilities include grep, egrep and fgrep.
+
+GNU grep is needed by many scripts, so it shall be installed on every system.
+
+%prep
+%setup -q
+%patch0 -p1 -b .man-fix-gs
+%patch1 -p1 -b .help-align
+%patch2 -p1 -b .w-multibyte-fix
+%patch3 -p1 -b .man-fixed-rexexp-option
+%patch4 -p1 -b .pcre-backported-fixes
+%patch5 -p1 -b .CVE-2015-1345
+%patch6 -p1 -b .egrep-fgrep-symlinks
+%patch7 -p1 -b .long-pattern-speedup
+
+chmod 755 tests/word-multibyte
+chmod 755 tests/pcre-invalid-utf8-input
+chmod 755 tests/pcre-utf8
+chmod 755 tests/kwset-abuse
+
+%build
+%global BUILD_FLAGS $RPM_OPT_FLAGS
+
+# Currently gcc on ppc uses double-double arithmetic for long double and it
+# does not conform to the IEEE floating-point standard. Thus force
+# long double to be double and conformant.
+%ifarch ppc ppc64
+%global BUILD_FLAGS %{BUILD_FLAGS} -mlong-double-64
+%endif
+
+%configure --without-included-regex CPPFLAGS="-I%{_includedir}/pcre" \
+  CFLAGS="%{BUILD_FLAGS}"
+make %{?_smp_mflags}
+
+%install
+rm -rf ${RPM_BUILD_ROOT}
+make %{?_smp_mflags} DESTDIR=$RPM_BUILD_ROOT install
+gzip $RPM_BUILD_ROOT%{_infodir}/grep*
+rm -f $RPM_BUILD_ROOT%{_infodir}/dir
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
+install -pm 644 %{SOURCE1} %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
+install -pm 644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}
+install -Dpm 755 %{SOURCE4} $RPM_BUILD_ROOT%{_libexecdir}/grepconf.sh
+
+%find_lang %name
+
+%check
+make check
+
+%clean
+rm -rf ${RPM_BUILD_ROOT}
+
+%post
+/sbin/install-info --quiet --info-dir=%{_infodir} %{_infodir}/grep.info.gz || :
+
+%preun
+if [ $1 = 0 ]; then
+	/sbin/install-info --quiet --info-dir=%{_infodir} --delete %{_infodir}/grep.info.gz || :
+fi
+
+%files -f %{name}.lang
+%defattr(-,root,root,-)
+%doc ABOUT-NLS AUTHORS THANKS TODO NEWS README ChangeLog COPYING
+
+%{_bindir}/*
+%config(noreplace) %{_sysconfdir}/profile.d/colorgrep.*sh
+%config(noreplace) %{_sysconfdir}/GREP_COLORS
+%{_infodir}/*.info*.gz
+%{_mandir}/*/*
+%{_libexecdir}/grepconf.sh
+
+%changelog
+* Fri Mar 24 2017 Jaroslav Škarvada <jskarvad@redhat.com> - 2.20-3
+- Speedup DFA for long patterns and fixed begline/endline matching
+  Resolves: rhbz#1413029
+- Added support for GREP_LEGACY_EGREP_FGREP_PS environmental variable which
+  controls how egrep, fgrep show in ps output
+  Resolves: rhbz#1297441
+
+* Wed Apr 29 2015 Jaroslav Škarvada <jskarvad@redhat.com> - 2.20-2
+- Fixed invalid UTF-8 byte sequence error in PCRE mode
+  (by pcre-backported-fixes patch)
+  Resolves: rhbz#1217080
+- Fixed buffer overrun for grep -F
+  Resolves: CVE-2015-1345
+- Fixed \w and \W behaviour in multibyte locales
+  Resolves: rhbz#1159012
+- Documented --fixed-regexp option
+  Resolves: rhbz#1103259
+- Updated pcre buildrequires to require pcre-devel >= 7.8-7
+  Related: rhbz#1217080
+
+* Fri Sep  5 2014 Jaroslav Škarvada <jskarvad@redhat.com> - 2.20-1
+- New version
+  Resolves: rhbz#1123005
+
+* Tue Feb 04 2014 Jan Grulich <jgrulich@redhat.com> - 2.16-1
+- Update to 2.16
+- Resolves: rhbz#1050916
+- Resolves: rhbz#1050919
+
+* Fri Jan 24 2014 Daniel Mach <dmach@redhat.com> - 2.14-6
+- Mass rebuild 2014-01-24
+
+* Fri Dec 27 2013 Daniel Mach <dmach@redhat.com> - 2.14-5
+- Mass rebuild 2013-12-27
+
+* Tue Jul  9 2013 Jaroslav Škarvada <jskarvad@redhat.com> - 2.14-4
+- Added group-separator, no-group-separator options decription
+- Aligned output of built-in help
+- Defuzzified gnulib-tests-rm-f patch
+
+* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.14-3
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
+
+* Wed Oct  3 2012 Jaroslav Škarvada <jskarvad@redhat.com> - 2.14-2
+- Fixed -R option placement
+  Resolves: rhbz#861937
+
+* Mon Aug 20 2012 Jaroslav Škarvada <jskarvad@redhat.com> - 2.14-1
+- New version
+  Resolves: rhbz#849594
+
+* Thu Jul 19 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.13-2
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
+
+* Tue Jul 10 2012 Jaroslav Škarvada <jskarvad@redhat.com> - 2.13-1
+- New version
+  Resolves: rhbz#837749
+- Fixed -i option
+  Resolves: rhbz#828844
+- Added virtual provide and FPC ticket link for bundled gnulib
+  Resolves: rhbz#821759
+
+* Tue Apr 24 2012 Jaroslav Škarvada <jskarvad@redhat.com> - 2.12-1
+- New version
+  Resolves: rhbz#815705
+
+* Fri Mar  2 2012 Jaroslav Škarvada <jskarvad@redhat.com> - 2.11-1
+- New version
+
+* Fri Feb 10 2012 Petr Pisar <ppisar@redhat.com> - 2.10-3
+- Rebuild against PCRE 8.30
+
+* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.10-2
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
+
+* Wed Nov 16 2011 Jaroslav Škarvada <jskarvad@redhat.com> - 2.10-1
+- New version
+
+* Mon Jul 11 2011 Jaroslav Škarvada <jskarvad@redhat.com> - 2.9-3
+- Use rm -f in gnulib-tests (gnulib-tests-rm-f patch)
+  Resolves: rhbz#716330
+
+* Mon Jul 04 2011 Jaroslav Škarvada <jskarvad@redhat.com> - 2.9-2
+- Fixed build failure on ppc - long double forced to double on ppc
+
+* Wed Jun 22 2011 Jaroslav Škarvada <jskarvad@redhat.com> - 2.9-1
+- New version: grep-2.9
+- Removed dfa-buffer-overrun-fix patch
+
+* Mon Jun 20 2011 Jaroslav Škarvada <jskarvad@redhat.com> - 2.8-4
+- dfa: don't overrun a malloc'd buffer for certain regexps
+  (patch dfa-buffer-overrun-fix)
+  Resolves: rhbz#713328
+
+* Mon May 16 2011 Jaroslav Škarvada <jskarvad@redhat.com> - 2.8-3
+- Added coloring aliases to csh script as well
+
+* Mon May 16 2011 Jaroslav Škarvada <jskarvad@redhat.com> - 2.8-2
+- Added coloring to egrep and fgrep
+  Resolves: rhbz#697895
+
+* Mon May 16 2011 Jaroslav Škarvada <jskarvad@redhat.com> - 2.8-1
+- New version: grep-2.8
+  Resolves: rhbz#704710
+- Removed const-range-exp patch (upstreamed)
+
+* Mon Apr 04 2011 Jaroslav Škarvada <jskarvad@redhat.com> - 2.7-5
+- colorgrep scripts no longer overwrites COLORS envvar (#693058),
+  thanks to Ville Skyttä
+
+* Wed Feb 09 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.7-4
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
+
+* Fri Oct 01 2010 Jaroslav Škarvada <jskarvad@redhat.com> - 2.7-3
+- Fixed inconsistency with range expressions, const-range-exp patch (#583011)
+
+* Wed Sep 29 2010 jkeating - 2.7-2
+- Rebuilt for gcc bug 634757
+
+* Tue Sep 21 2010 Jaroslav Škarvada <jskarvad@redhat.com> - 2.7-1
+- New version: grep-2.7
+- Removed patches (already in upstream): dfa-optimize-period,
+  glibc-matcher-fallback, mmap-option-fix, dfa-convert-to-wide-char,
+  dfa-speedup-digit-xdigit
+
+* Fri Jun 11 2010 Jaroslav Škarvada <jskarvad@redhat.com> - 2.6.3-4
+- Colors can be globally disabled via /etc/GREP_COLORS (#602867)
+- Fixed indentation in spec
+- Fixed defattr in spec
+
+* Mon Jun 07 2010 Jaroslav Škarvada <jskarvad@redhat.com> - 2.6.3-3
+- Added auto-color profile.d scripts (thanks to Ville Skyttä #600832)
+- Removed description macro from changelog
+
+* Thu May 06 2010 Jaroslav Škarvada <jskarvad@redhat.com> - 2.6.3-2
+- Added dfa-optimize-period patch (speedup for . patterns in UTF-8)
+- Added glibc-matcher-fallback patch (speedup for [a-z] patterns in UTF-8)
+- Added mmap-option-fix patch
+- Added dfa-convert-to-wide-char patch (speedup for -m and remove quadratic
+  complexity when going to glibc)
+- Added dfa-speedup-digit-xdigit patch (speedup for [[:digit:]] [:xdigit:]])
+
+* Sun Apr 04 2010 Jaroslav Škarvada <jskarvad@redhat.com> - 2.6.3-1
+- New version: grep-2.6.3
+- make check is not silent now
+
+* Fri Mar 26 2010 Jaroslav Škarvada <jskarvad@redhat.com> - 2.6.1-1
+- New version: grep-2.6.1
+- Dropped sigsegv patch (integrated upstream)
+
+* Tue Mar 23 2010 Jaroslav Škarvada <jskarvad@redhat.com> - 2.6-1
+- New version: grep-2.6
+- Added sigsegv patch (after release patch from upstream)
+- Dropped obsoleted patches: fedora-tests, pcrewrap, case, egf-speedup,
+  bz460641, utf8, dfa-optional, w
+
+* Fri Mar 05 2010 Jaroslav Škarvada <jskarvad@redhat.com> - 2.5.4-2
+- Added w patch to fix -w switch behaviour broken by dfa-optional patch
+
+* Wed Feb 10 2010 Jaroslav Škarvada <jskarvad@redhat.com> - 2.5.4-1
+- New version: grep-2.5.4
+- Fixed typos in description
+- Updated utf-8 patch
+- Added dfa-optional patch (#538423)
+
+* Tue Aug 11 2009 Lubomir Rintel <lkundrak@v3.sk> 2.5.3-6
+- Silence possible scriptlets errors
+
+* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.5.3-5
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
+
+* Tue Feb 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.5.3-4
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild
+
+* Tue Jan 27 2009 Stepan Kasal <skasal@redhat.com> 2.5.3-3
+- remove grep-mem-exhausted.patch (#481765, #198165)
+
+* Thu Jan  8 2009 Stepan Kasal <skasal@redhat.com> 2.5.3-2
+- fix bug #460641 (a.k.a. 479152)
+
+* Thu Nov 20 2008 Lubomir Rintel <lkundrak@v3.sk> 2.5.3-1
+- Update to latest upstream version
+- Drop upstreamed patches
+- Add a couple of regression tests
+- Temporarily disable tests
+- Minor cleanup
+
+* Wed Oct 1 2008 Lubomir Rintel <lkundrak@v3.sk> 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 <tcallawa@redhat.com> - 2.5.1-60
+- fix license tag
+
+* Tue Feb 19 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 2.5.1-59
+- Autorebuild for GCC 4.3
+
+* Fri Apr 20 2007 Stepan Kasal <skasal@redhat.com> - 2.5.1-58
+- Adhere to packaging guidelines.
+- Resolves: #225857
+- Use CPPFLAGS= argument to configure to add an -I option.
+- Do not set LDFLAGS=-s for "make install".
+
+* Mon Jan 22 2007 Tim Waugh <twaugh@redhat.com> 2.5.1-57
+- Make preun scriptlet unconditionally succeed (bug #223697).
+
+* Wed Nov 22 2006 Tim Waugh <twaugh@redhat.com> 2.5.1-56
+- Fixed count of patterns when the last is an empty string (bug #204255).
+
+* Wed Nov 22 2006 Tim Waugh <twaugh@redhat.com> 2.5.1-55
+- Fix 'memory exhausted' errors by limiting in-memory buffer (bug #198165).
+
+* Wed Jul 12 2006 Jesse Keating <jkeating@redhat.com> - 2.5.1-54.1
+- rebuild
+
+* Wed May 31 2006 Tim Waugh <twaugh@redhat.com> 2.5.1-54
+- Applied upstream patch to fix '-D skip' (bug #189580).
+
+* Mon Feb 20 2006 Tim Waugh <twaugh@redhat.com> 2.5.1-53
+- Applied Tim Robbins' patch for 'grep -w' (bug #179698).
+
+* Fri Feb 10 2006 Jesse Keating <jkeating@redhat.com> - 2.5.1-52.2
+- bump again for double-long bug on ppc(64)
+
+* Tue Feb 07 2006 Jesse Keating <jkeating@redhat.com> - 2.5.1-52.1
+- rebuilt for new gcc4.1 snapshot and glibc changes
+
+* Fri Feb  3 2006 Tim Waugh <twaugh@redhat.com> 2.5.1-52
+- Prevent 'grep -P' from segfaulting (bug #171379).
+
+* Fri Dec 09 2005 Jesse Keating <jkeating@redhat.com>
+- rebuilt
+
+* Thu Sep 29 2005 Tim Waugh <twaugh@redhat.com> 2.5.1-51
+- Prevent 'grep -Fw ""' from busy-looping (bug #169524).
+
+* Tue Jun 28 2005 Tim Waugh <twaugh@redhat.com> 2.5.1-50
+- Further fixing for bug #161700.
+
+* Mon Jun 27 2005 Tim Waugh <twaugh@redhat.com> 2.5.1-49
+- Fix 'grep -Fw' for encodings other than UTF-8 (bug #161700).
+
+* Wed Apr 13 2005 Tim Waugh <twaugh@redhat.com>
+- Build requires recent pcre-devel (bug #154626).
+
+* Wed Mar  2 2005 Tim Waugh <twaugh@redhat.com> 2.5.1-48
+- Rebuild for new GCC.
+
+* Fri Jan  7 2005 Tim Waugh <twaugh@redhat.com> 2.5.1-47
+- Run 'make check'.
+- Fixed -w handling for EGexecute.  Now 'make check' passes.
+- Cache MB_CUR_MAX value in egf-speedup patch.
+- Fixed variable shadowing in egf-speedup patch.
+- Removed redundant (and incorrect) code in prline.
+
+* Fri Jan  7 2005 Tim Waugh <twaugh@redhat.com> 2.5.1-46
+- More -w tests from Jakub Jelinek.
+- Rebased on 2.5.1a.
+
+* Fri Dec 31 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-45
+- More tests (Jakub Jelinek).
+- Jakub Jelinek's much improved -Fi algorithm.
+- Removed bogus part of grep-2.5.1-fgrep patch.
+
+* Tue Dec 21 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-44
+- Fixed -Fi for multibyte input (bug #143079).
+
+* Thu Dec 16 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-43
+- Bypass kwset matching when ignoring case and processing multibyte input
+  (bug #143079).
+
+* Tue Dec 14 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-42
+- Further UTF-8 processing avoided since a '\n' byte is always an
+  end-of-line character in that encoding.
+
+* Fri Dec  3 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-41
+- Fixed a busy loop in the egf-speedup patch (bug #140781).
+
+* Thu Nov 18 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-40
+- Fixed a bug in the fgrep patch, exposed by the dfa-optional patch
+  (bug #138558).
+
+* Tue Nov 16 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-39
+- Fixed last patch.
+
+* Tue Nov 16 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-38
+- Applied patch from Karsten Hopp to fix background colour problems with
+  --color output (bug #138913).
+
+* Wed Nov 10 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-37
+- Prevent false matches when DFA is disabled (bug #138558).
+
+* Mon Nov  8 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-36
+- Automatically disable DFA when processing multibyte input.  GREP_USE_DFA
+  environment variable overrides.
+
+* Fri Nov  5 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-35
+- Fixes to egf-speedup patch: now it does not change any functionality,
+  as intended.
+- GREP_NO_DFA now turns off the DFA engine, for performance testing.
+
+* Thu Nov  4 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-34
+- More improvements to egf-speedup patch (bug #138076).
+
+* Thu Nov  4 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-33
+- Small improvements to egf-speedup patch.
+
+* Wed Nov  3 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-32
+- Remove mb-caching hack.
+- Better multibyte handling in EGexecute() and Fexecute().
+- Don't need regex.c changes in grep-2.5-i18n.patch.
+
+* Wed Oct 13 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-31
+- Make 'grep -F' avoid UTF-8 processing if the pattern contains no
+  multibyte characters (bug #133932).
+
+* Mon Oct 11 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-30
+- Applied patch from Robert Scheck to tidy spec file and add a URL
+  tag (bug #135185).
+
+* Tue Jun 15 2004 Elliot Lee <sopwith@redhat.com>
+- rebuilt
+
+* Fri Jun  4 2004 Tim Waugh <twaugh@redhat.com>
+- More build requirements (bug #125323).
+
+* Tue May 18 2004 Jeremy Katz <katzj@redhat.com> 2.5.1-28
+- rebuild
+
+* Tue May 18 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-27
+- Fix dfa multibyte character class matching when -i is used (bug #123363).
+- Use bracket patch before i18n patch to make it clear that the bug exists
+  upstream.
+
+* Thu Feb 26 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-26
+- Fix fgrep (bug #116909).
+
+* Fri Feb 13 2004 Elliot Lee <sopwith@redhat.com>
+- rebuilt
+
+* Mon Jan  5 2004 Tim Waugh <twaugh@redhat.com> 2.5.1-24
+- Work around glibc bug #112869 (segfault in re_compile_pattern).
+- Avoid patching Makefile.am, to avoid automake/autoconf weirdness.
+
+* Wed Dec 10 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-23
+- Another multibyte efficiency bug-fix (bug #111800).
+
+* Mon Dec  8 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-22
+- Fixed [:alpha:]-type character classes (bug #108484).
+- Fixed -o -i properly (bug #111489).
+
+* Sat Dec  6 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-21
+- Fixed 'fgrep -i' (bug #111614).
+
+* Fri Nov 21 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-20
+- Another two multibyte efficiency bug-fixes (bug #110524).
+
+* Thu Nov  6 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-19
+- Fixed a multibyte efficiency bug.
+
+* Thu Nov  6 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-18
+- Turn on multibyte efficiency patch again to shake out bugs.
+
+* Wed Oct  8 2003 Tim Waugh <twaugh@redhat.com>
+- Fixed man page bug (bug #106267).
+
+* Thu Sep 18 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-17
+- Use symlinks for egrep/fgrep, rather than shell script wrappers.
+
+* Fri Jun 27 2003 Tim Waugh <twaugh@redhat.com>
+- Fix debuginfo package.
+
+* Fri Jun 27 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-16.1
+- Rebuilt.
+
+* Fri Jun 27 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-16
+- Finally give up on making grep go fast. :-(
+
+* Thu Jun 26 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-15.1
+- Rebuilt.
+
+* Thu Jun 26 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-15
+- Fixed grep -i bug introduced by cache.
+
+* Mon Jun 23 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-14.1
+- Rebuilt.
+
+* Mon Jun 23 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-14
+- Redo the gofast patch (bug #97785).
+
+* Thu Jun 12 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-13.1
+- Rebuilt.
+
+* Thu Jun 12 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-13
+- Fixed a bug in the gofast patch (bug #97266).
+
+* Tue Jun 10 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-12.1
+- Rebuilt.
+
+* Tue Jun 10 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-12
+- Go faster (bug #69900).
+- Fix man page.
+
+* Wed Jun 04 2003 Elliot Lee <sopwith@redhat.com>
+- rebuilt
+
+* Thu May 29 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-10.1
+- Rebuilt.
+
+* Thu May 29 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-10
+- Use system regex again.
+
+* Thu May 29 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-9
+- Fixed bug in go-fast patch.
+
+* Wed May 28 2003 Tim Waugh <twaugh@redhat.com> 2.5.1-8
+- Go fast (bug #69900).
+- Run test suite.
+
+* Wed Jan 22 2003 Tim Powers <timp@redhat.com> 2.5.1-7
+- rebuilt
+
+* Tue Nov 19 2002 Tim Waugh <twaugh@redhat.com> 2.5.1-6
+- i18n patch.
+
+* Mon Oct 21 2002 Tim Waugh <twaugh@redhat.com> 2.5.1-5
+- Don't install /usr/share/info/dir.
+- Fix -o -i (bug #72641).
+
+* Sat Jul 20 2002 Florian La Roche <Florian.LaRoche@redhat.de>
+- install all info files #69204
+
+* Fri Jun 21 2002 Tim Powers <timp@redhat.com>
+- automated rebuild
+
+* Thu May 23 2002 Tim Powers <timp@redhat.com>
+- automated rebuild
+
+* Tue Mar 26 2002 Bernhard Rosenkraenzer <bero@redhat.com> 2.5.1-1
+- 2.5.1
+
+* Wed Mar 13 2002 Bernhard Rosenkraenzer <bero@redhat.com> 2.5-1
+- 2.5 final
+
+* Wed Jan 23 2002 Bernhard Rosenkraenzer <bero@redhat.com> 2.5-0.g.1
+- 2.5g
+
+* Wed Jan 09 2002 Tim Powers <timp@redhat.com>
+- automated rebuild
+
+* Mon Nov 19 2001 Bernhard Rosenkraenzer <bero@redhat.com> 2.5-0.f.4
+- Update CVS to reduce bloat
+
+* Thu Nov  8 2001 Bernhard Rosenkraenzer <bero@redhat.com> 2.5-0.f.3
+- Don't fail %%post with --excludedocs
+
+* Wed Sep 26 2001 Bernhard Rosenkraenzer <bero@redhat.com> 2.5-0.f.2
+- Fix up echo A |grep '[A-Z0-9]' in locales other than C
+
+* Tue Sep 25 2001 Bernhard Rosenkraenzer <bero@redhat.com> 2.5-0.f.1
+- 2.5f, fixes #53603
+
+* Wed Jul 18 2001 Bernhard Rosenkraenzer <bero@redhat.com> 2.4.2-7
+- Fix up the i18n patch - it used to break "grep '[]a]'" (#49003)
+- revert to 2.4.2 (latest official release) for now
+
+* Mon May 28 2001 Bernhard Rosenkraenzer <bero@redhat.com> 2.5e-4
+- Fix "echo Linux forever |grep -D skip Linux"
+
+* Mon May 21 2001 Bernhard Rosenkraenzer <bero@redhat.com> 2.5e-3
+- Add new -D, --devices option
+- Fix a bug with "directories" being uninitialized
+
+* Sun May 13 2001 Bernhard Rosenkraenzer <bero@redhat.com> 2.5e-2
+- Fix up the --color option to behave like the one from ls (--color=auto)
+  Sooner or later, some people will alias grep="grep --color" and wonder why
+  their scripts break.
+- Update docs accordingly
+- Get rid of the annoying blinking in grep --color
+
+* Sun May 13 2001 Bernhard Rosenkraenzer <bero@redhat.com> 2.5e-1
+- 2.5e
+
+* Tue Feb 27 2001 Trond Eivind Glomsrød <teg@redhat.com>
+- use %%{_tmppath}
+- langify
+
+* Sun Aug 20 2000 Jakub Jelinek <jakub@redhat.com>
+- i18n character ranges patch from Ulrich Drepper
+
+* Thu Jul 13 2000 Prospector <bugzilla@redhat.com>
+- automatic rebuild
+
+* Mon Jun 19 2000 Bernhard Rosenkraenzer <bero@redhat.com>
+- FHSify
+
+* Tue Mar 21 2000 Florian La Roche <Florian.LaRoche@redhat.com>
+- update to 2.4.2
+- fix download URL
+
+* Thu Feb 03 2000 Bernhard Rosenkraenzer <bero@redhat.com>
+- gzip info pages (Bug #9035)
+
+* Wed Feb 02 2000 Cristian Gafton <gafton@redhat.com>
+- fix description
+
+* Wed Dec 22 1999 Jeff Johnson <jbj@redhat.com>
+- update to 2.4.
+
+* Wed Oct 20 1999 Bill Nottingham <notting@redhat.com>
+- prereq install-info
+
+* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
+- auto rebuild in the new build environment (release 2)
+
+* Mon Mar 08 1999 Preston Brown <pbrown@redhat.com>
+- upgraded to grep 2.3, added install-info %%post/%%preun for info
+
+* Wed Feb 24 1999 Preston Brown <pbrown@redhat.com>
+- Injected new description and group.
+
+* Sat May 09 1998 Prospector System <bugs@redhat.com>
+- translations modified for de, fr, tr
+
+* Fri May 01 1998 Cristian Gafton <gafton@redhat.com>
+- updated to 2.2
+
+* Thu Oct 16 1997 Donnie Barnes <djb@redhat.com>
+- updated from 2.0 to 2.1
+- spec file cleanups
+- added BuildRoot
+
+* Mon Jun 02 1997 Erik Troan <ewt@redhat.com>
+- built against glibc