[Top][All Lists]

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

Some fix to src/kwset.c [was: Use of 0 instead of NULL in src/kwset.c]

From: Julian Foad
Subject: Some fix to src/kwset.c [was: Use of 0 instead of NULL in src/kwset.c]
Date: Sat, 16 Jul 2005 14:43:10 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050511

Charles Levert wrote:
I think the only pending patch that's affected
is one you were working on to fix a bug.

Sorry to be so forgetful, but could you post the URL or tracker number of the particular bug that you are talking about?

 I would now propose
[second revision]

--- 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];

along with tests that would be surrounded by a

   for mode in F G E

loop in "tests/foad1.sh".

Please could you write those tests?

 I still have to fully
understand how this delta[] array is used and
may (or not) suggest additional individual tests
later on.

In another email you wrote:
(I still don't understand the second test case,
but I think the fix is correct nevertheless.
Please don't use a MIN() macro with a complex
twice-evaluated argument that the optimizer
might not pick up on, though; see a previous
email for my proposed alternative.)

Please could you be more specific - what test are you looking at, and what/where is that alternative?

- Julian

reply via email to

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