From MAILER-DAEMON Tue Apr 01 11:03:24 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WV0Dk-0007PZ-LU
	for mharc-grep-commit@gnu.org; Tue, 01 Apr 2014 11:03:24 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:38904)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WV0De-0007Oq-Px
	for grep-commit@gnu.org; Tue, 01 Apr 2014 11:03:22 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WV0DZ-0005uL-7R
	for grep-commit@gnu.org; Tue, 01 Apr 2014 11:03:18 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:35815)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WV0DZ-0005u5-3R
	for grep-commit@gnu.org; Tue, 01 Apr 2014 11:03:13 -0400
Received: from meyering by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <jim@meyering.net>) id 1WV0DY-0002LO-CT
	for grep-commit@gnu.org; Tue, 01 Apr 2014 15:03:12 +0000
Date: Tue, 01 Apr 2014 15:03:12 +0000
Message-Id: <E1WV0DY-0002LO-CT@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-42-gd80c9a5
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: df6da5d40a47abbc6e3451cb9fab7a8c9ede12cc
X-Git-Newrev: d80c9a5da2c5e04844ac39f8cdd45e6425b2dde6
From: Jim Meyering <jim@meyering.net>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 01 Apr 2014 15:03:22 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  d80c9a5da2c5e04844ac39f8cdd45e6425b2dde6 (commit)
      from  df6da5d40a47abbc6e3451cb9fab7a8c9ede12cc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=d80c9a5da2c5e04844ac39f8cdd45e6425b2dde6


commit d80c9a5da2c5e04844ac39f8cdd45e6425b2dde6
Author: Norihiro Tanaka <noritnk@kcn.ne.jp>
Date:   Tue Apr 1 11:18:44 2014 +0200

    dfa: avoid re-building a state built previously
    
    * src/dfa.c (dfaexec): Avoid to re-build a state built previously.

diff --git a/src/dfa.c b/src/dfa.c
index b22fe97..b6fbd58 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3537,7 +3537,8 @@ dfaexec (struct dfa *d, char const *begin, char *end,
 
       if (s >= 0)
         {
-          build_state (s, d);
+          if (!d->trans[s])
+            build_state (s, d);
           trans = d->trans;
           continue;
         }

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Sat Apr 05 19:32:56 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WWa52-0008Qw-1K
	for mharc-grep-commit@gnu.org; Sat, 05 Apr 2014 19:32:56 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:44065)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WWa4y-0008Q3-5w
	for grep-commit@gnu.org; Sat, 05 Apr 2014 19:32:53 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WWa4w-00084A-1X
	for grep-commit@gnu.org; Sat, 05 Apr 2014 19:32:52 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:35296)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WWa4v-000846-TV
	for grep-commit@gnu.org; Sat, 05 Apr 2014 19:32:49 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WWa4u-0005Rk-T7
	for grep-commit@gnu.org; Sat, 05 Apr 2014 23:32:49 +0000
Date: Sat, 05 Apr 2014 23:32:48 +0000
Message-Id: <E1WWa4u-0005Rk-T7@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-43-g8d0fcb8
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d80c9a5da2c5e04844ac39f8cdd45e6425b2dde6
X-Git-Newrev: 8d0fcb8a231acfdb45fbab7c9df14cda90756c55
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 05 Apr 2014 23:32:54 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  8d0fcb8a231acfdb45fbab7c9df14cda90756c55 (commit)
      from  d80c9a5da2c5e04844ac39f8cdd45e6425b2dde6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=8d0fcb8a231acfdb45fbab7c9df14cda90756c55


commit 8d0fcb8a231acfdb45fbab7c9df14cda90756c55
Author: Paul Eggert <eggert@penguin.cs.ucla.edu>
Date:   Thu Apr 3 18:14:15 2014 -0700

    grep: simplify dfa.c by having it not include mbsupport.h directly
    
    * src/mbsupport.h: Remove.
    * src/Makefile.am (noinst_HEADERS): Remove mbsupport.h.
    * src/dfa.c, src/grep.c, src/search.h: Don't include mbsupport.h.
    * src/dfa.c: Include wchar.h and wctype.h unconditionally, as
    this simplifies the use of dfa.c in grep, and it does no harm
    in gawk.
    (setlocale, static_assert): Remove gawk-specific hacks, as
    gawk now does these itself.
    (struct dfa, dfambcache, mbs_to_wchar)
    (is_valid_unibyte_character, setbit_wc, using_utf8, FETCH_WC)
    (addtok_wc, add_utf8_anychar, atom, state_index, epsclosure)
    (dfaanalyze, dfastate, prepare_wc_buf, dfaoptimize, dfafree, dfamust):
    * src/dfasearch.c (EGexecute):
    * src/grep.c (main):
    * src/searchutils.c (mbtoupper):
    Assume MBS_SUPPORT.

diff --git a/src/Makefile.am b/src/Makefile.am
index 3487848..f8c9415 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,7 +27,7 @@ grep_SOURCES = grep.c searchutils.c \
           dfa.c dfasearch.c \
           kwset.c kwsearch.c \
           pcresearch.c
-noinst_HEADERS = grep.h dfa.h kwset.h search.h system.h mbsupport.h
+noinst_HEADERS = grep.h dfa.h kwset.h search.h system.h
 
 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
 # include modules defining variables like 'optind', so libgreputils.a
diff --git a/src/dfa.c b/src/dfa.c
index b6fbd58..0d7eab5 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -34,16 +34,6 @@
 #include <locale.h>
 #include <stdbool.h>
 
-/* Gawk doesn't use Gnulib, so don't assume that setlocale and
-   static_assert are present.  */
-#ifndef LC_ALL
-# define setlocale(category, locale) NULL
-#endif
-#ifndef static_assert
-# define static_assert(cond, diagnostic) \
-    extern int (*foo (void)) [!!sizeof (struct { int foo: (cond) ? 8 : -1; })]
-#endif
-
 #define STREQ(a, b) (strcmp (a, b) == 0)
 
 /* ISASCIIDIGIT differs from isdigit, as follows:
@@ -60,12 +50,8 @@
 #include "gettext.h"
 #define _(str) gettext (str)
 
-#include "mbsupport.h" /* Define MBS_SUPPORT to 1 or 0, as appropriate.  */
-#if MBS_SUPPORT
-/* We can handle multibyte strings.  */
-# include <wchar.h>
-# include <wctype.h>
-#endif
+#include <wchar.h>
+#include <wctype.h>
 
 #if HAVE_LANGINFO_CODESET
 # include <langinfo.h>
@@ -376,13 +362,11 @@ struct dfa
   size_t nmultibyte_prop;
   int *multibyte_prop;
 
-#if MBS_SUPPORT
   /* A table indexed by byte values that contains the corresponding wide
      character (if any) for that byte.  WEOF means the byte is the
      leading byte of a multibyte character.  Invalid and null bytes are
      mapped to themselves.  */
   wint_t mbrtowc_cache[NOTCHAR];
-#endif
 
   /* Array of the bracket expression in the DFA.  */
   struct mb_char_classes *mbcsets;
@@ -488,7 +472,6 @@ static void regexp (void);
 static void
 dfambcache (struct dfa *d)
 {
-#if MBS_SUPPORT
   int i;
   for (i = CHAR_MIN; i <= CHAR_MAX; ++i)
     {
@@ -505,10 +488,8 @@ dfambcache (struct dfa *d)
         }
       d->mbrtowc_cache[uc] = wi;
     }
-#endif
 }
 
-#if MBS_SUPPORT
 /* Given the dfa D, store into *PWC the result of converting the
    leading bytes of the multibyte buffer S of length N bytes, updating
    the conversion state in *MBS.  On conversion error, convert just a
@@ -542,7 +523,6 @@ mbs_to_wchar (struct dfa *d, wchar_t *pwc, char const *s, size_t n,
   *pwc = wc;
   return 1;
 }
-#endif
 
 #ifdef DEBUG
 
@@ -712,7 +692,7 @@ static charclass newline;
 #ifdef __GLIBC__
 # define is_valid_unibyte_character(c) 1
 #else
-# define is_valid_unibyte_character(c) (! (MBS_SUPPORT && btowc (c) == WEOF))
+# define is_valid_unibyte_character(c) (btowc (c) != WEOF)
 #endif
 
 /* Return non-zero if C is a "word-constituent" byte; zero otherwise.  */
@@ -773,17 +753,12 @@ dfasyntax (reg_syntax_t bits, int fold, unsigned char eol)
 static bool
 setbit_wc (wint_t wc, charclass c)
 {
-#if MBS_SUPPORT
   int b = wctob (wc);
   if (b == EOF)
     return false;
 
   setbit (b, c);
   return true;
-#else
-  abort ();
-   /*NOTREACHED*/ return false;
-#endif
 }
 
 /* Set a bit for B and its case variants in the charclass C.
@@ -808,7 +783,7 @@ using_utf8 (void)
   static int utf8 = -1;
   if (utf8 == -1)
     {
-#if defined HAVE_LANGINFO_CODESET && MBS_SUPPORT
+#if defined HAVE_LANGINFO_CODESET
       utf8 = (STREQ (nl_langinfo (CODESET), "UTF-8"));
 #else
       utf8 = 0;
@@ -897,7 +872,6 @@ static unsigned char const *buf_begin;  /* reference to begin in dfaexec.  */
 static unsigned char const *buf_end;    /* reference to end in dfaexec.  */
 
 
-#if MBS_SUPPORT
 /* Note that characters become unsigned here.  */
 # define FETCH_WC(c, wc, eoferr)		\
   do {						\
@@ -920,23 +894,6 @@ static unsigned char const *buf_end;    /* reference to end in dfaexec.  */
       }						\
   } while (0)
 
-#else
-/* Note that characters become unsigned here.  */
-# define FETCH_WC(c, unused, eoferr)  \
-  do {				      \
-    if (! lexleft)		      \
-      {				      \
-        if ((eoferr) != 0)	      \
-          dfaerror (eoferr);	      \
-        else			      \
-          return lasttok = END;	      \
-      }				      \
-    (c) = to_uchar (*lexptr++);       \
-    --lexleft;			      \
-  } while (0)
-
-#endif /* MBS_SUPPORT */
-
 #ifndef MIN
 # define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
@@ -1720,7 +1677,6 @@ addtok (token t)
     }
 }
 
-#if MBS_SUPPORT
 /* We treat a multibyte character as a single atom, so that DFA
    can treat a multibyte character as a single expression.
 
@@ -1752,17 +1708,10 @@ addtok_wc (wint_t wc)
       addtok (CAT);
     }
 }
-#else
-static void
-addtok_wc (wint_t wc)
-{
-}
-#endif
 
 static void
 add_utf8_anychar (void)
 {
-#if MBS_SUPPORT
   static const charclass utf8_classes[5] = {
     {0, 0, 0, 0, ~0, ~0, 0, 0},		/* 80-bf: non-leading bytes */
     {~0, ~0, ~0, ~0, 0, 0, 0, 0},       /* 00-7f: 1-byte sequence */
@@ -1807,7 +1756,6 @@ add_utf8_anychar (void)
       addtok (CAT);
       addtok (OR);
     }
-#endif
 }
 
 /* The grammar understood by the parser is as follows.
@@ -1848,7 +1796,7 @@ add_utf8_anychar (void)
 static void
 atom (void)
 {
-  if (MBS_SUPPORT && tok == WCHAR)
+  if (tok == WCHAR)
     {
       addtok_wc (wctok);
 
@@ -1865,7 +1813,7 @@ atom (void)
 
       tok = lex ();
     }
-  else if (MBS_SUPPORT && tok == ANYCHAR && using_utf8 ())
+  else if (tok == ANYCHAR && using_utf8 ())
     {
       /* For UTF-8 expand the period to a series of CSETs that define a valid
          UTF-8 character.  This avoids using the slow multibyte path.  I'm
@@ -1879,9 +1827,7 @@ atom (void)
     }
   else if ((tok >= 0 && tok < NOTCHAR) || tok >= CSET || tok == BACKREF
            || tok == BEGLINE || tok == ENDLINE || tok == BEGWORD
-#if MBS_SUPPORT
            || tok == ANYCHAR || tok == MBCSET
-#endif /* MBS_SUPPORT */
            || tok == ENDWORD || tok == LIMWORD || tok == NOTLIMWORD)
     {
       addtok (tok);
@@ -2164,11 +2110,9 @@ state_index (struct dfa *d, position_set const *s, int context)
   d->states[i].backref = 0;
   d->states[i].constraint = 0;
   d->states[i].first_end = 0;
-  if (MBS_SUPPORT)
-    {
-      d->states[i].mbps.nelem = 0;
-      d->states[i].mbps.elems = NULL;
-    }
+  d->states[i].mbps.nelem = 0;
+  d->states[i].mbps.elems = NULL;
+
   for (j = 0; j < s->nelem; ++j)
     if (d->tokens[s->elems[j].index] < 0)
       {
@@ -2206,10 +2150,8 @@ epsclosure (position_set * s, struct dfa const *d)
   for (i = 0; i < s->nelem; ++i)
     if (d->tokens[s->elems[i].index] >= NOTCHAR
         && d->tokens[s->elems[i].index] != BACKREF
-#if MBS_SUPPORT
         && d->tokens[s->elems[i].index] != ANYCHAR
         && d->tokens[s->elems[i].index] != MBCSET
-#endif
         && d->tokens[s->elems[i].index] < CSET)
       {
         old = s->elems[i];
@@ -2526,9 +2468,7 @@ dfaanalyze (struct dfa *d, int searchflag)
      it with its epsilon closure.  */
   for (i = 0; i < d->tindex; ++i)
     if (d->tokens[i] < NOTCHAR || d->tokens[i] == BACKREF
-#if MBS_SUPPORT
         || d->tokens[i] == ANYCHAR || d->tokens[i] == MBCSET
-#endif
         || d->tokens[i] >= CSET)
       {
 #ifdef DEBUG
@@ -2638,9 +2578,8 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
         setbit (d->tokens[pos.index], matches);
       else if (d->tokens[pos.index] >= CSET)
         copyset (d->charclasses[d->tokens[pos.index] - CSET], matches);
-      else if (MBS_SUPPORT
-               && (d->tokens[pos.index] == ANYCHAR
-                   || d->tokens[pos.index] == MBCSET))
+      else if (d->tokens[pos.index] == ANYCHAR
+               || d->tokens[pos.index] == MBCSET)
         /* MB_CUR_MAX > 1  */
         {
           /* ANYCHAR and MBCSET must match with a single character, so we
@@ -2814,7 +2753,7 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
       /* If we are building a searching matcher, throw in the positions
          of state 0 as well.  */
       if (d->searchflag
-          && (!MBS_SUPPORT || (d->mb_cur_max == 1 || !next_isnt_1st_byte)))
+          && (d->mb_cur_max == 1 || !next_isnt_1st_byte))
         for (j = 0; j < d->states[0].elems.nelem; ++j)
           insert (d->states[0].elems.elems[j], &follows);
 
@@ -3366,7 +3305,6 @@ transit_state (struct dfa *d, state_num s, unsigned char const **pp)
 static void
 prepare_wc_buf (struct dfa *d, const char *begin, const char *end)
 {
-#if MBS_SUPPORT
   unsigned char eol = eolbyte;
   size_t i;
   size_t ilim = end - begin + 1;
@@ -3390,7 +3328,6 @@ prepare_wc_buf (struct dfa *d, const char *begin, const char *end)
   buf_end = (unsigned char *) (begin + i);
   mblen_buf[i] = 0;
   inputwcs[i] = 0;              /* sentinel */
-#endif /* MBS_SUPPORT */
 }
 
 /* Search through a buffer looking for a match to the given struct dfa.
@@ -3613,7 +3550,7 @@ dfaoptimize (struct dfa *d)
 {
   size_t i;
 
-  if (!MBS_SUPPORT || !using_utf8 ())
+  if (!using_utf8 ())
     return;
 
   for (i = 0; i < d->tindex; ++i)
@@ -3663,8 +3600,7 @@ dfafree (struct dfa *d)
   for (i = 0; i < d->sindex; ++i)
     {
       free (d->states[i].elems.elems);
-      if (MBS_SUPPORT)
-        free (d->states[i].mbps.elems);
+      free (d->states[i].mbps.elems);
     }
   free (d->states);
   for (i = 0; i < d->tindex; ++i)
@@ -4139,7 +4075,7 @@ dfamust (struct dfa *d)
               /* not on *my* shift */
               goto done;
             }
-          else if (t >= CSET || !MBS_SUPPORT || t == ANYCHAR || t == MBCSET)
+          else if (t >= CSET || t == ANYCHAR || t == MBCSET)
             {
               /* easy enough */
               resetmust (mp);
diff --git a/src/dfasearch.c b/src/dfasearch.c
index d098a9b..5665b82 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -239,9 +239,6 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
               char const *dfa_start = beg;
               if (kwsm.index < kwset_exact_matches)
                 {
-                  if (!MBS_SUPPORT)
-                    goto success;
-
                   if (mb_start < beg)
                     mb_start = beg;
                   if (MB_CUR_MAX == 1
diff --git a/src/grep.c b/src/grep.c
index a1bccdb..7033730 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -21,7 +21,6 @@
 #include <config.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include "mbsupport.h"
 #include <wchar.h>
 #include <wctype.h>
 #include <fcntl.h>
@@ -2461,10 +2460,8 @@ main (int argc, char **argv)
         }
     }
 
-#if MBS_SUPPORT
   if (MB_CUR_MAX > 1)
     build_mbclen_cache ();
-#endif
 
   compile (keys, keycc);
   free (keys);
diff --git a/src/mbsupport.h b/src/mbsupport.h
deleted file mode 100644
index 49c7926..0000000
--- a/src/mbsupport.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* mbsupport.h --- Localize determination of whether we have multibyte stuff.
-
-   Copyright (C) 2004-2005, 2007, 2009-2014 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, 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, write to the Free Software
-   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
-   02110-1301, USA.  */
-
-#include <stdlib.h>
-
-#ifndef MBS_SUPPORT
-# define MBS_SUPPORT 1
-#endif
-
-#if ! MBS_SUPPORT
-# undef MB_CUR_MAX
-# define MB_CUR_MAX 1
-#endif
diff --git a/src/search.h b/src/search.h
index 69e3afd..871b7d5 100644
--- a/src/search.h
+++ b/src/search.h
@@ -23,9 +23,6 @@
 
 #include <sys/types.h>
 #include <stdint.h>
-
-#include "mbsupport.h"
-
 #include <wchar.h>
 #include <wctype.h>
 #include <regex.h>
diff --git a/src/searchutils.c b/src/searchutils.c
index babb31f..6749945 100644
--- a/src/searchutils.c
+++ b/src/searchutils.c
@@ -48,7 +48,6 @@ kwsinit (kwset_t *kwset)
     xalloc_die ();
 }
 
-#if MBS_SUPPORT
 /* Convert BEG, an *N-byte string, to uppercase, and write the
    NUL-terminated result into malloc'd storage.  Upon success, set *N
    to the length (in bytes) of the resulting string (not including the
@@ -276,4 +275,3 @@ is_mb_middle (const char **good, const char *buf, const char *end,
   /* P == BUF here.  */
   return 0 < match_len && match_len < mbrlen (p, end - p, &cur_state);
 }
-#endif /* MBS_SUPPORT */

-----------------------------------------------------------------------

Summary of changes:
 src/Makefile.am   |    2 +-
 src/dfa.c         |   94 ++++++++--------------------------------------------
 src/dfasearch.c   |    3 --
 src/grep.c        |    3 --
 src/mbsupport.h   |   29 ----------------
 src/search.h      |    3 --
 src/searchutils.c |    2 -
 7 files changed, 16 insertions(+), 120 deletions(-)
 delete mode 100644 src/mbsupport.h


hooks/post-receive
-- 
grep


From MAILER-DAEMON Sun Apr 06 01:04:09 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WWfFZ-0000vS-OE
	for mharc-grep-commit@gnu.org; Sun, 06 Apr 2014 01:04:09 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:55120)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WWfFW-0000uc-Jo
	for grep-commit@gnu.org; Sun, 06 Apr 2014 01:04:08 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WWfFV-00087J-1W
	for grep-commit@gnu.org; Sun, 06 Apr 2014 01:04:06 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:37714)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WWfFU-00087D-Sf
	for grep-commit@gnu.org; Sun, 06 Apr 2014 01:04:04 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WWfFT-0003qH-HF
	for grep-commit@gnu.org; Sun, 06 Apr 2014 05:04:03 +0000
Date: Sun, 06 Apr 2014 05:04:03 +0000
Message-Id: <E1WWfFT-0003qH-HF@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-45-g625eef0
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 8d0fcb8a231acfdb45fbab7c9df14cda90756c55
X-Git-Newrev: 625eef0262c1e0d36529fa5a8988a1aa64b3bc2e
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 06 Apr 2014 05:04:08 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  625eef0262c1e0d36529fa5a8988a1aa64b3bc2e (commit)
       via  8d823930fd0717d05f989e438d506b6495955a4c (commit)
      from  8d0fcb8a231acfdb45fbab7c9df14cda90756c55 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=625eef0262c1e0d36529fa5a8988a1aa64b3bc2e


commit 625eef0262c1e0d36529fa5a8988a1aa64b3bc2e
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sat Apr 5 22:01:39 2014 -0700

    grep: minor improvements to previous patch
    
    * src/dfa.c (MAX): New macro.
    (match_anychar, match_mb_charset, transit_state_consume_1char):
    Use it to simplify assignments.
    (SKIP_REMAINS_MB_IF_INITIAL_STATE): Prefer != 0 for unsigned.
    (free_mbdata): Omit an unnecessary 'free'.

diff --git a/src/dfa.c b/src/dfa.c
index 96fbcb3..ef5c8a9 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -429,8 +429,7 @@ struct dfa
                                    e.g., input : 'a', <mb(0)>, <mb(1)>, <mb(2)>
                                    mblen_buf   :  0,       3,       2,       1
                                  */
-  size_t nmblen_buf;            /* Length of the mblen buffer currently
-                                   allocated.  */
+  size_t nmblen_buf;            /* Allocated size of mblen_buf.  */
   wchar_t *inputwcs;            /* Wide character representation of the input
                                    string in dfaexec.
                                    The length of this array is the same as
@@ -438,8 +437,7 @@ struct dfa
                                    inputstring[i] is a single-byte char,
                                    or the first byte of a multibyte char;
                                    inputwcs[i] is the codepoint.  */
-  size_t ninputwcs;             /* Length of the input wide characters
-                                   currently allocated.  */
+  size_t ninputwcs;             /* Allocated number of inputwcs elements.  */
   position_set *mb_follows;     /* Follow set added by ANYCHAR and/or MBCSET
                                    on demand.  */
   int *mb_match_lens;           /* Array of length reduced by ANYCHAR and/or
@@ -905,6 +903,9 @@ static unsigned char const *buf_end;    /* reference to end in dfaexec.  */
 #ifndef MIN
 # define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
+#ifndef MAX
+# define MAX(a,b) ((a) < (b) ? (b) : (a))
+#endif
 
 /* The set of wchar_t values C such that there's a useful locale
    somewhere where C != towupper (C) && C != towlower (towupper (C)).
@@ -2908,8 +2909,8 @@ build_state_zero (struct dfa *d)
   if (s == 0)						\
     {							\
       while (d->inputwcs[p - buf_begin] == 0		\
-            && d->mblen_buf[p - buf_begin] > 0		\
-            && (unsigned char const *) p < buf_end)	\
+             && d->mblen_buf[p - buf_begin] != 0	\
+             && (unsigned char const *) p < buf_end)	\
         ++p;						\
       if ((char *) p >= end)				\
         {						\
@@ -3007,7 +3008,7 @@ match_anychar (struct dfa *d, state_num s, position pos, size_t idx)
   int mbclen;
 
   wc = d->inputwcs[idx];
-  mbclen = (d->mblen_buf[idx] == 0) ? 1 : d->mblen_buf[idx];
+  mbclen = MAX (1, d->mblen_buf[idx]);
 
   /* Check syntax bits.  */
   if (wc == (wchar_t) eolbyte)
@@ -3069,7 +3070,7 @@ match_mb_charset (struct dfa *d, state_num s, position pos, size_t idx)
   /* Assign the current referring operator to work_mbc.  */
   work_mbc = &(d->mbcsets[(d->multibyte_prop[pos.index]) >> 2]);
   match = !work_mbc->invert;
-  match_len = (d->mblen_buf[idx] == 0) ? 1 : d->mblen_buf[idx];
+  match_len = MAX (1, d->mblen_buf[idx]);
 
   /* Match in range 0-255?  */
   if (wc < NOTCHAR && work_mbc->cset != -1
@@ -3187,7 +3188,7 @@ transit_state_consume_1char (struct dfa *d, state_num s,
 
   /* Calculate the length of the (single/multi byte) character
      to which p points.  */
-  *mbclen = (d->mblen_buf[*pp - buf_begin] == 0) ? 1 : d->mblen_buf[*pp - buf_begin];
+  *mbclen = MAX (1, d->mblen_buf[*pp - buf_begin]);
 
   /* Calculate the state which can be reached from the state 's' by
      consuming '*mbclen' single bytes from the buffer.  */
@@ -3214,7 +3215,7 @@ transit_state_consume_1char (struct dfa *d, state_num s,
         for (j = 0; j < d->follows[d->states[s].mbps.elems[i].index].nelem;
              j++)
           insert (d->follows[d->states[s].mbps.elems[i].index].elems[j],
-            d->mb_follows);
+                  d->mb_follows);
     }
 
   /* FIXME: this return value is always ignored.  */
@@ -3519,9 +3520,11 @@ free_mbdata (struct dfa *d)
 
   free (d->mblen_buf);
   free (d->inputwcs);
-  if (d->mb_follows != NULL)
-    free (d->mb_follows->elems);
-  free (d->mb_follows);
+  if (d->mb_follows)
+    {
+      free (d->mb_follows->elems);
+      free (d->mb_follows);
+    }
   free (d->mb_match_lens);
 }
 

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=8d823930fd0717d05f989e438d506b6495955a4c


commit 625eef0262c1e0d36529fa5a8988a1aa64b3bc2e
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sat Apr 5 22:01:39 2014 -0700

    grep: minor improvements to previous patch
    
    * src/dfa.c (MAX): New macro.
    (match_anychar, match_mb_charset, transit_state_consume_1char):
    Use it to simplify assignments.
    (SKIP_REMAINS_MB_IF_INITIAL_STATE): Prefer != 0 for unsigned.
    (free_mbdata): Omit an unnecessary 'free'.

diff --git a/src/dfa.c b/src/dfa.c
index 96fbcb3..ef5c8a9 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -429,8 +429,7 @@ struct dfa
                                    e.g., input : 'a', <mb(0)>, <mb(1)>, <mb(2)>
                                    mblen_buf   :  0,       3,       2,       1
                                  */
-  size_t nmblen_buf;            /* Length of the mblen buffer currently
-                                   allocated.  */
+  size_t nmblen_buf;            /* Allocated size of mblen_buf.  */
   wchar_t *inputwcs;            /* Wide character representation of the input
                                    string in dfaexec.
                                    The length of this array is the same as
@@ -438,8 +437,7 @@ struct dfa
                                    inputstring[i] is a single-byte char,
                                    or the first byte of a multibyte char;
                                    inputwcs[i] is the codepoint.  */
-  size_t ninputwcs;             /* Length of the input wide characters
-                                   currently allocated.  */
+  size_t ninputwcs;             /* Allocated number of inputwcs elements.  */
   position_set *mb_follows;     /* Follow set added by ANYCHAR and/or MBCSET
                                    on demand.  */
   int *mb_match_lens;           /* Array of length reduced by ANYCHAR and/or
@@ -905,6 +903,9 @@ static unsigned char const *buf_end;    /* reference to end in dfaexec.  */
 #ifndef MIN
 # define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
+#ifndef MAX
+# define MAX(a,b) ((a) < (b) ? (b) : (a))
+#endif
 
 /* The set of wchar_t values C such that there's a useful locale
    somewhere where C != towupper (C) && C != towlower (towupper (C)).
@@ -2908,8 +2909,8 @@ build_state_zero (struct dfa *d)
   if (s == 0)						\
     {							\
       while (d->inputwcs[p - buf_begin] == 0		\
-            && d->mblen_buf[p - buf_begin] > 0		\
-            && (unsigned char const *) p < buf_end)	\
+             && d->mblen_buf[p - buf_begin] != 0	\
+             && (unsigned char const *) p < buf_end)	\
         ++p;						\
       if ((char *) p >= end)				\
         {						\
@@ -3007,7 +3008,7 @@ match_anychar (struct dfa *d, state_num s, position pos, size_t idx)
   int mbclen;
 
   wc = d->inputwcs[idx];
-  mbclen = (d->mblen_buf[idx] == 0) ? 1 : d->mblen_buf[idx];
+  mbclen = MAX (1, d->mblen_buf[idx]);
 
   /* Check syntax bits.  */
   if (wc == (wchar_t) eolbyte)
@@ -3069,7 +3070,7 @@ match_mb_charset (struct dfa *d, state_num s, position pos, size_t idx)
   /* Assign the current referring operator to work_mbc.  */
   work_mbc = &(d->mbcsets[(d->multibyte_prop[pos.index]) >> 2]);
   match = !work_mbc->invert;
-  match_len = (d->mblen_buf[idx] == 0) ? 1 : d->mblen_buf[idx];
+  match_len = MAX (1, d->mblen_buf[idx]);
 
   /* Match in range 0-255?  */
   if (wc < NOTCHAR && work_mbc->cset != -1
@@ -3187,7 +3188,7 @@ transit_state_consume_1char (struct dfa *d, state_num s,
 
   /* Calculate the length of the (single/multi byte) character
      to which p points.  */
-  *mbclen = (d->mblen_buf[*pp - buf_begin] == 0) ? 1 : d->mblen_buf[*pp - buf_begin];
+  *mbclen = MAX (1, d->mblen_buf[*pp - buf_begin]);
 
   /* Calculate the state which can be reached from the state 's' by
      consuming '*mbclen' single bytes from the buffer.  */
@@ -3214,7 +3215,7 @@ transit_state_consume_1char (struct dfa *d, state_num s,
         for (j = 0; j < d->follows[d->states[s].mbps.elems[i].index].nelem;
              j++)
           insert (d->follows[d->states[s].mbps.elems[i].index].elems[j],
-            d->mb_follows);
+                  d->mb_follows);
     }
 
   /* FIXME: this return value is always ignored.  */
@@ -3519,9 +3520,11 @@ free_mbdata (struct dfa *d)
 
   free (d->mblen_buf);
   free (d->inputwcs);
-  if (d->mb_follows != NULL)
-    free (d->mb_follows->elems);
-  free (d->mb_follows);
+  if (d->mb_follows)
+    {
+      free (d->mb_follows->elems);
+      free (d->mb_follows);
+    }
   free (d->mb_match_lens);
 }
 

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |  139 ++++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 73 insertions(+), 66 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Sun Apr 06 01:23:24 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WWfYC-0000n2-4C
	for mharc-grep-commit@gnu.org; Sun, 06 Apr 2014 01:23:24 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:57067)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WWfY8-0000m5-Vs
	for grep-commit@gnu.org; Sun, 06 Apr 2014 01:23:22 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WWfY7-0005L4-Jw
	for grep-commit@gnu.org; Sun, 06 Apr 2014 01:23:20 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:37871)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WWfY7-0005Kk-GK
	for grep-commit@gnu.org; Sun, 06 Apr 2014 01:23:19 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WWfY6-00058S-UK
	for grep-commit@gnu.org; Sun, 06 Apr 2014 05:23:19 +0000
Date: Sun, 06 Apr 2014 05:23:18 +0000
Message-Id: <E1WWfY6-00058S-UK@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-46-g561ffc0
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 625eef0262c1e0d36529fa5a8988a1aa64b3bc2e
X-Git-Newrev: 561ffc0f203ea663bb668ac9f6014c16f39fc7d9
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 06 Apr 2014 05:23:22 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  561ffc0f203ea663bb668ac9f6014c16f39fc7d9 (commit)
      from  625eef0262c1e0d36529fa5a8988a1aa64b3bc2e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=561ffc0f203ea663bb668ac9f6014c16f39fc7d9


commit 561ffc0f203ea663bb668ac9f6014c16f39fc7d9
Author: Norihiro Tanaka <noritnk@kcn.ne.jp>
Date:   Mon Mar 17 23:46:31 2014 +0900

    grep: fix performance bug with regex in line-by-line mode
    
    * src/dfasearch.c (EGexecute): Match line-by-line with regex.

diff --git a/src/dfasearch.c b/src/dfasearch.c
index 5665b82..ca00505 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -204,7 +204,7 @@ size_t
 EGexecute (char const *buf, size_t size, size_t *match_size,
            char const *start_ptr)
 {
-  char const *buflim, *beg, *end, *match, *best_match, *mb_start;
+  char const *buflim, *beg, *end, *ptr, *match, *best_match, *mb_start;
   char eol = eolbyte;
   int backref;
   regoff_t start;
@@ -275,18 +275,20 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
           /* Successful, no backreferences encountered! */
           if (!backref)
             goto success;
+          ptr = beg;
         }
       else
         {
           /* We are looking for the leftmost (then longest) exact match.
              We will go through the outer loop only once.  */
-          beg = start_ptr;
+          beg = buf;
           end = buflim;
+          ptr = start_ptr;
         }
 
       /* If the "line" is longer than the maximum regexp offset,
          die as if we've run out of memory.  */
-      if (TYPE_MAXIMUM (regoff_t) < end - buf - 1)
+      if (TYPE_MAXIMUM (regoff_t) < end - beg - 1)
         xalloc_die ();
 
       /* If we've made it to this point, this means DFA has seen
@@ -297,24 +299,24 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
         {
           patterns[i].regexbuf.not_eol = 0;
           start = re_search (&(patterns[i].regexbuf),
-                             buf, end - buf - 1,
-                             beg - buf, end - beg - 1,
+                             beg, end - beg - 1,
+                             ptr - beg, end - ptr - 1,
                              &(patterns[i].regs));
           if (start < -1)
             xalloc_die ();
           else if (0 <= start)
             {
               len = patterns[i].regs.end[0] - start;
-              match = buf + start;
+              match = beg + start;
               if (match > best_match)
                 continue;
               if (start_ptr && !match_words)
                 goto assess_pattern_match;
               if ((!match_lines && !match_words)
-                  || (match_lines && len == end - beg - 1))
+                  || (match_lines && len == end - ptr - 1))
                 {
-                  match = beg;
-                  len = end - beg;
+                  match = ptr;
+                  len = end - ptr;
                   goto assess_pattern_match;
                 }
               /* If -w, check if the match aligns with word boundaries.
@@ -328,8 +330,8 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                 while (match <= best_match)
                   {
                     regoff_t shorter_len = 0;
-                    if ((match == buf || !WCHAR (to_uchar (match[-1])))
-                        && (start + len == end - buf - 1
+                    if ((match == beg || !WCHAR (to_uchar (match[-1])))
+                        && (start + len == end - beg - 1
                             || !WCHAR (to_uchar (match[len]))))
                       goto assess_pattern_match;
                     if (len > 0)
@@ -338,8 +340,8 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                         --len;
                         patterns[i].regexbuf.not_eol = 1;
                         shorter_len = re_match (&(patterns[i].regexbuf),
-                                                buf, match + len - beg,
-                                                match - buf,
+                                                beg, match + len - ptr,
+                                                match - beg,
                                                 &(patterns[i].regs));
                         if (shorter_len < -1)
                           xalloc_die ();
@@ -354,8 +356,8 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                         match++;
                         patterns[i].regexbuf.not_eol = 0;
                         start = re_search (&(patterns[i].regexbuf),
-                                           buf, end - buf - 1,
-                                           match - buf, end - match - 1,
+                                           beg, end - beg - 1,
+                                           match - beg, end - match - 1,
                                            &(patterns[i].regs));
                         if (start < 0)
                           {
@@ -364,7 +366,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                             break;
                           }
                         len = patterns[i].regs.end[0] - start;
-                        match = buf + start;
+                        match = beg + start;
                       }
                   } /* while (match <= best_match) */
               continue;

-----------------------------------------------------------------------

Summary of changes:
 src/dfasearch.c |   34 ++++++++++++++++++----------------
 1 files changed, 18 insertions(+), 16 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Sun Apr 06 13:01:14 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WWqRW-0003rF-Ag
	for mharc-grep-commit@gnu.org; Sun, 06 Apr 2014 13:01:14 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33834)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WWqRT-0003qX-Ky
	for grep-commit@gnu.org; Sun, 06 Apr 2014 13:01:12 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WWqRS-0003YH-C1
	for grep-commit@gnu.org; Sun, 06 Apr 2014 13:01:11 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:43936)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WWqRS-0003YD-8a
	for grep-commit@gnu.org; Sun, 06 Apr 2014 13:01:10 -0400
Received: from meyering by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <jim@meyering.net>) id 1WWqRR-0006nK-NA
	for grep-commit@gnu.org; Sun, 06 Apr 2014 17:01:09 +0000
Date: Sun, 06 Apr 2014 17:01:09 +0000
Message-Id: <E1WWqRR-0006nK-NA@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-47-ga09cec8
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 561ffc0f203ea663bb668ac9f6014c16f39fc7d9
X-Git-Newrev: a09cec8b667bcbae2f96c8b3de12dc9de4a3ab87
From: Jim Meyering <jim@meyering.net>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 06 Apr 2014 17:01:12 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  a09cec8b667bcbae2f96c8b3de12dc9de4a3ab87 (commit)
      from  561ffc0f203ea663bb668ac9f6014c16f39fc7d9 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=a09cec8b667bcbae2f96c8b3de12dc9de4a3ab87


commit a09cec8b667bcbae2f96c8b3de12dc9de4a3ab87
Author: Jim Meyering <meyering@fb.com>
Date:   Sun Apr 6 09:25:41 2014 -0700

    build: avoid OS X 10.8.5 build failure due to lack of static_assert
    
    * bootstrap.conf (gnulib_modules): Add assert-h, to accommodate the
    new use of static_assert on systems lacking support for that construct.
    Without this change, compilation of dfa.c failed on OS X 10.8.5 with
    gcc-4.9.0 20140324.  We should be using gnulib's assert-h module,
    regardless, for its nominal improved portability, since grep includes
    assert.h and uses assert.

diff --git a/bootstrap.conf b/bootstrap.conf
index 367427d..86cd81d 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -24,6 +24,7 @@ gnulib_modules='
 alloca
 announce-gen
 argmatch
+assert-h
 binary-io
 btowc
 c-ctype

-----------------------------------------------------------------------

Summary of changes:
 bootstrap.conf |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Mon Apr 07 00:56:25 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WX1bd-00069x-B3
	for mharc-grep-commit@gnu.org; Mon, 07 Apr 2014 00:56:25 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:35341)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WX1bZ-00068t-7A
	for grep-commit@gnu.org; Mon, 07 Apr 2014 00:56:23 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WX1bW-0001ui-Q6
	for grep-commit@gnu.org; Mon, 07 Apr 2014 00:56:21 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:49468)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WX1bW-0001ue-L9
	for grep-commit@gnu.org; Mon, 07 Apr 2014 00:56:18 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WX1bV-0000u1-TF
	for grep-commit@gnu.org; Mon, 07 Apr 2014 04:56:18 +0000
Date: Mon, 07 Apr 2014 04:56:17 +0000
Message-Id: <E1WX1bV-0000u1-TF@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-49-g64bd867
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: a09cec8b667bcbae2f96c8b3de12dc9de4a3ab87
X-Git-Newrev: 64bd867b819a68efbd35c07cf8b1fe3ef86c24bd
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 07 Apr 2014 04:56:23 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  64bd867b819a68efbd35c07cf8b1fe3ef86c24bd (commit)
       via  7c9d39eab21ef5dfccb9c1626f9a00a32e514ca0 (commit)
      from  a09cec8b667bcbae2f96c8b3de12dc9de4a3ab87 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=64bd867b819a68efbd35c07cf8b1fe3ef86c24bd


commit 64bd867b819a68efbd35c07cf8b1fe3ef86c24bd
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sun Apr 6 21:54:59 2014 -0700

    grep: cleanup DFA superset optimization
    
    * src/dfa.c (dfa_charclass_index): New function, with body of
    old dfa_charclass but with an extra parameter D.
    (charclass_index): Reimplement in terms of dfa_charclass_index.
    (dfahint): Clarify.
    (dfasuperset): Do not assign to 'dfa' static variable.  Instead,
    use a local, and use the new dfa_charclass_index function.  This
    doesn't fix any bugs, but it's clearer.  Initialize a few more
    members, to simplify dfafree.  Copy the charclasses with
    just one memcpy call.  Don't assign nonnull to D->superset until
    it's known to be valid; that's simpler.
    (dfafree, dfaalloc): Simplify based on dfasuperset initializations.
    * src/dfa.h (dfahint): Add comment.
    * src/dfasearch.c (EGexecute): Simplify use of memchr.
    Simplify by using memrchr.  Fix typo that could cause a buffer
    read overrun.

diff --git a/src/dfa.c b/src/dfa.c
index d88d077..b6c1250 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -674,25 +674,31 @@ equal (charclass const s1, charclass const s2)
   return memcmp (s1, s2, sizeof (charclass)) == 0;
 }
 
-/* A pointer to the current dfa is kept here during parsing.  */
-static struct dfa *dfa;
-
-/* Find the index of charclass s in dfa->charclasses, or allocate a
-   new charclass.  */
+/* In DFA D, find the index of charclass S, or allocate a new one.  */
 static size_t
-charclass_index (charclass const s)
+dfa_charclass_index (struct dfa *d, charclass const s)
 {
   size_t i;
 
-  for (i = 0; i < dfa->cindex; ++i)
-    if (equal (s, dfa->charclasses[i]))
+  for (i = 0; i < d->cindex; ++i)
+    if (equal (s, d->charclasses[i]))
       return i;
-  REALLOC_IF_NECESSARY (dfa->charclasses, dfa->calloc, dfa->cindex + 1);
-  ++dfa->cindex;
-  copyset (s, dfa->charclasses[i]);
+  REALLOC_IF_NECESSARY (d->charclasses, d->calloc, d->cindex + 1);
+  ++d->cindex;
+  copyset (s, d->charclasses[i]);
   return i;
 }
 
+/* A pointer to the current dfa is kept here during parsing.  */
+static struct dfa *dfa;
+
+/* Find the index of charclass S in the current DFA, or allocate a new one.  */
+static size_t
+charclass_index (charclass const s)
+{
+  return dfa_charclass_index (dfa, s);
+}
+
 /* Syntax bits controlling the behavior of the lexical analyzer.  */
 static reg_syntax_t syntax_bits, syntax_bits_set;
 
@@ -3491,19 +3497,24 @@ dfaexec (struct dfa *d, char const *begin, char *end,
     }
 }
 
+/* Search through a buffer looking for a potential match for D.
+   Return the offset of the byte after the first potential match.
+   If there is no match, return (size_t) -1.  If D lacks a superset
+   so it's not known whether there is a match, return (size_t) -2.
+   BEGIN points to the beginning of the buffer, and END points to the
+   first byte after its end.  Store a sentinel byte (usually newline)
+   in *END, so the actual buffer must be one byte longer.  If COUNT is
+   non-NULL, increment *COUNT once for each newline processed.  */
 size_t
 dfahint (struct dfa *d, char const *begin, char *end, size_t *count)
 {
-  char const *match;
-
-  if (d->superset == NULL)
-    return (size_t) -2;
-
-  match = dfaexec (d->superset, begin, end, 1, count, NULL);
-  if (match == NULL)
-    return (size_t) -1;
-
-  return match - begin;
+  if (! d->superset)
+    return -2;
+  else
+    {
+      char const *match = dfaexec (d->superset, begin, end, 1, count, NULL);
+      return match ? match - begin : -1;
+    }
 }
 
 static void
@@ -3604,28 +3615,29 @@ dfasuperset (struct dfa *d)
   charclass ccl;
   bool have_achar = false;
   bool have_nchar = false;
-
-  dfa = d->superset = dfaalloc ();
-  *d->superset = *d;
-  d->superset->mb_cur_max = 1;
-  d->superset->multibyte_prop = NULL;
-  d->superset->mbcsets = NULL;
-  d->superset->superset = NULL;
-  d->superset->states = NULL;
-  d->superset->follows = NULL;
-  d->superset->trans = NULL;
-  d->superset->realtrans = NULL;
-  d->superset->fails = NULL;
-  d->superset->success = NULL;
-  d->superset->newlines = NULL;
-  d->superset->musts = NULL;
-
-  MALLOC (d->superset->charclasses, d->superset->calloc);
-  for (i = 0; i < d->cindex; i++)
-    copyset (d->charclasses[i], d->superset->charclasses[i]);
-
-  d->superset->talloc = d->tindex * 2;
-  MALLOC (d->superset->tokens, d->superset->talloc);
+  struct dfa *sup = dfaalloc ();
+
+  *sup = *d;
+  sup->mb_cur_max = 1;
+  sup->multibyte_prop = NULL;
+  sup->mbcsets = NULL;
+  sup->superset = NULL;
+  sup->states = NULL;
+  sup->sindex = 0;
+  sup->follows = NULL;
+  sup->tralloc = 0;
+  sup->realtrans = NULL;
+  sup->fails = NULL;
+  sup->success = NULL;
+  sup->newlines = NULL;
+  sup->musts = NULL;
+
+  MALLOC (sup->charclasses, sup->calloc);
+  memcpy (sup->charclasses, d->charclasses,
+          d->cindex * sizeof *sup->charclasses);
+
+  sup->talloc = d->tindex * 2;
+  MALLOC (sup->tokens, sup->talloc);
 
   for (i = j = 0; i < d->tindex; i++)
     {
@@ -3636,8 +3648,8 @@ dfasuperset (struct dfa *d)
         case BACKREF:
           zeroset (ccl);
           notset (ccl);
-          d->superset->tokens[j++] = CSET + charclass_index (ccl);
-          d->superset->tokens[j++] = STAR;
+          sup->tokens[j++] = CSET + dfa_charclass_index (sup, ccl);
+          sup->tokens[j++] = STAR;
           if (d->tokens[i + 1] == QMARK || d->tokens[i + 1] == STAR
               || d->tokens[i + 1] == PLUS)
             i++;
@@ -3650,26 +3662,23 @@ dfasuperset (struct dfa *d)
           if (MB_CUR_MAX > 1)
             {
               /* Ignore these constraints.  */
-              d->superset->tokens[j++] = EMPTY;
+              sup->tokens[j++] = EMPTY;
               break;
             }
         default:
-          d->superset->tokens[j++] = d->tokens[i];
-          if ((d->tokens[i] >= 0 && d->tokens[i] < NOTCHAR)
-               || d->tokens[i] >= CSET)
+          sup->tokens[j++] = d->tokens[i];
+          if ((0 <= d->tokens[i] && d->tokens[i] < NOTCHAR)
+              || d->tokens[i] >= CSET)
             have_nchar = true;
           break;
         }
     }
+  sup->tindex = j;
 
   if ((d->mb_cur_max == 1 && !have_achar) || !have_nchar)
-    {
-      dfafree (d->superset);
-      d->superset = NULL;
-      return;
-    }
-
-  d->superset->tindex = j;
+    dfafree (sup);
+  else
+    d->superset = sup;
 }
 
 /* Parse and analyze a single string of the given length.  */
@@ -3683,7 +3692,7 @@ dfacomp (char const *s, size_t len, struct dfa *d, int searchflag)
   dfaoptimize (d);
   dfasuperset (d);
   dfaanalyze (d, searchflag);
-  if (d->superset != NULL)
+  if (d->superset)
     dfaanalyze (d->superset, searchflag);
 }
 
@@ -3700,27 +3709,25 @@ dfafree (struct dfa *d)
   if (d->mb_cur_max > 1)
     free_mbdata (d);
 
-  if (d->states != NULL)
+  for (i = 0; i < d->sindex; ++i)
     {
-      for (i = 0; i < d->sindex; ++i)
-        {
-          free (d->states[i].elems.elems);
-          free (d->states[i].mbps.elems);
-        }
-      free (d->states);
+      free (d->states[i].elems.elems);
+      free (d->states[i].mbps.elems);
     }
-  if (d->follows != NULL)
+  free (d->states);
+
+  if (d->follows)
     {
       for (i = 0; i < d->tindex; ++i)
         free (d->follows[i].elems);
       free (d->follows);
     }
-  if (d->trans != NULL)
-    for (i = 0; i < d->tralloc; ++i)
-      {
-        free (d->trans[i]);
-        free (d->fails[i]);
-      }
+
+  for (i = 0; i < d->tralloc; ++i)
+    {
+      free (d->trans[i]);
+      free (d->fails[i]);
+    }
 
   free (d->realtrans);
   free (d->fails);
@@ -3734,7 +3741,7 @@ dfafree (struct dfa *d)
       free (dm);
     }
 
-  if (d->superset != NULL)
+  if (d->superset)
     dfafree (d->superset);
 }
 
@@ -4243,9 +4250,7 @@ done:
 struct dfa *
 dfaalloc (void)
 {
-  struct dfa *d = xmalloc (sizeof (struct dfa));
-  d->superset = NULL;
-  return d;
+  return xmalloc (sizeof (struct dfa));
 }
 
 struct dfamust *_GL_ATTRIBUTE_PURE
diff --git a/src/dfa.h b/src/dfa.h
index ad97498..6ed2231 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -67,10 +67,18 @@ extern void dfacomp (char const *, size_t, struct dfa *, int);
    to decide whether to fall back on a backtracking matcher. */
 extern char *dfaexec (struct dfa *d, char const *begin, char *end,
                       int newline, size_t *count, int *backref);
+
+/* Search through a buffer looking for a potential match for D.
+   Return the offset of the byte after the first potential match.
+   If there is no match, return (size_t) -1.  If D lacks a superset
+   so it's not known whether there is a match, return (size_t) -2.
+   BEGIN points to the beginning of the buffer, and END points to the
+   first byte after its end.  Store a sentinel byte (usually newline)
+   in *END, so the actual buffer must be one byte longer.  If COUNT is
+   non-NULL, increment *COUNT once for each newline processed.  */
 extern size_t dfahint (struct dfa *d, char const *begin, char *end,
                        size_t *count);
 
-
 /* Free the storage held by the components of a struct dfa. */
 extern void dfafree (struct dfa *);
 
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 383c2ad..adec4e2 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -229,13 +229,11 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
               beg += offset;
               /* Narrow down to the line containing the candidate, and
                  run it through DFA. */
-              if ((end = memchr(beg, eol, buflim - beg)) != NULL)
-                end++;
-              else
-                end = buflim;
+              end = memchr (beg, eol, buflim - beg);
+              end = end ? end + 1 : buflim;
               match = beg;
-              while (beg > buf && beg[-1] != eol)
-                --beg;
+              beg = memrchr (buf, eol, beg - buf);
+              beg = beg ? beg + 1 : buf;
               if (kwsm.index < kwset_exact_matches)
                 {
                   if (mb_start < beg)
@@ -247,17 +245,15 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                   /* The matched line starts in the middle of a multibyte
                      character.  Perform the DFA search starting from the
                      beginning of the next character.  */
-                  if (dfaexec (dfa, mb_start, (char *) end, 0, NULL,
-                               &backref) == NULL)
+                  if (! dfaexec (dfa, mb_start, (char *) end, 0, NULL,
+                                 &backref))
                     continue;
                 }
               else
                 {
-                  if (dfahint (dfa, beg, (char *) end, NULL) ==
-                               (size_t) -1)
+                  if (dfahint (dfa, beg, (char *) end, NULL) == (size_t) -1)
                     continue;
-                  if (dfaexec (dfa, beg, (char *) end, 0, NULL,
-                               &backref) == NULL)
+                  if (! dfaexec (dfa, beg, (char *) end, 0, NULL, &backref))
                     continue;
                 }
             }
@@ -283,20 +279,17 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
               else
                 next_beg = beg + offset;
               /* Narrow down to the line we've found. */
-              beg = next_beg;
-              while (beg > buf && beg[-1] != eol)
-                --beg;
-              if (count > 0)
+              beg = memrchr (buf, eol, next_beg - buf);
+              beg = beg ? beg + 1 : buf;
+              if (count != 0)
                 {
-                  /* dfahint() may match in multiple lines.  If that is
-                     the case, try to match in one line.  */
+                  /* If dfahint may match in multiple lines, try to
+                     match in one line.  */
                   end = beg;
                   continue;
                 }
-              if ((end = memchr(next_beg, eol, buflim - beg)) != NULL)
-                end++;
-              else
-                end = buflim;
+              end = memchr (next_beg, eol, buflim - next_beg);
+              end = end ? end + 1 : buflim;
               if (offset != (size_t) -2)
                 {
                   next_beg = dfaexec (dfa, beg, (char *) end, 0, NULL,

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=7c9d39eab21ef5dfccb9c1626f9a00a32e514ca0


commit 64bd867b819a68efbd35c07cf8b1fe3ef86c24bd
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sun Apr 6 21:54:59 2014 -0700

    grep: cleanup DFA superset optimization
    
    * src/dfa.c (dfa_charclass_index): New function, with body of
    old dfa_charclass but with an extra parameter D.
    (charclass_index): Reimplement in terms of dfa_charclass_index.
    (dfahint): Clarify.
    (dfasuperset): Do not assign to 'dfa' static variable.  Instead,
    use a local, and use the new dfa_charclass_index function.  This
    doesn't fix any bugs, but it's clearer.  Initialize a few more
    members, to simplify dfafree.  Copy the charclasses with
    just one memcpy call.  Don't assign nonnull to D->superset until
    it's known to be valid; that's simpler.
    (dfafree, dfaalloc): Simplify based on dfasuperset initializations.
    * src/dfa.h (dfahint): Add comment.
    * src/dfasearch.c (EGexecute): Simplify use of memchr.
    Simplify by using memrchr.  Fix typo that could cause a buffer
    read overrun.

diff --git a/src/dfa.c b/src/dfa.c
index d88d077..b6c1250 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -674,25 +674,31 @@ equal (charclass const s1, charclass const s2)
   return memcmp (s1, s2, sizeof (charclass)) == 0;
 }
 
-/* A pointer to the current dfa is kept here during parsing.  */
-static struct dfa *dfa;
-
-/* Find the index of charclass s in dfa->charclasses, or allocate a
-   new charclass.  */
+/* In DFA D, find the index of charclass S, or allocate a new one.  */
 static size_t
-charclass_index (charclass const s)
+dfa_charclass_index (struct dfa *d, charclass const s)
 {
   size_t i;
 
-  for (i = 0; i < dfa->cindex; ++i)
-    if (equal (s, dfa->charclasses[i]))
+  for (i = 0; i < d->cindex; ++i)
+    if (equal (s, d->charclasses[i]))
       return i;
-  REALLOC_IF_NECESSARY (dfa->charclasses, dfa->calloc, dfa->cindex + 1);
-  ++dfa->cindex;
-  copyset (s, dfa->charclasses[i]);
+  REALLOC_IF_NECESSARY (d->charclasses, d->calloc, d->cindex + 1);
+  ++d->cindex;
+  copyset (s, d->charclasses[i]);
   return i;
 }
 
+/* A pointer to the current dfa is kept here during parsing.  */
+static struct dfa *dfa;
+
+/* Find the index of charclass S in the current DFA, or allocate a new one.  */
+static size_t
+charclass_index (charclass const s)
+{
+  return dfa_charclass_index (dfa, s);
+}
+
 /* Syntax bits controlling the behavior of the lexical analyzer.  */
 static reg_syntax_t syntax_bits, syntax_bits_set;
 
@@ -3491,19 +3497,24 @@ dfaexec (struct dfa *d, char const *begin, char *end,
     }
 }
 
+/* Search through a buffer looking for a potential match for D.
+   Return the offset of the byte after the first potential match.
+   If there is no match, return (size_t) -1.  If D lacks a superset
+   so it's not known whether there is a match, return (size_t) -2.
+   BEGIN points to the beginning of the buffer, and END points to the
+   first byte after its end.  Store a sentinel byte (usually newline)
+   in *END, so the actual buffer must be one byte longer.  If COUNT is
+   non-NULL, increment *COUNT once for each newline processed.  */
 size_t
 dfahint (struct dfa *d, char const *begin, char *end, size_t *count)
 {
-  char const *match;
-
-  if (d->superset == NULL)
-    return (size_t) -2;
-
-  match = dfaexec (d->superset, begin, end, 1, count, NULL);
-  if (match == NULL)
-    return (size_t) -1;
-
-  return match - begin;
+  if (! d->superset)
+    return -2;
+  else
+    {
+      char const *match = dfaexec (d->superset, begin, end, 1, count, NULL);
+      return match ? match - begin : -1;
+    }
 }
 
 static void
@@ -3604,28 +3615,29 @@ dfasuperset (struct dfa *d)
   charclass ccl;
   bool have_achar = false;
   bool have_nchar = false;
-
-  dfa = d->superset = dfaalloc ();
-  *d->superset = *d;
-  d->superset->mb_cur_max = 1;
-  d->superset->multibyte_prop = NULL;
-  d->superset->mbcsets = NULL;
-  d->superset->superset = NULL;
-  d->superset->states = NULL;
-  d->superset->follows = NULL;
-  d->superset->trans = NULL;
-  d->superset->realtrans = NULL;
-  d->superset->fails = NULL;
-  d->superset->success = NULL;
-  d->superset->newlines = NULL;
-  d->superset->musts = NULL;
-
-  MALLOC (d->superset->charclasses, d->superset->calloc);
-  for (i = 0; i < d->cindex; i++)
-    copyset (d->charclasses[i], d->superset->charclasses[i]);
-
-  d->superset->talloc = d->tindex * 2;
-  MALLOC (d->superset->tokens, d->superset->talloc);
+  struct dfa *sup = dfaalloc ();
+
+  *sup = *d;
+  sup->mb_cur_max = 1;
+  sup->multibyte_prop = NULL;
+  sup->mbcsets = NULL;
+  sup->superset = NULL;
+  sup->states = NULL;
+  sup->sindex = 0;
+  sup->follows = NULL;
+  sup->tralloc = 0;
+  sup->realtrans = NULL;
+  sup->fails = NULL;
+  sup->success = NULL;
+  sup->newlines = NULL;
+  sup->musts = NULL;
+
+  MALLOC (sup->charclasses, sup->calloc);
+  memcpy (sup->charclasses, d->charclasses,
+          d->cindex * sizeof *sup->charclasses);
+
+  sup->talloc = d->tindex * 2;
+  MALLOC (sup->tokens, sup->talloc);
 
   for (i = j = 0; i < d->tindex; i++)
     {
@@ -3636,8 +3648,8 @@ dfasuperset (struct dfa *d)
         case BACKREF:
           zeroset (ccl);
           notset (ccl);
-          d->superset->tokens[j++] = CSET + charclass_index (ccl);
-          d->superset->tokens[j++] = STAR;
+          sup->tokens[j++] = CSET + dfa_charclass_index (sup, ccl);
+          sup->tokens[j++] = STAR;
           if (d->tokens[i + 1] == QMARK || d->tokens[i + 1] == STAR
               || d->tokens[i + 1] == PLUS)
             i++;
@@ -3650,26 +3662,23 @@ dfasuperset (struct dfa *d)
           if (MB_CUR_MAX > 1)
             {
               /* Ignore these constraints.  */
-              d->superset->tokens[j++] = EMPTY;
+              sup->tokens[j++] = EMPTY;
               break;
             }
         default:
-          d->superset->tokens[j++] = d->tokens[i];
-          if ((d->tokens[i] >= 0 && d->tokens[i] < NOTCHAR)
-               || d->tokens[i] >= CSET)
+          sup->tokens[j++] = d->tokens[i];
+          if ((0 <= d->tokens[i] && d->tokens[i] < NOTCHAR)
+              || d->tokens[i] >= CSET)
             have_nchar = true;
           break;
         }
     }
+  sup->tindex = j;
 
   if ((d->mb_cur_max == 1 && !have_achar) || !have_nchar)
-    {
-      dfafree (d->superset);
-      d->superset = NULL;
-      return;
-    }
-
-  d->superset->tindex = j;
+    dfafree (sup);
+  else
+    d->superset = sup;
 }
 
 /* Parse and analyze a single string of the given length.  */
@@ -3683,7 +3692,7 @@ dfacomp (char const *s, size_t len, struct dfa *d, int searchflag)
   dfaoptimize (d);
   dfasuperset (d);
   dfaanalyze (d, searchflag);
-  if (d->superset != NULL)
+  if (d->superset)
     dfaanalyze (d->superset, searchflag);
 }
 
@@ -3700,27 +3709,25 @@ dfafree (struct dfa *d)
   if (d->mb_cur_max > 1)
     free_mbdata (d);
 
-  if (d->states != NULL)
+  for (i = 0; i < d->sindex; ++i)
     {
-      for (i = 0; i < d->sindex; ++i)
-        {
-          free (d->states[i].elems.elems);
-          free (d->states[i].mbps.elems);
-        }
-      free (d->states);
+      free (d->states[i].elems.elems);
+      free (d->states[i].mbps.elems);
     }
-  if (d->follows != NULL)
+  free (d->states);
+
+  if (d->follows)
     {
       for (i = 0; i < d->tindex; ++i)
         free (d->follows[i].elems);
       free (d->follows);
     }
-  if (d->trans != NULL)
-    for (i = 0; i < d->tralloc; ++i)
-      {
-        free (d->trans[i]);
-        free (d->fails[i]);
-      }
+
+  for (i = 0; i < d->tralloc; ++i)
+    {
+      free (d->trans[i]);
+      free (d->fails[i]);
+    }
 
   free (d->realtrans);
   free (d->fails);
@@ -3734,7 +3741,7 @@ dfafree (struct dfa *d)
       free (dm);
     }
 
-  if (d->superset != NULL)
+  if (d->superset)
     dfafree (d->superset);
 }
 
@@ -4243,9 +4250,7 @@ done:
 struct dfa *
 dfaalloc (void)
 {
-  struct dfa *d = xmalloc (sizeof (struct dfa));
-  d->superset = NULL;
-  return d;
+  return xmalloc (sizeof (struct dfa));
 }
 
 struct dfamust *_GL_ATTRIBUTE_PURE
diff --git a/src/dfa.h b/src/dfa.h
index ad97498..6ed2231 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -67,10 +67,18 @@ extern void dfacomp (char const *, size_t, struct dfa *, int);
    to decide whether to fall back on a backtracking matcher. */
 extern char *dfaexec (struct dfa *d, char const *begin, char *end,
                       int newline, size_t *count, int *backref);
+
+/* Search through a buffer looking for a potential match for D.
+   Return the offset of the byte after the first potential match.
+   If there is no match, return (size_t) -1.  If D lacks a superset
+   so it's not known whether there is a match, return (size_t) -2.
+   BEGIN points to the beginning of the buffer, and END points to the
+   first byte after its end.  Store a sentinel byte (usually newline)
+   in *END, so the actual buffer must be one byte longer.  If COUNT is
+   non-NULL, increment *COUNT once for each newline processed.  */
 extern size_t dfahint (struct dfa *d, char const *begin, char *end,
                        size_t *count);
 
-
 /* Free the storage held by the components of a struct dfa. */
 extern void dfafree (struct dfa *);
 
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 383c2ad..adec4e2 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -229,13 +229,11 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
               beg += offset;
               /* Narrow down to the line containing the candidate, and
                  run it through DFA. */
-              if ((end = memchr(beg, eol, buflim - beg)) != NULL)
-                end++;
-              else
-                end = buflim;
+              end = memchr (beg, eol, buflim - beg);
+              end = end ? end + 1 : buflim;
               match = beg;
-              while (beg > buf && beg[-1] != eol)
-                --beg;
+              beg = memrchr (buf, eol, beg - buf);
+              beg = beg ? beg + 1 : buf;
               if (kwsm.index < kwset_exact_matches)
                 {
                   if (mb_start < beg)
@@ -247,17 +245,15 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                   /* The matched line starts in the middle of a multibyte
                      character.  Perform the DFA search starting from the
                      beginning of the next character.  */
-                  if (dfaexec (dfa, mb_start, (char *) end, 0, NULL,
-                               &backref) == NULL)
+                  if (! dfaexec (dfa, mb_start, (char *) end, 0, NULL,
+                                 &backref))
                     continue;
                 }
               else
                 {
-                  if (dfahint (dfa, beg, (char *) end, NULL) ==
-                               (size_t) -1)
+                  if (dfahint (dfa, beg, (char *) end, NULL) == (size_t) -1)
                     continue;
-                  if (dfaexec (dfa, beg, (char *) end, 0, NULL,
-                               &backref) == NULL)
+                  if (! dfaexec (dfa, beg, (char *) end, 0, NULL, &backref))
                     continue;
                 }
             }
@@ -283,20 +279,17 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
               else
                 next_beg = beg + offset;
               /* Narrow down to the line we've found. */
-              beg = next_beg;
-              while (beg > buf && beg[-1] != eol)
-                --beg;
-              if (count > 0)
+              beg = memrchr (buf, eol, next_beg - buf);
+              beg = beg ? beg + 1 : buf;
+              if (count != 0)
                 {
-                  /* dfahint() may match in multiple lines.  If that is
-                     the case, try to match in one line.  */
+                  /* If dfahint may match in multiple lines, try to
+                     match in one line.  */
                   end = beg;
                   continue;
                 }
-              if ((end = memchr(next_beg, eol, buflim - beg)) != NULL)
-                end++;
-              else
-                end = buflim;
+              end = memchr (next_beg, eol, buflim - next_beg);
+              end = end ? end + 1 : buflim;
               if (offset != (size_t) -2)
                 {
                   next_beg = dfaexec (dfa, beg, (char *) end, 0, NULL,

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c       |  143 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 src/dfa.h       |   11 ++++
 src/dfasearch.c |   76 ++++++++++++++++++++---------
 3 files changed, 192 insertions(+), 38 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Mon Apr 07 22:51:31 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WXM8J-0005z7-3D
	for mharc-grep-commit@gnu.org; Mon, 07 Apr 2014 22:51:31 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34533)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXM8E-0005yz-QS
	for grep-commit@gnu.org; Mon, 07 Apr 2014 22:51:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXM8B-0000jt-Bv
	for grep-commit@gnu.org; Mon, 07 Apr 2014 22:51:26 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:33633)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXM8B-0000jl-6c
	for grep-commit@gnu.org; Mon, 07 Apr 2014 22:51:23 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXM8A-0007dy-DC
	for grep-commit@gnu.org; Tue, 08 Apr 2014 02:51:22 +0000
Date: Tue, 08 Apr 2014 02:51:22 +0000
Message-Id: <E1WXM8A-0007dy-DC@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-52-gbf34bed
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 64bd867b819a68efbd35c07cf8b1fe3ef86c24bd
X-Git-Newrev: bf34bedae7276c0f5522ad40db55a7c0d23c739d
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 08 Apr 2014 02:51:30 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  bf34bedae7276c0f5522ad40db55a7c0d23c739d (commit)
       via  3a8f221c59ce0f3936424f03f2d696b27d47765f (commit)
       via  757381e58d669729510a89c323d4698f9a81f6c0 (commit)
      from  64bd867b819a68efbd35c07cf8b1fe3ef86c24bd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=bf34bedae7276c0f5522ad40db55a7c0d23c739d


commit bf34bedae7276c0f5522ad40db55a7c0d23c739d
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Mon Apr 7 19:48:33 2014 -0700

    grep: simplify memory allocation in kwset
    
    * src/kwset.c: Include kwset.h first, to check its prereqs.
    Include xalloc.h, for xmalloc.
    (kwsalloc): Use xmalloc, not malloc, so that the caller need not
    worry about memory allocation failure.
    (kwsalloc, kwsincr, kwsprep): Do not worry about obstack_alloc
    returning NULL, as that's not possible.
    (kwsalloc, kwsincr, kwsprep, bmexec, cwexec, kwsexec, kwsfree):
    Omit unnecessary conversion between struct kwset * and kwset_t.
    (kwsincr, kwsprep): Return void since memory-allocation failure is
    not possible now.  All uses changed.
    * src/kwset.h: Include <stddef.h>, for size_t, so that this
    include file doesn't require other files to be included first.

diff --git a/src/dfasearch.c b/src/dfasearch.c
index adec4e2..44360b6 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -90,7 +90,6 @@ kwsmusts (void)
   struct dfamust const *dm = dfamusts (dfa);
   if (dm)
     {
-      char const *err;
       kwsinit (&kwset);
       /* First, we compile in the substrings known to be exact
          matches.  The kwset matcher will return the index
@@ -100,8 +99,7 @@ kwsmusts (void)
           if (!dm->exact)
             continue;
           ++kwset_exact_matches;
-          if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != NULL)
-            error (EXIT_TROUBLE, 0, "%s", err);
+          kwsincr (kwset, dm->must, strlen (dm->must));
         }
       /* Now, we compile the substrings that will require
          the use of the regexp matcher.  */
@@ -109,11 +107,9 @@ kwsmusts (void)
         {
           if (dm->exact)
             continue;
-          if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != NULL)
-            error (EXIT_TROUBLE, 0, "%s", err);
+          kwsincr (kwset, dm->must, strlen (dm->must));
         }
-      if ((err = kwsprep (kwset)) != NULL)
-        error (EXIT_TROUBLE, 0, "%s", err);
+      kwsprep (kwset);
     }
 }
 
diff --git a/src/kwsearch.c b/src/kwsearch.c
index dd01518..df94951 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -32,7 +32,6 @@ static kwset_t kwset;
 void
 Fcompile (char const *pattern, size_t size)
 {
-  char const *err;
   size_t psize = size;
   mb_len_map_t *map = NULL;
   char const *pat = (match_icase && MB_CUR_MAX > 1
@@ -65,14 +64,12 @@ Fcompile (char const *pattern, size_t size)
 #endif
         }
 
-      if ((err = kwsincr (kwset, beg, end - beg)) != NULL)
-        error (EXIT_TROUBLE, 0, "%s", err);
+      kwsincr (kwset, beg, end - beg);
       beg = lim;
     }
   while (beg < pat + psize);
 
-  if ((err = kwsprep (kwset)) != NULL)
-    error (EXIT_TROUBLE, 0, "%s", err);
+  kwsprep (kwset);
 }
 
 /* Apply the MAP (created by mbtoupper) to the uppercase-buffer-relative
diff --git a/src/kwset.c b/src/kwset.c
index 6c07249..d5db12f 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -32,11 +32,14 @@
    failure function used below. */
 
 #include <config.h>
+
+#include "kwset.h"
+
 #include <stdbool.h>
 #include <sys/types.h>
 #include "system.h"
-#include "kwset.h"
 #include "obstack.h"
+#include "xalloc.h"
 
 #define link kwset_link
 
@@ -91,25 +94,15 @@ struct kwset
 };
 
 /* Allocate and initialize a keyword set object, returning an opaque
-   pointer to it.  Return NULL if memory is not available. */
+   pointer to it.  */
 kwset_t
 kwsalloc (char const *trans)
 {
-  struct kwset *kwset;
+  struct kwset *kwset = xmalloc (sizeof *kwset);
 
-  kwset = (struct kwset *) malloc(sizeof (struct kwset));
-  if (!kwset)
-    return NULL;
-
-  obstack_init(&kwset->obstack);
+  obstack_init (&kwset->obstack);
   kwset->words = 0;
-  kwset->trie
-    = (struct trie *) obstack_alloc(&kwset->obstack, sizeof (struct trie));
-  if (!kwset->trie)
-    {
-      kwsfree((kwset_t) kwset);
-      return NULL;
-    }
+  kwset->trie = obstack_alloc (&kwset->obstack, sizeof *kwset->trie);
   kwset->trie->accepting = 0;
   kwset->trie->links = NULL;
   kwset->trie->parent = NULL;
@@ -122,19 +115,17 @@ kwsalloc (char const *trans)
   kwset->target = NULL;
   kwset->trans = trans;
 
-  return (kwset_t) kwset;
+  return kwset;
 }
 
 /* This upper bound is valid for CHAR_BIT >= 4 and
    exact for CHAR_BIT in { 4..11, 13, 15, 17, 19 }. */
 #define DEPTH_SIZE (CHAR_BIT + CHAR_BIT/2)
 
-/* Add the given string to the contents of the keyword set.  Return NULL
-   for success, an error message otherwise. */
-const char *
-kwsincr (kwset_t kws, char const *text, size_t len)
+/* Add the given string to the contents of the keyword set.  */
+void
+kwsincr (kwset_t kwset, char const *text, size_t len)
 {
-  struct kwset *kwset = kws;
   struct trie *trie = kwset->trie;
   char const *trans = kwset->trans;
 
@@ -171,19 +162,10 @@ kwsincr (kwset_t kws, char const *text, size_t len)
          a link in the current trie node's tree. */
       if (!link)
         {
-          link = (struct tree *) obstack_alloc(&kwset->obstack,
-                                               sizeof (struct tree));
-          if (!link)
-            return _("memory exhausted");
+          link = obstack_alloc (&kwset->obstack, sizeof *link);
           link->llink = NULL;
           link->rlink = NULL;
-          link->trie = (struct trie *) obstack_alloc(&kwset->obstack,
-                                                     sizeof (struct trie));
-          if (!link->trie)
-            {
-              obstack_free(&kwset->obstack, link);
-              return _("memory exhausted");
-            }
+          link->trie = obstack_alloc (&kwset->obstack, sizeof *link->trie);
           link->trie->accepting = 0;
           link->trie->links = NULL;
           link->trie->parent = trie;
@@ -283,8 +265,6 @@ kwsincr (kwset_t kws, char const *text, size_t len)
     kwset->mind = trie->depth;
   if (trie->depth > kwset->maxd)
     kwset->maxd = trie->depth;
-
-  return NULL;
 }
 
 /* Enqueue the trie nodes referenced from the given tree in the
@@ -382,10 +362,9 @@ treenext (struct tree const *tree, struct trie *next[])
 
 /* Compute the shift for each trie node, as well as the delta
    table and next cache for the given keyword set. */
-const char *
-kwsprep (kwset_t kws)
+void
+kwsprep (kwset_t kwset)
 {
-  struct kwset *kwset = kws;
   char const *trans = kwset->trans;
   int i;
   unsigned char deltabuf[NCHAR];
@@ -458,9 +437,7 @@ kwsprep (kwset_t kws)
   if (!trans && kwset->words == 1)
     {
       /* Looking for just one string.  Extract it from the trie. */
-      kwset->target = obstack_alloc(&kwset->obstack, kwset->mind);
-      if (!kwset->target)
-        return _("memory exhausted");
+      kwset->target = obstack_alloc (&kwset->obstack, kwset->mind);
       for (i = kwset->mind - 1, curr = kwset->trie; i >= 0; --i)
         {
           kwset->target[i] = curr->links->label;
@@ -473,8 +450,6 @@ kwsprep (kwset_t kws)
           kwset->shift
             = obstack_alloc (&kwset->obstack,
                              sizeof *kwset->shift * (kwset->mind - 1));
-          if (!kwset->shift)
-            return _("memory exhausted");
           for (i = 0, curr = kwset->trie->next; i < kwset->mind - 1; ++i)
             {
               kwset->shift[i] = curr->shift;
@@ -487,22 +462,17 @@ kwsprep (kwset_t kws)
   if (trans)
     for (i = 0; i < NCHAR; ++i)
       kwset->delta[i] = delta[U(trans[i])];
-
-  return NULL;
 }
 
 /* Fast boyer-moore search. */
 static size_t _GL_ATTRIBUTE_PURE
-bmexec (kwset_t kws, char const *text, size_t size)
+bmexec (kwset_t kwset, char const *text, size_t size)
 {
-  struct kwset const *kwset;
   unsigned char const *d1;
   char const *ep, *sp, *tp;
-  int d, i, len, skip;
+  int d, i, skip;
   char gc1, gc2;
-
-  kwset = (struct kwset const *) kws;
-  len = kwset->mind;
+  int len = kwset->mind;
 
   if (len == 0)
     return 0;
@@ -619,9 +589,8 @@ bmexec (kwset_t kws, char const *text, size_t size)
 
 /* Hairy multiple string search. */
 static size_t _GL_ARG_NONNULL ((4))
-cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch)
+cwexec (kwset_t kwset, char const *text, size_t len, struct kwsmatch *kwsmatch)
 {
-  struct kwset const *kwset;
   struct trie * const *next;
   struct trie const *trie;
   struct trie const *accept;
@@ -638,7 +607,6 @@ cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch)
 #endif
 
   /* Initialize register copies and look for easy ways out. */
-  kwset = (struct kwset *) kws;
   if (len < kwset->mind)
     return -1;
   next = kwset->next;
@@ -775,18 +743,18 @@ cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch)
   return mch - text;
 }
 
-/* Search TEXT for a match of any member of the keyword set, KWS.
+/* Search TEXT for a match of any member of KWSET.
    Return the offset (into TEXT) of the first byte of the matching substring,
    or (size_t) -1 if no match is found.  Upon a match, store details in
    *KWSMATCH: index of matched keyword, start offset (same as the return
    value), and length.  */
 size_t
-kwsexec (kwset_t kws, char const *text, size_t size, struct kwsmatch *kwsmatch)
+kwsexec (kwset_t kwset, char const *text, size_t size,
+         struct kwsmatch *kwsmatch)
 {
-  struct kwset const *kwset = (struct kwset *) kws;
   if (kwset->words == 1 && kwset->trans == NULL)
     {
-      size_t ret = bmexec (kws, text, size);
+      size_t ret = bmexec (kwset, text, size);
       if (ret != (size_t) -1)
         {
           kwsmatch->index = 0;
@@ -796,16 +764,13 @@ kwsexec (kwset_t kws, char const *text, size_t size, struct kwsmatch *kwsmatch)
       return ret;
     }
   else
-    return cwexec(kws, text, size, kwsmatch);
+    return cwexec (kwset, text, size, kwsmatch);
 }
 
 /* Free the components of the given keyword set. */
 void
-kwsfree (kwset_t kws)
+kwsfree (kwset_t kwset)
 {
-  struct kwset *kwset;
-
-  kwset = (struct kwset *) kws;
-  obstack_free(&kwset->obstack, NULL);
-  free(kws);
+  obstack_free (&kwset->obstack, NULL);
+  free (kwset);
 }
diff --git a/src/kwset.h b/src/kwset.h
index 2d3cdd9..12afb8e 100644
--- a/src/kwset.h
+++ b/src/kwset.h
@@ -21,6 +21,8 @@
    The author may be reached (Email) at the address mike@ai.mit.edu,
    or (US mail) as Mike Haertel c/o Free Software Foundation. */
 
+#include <stddef.h>
+
 struct kwsmatch
 {
   size_t index;			/* Index number of matching keyword. */
@@ -33,20 +35,17 @@ struct kwsmatch
 struct kwset;
 typedef struct kwset *kwset_t;
 
-/* Return an opaque pointer to a newly allocated keyword set, or NULL
-   if enough memory cannot be obtained.  The argument if non-NULL
+/* Return an opaque pointer to a newly allocated keyword set.  A nonnull arg
    specifies a table of character translations to be applied to all
-   pattern and search text. */
+   pattern and search text.  */
 extern kwset_t kwsalloc (char const *);
 
 /* Incrementally extend the keyword set to include the given string.
-   Return NULL for success, or an error message.  Remember an index
-   number for each keyword included in the set. */
-extern const char *kwsincr (kwset_t, char const *, size_t);
+   Remember an index number for each keyword included in the set.  */
+extern void kwsincr (kwset_t, char const *, size_t);
 
-/* When the keyword set has been completely built, prepare it for
-   use.  Return NULL for success, or an error message. */
-extern const char *kwsprep (kwset_t);
+/* When the keyword set has been completely built, prepare it for use.  */
+extern void kwsprep (kwset_t);
 
 /* Search through the given buffer for a member of the keyword set.
    Return a pointer to the leftmost longest match found, or NULL if

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=3a8f221c59ce0f3936424f03f2d696b27d47765f


commit bf34bedae7276c0f5522ad40db55a7c0d23c739d
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Mon Apr 7 19:48:33 2014 -0700

    grep: simplify memory allocation in kwset
    
    * src/kwset.c: Include kwset.h first, to check its prereqs.
    Include xalloc.h, for xmalloc.
    (kwsalloc): Use xmalloc, not malloc, so that the caller need not
    worry about memory allocation failure.
    (kwsalloc, kwsincr, kwsprep): Do not worry about obstack_alloc
    returning NULL, as that's not possible.
    (kwsalloc, kwsincr, kwsprep, bmexec, cwexec, kwsexec, kwsfree):
    Omit unnecessary conversion between struct kwset * and kwset_t.
    (kwsincr, kwsprep): Return void since memory-allocation failure is
    not possible now.  All uses changed.
    * src/kwset.h: Include <stddef.h>, for size_t, so that this
    include file doesn't require other files to be included first.

diff --git a/src/dfasearch.c b/src/dfasearch.c
index adec4e2..44360b6 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -90,7 +90,6 @@ kwsmusts (void)
   struct dfamust const *dm = dfamusts (dfa);
   if (dm)
     {
-      char const *err;
       kwsinit (&kwset);
       /* First, we compile in the substrings known to be exact
          matches.  The kwset matcher will return the index
@@ -100,8 +99,7 @@ kwsmusts (void)
           if (!dm->exact)
             continue;
           ++kwset_exact_matches;
-          if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != NULL)
-            error (EXIT_TROUBLE, 0, "%s", err);
+          kwsincr (kwset, dm->must, strlen (dm->must));
         }
       /* Now, we compile the substrings that will require
          the use of the regexp matcher.  */
@@ -109,11 +107,9 @@ kwsmusts (void)
         {
           if (dm->exact)
             continue;
-          if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != NULL)
-            error (EXIT_TROUBLE, 0, "%s", err);
+          kwsincr (kwset, dm->must, strlen (dm->must));
         }
-      if ((err = kwsprep (kwset)) != NULL)
-        error (EXIT_TROUBLE, 0, "%s", err);
+      kwsprep (kwset);
     }
 }
 
diff --git a/src/kwsearch.c b/src/kwsearch.c
index dd01518..df94951 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -32,7 +32,6 @@ static kwset_t kwset;
 void
 Fcompile (char const *pattern, size_t size)
 {
-  char const *err;
   size_t psize = size;
   mb_len_map_t *map = NULL;
   char const *pat = (match_icase && MB_CUR_MAX > 1
@@ -65,14 +64,12 @@ Fcompile (char const *pattern, size_t size)
 #endif
         }
 
-      if ((err = kwsincr (kwset, beg, end - beg)) != NULL)
-        error (EXIT_TROUBLE, 0, "%s", err);
+      kwsincr (kwset, beg, end - beg);
       beg = lim;
     }
   while (beg < pat + psize);
 
-  if ((err = kwsprep (kwset)) != NULL)
-    error (EXIT_TROUBLE, 0, "%s", err);
+  kwsprep (kwset);
 }
 
 /* Apply the MAP (created by mbtoupper) to the uppercase-buffer-relative
diff --git a/src/kwset.c b/src/kwset.c
index 6c07249..d5db12f 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -32,11 +32,14 @@
    failure function used below. */
 
 #include <config.h>
+
+#include "kwset.h"
+
 #include <stdbool.h>
 #include <sys/types.h>
 #include "system.h"
-#include "kwset.h"
 #include "obstack.h"
+#include "xalloc.h"
 
 #define link kwset_link
 
@@ -91,25 +94,15 @@ struct kwset
 };
 
 /* Allocate and initialize a keyword set object, returning an opaque
-   pointer to it.  Return NULL if memory is not available. */
+   pointer to it.  */
 kwset_t
 kwsalloc (char const *trans)
 {
-  struct kwset *kwset;
+  struct kwset *kwset = xmalloc (sizeof *kwset);
 
-  kwset = (struct kwset *) malloc(sizeof (struct kwset));
-  if (!kwset)
-    return NULL;
-
-  obstack_init(&kwset->obstack);
+  obstack_init (&kwset->obstack);
   kwset->words = 0;
-  kwset->trie
-    = (struct trie *) obstack_alloc(&kwset->obstack, sizeof (struct trie));
-  if (!kwset->trie)
-    {
-      kwsfree((kwset_t) kwset);
-      return NULL;
-    }
+  kwset->trie = obstack_alloc (&kwset->obstack, sizeof *kwset->trie);
   kwset->trie->accepting = 0;
   kwset->trie->links = NULL;
   kwset->trie->parent = NULL;
@@ -122,19 +115,17 @@ kwsalloc (char const *trans)
   kwset->target = NULL;
   kwset->trans = trans;
 
-  return (kwset_t) kwset;
+  return kwset;
 }
 
 /* This upper bound is valid for CHAR_BIT >= 4 and
    exact for CHAR_BIT in { 4..11, 13, 15, 17, 19 }. */
 #define DEPTH_SIZE (CHAR_BIT + CHAR_BIT/2)
 
-/* Add the given string to the contents of the keyword set.  Return NULL
-   for success, an error message otherwise. */
-const char *
-kwsincr (kwset_t kws, char const *text, size_t len)
+/* Add the given string to the contents of the keyword set.  */
+void
+kwsincr (kwset_t kwset, char const *text, size_t len)
 {
-  struct kwset *kwset = kws;
   struct trie *trie = kwset->trie;
   char const *trans = kwset->trans;
 
@@ -171,19 +162,10 @@ kwsincr (kwset_t kws, char const *text, size_t len)
          a link in the current trie node's tree. */
       if (!link)
         {
-          link = (struct tree *) obstack_alloc(&kwset->obstack,
-                                               sizeof (struct tree));
-          if (!link)
-            return _("memory exhausted");
+          link = obstack_alloc (&kwset->obstack, sizeof *link);
           link->llink = NULL;
           link->rlink = NULL;
-          link->trie = (struct trie *) obstack_alloc(&kwset->obstack,
-                                                     sizeof (struct trie));
-          if (!link->trie)
-            {
-              obstack_free(&kwset->obstack, link);
-              return _("memory exhausted");
-            }
+          link->trie = obstack_alloc (&kwset->obstack, sizeof *link->trie);
           link->trie->accepting = 0;
           link->trie->links = NULL;
           link->trie->parent = trie;
@@ -283,8 +265,6 @@ kwsincr (kwset_t kws, char const *text, size_t len)
     kwset->mind = trie->depth;
   if (trie->depth > kwset->maxd)
     kwset->maxd = trie->depth;
-
-  return NULL;
 }
 
 /* Enqueue the trie nodes referenced from the given tree in the
@@ -382,10 +362,9 @@ treenext (struct tree const *tree, struct trie *next[])
 
 /* Compute the shift for each trie node, as well as the delta
    table and next cache for the given keyword set. */
-const char *
-kwsprep (kwset_t kws)
+void
+kwsprep (kwset_t kwset)
 {
-  struct kwset *kwset = kws;
   char const *trans = kwset->trans;
   int i;
   unsigned char deltabuf[NCHAR];
@@ -458,9 +437,7 @@ kwsprep (kwset_t kws)
   if (!trans && kwset->words == 1)
     {
       /* Looking for just one string.  Extract it from the trie. */
-      kwset->target = obstack_alloc(&kwset->obstack, kwset->mind);
-      if (!kwset->target)
-        return _("memory exhausted");
+      kwset->target = obstack_alloc (&kwset->obstack, kwset->mind);
       for (i = kwset->mind - 1, curr = kwset->trie; i >= 0; --i)
         {
           kwset->target[i] = curr->links->label;
@@ -473,8 +450,6 @@ kwsprep (kwset_t kws)
           kwset->shift
             = obstack_alloc (&kwset->obstack,
                              sizeof *kwset->shift * (kwset->mind - 1));
-          if (!kwset->shift)
-            return _("memory exhausted");
           for (i = 0, curr = kwset->trie->next; i < kwset->mind - 1; ++i)
             {
               kwset->shift[i] = curr->shift;
@@ -487,22 +462,17 @@ kwsprep (kwset_t kws)
   if (trans)
     for (i = 0; i < NCHAR; ++i)
       kwset->delta[i] = delta[U(trans[i])];
-
-  return NULL;
 }
 
 /* Fast boyer-moore search. */
 static size_t _GL_ATTRIBUTE_PURE
-bmexec (kwset_t kws, char const *text, size_t size)
+bmexec (kwset_t kwset, char const *text, size_t size)
 {
-  struct kwset const *kwset;
   unsigned char const *d1;
   char const *ep, *sp, *tp;
-  int d, i, len, skip;
+  int d, i, skip;
   char gc1, gc2;
-
-  kwset = (struct kwset const *) kws;
-  len = kwset->mind;
+  int len = kwset->mind;
 
   if (len == 0)
     return 0;
@@ -619,9 +589,8 @@ bmexec (kwset_t kws, char const *text, size_t size)
 
 /* Hairy multiple string search. */
 static size_t _GL_ARG_NONNULL ((4))
-cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch)
+cwexec (kwset_t kwset, char const *text, size_t len, struct kwsmatch *kwsmatch)
 {
-  struct kwset const *kwset;
   struct trie * const *next;
   struct trie const *trie;
   struct trie const *accept;
@@ -638,7 +607,6 @@ cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch)
 #endif
 
   /* Initialize register copies and look for easy ways out. */
-  kwset = (struct kwset *) kws;
   if (len < kwset->mind)
     return -1;
   next = kwset->next;
@@ -775,18 +743,18 @@ cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch)
   return mch - text;
 }
 
-/* Search TEXT for a match of any member of the keyword set, KWS.
+/* Search TEXT for a match of any member of KWSET.
    Return the offset (into TEXT) of the first byte of the matching substring,
    or (size_t) -1 if no match is found.  Upon a match, store details in
    *KWSMATCH: index of matched keyword, start offset (same as the return
    value), and length.  */
 size_t
-kwsexec (kwset_t kws, char const *text, size_t size, struct kwsmatch *kwsmatch)
+kwsexec (kwset_t kwset, char const *text, size_t size,
+         struct kwsmatch *kwsmatch)
 {
-  struct kwset const *kwset = (struct kwset *) kws;
   if (kwset->words == 1 && kwset->trans == NULL)
     {
-      size_t ret = bmexec (kws, text, size);
+      size_t ret = bmexec (kwset, text, size);
       if (ret != (size_t) -1)
         {
           kwsmatch->index = 0;
@@ -796,16 +764,13 @@ kwsexec (kwset_t kws, char const *text, size_t size, struct kwsmatch *kwsmatch)
       return ret;
     }
   else
-    return cwexec(kws, text, size, kwsmatch);
+    return cwexec (kwset, text, size, kwsmatch);
 }
 
 /* Free the components of the given keyword set. */
 void
-kwsfree (kwset_t kws)
+kwsfree (kwset_t kwset)
 {
-  struct kwset *kwset;
-
-  kwset = (struct kwset *) kws;
-  obstack_free(&kwset->obstack, NULL);
-  free(kws);
+  obstack_free (&kwset->obstack, NULL);
+  free (kwset);
 }
diff --git a/src/kwset.h b/src/kwset.h
index 2d3cdd9..12afb8e 100644
--- a/src/kwset.h
+++ b/src/kwset.h
@@ -21,6 +21,8 @@
    The author may be reached (Email) at the address mike@ai.mit.edu,
    or (US mail) as Mike Haertel c/o Free Software Foundation. */
 
+#include <stddef.h>
+
 struct kwsmatch
 {
   size_t index;			/* Index number of matching keyword. */
@@ -33,20 +35,17 @@ struct kwsmatch
 struct kwset;
 typedef struct kwset *kwset_t;
 
-/* Return an opaque pointer to a newly allocated keyword set, or NULL
-   if enough memory cannot be obtained.  The argument if non-NULL
+/* Return an opaque pointer to a newly allocated keyword set.  A nonnull arg
    specifies a table of character translations to be applied to all
-   pattern and search text. */
+   pattern and search text.  */
 extern kwset_t kwsalloc (char const *);
 
 /* Incrementally extend the keyword set to include the given string.
-   Return NULL for success, or an error message.  Remember an index
-   number for each keyword included in the set. */
-extern const char *kwsincr (kwset_t, char const *, size_t);
+   Remember an index number for each keyword included in the set.  */
+extern void kwsincr (kwset_t, char const *, size_t);
 
-/* When the keyword set has been completely built, prepare it for
-   use.  Return NULL for success, or an error message. */
-extern const char *kwsprep (kwset_t);
+/* When the keyword set has been completely built, prepare it for use.  */
+extern void kwsprep (kwset_t);
 
 /* Search through the given buffer for a member of the keyword set.
    Return a pointer to the leftmost longest match found, or NULL if

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=757381e58d669729510a89c323d4698f9a81f6c0


commit bf34bedae7276c0f5522ad40db55a7c0d23c739d
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Mon Apr 7 19:48:33 2014 -0700

    grep: simplify memory allocation in kwset
    
    * src/kwset.c: Include kwset.h first, to check its prereqs.
    Include xalloc.h, for xmalloc.
    (kwsalloc): Use xmalloc, not malloc, so that the caller need not
    worry about memory allocation failure.
    (kwsalloc, kwsincr, kwsprep): Do not worry about obstack_alloc
    returning NULL, as that's not possible.
    (kwsalloc, kwsincr, kwsprep, bmexec, cwexec, kwsexec, kwsfree):
    Omit unnecessary conversion between struct kwset * and kwset_t.
    (kwsincr, kwsprep): Return void since memory-allocation failure is
    not possible now.  All uses changed.
    * src/kwset.h: Include <stddef.h>, for size_t, so that this
    include file doesn't require other files to be included first.

diff --git a/src/dfasearch.c b/src/dfasearch.c
index adec4e2..44360b6 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -90,7 +90,6 @@ kwsmusts (void)
   struct dfamust const *dm = dfamusts (dfa);
   if (dm)
     {
-      char const *err;
       kwsinit (&kwset);
       /* First, we compile in the substrings known to be exact
          matches.  The kwset matcher will return the index
@@ -100,8 +99,7 @@ kwsmusts (void)
           if (!dm->exact)
             continue;
           ++kwset_exact_matches;
-          if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != NULL)
-            error (EXIT_TROUBLE, 0, "%s", err);
+          kwsincr (kwset, dm->must, strlen (dm->must));
         }
       /* Now, we compile the substrings that will require
          the use of the regexp matcher.  */
@@ -109,11 +107,9 @@ kwsmusts (void)
         {
           if (dm->exact)
             continue;
-          if ((err = kwsincr (kwset, dm->must, strlen (dm->must))) != NULL)
-            error (EXIT_TROUBLE, 0, "%s", err);
+          kwsincr (kwset, dm->must, strlen (dm->must));
         }
-      if ((err = kwsprep (kwset)) != NULL)
-        error (EXIT_TROUBLE, 0, "%s", err);
+      kwsprep (kwset);
     }
 }
 
diff --git a/src/kwsearch.c b/src/kwsearch.c
index dd01518..df94951 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -32,7 +32,6 @@ static kwset_t kwset;
 void
 Fcompile (char const *pattern, size_t size)
 {
-  char const *err;
   size_t psize = size;
   mb_len_map_t *map = NULL;
   char const *pat = (match_icase && MB_CUR_MAX > 1
@@ -65,14 +64,12 @@ Fcompile (char const *pattern, size_t size)
 #endif
         }
 
-      if ((err = kwsincr (kwset, beg, end - beg)) != NULL)
-        error (EXIT_TROUBLE, 0, "%s", err);
+      kwsincr (kwset, beg, end - beg);
       beg = lim;
     }
   while (beg < pat + psize);
 
-  if ((err = kwsprep (kwset)) != NULL)
-    error (EXIT_TROUBLE, 0, "%s", err);
+  kwsprep (kwset);
 }
 
 /* Apply the MAP (created by mbtoupper) to the uppercase-buffer-relative
diff --git a/src/kwset.c b/src/kwset.c
index 6c07249..d5db12f 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -32,11 +32,14 @@
    failure function used below. */
 
 #include <config.h>
+
+#include "kwset.h"
+
 #include <stdbool.h>
 #include <sys/types.h>
 #include "system.h"
-#include "kwset.h"
 #include "obstack.h"
+#include "xalloc.h"
 
 #define link kwset_link
 
@@ -91,25 +94,15 @@ struct kwset
 };
 
 /* Allocate and initialize a keyword set object, returning an opaque
-   pointer to it.  Return NULL if memory is not available. */
+   pointer to it.  */
 kwset_t
 kwsalloc (char const *trans)
 {
-  struct kwset *kwset;
+  struct kwset *kwset = xmalloc (sizeof *kwset);
 
-  kwset = (struct kwset *) malloc(sizeof (struct kwset));
-  if (!kwset)
-    return NULL;
-
-  obstack_init(&kwset->obstack);
+  obstack_init (&kwset->obstack);
   kwset->words = 0;
-  kwset->trie
-    = (struct trie *) obstack_alloc(&kwset->obstack, sizeof (struct trie));
-  if (!kwset->trie)
-    {
-      kwsfree((kwset_t) kwset);
-      return NULL;
-    }
+  kwset->trie = obstack_alloc (&kwset->obstack, sizeof *kwset->trie);
   kwset->trie->accepting = 0;
   kwset->trie->links = NULL;
   kwset->trie->parent = NULL;
@@ -122,19 +115,17 @@ kwsalloc (char const *trans)
   kwset->target = NULL;
   kwset->trans = trans;
 
-  return (kwset_t) kwset;
+  return kwset;
 }
 
 /* This upper bound is valid for CHAR_BIT >= 4 and
    exact for CHAR_BIT in { 4..11, 13, 15, 17, 19 }. */
 #define DEPTH_SIZE (CHAR_BIT + CHAR_BIT/2)
 
-/* Add the given string to the contents of the keyword set.  Return NULL
-   for success, an error message otherwise. */
-const char *
-kwsincr (kwset_t kws, char const *text, size_t len)
+/* Add the given string to the contents of the keyword set.  */
+void
+kwsincr (kwset_t kwset, char const *text, size_t len)
 {
-  struct kwset *kwset = kws;
   struct trie *trie = kwset->trie;
   char const *trans = kwset->trans;
 
@@ -171,19 +162,10 @@ kwsincr (kwset_t kws, char const *text, size_t len)
          a link in the current trie node's tree. */
       if (!link)
         {
-          link = (struct tree *) obstack_alloc(&kwset->obstack,
-                                               sizeof (struct tree));
-          if (!link)
-            return _("memory exhausted");
+          link = obstack_alloc (&kwset->obstack, sizeof *link);
           link->llink = NULL;
           link->rlink = NULL;
-          link->trie = (struct trie *) obstack_alloc(&kwset->obstack,
-                                                     sizeof (struct trie));
-          if (!link->trie)
-            {
-              obstack_free(&kwset->obstack, link);
-              return _("memory exhausted");
-            }
+          link->trie = obstack_alloc (&kwset->obstack, sizeof *link->trie);
           link->trie->accepting = 0;
           link->trie->links = NULL;
           link->trie->parent = trie;
@@ -283,8 +265,6 @@ kwsincr (kwset_t kws, char const *text, size_t len)
     kwset->mind = trie->depth;
   if (trie->depth > kwset->maxd)
     kwset->maxd = trie->depth;
-
-  return NULL;
 }
 
 /* Enqueue the trie nodes referenced from the given tree in the
@@ -382,10 +362,9 @@ treenext (struct tree const *tree, struct trie *next[])
 
 /* Compute the shift for each trie node, as well as the delta
    table and next cache for the given keyword set. */
-const char *
-kwsprep (kwset_t kws)
+void
+kwsprep (kwset_t kwset)
 {
-  struct kwset *kwset = kws;
   char const *trans = kwset->trans;
   int i;
   unsigned char deltabuf[NCHAR];
@@ -458,9 +437,7 @@ kwsprep (kwset_t kws)
   if (!trans && kwset->words == 1)
     {
       /* Looking for just one string.  Extract it from the trie. */
-      kwset->target = obstack_alloc(&kwset->obstack, kwset->mind);
-      if (!kwset->target)
-        return _("memory exhausted");
+      kwset->target = obstack_alloc (&kwset->obstack, kwset->mind);
       for (i = kwset->mind - 1, curr = kwset->trie; i >= 0; --i)
         {
           kwset->target[i] = curr->links->label;
@@ -473,8 +450,6 @@ kwsprep (kwset_t kws)
           kwset->shift
             = obstack_alloc (&kwset->obstack,
                              sizeof *kwset->shift * (kwset->mind - 1));
-          if (!kwset->shift)
-            return _("memory exhausted");
           for (i = 0, curr = kwset->trie->next; i < kwset->mind - 1; ++i)
             {
               kwset->shift[i] = curr->shift;
@@ -487,22 +462,17 @@ kwsprep (kwset_t kws)
   if (trans)
     for (i = 0; i < NCHAR; ++i)
       kwset->delta[i] = delta[U(trans[i])];
-
-  return NULL;
 }
 
 /* Fast boyer-moore search. */
 static size_t _GL_ATTRIBUTE_PURE
-bmexec (kwset_t kws, char const *text, size_t size)
+bmexec (kwset_t kwset, char const *text, size_t size)
 {
-  struct kwset const *kwset;
   unsigned char const *d1;
   char const *ep, *sp, *tp;
-  int d, i, len, skip;
+  int d, i, skip;
   char gc1, gc2;
-
-  kwset = (struct kwset const *) kws;
-  len = kwset->mind;
+  int len = kwset->mind;
 
   if (len == 0)
     return 0;
@@ -619,9 +589,8 @@ bmexec (kwset_t kws, char const *text, size_t size)
 
 /* Hairy multiple string search. */
 static size_t _GL_ARG_NONNULL ((4))
-cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch)
+cwexec (kwset_t kwset, char const *text, size_t len, struct kwsmatch *kwsmatch)
 {
-  struct kwset const *kwset;
   struct trie * const *next;
   struct trie const *trie;
   struct trie const *accept;
@@ -638,7 +607,6 @@ cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch)
 #endif
 
   /* Initialize register copies and look for easy ways out. */
-  kwset = (struct kwset *) kws;
   if (len < kwset->mind)
     return -1;
   next = kwset->next;
@@ -775,18 +743,18 @@ cwexec (kwset_t kws, char const *text, size_t len, struct kwsmatch *kwsmatch)
   return mch - text;
 }
 
-/* Search TEXT for a match of any member of the keyword set, KWS.
+/* Search TEXT for a match of any member of KWSET.
    Return the offset (into TEXT) of the first byte of the matching substring,
    or (size_t) -1 if no match is found.  Upon a match, store details in
    *KWSMATCH: index of matched keyword, start offset (same as the return
    value), and length.  */
 size_t
-kwsexec (kwset_t kws, char const *text, size_t size, struct kwsmatch *kwsmatch)
+kwsexec (kwset_t kwset, char const *text, size_t size,
+         struct kwsmatch *kwsmatch)
 {
-  struct kwset const *kwset = (struct kwset *) kws;
   if (kwset->words == 1 && kwset->trans == NULL)
     {
-      size_t ret = bmexec (kws, text, size);
+      size_t ret = bmexec (kwset, text, size);
       if (ret != (size_t) -1)
         {
           kwsmatch->index = 0;
@@ -796,16 +764,13 @@ kwsexec (kwset_t kws, char const *text, size_t size, struct kwsmatch *kwsmatch)
       return ret;
     }
   else
-    return cwexec(kws, text, size, kwsmatch);
+    return cwexec (kwset, text, size, kwsmatch);
 }
 
 /* Free the components of the given keyword set. */
 void
-kwsfree (kwset_t kws)
+kwsfree (kwset_t kwset)
 {
-  struct kwset *kwset;
-
-  kwset = (struct kwset *) kws;
-  obstack_free(&kwset->obstack, NULL);
-  free(kws);
+  obstack_free (&kwset->obstack, NULL);
+  free (kwset);
 }
diff --git a/src/kwset.h b/src/kwset.h
index 2d3cdd9..12afb8e 100644
--- a/src/kwset.h
+++ b/src/kwset.h
@@ -21,6 +21,8 @@
    The author may be reached (Email) at the address mike@ai.mit.edu,
    or (US mail) as Mike Haertel c/o Free Software Foundation. */
 
+#include <stddef.h>
+
 struct kwsmatch
 {
   size_t index;			/* Index number of matching keyword. */
@@ -33,20 +35,17 @@ struct kwsmatch
 struct kwset;
 typedef struct kwset *kwset_t;
 
-/* Return an opaque pointer to a newly allocated keyword set, or NULL
-   if enough memory cannot be obtained.  The argument if non-NULL
+/* Return an opaque pointer to a newly allocated keyword set.  A nonnull arg
    specifies a table of character translations to be applied to all
-   pattern and search text. */
+   pattern and search text.  */
 extern kwset_t kwsalloc (char const *);
 
 /* Incrementally extend the keyword set to include the given string.
-   Return NULL for success, or an error message.  Remember an index
-   number for each keyword included in the set. */
-extern const char *kwsincr (kwset_t, char const *, size_t);
+   Remember an index number for each keyword included in the set.  */
+extern void kwsincr (kwset_t, char const *, size_t);
 
-/* When the keyword set has been completely built, prepare it for
-   use.  Return NULL for success, or an error message. */
-extern const char *kwsprep (kwset_t);
+/* When the keyword set has been completely built, prepare it for use.  */
+extern void kwsprep (kwset_t);
 
 /* Search through the given buffer for a member of the keyword set.
    Return a pointer to the leftmost longest match found, or NULL if

-----------------------------------------------------------------------

Summary of changes:
 src/dfasearch.c |   10 +-
 src/kwsearch.c  |    7 +-
 src/kwset.c     |  356 ++++++++++++++++++++++++++++---------------------------
 src/kwset.h     |   17 ++--
 4 files changed, 192 insertions(+), 198 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Mon Apr 07 23:29:26 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WXMj0-0002lB-Ek
	for mharc-grep-commit@gnu.org; Mon, 07 Apr 2014 23:29:26 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:39494)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXMix-0002l1-HL
	for grep-commit@gnu.org; Mon, 07 Apr 2014 23:29:25 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXMis-0003gA-T5
	for grep-commit@gnu.org; Mon, 07 Apr 2014 23:29:23 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:33851)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXMis-0003fy-Pm
	for grep-commit@gnu.org; Mon, 07 Apr 2014 23:29:18 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXMis-0001TA-DB
	for grep-commit@gnu.org; Tue, 08 Apr 2014 03:29:18 +0000
Date: Tue, 08 Apr 2014 03:29:18 +0000
Message-Id: <E1WXMis-0001TA-DB@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-53-ge9cf5ae
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: bf34bedae7276c0f5522ad40db55a7c0d23c739d
X-Git-Newrev: e9cf5ae927a462ac0b224668b39e0a778e2661c5
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 08 Apr 2014 03:29:25 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  e9cf5ae927a462ac0b224668b39e0a778e2661c5 (commit)
      from  bf34bedae7276c0f5522ad40db55a7c0d23c739d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=e9cf5ae927a462ac0b224668b39e0a778e2661c5


commit e9cf5ae927a462ac0b224668b39e0a778e2661c5
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Mon Apr 7 20:28:26 2014 -0700

    grep: remove trival_case_ignore
    
    This optimization is no longer needed, given the other
    optimizations recently installed.  Derived from a patch by
    Norihiro Tanaka; see <http://bugs.gnu.org/17019>.
    * bootstrap.conf (gnulib_modules): Remove assert-h.
    * src/dfa.c (CASE_FOLDED_BUFSIZE): Move here from dfa.h.
    Remove now-unnecessary static assert.
    (case_folded_counterparts): Now static.
    * src/dfa.h (CASE_FOLDED_BUFSIZE, case_folded_counterparts):
    Remove decls; no longer public.
    * src/dfasearch.c (kwsmusts): Use kwset even if fill MB_CUR_MAX > 1
    and case-insensitive.
    * src/grep.c (MBRTOWC, WCRTOMB): Remove.
    (fgrep_to_grep_pattern): Use mbrtowc, not MBRTOWC.
    (trivial_case_ignore): Remove; this optimization is no longer needed.
    All uses removed.

diff --git a/bootstrap.conf b/bootstrap.conf
index 86cd81d..367427d 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -24,7 +24,6 @@ gnulib_modules='
 alloca
 announce-gen
 argmatch
-assert-h
 binary-io
 btowc
 c-ctype
diff --git a/src/dfa.c b/src/dfa.c
index b6c1250..d8744d7 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -933,14 +933,17 @@ static short const lonesome_lower[] =
     0x03F5, 0x1E9B, 0x1FBE,
   };
 
-static_assert ((sizeof lonesome_lower / sizeof *lonesome_lower + 2
-                == CASE_FOLDED_BUFSIZE),
-               "CASE_FOLDED_BUFSIZE is wrong");
+/* Maximum number of characters that can be the case-folded
+   counterparts of a single character, not counting the character
+   itself.  This is 1 for towupper, 1 for towlower, and 1 for each
+   entry in LONESOME_LOWER.  */
+enum
+{ CASE_FOLDED_BUFSIZE = 2 + sizeof lonesome_lower / sizeof *lonesome_lower };
 
 /* Find the characters equal to C after case-folding, other than C
    itself, and store them into FOLDED.  Return the number of characters
    stored.  */
-int
+static int
 case_folded_counterparts (wchar_t c, wchar_t folded[CASE_FOLDED_BUFSIZE])
 {
   int i;
diff --git a/src/dfa.h b/src/dfa.h
index 6ed2231..db29a62 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -112,11 +112,3 @@ extern void dfawarn (const char *);
 extern _Noreturn void dfaerror (const char *);
 
 extern int using_utf8 (void);
-
-/* Maximum number of characters that can be the case-folded
-   counterparts of a single character, not counting the character
-   itself.  This is 1 for towupper, 1 for towlower, and 1 for each
-   entry in LONESOME_LOWER; see dfa.c.  */
-enum { CASE_FOLDED_BUFSIZE = 1 + 1 + 19 };
-
-extern int case_folded_counterparts (wchar_t, wchar_t[CASE_FOLDED_BUFSIZE]);
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 44360b6..2ae0a4a 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -81,12 +81,6 @@ dfawarn (char const *mesg)
 static void
 kwsmusts (void)
 {
-  /* With case-insensitive matching in a multi-byte locale, do not
-     use kwsearch, because in that case, it would be too expensive,
-     requiring that we case-convert all searched input.  */
-  if (MB_CUR_MAX > 1 && match_icase)
-    return;
-
   struct dfamust const *dm = dfamusts (dfa);
   if (dm)
     {
diff --git a/src/grep.c b/src/grep.c
index 7033730..8bd6c49 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -1894,15 +1894,6 @@ parse_grep_colors (void)
       return;
 }
 
-#define MBRTOWC(pwc, s, n, ps) \
-  (MB_CUR_MAX == 1 \
-   ? (*(pwc) = btowc (*(unsigned char *) (s)), 1) \
-   : mbrtowc (pwc, s, n, ps))
-#define WCRTOMB(s, wc, ps) \
-  (MB_CUR_MAX == 1 \
-   ? (*(s) = wctob ((wint_t) (wc)), 1) \
-   : wcrtomb (s, wc, ps))
-
 /* Change a pattern for fgrep into grep.  */
 static void
 fgrep_to_grep_pattern (size_t len, char const *keys,
@@ -1915,7 +1906,7 @@ fgrep_to_grep_pattern (size_t len, char const *keys,
   for (; len; keys += n, len -= n)
     {
       wchar_t wc;
-      n = MBRTOWC (&wc, keys, len, &mb_state);
+      n = mbrtowc (&wc, keys, len, &mb_state);
       switch (n)
         {
         case (size_t) -2:
@@ -1942,86 +1933,6 @@ fgrep_to_grep_pattern (size_t len, char const *keys,
   *new_len = p - *new_keys;
 }
 
-/* If the newline-separated regular expressions, KEYS (with length, LEN
-   and no trailing NUL byte), are amenable to transformation into
-   otherwise equivalent case-ignoring ones, perform the transformation,
-   put the result into malloc'd memory, *NEW_KEYS with length *NEW_LEN,
-   and return true.  Otherwise, return false.  */
-
-static bool
-trivial_case_ignore (size_t len, char const *keys,
-                     size_t *new_len, char **new_keys)
-{
-  /* FIXME: consider removing the following restriction:
-     Reject if KEYS contain ASCII '\\' or '['.  */
-  if (memchr (keys, '\\', len) || memchr (keys, '[', len))
-    return false;
-
-  /* Worst case is that each byte B of KEYS is ASCII alphabetic and
-     CASE_FOLDED_BUFSIZE other_case(B) characters, C through Z, each
-     occupying MB_CUR_MAX bytes, so each B maps to [BC...Z], which
-     requires CASE_FOLDED_BUFSIZE * MB_CUR_MAX + 3 bytes; this is
-     bounded above by the constant expression CASE_FOLDED_BUFSIZE *
-     MB_LEN_MAX + 3.  */
-  *new_keys = xnmalloc (len + 1, CASE_FOLDED_BUFSIZE * MB_LEN_MAX + 3);
-  char *p = *new_keys;
-
-  mbstate_t mb_state = { 0 };
-  while (len)
-    {
-      bool initial_state = mbsinit (&mb_state) != 0;
-      wchar_t wc;
-      size_t n = MBRTOWC (&wc, keys, len, &mb_state);
-
-      /* For an invalid, incomplete or L'\0', skip this optimization.  */
-      if ((size_t) -2 <= n)
-        {
-        skip_case_ignore_optimization:
-          free (*new_keys);
-          return false;
-        }
-
-      char const *orig = keys;
-      keys += n;
-      len -= n;
-
-      wchar_t folded[CASE_FOLDED_BUFSIZE];
-      int nfolded = case_folded_counterparts (wc, folded);
-      if (nfolded <= 0)
-        {
-          memcpy (p, orig, n);
-          p += n;
-        }
-      else if (! initial_state)
-        goto skip_case_ignore_optimization;
-      else
-        {
-          *p++ = '[';
-          memcpy (p, orig, n);
-          p += n;
-
-          int i = 0;
-          do
-            {
-              size_t nbytes = WCRTOMB (p, folded[i], &mb_state);
-              if (nbytes == (size_t) -1)
-                goto skip_case_ignore_optimization;
-              p += nbytes;
-            }
-          while (++i < nfolded);
-
-          if (! mbsinit (&mb_state))
-            goto skip_case_ignore_optimization;
-
-          *p++ = ']';
-        }
-    }
-
-  *new_len = p - *new_keys;
-
-  return true;
-}
-
 int
 main (int argc, char **argv)
 {
@@ -2432,34 +2343,6 @@ main (int argc, char **argv)
       execute = EGexecute;
     }
 
-  /* Case-insensitive matching is expensive in multibyte locales
-     because a few characters may change size when converted to upper
-     or lower case.  To accommodate those, search the input one line
-     at a time, rather than using the much more efficient buffer search.
-
-     Try to convert a regular expression 'foo' (ignoring case) to an
-     equivalent regular expression '[fF][oO][oO]' (where case matters).
-     Not only does this avoid the expensive requirement to read and
-     process a line at a time, it also allows use of the kwset engine,
-     a win in non-UTF-8 multibyte locales.  */
-  if (match_icase)
-    {
-      size_t new_keycc;
-      char *new_keys;
-      /* It is not possible with -F, not useful with -P (pcre) and there is no
-         point when there is no regexp.  It also depends on which constructs
-         appear in the regexp.  See trivial_case_ignore for those details.  */
-      if (keycc
-          && ! (compile == Fcompile || compile == Pcompile)
-          && trivial_case_ignore (keycc, keys, &new_keycc, &new_keys))
-        {
-          match_icase = 0;
-          free (keys);
-          keys = new_keys;
-          keycc = new_keycc;
-        }
-    }
-
   if (MB_CUR_MAX > 1)
     build_mbclen_cache ();
 

-----------------------------------------------------------------------

Summary of changes:
 bootstrap.conf  |    1 -
 src/dfa.c       |   11 +++--
 src/dfa.h       |    8 ----
 src/dfasearch.c |    6 ---
 src/grep.c      |  119 +------------------------------------------------------
 5 files changed, 8 insertions(+), 137 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Tue Apr 08 00:07:52 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WXNKC-0001aw-UM
	for mharc-grep-commit@gnu.org; Tue, 08 Apr 2014 00:07:52 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:44951)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXNK4-0001Zh-HX
	for grep-commit@gnu.org; Tue, 08 Apr 2014 00:07:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXNK3-0007eF-1L
	for grep-commit@gnu.org; Tue, 08 Apr 2014 00:07:44 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:34114)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXNK2-0007eA-UX
	for grep-commit@gnu.org; Tue, 08 Apr 2014 00:07:42 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXNK2-0004JD-Ek
	for grep-commit@gnu.org; Tue, 08 Apr 2014 04:07:42 +0000
Date: Tue, 08 Apr 2014 04:07:42 +0000
Message-Id: <E1WXNK2-0004JD-Ek@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-54-g3ef4c8e
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: e9cf5ae927a462ac0b224668b39e0a778e2661c5
X-Git-Newrev: 3ef4c8ee04951b34a5fbbe6d6e3287a3182f6059
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 08 Apr 2014 04:07:46 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  3ef4c8ee04951b34a5fbbe6d6e3287a3182f6059 (commit)
      from  e9cf5ae927a462ac0b224668b39e0a778e2661c5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=3ef4c8ee04951b34a5fbbe6d6e3287a3182f6059


commit 3ef4c8ee04951b34a5fbbe6d6e3287a3182f6059
Author: Norihiro Tanaka <noritnk@kcn.ne.jp>
Date:   Tue Apr 1 23:48:16 2014 +0900

    grep: prefer regex to DFA for ANYCHAR in multibyte locales
    
    * src/dfa.c (dfa_state): New member has_mbcset.
    Rename backref to has_backref, and make it of type bool too.
    All uses changed.
    (state_index, dfastate): Initialize new member.
    (dfaexec): Prefer regex to DFA for ANYCHAR in multibyte locales.

diff --git a/src/dfa.c b/src/dfa.c
index d8744d7..7bab84d 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -288,7 +288,8 @@ typedef struct
   size_t hash;                  /* Hash of the positions of this state.  */
   position_set elems;           /* Positions this state could match.  */
   unsigned char context;        /* Context from previous state.  */
-  char backref;                 /* True if this state matches a \<digit>.  */
+  bool has_backref;             /* True if this state matches a \<digit>.  */
+  bool has_mbcset;              /* True if this state matches a MBCSET.  */
   unsigned short constraint;    /* Constraint for this state to accept.  */
   token first_end;              /* Token value of the first END in elems.  */
   position_set mbps;            /* Positions which can match multibyte
@@ -2128,7 +2129,8 @@ state_index (struct dfa *d, position_set const *s, int context)
   alloc_position_set (&d->states[i].elems, s->nelem);
   copy (s, &d->states[i].elems);
   d->states[i].context = context;
-  d->states[i].backref = 0;
+  d->states[i].has_backref = false;
+  d->states[i].has_mbcset = false;
   d->states[i].constraint = 0;
   d->states[i].first_end = 0;
   d->states[i].mbps.nelem = 0;
@@ -2146,7 +2148,7 @@ state_index (struct dfa *d, position_set const *s, int context)
     else if (d->tokens[s->elems[j].index] == BACKREF)
       {
         d->states[i].constraint = NO_CONSTRAINT;
-        d->states[i].backref = 1;
+        d->states[i].has_backref = true;
       }
 
   ++d->sindex;
@@ -2609,6 +2611,7 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
           if (d->states[s].mbps.nelem == 0)
             alloc_position_set (&d->states[s].mbps, 1);
           insert (pos, &(d->states[s].mbps));
+          d->states[s].has_mbcset |= (d->tokens[pos.index] == MBCSET);
           continue;
         }
       else
@@ -3413,7 +3416,7 @@ dfaexec (struct dfa *d, char const *begin, char *end,
                  better performance (up to 25% better on [a-z], for
                  example) and enables support for collating symbols and
                  equivalence classes.  */
-              if (backref)
+              if (d->states[s].has_mbcset && backref)
                 {
                   *backref = 1;
                   *end = saved_end;
@@ -3447,7 +3450,7 @@ dfaexec (struct dfa *d, char const *begin, char *end,
           if (d->success[s] & sbit[*p])
             {
               if (backref)
-                *backref = (d->states[s].backref != 0);
+                *backref = d->states[s].has_backref;
               *end = saved_end;
               return (char *) p;
             }

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Tue Apr 08 02:08:36 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WXPD2-0003jT-MS
	for mharc-grep-commit@gnu.org; Tue, 08 Apr 2014 02:08:36 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34403)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXPCy-0003in-MZ
	for grep-commit@gnu.org; Tue, 08 Apr 2014 02:08:34 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXPCw-0005LH-KJ
	for grep-commit@gnu.org; Tue, 08 Apr 2014 02:08:32 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:35120)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXPCw-0005L9-Gr
	for grep-commit@gnu.org; Tue, 08 Apr 2014 02:08:30 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXPCv-0004c8-Qs
	for grep-commit@gnu.org; Tue, 08 Apr 2014 06:08:29 +0000
Date: Tue, 08 Apr 2014 06:08:29 +0000
Message-Id: <E1WXPCv-0004c8-Qs@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-55-g359012d
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 3ef4c8ee04951b34a5fbbe6d6e3287a3182f6059
X-Git-Newrev: 359012dab9476c8accd3629a8991418a09233b3f
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 08 Apr 2014 06:08:34 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  359012dab9476c8accd3629a8991418a09233b3f (commit)
      from  3ef4c8ee04951b34a5fbbe6d6e3287a3182f6059 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=359012dab9476c8accd3629a8991418a09233b3f


commit 359012dab9476c8accd3629a8991418a09233b3f
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Mon Apr 7 23:06:45 2014 -0700

    grep: prefer bool in DFA internals
    
    * src/dfa.c (bool_bf): New type.
    (dfa_state): Use it, as this seems to generate slightly better
    code with GCC.
    (struct mb_char_classes, struct dfa, equal, case_fold, dfasyntax)
    (laststart, parse_bracket_exp, lex, dfaparse, dfaanalyze, dfastate)
    (match_mb_charset, dfamust):
    Use bool for boolean.
    (using_utf8) [!HAVE_LANGINFO_CODESET]: Tune.
    (dfaanalyze): Prefer & to && and | to || on booleans; it's simpler here.
    (dfastate): Simplify charclass nonzero testing.  Redo has_mbcset
    test so that the compiler's more likely to optimize it.

diff --git a/src/dfa.c b/src/dfa.c
index 7bab84d..76f7e79 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -34,6 +34,13 @@
 #include <locale.h>
 #include <stdbool.h>
 
+/* The pre-C99 <stdbool.h> emulation doesn't work for bool bitfields.  */
+#if __STDC_VERSION__ < 199901
+typedef unsigned int bool_bf;
+#else
+typedef bool bool_bf;
+#endif
+
 #define STREQ(a, b) (strcmp (a, b) == 0)
 
 /* ISASCIIDIGIT differs from isdigit, as follows:
@@ -288,8 +295,8 @@ typedef struct
   size_t hash;                  /* Hash of the positions of this state.  */
   position_set elems;           /* Positions this state could match.  */
   unsigned char context;        /* Context from previous state.  */
-  bool has_backref;             /* True if this state matches a \<digit>.  */
-  bool has_mbcset;              /* True if this state matches a MBCSET.  */
+  bool_bf has_backref : 1;      /* True if this state matches a \<digit>.  */
+  bool_bf has_mbcset : 1;       /* True if this state matches a MBCSET.  */
   unsigned short constraint;    /* Constraint for this state to accept.  */
   token first_end;              /* Token value of the first END in elems.  */
   position_set mbps;            /* Positions which can match multibyte
@@ -306,7 +313,7 @@ typedef ptrdiff_t state_num;
 struct mb_char_classes
 {
   ptrdiff_t cset;
-  int invert;
+  bool invert;
   wchar_t *chars;               /* Normal characters.  */
   size_t nchars;
   wctype_t *ch_classes;         /* Character classes.  */
@@ -390,7 +397,7 @@ struct dfa
                                    matching the given position in a string
                                    matching the regexp.  Allocated to the
                                    maximum possible position index.  */
-  int searchflag;               /* True if we are supposed to build a searching
+  bool searchflag;              /* True if we are supposed to build a searching
                                    as opposed to an exact matcher.  A searching
                                    matcher finds the first and shortest string
                                    matching a regexp anywhere in the buffer,
@@ -669,7 +676,7 @@ notset (charclass s)
     s[i] = ~s[i];
 }
 
-static int
+static bool
 equal (charclass const s1, charclass const s2)
 {
   return memcmp (s1, s2, sizeof (charclass)) == 0;
@@ -704,7 +711,7 @@ charclass_index (charclass const s)
 static reg_syntax_t syntax_bits, syntax_bits_set;
 
 /* Flag for case-folding letters into sets.  */
-static int case_fold;
+static bool case_fold;
 
 /* End-of-line byte in data.  */
 static unsigned char eolbyte;
@@ -759,7 +766,7 @@ dfasyntax (reg_syntax_t bits, int fold, unsigned char eol)
 
   syntax_bits_set = 1;
   syntax_bits = bits;
-  case_fold = fold;
+  case_fold = fold != 0;
   eolbyte = eol;
 
   for (i = 0; i < NOTCHAR; ++i)
@@ -812,17 +819,14 @@ setbit_case_fold_c (int b, charclass c)
 int
 using_utf8 (void)
 {
+#ifdef HAVE_LANGINFO_CODESET
   static int utf8 = -1;
-  if (utf8 == -1)
-    {
-#if defined HAVE_LANGINFO_CODESET
-      utf8 = (STREQ (nl_langinfo (CODESET), "UTF-8"));
+  if (utf8 < 0)
+    utf8 = STREQ (nl_langinfo (CODESET), "UTF-8");
+  return utf8;
 #else
-      utf8 = 0;
+  return 0;
 #endif
-    }
-
-  return utf8;
 }
 
 /* Return true if the current locale is known to be a unibyte locale
@@ -873,7 +877,7 @@ using_simple_locale (void)
 static char const *lexptr;      /* Pointer to next input character.  */
 static size_t lexleft;          /* Number of characters remaining.  */
 static token lasttok;           /* Previous token returned; initially END.  */
-static int laststart;           /* True if we're separated from beginning or (,
+static bool laststart;          /* True if we're separated from beginning or (,
                                    | only by zero-width characters.  */
 static size_t parens;           /* Count of outstanding left parens.  */
 static int minrep, maxrep;      /* Repeat counts for {m,n}.  */
@@ -1009,7 +1013,7 @@ find_pred (const char *str)
 static token
 parse_bracket_exp (void)
 {
-  int invert;
+  bool invert;
   int c, c1, c2;
   charclass ccl;
 
@@ -1057,11 +1061,11 @@ parse_bracket_exp (void)
   if (c == '^')
     {
       FETCH_WC (c, wc, _("unbalanced ["));
-      invert = 1;
+      invert = true;
       known_bracket_exp = using_simple_locale ();
     }
   else
-    invert = 0;
+    invert = false;
 
   colon_warning_state = (c == ':');
   do
@@ -1279,7 +1283,7 @@ static token
 lex (void)
 {
   unsigned int c, c2;
-  int backslash = 0;
+  bool backslash = false;
   charclass ccl;
   int i;
 
@@ -1302,7 +1306,7 @@ lex (void)
             goto normal_char;
           if (lexleft == 0)
             dfaerror (_("unfinished \\ escape"));
-          backslash = 1;
+          backslash = true;
           break;
 
         case '^':
@@ -1340,7 +1344,7 @@ lex (void)
         case '9':
           if (backslash && !(syntax_bits & RE_NO_BK_REFS))
             {
-              laststart = 0;
+              laststart = false;
               return lasttok = BACKREF;
             }
           goto normal_char;
@@ -1455,7 +1459,7 @@ lex (void)
             lexptr = p;
             lexleft = lim - p;
           }
-          laststart = 0;
+          laststart = false;
           return lasttok = REPMN;
 
         case '|':
@@ -1463,21 +1467,21 @@ lex (void)
             goto normal_char;
           if (backslash != ((syntax_bits & RE_NO_BK_VBAR) == 0))
             goto normal_char;
-          laststart = 1;
+          laststart = true;
           return lasttok = OR;
 
         case '\n':
           if (syntax_bits & RE_LIMITED_OPS
               || backslash || !(syntax_bits & RE_NEWLINE_ALT))
             goto normal_char;
-          laststart = 1;
+          laststart = true;
           return lasttok = OR;
 
         case '(':
           if (backslash != ((syntax_bits & RE_NO_BK_PARENS) == 0))
             goto normal_char;
           ++parens;
-          laststart = 1;
+          laststart = true;
           return lasttok = LPAREN;
 
         case ')':
@@ -1486,7 +1490,7 @@ lex (void)
           if (parens == 0 && syntax_bits & RE_UNMATCHED_RIGHT_PAREN_ORD)
             goto normal_char;
           --parens;
-          laststart = 0;
+          laststart = false;
           return lasttok = RPAREN;
 
         case '.':
@@ -1496,7 +1500,7 @@ lex (void)
             {
               /* In multibyte environment period must match with a single
                  character not a byte.  So we use ANYCHAR.  */
-              laststart = 0;
+              laststart = false;
               return lasttok = ANYCHAR;
             }
           zeroset (ccl);
@@ -1505,7 +1509,7 @@ lex (void)
             clrbit (eolbyte, ccl);
           if (syntax_bits & RE_DOT_NOT_NULL)
             clrbit ('\0', ccl);
-          laststart = 0;
+          laststart = false;
           return lasttok = CSET + charclass_index (ccl);
 
         case 's':
@@ -1520,7 +1524,7 @@ lex (void)
                   setbit (c2, ccl);
               if (c == 'S')
                 notset (ccl);
-              laststart = 0;
+              laststart = false;
               return lasttok = CSET + charclass_index (ccl);
             }
 
@@ -1550,7 +1554,7 @@ lex (void)
 
           POP_LEX_STATE ();
 
-          laststart = 0;
+          laststart = false;
           return lasttok;
 
         case 'w':
@@ -1563,18 +1567,18 @@ lex (void)
               setbit (c2, ccl);
           if (c == 'W')
             notset (ccl);
-          laststart = 0;
+          laststart = false;
           return lasttok = CSET + charclass_index (ccl);
 
         case '[':
           if (backslash)
             goto normal_char;
-          laststart = 0;
+          laststart = false;
           return lasttok = parse_bracket_exp ();
 
         default:
         normal_char:
-          laststart = 0;
+          laststart = false;
           /* For multibyte character sets, folding is done in atom.  Always
              return WCHAR.  */
           if (MB_CUR_MAX > 1)
@@ -1977,7 +1981,7 @@ dfaparse (char const *s, size_t len, struct dfa *d)
   lexptr = s;
   lexleft = len;
   lasttok = END;
-  laststart = 1;
+  laststart = true;
   parens = 0;
   if (MB_CUR_MAX > 1)
     {
@@ -2323,7 +2327,7 @@ state_separate_contexts (position_set const *s)
 void
 dfaanalyze (struct dfa *d, int searchflag)
 {
-  int *nullable;                /* Nullable stack.  */
+  bool *nullable;               /* Nullable stack.  */
   size_t *nfirstpos;            /* Element count stack for firstpos sets.  */
   position *firstpos;           /* Array where firstpos elements are stored.  */
   size_t *nlastpos;             /* Element count stack for lastpos sets.  */
@@ -2331,7 +2335,7 @@ dfaanalyze (struct dfa *d, int searchflag)
   position_set tmp;             /* Temporary set for merging sets.  */
   position_set merged;          /* Result of merging sets.  */
   int separate_contexts;        /* Context wanted by some position.  */
-  int *o_nullable;
+  bool *o_nullable;
   size_t *o_nfirst, *o_nlast;
   position *o_firstpos, *o_lastpos;
   size_t i, j;
@@ -2347,7 +2351,7 @@ dfaanalyze (struct dfa *d, int searchflag)
   putc ('\n', stderr);
 #endif
 
-  d->searchflag = searchflag;
+  d->searchflag = searchflag != 0;
 
   MALLOC (nullable, d->depth);
   o_nullable = nullable;
@@ -2369,7 +2373,7 @@ dfaanalyze (struct dfa *d, int searchflag)
         {
         case EMPTY:
           /* The empty set is nullable.  */
-          *nullable++ = 1;
+          *nullable++ = true;
 
           /* The firstpos and lastpos of the empty leaf are both empty.  */
           *nfirstpos++ = *nlastpos++ = 0;
@@ -2391,7 +2395,7 @@ dfaanalyze (struct dfa *d, int searchflag)
         case QMARK:
           /* A QMARK or STAR node is automatically nullable.  */
           if (d->tokens[i] != PLUS)
-            nullable[-1] = 1;
+            nullable[-1] = true;
           break;
 
         case CAT:
@@ -2429,7 +2433,7 @@ dfaanalyze (struct dfa *d, int searchflag)
           --nlastpos;
 
           /* A CAT node is nullable if both arguments are nullable.  */
-          nullable[-2] = nullable[-1] && nullable[-2];
+          nullable[-2] &= nullable[-1];
           --nullable;
           break;
 
@@ -2443,7 +2447,7 @@ dfaanalyze (struct dfa *d, int searchflag)
           --nlastpos;
 
           /* An OR node is nullable if either argument is nullable.  */
-          nullable[-2] = nullable[-1] || nullable[-2];
+          nullable[-2] |= nullable[-1];
           --nullable;
           break;
 
@@ -2574,11 +2578,11 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
   size_t ngrps = 0;             /* Number of groups actually used.  */
   position pos;                 /* Current position being considered.  */
   charclass matches;            /* Set of matching characters.  */
-  int matchesf;                 /* True if matches is nonempty.  */
+  unsigned int matchesf;        /* Nonzero if matches is nonempty.  */
   charclass intersect;          /* Intersection with some label set.  */
-  int intersectf;               /* True if intersect is nonempty.  */
+  unsigned int intersectf;      /* Nonzero if intersect is nonempty.  */
   charclass leftovers;          /* Stuff in the label that didn't match.  */
-  int leftoversf;               /* True if leftovers is nonempty.  */
+  unsigned int leftoversf;      /* Nonzero if leftovers is nonempty.  */
   position_set follows;         /* Union of the follows of some group.  */
   position_set tmp;             /* Temporary space for merging sets.  */
   int possible_contexts;        /* Contexts that this group can match.  */
@@ -2586,7 +2590,7 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
   state_num state;              /* New state.  */
   state_num state_newline;      /* New state on a newline transition.  */
   state_num state_letter;       /* New state on a letter transition.  */
-  int next_isnt_1st_byte = 0;   /* Flag if we can't add state0.  */
+  bool next_isnt_1st_byte = false; /* Flag if we can't add state0.  */
   size_t i, j, k;
 
   MALLOC (grps, NOTCHAR);
@@ -2601,21 +2605,23 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
         setbit (d->tokens[pos.index], matches);
       else if (d->tokens[pos.index] >= CSET)
         copyset (d->charclasses[d->tokens[pos.index] - CSET], matches);
-      else if (d->tokens[pos.index] == ANYCHAR
-               || d->tokens[pos.index] == MBCSET)
-        /* MB_CUR_MAX > 1  */
+      else
         {
-          /* ANYCHAR and MBCSET must match with a single character, so we
-             must put it to d->states[s].mbps, which contains the positions
-             which can match with a single character not a byte.  */
-          if (d->states[s].mbps.nelem == 0)
-            alloc_position_set (&d->states[s].mbps, 1);
-          insert (pos, &(d->states[s].mbps));
-          d->states[s].has_mbcset |= (d->tokens[pos.index] == MBCSET);
+          if (d->tokens[pos.index] == MBCSET
+              || d->tokens[pos.index] == ANYCHAR)
+            {
+              /* MB_CUR_MAX > 1 */
+              if (d->tokens[pos.index] == MBCSET)
+                d->states[s].has_mbcset = true;
+              /* ANYCHAR and MBCSET must match with a single character, so we
+                 must put it to d->states[s].mbps, which contains the positions
+                 which can match with a single character not a byte.  */
+              if (d->states[s].mbps.nelem == 0)
+                alloc_position_set (&d->states[s].mbps, 1);
+              insert (pos, &(d->states[s].mbps));
+            }
           continue;
         }
-      else
-        continue;
 
       /* Some characters may need to be eliminated from matches because
          they fail in the current context.  */
@@ -2654,7 +2660,7 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
              matches.  */
           intersectf = 0;
           for (k = 0; k < CHARCLASS_INTS; ++k)
-            (intersect[k] = matches[k] & labels[j][k]) ? (intersectf = 1) : 0;
+            intersectf |= intersect[k] = matches[k] & labels[j][k];
           if (!intersectf)
             continue;
 
@@ -2665,8 +2671,8 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
               /* Even an optimizing compiler can't know this for sure.  */
               int match = matches[k], label = labels[j][k];
 
-              (leftovers[k] = ~match & label) ? (leftoversf = 1) : 0;
-              (matches[k] = match & ~label) ? (matchesf = 1) : 0;
+              leftoversf |= leftovers[k] = ~match & label;
+              matchesf |= matches[k] = match & ~label;
             }
 
           /* If there were leftovers, create a new group labeled with them.  */
@@ -2763,12 +2769,12 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
              codepoint of <sb a>, it must not be <sb a> but 2nd byte of
              <mb A>, so we cannot add state[0].  */
 
-          next_isnt_1st_byte = 0;
+          next_isnt_1st_byte = false;
           for (j = 0; j < follows.nelem; ++j)
             {
               if (!(d->multibyte_prop[follows.elems[j].index] & 1))
                 {
-                  next_isnt_1st_byte = 1;
+                  next_isnt_1st_byte = true;
                   break;
                 }
             }
@@ -3052,7 +3058,7 @@ static int
 match_mb_charset (struct dfa *d, state_num s, position pos, size_t idx)
 {
   size_t i;
-  int match;               /* Matching succeeded.  */
+  bool match;              /* Matching succeeded.  */
   int match_len;           /* Length of the character (or collating element)
                               with which this operator matches.  */
   int op_len;              /* Length of the operator.  */
@@ -4040,14 +4046,14 @@ dfamust (struct dfa *d)
   char *result;
   size_t ri;
   size_t i;
-  int exact;
+  bool exact;
   token t;
   static must must0;
   struct dfamust *dm;
   static char empty_string[] = "";
 
   result = empty_string;
-  exact = 0;
+  exact = false;
   MALLOC (musts, d->tindex + 1);
   mp = musts;
   for (i = 0; i <= d->tindex; ++i)
@@ -4142,7 +4148,7 @@ dfamust (struct dfa *d)
             if (strlen (musts[0].in[i]) > strlen (result))
               result = musts[0].in[i];
           if (STREQ (result, musts[0].is))
-            exact = 1;
+            exact = true;
           goto done;
         case CAT:
           assert (&musts[2] <= mp);

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |  140 ++++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 73 insertions(+), 67 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Tue Apr 08 11:05:27 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WXXaY-0008AN-Th
	for mharc-grep-commit@gnu.org; Tue, 08 Apr 2014 11:05:26 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:42515)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXXaV-00086e-3p
	for grep-commit@gnu.org; Tue, 08 Apr 2014 11:05:24 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXXaT-0002Rf-Mb
	for grep-commit@gnu.org; Tue, 08 Apr 2014 11:05:23 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:40691)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXXaT-0002PR-Jf
	for grep-commit@gnu.org; Tue, 08 Apr 2014 11:05:21 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXXaS-0005ax-3K
	for grep-commit@gnu.org; Tue, 08 Apr 2014 15:05:20 +0000
Date: Tue, 08 Apr 2014 15:05:20 +0000
Message-Id: <E1WXXaS-0005ax-3K@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-56-gc74a1d1
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 359012dab9476c8accd3629a8991418a09233b3f
X-Git-Newrev: c74a1d118577e4d3721cd0bcba1a09b8b451f3cc
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 08 Apr 2014 15:05:24 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  c74a1d118577e4d3721cd0bcba1a09b8b451f3cc (commit)
      from  359012dab9476c8accd3629a8991418a09233b3f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=c74a1d118577e4d3721cd0bcba1a09b8b451f3cc


commit c74a1d118577e4d3721cd0bcba1a09b8b451f3cc
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Tue Apr 8 08:04:36 2014 -0700

    grep: port better to hosts with nonstandard nl_langinfo
    
    On some hosts, nl_langinfo returns strings other than "UTF-8" when
    UTF-8 is used, and (worse) return "UTF-8" even if the encoding is
    single-byte.  Work around these problems by trying a sample
    character instead.
    * src/dfa.c, src/pcresearch.c, src/searchutils.c:
    Don't include <langinfo.h>.
    * src/dfa.c (using_utf8): Test for UTF-8 by trying a character
    rather than by invoking nl_langinfo (CODESET); this is more
    portable in practice, and removes a dependency on
    HAVE_LANGINFO_CODESET.
    * src/pcresearch.c: Include dfa.h, for using_utf8.
    (Pcompile): Use using_utf8 rather than nl_langinfo.

diff --git a/src/dfa.c b/src/dfa.c
index 76f7e79..34f230e 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -60,10 +60,6 @@ typedef bool bool_bf;
 #include <wchar.h>
 #include <wctype.h>
 
-#if HAVE_LANGINFO_CODESET
-# include <langinfo.h>
-#endif
-
 #include "xalloc.h"
 
 /* HPUX defines these as macros in sys/param.h.  */
@@ -819,14 +815,14 @@ setbit_case_fold_c (int b, charclass c)
 int
 using_utf8 (void)
 {
-#ifdef HAVE_LANGINFO_CODESET
   static int utf8 = -1;
   if (utf8 < 0)
-    utf8 = STREQ (nl_langinfo (CODESET), "UTF-8");
+    {
+      wchar_t wc;
+      mbstate_t mbs = { 0 };
+      utf8 = mbrtowc (&wc, "\xc4\x80", 2, &mbs) == 2 && wc == 0x100;
+    }
   return utf8;
-#else
-  return 0;
-#endif
 }
 
 /* Return true if the current locale is known to be a unibyte locale
diff --git a/src/pcresearch.c b/src/pcresearch.c
index 319155f..a5e953f 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -20,14 +20,12 @@
 
 #include <config.h>
 #include "search.h"
+#include "dfa.h"
 #if HAVE_PCRE_H
 # include <pcre.h>
 #elif HAVE_PCRE_PCRE_H
 # include <pcre/pcre.h>
 #endif
-#if HAVE_LANGINFO_CODESET
-# include <langinfo.h>
-#endif
 
 #if HAVE_LIBPCRE
 /* Compiled internal form of a Perl regular expression.  */
@@ -60,14 +58,12 @@ Pcompile (char const *pattern, size_t size)
   char const *p;
   char const *pnul;
 
-# if defined HAVE_LANGINFO_CODESET
-  if (STREQ (nl_langinfo (CODESET), "UTF-8"))
+  if (using_utf8 ())
     {
       /* Enable PCRE's UTF-8 matching.  Note also the use of
          PCRE_NO_UTF8_CHECK when calling pcre_extra, below.   */
       flags |= PCRE_UTF8;
     }
-# endif
 
   /* FIXME: Remove these restrictions.  */
   if (memchr (pattern, '\n', size))
diff --git a/src/searchutils.c b/src/searchutils.c
index 6749945..6440f07 100644
--- a/src/searchutils.c
+++ b/src/searchutils.c
@@ -20,9 +20,6 @@
 #include <assert.h>
 #include "search.h"
 #include "dfa.h"
-#if HAVE_LANGINFO_CODESET
-# include <langinfo.h>
-#endif
 
 #define NCHAR (UCHAR_MAX + 1)
 

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c         |   14 +++++---------
 src/pcresearch.c  |    8 ++------
 src/searchutils.c |    3 ---
 3 files changed, 7 insertions(+), 18 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Tue Apr 08 13:37:03 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WXZxH-0004ws-Bq
	for mharc-grep-commit@gnu.org; Tue, 08 Apr 2014 13:37:03 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:35091)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WXZxE-0004qt-NH
	for grep-commit@gnu.org; Tue, 08 Apr 2014 13:37:01 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WXZxD-00037P-GX
	for grep-commit@gnu.org; Tue, 08 Apr 2014 13:37:00 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:42089)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WXZxD-00037L-EJ
	for grep-commit@gnu.org; Tue, 08 Apr 2014 13:36:59 -0400
Received: from meyering by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <jim@meyering.net>) id 1WXZxD-0000sz-2T
	for grep-commit@gnu.org; Tue, 08 Apr 2014 17:36:59 +0000
Date: Tue, 08 Apr 2014 17:36:59 +0000
Message-Id: <E1WXZxD-0000sz-2T@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-57-g06d4798
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: c74a1d118577e4d3721cd0bcba1a09b8b451f3cc
X-Git-Newrev: 06d479820ac1a80a1c75fc8f4afe83b75f6fe64d
From: Jim Meyering <jim@meyering.net>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 08 Apr 2014 17:37:02 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  06d479820ac1a80a1c75fc8f4afe83b75f6fe64d (commit)
      from  c74a1d118577e4d3721cd0bcba1a09b8b451f3cc (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=06d479820ac1a80a1c75fc8f4afe83b75f6fe64d


commit 06d479820ac1a80a1c75fc8f4afe83b75f6fe64d
Author: Jim Meyering <meyering@fb.com>
Date:   Tue Apr 8 07:45:56 2014 -0700

    maint: avoid sc_po_check syntax-check failure (kwset.c)
    
    * po/POTFILES.in: Remove kwset.c from this list, since it
    no longer contains a translatable diagnostic.

diff --git a/po/POTFILES.in b/po/POTFILES.in
index 399bd2f..c5c9979 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -28,5 +28,4 @@ lib/xalloc-die.c
 lib/xstrtol-error.c
 src/dfa.c
 src/grep.c
-src/kwset.c
 src/pcresearch.c

-----------------------------------------------------------------------

Summary of changes:
 po/POTFILES.in |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Tue Apr 08 16:16:16 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WXcRM-0001HE-HW
	for mharc-grep-commit@gnu.org; Tue, 08 Apr 2014 16:16:16 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:38611)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXcRJ-0001GG-IF
	for grep-commit@gnu.org; Tue, 08 Apr 2014 16:16:14 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXcR5-0006Dy-Hf
	for grep-commit@gnu.org; Tue, 08 Apr 2014 16:16:13 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:43613)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXcR5-0006Do-AQ
	for grep-commit@gnu.org; Tue, 08 Apr 2014 16:15:59 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WXcR4-00056H-Po
	for grep-commit@gnu.org; Tue, 08 Apr 2014 20:15:58 +0000
Date: Tue, 08 Apr 2014 20:15:58 +0000
Message-Id: <E1WXcR4-00056H-Po@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-58-gd9869ef
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 06d479820ac1a80a1c75fc8f4afe83b75f6fe64d
X-Git-Newrev: d9869ef79c2e1c549c2b2100b2115b0cdb1d3297
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Tue, 08 Apr 2014 20:16:14 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  d9869ef79c2e1c549c2b2100b2115b0cdb1d3297 (commit)
      from  06d479820ac1a80a1c75fc8f4afe83b75f6fe64d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=d9869ef79c2e1c549c2b2100b2115b0cdb1d3297


commit d9869ef79c2e1c549c2b2100b2115b0cdb1d3297
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Tue Apr 8 13:15:24 2014 -0700

    grep: remove bool_bf
    
    The extra complexity of this microoptimization wasn't ever much help,
    and currently it generated bigger code with gcc -O2 (x86-64).
    * src/dfa.c (bool_bf): Remove.  All uses replaced by plain 'bool',
    without a bitfield.

diff --git a/src/dfa.c b/src/dfa.c
index 34f230e..a3cfa8d 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -34,13 +34,6 @@
 #include <locale.h>
 #include <stdbool.h>
 
-/* The pre-C99 <stdbool.h> emulation doesn't work for bool bitfields.  */
-#if __STDC_VERSION__ < 199901
-typedef unsigned int bool_bf;
-#else
-typedef bool bool_bf;
-#endif
-
 #define STREQ(a, b) (strcmp (a, b) == 0)
 
 /* ISASCIIDIGIT differs from isdigit, as follows:
@@ -291,8 +284,8 @@ typedef struct
   size_t hash;                  /* Hash of the positions of this state.  */
   position_set elems;           /* Positions this state could match.  */
   unsigned char context;        /* Context from previous state.  */
-  bool_bf has_backref : 1;      /* True if this state matches a \<digit>.  */
-  bool_bf has_mbcset : 1;       /* True if this state matches a MBCSET.  */
+  bool has_backref;             /* True if this state matches a \<digit>.  */
+  bool has_mbcset;              /* True if this state matches a MBCSET.  */
   unsigned short constraint;    /* Constraint for this state to accept.  */
   token first_end;              /* Token value of the first END in elems.  */
   position_set mbps;            /* Positions which can match multibyte

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |   11 ++---------
 1 files changed, 2 insertions(+), 9 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Fri Apr 11 16:23:39 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WYhz9-0001nz-OJ
	for mharc-grep-commit@gnu.org; Fri, 11 Apr 2014 16:23:39 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:43359)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WYhz6-0001n7-RZ
	for grep-commit@gnu.org; Fri, 11 Apr 2014 16:23:38 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WYhz4-0000Xl-HG
	for grep-commit@gnu.org; Fri, 11 Apr 2014 16:23:36 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:53790)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WYhz4-0000Xh-Ct
	for grep-commit@gnu.org; Fri, 11 Apr 2014 16:23:34 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WYhz3-00071W-VV
	for grep-commit@gnu.org; Fri, 11 Apr 2014 20:23:34 +0000
Date: Fri, 11 Apr 2014 20:23:33 +0000
Message-Id: <E1WYhz3-00071W-VV@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-61-g5c92a54
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d9869ef79c2e1c549c2b2100b2115b0cdb1d3297
X-Git-Newrev: 5c92a54ec36f176854f0b0cca83b5ff224f2d8e8
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 11 Apr 2014 20:23:38 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  5c92a54ec36f176854f0b0cca83b5ff224f2d8e8 (commit)
       via  45aef12b13259a36e9fd4e2085860a45202f3820 (commit)
       via  2d3832e1ff772dc1a374bfad5dcc1338350cc48b (commit)
      from  d9869ef79c2e1c549c2b2100b2115b0cdb1d3297 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=5c92a54ec36f176854f0b0cca83b5ff224f2d8e8


commit 5c92a54ec36f176854f0b0cca83b5ff224f2d8e8
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Fri Apr 11 12:48:48 2014 -0700

    grep: cleanup for HAS_DOS_FILE_CONTENTS issue
    
    While cleaning up the empty-string fix, I noticed that one part of
    the code worried about CRLF in pattern files whereas another part
    did not.  Fix this by using the same approach in both places,
    and make the CRLF code more modular in the process.
    * src/dosbuf.c (dos_binary, dos_unix_byte_offsets): New functions.
    (undossify_input, dossified_pos): Do nothing if ! O_BINARY.
    * src/grep.c: Always include dosbuf.c so that the code is
    checked statically even on non-DOS hosts.
    (dos_binary, dos_unix_byte_offsets): New decls.
    (undossify_input): Declare unconditionally.
    * src/grep.c (fillbuf, print_line_head, main):
    * src/kwsearch.c (Fcompile):
    Simplify by not worrying about HAVE_DOS_FILE_CONTENTS.
    * src/grep.c (main): fopen with "rt" if O_TEXT; this is simpler
    than worrying about HAVE_DOS_FILE_CONTENTS elsewhere.
    * src/system.h (HAVE_DOS_FILE_CONTENTS): Remove.

diff --git a/src/dosbuf.c b/src/dosbuf.c
index 3648371..9ac2d13 100644
--- a/src/dosbuf.c
+++ b/src/dosbuf.c
@@ -49,6 +49,22 @@ static int       dos_pos_map_size  = 0;
 static int       dos_pos_map_used  = 0;
 static int       inp_map_idx = 0, out_map_idx = 1;
 
+/* Set default DOS file type to binary.  */
+static void
+dos_binary (void)
+{
+  if (O_BINARY)
+    dos_use_file_type = DOS_BINARY;
+}
+
+/* Tell DOS routines to report Unix offset.  */
+static void
+dos_unix_byte_offsets (void)
+{
+  if (O_BINARY)
+    dos_report_unix_offset = 1;
+}
+
 /* Guess DOS file type by looking at its contents.  */
 static File_type
 guess_type (char *buf, size_t buflen)
@@ -79,6 +95,9 @@ guess_type (char *buf, size_t buflen)
 static int
 undossify_input (char *buf, size_t buflen)
 {
+  if (! O_BINARY)
+    return buflen;
+
   int chars_left = 0;
 
   if (totalcc == 0)
@@ -167,6 +186,9 @@ undossify_input (char *buf, size_t buflen)
 static off_t
 dossified_pos (off_t byteno)
 {
+  if (! O_BINARY)
+    return byteno;
+
   off_t pos_lo;
   off_t pos_hi;
 
diff --git a/src/grep.c b/src/grep.c
index 8bd6c49..d58ef03 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -395,9 +395,10 @@ static enum
 
 static int grepfile (int, char const *, int, int);
 static int grepdesc (int, int);
-#if defined HAVE_DOS_FILE_CONTENTS
+
+static void dos_binary (void);
+static void dos_unix_byte_offsets (void);
 static int undossify_input (char *, size_t);
-#endif
 
 static int
 is_device_mode (mode_t m)
@@ -648,10 +649,7 @@ fillbuf (size_t save, struct stat const *st)
   if (fillsize < 0)
     fillsize = cc = 0;
   bufoffset += fillsize;
-#if defined HAVE_DOS_FILE_CONTENTS
-  if (fillsize)
-    fillsize = undossify_input (readbuf, fillsize);
-#endif
+  fillsize = undossify_input (readbuf, fillsize);
   buflim = readbuf + fillsize;
   return cc;
 }
@@ -695,9 +693,7 @@ static intmax_t pending;	/* Pending lines of output.
 static int done_on_match;	/* Stop scanning file on first match.  */
 static int exit_on_match;	/* Exit on first match.  */
 
-#if defined HAVE_DOS_FILE_CONTENTS
-# include "dosbuf.c"
-#endif
+#include "dosbuf.c"
 
 /* Add two numbers that count input bytes or lines, and report an
    error if the addition overflows.  */
@@ -803,9 +799,7 @@ print_line_head (char const *beg, char const *lim, int sep)
   if (out_byte)
     {
       uintmax_t pos = add_count (totalcc, beg - bufbeg);
-#if defined HAVE_DOS_FILE_CONTENTS
       pos = dossified_pos (pos);
-#endif
       if (pending_sep)
         print_sep (sep);
       print_offset (pos, 6, byte_num_color);
@@ -2043,15 +2037,11 @@ main (int argc, char **argv)
         break;
 
       case 'U':
-#if defined HAVE_DOS_FILE_CONTENTS
-        dos_use_file_type = DOS_BINARY;
-#endif
+        dos_binary ();
         break;
 
       case 'u':
-#if defined HAVE_DOS_FILE_CONTENTS
-        dos_report_unix_offset = 1;
-#endif
+        dos_unix_byte_offsets ();
         break;
 
       case 'V':
@@ -2086,7 +2076,7 @@ main (int argc, char **argv)
         break;
 
       case 'f':
-        fp = STREQ (optarg, "-") ? stdin : fopen (optarg, "r");
+        fp = STREQ (optarg, "-") ? stdin : fopen (optarg, O_TEXT ? "rt" : "r");
         if (!fp)
           error (EXIT_TROUBLE, errno, "%s", optarg);
         for (keyalloc = 1; keyalloc <= keycc + 1; keyalloc *= 2)
diff --git a/src/kwsearch.c b/src/kwsearch.c
index cf8df3c..5f3f233 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -50,10 +50,6 @@ Fcompile (char const *pattern, size_t size)
           len = sep - p;
           sep++;
           total -= (len + 1);
-#if HAVE_DOS_FILE_CONTENTS
-         if (sep[-1] == '\r')
-           --len;
-#endif
         }
       else
         {
diff --git a/src/system.h b/src/system.h
index 4c85409..7da1d8d 100644
--- a/src/system.h
+++ b/src/system.h
@@ -29,10 +29,6 @@
 #include "minmax.h"
 #include "same-inode.h"
 
-#if O_BINARY
-# define HAVE_DOS_FILE_CONTENTS 1
-#endif
-
 #include <stdlib.h>
 #include <stddef.h>
 #include <limits.h>

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=45aef12b13259a36e9fd4e2085860a45202f3820


commit 5c92a54ec36f176854f0b0cca83b5ff224f2d8e8
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Fri Apr 11 12:48:48 2014 -0700

    grep: cleanup for HAS_DOS_FILE_CONTENTS issue
    
    While cleaning up the empty-string fix, I noticed that one part of
    the code worried about CRLF in pattern files whereas another part
    did not.  Fix this by using the same approach in both places,
    and make the CRLF code more modular in the process.
    * src/dosbuf.c (dos_binary, dos_unix_byte_offsets): New functions.
    (undossify_input, dossified_pos): Do nothing if ! O_BINARY.
    * src/grep.c: Always include dosbuf.c so that the code is
    checked statically even on non-DOS hosts.
    (dos_binary, dos_unix_byte_offsets): New decls.
    (undossify_input): Declare unconditionally.
    * src/grep.c (fillbuf, print_line_head, main):
    * src/kwsearch.c (Fcompile):
    Simplify by not worrying about HAVE_DOS_FILE_CONTENTS.
    * src/grep.c (main): fopen with "rt" if O_TEXT; this is simpler
    than worrying about HAVE_DOS_FILE_CONTENTS elsewhere.
    * src/system.h (HAVE_DOS_FILE_CONTENTS): Remove.

diff --git a/src/dosbuf.c b/src/dosbuf.c
index 3648371..9ac2d13 100644
--- a/src/dosbuf.c
+++ b/src/dosbuf.c
@@ -49,6 +49,22 @@ static int       dos_pos_map_size  = 0;
 static int       dos_pos_map_used  = 0;
 static int       inp_map_idx = 0, out_map_idx = 1;
 
+/* Set default DOS file type to binary.  */
+static void
+dos_binary (void)
+{
+  if (O_BINARY)
+    dos_use_file_type = DOS_BINARY;
+}
+
+/* Tell DOS routines to report Unix offset.  */
+static void
+dos_unix_byte_offsets (void)
+{
+  if (O_BINARY)
+    dos_report_unix_offset = 1;
+}
+
 /* Guess DOS file type by looking at its contents.  */
 static File_type
 guess_type (char *buf, size_t buflen)
@@ -79,6 +95,9 @@ guess_type (char *buf, size_t buflen)
 static int
 undossify_input (char *buf, size_t buflen)
 {
+  if (! O_BINARY)
+    return buflen;
+
   int chars_left = 0;
 
   if (totalcc == 0)
@@ -167,6 +186,9 @@ undossify_input (char *buf, size_t buflen)
 static off_t
 dossified_pos (off_t byteno)
 {
+  if (! O_BINARY)
+    return byteno;
+
   off_t pos_lo;
   off_t pos_hi;
 
diff --git a/src/grep.c b/src/grep.c
index 8bd6c49..d58ef03 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -395,9 +395,10 @@ static enum
 
 static int grepfile (int, char const *, int, int);
 static int grepdesc (int, int);
-#if defined HAVE_DOS_FILE_CONTENTS
+
+static void dos_binary (void);
+static void dos_unix_byte_offsets (void);
 static int undossify_input (char *, size_t);
-#endif
 
 static int
 is_device_mode (mode_t m)
@@ -648,10 +649,7 @@ fillbuf (size_t save, struct stat const *st)
   if (fillsize < 0)
     fillsize = cc = 0;
   bufoffset += fillsize;
-#if defined HAVE_DOS_FILE_CONTENTS
-  if (fillsize)
-    fillsize = undossify_input (readbuf, fillsize);
-#endif
+  fillsize = undossify_input (readbuf, fillsize);
   buflim = readbuf + fillsize;
   return cc;
 }
@@ -695,9 +693,7 @@ static intmax_t pending;	/* Pending lines of output.
 static int done_on_match;	/* Stop scanning file on first match.  */
 static int exit_on_match;	/* Exit on first match.  */
 
-#if defined HAVE_DOS_FILE_CONTENTS
-# include "dosbuf.c"
-#endif
+#include "dosbuf.c"
 
 /* Add two numbers that count input bytes or lines, and report an
    error if the addition overflows.  */
@@ -803,9 +799,7 @@ print_line_head (char const *beg, char const *lim, int sep)
   if (out_byte)
     {
       uintmax_t pos = add_count (totalcc, beg - bufbeg);
-#if defined HAVE_DOS_FILE_CONTENTS
       pos = dossified_pos (pos);
-#endif
       if (pending_sep)
         print_sep (sep);
       print_offset (pos, 6, byte_num_color);
@@ -2043,15 +2037,11 @@ main (int argc, char **argv)
         break;
 
       case 'U':
-#if defined HAVE_DOS_FILE_CONTENTS
-        dos_use_file_type = DOS_BINARY;
-#endif
+        dos_binary ();
         break;
 
       case 'u':
-#if defined HAVE_DOS_FILE_CONTENTS
-        dos_report_unix_offset = 1;
-#endif
+        dos_unix_byte_offsets ();
         break;
 
       case 'V':
@@ -2086,7 +2076,7 @@ main (int argc, char **argv)
         break;
 
       case 'f':
-        fp = STREQ (optarg, "-") ? stdin : fopen (optarg, "r");
+        fp = STREQ (optarg, "-") ? stdin : fopen (optarg, O_TEXT ? "rt" : "r");
         if (!fp)
           error (EXIT_TROUBLE, errno, "%s", optarg);
         for (keyalloc = 1; keyalloc <= keycc + 1; keyalloc *= 2)
diff --git a/src/kwsearch.c b/src/kwsearch.c
index cf8df3c..5f3f233 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -50,10 +50,6 @@ Fcompile (char const *pattern, size_t size)
           len = sep - p;
           sep++;
           total -= (len + 1);
-#if HAVE_DOS_FILE_CONTENTS
-         if (sep[-1] == '\r')
-           --len;
-#endif
         }
       else
         {
diff --git a/src/system.h b/src/system.h
index 4c85409..7da1d8d 100644
--- a/src/system.h
+++ b/src/system.h
@@ -29,10 +29,6 @@
 #include "minmax.h"
 #include "same-inode.h"
 
-#if O_BINARY
-# define HAVE_DOS_FILE_CONTENTS 1
-#endif
-
 #include <stdlib.h>
 #include <stddef.h>
 #include <limits.h>

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=2d3832e1ff772dc1a374bfad5dcc1338350cc48b


commit 5c92a54ec36f176854f0b0cca83b5ff224f2d8e8
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Fri Apr 11 12:48:48 2014 -0700

    grep: cleanup for HAS_DOS_FILE_CONTENTS issue
    
    While cleaning up the empty-string fix, I noticed that one part of
    the code worried about CRLF in pattern files whereas another part
    did not.  Fix this by using the same approach in both places,
    and make the CRLF code more modular in the process.
    * src/dosbuf.c (dos_binary, dos_unix_byte_offsets): New functions.
    (undossify_input, dossified_pos): Do nothing if ! O_BINARY.
    * src/grep.c: Always include dosbuf.c so that the code is
    checked statically even on non-DOS hosts.
    (dos_binary, dos_unix_byte_offsets): New decls.
    (undossify_input): Declare unconditionally.
    * src/grep.c (fillbuf, print_line_head, main):
    * src/kwsearch.c (Fcompile):
    Simplify by not worrying about HAVE_DOS_FILE_CONTENTS.
    * src/grep.c (main): fopen with "rt" if O_TEXT; this is simpler
    than worrying about HAVE_DOS_FILE_CONTENTS elsewhere.
    * src/system.h (HAVE_DOS_FILE_CONTENTS): Remove.

diff --git a/src/dosbuf.c b/src/dosbuf.c
index 3648371..9ac2d13 100644
--- a/src/dosbuf.c
+++ b/src/dosbuf.c
@@ -49,6 +49,22 @@ static int       dos_pos_map_size  = 0;
 static int       dos_pos_map_used  = 0;
 static int       inp_map_idx = 0, out_map_idx = 1;
 
+/* Set default DOS file type to binary.  */
+static void
+dos_binary (void)
+{
+  if (O_BINARY)
+    dos_use_file_type = DOS_BINARY;
+}
+
+/* Tell DOS routines to report Unix offset.  */
+static void
+dos_unix_byte_offsets (void)
+{
+  if (O_BINARY)
+    dos_report_unix_offset = 1;
+}
+
 /* Guess DOS file type by looking at its contents.  */
 static File_type
 guess_type (char *buf, size_t buflen)
@@ -79,6 +95,9 @@ guess_type (char *buf, size_t buflen)
 static int
 undossify_input (char *buf, size_t buflen)
 {
+  if (! O_BINARY)
+    return buflen;
+
   int chars_left = 0;
 
   if (totalcc == 0)
@@ -167,6 +186,9 @@ undossify_input (char *buf, size_t buflen)
 static off_t
 dossified_pos (off_t byteno)
 {
+  if (! O_BINARY)
+    return byteno;
+
   off_t pos_lo;
   off_t pos_hi;
 
diff --git a/src/grep.c b/src/grep.c
index 8bd6c49..d58ef03 100644
--- a/src/grep.c
+++ b/src/grep.c
@@ -395,9 +395,10 @@ static enum
 
 static int grepfile (int, char const *, int, int);
 static int grepdesc (int, int);
-#if defined HAVE_DOS_FILE_CONTENTS
+
+static void dos_binary (void);
+static void dos_unix_byte_offsets (void);
 static int undossify_input (char *, size_t);
-#endif
 
 static int
 is_device_mode (mode_t m)
@@ -648,10 +649,7 @@ fillbuf (size_t save, struct stat const *st)
   if (fillsize < 0)
     fillsize = cc = 0;
   bufoffset += fillsize;
-#if defined HAVE_DOS_FILE_CONTENTS
-  if (fillsize)
-    fillsize = undossify_input (readbuf, fillsize);
-#endif
+  fillsize = undossify_input (readbuf, fillsize);
   buflim = readbuf + fillsize;
   return cc;
 }
@@ -695,9 +693,7 @@ static intmax_t pending;	/* Pending lines of output.
 static int done_on_match;	/* Stop scanning file on first match.  */
 static int exit_on_match;	/* Exit on first match.  */
 
-#if defined HAVE_DOS_FILE_CONTENTS
-# include "dosbuf.c"
-#endif
+#include "dosbuf.c"
 
 /* Add two numbers that count input bytes or lines, and report an
    error if the addition overflows.  */
@@ -803,9 +799,7 @@ print_line_head (char const *beg, char const *lim, int sep)
   if (out_byte)
     {
       uintmax_t pos = add_count (totalcc, beg - bufbeg);
-#if defined HAVE_DOS_FILE_CONTENTS
       pos = dossified_pos (pos);
-#endif
       if (pending_sep)
         print_sep (sep);
       print_offset (pos, 6, byte_num_color);
@@ -2043,15 +2037,11 @@ main (int argc, char **argv)
         break;
 
       case 'U':
-#if defined HAVE_DOS_FILE_CONTENTS
-        dos_use_file_type = DOS_BINARY;
-#endif
+        dos_binary ();
         break;
 
       case 'u':
-#if defined HAVE_DOS_FILE_CONTENTS
-        dos_report_unix_offset = 1;
-#endif
+        dos_unix_byte_offsets ();
         break;
 
       case 'V':
@@ -2086,7 +2076,7 @@ main (int argc, char **argv)
         break;
 
       case 'f':
-        fp = STREQ (optarg, "-") ? stdin : fopen (optarg, "r");
+        fp = STREQ (optarg, "-") ? stdin : fopen (optarg, O_TEXT ? "rt" : "r");
         if (!fp)
           error (EXIT_TROUBLE, errno, "%s", optarg);
         for (keyalloc = 1; keyalloc <= keycc + 1; keyalloc *= 2)
diff --git a/src/kwsearch.c b/src/kwsearch.c
index cf8df3c..5f3f233 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -50,10 +50,6 @@ Fcompile (char const *pattern, size_t size)
           len = sep - p;
           sep++;
           total -= (len + 1);
-#if HAVE_DOS_FILE_CONTENTS
-         if (sep[-1] == '\r')
-           --len;
-#endif
         }
       else
         {
diff --git a/src/system.h b/src/system.h
index 4c85409..7da1d8d 100644
--- a/src/system.h
+++ b/src/system.h
@@ -29,10 +29,6 @@
 #include "minmax.h"
 #include "same-inode.h"
 
-#if O_BINARY
-# define HAVE_DOS_FILE_CONTENTS 1
-#endif
-
 #include <stdlib.h>
 #include <stddef.h>
 #include <limits.h>

-----------------------------------------------------------------------

Summary of changes:
 NEWS              |    3 +++
 src/dfasearch.c   |   23 +++++++++++------------
 src/dosbuf.c      |   22 ++++++++++++++++++++++
 src/grep.c        |   26 ++++++++------------------
 src/kwsearch.c    |   41 +++++++++++++++++------------------------
 src/system.h      |    4 ----
 tests/Makefile.am |    1 +
 tests/empty-line  |   41 +++++++++++++++++++++++++++++++++++++++++
 8 files changed, 103 insertions(+), 58 deletions(-)
 create mode 100755 tests/empty-line


hooks/post-receive
-- 
grep


From MAILER-DAEMON Fri Apr 11 21:28:50 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WYmkU-0006k2-Kg
	for mharc-grep-commit@gnu.org; Fri, 11 Apr 2014 21:28:50 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:56618)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WYmkR-0006ju-JO
	for grep-commit@gnu.org; Fri, 11 Apr 2014 21:28:49 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WYmkP-0000Y0-Lh
	for grep-commit@gnu.org; Fri, 11 Apr 2014 21:28:47 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:56216)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WYmkP-0000Xw-Hr
	for grep-commit@gnu.org; Fri, 11 Apr 2014 21:28:45 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WYmkO-0003WO-Tc
	for grep-commit@gnu.org; Sat, 12 Apr 2014 01:28:45 +0000
Date: Sat, 12 Apr 2014 01:28:44 +0000
Message-Id: <E1WYmkO-0003WO-Tc@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-63-g34e17a7
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 5c92a54ec36f176854f0b0cca83b5ff224f2d8e8
X-Git-Newrev: 34e17a7a01ac1d85b330444dbc8979d07b8dd9d0
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 12 Apr 2014 01:28:49 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  34e17a7a01ac1d85b330444dbc8979d07b8dd9d0 (commit)
       via  441775e9bbec9359ceac237dd908ef9689f76e61 (commit)
      from  5c92a54ec36f176854f0b0cca83b5ff224f2d8e8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=34e17a7a01ac1d85b330444dbc8979d07b8dd9d0


commit 34e17a7a01ac1d85b330444dbc8979d07b8dd9d0
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Wed Apr 9 19:59:12 2014 -0700

    grep: improvements for the open-CSET patch
    
    * src/dfa.c (dfamust): Simplify by removing some duplicate code.
    Optimize patterns like [aaa] even when not case-folding.
    Avoid an unnecessary copy of the charclass.

diff --git a/src/dfa.c b/src/dfa.c
index 6b4169d..2b6c5d6 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -4036,7 +4036,6 @@ dfamust (struct dfa *d)
   size_t ri;
   size_t i;
   bool exact;
-  token t;
   static must must0;
   struct dfamust *dm;
   static char empty_string[] = "";
@@ -4067,11 +4066,18 @@ dfamust (struct dfa *d)
 #endif
   for (ri = 0; ri < d->tindex; ++ri)
     {
-      switch (t = d->tokens[ri])
+      token t = d->tokens[ri];
+      switch (t)
         {
         case LPAREN:
         case RPAREN:
           assert (!"neither LPAREN nor RPAREN may appear here");
+
+        case STAR:
+        case QMARK:
+          assert (musts < mp);
+          --mp;
+          /* Fall through.  */
         case EMPTY:
         case BEGLINE:
         case ENDLINE:
@@ -4080,14 +4086,11 @@ dfamust (struct dfa *d)
         case LIMWORD:
         case NOTLIMWORD:
         case BACKREF:
+        case ANYCHAR:
+        case MBCSET:
           resetmust (mp);
           break;
-        case STAR:
-        case QMARK:
-          assert (musts < mp);
-          --mp;
-          resetmust (mp);
-          break;
+
         case OR:
           assert (&musts[2] <= mp);
           {
@@ -4126,11 +4129,13 @@ dfamust (struct dfa *d)
             lmp->in = new;
           }
           break;
+
         case PLUS:
           assert (musts < mp);
           --mp;
           mp->is[0] = '\0';
           break;
+
         case END:
           assert (mp == &musts[1]);
           for (i = 0; musts[0].in[i] != NULL; ++i)
@@ -4139,6 +4144,7 @@ dfamust (struct dfa *d)
           if (STREQ (result, musts[0].is))
             exact = true;
           goto done;
+
         case CAT:
           assert (&musts[2] <= mp);
           {
@@ -4188,62 +4194,41 @@ dfamust (struct dfa *d)
               lmp->is[0] = '\0';
           }
           break;
+
+        case '\0':
+          /* Not on *my* shift.  */
+          goto done;
+
         default:
-          if (t < END)
-            {
-              assert (!"oops! t >= END");
-            }
-          else if (t == '\0')
-            {
-              /* not on *my* shift */
-              goto done;
-            }
-          else if (t >= CSET)
+          resetmust (mp);
+          if (CSET <= t)
             {
-              charclass ccl;
+              /* If T is a singleton, or if case-folding in a unibyte
+                 locale and T's members all case-fold to the same char,
+                 convert T to one of its members.  Otherwise, do
+                 nothing further with T.  */
+              charclass *ccl = &d->charclasses[t - CSET];
               int j;
-              copyset (d->charclasses[t - CSET], ccl);
-              for (j = 0; j < NOTCHAR; ++j)
-                if (tstbit (j, ccl))
+              for (j = 0; j < NOTCHAR; j++)
+                if (tstbit (j, *ccl))
+                  break;
+              if (! (j < NOTCHAR))
+                break;
+              t = j;
+              while (++j < NOTCHAR)
+                if (tstbit (j, *ccl)
+                    && ! (case_fold && MB_CUR_MAX == 1
+                          && toupper (j) == toupper (t)))
                   break;
               if (j < NOTCHAR)
-                {
-                  int c = (case_fold && MB_CUR_MAX == 1) ? toupper (j) : j;
-                  for (; j < NOTCHAR; j++)
-                    if (tstbit (j, ccl)
-                        && (!(case_fold && MB_CUR_MAX == 1) || c != toupper (j)))
-                      break;
-                  if (j < NOTCHAR)
-                    resetmust (mp);
-                  else
-                    {
-                      resetmust (mp);
-                      mp->is[0] = mp->left[0] = mp->right[0] = c;
-                      mp->is[1] = mp->left[1] = mp->right[1] = '\0';
-                      mp->in = enlist (mp->in, mp->is, (size_t) 1);
-                      if (mp->in == NULL)
-                        goto done;
-                    }
-                }
-              else
-                resetmust (mp);
-            }
-          else if (t == ANYCHAR || t == MBCSET)
-            {
-              /* easy enough */
-              resetmust (mp);
-            }
-          else
-            {
-              /* plain character */
-              resetmust (mp);
-              mp->is[0] = mp->left[0] = mp->right[0] =
-                (case_fold && MB_CUR_MAX == 1) ? toupper (t) : t;
-              mp->is[1] = mp->left[1] = mp->right[1] = '\0';
-              mp->in = enlist (mp->in, mp->is, (size_t) 1);
-              if (mp->in == NULL)
-                goto done;
+                break;
             }
+          mp->is[0] = mp->left[0] = mp->right[0]
+            = case_fold && MB_CUR_MAX == 1 ? toupper (t) : t;
+          mp->is[1] = mp->left[1] = mp->right[1] = '\0';
+          mp->in = enlist (mp->in, mp->is, 1);
+          if (mp->in == NULL)
+            goto done;
           break;
         }
 #ifdef DEBUG

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=441775e9bbec9359ceac237dd908ef9689f76e61


commit 34e17a7a01ac1d85b330444dbc8979d07b8dd9d0
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Wed Apr 9 19:59:12 2014 -0700

    grep: improvements for the open-CSET patch
    
    * src/dfa.c (dfamust): Simplify by removing some duplicate code.
    Optimize patterns like [aaa] even when not case-folding.
    Avoid an unnecessary copy of the charclass.

diff --git a/src/dfa.c b/src/dfa.c
index 6b4169d..2b6c5d6 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -4036,7 +4036,6 @@ dfamust (struct dfa *d)
   size_t ri;
   size_t i;
   bool exact;
-  token t;
   static must must0;
   struct dfamust *dm;
   static char empty_string[] = "";
@@ -4067,11 +4066,18 @@ dfamust (struct dfa *d)
 #endif
   for (ri = 0; ri < d->tindex; ++ri)
     {
-      switch (t = d->tokens[ri])
+      token t = d->tokens[ri];
+      switch (t)
         {
         case LPAREN:
         case RPAREN:
           assert (!"neither LPAREN nor RPAREN may appear here");
+
+        case STAR:
+        case QMARK:
+          assert (musts < mp);
+          --mp;
+          /* Fall through.  */
         case EMPTY:
         case BEGLINE:
         case ENDLINE:
@@ -4080,14 +4086,11 @@ dfamust (struct dfa *d)
         case LIMWORD:
         case NOTLIMWORD:
         case BACKREF:
+        case ANYCHAR:
+        case MBCSET:
           resetmust (mp);
           break;
-        case STAR:
-        case QMARK:
-          assert (musts < mp);
-          --mp;
-          resetmust (mp);
-          break;
+
         case OR:
           assert (&musts[2] <= mp);
           {
@@ -4126,11 +4129,13 @@ dfamust (struct dfa *d)
             lmp->in = new;
           }
           break;
+
         case PLUS:
           assert (musts < mp);
           --mp;
           mp->is[0] = '\0';
           break;
+
         case END:
           assert (mp == &musts[1]);
           for (i = 0; musts[0].in[i] != NULL; ++i)
@@ -4139,6 +4144,7 @@ dfamust (struct dfa *d)
           if (STREQ (result, musts[0].is))
             exact = true;
           goto done;
+
         case CAT:
           assert (&musts[2] <= mp);
           {
@@ -4188,62 +4194,41 @@ dfamust (struct dfa *d)
               lmp->is[0] = '\0';
           }
           break;
+
+        case '\0':
+          /* Not on *my* shift.  */
+          goto done;
+
         default:
-          if (t < END)
-            {
-              assert (!"oops! t >= END");
-            }
-          else if (t == '\0')
-            {
-              /* not on *my* shift */
-              goto done;
-            }
-          else if (t >= CSET)
+          resetmust (mp);
+          if (CSET <= t)
             {
-              charclass ccl;
+              /* If T is a singleton, or if case-folding in a unibyte
+                 locale and T's members all case-fold to the same char,
+                 convert T to one of its members.  Otherwise, do
+                 nothing further with T.  */
+              charclass *ccl = &d->charclasses[t - CSET];
               int j;
-              copyset (d->charclasses[t - CSET], ccl);
-              for (j = 0; j < NOTCHAR; ++j)
-                if (tstbit (j, ccl))
+              for (j = 0; j < NOTCHAR; j++)
+                if (tstbit (j, *ccl))
+                  break;
+              if (! (j < NOTCHAR))
+                break;
+              t = j;
+              while (++j < NOTCHAR)
+                if (tstbit (j, *ccl)
+                    && ! (case_fold && MB_CUR_MAX == 1
+                          && toupper (j) == toupper (t)))
                   break;
               if (j < NOTCHAR)
-                {
-                  int c = (case_fold && MB_CUR_MAX == 1) ? toupper (j) : j;
-                  for (; j < NOTCHAR; j++)
-                    if (tstbit (j, ccl)
-                        && (!(case_fold && MB_CUR_MAX == 1) || c != toupper (j)))
-                      break;
-                  if (j < NOTCHAR)
-                    resetmust (mp);
-                  else
-                    {
-                      resetmust (mp);
-                      mp->is[0] = mp->left[0] = mp->right[0] = c;
-                      mp->is[1] = mp->left[1] = mp->right[1] = '\0';
-                      mp->in = enlist (mp->in, mp->is, (size_t) 1);
-                      if (mp->in == NULL)
-                        goto done;
-                    }
-                }
-              else
-                resetmust (mp);
-            }
-          else if (t == ANYCHAR || t == MBCSET)
-            {
-              /* easy enough */
-              resetmust (mp);
-            }
-          else
-            {
-              /* plain character */
-              resetmust (mp);
-              mp->is[0] = mp->left[0] = mp->right[0] =
-                (case_fold && MB_CUR_MAX == 1) ? toupper (t) : t;
-              mp->is[1] = mp->left[1] = mp->right[1] = '\0';
-              mp->in = enlist (mp->in, mp->is, (size_t) 1);
-              if (mp->in == NULL)
-                goto done;
+                break;
             }
+          mp->is[0] = mp->left[0] = mp->right[0]
+            = case_fold && MB_CUR_MAX == 1 ? toupper (t) : t;
+          mp->is[1] = mp->left[1] = mp->right[1] = '\0';
+          mp->in = enlist (mp->in, mp->is, 1);
+          if (mp->in == NULL)
+            goto done;
           break;
         }
 #ifdef DEBUG

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |   76 +++++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 46 insertions(+), 30 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Sat Apr 12 14:05:14 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WZ2Ik-0004Qe-Q7
	for mharc-grep-commit@gnu.org; Sat, 12 Apr 2014 14:05:14 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:38287)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WZ2Ih-0004Po-QV
	for grep-commit@gnu.org; Sat, 12 Apr 2014 14:05:12 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WZ2Ig-000799-Sz
	for grep-commit@gnu.org; Sat, 12 Apr 2014 14:05:11 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:37363)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WZ2Ig-000791-PP
	for grep-commit@gnu.org; Sat, 12 Apr 2014 14:05:10 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WZ2If-000267-S9
	for grep-commit@gnu.org; Sat, 12 Apr 2014 18:05:10 +0000
Date: Sat, 12 Apr 2014 18:05:10 +0000
Message-Id: <E1WZ2If-000267-S9@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-64-gc96d5e6
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 34e17a7a01ac1d85b330444dbc8979d07b8dd9d0
X-Git-Newrev: c96d5e6f6fb4bf5e1c46769fd87d6667b5c322ea
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 12 Apr 2014 18:05:13 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  c96d5e6f6fb4bf5e1c46769fd87d6667b5c322ea (commit)
      from  34e17a7a01ac1d85b330444dbc8979d07b8dd9d0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=c96d5e6f6fb4bf5e1c46769fd87d6667b5c322ea


commit c96d5e6f6fb4bf5e1c46769fd87d6667b5c322ea
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sat Apr 12 11:01:18 2014 -0700

    build: update gnulib submodule to latest

diff --git a/gnulib b/gnulib
index 24379a9..2f40bc5 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 24379a9217fa4bd62685795aaaa010fd90ced9e3
+Subproject commit 2f40bc523412742dac387b37d70b5a7f5d8363cc

-----------------------------------------------------------------------

Summary of changes:
 gnulib |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Mon Apr 14 11:35:54 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WZivK-0004Eb-EC
	for mharc-grep-commit@gnu.org; Mon, 14 Apr 2014 11:35:54 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33512)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WZivH-0004A0-Hi
	for grep-commit@gnu.org; Mon, 14 Apr 2014 11:35:52 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WZivD-0004av-Hy
	for grep-commit@gnu.org; Mon, 14 Apr 2014 11:35:51 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:34017)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WZivD-0004aq-58
	for grep-commit@gnu.org; Mon, 14 Apr 2014 11:35:47 -0400
Received: from meyering by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <jim@meyering.net>) id 1WZivC-0008U1-0U
	for grep-commit@gnu.org; Mon, 14 Apr 2014 15:35:46 +0000
Date: Mon, 14 Apr 2014 15:35:46 +0000
Message-Id: <E1WZivC-0008U1-0U@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-65-g4965c79
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: c96d5e6f6fb4bf5e1c46769fd87d6667b5c322ea
X-Git-Newrev: 4965c7942ee355587d47624b226725184fea73c3
From: Jim Meyering <jim@meyering.net>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 14 Apr 2014 15:35:53 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  4965c7942ee355587d47624b226725184fea73c3 (commit)
      from  c96d5e6f6fb4bf5e1c46769fd87d6667b5c322ea (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=4965c7942ee355587d47624b226725184fea73c3


commit 4965c7942ee355587d47624b226725184fea73c3
Author: Jim Meyering <meyering@fb.com>
Date:   Sun Apr 13 13:21:14 2014 -0700

    tests: detect an infloop-inducing bug in grep -P (pcre-8.35)
    
    * tests/pcre-infloop: New test.
    * tests/Makefile.am (TESTS): Add it.

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 49d6cba..cc79903 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -83,6 +83,7 @@ TESTS =						\
   options					\
   pcre						\
   pcre-abort					\
+  pcre-infloop					\
   pcre-invalid-utf8-input			\
   pcre-utf8					\
   pcre-w					\
diff --git a/tests/pcre-infloop b/tests/pcre-infloop
new file mode 100755
index 0000000..57b67ae
--- /dev/null
+++ b/tests/pcre-infloop
@@ -0,0 +1,33 @@
+#!/bin/sh
+# With some versions of libpcre, apparently including 8.35,
+# the following would trigger an infinite loop in its match function.
+
+# Copyright 2014 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
+require_pcre_
+require_timeout_
+require_en_utf8_locale_
+require_compiled_in_MB_support
+
+printf 'a\201b\r' > in || framework_failure_
+
+fail=0
+
+LC_ALL=en_US.utf8 timeout 3 grep -P 'a.?..b' in
+test $? = 1 || fail_ "libpcre's match function appears to infloop"
+
+Exit $fail

-----------------------------------------------------------------------

Summary of changes:
 tests/Makefile.am                    |    1 +
 tests/{dfa-coverage => pcre-infloop} |   17 +++++++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)
 copy tests/{dfa-coverage => pcre-infloop} (67%)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Fri Apr 18 01:51:52 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Wb1iK-00069o-04
	for mharc-grep-commit@gnu.org; Fri, 18 Apr 2014 01:51:52 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:59656)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wb1iF-00069g-Te
	for grep-commit@gnu.org; Fri, 18 Apr 2014 01:51:50 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wb1iD-0003Fb-Nm
	for grep-commit@gnu.org; Fri, 18 Apr 2014 01:51:47 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:55500)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wb1iD-0003FX-Io
	for grep-commit@gnu.org; Fri, 18 Apr 2014 01:51:45 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wb1iC-0004jR-KS
	for grep-commit@gnu.org; Fri, 18 Apr 2014 05:51:45 +0000
Date: Fri, 18 Apr 2014 05:51:44 +0000
Message-Id: <E1Wb1iC-0004jR-KS@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-77-g28f6eed
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 4965c7942ee355587d47624b226725184fea73c3
X-Git-Newrev: 28f6eed8db830ec2a92a560ef25cc93c6361b12c
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 18 Apr 2014 05:51:50 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  28f6eed8db830ec2a92a560ef25cc93c6361b12c (commit)
       via  689f51d3a2427134d6487d973757a1b7e38ec46c (commit)
       via  78d62ecc5a4e90c398dae525e9d74b78badf7060 (commit)
       via  4dee094c29725f4492fe45b61588e6bbdbdd53f7 (commit)
       via  c49f3cb06b6a917f69e945ba30eb21c641ce7085 (commit)
       via  7cb640ae558d716820ce974e7e6b493399be815f (commit)
       via  a26989f8ee58569d2e732d67c6afca9fd88454c6 (commit)
       via  d3d96123274d519b18f56b68423c26c5474e79be (commit)
       via  730a5b80b211ee0ae40722f3924a1a6df7b67c72 (commit)
       via  0a8b75ef73ae3e841f57d93802fbed1613eda3e2 (commit)
       via  26cb9008c855fbda3bf7e0dc377d1f6e95a9e68e (commit)
       via  6a60fd53ef09c2403f7e70ceff2bbbc0f7325234 (commit)
      from  4965c7942ee355587d47624b226725184fea73c3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=28f6eed8db830ec2a92a560ef25cc93c6361b12c


commit 28f6eed8db830ec2a92a560ef25cc93c6361b12c
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 17 22:30:10 2014 -0700

    dfa: trans reallocation microoptimization
    
    * src/dfa.c (realloc_trans_if_necessary):
    Help the compiler avoid unnecessary reloads.

diff --git a/src/dfa.c b/src/dfa.c
index 618a8bc..24355d8 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2799,19 +2799,20 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
 static void
 realloc_trans_if_necessary (struct dfa *d, state_num new_state)
 {
-  if (d->tralloc <= new_state)
+  state_num oldalloc = d->tralloc;
+  if (oldalloc <= new_state)
     {
       state_num **realtrans = d->trans ? d->trans - 1 : NULL;
-      state_num oldalloc = d->tralloc;
+      size_t newalloc;
       d->tralloc = new_state + 1;
       realtrans = x2nrealloc (realtrans, &d->tralloc, sizeof *realtrans);
       realtrans[0] = NULL;
       d->trans = realtrans + 1;
-      d->tralloc--;
-      d->fails = xnrealloc (d->fails, d->tralloc, sizeof *d->fails);
-      d->success = xnrealloc (d->success, d->tralloc, sizeof *d->success);
-      d->newlines = xnrealloc (d->newlines, d->tralloc, sizeof *d->newlines);
-      for (; oldalloc < d->tralloc; oldalloc++)
+      newalloc = --d->tralloc;
+      d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
+      d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
+      d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+      for (; oldalloc < newalloc; oldalloc++)
         {
           d->trans[oldalloc] = NULL;
           d->fails[oldalloc] = NULL;

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=689f51d3a2427134d6487d973757a1b7e38ec46c


commit 28f6eed8db830ec2a92a560ef25cc93c6361b12c
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 17 22:30:10 2014 -0700

    dfa: trans reallocation microoptimization
    
    * src/dfa.c (realloc_trans_if_necessary):
    Help the compiler avoid unnecessary reloads.

diff --git a/src/dfa.c b/src/dfa.c
index 618a8bc..24355d8 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2799,19 +2799,20 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
 static void
 realloc_trans_if_necessary (struct dfa *d, state_num new_state)
 {
-  if (d->tralloc <= new_state)
+  state_num oldalloc = d->tralloc;
+  if (oldalloc <= new_state)
     {
       state_num **realtrans = d->trans ? d->trans - 1 : NULL;
-      state_num oldalloc = d->tralloc;
+      size_t newalloc;
       d->tralloc = new_state + 1;
       realtrans = x2nrealloc (realtrans, &d->tralloc, sizeof *realtrans);
       realtrans[0] = NULL;
       d->trans = realtrans + 1;
-      d->tralloc--;
-      d->fails = xnrealloc (d->fails, d->tralloc, sizeof *d->fails);
-      d->success = xnrealloc (d->success, d->tralloc, sizeof *d->success);
-      d->newlines = xnrealloc (d->newlines, d->tralloc, sizeof *d->newlines);
-      for (; oldalloc < d->tralloc; oldalloc++)
+      newalloc = --d->tralloc;
+      d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
+      d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
+      d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+      for (; oldalloc < newalloc; oldalloc++)
         {
           d->trans[oldalloc] = NULL;
           d->fails[oldalloc] = NULL;

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=78d62ecc5a4e90c398dae525e9d74b78badf7060


commit 28f6eed8db830ec2a92a560ef25cc93c6361b12c
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 17 22:30:10 2014 -0700

    dfa: trans reallocation microoptimization
    
    * src/dfa.c (realloc_trans_if_necessary):
    Help the compiler avoid unnecessary reloads.

diff --git a/src/dfa.c b/src/dfa.c
index 618a8bc..24355d8 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2799,19 +2799,20 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
 static void
 realloc_trans_if_necessary (struct dfa *d, state_num new_state)
 {
-  if (d->tralloc <= new_state)
+  state_num oldalloc = d->tralloc;
+  if (oldalloc <= new_state)
     {
       state_num **realtrans = d->trans ? d->trans - 1 : NULL;
-      state_num oldalloc = d->tralloc;
+      size_t newalloc;
       d->tralloc = new_state + 1;
       realtrans = x2nrealloc (realtrans, &d->tralloc, sizeof *realtrans);
       realtrans[0] = NULL;
       d->trans = realtrans + 1;
-      d->tralloc--;
-      d->fails = xnrealloc (d->fails, d->tralloc, sizeof *d->fails);
-      d->success = xnrealloc (d->success, d->tralloc, sizeof *d->success);
-      d->newlines = xnrealloc (d->newlines, d->tralloc, sizeof *d->newlines);
-      for (; oldalloc < d->tralloc; oldalloc++)
+      newalloc = --d->tralloc;
+      d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
+      d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
+      d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+      for (; oldalloc < newalloc; oldalloc++)
         {
           d->trans[oldalloc] = NULL;
           d->fails[oldalloc] = NULL;

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=4dee094c29725f4492fe45b61588e6bbdbdd53f7


commit 28f6eed8db830ec2a92a560ef25cc93c6361b12c
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 17 22:30:10 2014 -0700

    dfa: trans reallocation microoptimization
    
    * src/dfa.c (realloc_trans_if_necessary):
    Help the compiler avoid unnecessary reloads.

diff --git a/src/dfa.c b/src/dfa.c
index 618a8bc..24355d8 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2799,19 +2799,20 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
 static void
 realloc_trans_if_necessary (struct dfa *d, state_num new_state)
 {
-  if (d->tralloc <= new_state)
+  state_num oldalloc = d->tralloc;
+  if (oldalloc <= new_state)
     {
       state_num **realtrans = d->trans ? d->trans - 1 : NULL;
-      state_num oldalloc = d->tralloc;
+      size_t newalloc;
       d->tralloc = new_state + 1;
       realtrans = x2nrealloc (realtrans, &d->tralloc, sizeof *realtrans);
       realtrans[0] = NULL;
       d->trans = realtrans + 1;
-      d->tralloc--;
-      d->fails = xnrealloc (d->fails, d->tralloc, sizeof *d->fails);
-      d->success = xnrealloc (d->success, d->tralloc, sizeof *d->success);
-      d->newlines = xnrealloc (d->newlines, d->tralloc, sizeof *d->newlines);
-      for (; oldalloc < d->tralloc; oldalloc++)
+      newalloc = --d->tralloc;
+      d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
+      d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
+      d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+      for (; oldalloc < newalloc; oldalloc++)
         {
           d->trans[oldalloc] = NULL;
           d->fails[oldalloc] = NULL;

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=c49f3cb06b6a917f69e945ba30eb21c641ce7085


commit 28f6eed8db830ec2a92a560ef25cc93c6361b12c
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 17 22:30:10 2014 -0700

    dfa: trans reallocation microoptimization
    
    * src/dfa.c (realloc_trans_if_necessary):
    Help the compiler avoid unnecessary reloads.

diff --git a/src/dfa.c b/src/dfa.c
index 618a8bc..24355d8 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2799,19 +2799,20 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
 static void
 realloc_trans_if_necessary (struct dfa *d, state_num new_state)
 {
-  if (d->tralloc <= new_state)
+  state_num oldalloc = d->tralloc;
+  if (oldalloc <= new_state)
     {
       state_num **realtrans = d->trans ? d->trans - 1 : NULL;
-      state_num oldalloc = d->tralloc;
+      size_t newalloc;
       d->tralloc = new_state + 1;
       realtrans = x2nrealloc (realtrans, &d->tralloc, sizeof *realtrans);
       realtrans[0] = NULL;
       d->trans = realtrans + 1;
-      d->tralloc--;
-      d->fails = xnrealloc (d->fails, d->tralloc, sizeof *d->fails);
-      d->success = xnrealloc (d->success, d->tralloc, sizeof *d->success);
-      d->newlines = xnrealloc (d->newlines, d->tralloc, sizeof *d->newlines);
-      for (; oldalloc < d->tralloc; oldalloc++)
+      newalloc = --d->tralloc;
+      d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
+      d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
+      d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+      for (; oldalloc < newalloc; oldalloc++)
         {
           d->trans[oldalloc] = NULL;
           d->fails[oldalloc] = NULL;

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=7cb640ae558d716820ce974e7e6b493399be815f


commit 28f6eed8db830ec2a92a560ef25cc93c6361b12c
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 17 22:30:10 2014 -0700

    dfa: trans reallocation microoptimization
    
    * src/dfa.c (realloc_trans_if_necessary):
    Help the compiler avoid unnecessary reloads.

diff --git a/src/dfa.c b/src/dfa.c
index 618a8bc..24355d8 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2799,19 +2799,20 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
 static void
 realloc_trans_if_necessary (struct dfa *d, state_num new_state)
 {
-  if (d->tralloc <= new_state)
+  state_num oldalloc = d->tralloc;
+  if (oldalloc <= new_state)
     {
       state_num **realtrans = d->trans ? d->trans - 1 : NULL;
-      state_num oldalloc = d->tralloc;
+      size_t newalloc;
       d->tralloc = new_state + 1;
       realtrans = x2nrealloc (realtrans, &d->tralloc, sizeof *realtrans);
       realtrans[0] = NULL;
       d->trans = realtrans + 1;
-      d->tralloc--;
-      d->fails = xnrealloc (d->fails, d->tralloc, sizeof *d->fails);
-      d->success = xnrealloc (d->success, d->tralloc, sizeof *d->success);
-      d->newlines = xnrealloc (d->newlines, d->tralloc, sizeof *d->newlines);
-      for (; oldalloc < d->tralloc; oldalloc++)
+      newalloc = --d->tralloc;
+      d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
+      d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
+      d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+      for (; oldalloc < newalloc; oldalloc++)
         {
           d->trans[oldalloc] = NULL;
           d->fails[oldalloc] = NULL;

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=a26989f8ee58569d2e732d67c6afca9fd88454c6


commit 28f6eed8db830ec2a92a560ef25cc93c6361b12c
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 17 22:30:10 2014 -0700

    dfa: trans reallocation microoptimization
    
    * src/dfa.c (realloc_trans_if_necessary):
    Help the compiler avoid unnecessary reloads.

diff --git a/src/dfa.c b/src/dfa.c
index 618a8bc..24355d8 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2799,19 +2799,20 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
 static void
 realloc_trans_if_necessary (struct dfa *d, state_num new_state)
 {
-  if (d->tralloc <= new_state)
+  state_num oldalloc = d->tralloc;
+  if (oldalloc <= new_state)
     {
       state_num **realtrans = d->trans ? d->trans - 1 : NULL;
-      state_num oldalloc = d->tralloc;
+      size_t newalloc;
       d->tralloc = new_state + 1;
       realtrans = x2nrealloc (realtrans, &d->tralloc, sizeof *realtrans);
       realtrans[0] = NULL;
       d->trans = realtrans + 1;
-      d->tralloc--;
-      d->fails = xnrealloc (d->fails, d->tralloc, sizeof *d->fails);
-      d->success = xnrealloc (d->success, d->tralloc, sizeof *d->success);
-      d->newlines = xnrealloc (d->newlines, d->tralloc, sizeof *d->newlines);
-      for (; oldalloc < d->tralloc; oldalloc++)
+      newalloc = --d->tralloc;
+      d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
+      d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
+      d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+      for (; oldalloc < newalloc; oldalloc++)
         {
           d->trans[oldalloc] = NULL;
           d->fails[oldalloc] = NULL;

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=d3d96123274d519b18f56b68423c26c5474e79be


commit 28f6eed8db830ec2a92a560ef25cc93c6361b12c
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 17 22:30:10 2014 -0700

    dfa: trans reallocation microoptimization
    
    * src/dfa.c (realloc_trans_if_necessary):
    Help the compiler avoid unnecessary reloads.

diff --git a/src/dfa.c b/src/dfa.c
index 618a8bc..24355d8 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2799,19 +2799,20 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
 static void
 realloc_trans_if_necessary (struct dfa *d, state_num new_state)
 {
-  if (d->tralloc <= new_state)
+  state_num oldalloc = d->tralloc;
+  if (oldalloc <= new_state)
     {
       state_num **realtrans = d->trans ? d->trans - 1 : NULL;
-      state_num oldalloc = d->tralloc;
+      size_t newalloc;
       d->tralloc = new_state + 1;
       realtrans = x2nrealloc (realtrans, &d->tralloc, sizeof *realtrans);
       realtrans[0] = NULL;
       d->trans = realtrans + 1;
-      d->tralloc--;
-      d->fails = xnrealloc (d->fails, d->tralloc, sizeof *d->fails);
-      d->success = xnrealloc (d->success, d->tralloc, sizeof *d->success);
-      d->newlines = xnrealloc (d->newlines, d->tralloc, sizeof *d->newlines);
-      for (; oldalloc < d->tralloc; oldalloc++)
+      newalloc = --d->tralloc;
+      d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
+      d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
+      d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+      for (; oldalloc < newalloc; oldalloc++)
         {
           d->trans[oldalloc] = NULL;
           d->fails[oldalloc] = NULL;

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=730a5b80b211ee0ae40722f3924a1a6df7b67c72


commit 28f6eed8db830ec2a92a560ef25cc93c6361b12c
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 17 22:30:10 2014 -0700

    dfa: trans reallocation microoptimization
    
    * src/dfa.c (realloc_trans_if_necessary):
    Help the compiler avoid unnecessary reloads.

diff --git a/src/dfa.c b/src/dfa.c
index 618a8bc..24355d8 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2799,19 +2799,20 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
 static void
 realloc_trans_if_necessary (struct dfa *d, state_num new_state)
 {
-  if (d->tralloc <= new_state)
+  state_num oldalloc = d->tralloc;
+  if (oldalloc <= new_state)
     {
       state_num **realtrans = d->trans ? d->trans - 1 : NULL;
-      state_num oldalloc = d->tralloc;
+      size_t newalloc;
       d->tralloc = new_state + 1;
       realtrans = x2nrealloc (realtrans, &d->tralloc, sizeof *realtrans);
       realtrans[0] = NULL;
       d->trans = realtrans + 1;
-      d->tralloc--;
-      d->fails = xnrealloc (d->fails, d->tralloc, sizeof *d->fails);
-      d->success = xnrealloc (d->success, d->tralloc, sizeof *d->success);
-      d->newlines = xnrealloc (d->newlines, d->tralloc, sizeof *d->newlines);
-      for (; oldalloc < d->tralloc; oldalloc++)
+      newalloc = --d->tralloc;
+      d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
+      d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
+      d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+      for (; oldalloc < newalloc; oldalloc++)
         {
           d->trans[oldalloc] = NULL;
           d->fails[oldalloc] = NULL;

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=0a8b75ef73ae3e841f57d93802fbed1613eda3e2


commit 28f6eed8db830ec2a92a560ef25cc93c6361b12c
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 17 22:30:10 2014 -0700

    dfa: trans reallocation microoptimization
    
    * src/dfa.c (realloc_trans_if_necessary):
    Help the compiler avoid unnecessary reloads.

diff --git a/src/dfa.c b/src/dfa.c
index 618a8bc..24355d8 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2799,19 +2799,20 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
 static void
 realloc_trans_if_necessary (struct dfa *d, state_num new_state)
 {
-  if (d->tralloc <= new_state)
+  state_num oldalloc = d->tralloc;
+  if (oldalloc <= new_state)
     {
       state_num **realtrans = d->trans ? d->trans - 1 : NULL;
-      state_num oldalloc = d->tralloc;
+      size_t newalloc;
       d->tralloc = new_state + 1;
       realtrans = x2nrealloc (realtrans, &d->tralloc, sizeof *realtrans);
       realtrans[0] = NULL;
       d->trans = realtrans + 1;
-      d->tralloc--;
-      d->fails = xnrealloc (d->fails, d->tralloc, sizeof *d->fails);
-      d->success = xnrealloc (d->success, d->tralloc, sizeof *d->success);
-      d->newlines = xnrealloc (d->newlines, d->tralloc, sizeof *d->newlines);
-      for (; oldalloc < d->tralloc; oldalloc++)
+      newalloc = --d->tralloc;
+      d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
+      d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
+      d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+      for (; oldalloc < newalloc; oldalloc++)
         {
           d->trans[oldalloc] = NULL;
           d->fails[oldalloc] = NULL;

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=26cb9008c855fbda3bf7e0dc377d1f6e95a9e68e


commit 28f6eed8db830ec2a92a560ef25cc93c6361b12c
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 17 22:30:10 2014 -0700

    dfa: trans reallocation microoptimization
    
    * src/dfa.c (realloc_trans_if_necessary):
    Help the compiler avoid unnecessary reloads.

diff --git a/src/dfa.c b/src/dfa.c
index 618a8bc..24355d8 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2799,19 +2799,20 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
 static void
 realloc_trans_if_necessary (struct dfa *d, state_num new_state)
 {
-  if (d->tralloc <= new_state)
+  state_num oldalloc = d->tralloc;
+  if (oldalloc <= new_state)
     {
       state_num **realtrans = d->trans ? d->trans - 1 : NULL;
-      state_num oldalloc = d->tralloc;
+      size_t newalloc;
       d->tralloc = new_state + 1;
       realtrans = x2nrealloc (realtrans, &d->tralloc, sizeof *realtrans);
       realtrans[0] = NULL;
       d->trans = realtrans + 1;
-      d->tralloc--;
-      d->fails = xnrealloc (d->fails, d->tralloc, sizeof *d->fails);
-      d->success = xnrealloc (d->success, d->tralloc, sizeof *d->success);
-      d->newlines = xnrealloc (d->newlines, d->tralloc, sizeof *d->newlines);
-      for (; oldalloc < d->tralloc; oldalloc++)
+      newalloc = --d->tralloc;
+      d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
+      d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
+      d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+      for (; oldalloc < newalloc; oldalloc++)
         {
           d->trans[oldalloc] = NULL;
           d->fails[oldalloc] = NULL;

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=6a60fd53ef09c2403f7e70ceff2bbbc0f7325234


commit 28f6eed8db830ec2a92a560ef25cc93c6361b12c
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 17 22:30:10 2014 -0700

    dfa: trans reallocation microoptimization
    
    * src/dfa.c (realloc_trans_if_necessary):
    Help the compiler avoid unnecessary reloads.

diff --git a/src/dfa.c b/src/dfa.c
index 618a8bc..24355d8 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2799,19 +2799,20 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
 static void
 realloc_trans_if_necessary (struct dfa *d, state_num new_state)
 {
-  if (d->tralloc <= new_state)
+  state_num oldalloc = d->tralloc;
+  if (oldalloc <= new_state)
     {
       state_num **realtrans = d->trans ? d->trans - 1 : NULL;
-      state_num oldalloc = d->tralloc;
+      size_t newalloc;
       d->tralloc = new_state + 1;
       realtrans = x2nrealloc (realtrans, &d->tralloc, sizeof *realtrans);
       realtrans[0] = NULL;
       d->trans = realtrans + 1;
-      d->tralloc--;
-      d->fails = xnrealloc (d->fails, d->tralloc, sizeof *d->fails);
-      d->success = xnrealloc (d->success, d->tralloc, sizeof *d->success);
-      d->newlines = xnrealloc (d->newlines, d->tralloc, sizeof *d->newlines);
-      for (; oldalloc < d->tralloc; oldalloc++)
+      newalloc = --d->tralloc;
+      d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
+      d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
+      d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);
+      for (; oldalloc < newalloc; oldalloc++)
         {
           d->trans[oldalloc] = NULL;
           d->fails[oldalloc] = NULL;

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |  600 ++++++++++++++++++++++++-------------------------------------
 1 files changed, 236 insertions(+), 364 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Fri Apr 18 02:28:02 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Wb2HK-0001KP-7f
	for mharc-grep-commit@gnu.org; Fri, 18 Apr 2014 02:28:02 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:36273)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wb2HH-0001GQ-I9
	for grep-commit@gnu.org; Fri, 18 Apr 2014 02:28:01 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wb2HG-0004y9-9M
	for grep-commit@gnu.org; Fri, 18 Apr 2014 02:27:59 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:55903)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wb2HG-0004y3-48
	for grep-commit@gnu.org; Fri, 18 Apr 2014 02:27:58 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wb2HF-0007Ko-Bn
	for grep-commit@gnu.org; Fri, 18 Apr 2014 06:27:57 +0000
Date: Fri, 18 Apr 2014 06:27:57 +0000
Message-Id: <E1Wb2HF-0007Ko-Bn@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-79-g03aeb1c
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 28f6eed8db830ec2a92a560ef25cc93c6361b12c
X-Git-Newrev: 03aeb1cca6bab2577666a3ce63ffe4437755af38
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 18 Apr 2014 06:28:01 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  03aeb1cca6bab2577666a3ce63ffe4437755af38 (commit)
       via  42b14d981975f50ca949ffbc234fb798816ec22e (commit)
      from  28f6eed8db830ec2a92a560ef25cc93c6361b12c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=03aeb1cca6bab2577666a3ce63ffe4437755af38


commit 03aeb1cca6bab2577666a3ce63ffe4437755af38
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 17 23:26:49 2014 -0700

    dfa: minor cleanup
    
    * src/dfa.c (MAX): Remove; no longer used.

diff --git a/src/dfa.c b/src/dfa.c
index c53d109..eeca257 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -868,9 +868,6 @@ static wchar_t wctok;           /* Wide character representation of the current
 #ifndef MIN
 # define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
-#ifndef MAX
-# define MAX(a,b) ((a) < (b) ? (b) : (a))
-#endif
 
 /* The set of wchar_t values C such that there's a useful locale
    somewhere where C != towupper (C) && C != towlower (towupper (C)).
@@ -3103,9 +3100,9 @@ transit_state_consume_1char (struct dfa *d, state_num s,
   state_num s1, s2;
   status_transit_state rs = TRANSIT_STATE_DONE;
 
-  /* Check (input) match_lens, and initialize if it is NULL.  */
-  if (match_lens == NULL && d->states[s].mbps.nelem != 0)
-    match_lens = check_matching_with_multibyte_ops (d, s, (char const *) *pp, wc, mbclen);
+  if (! match_lens && d->states[s].mbps.nelem != 0)
+    match_lens = check_matching_with_multibyte_ops (d, s, (char const *) *pp,
+                                                    wc, mbclen);
 
   /* Calculate the state which can be reached from the state 's' by
      consuming 'mbclen' single bytes from the buffer.  */
@@ -3155,7 +3152,8 @@ transit_state (struct dfa *d, state_num s, unsigned char const **pp,
     {
       /* Note: caller must free the return value of this function.  */
       mbclen = mbs_to_wchar (d, &wc, (char const *) *pp, end - *pp, &mbs);
-      match_lens = check_matching_with_multibyte_ops (d, s, (char const *) *pp, wc, mbclen);
+      match_lens = check_matching_with_multibyte_ops (d, s, (char const *) *pp,
+                                                      wc, mbclen);
 
       for (i = 0; i < nelem; i++)
         /* Search the operator which match the longest string,

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=42b14d981975f50ca949ffbc234fb798816ec22e


commit 03aeb1cca6bab2577666a3ce63ffe4437755af38
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 17 23:26:49 2014 -0700

    dfa: minor cleanup
    
    * src/dfa.c (MAX): Remove; no longer used.

diff --git a/src/dfa.c b/src/dfa.c
index c53d109..eeca257 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -868,9 +868,6 @@ static wchar_t wctok;           /* Wide character representation of the current
 #ifndef MIN
 # define MIN(a,b) ((a) < (b) ? (a) : (b))
 #endif
-#ifndef MAX
-# define MAX(a,b) ((a) < (b) ? (b) : (a))
-#endif
 
 /* The set of wchar_t values C such that there's a useful locale
    somewhere where C != towupper (C) && C != towlower (towupper (C)).
@@ -3103,9 +3100,9 @@ transit_state_consume_1char (struct dfa *d, state_num s,
   state_num s1, s2;
   status_transit_state rs = TRANSIT_STATE_DONE;
 
-  /* Check (input) match_lens, and initialize if it is NULL.  */
-  if (match_lens == NULL && d->states[s].mbps.nelem != 0)
-    match_lens = check_matching_with_multibyte_ops (d, s, (char const *) *pp, wc, mbclen);
+  if (! match_lens && d->states[s].mbps.nelem != 0)
+    match_lens = check_matching_with_multibyte_ops (d, s, (char const *) *pp,
+                                                    wc, mbclen);
 
   /* Calculate the state which can be reached from the state 's' by
      consuming 'mbclen' single bytes from the buffer.  */
@@ -3155,7 +3152,8 @@ transit_state (struct dfa *d, state_num s, unsigned char const **pp,
     {
       /* Note: caller must free the return value of this function.  */
       mbclen = mbs_to_wchar (d, &wc, (char const *) *pp, end - *pp, &mbs);
-      match_lens = check_matching_with_multibyte_ops (d, s, (char const *) *pp, wc, mbclen);
+      match_lens = check_matching_with_multibyte_ops (d, s, (char const *) *pp,
+                                                      wc, mbclen);
 
       for (i = 0; i < nelem; i++)
         /* Search the operator which match the longest string,

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |  215 ++++++++++++++++++-------------------------------------------
 1 files changed, 63 insertions(+), 152 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Fri Apr 18 12:41:41 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WbBrB-0002aP-20
	for mharc-grep-commit@gnu.org; Fri, 18 Apr 2014 12:41:41 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:43292)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WbBr8-0002ZY-Ah
	for grep-commit@gnu.org; Fri, 18 Apr 2014 12:41:39 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WbBr7-0005Qc-46
	for grep-commit@gnu.org; Fri, 18 Apr 2014 12:41:38 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:33465)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WbBr6-0005OZ-WD
	for grep-commit@gnu.org; Fri, 18 Apr 2014 12:41:37 -0400
Received: from meyering by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <jim@meyering.net>) id 1WbBr6-0003Rq-2E
	for grep-commit@gnu.org; Fri, 18 Apr 2014 16:41:36 +0000
Date: Fri, 18 Apr 2014 16:41:36 +0000
Message-Id: <E1WbBr6-0003Rq-2E@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-80-g5190041
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 03aeb1cca6bab2577666a3ce63ffe4437755af38
X-Git-Newrev: 5190041fe515743ef4545abf287d243bc025c701
From: Jim Meyering <jim@meyering.net>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 18 Apr 2014 16:41:39 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  5190041fe515743ef4545abf287d243bc025c701 (commit)
      from  03aeb1cca6bab2577666a3ce63ffe4437755af38 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=5190041fe515743ef4545abf287d243bc025c701


commit 5190041fe515743ef4545abf287d243bc025c701
Author: Jim Meyering <meyering@fb.com>
Date:   Fri Apr 18 09:36:23 2014 -0700

    dfa: avoid new NULL dereference
    
    * src/dfa.c (dfa_charclass_index): Restore a "+ 1" mistakenly omitted
    during recent improvements.  Introduced in v2.18-66-g6a60fd5.

diff --git a/src/dfa.c b/src/dfa.c
index eeca257..8463762 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -643,7 +643,7 @@ dfa_charclass_index (struct dfa *d, charclass const s)
   for (i = 0; i < d->cindex; ++i)
     if (equal (s, d->charclasses[i]))
       return i;
-  d->charclasses = maybe_realloc (d->charclasses, d->cindex, &d->calloc,
+  d->charclasses = maybe_realloc (d->charclasses, d->cindex + 1, &d->calloc,
                                   sizeof *d->charclasses);
   ++d->cindex;
   copyset (s, d->charclasses[i]);

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Fri Apr 18 21:14:11 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WbJr9-0000cT-Bf
	for mharc-grep-commit@gnu.org; Fri, 18 Apr 2014 21:14:11 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:50527)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WbJr7-0000cC-0p
	for grep-commit@gnu.org; Fri, 18 Apr 2014 21:14:09 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WbJr6-0000Wq-0p
	for grep-commit@gnu.org; Fri, 18 Apr 2014 21:14:08 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:38141)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WbJr5-0000Wk-TY
	for grep-commit@gnu.org; Fri, 18 Apr 2014 21:14:07 -0400
Received: from meyering by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <jim@meyering.net>) id 1WbJr5-0002RE-F2
	for grep-commit@gnu.org; Sat, 19 Apr 2014 01:14:07 +0000
Date: Sat, 19 Apr 2014 01:14:07 +0000
Message-Id: <E1WbJr5-0002RE-F2@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-81-gf084979
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 5190041fe515743ef4545abf287d243bc025c701
X-Git-Newrev: f08497935213250eb1aba9604a5418f2f7c41880
From: Jim Meyering <jim@meyering.net>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 19 Apr 2014 01:14:10 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  f08497935213250eb1aba9604a5418f2f7c41880 (commit)
      from  5190041fe515743ef4545abf287d243bc025c701 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=f08497935213250eb1aba9604a5418f2f7c41880


commit f08497935213250eb1aba9604a5418f2f7c41880
Author: Jim Meyering <meyering@fb.com>
Date:   Fri Apr 18 10:12:28 2014 -0700

    maint: Revert "dfa: avoid new NULL dereference"
    
    This reverts commit 5190041fe515743ef4545abf287d243bc025c701.
    It was only a bug if one neglected to update to the latest gnulib.
    With the newer xn2realloc, there is no problem.

diff --git a/src/dfa.c b/src/dfa.c
index 8463762..eeca257 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -643,7 +643,7 @@ dfa_charclass_index (struct dfa *d, charclass const s)
   for (i = 0; i < d->cindex; ++i)
     if (equal (s, d->charclasses[i]))
       return i;
-  d->charclasses = maybe_realloc (d->charclasses, d->cindex + 1, &d->calloc,
+  d->charclasses = maybe_realloc (d->charclasses, d->cindex, &d->calloc,
                                   sizeof *d->charclasses);
   ++d->cindex;
   copyset (s, d->charclasses[i]);

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Sat Apr 19 02:18:20 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WbObU-0007FX-9G
	for mharc-grep-commit@gnu.org; Sat, 19 Apr 2014 02:18:20 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:55412)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WbObR-0007Ea-Kk
	for grep-commit@gnu.org; Sat, 19 Apr 2014 02:18:18 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WbObN-0000Pg-EJ
	for grep-commit@gnu.org; Sat, 19 Apr 2014 02:18:17 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:40495)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WbObN-0000Pc-B4
	for grep-commit@gnu.org; Sat, 19 Apr 2014 02:18:13 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WbObM-0001SL-Kj
	for grep-commit@gnu.org; Sat, 19 Apr 2014 06:18:12 +0000
Date: Sat, 19 Apr 2014 06:18:12 +0000
Message-Id: <E1WbObM-0001SL-Kj@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-82-gee163d8
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: f08497935213250eb1aba9604a5418f2f7c41880
X-Git-Newrev: ee163d8f5ae541bdaab0f2d23826c7e4e275846b
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 19 Apr 2014 06:18:19 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  ee163d8f5ae541bdaab0f2d23826c7e4e275846b (commit)
      from  f08497935213250eb1aba9604a5418f2f7c41880 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=ee163d8f5ae541bdaab0f2d23826c7e4e275846b


commit ee163d8f5ae541bdaab0f2d23826c7e4e275846b
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Fri Apr 18 23:17:41 2014 -0700

    dfa: fix pointer type conversion bug
    
    The code converted between size_t * and ptrdiff_t *, which wasn't
    diagnosed by modern x86-64 GCC but isn't portable.  Problem
    reported by Norihiro Tanaka in <http://bugs.gnu.org/17136#31>.
    * configure.ac (WERROR_CFLAGS): Don't add -Wno-pointer-sign.
    We want GCC to diagnose pointer signedness problems, as they
    violate the C standard and other compilers no doubt complain too.
    * src/dfa.c (struct dfa): Change type of salloc to size_t.
    (realloc_trans_if_necessary): Convert signed value to size_t before
    passing its address to x2nrealloc.  Changing the type of tralloc
    to size_t might have led to problems elsewhere.

diff --git a/configure.ac b/configure.ac
index 886449b..17a8920 100644
--- a/configure.ac
+++ b/configure.ac
@@ -145,7 +145,6 @@ if test "$gl_gcc_warnings" = yes; then
   done
   gl_WARN_ADD([-Wno-missing-field-initializers]) # We need this one
   gl_WARN_ADD([-Wno-sign-compare])     # Too many warnings for now
-  gl_WARN_ADD([-Wno-pointer-sign])     # Too many warnings for now
   gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
 
   # In spite of excluding -Wlogical-op above, it is enabled, as of
diff --git a/src/dfa.c b/src/dfa.c
index eeca257..90cf4a9 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -378,7 +378,7 @@ struct dfa
   /* Fields filled by the state builder.  */
   dfa_state *states;            /* States of the dfa.  */
   state_num sindex;             /* Index for adding new states.  */
-  state_num salloc;             /* Number of states currently allocated.  */
+  size_t salloc;		/* Number of states currently allocated.  */
 
   /* Fields filled by the parse tree->NFA conversion.  */
   position_set *follows;        /* Array of follow sets, indexed by position
@@ -2780,12 +2780,12 @@ realloc_trans_if_necessary (struct dfa *d, state_num new_state)
   if (oldalloc <= new_state)
     {
       state_num **realtrans = d->trans ? d->trans - 1 : NULL;
-      size_t newalloc;
-      d->tralloc = new_state + 1;
-      realtrans = x2nrealloc (realtrans, &d->tralloc, sizeof *realtrans);
+      size_t newalloc, newalloc1;
+      newalloc1 = new_state + 1;
+      realtrans = x2nrealloc (realtrans, &newalloc1, sizeof *realtrans);
       realtrans[0] = NULL;
       d->trans = realtrans + 1;
-      newalloc = --d->tralloc;
+      d->tralloc = newalloc = newalloc1 - 1;
       d->fails = xnrealloc (d->fails, newalloc, sizeof *d->fails);
       d->success = xnrealloc (d->success, newalloc, sizeof *d->success);
       d->newlines = xnrealloc (d->newlines, newalloc, sizeof *d->newlines);

-----------------------------------------------------------------------

Summary of changes:
 configure.ac |    1 -
 src/dfa.c    |   10 +++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Sat Apr 19 17:21:59 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Wbchz-0007h2-Fe
	for mharc-grep-commit@gnu.org; Sat, 19 Apr 2014 17:21:59 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:49537)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1Wbchx-0007gr-2I
	for grep-commit@gnu.org; Sat, 19 Apr 2014 17:21:58 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1Wbchv-0001Ks-U2
	for grep-commit@gnu.org; Sat, 19 Apr 2014 17:21:57 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:48055)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1Wbchv-0001Ko-Px
	for grep-commit@gnu.org; Sat, 19 Apr 2014 17:21:55 -0400
Received: from meyering by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <jim@meyering.net>) id 1Wbchv-0002fW-9Z
	for grep-commit@gnu.org; Sat, 19 Apr 2014 21:21:55 +0000
Date: Sat, 19 Apr 2014 21:21:55 +0000
Message-Id: <E1Wbchv-0002fW-9Z@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-83-gd65dcf3
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: ee163d8f5ae541bdaab0f2d23826c7e4e275846b
X-Git-Newrev: d65dcf39f3d587027cccb6c7de6d7d70fb336e56
From: Jim Meyering <jim@meyering.net>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sat, 19 Apr 2014 21:21:58 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  d65dcf39f3d587027cccb6c7de6d7d70fb336e56 (commit)
      from  ee163d8f5ae541bdaab0f2d23826c7e4e275846b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=d65dcf39f3d587027cccb6c7de6d7d70fb336e56


commit d65dcf39f3d587027cccb6c7de6d7d70fb336e56
Author: Jim Meyering <meyering@fb.com>
Date:   Sat Apr 19 08:23:14 2014 -0700

    build: reenable some compiler warning options

diff --git a/configure.ac b/configure.ac
index 17a8920..6a99c40 100644
--- a/configure.ac
+++ b/configure.ac
@@ -114,29 +114,12 @@ if test "$gl_gcc_warnings" = yes; then
   nw="$nw -Wlong-long"              # C90 is anachronistic (lib/gethrxtime.h)
   nw="$nw -Wc++-compat"             # We don't care about C++ compilers
   nw="$nw -Wundef"                  # Warns on '#if GNULIB_FOO' etc in gnulib
-  nw="$nw -Wtraditional"            # Warns on #elif which we use often
-  nw="$nw -Wcast-qual"              # Too many warnings for now
-  nw="$nw -Wconversion"             # Too many warnings for now
   nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
-  nw="$nw -Wsign-conversion"        # Too many warnings for now
-  nw="$nw -Wtraditional-conversion" # Too many warnings for now
-  nw="$nw -Wunreachable-code"       # Too many warnings for now
   nw="$nw -Wpadded"                 # Our structs are not padded
-  nw="$nw -Wredundant-decls"        # openat.h declares e.g., mkdirat
-  nw="$nw -Wlogical-op"             # any use of fwrite provokes this
-  nw="$nw -Wformat-nonliteral"      # who.c and pinky.c strftime uses
   nw="$nw -Wvla"                    # warnings in gettext.h
-  nw="$nw -Wnested-externs"         # use of XARGMATCH/verify_function__
-  nw="$nw -Wswitch-enum"            # Too many warnings for now
   nw="$nw -Wswitch-default"         # Too many warnings for now
-  nw="$nw -Wstack-protector"        # not worth working around
-  # things I might fix soon:
-  nw="$nw -Wfloat-equal"            # sort.c, seq.c
-  nw="$nw -Wmissing-format-attribute" # copy.c
-  nw="$nw -Wunsafe-loop-optimizations" # a few src/*.c
-  nw="$nw -Winline"                 # system.h's readdir_ignoring_dot_and_dotdot
-  nw="$nw -Wstrict-overflow"        # expr.c, pr.c, tr.c, factor.c
-  # ?? -Wstrict-overflow
+  nw="$nw -Winline"                 # streq.h's streq4, streq6 and strcaseeq6
+  nw="$nw -Wstrict-overflow"        # regexec.c
 
   gl_MANYWARN_ALL_GCC([ws])
   gl_MANYWARN_COMPLEMENT([ws], [$ws], [$nw])
@@ -166,12 +149,7 @@ if test "$gl_gcc_warnings" = yes; then
   # We use a slightly smaller set of warning options for lib/.
   # Remove the following and save the result in GNULIB_WARN_CFLAGS.
   nw=
-  #nw="$nw -Wuninitialized"
   nw="$nw -Wunused-macros"
-  #nw="$nw -Wmissing-prototypes"
-  nw="$nw -Wold-style-definition"
-  nw="$nw -Wcast-align"
-  nw="$nw -Wunsuffixed-float-constants"
   gl_WARN_ADD([-Wno-format-nonliteral])
   gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
   AC_SUBST([GNULIB_WARN_CFLAGS])

-----------------------------------------------------------------------

Summary of changes:
 configure.ac |   26 ++------------------------
 1 files changed, 2 insertions(+), 24 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Mon Apr 21 02:20:30 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Wc7ag-0001ZI-NO
	for mharc-grep-commit@gnu.org; Mon, 21 Apr 2014 02:20:30 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34048)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wc7ad-0001W9-H8
	for grep-commit@gnu.org; Mon, 21 Apr 2014 02:20:29 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wc7ac-0000OG-7C
	for grep-commit@gnu.org; Mon, 21 Apr 2014 02:20:27 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:36975)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wc7ac-0000OC-3k
	for grep-commit@gnu.org; Mon, 21 Apr 2014 02:20:26 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wc7aa-0000u1-Uk
	for grep-commit@gnu.org; Mon, 21 Apr 2014 06:20:25 +0000
Date: Mon, 21 Apr 2014 06:20:25 +0000
Message-Id: <E1Wc7aa-0000u1-Uk@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-84-g9276ef4
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d65dcf39f3d587027cccb6c7de6d7d70fb336e56
X-Git-Newrev: 9276ef47ee5aa4a90908c89b9b1caf46415a8b53
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 21 Apr 2014 06:20:29 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  9276ef47ee5aa4a90908c89b9b1caf46415a8b53 (commit)
      from  d65dcf39f3d587027cccb6c7de6d7d70fb336e56 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=9276ef47ee5aa4a90908c89b9b1caf46415a8b53


commit 9276ef47ee5aa4a90908c89b9b1caf46415a8b53
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sun Apr 20 23:18:56 2014 -0700

    dfa: fix bug that caused NUL to be mishandled in patterns
    
    This bug was introduced in the early-2012 patches that fixed some
    context-handling bugs.  Bisecting found commit
    d8951d3f4e1bbd564809aa8e713d8333bda2f802 (2012-02-05 18:00:43 +0100),
    but it apears the underlying problem was introduced in commit
    8b47c4cf6556933f59226c234b0fe984f6c77dc7 (2012-01-03 11:22:09 +0100).
    * NEWS: Mention bug fix.
    * src/dfa.c (char_context): Consider NUL to be a newline only if -z.
    * tests/Makefile.am (TESTS): Add null-byte.
    * tests/null-byte: New file.

diff --git a/NEWS b/NEWS
index 92ce95e..fbb782b 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,9 @@ GNU grep NEWS                                    -*- outline -*-
   grep no longer mishandles an empty pattern at the end of a pattern list.
   [bug introduced in grep-2.5]
 
+  grep -f no longer mishandles patterns containing NUL bytes.
+  [bug introduced in grep-2.11]
+
   grep -P now works with -w and -x and backreferences. Before,
   echo aa|grep -Pw '(.)\1' would fail to match, yet
   echo aa|grep -Pw '(.)\2' would match.
diff --git a/src/dfa.c b/src/dfa.c
index 90cf4a9..c93f451 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -694,7 +694,7 @@ static charclass newline;
 static int
 char_context (unsigned char c)
 {
-  if (c == eolbyte || c == 0)
+  if (c == eolbyte)
     return CTX_NEWLINE;
   if (IS_WORD_CONSTITUENT (c))
     return CTX_LETTER;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cc79903..91775bd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -76,6 +76,7 @@ TESTS =						\
   max-count-vs-context				\
   mb-non-UTF8-performance			\
   multibyte-white-space				\
+  null-byte					\
   empty-line-mb					\
   unibyte-bracket-expr				\
   unibyte-negated-circumflex			\
diff --git a/tests/null-byte b/tests/null-byte
new file mode 100755
index 0000000..c967dbc
--- /dev/null
+++ b/tests/null-byte
@@ -0,0 +1,52 @@
+#!/bin/sh
+# Test NUL bytes in patterns and data.
+
+# Copyright 2014 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
+
+# Add "." to PATH for the use of get-mb-cur-max.
+path_prepend_ .
+
+locales=C
+for locale in en_US.iso885915 en_US.UTF-8; do
+  get-mb-cur-max en_US.UTF-8 >/dev/null 2>&1 && locales="$locales $locale"
+done
+
+fail=0
+
+for left in '' a '#' '\0'; do
+  for right in '' b '#' '\0'; do
+    data="$left\\0$right"
+    printf "$data\\n" >in || framework_failure_
+    for hat in '' '^'; do
+      for dollar in '' '$'; do
+        for force_regex in '' '\\(\\)\\1'; do
+          pat="$hat$force_regex$data$dollar"
+          printf "$pat\\n" >pat || framework_failure_
+          for locale in $locales; do
+            LC_ALL=$locale grep -f pat in ||
+              fail_ "'$pat' does not match '$data'"
+            LC_ALL=$locale grep -a -f pat in | cmp -s - in ||
+              fail_ "-a '$pat' does not match '$data'"
+          done
+        done
+      done
+    done
+  done
+done
+
+Exit $fail

-----------------------------------------------------------------------

Summary of changes:
 NEWS              |    3 +++
 src/dfa.c         |    2 +-
 tests/Makefile.am |    1 +
 tests/null-byte   |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 57 insertions(+), 1 deletions(-)
 create mode 100755 tests/null-byte


hooks/post-receive
-- 
grep


From MAILER-DAEMON Mon Apr 21 10:55:50 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WcFdO-0006zB-6P
	for mharc-grep-commit@gnu.org; Mon, 21 Apr 2014 10:55:50 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34089)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WcFdL-0006xK-Is
	for grep-commit@gnu.org; Mon, 21 Apr 2014 10:55:49 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WcFdJ-0008Bc-MH
	for grep-commit@gnu.org; Mon, 21 Apr 2014 10:55:47 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:42328)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WcFdJ-0008BY-4q
	for grep-commit@gnu.org; Mon, 21 Apr 2014 10:55:45 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WcFdI-0007sS-GZ
	for grep-commit@gnu.org; Mon, 21 Apr 2014 14:55:44 +0000
Date: Mon, 21 Apr 2014 14:55:44 +0000
Message-Id: <E1WcFdI-0007sS-GZ@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-86-ge403616
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 9276ef47ee5aa4a90908c89b9b1caf46415a8b53
X-Git-Newrev: e40361683cdc703121cdd51ffd3e189388b6f9a4
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 21 Apr 2014 14:55:49 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  e40361683cdc703121cdd51ffd3e189388b6f9a4 (commit)
       via  2c94326bd94a1ff46fe54cbd0596dd5d669d1b38 (commit)
      from  9276ef47ee5aa4a90908c89b9b1caf46415a8b53 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=e40361683cdc703121cdd51ffd3e189388b6f9a4


commit e40361683cdc703121cdd51ffd3e189388b6f9a4
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Mon Apr 21 07:27:14 2014 -0700

    dfa: minor improvements to previous patch
    
    * src/dfa.c (dfamust): Use &=, not if-then.
    * src/dfa.h (struct dfamust):
    * src/dfasearch.c (begline, hwsmusts): Use bool for boolean.
    * src/dfasearch.c (kwsmusts):
    * src/kwsearch.c (Fcompile): Prefer decls after statements.
    * src/dfasearch.c (kwsmusts): Avoid conditional branch.
    * src/kwsearch.c (Fcompile): Unify the two calls to kwsincr.

diff --git a/src/dfa.c b/src/dfa.c
index 0a6f061..65fc03d 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3916,10 +3916,8 @@ dfamust (struct dfa *d)
             /* Guaranteed to be.  Unlikely, but ...  */
             if (!STREQ (lmp->is, rmp->is))
               lmp->is[0] = '\0';
-            if (lmp->begline)
-              lmp->begline = rmp->begline;
-            if (lmp->endline)
-              lmp->endline = rmp->endline;
+            lmp->begline &= rmp->begline;
+            lmp->endline &= rmp->endline;
             /* Left side--easy */
             i = 0;
             while (lmp->left[i] != '\0' && lmp->left[i] == rmp->left[i])
diff --git a/src/dfa.h b/src/dfa.h
index 3829e6a..60aff11 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -19,15 +19,16 @@
 /* Written June, 1988 by Mike Haertel */
 
 #include <regex.h>
+#include <stdbool.h>
 #include <stddef.h>
 
 /* Element of a list of strings, at least one of which is known to
    appear in any R.E. matching the DFA. */
 struct dfamust
 {
-  int exact;
-  int begline;
-  int endline;
+  bool exact;
+  bool begline;
+  bool endline;
   char *must;
   struct dfamust *next;
 };
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 34c4505..dc76397 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -51,7 +51,7 @@ static size_t pcount;
    call the regexp matcher at all. */
 static size_t kwset_exact_matches;
 
-static int begline;
+static bool begline;
 
 void
 dfaerror (char const *mesg)
@@ -87,25 +87,21 @@ kwsmusts (void)
   if (dm)
     {
       kwsinit (&kwset);
-      begline = 0;
       /* First, we compile in the substrings known to be exact
          matches.  The kwset matcher will return the index
          of the matching string that it chooses. */
       for (; dm; dm = dm->next)
         {
-          char *must, *mp;
-          size_t old_len, new_len;
           if (!dm->exact)
             continue;
           ++kwset_exact_matches;
-          old_len = strlen (dm->must);
-          new_len = old_len + dm->begline + dm->endline;
-          must = mp = xmalloc (new_len);
-          if (dm->begline)
-            {
-              (mp++)[0] = eolbyte;
-              begline = 1;
-            }
+          size_t old_len = strlen (dm->must);
+          size_t new_len = old_len + dm->begline + dm->endline;
+          char *must = xmalloc (new_len);
+          char *mp = must;
+          *mp = eolbyte;
+          mp += dm->begline;
+          begline |= dm->begline;
           memcpy (mp, dm->must, old_len);
           if (dm->endline)
             mp[old_len] = eolbyte;
diff --git a/src/kwsearch.c b/src/kwsearch.c
index 9904bfe..7c64c86 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -57,16 +57,19 @@ Fcompile (char const *pattern, size_t size)
           total = 0;
         }
 
+      char *buf = NULL;
       if (match_lines)
         {
-          char *buf = xmalloc (len + 2);
-          memcpy (&buf[1], p, len);
-          buf[0] = buf[len + 1] = eolbyte;
-          kwsincr (kwset, buf, len + 2);
-          free (buf);
+          buf = xmalloc (len + 2);
+          buf[0] = eolbyte;
+          memcpy (buf + 1, p, len);
+          buf[len + 1] = eolbyte;
+          p = buf;
+          len += 2;
         }
-      else
-        kwsincr (kwset, p, len);
+      kwsincr (kwset, p, len);
+      free (buf);
+
       p = sep;
     }
   while (p);

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=2c94326bd94a1ff46fe54cbd0596dd5d669d1b38


commit e40361683cdc703121cdd51ffd3e189388b6f9a4
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Mon Apr 21 07:27:14 2014 -0700

    dfa: minor improvements to previous patch
    
    * src/dfa.c (dfamust): Use &=, not if-then.
    * src/dfa.h (struct dfamust):
    * src/dfasearch.c (begline, hwsmusts): Use bool for boolean.
    * src/dfasearch.c (kwsmusts):
    * src/kwsearch.c (Fcompile): Prefer decls after statements.
    * src/dfasearch.c (kwsmusts): Avoid conditional branch.
    * src/kwsearch.c (Fcompile): Unify the two calls to kwsincr.

diff --git a/src/dfa.c b/src/dfa.c
index 0a6f061..65fc03d 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3916,10 +3916,8 @@ dfamust (struct dfa *d)
             /* Guaranteed to be.  Unlikely, but ...  */
             if (!STREQ (lmp->is, rmp->is))
               lmp->is[0] = '\0';
-            if (lmp->begline)
-              lmp->begline = rmp->begline;
-            if (lmp->endline)
-              lmp->endline = rmp->endline;
+            lmp->begline &= rmp->begline;
+            lmp->endline &= rmp->endline;
             /* Left side--easy */
             i = 0;
             while (lmp->left[i] != '\0' && lmp->left[i] == rmp->left[i])
diff --git a/src/dfa.h b/src/dfa.h
index 3829e6a..60aff11 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -19,15 +19,16 @@
 /* Written June, 1988 by Mike Haertel */
 
 #include <regex.h>
+#include <stdbool.h>
 #include <stddef.h>
 
 /* Element of a list of strings, at least one of which is known to
    appear in any R.E. matching the DFA. */
 struct dfamust
 {
-  int exact;
-  int begline;
-  int endline;
+  bool exact;
+  bool begline;
+  bool endline;
   char *must;
   struct dfamust *next;
 };
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 34c4505..dc76397 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -51,7 +51,7 @@ static size_t pcount;
    call the regexp matcher at all. */
 static size_t kwset_exact_matches;
 
-static int begline;
+static bool begline;
 
 void
 dfaerror (char const *mesg)
@@ -87,25 +87,21 @@ kwsmusts (void)
   if (dm)
     {
       kwsinit (&kwset);
-      begline = 0;
       /* First, we compile in the substrings known to be exact
          matches.  The kwset matcher will return the index
          of the matching string that it chooses. */
       for (; dm; dm = dm->next)
         {
-          char *must, *mp;
-          size_t old_len, new_len;
           if (!dm->exact)
             continue;
           ++kwset_exact_matches;
-          old_len = strlen (dm->must);
-          new_len = old_len + dm->begline + dm->endline;
-          must = mp = xmalloc (new_len);
-          if (dm->begline)
-            {
-              (mp++)[0] = eolbyte;
-              begline = 1;
-            }
+          size_t old_len = strlen (dm->must);
+          size_t new_len = old_len + dm->begline + dm->endline;
+          char *must = xmalloc (new_len);
+          char *mp = must;
+          *mp = eolbyte;
+          mp += dm->begline;
+          begline |= dm->begline;
           memcpy (mp, dm->must, old_len);
           if (dm->endline)
             mp[old_len] = eolbyte;
diff --git a/src/kwsearch.c b/src/kwsearch.c
index 9904bfe..7c64c86 100644
--- a/src/kwsearch.c
+++ b/src/kwsearch.c
@@ -57,16 +57,19 @@ Fcompile (char const *pattern, size_t size)
           total = 0;
         }
 
+      char *buf = NULL;
       if (match_lines)
         {
-          char *buf = xmalloc (len + 2);
-          memcpy (&buf[1], p, len);
-          buf[0] = buf[len + 1] = eolbyte;
-          kwsincr (kwset, buf, len + 2);
-          free (buf);
+          buf = xmalloc (len + 2);
+          buf[0] = eolbyte;
+          memcpy (buf + 1, p, len);
+          buf[len + 1] = eolbyte;
+          p = buf;
+          len += 2;
         }
-      else
-        kwsincr (kwset, p, len);
+      kwsincr (kwset, p, len);
+      free (buf);
+
       p = sep;
     }
   while (p);

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c       |   40 ++++++++++++++++++++++++++++++++++------
 src/dfa.h       |    5 ++++-
 src/dfasearch.c |   25 ++++++++++++++++++++-----
 src/kwsearch.c  |   29 ++++++++++++++++++-----------
 4 files changed, 76 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Mon Apr 21 13:52:32 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WcIOO-0004Bi-Ei
	for mharc-grep-commit@gnu.org; Mon, 21 Apr 2014 13:52:32 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:45796)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WcIOL-00043d-Le
	for grep-commit@gnu.org; Mon, 21 Apr 2014 13:52:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WcIOK-0003cr-5c
	for grep-commit@gnu.org; Mon, 21 Apr 2014 13:52:29 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:44775)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WcIOK-0003cl-1u
	for grep-commit@gnu.org; Mon, 21 Apr 2014 13:52:28 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WcIOJ-00057L-5r
	for grep-commit@gnu.org; Mon, 21 Apr 2014 17:52:27 +0000
Date: Mon, 21 Apr 2014 17:52:27 +0000
Message-Id: <E1WcIOJ-00057L-5r@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-87-gca7868c
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: e40361683cdc703121cdd51ffd3e189388b6f9a4
X-Git-Newrev: ca7868cc27db3d9deafaa2e0ac5a2bb0aa8ef373
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 21 Apr 2014 17:52:31 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  ca7868cc27db3d9deafaa2e0ac5a2bb0aa8ef373 (commit)
      from  e40361683cdc703121cdd51ffd3e189388b6f9a4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=ca7868cc27db3d9deafaa2e0ac5a2bb0aa8ef373


commit ca7868cc27db3d9deafaa2e0ac5a2bb0aa8ef373
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Mon Apr 21 10:51:16 2014 -0700

    grep: -P now rejects invalid input sequences in UTF-8 locales
    
    See <http://bugs.gnu.org/17245> and <http://bugs.exim.org/1468>.
    * NEWS: Document this.
    * src/pcresearch.c (Pexecute): Do not use PCRE_NO_UTF8_CHECK,
    as this leads to undefined behavior when the input is not UTF-8.
    * tests/pcre-infloop, tests/pcre-invalid-utf8-input:
    Exit status is now 2, not 1, when grep -P is given invalid UTF-8
    data in a UTF-8 locale.

diff --git a/NEWS b/NEWS
index fbb782b..2d3e12a 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,10 @@ GNU grep NEWS                                    -*- outline -*-
   grep -f no longer mishandles patterns containing NUL bytes.
   [bug introduced in grep-2.11]
 
+  grep -P now reports an error and exits when given invalid UTF-8 data.
+  Previously it was unreliable, and sometimes crashed or looped.
+  [bug introduced in grep-2.16]
+
   grep -P now works with -w and -x and backreferences. Before,
   echo aa|grep -Pw '(.)\1' would fail to match, yet
   echo aa|grep -Pw '(.)\2' would match.
diff --git a/src/pcresearch.c b/src/pcresearch.c
index a5e953f..9f63f37 100644
--- a/src/pcresearch.c
+++ b/src/pcresearch.c
@@ -52,19 +52,14 @@ Pcompile (char const *pattern, size_t size)
   int e;
   char const *ep;
   char *re = xnmalloc (4, size + 7);
-  int flags = PCRE_MULTILINE | (match_icase ? PCRE_CASELESS : 0);
+  int flags = (PCRE_MULTILINE
+               | (match_icase ? PCRE_CASELESS : 0)
+               | (using_utf8 () ? PCRE_UTF8 : 0));
   char const *patlim = pattern + size;
   char *n = re;
   char const *p;
   char const *pnul;
 
-  if (using_utf8 ())
-    {
-      /* Enable PCRE's UTF-8 matching.  Note also the use of
-         PCRE_NO_UTF8_CHECK when calling pcre_extra, below.   */
-      flags |= PCRE_UTF8;
-    }
-
   /* FIXME: Remove these restrictions.  */
   if (memchr (pattern, '\n', size))
     error (EXIT_TROUBLE, 0, _("the -P option only supports a single pattern"));
@@ -154,10 +149,6 @@ Pexecute (char const *buf, size_t size, size_t *match_size,
        e == PCRE_ERROR_NOMATCH && line_next < buf + size;
        start_ofs -= line_next - line_buf)
     {
-      /* Disable the check that would make an invalid byte
-         seqence *in the input* trigger a failure.   */
-      int options = PCRE_NO_UTF8_CHECK;
-
       line_buf = line_next;
       line_end = memchr (line_buf, eolbyte, (buf + size) - line_buf);
       if (line_end == NULL)
@@ -172,7 +163,7 @@ Pexecute (char const *buf, size_t size, size_t *match_size,
         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, options,
+                     start_ofs < 0 ? 0 : start_ofs, 0,
                      sub, sizeof sub / sizeof *sub);
     }
 
diff --git a/tests/pcre-infloop b/tests/pcre-infloop
index 57b67ae..febf356 100755
--- a/tests/pcre-infloop
+++ b/tests/pcre-infloop
@@ -28,6 +28,6 @@ printf 'a\201b\r' > in || framework_failure_
 fail=0
 
 LC_ALL=en_US.utf8 timeout 3 grep -P 'a.?..b' in
-test $? = 1 || fail_ "libpcre's match function appears to infloop"
+test $? = 2 || 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 ccf3caf..913e8ee 100755
--- a/tests/pcre-invalid-utf8-input
+++ b/tests/pcre-invalid-utf8-input
@@ -15,8 +15,7 @@ fail=0
 
 printf 'j\202\nj\n' > in || framework_failure_
 
-LC_ALL=en_US.UTF-8 grep -P j in > out 2>&1 || fail=1
-compare in out || fail=1
-compare /dev/null err || fail=1
+LC_ALL=en_US.UTF-8 grep -P j in
+test $? -eq 2 || fail=1
 
 Exit $fail

-----------------------------------------------------------------------

Summary of changes:
 NEWS                          |    4 ++++
 src/pcresearch.c              |   17 ++++-------------
 tests/pcre-infloop            |    2 +-
 tests/pcre-invalid-utf8-input |    5 ++---
 4 files changed, 11 insertions(+), 17 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Wed Apr 23 00:09:40 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WcoVA-00063o-1p
	for mharc-grep-commit@gnu.org; Wed, 23 Apr 2014 00:09:40 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:59511)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WcoV7-00063i-BB
	for grep-commit@gnu.org; Wed, 23 Apr 2014 00:09:39 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WcoV5-0005IR-LB
	for grep-commit@gnu.org; Wed, 23 Apr 2014 00:09:37 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:35238)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WcoV5-0005IN-GB
	for grep-commit@gnu.org; Wed, 23 Apr 2014 00:09:35 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WcoV5-0005Er-1K
	for grep-commit@gnu.org; Wed, 23 Apr 2014 04:09:35 +0000
Date: Wed, 23 Apr 2014 04:09:35 +0000
Message-Id: <E1WcoV5-0005Er-1K@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-89-gc7ea5ae
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: ca7868cc27db3d9deafaa2e0ac5a2bb0aa8ef373
X-Git-Newrev: c7ea5aea911b950b2398454ca89cce23cabd3a40
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 23 Apr 2014 04:09:39 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  c7ea5aea911b950b2398454ca89cce23cabd3a40 (commit)
       via  e2f3093e35da98b4cc1357ae63b5e0da26796128 (commit)
      from  ca7868cc27db3d9deafaa2e0ac5a2bb0aa8ef373 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=c7ea5aea911b950b2398454ca89cce23cabd3a40


commit c7ea5aea911b950b2398454ca89cce23cabd3a40
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Mon Apr 21 17:15:56 2014 -0700

    kwset: simplify Boyer-Moore with unibyte -i
    
    This change doesn't significantly affect performance on my platform,
    and should make the code easier to maintain.
    * src/kwset.c (BM_DELTA2_SEARCH, LAST_SHIFT, TRANS):
    Remove these macros, in favor of ...
    (tr, bm_delta2_search): New functions.  All uses changed.
    The latter function is inline because this improves code size and
    runtime CPU slightly on x86-64 with gcc -O2 (GCC 4.9.0).
    (bmexec): Prefer tr when that's simpler.

diff --git a/src/kwset.c b/src/kwset.c
index d212d59..69b0a55 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -464,75 +464,66 @@ kwsprep (kwset_t kwset)
       kwset->delta[i] = delta[U(trans[i])];
 }
 
-#define BM_DELTA2_SEARCH 				\
-  if (TRANS(tp[-2]) == gc2)				\
-    {							\
-      for (i = 3; i <= len; ++i)			\
-        if (TRANS(tp[-i]) != TRANS(sp[-i]))		\
-          break;					\
-      if (i > len)					\
-        return tp - len - text;				\
-      d = kwset->shift[i - 2]; tp += d;			\
-      if (tp > ep)					\
-        break;						\
-      if (TRANS(tp[-1]) != gc1)				\
-        {						\
-          d = d1[U(tp[-1])]; LAST_SHIFT;		\
-          continue;					\
-        }						\
-      skip = i - 1;					\
-    }							\
-  else							\
-    {							\
-      d = kwset->shift[0]; tp += d;			\
-      if (tp > ep)					\
-        break;						\
-      if (TRANS(tp[-1]) != gc1)				\
-        {						\
-          d = d1[U(tp[-1])]; LAST_SHIFT;		\
-          continue;					\
-        }						\
-      skip = 1;						\
-    }							\
-  while (true)						\
-    {							\
-      if (TRANS(tp[-2]) == gc2)				\
-        {						\
-          for (i = 3; i <= d; ++i)			\
-            if (TRANS(tp[-i]) != TRANS(sp[-i]))		\
-              break;					\
-          if (i > d)					\
-            {						\
-              for (i = d + skip + 1; i <= len; ++i)	\
-                if (TRANS(tp[-i]) != TRANS(sp[-i]))	\
-                  break;				\
-              if (i > len)				\
-                return tp - len - text;			\
-            }						\
-          d = kwset->shift[i - 2]; tp += d;		\
-          if (tp > ep)					\
-            break;					\
-          if (TRANS(tp[-1]) != gc1)			\
-            {						\
-              d = d1[U(tp[-1])]; LAST_SHIFT;		\
-              break;					\
-            }						\
-          skip = i - 1;					\
-        }						\
-      else						\
-        {						\
-          d = kwset->shift[0]; tp += d;			\
-          if (tp > ep)					\
-            break;					\
-          if (TRANS(tp[-1]) != gc1)			\
-            {						\
-              d = d1[U(tp[-1])]; LAST_SHIFT;		\
-              break;					\
-            }						\
-          skip = 1;					\
-        }						\
+/* Use TRANS to transliterate C.  A null TRANS does no transliteration.  */
+static char
+tr (char const *trans, char c)
+{
+  return trans ? trans[U(c)] : c;
+}
+
+/* Delta2 portion of a Boyer-Moore search.  *TP is the string text
+   pointer; it is updated in place.  EP is the end of the string text,
+   and SP the end of the pattern.  LEN is the pattern length; it must
+   be at least 2.  TRANS, if nonnull, is the input translation table.
+   GC1 and GC2 are the last and second-from last bytes of the pattern,
+   transliterated by TRANS; the caller precomputes them for
+   efficiency.  If D1 is nonnull, it is a delta1 table for shifting *TP
+   when failing.  KWSET->shift says how much to shift.  */
+static inline bool
+bm_delta2_search (char const **tpp, char const *ep, char const *sp, int len,
+                  char const *trans, char gc1, char gc2,
+                  unsigned char const *d1, kwset_t kwset)
+{
+  char const *tp = *tpp;
+  int d = len, skip = 0;
+
+  while (true)
+    {
+      int i = 2;
+      if (tr (trans, tp[-2]) == gc2)
+        {
+          while (++i <= d)
+            if (tr (trans, tp[-i]) != tr (trans, sp[-i]))
+              break;
+          if (i > d)
+            {
+              for (i = d + skip + 1; i <= len; ++i)
+                if (tr (trans, tp[-i]) != tr (trans, sp[-i]))
+                  break;
+              if (i > len)
+                {
+                  *tpp = tp - len;
+                  return true;
+                }
+            }
+        }
+
+      tp += d = kwset->shift[i - 2];
+      if (tp > ep)
+        break;
+      if (tr (trans, tp[-1]) != gc1)
+        {
+          if (d1)
+            tp += d1[U(tp[-1])];
+          break;
+        }
+      skip = i - 1;
     }
 
+  *tpp = tp;
+  return false;
+}
+
 
 /* Fast boyer-moore search. */
 static size_t _GL_ATTRIBUTE_PURE
@@ -540,8 +531,7 @@ bmexec (kwset_t kwset, char const *text, size_t size)
 {
   unsigned char const *d1;
   char const *ep, *sp, *tp;
-  int d, i, skip;
-  char gc1, gc2;
+  int d;
   int len = kwset->mind;
   char const *trans = kwset->trans;
 
@@ -568,17 +558,8 @@ bmexec (kwset_t kwset, char const *text, size_t size)
   d1 = kwset->delta;
   sp = kwset->target + len;
   tp = text + len;
-  if (trans)
-    {
-      gc1 = trans[U(sp[-1])];
-      gc2 = trans[U(sp[-2])];
-    }
-  else
-    {
-      gc1 = sp[-1];
-      gc2 = sp[-2];
-    }
-  skip = 0;
+  char gc1 = tr (trans, sp[-1]);
+  char gc2 = tr (trans, sp[-2]);
 
   /* Significance of 12: 1 (initial offset) + 10 (skip loop) + 1 (md2). */
   if (size > 12 * len)
@@ -606,20 +587,8 @@ bmexec (kwset_t kwset, char const *text, size_t size)
           }
         break;
       found:
-#undef LAST_SHIFT
-#define LAST_SHIFT tp += d
-        if (trans)
-          {
-#undef TRANS
-#define TRANS(ch) trans[U(ch)]
-            BM_DELTA2_SEARCH;
-          }
-        else
-          {
-#undef TRANS
-#define TRANS(ch) ch
-            BM_DELTA2_SEARCH;
-          }
+        if (bm_delta2_search (&tp, ep, sp, len, trans, gc1, gc2, d1, kwset))
+          return tp - text;
       }
 
   /* Now we have only a few characters left to search.  We
@@ -631,20 +600,8 @@ bmexec (kwset_t kwset, char const *text, size_t size)
       d = d1[U((tp += d)[-1])];
       if (d != 0)
         continue;
-#undef LAST_SHIFT
-#define LAST_SHIFT
-      if (trans)
-        {
-#undef TRANS
-#define TRANS(ch) trans[U(ch)]
-          BM_DELTA2_SEARCH;
-        }
-      else
-        {
-#undef TRANS
-#define TRANS(ch) ch
-          BM_DELTA2_SEARCH;
-        }
+      if (bm_delta2_search (&tp, ep, sp, len, trans, gc1, gc2, NULL, kwset))
+        return tp - text;
     }
 
   return -1;

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=e2f3093e35da98b4cc1357ae63b5e0da26796128


commit c7ea5aea911b950b2398454ca89cce23cabd3a40
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Mon Apr 21 17:15:56 2014 -0700

    kwset: simplify Boyer-Moore with unibyte -i
    
    This change doesn't significantly affect performance on my platform,
    and should make the code easier to maintain.
    * src/kwset.c (BM_DELTA2_SEARCH, LAST_SHIFT, TRANS):
    Remove these macros, in favor of ...
    (tr, bm_delta2_search): New functions.  All uses changed.
    The latter function is inline because this improves code size and
    runtime CPU slightly on x86-64 with gcc -O2 (GCC 4.9.0).
    (bmexec): Prefer tr when that's simpler.

diff --git a/src/kwset.c b/src/kwset.c
index d212d59..69b0a55 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -464,75 +464,66 @@ kwsprep (kwset_t kwset)
       kwset->delta[i] = delta[U(trans[i])];
 }
 
-#define BM_DELTA2_SEARCH 				\
-  if (TRANS(tp[-2]) == gc2)				\
-    {							\
-      for (i = 3; i <= len; ++i)			\
-        if (TRANS(tp[-i]) != TRANS(sp[-i]))		\
-          break;					\
-      if (i > len)					\
-        return tp - len - text;				\
-      d = kwset->shift[i - 2]; tp += d;			\
-      if (tp > ep)					\
-        break;						\
-      if (TRANS(tp[-1]) != gc1)				\
-        {						\
-          d = d1[U(tp[-1])]; LAST_SHIFT;		\
-          continue;					\
-        }						\
-      skip = i - 1;					\
-    }							\
-  else							\
-    {							\
-      d = kwset->shift[0]; tp += d;			\
-      if (tp > ep)					\
-        break;						\
-      if (TRANS(tp[-1]) != gc1)				\
-        {						\
-          d = d1[U(tp[-1])]; LAST_SHIFT;		\
-          continue;					\
-        }						\
-      skip = 1;						\
-    }							\
-  while (true)						\
-    {							\
-      if (TRANS(tp[-2]) == gc2)				\
-        {						\
-          for (i = 3; i <= d; ++i)			\
-            if (TRANS(tp[-i]) != TRANS(sp[-i]))		\
-              break;					\
-          if (i > d)					\
-            {						\
-              for (i = d + skip + 1; i <= len; ++i)	\
-                if (TRANS(tp[-i]) != TRANS(sp[-i]))	\
-                  break;				\
-              if (i > len)				\
-                return tp - len - text;			\
-            }						\
-          d = kwset->shift[i - 2]; tp += d;		\
-          if (tp > ep)					\
-            break;					\
-          if (TRANS(tp[-1]) != gc1)			\
-            {						\
-              d = d1[U(tp[-1])]; LAST_SHIFT;		\
-              break;					\
-            }						\
-          skip = i - 1;					\
-        }						\
-      else						\
-        {						\
-          d = kwset->shift[0]; tp += d;			\
-          if (tp > ep)					\
-            break;					\
-          if (TRANS(tp[-1]) != gc1)			\
-            {						\
-              d = d1[U(tp[-1])]; LAST_SHIFT;		\
-              break;					\
-            }						\
-          skip = 1;					\
-        }						\
+/* Use TRANS to transliterate C.  A null TRANS does no transliteration.  */
+static char
+tr (char const *trans, char c)
+{
+  return trans ? trans[U(c)] : c;
+}
+
+/* Delta2 portion of a Boyer-Moore search.  *TP is the string text
+   pointer; it is updated in place.  EP is the end of the string text,
+   and SP the end of the pattern.  LEN is the pattern length; it must
+   be at least 2.  TRANS, if nonnull, is the input translation table.
+   GC1 and GC2 are the last and second-from last bytes of the pattern,
+   transliterated by TRANS; the caller precomputes them for
+   efficiency.  If D1 is nonnull, it is a delta1 table for shifting *TP
+   when failing.  KWSET->shift says how much to shift.  */
+static inline bool
+bm_delta2_search (char const **tpp, char const *ep, char const *sp, int len,
+                  char const *trans, char gc1, char gc2,
+                  unsigned char const *d1, kwset_t kwset)
+{
+  char const *tp = *tpp;
+  int d = len, skip = 0;
+
+  while (true)
+    {
+      int i = 2;
+      if (tr (trans, tp[-2]) == gc2)
+        {
+          while (++i <= d)
+            if (tr (trans, tp[-i]) != tr (trans, sp[-i]))
+              break;
+          if (i > d)
+            {
+              for (i = d + skip + 1; i <= len; ++i)
+                if (tr (trans, tp[-i]) != tr (trans, sp[-i]))
+                  break;
+              if (i > len)
+                {
+                  *tpp = tp - len;
+                  return true;
+                }
+            }
+        }
+
+      tp += d = kwset->shift[i - 2];
+      if (tp > ep)
+        break;
+      if (tr (trans, tp[-1]) != gc1)
+        {
+          if (d1)
+            tp += d1[U(tp[-1])];
+          break;
+        }
+      skip = i - 1;
     }
 
+  *tpp = tp;
+  return false;
+}
+
 
 /* Fast boyer-moore search. */
 static size_t _GL_ATTRIBUTE_PURE
@@ -540,8 +531,7 @@ bmexec (kwset_t kwset, char const *text, size_t size)
 {
   unsigned char const *d1;
   char const *ep, *sp, *tp;
-  int d, i, skip;
-  char gc1, gc2;
+  int d;
   int len = kwset->mind;
   char const *trans = kwset->trans;
 
@@ -568,17 +558,8 @@ bmexec (kwset_t kwset, char const *text, size_t size)
   d1 = kwset->delta;
   sp = kwset->target + len;
   tp = text + len;
-  if (trans)
-    {
-      gc1 = trans[U(sp[-1])];
-      gc2 = trans[U(sp[-2])];
-    }
-  else
-    {
-      gc1 = sp[-1];
-      gc2 = sp[-2];
-    }
-  skip = 0;
+  char gc1 = tr (trans, sp[-1]);
+  char gc2 = tr (trans, sp[-2]);
 
   /* Significance of 12: 1 (initial offset) + 10 (skip loop) + 1 (md2). */
   if (size > 12 * len)
@@ -606,20 +587,8 @@ bmexec (kwset_t kwset, char const *text, size_t size)
           }
         break;
       found:
-#undef LAST_SHIFT
-#define LAST_SHIFT tp += d
-        if (trans)
-          {
-#undef TRANS
-#define TRANS(ch) trans[U(ch)]
-            BM_DELTA2_SEARCH;
-          }
-        else
-          {
-#undef TRANS
-#define TRANS(ch) ch
-            BM_DELTA2_SEARCH;
-          }
+        if (bm_delta2_search (&tp, ep, sp, len, trans, gc1, gc2, d1, kwset))
+          return tp - text;
       }
 
   /* Now we have only a few characters left to search.  We
@@ -631,20 +600,8 @@ bmexec (kwset_t kwset, char const *text, size_t size)
       d = d1[U((tp += d)[-1])];
       if (d != 0)
         continue;
-#undef LAST_SHIFT
-#define LAST_SHIFT
-      if (trans)
-        {
-#undef TRANS
-#define TRANS(ch) trans[U(ch)]
-          BM_DELTA2_SEARCH;
-        }
-      else
-        {
-#undef TRANS
-#define TRANS(ch) ch
-          BM_DELTA2_SEARCH;
-        }
+      if (bm_delta2_search (&tp, ep, sp, len, trans, gc1, gc2, NULL, kwset))
+        return tp - text;
     }
 
   return -1;

-----------------------------------------------------------------------

Summary of changes:
 src/kwset.c |  146 +++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 83 insertions(+), 63 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Wed Apr 23 02:55:34 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Wcr5i-0001Od-BC
	for mharc-grep-commit@gnu.org; Wed, 23 Apr 2014 02:55:34 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52101)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wcr5e-0001IH-UV
	for grep-commit@gnu.org; Wed, 23 Apr 2014 02:55:32 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wcr5d-0000s8-6n
	for grep-commit@gnu.org; Wed, 23 Apr 2014 02:55:30 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:36684)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wcr5c-0000rz-U3
	for grep-commit@gnu.org; Wed, 23 Apr 2014 02:55:29 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wcr5Z-0000My-JY
	for grep-commit@gnu.org; Wed, 23 Apr 2014 06:55:27 +0000
Date: Wed, 23 Apr 2014 06:55:27 +0000
Message-Id: <E1Wcr5Z-0000My-JY@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-91-g14892aa
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: c7ea5aea911b950b2398454ca89cce23cabd3a40
X-Git-Newrev: 14892aa6e0c21f49e5ec6d203253074ef15fedb0
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 23 Apr 2014 06:55:32 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  14892aa6e0c21f49e5ec6d203253074ef15fedb0 (commit)
       via  73893ffbada36599fb6ec2eb489b6a7decf0c248 (commit)
      from  c7ea5aea911b950b2398454ca89cce23cabd3a40 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=14892aa6e0c21f49e5ec6d203253074ef15fedb0


commit 14892aa6e0c21f49e5ec6d203253074ef15fedb0
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Tue Apr 22 23:34:22 2014 -0700

    kwset: simplify and speed up Boyer-Moore unibyte -i in some cases
    
    This improves the performance of, for example,
    yes jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj | head -10000000 | grep -i jk
    in a unibyte locale.
    * src/kwset.c (memchr_trans): New function.
    (bmexec): Use it.  Simplify the code and remove some of the
    confusing gotos and breaks and labels.  Do not treat glibc memchr
    as a special case; if non-glibc memchr is slow, that is lower
    priority and I suppose we can try to work around the problem in
    gnulib.

diff --git a/src/kwset.c b/src/kwset.c
index 78fb0b2..f86ee03 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -524,6 +524,20 @@ bm_delta2_search (char const **tpp, char const *ep, char const *sp, int len,
   return false;
 }
 
+/* Return the address of the first byte in the buffer S that equals C.
+   S contains N bytes.  If TRANS is nonnull, use it to transliterate
+   S's bytes before comparing them.  */
+static char const *
+memchr_trans (char const *s, char c, size_t n, char const *trans)
+{
+  if (! trans)
+    return memchr (s, c, n);
+  char const *slim = s + n;
+  for (; s < slim; s++)
+    if (trans[U(*s)] == c)
+      return s;
+  return NULL;
+}
 
 /* Fast boyer-moore search. */
 static size_t _GL_ATTRIBUTE_PURE
@@ -541,18 +555,8 @@ bmexec (kwset_t kwset, char const *text, size_t size)
     return -1;
   if (len == 1)
     {
-      if (trans)
-        {
-          for (tp = text; tp < text + size; tp++)
-            if (trans[U(*tp)] == kwset->target[0])
-              return tp - text;
-          return -1;
-        }
-      else
-        {
-          tp = memchr (text, kwset->target[0], size);
-          return tp ? tp - text : -1;
-        }
+      tp = memchr_trans (text, kwset->target[0], size, trans);
+      return tp ? tp - text : -1;
     }
 
   d1 = kwset->delta;
@@ -564,48 +568,33 @@ bmexec (kwset_t kwset, char const *text, size_t size)
   /* Significance of 12: 1 (initial offset) + 10 (skip loop) + 1 (md2). */
   if (size > 12 * len)
     /* 11 is not a bug, the initial offset happens only once. */
-    for (ep = text + size - 11 * len;;)
+    for (ep = text + size - 11 * len; tp <= ep; )
       {
-        while (tp <= ep)
+        d = d1[U(tp[-1])], tp += d;
+        d = d1[U(tp[-1])], tp += d;
+        if (d != 0)
           {
             d = d1[U(tp[-1])], tp += d;
             d = d1[U(tp[-1])], tp += d;
-            if (d == 0)
-              goto found;
-            d = d1[U(tp[-1])], tp += d;
-            d = d1[U(tp[-1])], tp += d;
-            d = d1[U(tp[-1])], tp += d;
-            if (d == 0)
-              goto found;
-            d = d1[U(tp[-1])], tp += d;
             d = d1[U(tp[-1])], tp += d;
-            d = d1[U(tp[-1])], tp += d;
-            if (d == 0)
-              goto found;
-            /* memchar() of glibc is faster than seeking by delta1 on
-               some platforms.  When there is no chance to match for a
-               while, use it on them.  */
-#if defined(__GLIBC__) && (defined(__i386__) || defined(__x86_64__))
-            if (!trans)
-              {
-                tp = memchr (tp - 1, gc1, size + text - tp + 1);
-                if (tp)
-                  {
-                    ++tp;
-                    goto found;
-                  }
-                else
-                  return -1;
-              }
-            else
-#endif
+            if (d != 0)
               {
                 d = d1[U(tp[-1])], tp += d;
                 d = d1[U(tp[-1])], tp += d;
+                d = d1[U(tp[-1])], tp += d;
+                if (d != 0)
+                  {
+                    /* Typically memchr is faster than seeking by
+                       delta1 when there is no chance to match for
+                       a while.  */
+                    tp--;
+                    tp = memchr_trans (tp, gc1, text + size - tp, trans);
+                    if (! tp)
+                      return -1;
+                    tp++;
+                  }
               }
           }
-        break;
-      found:
         if (bm_delta2_search (&tp, ep, sp, len, trans, gc1, gc2, d1, kwset))
           return tp - text;
       }

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=73893ffbada36599fb6ec2eb489b6a7decf0c248


commit 14892aa6e0c21f49e5ec6d203253074ef15fedb0
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Tue Apr 22 23:34:22 2014 -0700

    kwset: simplify and speed up Boyer-Moore unibyte -i in some cases
    
    This improves the performance of, for example,
    yes jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj | head -10000000 | grep -i jk
    in a unibyte locale.
    * src/kwset.c (memchr_trans): New function.
    (bmexec): Use it.  Simplify the code and remove some of the
    confusing gotos and breaks and labels.  Do not treat glibc memchr
    as a special case; if non-glibc memchr is slow, that is lower
    priority and I suppose we can try to work around the problem in
    gnulib.

diff --git a/src/kwset.c b/src/kwset.c
index 78fb0b2..f86ee03 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -524,6 +524,20 @@ bm_delta2_search (char const **tpp, char const *ep, char const *sp, int len,
   return false;
 }
 
+/* Return the address of the first byte in the buffer S that equals C.
+   S contains N bytes.  If TRANS is nonnull, use it to transliterate
+   S's bytes before comparing them.  */
+static char const *
+memchr_trans (char const *s, char c, size_t n, char const *trans)
+{
+  if (! trans)
+    return memchr (s, c, n);
+  char const *slim = s + n;
+  for (; s < slim; s++)
+    if (trans[U(*s)] == c)
+      return s;
+  return NULL;
+}
 
 /* Fast boyer-moore search. */
 static size_t _GL_ATTRIBUTE_PURE
@@ -541,18 +555,8 @@ bmexec (kwset_t kwset, char const *text, size_t size)
     return -1;
   if (len == 1)
     {
-      if (trans)
-        {
-          for (tp = text; tp < text + size; tp++)
-            if (trans[U(*tp)] == kwset->target[0])
-              return tp - text;
-          return -1;
-        }
-      else
-        {
-          tp = memchr (text, kwset->target[0], size);
-          return tp ? tp - text : -1;
-        }
+      tp = memchr_trans (text, kwset->target[0], size, trans);
+      return tp ? tp - text : -1;
     }
 
   d1 = kwset->delta;
@@ -564,48 +568,33 @@ bmexec (kwset_t kwset, char const *text, size_t size)
   /* Significance of 12: 1 (initial offset) + 10 (skip loop) + 1 (md2). */
   if (size > 12 * len)
     /* 11 is not a bug, the initial offset happens only once. */
-    for (ep = text + size - 11 * len;;)
+    for (ep = text + size - 11 * len; tp <= ep; )
       {
-        while (tp <= ep)
+        d = d1[U(tp[-1])], tp += d;
+        d = d1[U(tp[-1])], tp += d;
+        if (d != 0)
           {
             d = d1[U(tp[-1])], tp += d;
             d = d1[U(tp[-1])], tp += d;
-            if (d == 0)
-              goto found;
-            d = d1[U(tp[-1])], tp += d;
-            d = d1[U(tp[-1])], tp += d;
-            d = d1[U(tp[-1])], tp += d;
-            if (d == 0)
-              goto found;
-            d = d1[U(tp[-1])], tp += d;
             d = d1[U(tp[-1])], tp += d;
-            d = d1[U(tp[-1])], tp += d;
-            if (d == 0)
-              goto found;
-            /* memchar() of glibc is faster than seeking by delta1 on
-               some platforms.  When there is no chance to match for a
-               while, use it on them.  */
-#if defined(__GLIBC__) && (defined(__i386__) || defined(__x86_64__))
-            if (!trans)
-              {
-                tp = memchr (tp - 1, gc1, size + text - tp + 1);
-                if (tp)
-                  {
-                    ++tp;
-                    goto found;
-                  }
-                else
-                  return -1;
-              }
-            else
-#endif
+            if (d != 0)
               {
                 d = d1[U(tp[-1])], tp += d;
                 d = d1[U(tp[-1])], tp += d;
+                d = d1[U(tp[-1])], tp += d;
+                if (d != 0)
+                  {
+                    /* Typically memchr is faster than seeking by
+                       delta1 when there is no chance to match for
+                       a while.  */
+                    tp--;
+                    tp = memchr_trans (tp, gc1, text + size - tp, trans);
+                    if (! tp)
+                      return -1;
+                    tp++;
+                  }
               }
           }
-        break;
-      found:
         if (bm_delta2_search (&tp, ep, sp, len, trans, gc1, gc2, d1, kwset))
           return tp - text;
       }

-----------------------------------------------------------------------

Summary of changes:
 src/kwset.c |   66 +++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 37 insertions(+), 29 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Wed Apr 23 15:44:40 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Wd360-0002dR-Au
	for mharc-grep-commit@gnu.org; Wed, 23 Apr 2014 15:44:40 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33992)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wd35w-0002YO-CT
	for grep-commit@gnu.org; Wed, 23 Apr 2014 15:44:38 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wd35u-0000p0-IR
	for grep-commit@gnu.org; Wed, 23 Apr 2014 15:44:36 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:44532)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wd35u-0000or-Dy
	for grep-commit@gnu.org; Wed, 23 Apr 2014 15:44:34 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wd35t-0004wR-Kj
	for grep-commit@gnu.org; Wed, 23 Apr 2014 19:44:33 +0000
Date: Wed, 23 Apr 2014 19:44:33 +0000
Message-Id: <E1Wd35t-0004wR-Kj@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-92-gb0a087b
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 14892aa6e0c21f49e5ec6d203253074ef15fedb0
X-Git-Newrev: b0a087b4c7196782d8e76f00c45de1540daf5b91
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 23 Apr 2014 19:44:38 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  b0a087b4c7196782d8e76f00c45de1540daf5b91 (commit)
      from  14892aa6e0c21f49e5ec6d203253074ef15fedb0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=b0a087b4c7196782d8e76f00c45de1540daf5b91


commit b0a087b4c7196782d8e76f00c45de1540daf5b91
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Wed Apr 23 12:43:52 2014 -0700

    dfa: omit static variables that limited dfaexec to one struct dfa
    
    Problem reported by Aharon Robbins in: http://bugs.gnu.org/17328
    * src/dfa.c (struct dfa): New member mbs.
    mb_follows is now a position_set, not a pointer to one;
    this simplifies memory allocation.  All uses changed.
    (mbs_to_wchar): Put DFA arg at the end, in place of the mbstate_t *arg,
    since the DFA now contains an mbstate_t.  All uses changed.
    (mbs): Remove static variable.
    (dfaexec): Remove static bool that attempted to optimize memory
    allocation, as this wasn't correct for Gawk.  Perhaps we can think
    of a better way to optimize memory.

diff --git a/src/dfa.c b/src/dfa.c
index 65fc03d..42a9736 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -339,8 +339,9 @@ struct dfa
                                    with dfaparse.  */
   unsigned int mb_cur_max;      /* Cached value of MB_CUR_MAX.  */
   token utf8_anychar_classes[5]; /* To lower ANYCHAR in UTF-8 locales.  */
+  mbstate_t mbs;		/* Multibyte conversion state.  */
 
-  /* The following are used only if MB_CUR_MAX > 1.  */
+  /* The following are valid only if mb_cur_max > 1.  */
 
   /* The value of multibyte_prop[i] is defined by following rule.
      if tokens[i] < NOTCHAR
@@ -422,7 +423,7 @@ struct dfa
   struct dfamust *musts;        /* List of strings, at least one of which
                                    is known to appear in any r.e. matching
                                    the dfa.  */
-  position_set *mb_follows;     /* Follow set added by ANYCHAR and/or MBCSET
+  position_set mb_follows;	/* Follow set added by ANYCHAR and/or MBCSET
                                    on demand.  */
   int *mb_match_lens;           /* Array of length reduced by ANYCHAR and/or
                                    MBCSET.  */
@@ -462,33 +463,34 @@ dfambcache (struct dfa *d)
     }
 }
 
-/* Given the dfa D, store into *PWC the result of converting the
-   leading bytes of the multibyte buffer S of length N bytes, updating
-   the conversion state in *MBS.  On conversion error, convert just a
-   single byte as-is.  Return the number of bytes converted.
+/* Store into *PWC the result of converting the leading bytes of the
+   multibyte buffer S of length N bytes, using the mbrtowc_cache in *D
+   and updating the conversion state in *D.  On conversion error,
+   convert just a single byte as-is.  Return the number of bytes
+   converted.
 
-   This differs from mbrtowc (PWC, S, N, MBS) as follows:
+   This differs from mbrtowc (PWC, S, N, &D->mbs) as follows:
 
-   * Extra arg D, containing an mbrtowc_cache for speed.
+   * The last arg is a dfa *D instead of merely a multibyte conversion
+     state D->mbs.  D also contains an mbrtowc_cache for speed.
    * N must be at least 1.
    * S[N - 1] must be a sentinel byte.
    * Shift encodings are not supported.
    * The return value is always in the range 1..N.
-   * *MBS is always valid afterwards.
+   * D->mbs is always valid afterwards.
    * *PWC is always set to something.  */
 static size_t
-mbs_to_wchar (struct dfa *d, wchar_t *pwc, char const *s, size_t n,
-              mbstate_t *mbs)
+mbs_to_wchar (wchar_t *pwc, char const *s, size_t n, struct dfa *d)
 {
   unsigned char uc = s[0];
   wint_t wc = d->mbrtowc_cache[uc];
 
   if (wc == WEOF)
     {
-      size_t nbytes = mbrtowc (pwc, s, n, mbs);
+      size_t nbytes = mbrtowc (pwc, s, n, &d->mbs);
       if (0 < nbytes && nbytes < (size_t) -2)
         return nbytes;
-      memset (mbs, 0, sizeof *mbs);
+      memset (&d->mbs, 0, sizeof d->mbs);
       wc = uc;
     }
 
@@ -838,7 +840,6 @@ static int minrep, maxrep;      /* Repeat counts for {m,n}.  */
 static int cur_mb_len = 1;      /* Length of the multibyte representation of
                                    wctok.  */
 /* These variables are used only if (MB_CUR_MAX > 1).  */
-static mbstate_t mbs;           /* mbstate for mbrtowc.  */
 static wchar_t wctok;           /* Wide character representation of the current
                                    multibyte character.  */
 
@@ -856,7 +857,7 @@ static wchar_t wctok;           /* Wide character representation of the current
     else					\
       {						\
         wchar_t _wc;				\
-        size_t nbytes = mbs_to_wchar (dfa, &_wc, lexptr, lexleft, &mbs); \
+        size_t nbytes = mbs_to_wchar (&_wc, lexptr, lexleft, dfa); \
         cur_mb_len = nbytes;			\
         (wc) = _wc;				\
         (c) = nbytes == 1 ? to_uchar (*lexptr) : EOF;    \
@@ -1932,7 +1933,7 @@ dfaparse (char const *s, size_t len, struct dfa *d)
   if (MB_CUR_MAX > 1)
     {
       cur_mb_len = 0;
-      memset (&mbs, 0, sizeof mbs);
+      memset (&d->mbs, 0, sizeof d->mbs);
     }
 
   if (!syntax_bits_set)
@@ -3112,8 +3113,7 @@ transit_state_consume_1char (struct dfa *d, state_num s,
       s2 = s1;
       rs = transit_state_singlebyte (d, s2, (*pp)++, &s1);
     }
-  /* Copy the positions contained by 's1' to the set 'd->mb_follows'.  */
-  copy (&(d->states[s1].elems), d->mb_follows);
+  copy (&d->states[s1].elems, &d->mb_follows);
 
   /* Add all of the positions which can be reached from 's' by consuming
      a single character.  */
@@ -3123,7 +3123,7 @@ transit_state_consume_1char (struct dfa *d, state_num s,
         for (j = 0; j < d->follows[d->states[s].mbps.elems[i].index].nelem;
              j++)
           insert (d->follows[d->states[s].mbps.elems[i].index].elems[j],
-                  d->mb_follows);
+                  &d->mb_follows);
     }
 
   /* FIXME: this return value is always ignored.  */
@@ -3151,7 +3151,7 @@ transit_state (struct dfa *d, state_num s, unsigned char const **pp,
        We check whether each of them can match or not.  */
     {
       /* Note: caller must free the return value of this function.  */
-      mbclen = mbs_to_wchar (d, &wc, (char const *) *pp, end - *pp, &mbs);
+      mbclen = mbs_to_wchar (&wc, (char const *) *pp, end - *pp, d);
       match_lens = check_matching_with_multibyte_ops (d, s, (char const *) *pp,
                                                       wc, mbclen);
 
@@ -3179,7 +3179,7 @@ transit_state (struct dfa *d, state_num s, unsigned char const **pp,
     }
 
   /* This state has some operators which can match a multibyte character.  */
-  d->mb_follows->nelem = 0;
+  d->mb_follows.nelem = 0;
 
   /* 'maxlen' may be longer than the length of a character, because it may
      not be a character but a (multi character) collating element.
@@ -3187,12 +3187,12 @@ transit_state (struct dfa *d, state_num s, unsigned char const **pp,
      'maxlen' bytes.  */
   transit_state_consume_1char (d, s, pp, wc, mbclen, match_lens);
 
-  s1 = state_index (d, d->mb_follows, wchar_context (wc));
+  s1 = state_index (d, &d->mb_follows, wchar_context (wc));
   realloc_trans_if_necessary (d, s1);
 
   while (*pp - p1 < maxlen)
     {
-      mbclen = mbs_to_wchar (d, &wc, (char const *) *pp, end - *pp, &mbs);
+      mbclen = mbs_to_wchar (&wc, (char const *) *pp, end - *pp, d);
       transit_state_consume_1char (d, s1, pp, wc, mbclen, NULL);
 
       for (i = 0; i < nelem; i++)
@@ -3201,10 +3201,10 @@ transit_state (struct dfa *d, state_num s, unsigned char const **pp,
             for (j = 0;
                  j < d->follows[d->states[s1].mbps.elems[i].index].nelem; j++)
               insert (d->follows[d->states[s1].mbps.elems[i].index].elems[j],
-                      d->mb_follows);
+                      &d->mb_follows);
         }
 
-      s1 = state_index (d, d->mb_follows, wchar_context (wc));
+      s1 = state_index (d, &d->mb_follows, wchar_context (wc));
       realloc_trans_if_necessary (d, s1);
     }
   return s1;
@@ -3244,15 +3244,9 @@ dfaexec (struct dfa *d, char const *begin, char *end,
 
   if (d->mb_cur_max > 1)
     {
-      static bool mb_alloc = false;
-      memset (&mbs, 0, sizeof (mbstate_t));
-      if (!mb_alloc)
-        {
-          d->mb_match_lens = xnmalloc (d->nleaves, sizeof *d->mb_match_lens);
-          d->mb_follows = xmalloc (sizeof *d->mb_follows);
-          alloc_position_set (d->mb_follows, d->nleaves);
-          mb_alloc = true;
-        }
+      memset (&d->mbs, 0, sizeof d->mbs);
+      d->mb_match_lens = xnmalloc (d->nleaves, sizeof *d->mb_match_lens);
+      alloc_position_set (&d->mb_follows, d->nleaves);
     }
 
   for (;;)
@@ -3277,8 +3271,8 @@ dfaexec (struct dfa *d, char const *begin, char *end,
                      character.  */
                   wchar_t wc;
                   while (mbp < p)
-                    mbp += mbs_to_wchar (d, &wc, (char const *) mbp,
-                                         end - (char const *) mbp, &mbs);
+                    mbp += mbs_to_wchar (&wc, (char const *) mbp,
+                                         end - (char const *) mbp, d);
                   p = mbp;
 
                   if ((char *) p >= end)
@@ -3407,7 +3401,6 @@ free_mbdata (struct dfa *d)
   size_t i;
 
   free (d->multibyte_prop);
-  d->multibyte_prop = NULL;
 
   for (i = 0; i < d->nmbcsets; ++i)
     {
@@ -3427,14 +3420,7 @@ free_mbdata (struct dfa *d)
     }
 
   free (d->mbcsets);
-  d->mbcsets = NULL;
-  d->nmbcsets = 0;
-
-  if (d->mb_follows)
-    {
-      free (d->mb_follows->elems);
-      free (d->mb_follows);
-    }
+  free (d->mb_follows.elems);
   free (d->mb_match_lens);
 }
 

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |   76 +++++++++++++++++++++++++------------------------------------
 1 files changed, 31 insertions(+), 45 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Wed Apr 23 22:24:44 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Wd9LA-0006uU-4b
	for mharc-grep-commit@gnu.org; Wed, 23 Apr 2014 22:24:44 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52341)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1Wd9L8-0006uM-Ft
	for grep-commit@gnu.org; Wed, 23 Apr 2014 22:24:43 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1Wd9L7-00022e-DY
	for grep-commit@gnu.org; Wed, 23 Apr 2014 22:24:42 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:47890)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1Wd9L7-00022Y-9X
	for grep-commit@gnu.org; Wed, 23 Apr 2014 22:24:41 -0400
Received: from meyering by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <jim@meyering.net>) id 1Wd9L6-0002P3-OA
	for grep-commit@gnu.org; Thu, 24 Apr 2014 02:24:40 +0000
Date: Thu, 24 Apr 2014 02:24:40 +0000
Message-Id: <E1Wd9L6-0002P3-OA@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-93-gb80a956
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: b0a087b4c7196782d8e76f00c45de1540daf5b91
X-Git-Newrev: b80a95691418ce19b42b54c706633ef8be0bd9ee
From: Jim Meyering <jim@meyering.net>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 24 Apr 2014 02:24:43 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  b80a95691418ce19b42b54c706633ef8be0bd9ee (commit)
      from  b0a087b4c7196782d8e76f00c45de1540daf5b91 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=b80a95691418ce19b42b54c706633ef8be0bd9ee


commit b80a95691418ce19b42b54c706633ef8be0bd9ee
Author: Jim Meyering <meyering@fb.com>
Date:   Wed Apr 23 19:21:11 2014 -0700

    tests: use consistent spelling for locale name, en_US.UTF-8
    
    * tests/pcre-infloop: Spell locale name, en_US.UTF-8, consistently,
    converting this one use from "en_US.utf8", which would provoke a
    test failure on OS/X.

diff --git a/tests/pcre-infloop b/tests/pcre-infloop
index febf356..1b33e72 100755
--- a/tests/pcre-infloop
+++ b/tests/pcre-infloop
@@ -27,7 +27,7 @@ printf 'a\201b\r' > in || framework_failure_
 
 fail=0
 
-LC_ALL=en_US.utf8 timeout 3 grep -P 'a.?..b' in
+LC_ALL=en_US.UTF-8 timeout 3 grep -P 'a.?..b' in
 test $? = 2 || fail_ "libpcre's match function appears to infloop"
 
 Exit $fail

-----------------------------------------------------------------------

Summary of changes:
 tests/pcre-infloop |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Thu Apr 24 02:21:09 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WdD1x-0005H6-TT
	for mharc-grep-commit@gnu.org; Thu, 24 Apr 2014 02:21:09 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:54032)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdD1v-0005CS-7F
	for grep-commit@gnu.org; Thu, 24 Apr 2014 02:21:08 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdD1u-0006Jh-AQ
	for grep-commit@gnu.org; Thu, 24 Apr 2014 02:21:07 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:50152)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdD1u-0006Jb-6g
	for grep-commit@gnu.org; Thu, 24 Apr 2014 02:21:06 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdD1t-0004G8-Ch
	for grep-commit@gnu.org; Thu, 24 Apr 2014 06:21:05 +0000
Date: Thu, 24 Apr 2014 06:21:05 +0000
Message-Id: <E1WdD1t-0004G8-Ch@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-94-g8345ee3
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: b80a95691418ce19b42b54c706633ef8be0bd9ee
X-Git-Newrev: 8345ee380535825253744a0b22725171ab02479c
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 24 Apr 2014 06:21:08 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  8345ee380535825253744a0b22725171ab02479c (commit)
      from  b80a95691418ce19b42b54c706633ef8be0bd9ee (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=8345ee380535825253744a0b22725171ab02479c


commit 8345ee380535825253744a0b22725171ab02479c
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Wed Apr 23 23:20:35 2014 -0700

    dfa: fix memory leak reintroduced by previous patch
    
    Reported by Norihiro Tanaka in <http://bugs.gnu.org/17328#16>.
    * src/dfa.c (dfaexec): Allocate mb_match_lens and mb_follows only
    if not already allocated.
    (free_mbdata): Null out mb_match_lens to mark it as being freed.

diff --git a/src/dfa.c b/src/dfa.c
index 42a9736..5dc0f09 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -426,7 +426,8 @@ struct dfa
   position_set mb_follows;	/* Follow set added by ANYCHAR and/or MBCSET
                                    on demand.  */
   int *mb_match_lens;           /* Array of length reduced by ANYCHAR and/or
-                                   MBCSET.  */
+                                   MBCSET.  Null if mb_follows.elems has not
+                                   been allocated.  */
 };
 
 /* Some macros for user access to dfa internals.  */
@@ -3245,8 +3246,11 @@ dfaexec (struct dfa *d, char const *begin, char *end,
   if (d->mb_cur_max > 1)
     {
       memset (&d->mbs, 0, sizeof d->mbs);
-      d->mb_match_lens = xnmalloc (d->nleaves, sizeof *d->mb_match_lens);
-      alloc_position_set (&d->mb_follows, d->nleaves);
+      if (! d->mb_match_lens)
+        {
+          d->mb_match_lens = xnmalloc (d->nleaves, sizeof *d->mb_match_lens);
+          alloc_position_set (&d->mb_follows, d->nleaves);
+        }
     }
 
   for (;;)
@@ -3422,6 +3426,7 @@ free_mbdata (struct dfa *d)
   free (d->mbcsets);
   free (d->mb_follows.elems);
   free (d->mb_match_lens);
+  d->mb_match_lens = NULL;
 }
 
 /* Initialize the components of a dfa that the other routines don't

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Thu Apr 24 20:54:01 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WdUOs-0007h2-PY
	for mharc-grep-commit@gnu.org; Thu, 24 Apr 2014 20:53:58 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:60759)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdUOj-0007d5-7t
	for grep-commit@gnu.org; Thu, 24 Apr 2014 20:53:50 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdUOg-0007KG-Vt
	for grep-commit@gnu.org; Thu, 24 Apr 2014 20:53:48 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:33438)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdUOg-0007K0-RO
	for grep-commit@gnu.org; Thu, 24 Apr 2014 20:53:46 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdUOg-0006jG-07
	for grep-commit@gnu.org; Fri, 25 Apr 2014 00:53:46 +0000
Date: Fri, 25 Apr 2014 00:53:46 +0000
Message-Id: <E1WdUOg-0006jG-07@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-102-gb642fb0
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 59f3fac48e8b5456f4e0a45dfd99fba38d8b7af5
X-Git-Newrev: b642fb02a94c0f6b9ff47f2b62c7d8f11ea3f223
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 25 Apr 2014 00:53:51 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  b642fb02a94c0f6b9ff47f2b62c7d8f11ea3f223 (commit)
       via  1f483c98a93066ecd28cbbc013415015431dd76a (commit)
       via  b36c5cf9ee0fa173ffa1f748350f16bc1cb2d619 (commit)
      from  59f3fac48e8b5456f4e0a45dfd99fba38d8b7af5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=b642fb02a94c0f6b9ff47f2b62c7d8f11ea3f223


commit b642fb02a94c0f6b9ff47f2b62c7d8f11ea3f223
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 24 17:52:10 2014 -0700

    dfa: minor simplification of dfaexec
    
    * src/dfa.c (dfaexec): Streamline updating of returned values.
    Don't bother to check d->multibyte before updating mbp.
    Avoid duplicate p > end test.

diff --git a/src/dfa.c b/src/dfa.c
index 7a99d3f..50264b2 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3237,6 +3237,7 @@ dfaexec (struct dfa *d, char const *begin, char *end,
                                    into a register.  */
   unsigned char eol = eolbyte;  /* Likewise for eolbyte.  */
   unsigned char saved_end;
+  size_t nlcount = 0;
 
   if (!d->tralloc)
     build_state_zero (d);
@@ -3285,8 +3286,8 @@ dfaexec (struct dfa *d, char const *begin, char *end,
 
                   if ((char *) p >= end)
                     {
-                      *end = saved_end;
-                      return NULL;
+                      p = NULL;
+                      goto done;
                     }
                 }
 
@@ -3303,8 +3304,7 @@ dfaexec (struct dfa *d, char const *begin, char *end,
               if (d->states[s].has_mbcset && backref)
                 {
                   *backref = 1;
-                  *end = saved_end;
-                  return (char *) p;
+                  goto done;
                 }
 
               /* Can match with a multibyte character (and multi character
@@ -3330,14 +3330,19 @@ dfaexec (struct dfa *d, char const *begin, char *end,
             }
         }
 
-      if (s >= 0 && (char *) p <= end && d->fails[s])
+      if ((char *) p > end)
+        {
+          p = NULL;
+          goto done;
+        }
+
+      if (s >= 0 && d->fails[s])
         {
           if (d->success[s] & sbit[*p])
             {
               if (backref)
                 *backref = d->states[s].has_backref;
-              *end = saved_end;
-              return (char *) p;
+              goto done;
             }
 
           s1 = s;
@@ -3354,21 +3359,12 @@ dfaexec (struct dfa *d, char const *begin, char *end,
           continue;
         }
 
-      /* Check if we've run off the end of the buffer.  */
-      if ((char *) p > end)
-        {
-          *end = saved_end;
-          return NULL;
-        }
-
       /* If the previous character was a newline, count it, and skip
          checking of multibyte character boundary until here.  */
       if (p[-1] == eol)
         {
-          if (count)
-            ++*count;
-          if (d->multibyte)
-            mbp = p;
+          nlcount++;
+          mbp = p;
         }
 
       if (s >= 0)
@@ -3387,6 +3383,12 @@ dfaexec (struct dfa *d, char const *begin, char *end,
 
       s = 0;
     }
+
+ done:
+  if (count)
+    *count += nlcount;
+  *end = saved_end;
+  return (char *) p;
 }
 
 /* Search through a buffer looking for a potential match for D.

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=1f483c98a93066ecd28cbbc013415015431dd76a


commit b642fb02a94c0f6b9ff47f2b62c7d8f11ea3f223
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 24 17:52:10 2014 -0700

    dfa: minor simplification of dfaexec
    
    * src/dfa.c (dfaexec): Streamline updating of returned values.
    Don't bother to check d->multibyte before updating mbp.
    Avoid duplicate p > end test.

diff --git a/src/dfa.c b/src/dfa.c
index 7a99d3f..50264b2 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3237,6 +3237,7 @@ dfaexec (struct dfa *d, char const *begin, char *end,
                                    into a register.  */
   unsigned char eol = eolbyte;  /* Likewise for eolbyte.  */
   unsigned char saved_end;
+  size_t nlcount = 0;
 
   if (!d->tralloc)
     build_state_zero (d);
@@ -3285,8 +3286,8 @@ dfaexec (struct dfa *d, char const *begin, char *end,
 
                   if ((char *) p >= end)
                     {
-                      *end = saved_end;
-                      return NULL;
+                      p = NULL;
+                      goto done;
                     }
                 }
 
@@ -3303,8 +3304,7 @@ dfaexec (struct dfa *d, char const *begin, char *end,
               if (d->states[s].has_mbcset && backref)
                 {
                   *backref = 1;
-                  *end = saved_end;
-                  return (char *) p;
+                  goto done;
                 }
 
               /* Can match with a multibyte character (and multi character
@@ -3330,14 +3330,19 @@ dfaexec (struct dfa *d, char const *begin, char *end,
             }
         }
 
-      if (s >= 0 && (char *) p <= end && d->fails[s])
+      if ((char *) p > end)
+        {
+          p = NULL;
+          goto done;
+        }
+
+      if (s >= 0 && d->fails[s])
         {
           if (d->success[s] & sbit[*p])
             {
               if (backref)
                 *backref = d->states[s].has_backref;
-              *end = saved_end;
-              return (char *) p;
+              goto done;
             }
 
           s1 = s;
@@ -3354,21 +3359,12 @@ dfaexec (struct dfa *d, char const *begin, char *end,
           continue;
         }
 
-      /* Check if we've run off the end of the buffer.  */
-      if ((char *) p > end)
-        {
-          *end = saved_end;
-          return NULL;
-        }
-
       /* If the previous character was a newline, count it, and skip
          checking of multibyte character boundary until here.  */
       if (p[-1] == eol)
         {
-          if (count)
-            ++*count;
-          if (d->multibyte)
-            mbp = p;
+          nlcount++;
+          mbp = p;
         }
 
       if (s >= 0)
@@ -3387,6 +3383,12 @@ dfaexec (struct dfa *d, char const *begin, char *end,
 
       s = 0;
     }
+
+ done:
+  if (count)
+    *count += nlcount;
+  *end = saved_end;
+  return (char *) p;
 }
 
 /* Search through a buffer looking for a potential match for D.

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=b36c5cf9ee0fa173ffa1f748350f16bc1cb2d619


commit b642fb02a94c0f6b9ff47f2b62c7d8f11ea3f223
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 24 17:52:10 2014 -0700

    dfa: minor simplification of dfaexec
    
    * src/dfa.c (dfaexec): Streamline updating of returned values.
    Don't bother to check d->multibyte before updating mbp.
    Avoid duplicate p > end test.

diff --git a/src/dfa.c b/src/dfa.c
index 7a99d3f..50264b2 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3237,6 +3237,7 @@ dfaexec (struct dfa *d, char const *begin, char *end,
                                    into a register.  */
   unsigned char eol = eolbyte;  /* Likewise for eolbyte.  */
   unsigned char saved_end;
+  size_t nlcount = 0;
 
   if (!d->tralloc)
     build_state_zero (d);
@@ -3285,8 +3286,8 @@ dfaexec (struct dfa *d, char const *begin, char *end,
 
                   if ((char *) p >= end)
                     {
-                      *end = saved_end;
-                      return NULL;
+                      p = NULL;
+                      goto done;
                     }
                 }
 
@@ -3303,8 +3304,7 @@ dfaexec (struct dfa *d, char const *begin, char *end,
               if (d->states[s].has_mbcset && backref)
                 {
                   *backref = 1;
-                  *end = saved_end;
-                  return (char *) p;
+                  goto done;
                 }
 
               /* Can match with a multibyte character (and multi character
@@ -3330,14 +3330,19 @@ dfaexec (struct dfa *d, char const *begin, char *end,
             }
         }
 
-      if (s >= 0 && (char *) p <= end && d->fails[s])
+      if ((char *) p > end)
+        {
+          p = NULL;
+          goto done;
+        }
+
+      if (s >= 0 && d->fails[s])
         {
           if (d->success[s] & sbit[*p])
             {
               if (backref)
                 *backref = d->states[s].has_backref;
-              *end = saved_end;
-              return (char *) p;
+              goto done;
             }
 
           s1 = s;
@@ -3354,21 +3359,12 @@ dfaexec (struct dfa *d, char const *begin, char *end,
           continue;
         }
 
-      /* Check if we've run off the end of the buffer.  */
-      if ((char *) p > end)
-        {
-          *end = saved_end;
-          return NULL;
-        }
-
       /* If the previous character was a newline, count it, and skip
          checking of multibyte character boundary until here.  */
       if (p[-1] == eol)
         {
-          if (count)
-            ++*count;
-          if (d->multibyte)
-            mbp = p;
+          nlcount++;
+          mbp = p;
         }
 
       if (s >= 0)
@@ -3387,6 +3383,12 @@ dfaexec (struct dfa *d, char const *begin, char *end,
 
       s = 0;
     }
+
+ done:
+  if (count)
+    *count += nlcount;
+  *end = saved_end;
+  return (char *) p;
 }
 
 /* Search through a buffer looking for a potential match for D.

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |  102 +++++++++++++++++++++++++++++++++----------------------------
 1 files changed, 55 insertions(+), 47 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Thu Apr 24 21:01:39 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WdUWJ-0003GP-RB
	for mharc-grep-commit@gnu.org; Thu, 24 Apr 2014 21:01:39 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:60759)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdURZ-0007d5-5z
	for grep-commit@gnu.org; Thu, 24 Apr 2014 20:56:46 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdMld-0006V9-4t
	for grep-commit@gnu.org; Thu, 24 Apr 2014 12:45:01 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:57281)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdMld-0006V5-0v
	for grep-commit@gnu.org; Thu, 24 Apr 2014 12:44:57 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdMlc-0003GE-F5
	for grep-commit@gnu.org; Thu, 24 Apr 2014 16:44:56 +0000
Date: Thu, 24 Apr 2014 16:44:56 +0000
Message-Id: <E1WdMlc-0003GE-F5@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-98-ga9c9f65
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 2c780631f89a1e50fe8221f72e128cf39b212141
X-Git-Newrev: a9c9f65425ee313b1a24b32bfa3f9fec679bbcc7
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 25 Apr 2014 01:01:39 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  a9c9f65425ee313b1a24b32bfa3f9fec679bbcc7 (commit)
       via  eebb7161b7321f08b448f9d7ab4d99d860445ef5 (commit)
      from  2c780631f89a1e50fe8221f72e128cf39b212141 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=a9c9f65425ee313b1a24b32bfa3f9fec679bbcc7


commit a9c9f65425ee313b1a24b32bfa3f9fec679bbcc7
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 24 09:40:34 2014 -0700

    dfa: minor tuneup of dfamust memory savings patch
    
    * src/dfa.c (allocmust): Use xmalloc, not xzalloc.
    Initialize the must completely, so that the caller need not
    invoke resetmust.  All callers changed.
    (dfamust): Omit asserts that aren't needed on typical machines
    where dereferencing NULL dumps core.  Don't leak memory if the
    pattern contains a NUL byte.

diff --git a/src/dfa.c b/src/dfa.c
index ee1e8e6..8fc3d6f 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3828,11 +3828,13 @@ struct must
 static must *
 allocmust (must *mp)
 {
-  must *new_mp = xzalloc (sizeof *new_mp);
+  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->begline = false;
+  new_mp->endline = false;
   new_mp->prev = mp;
   return new_mp;
 }
@@ -3877,12 +3879,10 @@ dfamust (struct dfa *d)
         {
         case BEGLINE:
           mp = allocmust (mp);
-          resetmust (mp);
           mp->begline = true;
           break;
         case ENDLINE:
           mp = allocmust (mp);
-          resetmust (mp);
           mp->endline = true;
           break;
         case LPAREN:
@@ -3898,23 +3898,20 @@ dfamust (struct dfa *d)
         case ANYCHAR:
         case MBCSET:
           mp = allocmust (mp);
-          /* Fall through.  */
+          break;
+
         case STAR:
         case QMARK:
-          assert (mp != NULL);
           resetmust (mp);
           break;
 
         case OR:
-          assert (mp && mp->prev);
           {
             char **new;
-            must *lmp;
-            must *rmp;
+            must *rmp = mp;
+            must *lmp = mp = mp->prev;
             size_t j, ln, rn, n;
 
-            rmp = mp;
-            lmp = mp = mp->prev;
             /* Guaranteed to be.  Unlikely, but ...  */
             if (!STREQ (lmp->is, rmp->is))
               lmp->is[0] = '\0';
@@ -3946,34 +3943,27 @@ dfamust (struct dfa *d)
           break;
 
         case PLUS:
-          assert (mp != NULL);
           mp->is[0] = '\0';
           break;
 
         case END:
-          assert (!mp || !mp->prev);
-          if (mp)
+          assert (!mp->prev);
+          for (i = 0; mp->in[i] != NULL; ++i)
+            if (strlen (mp->in[i]) > strlen (result))
+              result = mp->in[i];
+          if (STREQ (result, mp->is))
             {
-              for (i = 0; mp->in[i] != NULL; ++i)
-                if (strlen (mp->in[i]) > strlen (result))
-                  result = mp->in[i];
-              if (STREQ (result, mp->is))
-                {
-                  exact = true;
-                  begline = mp->begline;
-                  endline = mp->endline;
-                }
+              exact = true;
+              begline = mp->begline;
+              endline = mp->endline;
             }
           goto done;
 
         case CAT:
-          assert (mp && mp->prev);
           {
-            must *lmp;
-            must *rmp;
+            must *rmp = mp;
+            must *lmp = mp = mp->prev;
 
-            rmp = mp;
-            lmp = mp = mp->prev;
             /* In.  Everything in left, plus everything in
                right, plus concatenation of
                left's right and right's left.  */
@@ -4018,7 +4008,6 @@ dfamust (struct dfa *d)
 
         default:
           mp = allocmust (mp);
-          resetmust (mp);
           if (CSET <= t)
             {
               /* If T is a singleton, or if case-folding in a unibyte
@@ -4059,8 +4048,13 @@ done:
       dm->next = d->musts;
       d->musts = dm;
     }
-  if (mp)
-    freemust (mp);
+
+  while (mp)
+    {
+      must *prev = mp->prev;
+      freemust (mp);
+      mp = prev;
+    }
 }
 
 struct dfa *

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=eebb7161b7321f08b448f9d7ab4d99d860445ef5


commit a9c9f65425ee313b1a24b32bfa3f9fec679bbcc7
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 24 09:40:34 2014 -0700

    dfa: minor tuneup of dfamust memory savings patch
    
    * src/dfa.c (allocmust): Use xmalloc, not xzalloc.
    Initialize the must completely, so that the caller need not
    invoke resetmust.  All callers changed.
    (dfamust): Omit asserts that aren't needed on typical machines
    where dereferencing NULL dumps core.  Don't leak memory if the
    pattern contains a NUL byte.

diff --git a/src/dfa.c b/src/dfa.c
index ee1e8e6..8fc3d6f 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3828,11 +3828,13 @@ struct must
 static must *
 allocmust (must *mp)
 {
-  must *new_mp = xzalloc (sizeof *new_mp);
+  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->begline = false;
+  new_mp->endline = false;
   new_mp->prev = mp;
   return new_mp;
 }
@@ -3877,12 +3879,10 @@ dfamust (struct dfa *d)
         {
         case BEGLINE:
           mp = allocmust (mp);
-          resetmust (mp);
           mp->begline = true;
           break;
         case ENDLINE:
           mp = allocmust (mp);
-          resetmust (mp);
           mp->endline = true;
           break;
         case LPAREN:
@@ -3898,23 +3898,20 @@ dfamust (struct dfa *d)
         case ANYCHAR:
         case MBCSET:
           mp = allocmust (mp);
-          /* Fall through.  */
+          break;
+
         case STAR:
         case QMARK:
-          assert (mp != NULL);
           resetmust (mp);
           break;
 
         case OR:
-          assert (mp && mp->prev);
           {
             char **new;
-            must *lmp;
-            must *rmp;
+            must *rmp = mp;
+            must *lmp = mp = mp->prev;
             size_t j, ln, rn, n;
 
-            rmp = mp;
-            lmp = mp = mp->prev;
             /* Guaranteed to be.  Unlikely, but ...  */
             if (!STREQ (lmp->is, rmp->is))
               lmp->is[0] = '\0';
@@ -3946,34 +3943,27 @@ dfamust (struct dfa *d)
           break;
 
         case PLUS:
-          assert (mp != NULL);
           mp->is[0] = '\0';
           break;
 
         case END:
-          assert (!mp || !mp->prev);
-          if (mp)
+          assert (!mp->prev);
+          for (i = 0; mp->in[i] != NULL; ++i)
+            if (strlen (mp->in[i]) > strlen (result))
+              result = mp->in[i];
+          if (STREQ (result, mp->is))
             {
-              for (i = 0; mp->in[i] != NULL; ++i)
-                if (strlen (mp->in[i]) > strlen (result))
-                  result = mp->in[i];
-              if (STREQ (result, mp->is))
-                {
-                  exact = true;
-                  begline = mp->begline;
-                  endline = mp->endline;
-                }
+              exact = true;
+              begline = mp->begline;
+              endline = mp->endline;
             }
           goto done;
 
         case CAT:
-          assert (mp && mp->prev);
           {
-            must *lmp;
-            must *rmp;
+            must *rmp = mp;
+            must *lmp = mp = mp->prev;
 
-            rmp = mp;
-            lmp = mp = mp->prev;
             /* In.  Everything in left, plus everything in
                right, plus concatenation of
                left's right and right's left.  */
@@ -4018,7 +4008,6 @@ dfamust (struct dfa *d)
 
         default:
           mp = allocmust (mp);
-          resetmust (mp);
           if (CSET <= t)
             {
               /* If T is a singleton, or if case-folding in a unibyte
@@ -4059,8 +4048,13 @@ done:
       dm->next = d->musts;
       d->musts = dm;
     }
-  if (mp)
-    freemust (mp);
+
+  while (mp)
+    {
+      must *prev = mp->prev;
+      freemust (mp);
+      mp = prev;
+    }
 }
 
 struct dfa *

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |  129 ++++++++++++++++++++++++++++--------------------------------
 1 files changed, 60 insertions(+), 69 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Thu Apr 24 21:06:21 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WdUar-0008Jb-CP
	for mharc-grep-commit@gnu.org; Thu, 24 Apr 2014 21:06:21 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:60759)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdUQX-0007d5-44
	for grep-commit@gnu.org; Thu, 24 Apr 2014 20:55:42 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdPeq-0003Q8-Vc
	for grep-commit@gnu.org; Thu, 24 Apr 2014 15:50:10 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:58930)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdPeq-0003OZ-Sv
	for grep-commit@gnu.org; Thu, 24 Apr 2014 15:50:08 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdPep-0000S8-A7
	for grep-commit@gnu.org; Thu, 24 Apr 2014 19:50:07 +0000
Date: Thu, 24 Apr 2014 19:50:07 +0000
Message-Id: <E1WdPep-0000S8-A7@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-99-g59f3fac
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: a9c9f65425ee313b1a24b32bfa3f9fec679bbcc7
X-Git-Newrev: 59f3fac48e8b5456f4e0a45dfd99fba38d8b7af5
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 25 Apr 2014 01:06:19 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  59f3fac48e8b5456f4e0a45dfd99fba38d8b7af5 (commit)
      from  a9c9f65425ee313b1a24b32bfa3f9fec679bbcc7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=59f3fac48e8b5456f4e0a45dfd99fba38d8b7af5


commit 59f3fac48e8b5456f4e0a45dfd99fba38d8b7af5
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 24 12:49:58 2014 -0700

    dfa: fix incorrect comment that led to heap overrun
    
    * dfa.c (maybe_realloc): Fix comment to match behavior.

diff --git a/src/dfa.c b/src/dfa.c
index 8fc3d6f..f9938b0 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -624,10 +624,14 @@ equal (charclass const s1, charclass const s2)
   return memcmp (s1, s2, sizeof (charclass)) == 0;
 }
 
-/* If needed, reallocate *PTR so that it holds at least NITEMS items.
-   The array holds *NALLOC items; *NALLOC is updated on reallocation.
-   ITEMSIZE is the size of one item.  Avoid O(N**2) behavior on arrays
-   growing linearly.  */
+/* Ensure that the array addressed by PTR holds at least NITEMS +
+   (PTR || !NITEMS) items.  Either return PTR, or reallocate the array
+   and return its new address.  Although PTR may be null, the returned
+   value is never null.
+
+   The array holds *NALLOC items; *NALLOC must be zero if PTR is null,
+   and is updated on reallocation.  ITEMSIZE is the size of one item.
+   Avoid O(N**2) behavior on arrays growing linearly.  */
 static void *
 maybe_realloc (void *ptr, size_t nitems, size_t *nalloc, size_t itemsize)
 {

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Thu Apr 24 21:24:39 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WdUsY-00078S-TJ
	for mharc-grep-commit@gnu.org; Thu, 24 Apr 2014 21:24:38 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:60759)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WdUSC-0007d5-So
	for grep-commit@gnu.org; Thu, 24 Apr 2014 20:57:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WdMQK-0006ne-8h
	for grep-commit@gnu.org; Thu, 24 Apr 2014 12:22:57 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:57037)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1WdMQK-0006nU-4W
	for grep-commit@gnu.org; Thu, 24 Apr 2014 12:22:56 -0400
Received: from meyering by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <jim@meyering.net>) id 1WdMQJ-0001Bz-Oq
	for grep-commit@gnu.org; Thu, 24 Apr 2014 16:22:55 +0000
Date: Thu, 24 Apr 2014 16:22:55 +0000
Message-Id: <E1WdMQJ-0001Bz-Oq@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-96-g2c78063
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: c841bbb0fc18abaa20638a4f9b965ec075c23457
X-Git-Newrev: 2c780631f89a1e50fe8221f72e128cf39b212141
From: Jim Meyering <jim@meyering.net>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 25 Apr 2014 01:24:37 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  2c780631f89a1e50fe8221f72e128cf39b212141 (commit)
      from  c841bbb0fc18abaa20638a4f9b965ec075c23457 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=2c780631f89a1e50fe8221f72e128cf39b212141


commit 2c780631f89a1e50fe8221f72e128cf39b212141
Author: Jim Meyering <meyering@fb.com>
Date:   Thu Apr 24 09:03:39 2014 -0700

    grep: fix new heap write buffer overrun
    
    * src/dfa.c (parse_bracket_exp): Fix off-by-one allocation error.
    Exposed by running the tests with an ASAN-enabled binary (i.e.,
    created using gcc's -fsanitize=address option).  Introduced by
    commit v2.18-70-gd3d9612, "dfa: simplify range char allocation".

diff --git a/src/dfa.c b/src/dfa.c
index 5dc0f09..24b4d5c 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -1125,7 +1125,7 @@ parse_bracket_exp (void)
                      is wrong in multiple ways, it's never used in practice.
                      FIXME: Remove this (and related) unused code.  */
                   work_mbc->ranges
-                    = maybe_realloc (work_mbc->ranges, work_mbc->nranges + 1,
+                    = maybe_realloc (work_mbc->ranges, work_mbc->nranges + 2,
                                      &ranges_al, sizeof *work_mbc->ranges);
                   work_mbc->ranges[work_mbc->nranges].beg
                     = case_fold ? towlower (wc) : wc;

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Fri Apr 25 00:24:55 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WdXh1-00056E-BI
	for mharc-grep-commit@gnu.org; Fri, 25 Apr 2014 00:24:55 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:46297)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdXgy-00054L-UX
	for grep-commit@gnu.org; Fri, 25 Apr 2014 00:24:53 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdXgx-0002lV-QB
	for grep-commit@gnu.org; Fri, 25 Apr 2014 00:24:52 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:34925)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdXgx-0002lO-Mo
	for grep-commit@gnu.org; Fri, 25 Apr 2014 00:24:51 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdXgx-0004vy-15
	for grep-commit@gnu.org; Fri, 25 Apr 2014 04:24:51 +0000
Date: Fri, 25 Apr 2014 04:24:51 +0000
Message-Id: <E1WdXgx-0004vy-15@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-103-gb73296a
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: b642fb02a94c0f6b9ff47f2b62c7d8f11ea3f223
X-Git-Newrev: b73296ace186451b096b075461634c153d1fa525
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 25 Apr 2014 04:24:54 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  b73296ace186451b096b075461634c153d1fa525 (commit)
      from  b642fb02a94c0f6b9ff47f2b62c7d8f11ea3f223 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=b73296ace186451b096b075461634c153d1fa525


commit b73296ace186451b096b075461634c153d1fa525
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 24 21:24:22 2014 -0700

    misc: fix doc and test bugs re grep -z
    
    Problem reported by Stephane Chazelas in: http://bugs.gnu.org/16871
    * doc/grep.texi (Usage): Remove incorrect example with -P.
    * tests/pcre: Improve test so that it actually tests whether \s
    matches a newline.

diff --git a/doc/grep.texi b/doc/grep.texi
index f631f03..59d0d3c 100644
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -1719,25 +1719,19 @@ How can I match across lines?
 
 Standard grep cannot do this, as it is fundamentally line-based.
 Therefore, merely using the @code{[:space:]} character class does not
-match newlines in the way you might expect.  However, if your grep is
-compiled with Perl patterns enabled, the Perl @samp{s}
-modifier (which makes @code{.} match newlines) can be used:
-
-@example
-printf 'foo\nbar\n' | grep -P '(?s)foo.*?bar'
-@end example
+match newlines in the way you might expect.
 
 With the GNU @command{grep} option @code{-z} (@pxref{File and
 Directory Selection}), the input is terminated by null bytes.  Thus,
-you can match newlines in the input, but the output will be the whole
-file, so this is really only useful to determine if the pattern is
-present:
+you can match newlines in the input, but typically if there is a match
+the entire input is output, so this usage is often combined with
+output-suppressing options like @option{-q}, e.g.:
 
 @example
 printf 'foo\nbar\n' | grep -z -q 'foo[[:space:]]\+bar'
 @end example
 
-Failing either of those options, you need to transform the input
+If this does not suffice, you can transform the input
 before giving it to @command{grep}, or turn to @command{awk},
 @command{sed}, @command{perl}, or many other utilities that are
 designed to operate across lines.
diff --git a/tests/pcre b/tests/pcre
index cbe6884..7efa560 100755
--- a/tests/pcre
+++ b/tests/pcre
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Ensure that with -P, \s*$ matches a newline.
+# Ensure that with -P, \s matches a newline.
 #
 # Copyright (C) 2001, 2006, 2009-2014 Free Software Foundation, Inc.
 #
@@ -12,7 +12,7 @@ require_pcre_
 
 fail=0
 
-# See CVS revision 1.32 of "src/search.c".
 echo | grep -P '\s*$' || fail=1
+echo | grep -zP '\s$' || fail=1
 
 Exit $fail

-----------------------------------------------------------------------

Summary of changes:
 doc/grep.texi |   16 +++++-----------
 tests/pcre    |    4 ++--
 2 files changed, 7 insertions(+), 13 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Fri Apr 25 01:27:56 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WdYg0-0005x9-Bf
	for mharc-grep-commit@gnu.org; Fri, 25 Apr 2014 01:27:56 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:60759)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdUlv-0007d5-Q8
	for grep-commit@gnu.org; Thu, 24 Apr 2014 21:18:33 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdEjg-0002V8-Ta
	for grep-commit@gnu.org; Thu, 24 Apr 2014 04:10:25 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:51538)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdEjg-0002Uy-Kp
	for grep-commit@gnu.org; Thu, 24 Apr 2014 04:10:24 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdEjf-0005MP-Th
	for grep-commit@gnu.org; Thu, 24 Apr 2014 08:10:24 +0000
Date: Thu, 24 Apr 2014 08:10:23 +0000
Message-Id: <E1WdEjf-0005MP-Th@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-95-gc841bbb
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 8345ee380535825253744a0b22725171ab02479c
X-Git-Newrev: c841bbb0fc18abaa20638a4f9b965ec075c23457
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 25 Apr 2014 05:27:55 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  c841bbb0fc18abaa20638a4f9b965ec075c23457 (commit)
      from  8345ee380535825253744a0b22725171ab02479c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=c841bbb0fc18abaa20638a4f9b965ec075c23457


commit c841bbb0fc18abaa20638a4f9b965ec075c23457
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 24 01:10:01 2014 -0700

    build: suppress unsafe-loop-optimizations warnings
    
    I ran into one of these while trying out GCC 4.9.0's new
    -fsanitize=undefined option.  The warning told me that GCC didn't
    do an unsafe optimization, but in 'grep' this is not typically a
    symptom of a programming error.
    * configure.ac (WERROR_CFLAGS): Suppress -Wunsafe-loop-optimizations.

diff --git a/configure.ac b/configure.ac
index 6a99c40..c301ebe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -118,6 +118,7 @@ if test "$gl_gcc_warnings" = yes; then
   nw="$nw -Wpadded"                 # Our structs are not padded
   nw="$nw -Wvla"                    # warnings in gettext.h
   nw="$nw -Wswitch-default"         # Too many warnings for now
+  nw="$nw -Wunsafe-loop-optimizations" # OK to suppress unsafe optimizations
   nw="$nw -Winline"                 # streq.h's streq4, streq6 and strcaseeq6
   nw="$nw -Wstrict-overflow"        # regexec.c
 

-----------------------------------------------------------------------

Summary of changes:
 configure.ac |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Fri Apr 25 02:29:57 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WdZe0-00009N-RF
	for mharc-grep-commit@gnu.org; Fri, 25 Apr 2014 02:29:57 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:45487)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdZdy-0008SN-An
	for grep-commit@gnu.org; Fri, 25 Apr 2014 02:29:55 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdZdx-0008Nw-AR
	for grep-commit@gnu.org; Fri, 25 Apr 2014 02:29:54 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:36043)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdZdx-0008No-6f
	for grep-commit@gnu.org; Fri, 25 Apr 2014 02:29:53 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WdZdw-0007v8-KE
	for grep-commit@gnu.org; Fri, 25 Apr 2014 06:29:52 +0000
Date: Fri, 25 Apr 2014 06:29:52 +0000
Message-Id: <E1WdZdw-0007v8-KE@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-104-ga0f01ed
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: b73296ace186451b096b075461634c153d1fa525
X-Git-Newrev: a0f01ed8dc7e042232eab6bd123204196410c769
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Fri, 25 Apr 2014 06:29:55 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  a0f01ed8dc7e042232eab6bd123204196410c769 (commit)
      from  b73296ace186451b096b075461634c153d1fa525 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=a0f01ed8dc7e042232eab6bd123204196410c769


commit a0f01ed8dc7e042232eab6bd123204196410c769
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Thu Apr 24 23:29:19 2014 -0700

    dfa: fix recently-introduced memory leak
    
    Problem reported by Aharon Robbins in: http://bugs.gnu.org/17341
    * src/dfa.c (dfasuperset): free after dfafree.

diff --git a/src/dfa.c b/src/dfa.c
index 50264b2..8e6c708 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3547,7 +3547,10 @@ dfasuperset (struct dfa *d)
   if (have_nchar && (have_achar || d->multibyte))
     d->superset = sup;
   else
-    dfafree (sup);
+    {
+      dfafree (sup);
+      free (sup);
+    }
 }
 
 /* Parse and analyze a single string of the given length.  */

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Sat Apr 26 21:02:28 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WeDUB-0004FJ-QO
	for mharc-grep-commit@gnu.org; Sat, 26 Apr 2014 21:02:27 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:34969)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WeDU8-0004AQ-D3
	for grep-commit@gnu.org; Sat, 26 Apr 2014 21:02:25 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WeDU6-0006tM-VQ
	for grep-commit@gnu.org; Sat, 26 Apr 2014 21:02:24 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:38068)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WeDU6-0006tG-Rt
	for grep-commit@gnu.org; Sat, 26 Apr 2014 21:02:22 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WeDU5-0002rF-Th
	for grep-commit@gnu.org; Sun, 27 Apr 2014 01:02:22 +0000
Date: Sun, 27 Apr 2014 01:02:21 +0000
Message-Id: <E1WeDU5-0002rF-Th@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-106-gd3d9950
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: a0f01ed8dc7e042232eab6bd123204196410c769
X-Git-Newrev: d3d99505cb704563cedf4643301d54ecc717ae57
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 27 Apr 2014 01:02:26 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  d3d99505cb704563cedf4643301d54ecc717ae57 (commit)
       via  3255bc58e8fb2d98145dbb2dd17bae0a5e47a85e (commit)
      from  a0f01ed8dc7e042232eab6bd123204196410c769 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=d3d99505cb704563cedf4643301d54ecc717ae57


commit d3d99505cb704563cedf4643301d54ecc717ae57
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sat Apr 26 18:01:11 2014 -0700

    dfa: fix index bug in previous patch, and simplify
    
    * src/dfa.c, src/dfa.h (dfaisfast): Arg is const pointer.
    * src/dfa.c (dfaisfast): Simplify, since supersets never contain BACKREF.
    * src/dfa.h (dfaisfast): Declare to be pure.
    * src/dfasearch.c (EGexecute): Fix typo that could cause buffer
    read overrun when !dfafast.  Hoist duplicate computation out
    of an if's then and else parts.

diff --git a/src/dfa.c b/src/dfa.c
index fc638c8..362de2c 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3412,25 +3412,20 @@ dfahint (struct dfa *d, char const *begin, char *end, size_t *count)
 }
 
 bool
-dfaisfast (struct dfa *d)
+dfaisfast (struct dfa const *d)
 {
-  size_t i;
   if (d->superset)
+    return true;
+  else if (d->multibyte)
+    return false;
+  else
     {
-      for (i = 0; i < d->superset->tindex; i++)
-        if (d->superset->tokens[i] == BACKREF)
-          return false;
-      return true;
-    }
-  else if (!d->multibyte)
-    {
+      size_t i;
       for (i = 0; i < d->tindex; i++)
         if (d->tokens[i] == BACKREF)
           return false;
       return true;
     }
-  else
-    return false;
 }
 
 static void
diff --git a/src/dfa.h b/src/dfa.h
index 2dd4871..fbcb191 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -82,9 +82,8 @@ extern char *dfaexec (struct dfa *d, char const *begin, char *end,
 extern size_t dfahint (struct dfa *d, char const *begin, char *end,
                        size_t *count);
 
-/* Return true, if `multibyte' attribute of struct dfa is false and the
-   pattern doesn't have BACKREF.  */
-extern bool dfaisfast (struct dfa *);
+/* Return true if the DFA is likely to be fast.  */
+extern bool dfaisfast (struct dfa const *) _GL_ATTRIBUTE_PURE;
 
 /* Free the storage held by the components of a struct dfa. */
 extern void dfafree (struct dfa *);
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 79a0cd8..7edc96b 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -225,21 +225,21 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
           /* We don't care about an exact match.  */
           if (kwset)
             {
-              /* Find a possible match using the KWset matcher. */
+              /* Find a possible match using the KWset matcher.  */
               size_t offset = kwsexec (kwset, beg - begline,
                                        buflim - beg + begline, &kwsm);
               if (offset == (size_t) -1)
                 goto failure;
-              beg += offset;
-              /* Narrow down to the line containing the candidate, and
-                 run it through DFA. */
-              match = beg;
-              beg = memrchr (buf, eol, beg - buf);
+              match = beg + offset;
+
+              /* Narrow down to the line containing the candidate.  */
+              beg = memrchr (buf, eol, match - buf);
               beg = beg ? beg + 1 : buf;
+              end = memchr (match, eol, buflim - match);
+              end = end ? end + 1 : buflim;
+
               if (kwsm.index < kwset_exact_matches)
                 {
-                  end = memchr (beg, eol, buflim - beg);
-                  end = end ? end + 1 : buflim;
                   if (MB_CUR_MAX == 1)
                     goto success;
                   if (mb_start < beg)
@@ -256,9 +256,6 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                 }
               else if (!dfafast)
                 {
-                  /* Narrow down to the line we've found if dfa isn't fast. */
-                  end = memchr (match, eol, buflim - beg);
-                  end = end ? end + 1 : buflim;
                   if (dfahint (dfa, beg, (char *) end, NULL) == (size_t) -1)
                     continue;
                   if (! dfaexec (dfa, beg, (char *) end, 0, NULL, &backref))
@@ -267,8 +264,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
             }
           if (!kwset || dfafast)
             {
-              /* No good fixed strings or DFA is fast; start with DFA
-                 broadly. */
+              /* No good fixed strings or DFA is fast; use DFA.  */
               size_t offset, count;
               char const *next_beg;
               count = 0;
@@ -287,7 +283,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                 }
               else
                 next_beg = beg + offset;
-              /* Narrow down to the line we've found. */
+              /* Narrow down to the line we've found.  */
               beg = memrchr (buf, eol, next_beg - buf);
               beg = beg ? beg + 1 : buf;
               if (count != 0)

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=3255bc58e8fb2d98145dbb2dd17bae0a5e47a85e


commit d3d99505cb704563cedf4643301d54ecc717ae57
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sat Apr 26 18:01:11 2014 -0700

    dfa: fix index bug in previous patch, and simplify
    
    * src/dfa.c, src/dfa.h (dfaisfast): Arg is const pointer.
    * src/dfa.c (dfaisfast): Simplify, since supersets never contain BACKREF.
    * src/dfa.h (dfaisfast): Declare to be pure.
    * src/dfasearch.c (EGexecute): Fix typo that could cause buffer
    read overrun when !dfafast.  Hoist duplicate computation out
    of an if's then and else parts.

diff --git a/src/dfa.c b/src/dfa.c
index fc638c8..362de2c 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3412,25 +3412,20 @@ dfahint (struct dfa *d, char const *begin, char *end, size_t *count)
 }
 
 bool
-dfaisfast (struct dfa *d)
+dfaisfast (struct dfa const *d)
 {
-  size_t i;
   if (d->superset)
+    return true;
+  else if (d->multibyte)
+    return false;
+  else
     {
-      for (i = 0; i < d->superset->tindex; i++)
-        if (d->superset->tokens[i] == BACKREF)
-          return false;
-      return true;
-    }
-  else if (!d->multibyte)
-    {
+      size_t i;
       for (i = 0; i < d->tindex; i++)
         if (d->tokens[i] == BACKREF)
           return false;
       return true;
     }
-  else
-    return false;
 }
 
 static void
diff --git a/src/dfa.h b/src/dfa.h
index 2dd4871..fbcb191 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -82,9 +82,8 @@ extern char *dfaexec (struct dfa *d, char const *begin, char *end,
 extern size_t dfahint (struct dfa *d, char const *begin, char *end,
                        size_t *count);
 
-/* Return true, if `multibyte' attribute of struct dfa is false and the
-   pattern doesn't have BACKREF.  */
-extern bool dfaisfast (struct dfa *);
+/* Return true if the DFA is likely to be fast.  */
+extern bool dfaisfast (struct dfa const *) _GL_ATTRIBUTE_PURE;
 
 /* Free the storage held by the components of a struct dfa. */
 extern void dfafree (struct dfa *);
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 79a0cd8..7edc96b 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -225,21 +225,21 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
           /* We don't care about an exact match.  */
           if (kwset)
             {
-              /* Find a possible match using the KWset matcher. */
+              /* Find a possible match using the KWset matcher.  */
               size_t offset = kwsexec (kwset, beg - begline,
                                        buflim - beg + begline, &kwsm);
               if (offset == (size_t) -1)
                 goto failure;
-              beg += offset;
-              /* Narrow down to the line containing the candidate, and
-                 run it through DFA. */
-              match = beg;
-              beg = memrchr (buf, eol, beg - buf);
+              match = beg + offset;
+
+              /* Narrow down to the line containing the candidate.  */
+              beg = memrchr (buf, eol, match - buf);
               beg = beg ? beg + 1 : buf;
+              end = memchr (match, eol, buflim - match);
+              end = end ? end + 1 : buflim;
+
               if (kwsm.index < kwset_exact_matches)
                 {
-                  end = memchr (beg, eol, buflim - beg);
-                  end = end ? end + 1 : buflim;
                   if (MB_CUR_MAX == 1)
                     goto success;
                   if (mb_start < beg)
@@ -256,9 +256,6 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                 }
               else if (!dfafast)
                 {
-                  /* Narrow down to the line we've found if dfa isn't fast. */
-                  end = memchr (match, eol, buflim - beg);
-                  end = end ? end + 1 : buflim;
                   if (dfahint (dfa, beg, (char *) end, NULL) == (size_t) -1)
                     continue;
                   if (! dfaexec (dfa, beg, (char *) end, 0, NULL, &backref))
@@ -267,8 +264,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
             }
           if (!kwset || dfafast)
             {
-              /* No good fixed strings or DFA is fast; start with DFA
-                 broadly. */
+              /* No good fixed strings or DFA is fast; use DFA.  */
               size_t offset, count;
               char const *next_beg;
               count = 0;
@@ -287,7 +283,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                 }
               else
                 next_beg = beg + offset;
-              /* Narrow down to the line we've found. */
+              /* Narrow down to the line we've found.  */
               beg = memrchr (buf, eol, next_beg - buf);
               beg = beg ? beg + 1 : buf;
               if (count != 0)

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c       |   17 +++++++++++++++++
 src/dfa.h       |    3 +++
 src/dfasearch.c |   25 +++++++++++++------------
 3 files changed, 33 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Sat Apr 26 23:59:00 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WeGF2-0001c0-6L
	for mharc-grep-commit@gnu.org; Sat, 26 Apr 2014 23:59:00 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:51906)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WeGEy-0001bj-HH
	for grep-commit@gnu.org; Sat, 26 Apr 2014 23:58:58 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WeGEw-0008RS-9M
	for grep-commit@gnu.org; Sat, 26 Apr 2014 23:58:56 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:39249)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WeGEw-0008RH-4m
	for grep-commit@gnu.org; Sat, 26 Apr 2014 23:58:54 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WeGEv-0007Od-4s
	for grep-commit@gnu.org; Sun, 27 Apr 2014 03:58:53 +0000
Date: Sun, 27 Apr 2014 03:58:53 +0000
Message-Id: <E1WeGEv-0007Od-4s@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-108-g4c57448
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d3d99505cb704563cedf4643301d54ecc717ae57
X-Git-Newrev: 4c57448135ebd424c15c774ffba8a187e32bc0a3
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 27 Apr 2014 03:58:58 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  4c57448135ebd424c15c774ffba8a187e32bc0a3 (commit)
       via  7600fde5bcf50872a89d427fea4add1f590ada36 (commit)
      from  d3d99505cb704563cedf4643301d54ecc717ae57 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=4c57448135ebd424c15c774ffba8a187e32bc0a3


commit 4c57448135ebd424c15c774ffba8a187e32bc0a3
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sat Apr 26 18:18:59 2014 -0700

    kwset: speed up by using memchr2
    
    Idea suggested by Eric Blake in: http://bugs.gnu.org/17229#43
    * bootstrap.conf (gnulib_modules): Add memchr2.
    * src/kwset.c: Include stdint.h, for uintptr_t.  Include memchr2.h.
    (struct kwset): New members gc1, gc2, gc1help.
    (tr): Move earlier, so it can be used earlier.
    (kwsprep): Initialize struct kwset's new members.
    (memchr_kwset): Rename from memchr_trans.  Combine C and TRANS args into
    new arg KWSET.  All uses changed.  Use memchr2 when appropriate.
    (bmexec): Use new members instead of recomputing their values.
    Increase advance_heuristic; it's just a guess, but memchr2 probably
    makes it reasonable to increase it.

diff --git a/bootstrap.conf b/bootstrap.conf
index 367427d..9f3457d 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -57,6 +57,7 @@ manywarnings
 mbrlen
 mbrtowc
 memchr
+memchr2
 mempcpy
 minmax
 obstack
diff --git a/src/kwset.c b/src/kwset.c
index 406fa0e..8270f05 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -36,8 +36,10 @@
 #include "kwset.h"
 
 #include <stdbool.h>
+#include <stdint.h>
 #include <sys/types.h>
 #include "system.h"
+#include "memchr2.h"
 #include "obstack.h"
 #include "xalloc.h"
 
@@ -91,8 +93,33 @@ struct kwset
   char *target;			/* Target string if there's only one. */
   int *shift;			/* Used in Boyer-Moore search for one string. */
   char const *trans;		/* Character translation table. */
+
+  /* If there's only one string, this is the string's last byte,
+     translated via TRANS if TRANS is nonnull.  */
+  char gc1;
+
+  /* Likewise for the string's penultimate byte, if it has two or more
+     bytes.  */
+  char gc2;
+
+  /* If there's only one string, this helps to match the string's last byte.
+     If GC1HELP is negative, only GC1 matches the string's last byte;
+     otherwise at least two bytes match, and B matches if TRANS[B] == GC1.
+     If GC1HELP is in the range 0..(NCHAR - 1), there are exactly two
+     such matches, and GC1HELP is the other match after conversion to
+     unsigned char.  If GC1HELP is at least NCHAR, there are three or
+     more such matches; e.g., Greek has three sigma characters that
+     all match when case-folding.  */
+  int gc1help;
 };
 
+/* Use TRANS to transliterate C.  A null TRANS does no transliteration.  */
+static char
+tr (char const *trans, char c)
+{
+  return trans ? trans[U(c)] : c;
+}
+
 /* Allocate and initialize a keyword set object, returning an opaque
    pointer to it.  */
 kwset_t
@@ -456,6 +483,27 @@ kwsprep (kwset_t kwset)
               curr = curr->next;
             }
         }
+
+      char gc1 = tr (trans, kwset->target[kwset->mind - 1]);
+
+      /* Set GC1HELP according to whether exactly one, exactly two, or
+         three-or-more characters match GC1.  */
+      int gc1help = -1;
+      if (trans)
+        {
+          char const *equiv1 = memchr (trans, gc1, NCHAR);
+          char const *equiv2 = memchr (equiv1 + 1, gc1,
+                                       trans + NCHAR - (equiv1 + 1));
+          if (equiv2)
+            gc1help = (memchr (equiv2 + 1, gc1, trans + NCHAR - (equiv2 + 1))
+                       ? NCHAR
+                       : U(gc1) ^ (equiv1 - trans) ^ (equiv2 - trans));
+        }
+
+      kwset->gc1 = gc1;
+      kwset->gc1help = gc1help;
+      if (kwset->mind > 1)
+        kwset->gc2 = tr (trans, kwset->target[kwset->mind - 2]);
     }
 
   /* Fix things up for any translation table. */
@@ -464,13 +512,6 @@ kwsprep (kwset_t kwset)
       kwset->delta[i] = delta[U(trans[i])];
 }
 
-/* Use TRANS to transliterate C.  A null TRANS does no transliteration.  */
-static char
-tr (char const *trans, char c)
-{
-  return trans ? trans[U(c)] : c;
-}
-
 /* Delta2 portion of a Boyer-Moore search.  *TP is the string text
    pointer; it is updated in place.  EP is the end of the string text,
    and SP the end of the pattern.  LEN is the pattern length; it must
@@ -524,19 +565,23 @@ bm_delta2_search (char const **tpp, char const *ep, char const *sp, int len,
   return false;
 }
 
-/* Return the address of the first byte in the buffer S that equals C.
-   S contains N bytes.  If TRANS is nonnull, use it to transliterate
-   S's bytes before comparing them.  */
+/* Return the address of the first byte in the buffer S (of size N)
+   that matches the last byte specified by KWSET, a singleton.  */
 static char const *
-memchr_trans (char const *s, char c, size_t n, char const *trans)
+memchr_kwset (char const *s, size_t n, kwset_t kwset)
 {
-  if (! trans)
-    return memchr (s, c, n);
-  char const *slim = s + n;
+  if (kwset->gc1help < 0)
+    return memchr (s, kwset->gc1, n);
+  int small_heuristic = 2;
+  int small = (- (uintptr_t) s % sizeof (long)
+               + small_heuristic * sizeof (long));
+  size_t ntrans = kwset->gc1help < NCHAR && small < n ? small : n;
+  char const *slim = s + ntrans;
   for (; s < slim; s++)
-    if (trans[U(*s)] == c)
+    if (kwset->trans[U(*s)] == kwset->gc1)
       return s;
-  return NULL;
+  n -= ntrans;
+  return n == 0 ? NULL : memchr2 (s, kwset->gc1, kwset->gc1help, n);
 }
 
 /* Fast boyer-moore search. */
@@ -555,15 +600,15 @@ bmexec (kwset_t kwset, char const *text, size_t size)
     return -1;
   if (len == 1)
     {
-      tp = memchr_trans (text, kwset->target[0], size, trans);
+      tp = memchr_kwset (text, size, kwset);
       return tp ? tp - text : -1;
     }
 
   d1 = kwset->delta;
   sp = kwset->target + len;
   tp = text + len;
-  char gc1 = tr (trans, sp[-1]);
-  char gc2 = tr (trans, sp[-2]);
+  char gc1 = kwset->gc1;
+  char gc2 = kwset->gc2;
 
   /* Significance of 12: 1 (initial offset) + 10 (skip loop) + 1 (md2). */
   if (size > 12 * len)
@@ -590,11 +635,11 @@ bmexec (kwset_t kwset, char const *text, size_t size)
 
                     /* As a heuristic, prefer memchr to seeking by
                        delta1 when the latter doesn't advance much.  */
-                    int advance_heuristic = 4 * sizeof (long);
+                    int advance_heuristic = 16 * sizeof (long);
                     if (advance_heuristic <= tp - tp0)
                       goto big_advance;
                     tp--;
-                    tp = memchr_trans (tp, gc1, text + size - tp, trans);
+                    tp = memchr_kwset (tp, text + size - tp, kwset);
                     if (! tp)
                       return -1;
                     tp++;

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=7600fde5bcf50872a89d427fea4add1f590ada36


commit 4c57448135ebd424c15c774ffba8a187e32bc0a3
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sat Apr 26 18:18:59 2014 -0700

    kwset: speed up by using memchr2
    
    Idea suggested by Eric Blake in: http://bugs.gnu.org/17229#43
    * bootstrap.conf (gnulib_modules): Add memchr2.
    * src/kwset.c: Include stdint.h, for uintptr_t.  Include memchr2.h.
    (struct kwset): New members gc1, gc2, gc1help.
    (tr): Move earlier, so it can be used earlier.
    (kwsprep): Initialize struct kwset's new members.
    (memchr_kwset): Rename from memchr_trans.  Combine C and TRANS args into
    new arg KWSET.  All uses changed.  Use memchr2 when appropriate.
    (bmexec): Use new members instead of recomputing their values.
    Increase advance_heuristic; it's just a guess, but memchr2 probably
    makes it reasonable to increase it.

diff --git a/bootstrap.conf b/bootstrap.conf
index 367427d..9f3457d 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -57,6 +57,7 @@ manywarnings
 mbrlen
 mbrtowc
 memchr
+memchr2
 mempcpy
 minmax
 obstack
diff --git a/src/kwset.c b/src/kwset.c
index 406fa0e..8270f05 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -36,8 +36,10 @@
 #include "kwset.h"
 
 #include <stdbool.h>
+#include <stdint.h>
 #include <sys/types.h>
 #include "system.h"
+#include "memchr2.h"
 #include "obstack.h"
 #include "xalloc.h"
 
@@ -91,8 +93,33 @@ struct kwset
   char *target;			/* Target string if there's only one. */
   int *shift;			/* Used in Boyer-Moore search for one string. */
   char const *trans;		/* Character translation table. */
+
+  /* If there's only one string, this is the string's last byte,
+     translated via TRANS if TRANS is nonnull.  */
+  char gc1;
+
+  /* Likewise for the string's penultimate byte, if it has two or more
+     bytes.  */
+  char gc2;
+
+  /* If there's only one string, this helps to match the string's last byte.
+     If GC1HELP is negative, only GC1 matches the string's last byte;
+     otherwise at least two bytes match, and B matches if TRANS[B] == GC1.
+     If GC1HELP is in the range 0..(NCHAR - 1), there are exactly two
+     such matches, and GC1HELP is the other match after conversion to
+     unsigned char.  If GC1HELP is at least NCHAR, there are three or
+     more such matches; e.g., Greek has three sigma characters that
+     all match when case-folding.  */
+  int gc1help;
 };
 
+/* Use TRANS to transliterate C.  A null TRANS does no transliteration.  */
+static char
+tr (char const *trans, char c)
+{
+  return trans ? trans[U(c)] : c;
+}
+
 /* Allocate and initialize a keyword set object, returning an opaque
    pointer to it.  */
 kwset_t
@@ -456,6 +483,27 @@ kwsprep (kwset_t kwset)
               curr = curr->next;
             }
         }
+
+      char gc1 = tr (trans, kwset->target[kwset->mind - 1]);
+
+      /* Set GC1HELP according to whether exactly one, exactly two, or
+         three-or-more characters match GC1.  */
+      int gc1help = -1;
+      if (trans)
+        {
+          char const *equiv1 = memchr (trans, gc1, NCHAR);
+          char const *equiv2 = memchr (equiv1 + 1, gc1,
+                                       trans + NCHAR - (equiv1 + 1));
+          if (equiv2)
+            gc1help = (memchr (equiv2 + 1, gc1, trans + NCHAR - (equiv2 + 1))
+                       ? NCHAR
+                       : U(gc1) ^ (equiv1 - trans) ^ (equiv2 - trans));
+        }
+
+      kwset->gc1 = gc1;
+      kwset->gc1help = gc1help;
+      if (kwset->mind > 1)
+        kwset->gc2 = tr (trans, kwset->target[kwset->mind - 2]);
     }
 
   /* Fix things up for any translation table. */
@@ -464,13 +512,6 @@ kwsprep (kwset_t kwset)
       kwset->delta[i] = delta[U(trans[i])];
 }
 
-/* Use TRANS to transliterate C.  A null TRANS does no transliteration.  */
-static char
-tr (char const *trans, char c)
-{
-  return trans ? trans[U(c)] : c;
-}
-
 /* Delta2 portion of a Boyer-Moore search.  *TP is the string text
    pointer; it is updated in place.  EP is the end of the string text,
    and SP the end of the pattern.  LEN is the pattern length; it must
@@ -524,19 +565,23 @@ bm_delta2_search (char const **tpp, char const *ep, char const *sp, int len,
   return false;
 }
 
-/* Return the address of the first byte in the buffer S that equals C.
-   S contains N bytes.  If TRANS is nonnull, use it to transliterate
-   S's bytes before comparing them.  */
+/* Return the address of the first byte in the buffer S (of size N)
+   that matches the last byte specified by KWSET, a singleton.  */
 static char const *
-memchr_trans (char const *s, char c, size_t n, char const *trans)
+memchr_kwset (char const *s, size_t n, kwset_t kwset)
 {
-  if (! trans)
-    return memchr (s, c, n);
-  char const *slim = s + n;
+  if (kwset->gc1help < 0)
+    return memchr (s, kwset->gc1, n);
+  int small_heuristic = 2;
+  int small = (- (uintptr_t) s % sizeof (long)
+               + small_heuristic * sizeof (long));
+  size_t ntrans = kwset->gc1help < NCHAR && small < n ? small : n;
+  char const *slim = s + ntrans;
   for (; s < slim; s++)
-    if (trans[U(*s)] == c)
+    if (kwset->trans[U(*s)] == kwset->gc1)
       return s;
-  return NULL;
+  n -= ntrans;
+  return n == 0 ? NULL : memchr2 (s, kwset->gc1, kwset->gc1help, n);
 }
 
 /* Fast boyer-moore search. */
@@ -555,15 +600,15 @@ bmexec (kwset_t kwset, char const *text, size_t size)
     return -1;
   if (len == 1)
     {
-      tp = memchr_trans (text, kwset->target[0], size, trans);
+      tp = memchr_kwset (text, size, kwset);
       return tp ? tp - text : -1;
     }
 
   d1 = kwset->delta;
   sp = kwset->target + len;
   tp = text + len;
-  char gc1 = tr (trans, sp[-1]);
-  char gc2 = tr (trans, sp[-2]);
+  char gc1 = kwset->gc1;
+  char gc2 = kwset->gc2;
 
   /* Significance of 12: 1 (initial offset) + 10 (skip loop) + 1 (md2). */
   if (size > 12 * len)
@@ -590,11 +635,11 @@ bmexec (kwset_t kwset, char const *text, size_t size)
 
                     /* As a heuristic, prefer memchr to seeking by
                        delta1 when the latter doesn't advance much.  */
-                    int advance_heuristic = 4 * sizeof (long);
+                    int advance_heuristic = 16 * sizeof (long);
                     if (advance_heuristic <= tp - tp0)
                       goto big_advance;
                     tp--;
-                    tp = memchr_trans (tp, gc1, text + size - tp, trans);
+                    tp = memchr_kwset (tp, text + size - tp, kwset);
                     if (! tp)
                       return -1;
                     tp++;

-----------------------------------------------------------------------

Summary of changes:
 bootstrap.conf |    1 +
 src/kwset.c    |   98 ++++++++++++++++++++++++++++++++++++++++++-------------
 2 files changed, 76 insertions(+), 23 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Sun Apr 27 16:02:32 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WeVHU-0006px-J8
	for mharc-grep-commit@gnu.org; Sun, 27 Apr 2014 16:02:32 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:45179)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WeVHR-0006p8-KG
	for grep-commit@gnu.org; Sun, 27 Apr 2014 16:02:30 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WeVHQ-0006Xl-DD
	for grep-commit@gnu.org; Sun, 27 Apr 2014 16:02:29 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:51343)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WeVHQ-0006Xh-AT
	for grep-commit@gnu.org; Sun, 27 Apr 2014 16:02:28 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WeVHP-0005xZ-FT
	for grep-commit@gnu.org; Sun, 27 Apr 2014 20:02:27 +0000
Date: Sun, 27 Apr 2014 20:02:27 +0000
Message-Id: <E1WeVHP-0005xZ-FT@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-109-g7eb003e
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 4c57448135ebd424c15c774ffba8a187e32bc0a3
X-Git-Newrev: 7eb003e1625a9c4bd268fc46bad04c03ef7f0035
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Sun, 27 Apr 2014 20:02:30 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  7eb003e1625a9c4bd268fc46bad04c03ef7f0035 (commit)
      from  4c57448135ebd424c15c774ffba8a187e32bc0a3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=7eb003e1625a9c4bd268fc46bad04c03ef7f0035


commit 7eb003e1625a9c4bd268fc46bad04c03ef7f0035
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Sun Apr 27 13:01:17 2014 -0700

    kwset: improve performance by inlining more
    
    Problem reported by Norihiro Tanaka in <http://bugs.gnu.org/17229#55>.
    * src/kwset.c (bmexec_trans): Rename from bmexec, and make it inline.
    (bmexec): New implementation, which calls bmexec_trans.  This helps
    GCC inline more aggressively with the default optimization, and
    improves performance 25% with the reported benchmark on my host.

diff --git a/src/kwset.c b/src/kwset.c
index 8270f05..8e9b510 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -584,9 +584,9 @@ memchr_kwset (char const *s, size_t n, kwset_t kwset)
   return n == 0 ? NULL : memchr2 (s, kwset->gc1, kwset->gc1help, n);
 }
 
-/* Fast boyer-moore search. */
-static size_t _GL_ATTRIBUTE_PURE
-bmexec (kwset_t kwset, char const *text, size_t size)
+/* Fast Boyer-Moore search (inlinable version).  */
+static inline size_t _GL_ATTRIBUTE_PURE
+bmexec_trans (kwset_t kwset, char const *text, size_t size)
 {
   unsigned char const *d1;
   char const *ep, *sp, *tp;
@@ -667,6 +667,17 @@ bmexec (kwset_t kwset, char const *text, size_t size)
   return -1;
 }
 
+/* Fast Boyer-Moore search.  */
+static size_t
+bmexec (kwset_t kwset, char const *text, size_t size)
+{
+  /* Help the compiler inline bmexec_trans in two ways, depending on
+     whether kwset->trans is null.  */
+  return (kwset->trans
+          ? bmexec_trans (kwset, text, size)
+          : bmexec_trans (kwset, text, size));
+}
+
 /* Hairy multiple string search. */
 static size_t _GL_ARG_NONNULL ((4))
 cwexec (kwset_t kwset, char const *text, size_t len, struct kwsmatch *kwsmatch)

-----------------------------------------------------------------------

Summary of changes:
 src/kwset.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Mon Apr 28 00:57:11 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Wedct-0003DH-0F
	for mharc-grep-commit@gnu.org; Mon, 28 Apr 2014 00:57:11 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:46364)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1Wedcp-0003Ce-Ud
	for grep-commit@gnu.org; Mon, 28 Apr 2014 00:57:08 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1Wedcp-0005ts-2m
	for grep-commit@gnu.org; Mon, 28 Apr 2014 00:57:07 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:55903)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <jim@meyering.net>) id 1Wedco-0005tk-VS
	for grep-commit@gnu.org; Mon, 28 Apr 2014 00:57:06 -0400
Received: from meyering by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <jim@meyering.net>) id 1Wedco-0000Ec-CX
	for grep-commit@gnu.org; Mon, 28 Apr 2014 04:57:06 +0000
Date: Mon, 28 Apr 2014 04:57:06 +0000
Message-Id: <E1Wedco-0000Ec-CX@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-110-g040685d
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 7eb003e1625a9c4bd268fc46bad04c03ef7f0035
X-Git-Newrev: 040685d071bee2354b2a598db96cf969c50d0d62
From: Jim Meyering <jim@meyering.net>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Mon, 28 Apr 2014 04:57:08 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  040685d071bee2354b2a598db96cf969c50d0d62 (commit)
      from  7eb003e1625a9c4bd268fc46bad04c03ef7f0035 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=040685d071bee2354b2a598db96cf969c50d0d62


commit 040685d071bee2354b2a598db96cf969c50d0d62
Author: Jim Meyering <meyering@fb.com>
Date:   Sun Apr 27 21:46:54 2014 -0700

    gnulib: update to latest
    
    * gnulib: This fixes a bug whereby running bootstrap
    would remove our build-aux/git-log-fix file.

diff --git a/gnulib b/gnulib
index 2f40bc5..a0712c3 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 2f40bc523412742dac387b37d70b5a7f5d8363cc
+Subproject commit a0712c3bd924b6dcb085e7a1b7d22f0c91ae7d74

-----------------------------------------------------------------------

Summary of changes:
 gnulib |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Tue Apr 29 21:35:27 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1WfJQl-0001of-3J
	for mharc-grep-commit@gnu.org; Tue, 29 Apr 2014 21:35:27 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:39444)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WfJQi-0001oJ-Dc
	for grep-commit@gnu.org; Tue, 29 Apr 2014 21:35:25 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WfJQh-0007J7-5P
	for grep-commit@gnu.org; Tue, 29 Apr 2014 21:35:24 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:54457)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WfJQh-0007Ih-1v
	for grep-commit@gnu.org; Tue, 29 Apr 2014 21:35:23 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WfJQg-0006oa-GI
	for grep-commit@gnu.org; Wed, 30 Apr 2014 01:35:22 +0000
Date: Wed, 30 Apr 2014 01:35:22 +0000
Message-Id: <E1WfJQg-0006oa-GI@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-111-ged0c7d5
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: 040685d071bee2354b2a598db96cf969c50d0d62
X-Git-Newrev: ed0c7d559baf344db2b887256ccae8843e99efa8
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 30 Apr 2014 01:35:25 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  ed0c7d559baf344db2b887256ccae8843e99efa8 (commit)
      from  040685d071bee2354b2a598db96cf969c50d0d62 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=ed0c7d559baf344db2b887256ccae8843e99efa8


commit ed0c7d559baf344db2b887256ccae8843e99efa8
Author: Norihiro Tanaka <noritnk@kcn.ne.jp>
Date:   Mon Apr 28 21:28:51 2014 +0900

    kwset: improve performance by inlining tr
    
    Without this change, older versions of GCC won't inline 'tr', and this
    can hurt performance significantly.  See: http://bugs.gnu.org/17229#64
    * src/kwset.c (tr): Make it inline.

diff --git a/src/kwset.c b/src/kwset.c
index 8e9b510..6d21893 100644
--- a/src/kwset.c
+++ b/src/kwset.c
@@ -114,7 +114,7 @@ struct kwset
 };
 
 /* Use TRANS to transliterate C.  A null TRANS does no transliteration.  */
-static char
+static inline char
 tr (char const *trans, char c)
 {
   return trans ? trans[U(c)] : c;

-----------------------------------------------------------------------

Summary of changes:
 src/kwset.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Wed Apr 30 15:23:32 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Wfa6O-0007M6-JZ
	for mharc-grep-commit@gnu.org; Wed, 30 Apr 2014 15:23:32 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:57809)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wfa6J-0007J5-Iu
	for grep-commit@gnu.org; Wed, 30 Apr 2014 15:23:28 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wfa6H-0007Cd-Gj
	for grep-commit@gnu.org; Wed, 30 Apr 2014 15:23:27 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:36442)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wfa6H-0007CY-DU
	for grep-commit@gnu.org; Wed, 30 Apr 2014 15:23:25 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wfa6G-0006gZ-GW
	for grep-commit@gnu.org; Wed, 30 Apr 2014 19:23:24 +0000
Date: Wed, 30 Apr 2014 19:23:24 +0000
Message-Id: <E1Wfa6G-0006gZ-GW@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-112-gd4c8de2
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: ed0c7d559baf344db2b887256ccae8843e99efa8
X-Git-Newrev: d4c8de2f3e4f6dfaf964f04600d4bb37285d5623
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Wed, 30 Apr 2014 19:23:28 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  d4c8de2f3e4f6dfaf964f04600d4bb37285d5623 (commit)
      from  ed0c7d559baf344db2b887256ccae8843e99efa8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=d4c8de2f3e4f6dfaf964f04600d4bb37285d5623


commit d4c8de2f3e4f6dfaf964f04600d4bb37285d5623
Author: Norihiro Tanaka <noritnk@kcn.ne.jp>
Date:   Wed Apr 30 16:53:44 2014 +0900

    dfa: optimize memory allocation
    
    * src/dfa.c (epsclosure): get the value of 'visited' from the argument.
    (dfaanalyze): Define and allocate variable 'visited'.
    (dfastate): Use not 'insert' but 'merge' to insert positions for
    state 0 of DFA.

diff --git a/src/dfa.c b/src/dfa.c
index 362de2c..507d7f6 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -2129,13 +2129,11 @@ state_index (struct dfa *d, position_set const *s, int context)
    constraint.  Repeat exhaustively until no funny positions are left.
    S->elems must be large enough to hold the result.  */
 static void
-epsclosure (position_set * s, struct dfa const *d)
+epsclosure (position_set *s, struct dfa const *d, char *visited)
 {
   size_t i, j;
   position p, old;
-
-  /* Array of booleans, large enough to use char, not int.  */
-  char *visited = xzalloc (d->tindex);
+  bool initialized = false;
 
   for (i = 0; i < s->nelem; ++i)
     if (d->tokens[s->elems[i].index] >= NOTCHAR
@@ -2144,6 +2142,11 @@ epsclosure (position_set * s, struct dfa const *d)
         && d->tokens[s->elems[i].index] != MBCSET
         && d->tokens[s->elems[i].index] < CSET)
       {
+        if (!initialized)
+          {
+            memset (visited, 0, d->tindex * sizeof (*visited));
+            initialized = true;
+          }
         old = s->elems[i];
         p.constraint = old.constraint;
         delete (s->elems[i], s);
@@ -2184,8 +2187,6 @@ epsclosure (position_set * s, struct dfa const *d)
         /* Force rescan to start at the beginning.  */
         i = -1;
       }
-
-  free (visited);
 }
 
 /* Returns the set of contexts for which there is at least one
@@ -2312,6 +2313,7 @@ dfaanalyze (struct dfa *d, int searchflag)
   int separate_contexts;        /* Context wanted by some position.  */
   size_t i, j;
   position *pos;
+  char *visited = xnmalloc (d->tindex, sizeof *visited);
 
 #ifdef DEBUG
   fprintf (stderr, "dfaanalyze:\n");
@@ -2470,7 +2472,7 @@ dfaanalyze (struct dfa *d, int searchflag)
         putc ('\n', stderr);
 #endif
         copy (&d->follows[i], &merged);
-        epsclosure (&merged, d);
+        epsclosure (&merged, d, visited);
         copy (&merged, &d->follows[i]);
       }
 
@@ -2479,7 +2481,7 @@ dfaanalyze (struct dfa *d, int searchflag)
   merged.nelem = 0;
   for (i = 0; i < stk[-1].nfirstpos; ++i)
     insert (firstpos[i], &merged);
-  epsclosure (&merged, d);
+  epsclosure (&merged, d, visited);
 
   /* Build the initial state.  */
   separate_contexts = state_separate_contexts (&merged);
@@ -2490,6 +2492,7 @@ dfaanalyze (struct dfa *d, int searchflag)
   free (posalloc);
   free (stkalloc);
   free (merged.elems);
+  free (visited);
 }
 
 
@@ -2733,10 +2736,11 @@ dfastate (state_num s, struct dfa *d, state_num trans[])
 
       /* If we are building a searching matcher, throw in the positions
          of state 0 as well.  */
-      if (d->searchflag
-          && (!d->multibyte || !next_isnt_1st_byte))
-        for (j = 0; j < d->states[0].elems.nelem; ++j)
-          insert (d->states[0].elems.elems[j], &follows);
+      if (d->searchflag && (!d->multibyte || !next_isnt_1st_byte))
+        {
+          merge (&d->states[0].elems, &follows, &tmp);
+          copy (&tmp, &follows);
+        }
 
       /* Find out if the new state will want any context information.  */
       possible_contexts = charclass_context (labels[i]);

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c |   28 ++++++++++++++++------------
 1 files changed, 16 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
grep


From MAILER-DAEMON Wed Apr 30 21:32:47 2014
Received: from list by lists.gnu.org with archive (Exim 4.71)
	id 1Wffrj-00008W-1O
	for mharc-grep-commit@gnu.org; Wed, 30 Apr 2014 21:32:47 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:33408)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1Wffre-00008Q-Ny
	for grep-commit@gnu.org; Wed, 30 Apr 2014 21:32:45 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WffrZ-0003BH-2V
	for grep-commit@gnu.org; Wed, 30 Apr 2014 21:32:42 -0400
Received: from vcs.savannah.gnu.org ([140.186.70.72]:39817)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <eggert@cs.ucla.edu>) id 1WffrY-0003BD-UC
	for grep-commit@gnu.org; Wed, 30 Apr 2014 21:32:37 -0400
Received: from eggert by vcs.savannah.gnu.org with local (Exim 4.72)
	(envelope-from <eggert@cs.ucla.edu>) id 1WffrY-0001XX-6z
	for grep-commit@gnu.org; Thu, 01 May 2014 01:32:36 +0000
Date: Thu, 01 May 2014 01:32:36 +0000
Message-Id: <E1WffrY-0001XX-6z@vcs.savannah.gnu.org>
To: grep-commit@gnu.org
Subject: grep branch, master, updated. v2.18-115-g10ce910
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d4c8de2f3e4f6dfaf964f04600d4bb37285d5623
X-Git-Newrev: 10ce910928c757d1adb790a9c9e5bad7de289bd4
From: Paul Eggert <eggert@cs.ucla.edu>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 140.186.70.72
X-BeenThere: grep-commit@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: bug-grep@gnu.org
List-Id: CVS commit notices for GNU grep <grep-commit.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/grep-commit>
List-Post: <mailto:grep-commit@gnu.org>
List-Help: <mailto:grep-commit-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/grep-commit>,
	<mailto:grep-commit-request@gnu.org?subject=subscribe>
X-List-Received-Date: Thu, 01 May 2014 01:32:45 -0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  10ce910928c757d1adb790a9c9e5bad7de289bd4 (commit)
       via  cbc97d923cdf98a3fc3744438097f5fe023cbb44 (commit)
       via  74e77131657a127f00e6ddc860968ccb3d2f6e03 (commit)
      from  d4c8de2f3e4f6dfaf964f04600d4bb37285d5623 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=10ce910928c757d1adb790a9c9e5bad7de289bd4


commit 10ce910928c757d1adb790a9c9e5bad7de289bd4
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Wed Apr 30 00:03:18 2014 -0700

    grep: simplify EGexecute further
    
    * src/dfa.c, src/dfa.h (dfasuperset): Arg is now const pointer.
    Now pure.
    * src/dfasearch.c (EGexecute): Coalesce some duplicate code.
    Don't worry about memrchr returning NULL when that's impossible.

diff --git a/src/dfa.c b/src/dfa.c
index 1bc6925..45dcc52 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3395,10 +3395,8 @@ dfaexec (struct dfa *d, char const *begin, char *end,
   return (char *) p;
 }
 
-/* Return superset for D, which searchs through a buffer looking for a
-   potential match.  */
 struct dfa *
-dfasuperset (struct dfa *d)
+dfasuperset (struct dfa const *d)
 {
   return d->superset;
 }
diff --git a/src/dfa.h b/src/dfa.h
index 2de7ba8..e3ab700 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -71,9 +71,11 @@ extern void dfacomp (char const *, size_t, struct dfa *, int);
 extern char *dfaexec (struct dfa *d, char const *begin, char *end,
                       int newline, size_t *count, int *backref);
 
-/* Return superset for D, which searchs through a buffer looking for a
-   potential match.  */
-extern struct dfa *dfasuperset (struct dfa *d);
+/* Return a superset for D.  The superset matches everything that D
+   matches, along with some other strings (though the latter should be
+   rare, for efficiency reasons).  Return a null pointer if no useful
+   superset is available.  */
+extern struct dfa *dfasuperset (struct dfa const *d) _GL_ATTRIBUTE_PURE;
 
 /* Return true if the DFA is likely to be fast.  */
 extern bool dfaisfast (struct dfa const *) _GL_ATTRIBUTE_PURE;
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 6d3765b..5ad6c9d 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -227,7 +227,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
         {
           char const *next_beg, *dfa_beg = beg;
           size_t count = 0;
-          bool narrowed = false;
+          bool exact_kwset_match = false;
 
           /* Try matching with KWset, if it's defined.  */
           if (kwset)
@@ -241,17 +241,30 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                 goto failure;
               match = beg + offset;
               prev_beg = beg;
-              
-              /* Narrow down to the line we've found.  */
+
+              /* Narrow down to the line containing the possible match.  */
               beg = memrchr (buf, eol, match - buf);
               beg = beg ? beg + 1 : buf;
               dfa_beg = beg;
 
-              if (kwsm.index < kwset_exact_matches)
-                {
-                  end = memchr (match, eol, buflim - match);
-                  end = end ? end + 1 : buflim;
+              /* Determine the end pointer to give the DFA next.  Typically
+                 this is after the first newline after MATCH; but if the KWset
+                 match is not exact, the DFA is fast, and the offset from
+                 PREV_BEG is less than 64 or (MATCH - PREV_BEG), this is the
+                 greater of the latter two values; this temporarily prefers
+                 the DFA to KWset.  */
+              exact_kwset_match = kwsm.index < kwset_exact_matches;
+              end = ((exact_kwset_match || !dfafast
+                      || MAX (16, match - beg) < (match - prev_beg) >> 2)
+                     ? match
+                     : (buflim - prev_beg) >> 2 <= match - beg
+                     ? buflim
+                     : prev_beg + 4 * (match - beg));
+              end = memchr (end, eol, buflim - end);
+              end = end ? end + 1 : buflim;
 
+              if (exact_kwset_match)
+                {
                   if (MB_CUR_MAX == 1)
                     goto success;
                   if (mb_start < beg)
@@ -263,69 +276,30 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                      character.  Perform the DFA search starting from the
                      beginning of the next character.  */
                   dfa_beg = mb_start;
-                  narrowed = true;
-                }
-              else if (dfafast)
-                {
-                  /* Determine the end pointer to start with DFA.  It's
-                     `match' by default.  If the offset from prev_beg is
-                     lesser than (match - beg) * 4 and/or 64, set it to
-                     greatest value in them.  A larger offset than the
-                     default means that DFA is preferred to KWset.  */
-                  offset = (match - beg) * 4;
-                  if (offset < 64)
-                    offset = 64;
-                  if (prev_beg + offset > match)
-                    {
-                      end = prev_beg + offset;
-                      if (end < buflim)
-                        {
-                          end = memchr (end, eol, buflim - end);
-                          end = end ? end + 1 : buflim;
-                        }
-                      else
-                        end = buflim;
-                    }
-                  else
-                    {
-                      end = memchr (match, eol, buflim - match);
-                      end = end ? end + 1 : buflim;
-                      narrowed = true;
-                    }
-                }
-              else
-                {
-                  end = memchr (match, eol, buflim - match);
-                  end = end ? end + 1 : buflim;
-                  narrowed = true;
                 }
             }
 
           /* Try matching with the superset of DFA, if it's defined.  */
-          if (superset && !(kwset && kwsm.index < kwset_exact_matches))
+          if (superset && !exact_kwset_match)
             {
-              next_beg = dfaexec (superset, dfa_beg, (char *) end, 1, &count, NULL);
+              next_beg = dfaexec (superset, dfa_beg, (char *) end, 1,
+                                  &count, NULL);
               /* If there's no match, or if we've matched the sentinel,
                  we're done.  */
               if (next_beg == NULL || next_beg == end)
                 continue;
-              if (!narrowed)
+
+              /* Narrow down to the line we've found.  */
+              if (count != 0)
                 {
-                  /* Narrow down to the line we've found.  */
-                  if (count != 0)
-                    {
-                      beg = memrchr (buf, eol, next_beg - buf);
-                      beg = beg ? beg + 1 : buf;
-
-                      /* If dfaexec may match in multiple lines, try to
-                         match in one line.  */
-                      end = beg;
-                      continue;
-                    }
-                  end = memchr (next_beg, eol, buflim - next_beg);
-                  end = end ? end + 1 : buflim;
-                  narrowed = true;
+                  /* If dfaexec may match in multiple lines, try to
+                     match in one line.  */
+                  end = memrchr (buf, eol, next_beg - buf);
+                  end++;
+                  continue;
                 }
+              end = memchr (next_beg, eol, buflim - next_beg);
+              end = end ? end + 1 : buflim;
             }
 
           /* Try matching with DFA.  */
@@ -335,17 +309,15 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
              we're done.  */
           if (next_beg == NULL || next_beg == end)
             continue;
-          if (!narrowed)
+
+          /* Narrow down to the line we've found.  */
+          if (count != 0)
             {
-              /* Narrow down to the line we've found.  */
-              if (count != 0)
-                {
-                  beg = memrchr (buf, eol, next_beg - buf);
-                  beg = beg ? beg + 1 : buf;
-                }
-              end = memchr (next_beg, eol, buflim - next_beg);
-              end = end ? end + 1 : buflim;
+              beg = memrchr (buf, eol, next_beg - buf);
+              beg++;
             }
+          end = memchr (next_beg, eol, buflim - next_beg);
+          end = end ? end + 1 : buflim;
 
           /* Successful, no backreferences encountered! */
           if (!backref)
@@ -364,8 +336,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
       if (TYPE_MAXIMUM (regoff_t) < end - beg - 1)
         xalloc_die ();
 
-      /* If we've made it to this point, this means DFA has seen
-         a probable match, and we need to run it through Regex. */
+      /* Run the possible match through Regex.  */
       best_match = end;
       best_len = 0;
       for (i = 0; i < pcount; i++)

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=cbc97d923cdf98a3fc3744438097f5fe023cbb44


commit 10ce910928c757d1adb790a9c9e5bad7de289bd4
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Wed Apr 30 00:03:18 2014 -0700

    grep: simplify EGexecute further
    
    * src/dfa.c, src/dfa.h (dfasuperset): Arg is now const pointer.
    Now pure.
    * src/dfasearch.c (EGexecute): Coalesce some duplicate code.
    Don't worry about memrchr returning NULL when that's impossible.

diff --git a/src/dfa.c b/src/dfa.c
index 1bc6925..45dcc52 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3395,10 +3395,8 @@ dfaexec (struct dfa *d, char const *begin, char *end,
   return (char *) p;
 }
 
-/* Return superset for D, which searchs through a buffer looking for a
-   potential match.  */
 struct dfa *
-dfasuperset (struct dfa *d)
+dfasuperset (struct dfa const *d)
 {
   return d->superset;
 }
diff --git a/src/dfa.h b/src/dfa.h
index 2de7ba8..e3ab700 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -71,9 +71,11 @@ extern void dfacomp (char const *, size_t, struct dfa *, int);
 extern char *dfaexec (struct dfa *d, char const *begin, char *end,
                       int newline, size_t *count, int *backref);
 
-/* Return superset for D, which searchs through a buffer looking for a
-   potential match.  */
-extern struct dfa *dfasuperset (struct dfa *d);
+/* Return a superset for D.  The superset matches everything that D
+   matches, along with some other strings (though the latter should be
+   rare, for efficiency reasons).  Return a null pointer if no useful
+   superset is available.  */
+extern struct dfa *dfasuperset (struct dfa const *d) _GL_ATTRIBUTE_PURE;
 
 /* Return true if the DFA is likely to be fast.  */
 extern bool dfaisfast (struct dfa const *) _GL_ATTRIBUTE_PURE;
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 6d3765b..5ad6c9d 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -227,7 +227,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
         {
           char const *next_beg, *dfa_beg = beg;
           size_t count = 0;
-          bool narrowed = false;
+          bool exact_kwset_match = false;
 
           /* Try matching with KWset, if it's defined.  */
           if (kwset)
@@ -241,17 +241,30 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                 goto failure;
               match = beg + offset;
               prev_beg = beg;
-              
-              /* Narrow down to the line we've found.  */
+
+              /* Narrow down to the line containing the possible match.  */
               beg = memrchr (buf, eol, match - buf);
               beg = beg ? beg + 1 : buf;
               dfa_beg = beg;
 
-              if (kwsm.index < kwset_exact_matches)
-                {
-                  end = memchr (match, eol, buflim - match);
-                  end = end ? end + 1 : buflim;
+              /* Determine the end pointer to give the DFA next.  Typically
+                 this is after the first newline after MATCH; but if the KWset
+                 match is not exact, the DFA is fast, and the offset from
+                 PREV_BEG is less than 64 or (MATCH - PREV_BEG), this is the
+                 greater of the latter two values; this temporarily prefers
+                 the DFA to KWset.  */
+              exact_kwset_match = kwsm.index < kwset_exact_matches;
+              end = ((exact_kwset_match || !dfafast
+                      || MAX (16, match - beg) < (match - prev_beg) >> 2)
+                     ? match
+                     : (buflim - prev_beg) >> 2 <= match - beg
+                     ? buflim
+                     : prev_beg + 4 * (match - beg));
+              end = memchr (end, eol, buflim - end);
+              end = end ? end + 1 : buflim;
 
+              if (exact_kwset_match)
+                {
                   if (MB_CUR_MAX == 1)
                     goto success;
                   if (mb_start < beg)
@@ -263,69 +276,30 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                      character.  Perform the DFA search starting from the
                      beginning of the next character.  */
                   dfa_beg = mb_start;
-                  narrowed = true;
-                }
-              else if (dfafast)
-                {
-                  /* Determine the end pointer to start with DFA.  It's
-                     `match' by default.  If the offset from prev_beg is
-                     lesser than (match - beg) * 4 and/or 64, set it to
-                     greatest value in them.  A larger offset than the
-                     default means that DFA is preferred to KWset.  */
-                  offset = (match - beg) * 4;
-                  if (offset < 64)
-                    offset = 64;
-                  if (prev_beg + offset > match)
-                    {
-                      end = prev_beg + offset;
-                      if (end < buflim)
-                        {
-                          end = memchr (end, eol, buflim - end);
-                          end = end ? end + 1 : buflim;
-                        }
-                      else
-                        end = buflim;
-                    }
-                  else
-                    {
-                      end = memchr (match, eol, buflim - match);
-                      end = end ? end + 1 : buflim;
-                      narrowed = true;
-                    }
-                }
-              else
-                {
-                  end = memchr (match, eol, buflim - match);
-                  end = end ? end + 1 : buflim;
-                  narrowed = true;
                 }
             }
 
           /* Try matching with the superset of DFA, if it's defined.  */
-          if (superset && !(kwset && kwsm.index < kwset_exact_matches))
+          if (superset && !exact_kwset_match)
             {
-              next_beg = dfaexec (superset, dfa_beg, (char *) end, 1, &count, NULL);
+              next_beg = dfaexec (superset, dfa_beg, (char *) end, 1,
+                                  &count, NULL);
               /* If there's no match, or if we've matched the sentinel,
                  we're done.  */
               if (next_beg == NULL || next_beg == end)
                 continue;
-              if (!narrowed)
+
+              /* Narrow down to the line we've found.  */
+              if (count != 0)
                 {
-                  /* Narrow down to the line we've found.  */
-                  if (count != 0)
-                    {
-                      beg = memrchr (buf, eol, next_beg - buf);
-                      beg = beg ? beg + 1 : buf;
-
-                      /* If dfaexec may match in multiple lines, try to
-                         match in one line.  */
-                      end = beg;
-                      continue;
-                    }
-                  end = memchr (next_beg, eol, buflim - next_beg);
-                  end = end ? end + 1 : buflim;
-                  narrowed = true;
+                  /* If dfaexec may match in multiple lines, try to
+                     match in one line.  */
+                  end = memrchr (buf, eol, next_beg - buf);
+                  end++;
+                  continue;
                 }
+              end = memchr (next_beg, eol, buflim - next_beg);
+              end = end ? end + 1 : buflim;
             }
 
           /* Try matching with DFA.  */
@@ -335,17 +309,15 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
              we're done.  */
           if (next_beg == NULL || next_beg == end)
             continue;
-          if (!narrowed)
+
+          /* Narrow down to the line we've found.  */
+          if (count != 0)
             {
-              /* Narrow down to the line we've found.  */
-              if (count != 0)
-                {
-                  beg = memrchr (buf, eol, next_beg - buf);
-                  beg = beg ? beg + 1 : buf;
-                }
-              end = memchr (next_beg, eol, buflim - next_beg);
-              end = end ? end + 1 : buflim;
+              beg = memrchr (buf, eol, next_beg - buf);
+              beg++;
             }
+          end = memchr (next_beg, eol, buflim - next_beg);
+          end = end ? end + 1 : buflim;
 
           /* Successful, no backreferences encountered! */
           if (!backref)
@@ -364,8 +336,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
       if (TYPE_MAXIMUM (regoff_t) < end - beg - 1)
         xalloc_die ();
 
-      /* If we've made it to this point, this means DFA has seen
-         a probable match, and we need to run it through Regex. */
+      /* Run the possible match through Regex.  */
       best_match = end;
       best_len = 0;
       for (i = 0; i < pcount; i++)

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=74e77131657a127f00e6ddc860968ccb3d2f6e03


commit 10ce910928c757d1adb790a9c9e5bad7de289bd4
Author: Paul Eggert <eggert@cs.ucla.edu>
Date:   Wed Apr 30 00:03:18 2014 -0700

    grep: simplify EGexecute further
    
    * src/dfa.c, src/dfa.h (dfasuperset): Arg is now const pointer.
    Now pure.
    * src/dfasearch.c (EGexecute): Coalesce some duplicate code.
    Don't worry about memrchr returning NULL when that's impossible.

diff --git a/src/dfa.c b/src/dfa.c
index 1bc6925..45dcc52 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -3395,10 +3395,8 @@ dfaexec (struct dfa *d, char const *begin, char *end,
   return (char *) p;
 }
 
-/* Return superset for D, which searchs through a buffer looking for a
-   potential match.  */
 struct dfa *
-dfasuperset (struct dfa *d)
+dfasuperset (struct dfa const *d)
 {
   return d->superset;
 }
diff --git a/src/dfa.h b/src/dfa.h
index 2de7ba8..e3ab700 100644
--- a/src/dfa.h
+++ b/src/dfa.h
@@ -71,9 +71,11 @@ extern void dfacomp (char const *, size_t, struct dfa *, int);
 extern char *dfaexec (struct dfa *d, char const *begin, char *end,
                       int newline, size_t *count, int *backref);
 
-/* Return superset for D, which searchs through a buffer looking for a
-   potential match.  */
-extern struct dfa *dfasuperset (struct dfa *d);
+/* Return a superset for D.  The superset matches everything that D
+   matches, along with some other strings (though the latter should be
+   rare, for efficiency reasons).  Return a null pointer if no useful
+   superset is available.  */
+extern struct dfa *dfasuperset (struct dfa const *d) _GL_ATTRIBUTE_PURE;
 
 /* Return true if the DFA is likely to be fast.  */
 extern bool dfaisfast (struct dfa const *) _GL_ATTRIBUTE_PURE;
diff --git a/src/dfasearch.c b/src/dfasearch.c
index 6d3765b..5ad6c9d 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -227,7 +227,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
         {
           char const *next_beg, *dfa_beg = beg;
           size_t count = 0;
-          bool narrowed = false;
+          bool exact_kwset_match = false;
 
           /* Try matching with KWset, if it's defined.  */
           if (kwset)
@@ -241,17 +241,30 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                 goto failure;
               match = beg + offset;
               prev_beg = beg;
-              
-              /* Narrow down to the line we've found.  */
+
+              /* Narrow down to the line containing the possible match.  */
               beg = memrchr (buf, eol, match - buf);
               beg = beg ? beg + 1 : buf;
               dfa_beg = beg;
 
-              if (kwsm.index < kwset_exact_matches)
-                {
-                  end = memchr (match, eol, buflim - match);
-                  end = end ? end + 1 : buflim;
+              /* Determine the end pointer to give the DFA next.  Typically
+                 this is after the first newline after MATCH; but if the KWset
+                 match is not exact, the DFA is fast, and the offset from
+                 PREV_BEG is less than 64 or (MATCH - PREV_BEG), this is the
+                 greater of the latter two values; this temporarily prefers
+                 the DFA to KWset.  */
+              exact_kwset_match = kwsm.index < kwset_exact_matches;
+              end = ((exact_kwset_match || !dfafast
+                      || MAX (16, match - beg) < (match - prev_beg) >> 2)
+                     ? match
+                     : (buflim - prev_beg) >> 2 <= match - beg
+                     ? buflim
+                     : prev_beg + 4 * (match - beg));
+              end = memchr (end, eol, buflim - end);
+              end = end ? end + 1 : buflim;
 
+              if (exact_kwset_match)
+                {
                   if (MB_CUR_MAX == 1)
                     goto success;
                   if (mb_start < beg)
@@ -263,69 +276,30 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
                      character.  Perform the DFA search starting from the
                      beginning of the next character.  */
                   dfa_beg = mb_start;
-                  narrowed = true;
-                }
-              else if (dfafast)
-                {
-                  /* Determine the end pointer to start with DFA.  It's
-                     `match' by default.  If the offset from prev_beg is
-                     lesser than (match - beg) * 4 and/or 64, set it to
-                     greatest value in them.  A larger offset than the
-                     default means that DFA is preferred to KWset.  */
-                  offset = (match - beg) * 4;
-                  if (offset < 64)
-                    offset = 64;
-                  if (prev_beg + offset > match)
-                    {
-                      end = prev_beg + offset;
-                      if (end < buflim)
-                        {
-                          end = memchr (end, eol, buflim - end);
-                          end = end ? end + 1 : buflim;
-                        }
-                      else
-                        end = buflim;
-                    }
-                  else
-                    {
-                      end = memchr (match, eol, buflim - match);
-                      end = end ? end + 1 : buflim;
-                      narrowed = true;
-                    }
-                }
-              else
-                {
-                  end = memchr (match, eol, buflim - match);
-                  end = end ? end + 1 : buflim;
-                  narrowed = true;
                 }
             }
 
           /* Try matching with the superset of DFA, if it's defined.  */
-          if (superset && !(kwset && kwsm.index < kwset_exact_matches))
+          if (superset && !exact_kwset_match)
             {
-              next_beg = dfaexec (superset, dfa_beg, (char *) end, 1, &count, NULL);
+              next_beg = dfaexec (superset, dfa_beg, (char *) end, 1,
+                                  &count, NULL);
               /* If there's no match, or if we've matched the sentinel,
                  we're done.  */
               if (next_beg == NULL || next_beg == end)
                 continue;
-              if (!narrowed)
+
+              /* Narrow down to the line we've found.  */
+              if (count != 0)
                 {
-                  /* Narrow down to the line we've found.  */
-                  if (count != 0)
-                    {
-                      beg = memrchr (buf, eol, next_beg - buf);
-                      beg = beg ? beg + 1 : buf;
-
-                      /* If dfaexec may match in multiple lines, try to
-                         match in one line.  */
-                      end = beg;
-                      continue;
-                    }
-                  end = memchr (next_beg, eol, buflim - next_beg);
-                  end = end ? end + 1 : buflim;
-                  narrowed = true;
+                  /* If dfaexec may match in multiple lines, try to
+                     match in one line.  */
+                  end = memrchr (buf, eol, next_beg - buf);
+                  end++;
+                  continue;
                 }
+              end = memchr (next_beg, eol, buflim - next_beg);
+              end = end ? end + 1 : buflim;
             }
 
           /* Try matching with DFA.  */
@@ -335,17 +309,15 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
              we're done.  */
           if (next_beg == NULL || next_beg == end)
             continue;
-          if (!narrowed)
+
+          /* Narrow down to the line we've found.  */
+          if (count != 0)
             {
-              /* Narrow down to the line we've found.  */
-              if (count != 0)
-                {
-                  beg = memrchr (buf, eol, next_beg - buf);
-                  beg = beg ? beg + 1 : buf;
-                }
-              end = memchr (next_beg, eol, buflim - next_beg);
-              end = end ? end + 1 : buflim;
+              beg = memrchr (buf, eol, next_beg - buf);
+              beg++;
             }
+          end = memchr (next_beg, eol, buflim - next_beg);
+          end = end ? end + 1 : buflim;
 
           /* Successful, no backreferences encountered! */
           if (!backref)
@@ -364,8 +336,7 @@ EGexecute (char const *buf, size_t size, size_t *match_size,
       if (TYPE_MAXIMUM (regoff_t) < end - beg - 1)
         xalloc_die ();
 
-      /* If we've made it to this point, this means DFA has seen
-         a probable match, and we need to run it through Regex. */
+      /* Run the possible match through Regex.  */
       best_match = end;
       best_len = 0;
       for (i = 0; i < pcount; i++)

-----------------------------------------------------------------------

Summary of changes:
 src/dfa.c       |   26 +++----------
 src/dfa.h       |   15 ++-----
 src/dfasearch.c |  113 ++++++++++++++++++++++++++++++-------------------------
 3 files changed, 73 insertions(+), 81 deletions(-)


hooks/post-receive
-- 
grep


