[Groonga-commit] groonga/groonga [master] Use upper case name for grn_token_status enum type

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Dec 21 13:26:25 JST 2012


Kouhei Sutou	2012-12-21 13:26:25 +0900 (Fri, 21 Dec 2012)

  New Revision: 3af74d78aa544d18a86448fa6e29837c09af9a7b
  https://github.com/groonga/groonga/commit/3af74d78aa544d18a86448fa6e29837c09af9a7b

  Log:
    Use upper case name for grn_token_status enum type

  Modified files:
    lib/ii.c
    lib/token.c
    lib/token.h

  Modified: lib/ii.c (+7 -7)
===================================================================
--- lib/ii.c    2012-12-21 13:25:01 +0900 (ccc1821)
+++ lib/ii.c    2012-12-21 13:26:25 +0900 (da79d0a)
@@ -5442,11 +5442,11 @@ token_info_build(grn_ctx *ctx, grn_obj *lexicon, grn_ii *ii, const char *string,
     tid = grn_token_next(ctx, token);
     if (token->force_prefix) { ef |= EX_PREFIX; }
     switch (token->status) {
-    case grn_token_doing :
+    case GRN_TOKEN_DOING :
       key = _grn_table_key(ctx, lexicon, tid, &size);
       ti = token_info_open(ctx, lexicon, ii, key, size, token->pos, ef & EX_SUFFIX);
       break;
-    case grn_token_done :
+    case GRN_TOKEN_DONE :
       ti = token_info_open(ctx, lexicon, ii, (const char *)token->curr,
                            token->curr_size, 0, ef);
       /*
@@ -5456,7 +5456,7 @@ token_info_build(grn_ctx *ctx, grn_obj *lexicon, grn_ii *ii, const char *string,
                            token->orig_blen, token->pos, ef);
       */
       break;
-    case grn_token_not_found :
+    case GRN_TOKEN_NOT_FOUND :
       ti = token_info_open(ctx, lexicon, ii, (char *)token->orig,
                            token->orig_blen, 0, ef);
       break;
@@ -5465,14 +5465,14 @@ token_info_build(grn_ctx *ctx, grn_obj *lexicon, grn_ii *ii, const char *string,
     }
     if (!ti) { goto exit ; }
     tis[(*n)++] = ti;
-    while (token->status == grn_token_doing) {
+    while (token->status == GRN_TOKEN_DOING) {
       tid = grn_token_next(ctx, token);
       switch (token->status) {
-      case grn_token_doing :
+      case GRN_TOKEN_DOING :
         key = _grn_table_key(ctx, lexicon, tid, &size);
         ti = token_info_open(ctx, lexicon, ii, key, size, token->pos, EX_NONE);
         break;
-      case grn_token_done :
+      case GRN_TOKEN_DONE :
         if (tid) {
           key = _grn_table_key(ctx, lexicon, tid, &size);
           ti = token_info_open(ctx, lexicon, ii, key, size, token->pos, ef & EX_PREFIX);
@@ -5709,7 +5709,7 @@ grn_ii_similar_search(grn_ctx *ctx, grn_ii *ii,
     return GRN_NO_MEMORY_AVAILABLE;
   }
   if (!(max_size = optarg->max_size)) { max_size = 1048576; }
-  while (token->status != grn_token_done) {
+  while (token->status != GRN_TOKEN_DONE) {
     if ((tid = grn_token_next(ctx, token))) {
       if (grn_hash_add(ctx, h, &tid, sizeof(grn_id), (void **)&w1, NULL)) { (*w1)++; }
     }

  Modified: lib/token.c (+8 -8)
===================================================================
--- lib/token.c    2012-12-21 13:25:01 +0900 (1055a94)
+++ lib/token.c    2012-12-21 13:26:25 +0900 (fc1c55a)
@@ -358,7 +358,7 @@ ngram_next(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
     // todo : grn_pat_lcp_search
     if ((tid = grn_sym_common_prefix_search(sym, p))) {
       if (!(key = _grn_sym_key(sym, tid))) {
-        token->status = grn_token_not_found;
+        token->status = GRN_TOKEN_NOT_FOUND;
         return NULL;
       }
       len = grn_str_len(key, token->encoding, NULL);
@@ -367,7 +367,7 @@ ngram_next(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
     if (tid && (len > 1 || r == p)) {
       if (r != p && pos + len - 1 <= token->tail) { continue; }
       p += strlen(key);
-      if (!*p && token->mode == GRN_TOKEN_GET) { token->status = grn_token_done; }
+      if (!*p && token->mode == GRN_TOKEN_GET) { token->status = GRN_TOKEN_DONE; }
     }
 #endif /* PRE_DEFINED_UNSPLIT_WORDS */
     if ((cl = grn_charlen_(ctx, (char *)r, (char *)e, token->encoding))) {
@@ -464,7 +464,7 @@ grn_token_open(grn_ctx *ctx, grn_obj *table, const char *str, size_t str_len,
   token->nstr = NULL;
   token->curr_size = 0;
   token->pos = -1;
-  token->status = grn_token_doing;
+  token->status = GRN_TOKEN_DOING;
   token->force_prefix = 0;
   if (tokenizer) {
     grn_obj str_;
@@ -506,7 +506,7 @@ grn_token_next(grn_ctx *ctx, grn_token *token)
   grn_id tid = GRN_ID_NIL;
   grn_obj *table = token->table;
   grn_obj *tokenizer = token->tokenizer;
-  while (token->status != grn_token_done) {
+  while (token->status != GRN_TOKEN_DONE) {
     if (tokenizer) {
       grn_obj *curr_, *stat_;
       ((grn_proc *)tokenizer)->funcs[PROC_NEXT](ctx, 1, &table, &token->pctx.user_data);
@@ -517,7 +517,7 @@ grn_token_next(grn_ctx *ctx, grn_token *token)
       status = GRN_UINT32_VALUE(stat_);
       token->status = ((status & GRN_TOKEN_LAST) ||
                        (token->mode == GRN_TOKEN_GET && (status & GRN_TOKEN_REACH_END)))
-        ? grn_token_done : grn_token_doing;
+        ? GRN_TOKEN_DONE : GRN_TOKEN_DOING;
       token->force_prefix = 0;
       if (status & GRN_TOKEN_UNMATURED) {
         if (status & GRN_TOKEN_OVERLAP) {
@@ -527,7 +527,7 @@ grn_token_next(grn_ctx *ctx, grn_token *token)
         }
       }
     } else {
-      token->status = grn_token_done;
+      token->status = GRN_TOKEN_DONE;
     }
     if (token->mode == GRN_TOKEN_ADD) {
       switch (table->header.type) {
@@ -586,8 +586,8 @@ grn_token_next(grn_ctx *ctx, grn_token *token)
         break;
       }
     }
-    if (tid == GRN_ID_NIL && token->status != grn_token_done) {
-      token->status = grn_token_not_found;
+    if (tid == GRN_ID_NIL && token->status != GRN_TOKEN_DONE) {
+      token->status = GRN_TOKEN_NOT_FOUND;
     }
     token->pos++;
     break;

  Modified: lib/token.h (+3 -3)
===================================================================
--- lib/token.h    2012-12-21 13:25:01 +0900 (7f67eba)
+++ lib/token.h    2012-12-21 13:26:25 +0900 (e700d67)
@@ -62,9 +62,9 @@ typedef struct {
 } grn_token;
 
 typedef enum {
-  grn_token_doing = 0,
-  grn_token_done,
-  grn_token_not_found
+  GRN_TOKEN_DOING = 0,
+  GRN_TOKEN_DONE,
+  GRN_TOKEN_NOT_FOUND
 } grn_token_status;
 
 #define GRN_TOKEN_LAST      (0x01L<<0)
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index