bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use of 0 instead of NULL in src/kwset.c


From: Charles Levert
Subject: Re: Use of 0 instead of NULL in src/kwset.c
Date: Mon, 4 Jul 2005 04:57:18 -0400
User-agent: Mutt/1.4.1i

* On Monday 2005-07-04 at 00:05:59 -0700, Paul Eggert wrote:
> Charles Levert <address@hidden> writes:
> 
> > +     unsigned u = kwset->mind - (i + 1);
> 
> A minor point: the usual GNU style is to say "unsigned int" rather
> than plain "unsigned".
> 
> Another point, still minor (though less minor): Why not just use
> "int"?  That will work here; no overflow is possible, since both
> values are nonnegative.  In general it's better to stick with the data
> types that the rest of the code is using, and in this case it's int.



--- src/kwset.c 2005-07-04 01:14:37 -0400
+++ src/kwset.c 2005-07-04 04:50:38 -0400
@@ -404,7 +404,13 @@ kwsprep (kwset_t kws)
        }
       /* Build the Boyer Moore delta.  Boy that's easy compared to CW. */
       for (i = 0; i < kwset->mind; ++i)
-       delta[U(kwset->target[i])] = kwset->mind - (i + 1);
+       {
+         int d = kwset->mind - (i + 1);
+
+         if (UCHAR_MAX < d)
+           d = UCHAR_MAX;
+         delta[U(kwset->target[i])] = d;
+       }
       /* Find the minimal delta2 shift that we might make after
         a backwards match has failed. */
       c = kwset->target[kwset->mind - 1];




reply via email to

[Prev in Thread] Current Thread [Next in Thread]