]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/kmp.h
Merge remote-tracking branch 'origin/master'
[libucw.git] / ucw / kmp.h
index 629a4c84c3354e8ff4c530178c723a13f1729e5c..335827f375422c18866ee7c1aa674bb273aab3bc 100644 (file)
--- a/ucw/kmp.h
+++ b/ucw/kmp.h
@@ -25,7 +25,7 @@
  *     #define KMP_WANT_CLEANUP
  *     #define KMP_WANT_SEARCH // includes ucw/kmp-search.h automatically
  *     #define KMPS_FOUND(kmp,src,s) printf("found\n")
- *     #include "ucw/kmp.h"
+ *     #include <ucw/kmp.h>
  *
  *    [...]
  *
@@ -49,7 +49,7 @@
  *  Brief description of all parameters:
  *
  *    Basic parameters:
- *             KMP_PREFIX(x)           macro to add a name prefix (used on all global names
+ *     KMP_PREFIX(x)           macro to add a name prefix (used on all global names
  *                             defined by the KMP generator); mandatory;
  *                             we abbreviate this to P(x) below
  *
  *     KMP_ONLYALPHA           converts non-alphas to KMP_CONTROL_CHAR (see below)
  *
  *    Parameters controlling add(kmp, src):
- *     KMP_ADD_EXTRA_ARGS      extra arguments, should be used carefully because of possible collisions
- *     KMP_ADD_INIT(kmp,src)   called in the beginning of add(), src is the first
+ *     KMP_ADD_EXTRA_ARGS      extra arguments, should be used carefully because of possible collisions
+ *     KMP_ADD_INIT(kmp,src)   called in the beginning of add(), src is the first
  *      KMP_INIT_STATE(kmp,s)   initialization of a new state s (called before KMP_ADD_{NEW,DUP});
- *                             null state is not included and should be handled after init() if necessary;
- *                             all user-defined data are filled by zeros before call to KMP_INIT_STATE
- *     KMP_ADD_NEW(kmp,src,s)  initialize last state of every new key string (called after KMP_INIT_STATE);
- *                             the string must be parsed before so src is after the last string's character
- *     KMP_ADD_DUP(kmp,src,s)  analogy of KMP_ADD_NEW called for duplicates
+ *                             null state is not included and should be handled after init() if necessary;
+ *                             all user-defined data are filled by zeros before call to KMP_INIT_STATE
+ *     KMP_ADD_NEW(kmp,src,s)  initialize last state of every new key string (called after KMP_INIT_STATE);
+ *                             the string must be parsed before so src is after the last string's character
+ *     KMP_ADD_DUP(kmp,src,s)  analogy of KMP_ADD_NEW called for duplicates
  *
  *    Parameters to build():
  *      KMP_BUILD_STATE(kmp,s) called for all states (including null) in order of non-decreasing tree depth
 #error Missing KMP_PREFIX
 #endif
 
-#include "ucw/mempool.h"
+#include <ucw/mempool.h>
 #include <alloca.h>
 #include <string.h>
 
@@ -159,16 +159,16 @@ struct P(hash_table);
 
 #define HASH_GIVE_HASHFN
 #ifdef KMP_GIVE_HASHFN
-static inline uns
+static inline uint
 P(hash_hash) (struct P(hash_table) *t, struct P(state) *f, P(char_t) c)
 {
   return P(hash) ((struct P(struct) *) t, f, c);
 }
 #else
-static inline uns
+static inline uint
 P(hash_hash) (struct P(hash_table) *t UNUSED, struct P(state) *f, P(char_t) c)
 {
-  return (((uns)c) << 16) + (uns)(uintptr_t)f;
+  return (((uint)c) << 16) + (uint)(uintptr_t)f;
 }
 #endif
 
@@ -196,7 +196,7 @@ P(hash_eq) (struct P(hash_table) *t, struct P(state) *f1, P(char_t) c1, struct P
 #ifdef KMP_GIVE_ALLOC
 #define HASH_GIVE_ALLOC
 static inline void *
-P(hash_alloc) (struct P(hash_table) *t, uns size)
+P(hash_alloc) (struct P(hash_table) *t, uint size)
 {
   return P(alloc) ((struct P(struct) *) t, size);
 }
@@ -240,7 +240,7 @@ P(hash_init_key) (struct P(hash_table) *t UNUSED, struct P(state) *s, struct P(s
 #endif
 #define HASH_CONSERVE_SPACE
 #define HASH_TABLE_DYNAMIC
-#include "ucw/hashtable.h"
+#include <ucw/hashtable.h>
 #define P(x) KMP_PREFIX(x)
 
 struct P(struct) {
@@ -267,20 +267,20 @@ P(get_char) (struct P(struct) *kmp UNUSED, P(source_t) *src UNUSED, P(char_t) *c
 }
 #else
 #  if defined(KMP_USE_UTF8)
-#    include "ucw/unicode.h"
+#    include <ucw/unicode.h>
 #    if defined(KMP_ONLYALPHA) || defined(KMP_TOLOWER) || defined(KMP_UNACCENT)
-#      include "charset/unicat.h"
+#      include <charset/unicat.h>
 #    endif
 #  elif defined(KMP_USE_ASCII)
 #    if defined(KMP_ONLYALPHA) || defined(KMP_TOLOWER)
-#      include "ucw/chartype.h"
+#      include <ucw/chartype.h>
 #    endif
 #  endif
 static inline int
 P(get_char) (struct P(struct) *kmp UNUSED, P(source_t) *src, P(char_t) *c)
 {
 # ifdef KMP_USE_UTF8
-  uns cc;
+  uint cc;
   *src = utf8_get(*src, &cc);
 # ifdef KMP_ONLYALPHA
   if (!cc) {}
@@ -297,7 +297,7 @@ P(get_char) (struct P(struct) *kmp UNUSED, P(source_t) *src, P(char_t) *c)
 #     endif
     }
 # else
-  uns cc = *(*src)++;
+  uint cc = *(*src)++;
 # ifdef KMP_ONLYALPHA
   if (!cc) {}
   else if (!Calpha(cc))
@@ -331,7 +331,7 @@ P(add) (struct P(struct) *kmp, P(source_t) src
   if (!P(get_char)(kmp, &src, &c))
     return NULL;
   struct P(state) *p = &kmp->null, *s;
-  uns len = 0;
+  uint len = 0;
   do
     {
       s = P(hash_find)(&kmp->hash, p, c);
@@ -395,7 +395,7 @@ P(build) (struct P(struct) *kmp)
 {
   if (P(empty)(kmp))
     return;
-  uns read = 0, write = 0;
+  uint read = 0, write = 0;
   struct P(state) *fifo[kmp->hash.hash_count], *null = &kmp->null;
   for (struct P(state) *s = null->back; s; s = s->next)
     fifo[write++] = s;
@@ -457,7 +457,7 @@ P(build) (struct P(struct) *kmp)
 #  undef KMP_WANT_SEARCH
 #  define KMPS_PREFIX(x) KMP_PREFIX(x)
 #  define KMPS_KMP_PREFIX(x) KMP_PREFIX(x)
-#  include "ucw/kmp-search.h"
+#  include <ucw/kmp-search.h>
 #endif
 
 #undef KMP_PREFIX