Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Sep 2011 19:55:49 +0000 (UTC)
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r225487 - in user/gabor/grep/trunk: . regex
Message-ID:  <201109111955.p8BJtnUw093350@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gabor
Date: Sun Sep 11 19:55:49 2011
New Revision: 225487
URL: http://svn.freebsd.org/changeset/base/225487

Log:
  - Increase WARNS to 3

Modified:
  user/gabor/grep/trunk/Makefile
  user/gabor/grep/trunk/regex/fastmatch.h
  user/gabor/grep/trunk/regex/tre-fastmatch.c

Modified: user/gabor/grep/trunk/Makefile
==============================================================================
--- user/gabor/grep/trunk/Makefile	Sun Sep 11 19:37:57 2011	(r225486)
+++ user/gabor/grep/trunk/Makefile	Sun Sep 11 19:55:49 2011	(r225487)
@@ -15,7 +15,7 @@ bsdgrep.1: grep.1
 .endif
 SRCS=	file.c grep.c queue.c util.c
 
-WARNS=2
+WARNS=3
 
 # Extra files ported backported form some regex improvements
 .PATH: ${.CURDIR}/regex

Modified: user/gabor/grep/trunk/regex/fastmatch.h
==============================================================================
--- user/gabor/grep/trunk/regex/fastmatch.h	Sun Sep 11 19:37:57 2011	(r225486)
+++ user/gabor/grep/trunk/regex/fastmatch.h	Sun Sep 11 19:55:49 2011	(r225487)
@@ -14,11 +14,11 @@ typedef struct {
   wchar_t	*wpattern;
   bool		*wescmap;
   unsigned int	 hasdot;
-  int		 qsBc[UCHAR_MAX + 1];
+  unsigned int	 qsBc[UCHAR_MAX + 1];
   unsigned int	*bmGs;
   char		*pattern;
   bool		*escmap;
-  int		 defBc;
+  unsigned int	 defBc;
   void		*qsBc_table;
   unsigned int	*sbmGs;
   const char	*re_endp;

Modified: user/gabor/grep/trunk/regex/tre-fastmatch.c
==============================================================================
--- user/gabor/grep/trunk/regex/tre-fastmatch.c	Sun Sep 11 19:37:57 2011	(r225486)
+++ user/gabor/grep/trunk/regex/tre-fastmatch.c	Sun Sep 11 19:55:49 2011	(r225487)
@@ -131,14 +131,15 @@ static int	fastcmp(const void *, const b
   CHECKBOUNDS;								\
 									\
   {									\
-    int bc = 0, gs = 0, ts, r = -1;					\
+    int r = -1;								\
+    unsigned int bc = 0, gs = 0, ts;					\
 									\
     switch (type)							\
       {									\
 	case STR_WIDE:							\
 	  if (!fg->hasdot)						\
 	    {								\
-	      if (u != 0 && mismatch == fg->wlen - 1 - shift)		\
+	      if (u != 0 && (unsigned)mismatch == fg->wlen - 1 - shift)	\
 		mismatch -= u;						\
 	      v = fg->wlen - 1 - mismatch;				\
 	      r = hashtable_get(fg->qsBc_table,				\
@@ -153,7 +154,7 @@ static int	fastcmp(const void *, const b
 	default:							\
 	  if (!fg->hasdot)						\
 	    {								\
-	      if (u != 0 && mismatch == fg->len - 1 - shift)		\
+	      if (u != 0 && (unsigned)mismatch == fg->len - 1 - shift)	\
 		mismatch -= u;						\
 	      v = fg->len - 1 - mismatch;				\
 	      gs = fg->sbmGs[mismatch];					\
@@ -167,7 +168,7 @@ static int	fastcmp(const void *, const b
       shift = bc;							\
     else								\
       {									\
-	ts = u - v;							\
+	ts = ((long)u - v < 0) ? 0 : (u - v);				\
 	shift = MAX(ts, bc);						\
 	shift = MAX(shift, gs);						\
 	if (shift == gs)						\
@@ -179,7 +180,7 @@ static int	fastcmp(const void *, const b
 	    u = 0;							\
 	  }								\
       }									\
-      DPRINT(("tre_fast_match: shifting %d characters\n", shift));	\
+      DPRINT(("tre_fast_match: shifting %u characters\n", shift));	\
       j += shift;							\
   }
 
@@ -263,7 +264,7 @@ static int	fastcmp(const void *, const b
 
 #ifdef _GREP_DEBUG
 #define DPRINT_BMGS(len, fmt_str, sh)					\
-  for (int i = 0; i < len; i++)						\
+  for (unsigned int i = 0; i < len; i++)				\
     DPRINT((fmt_str, i, sh[i]));
 #else
 #define DPRINT_BMGS(len, fmt_str, sh)					\
@@ -725,9 +726,9 @@ int
 tre_match_fast(const fastmatch_t *fg, const void *data, size_t len,
     tre_str_type_t type, int nmatch, regmatch_t pmatch[], int eflags)
 {
-  unsigned int j = 0;
+  unsigned int j = 0, shift, u = 0, v;
   int ret = REG_NOMATCH;
-  int mismatch, shift, u = 0, v;
+  int mismatch;
   const char *str_byte = data;
   const void *startptr = NULL;
   const tre_char_t *str_wide = data;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201109111955.p8BJtnUw093350>