]> mj.ucw.cz Git - libucw.git/commitdiff
corrections in substr analyser
authorPavel Charvat <pavel.charvat@netcentrum.cz>
Tue, 18 Apr 2006 06:53:23 +0000 (08:53 +0200)
committerPavel Charvat <pavel.charvat@netcentrum.cz>
Tue, 18 Apr 2006 06:53:23 +0000 (08:53 +0200)
lib/kmp-new.h

index 2d677aa5f02ed6b5a6b813cfa5477812523f2cdc..5966b8a5ecfbf6cb1cf9526c1deac603abb2efb6 100644 (file)
@@ -44,7 +44,7 @@
  *     KMP_NO_DUPS             no support for duplicates
  *
  *    Parameters to build():
- *      KMP_BUILD_STATE(ctx,s) called for all states (except null) in order of non-decreasing tree depth
+ *      KMP_BUILD_STATE(ctx,s) called for all states (including null) in order of non-decreasing tree depth
  *
  *     KMP_WANT_CLEANUP        cleanup()
  *     KMP_WANT_SEARCH         includes lib/kmp-search.h with the same prefix;
@@ -291,10 +291,13 @@ P(build) (struct P(context) *ctx)
   if (P(empty)(ctx))
     return;
   uns read = 0, write = 0;
-  struct P(state) *fifo[ctx->hash.hash_count];
-  for (struct P(state) *s = ctx->null.back; s; s = s->next)
+  struct P(state) *fifo[ctx->hash.hash_count], *null = &ctx->null;
+  for (struct P(state) *s = null->back; s; s = s->next)
     fifo[write++] = s;
-  ctx->null.back = NULL;
+  null->back = NULL;
+# ifdef KMP_BUILD_STATE
+  { KMP_BUILD_STATE(ctx, null); }
+# endif  
   while (read != write)
     {
       struct P(state) *s = fifo[read++], *t;
@@ -304,7 +307,7 @@ P(build) (struct P(context) *ctx)
         {
          if (!t)
            {
-             s->back = &ctx->null;
+             s->back = null;
              s->next = NULL;
              break;
            }
@@ -315,9 +318,9 @@ P(build) (struct P(context) *ctx)
              break;
            }
        }
-#ifdef KMP_BUILD_STATE
+#     ifdef KMP_BUILD_STATE
       { KMP_BUILD_STATE(ctx, s); }
-#endif      
+#     endif      
     }
 }