Kouhei Sutou
null+****@clear*****
Fri Dec 21 13:16:44 JST 2012
Kouhei Sutou 2012-12-21 13:16:44 +0900 (Fri, 21 Dec 2012) New Revision: fa0a7770846596b1e540f02dd645ba8bb564660f https://github.com/groonga/groonga/commit/fa0a7770846596b1e540f02dd645ba8bb564660f Log: Use upper case name for grn_token_mode enum type Modified files: lib/db.c lib/ii.c lib/token.c lib/token.h Modified: lib/db.c (+1 -1) =================================================================== --- lib/db.c 2012-12-21 11:59:07 +0900 (ddef5d4) +++ lib/db.c 2012-12-21 13:16:44 +0900 (28075f5) @@ -5561,7 +5561,7 @@ grn_obj_set_value(grn_ctx *ctx, grn_obj *obj, grn_id id, { grn_token *token; if (v && s && - (token = grn_token_open(ctx, lexicon, v, s, grn_token_add))) { + (token = grn_token_open(ctx, lexicon, v, s, GRN_TOKEN_ADD))) { while (!token->status) { grn_id tid = grn_token_next(ctx, token); grn_bulk_write(ctx, &buf, (char *)&tid, sizeof(grn_id)); Modified: lib/ii.c (+9 -9) =================================================================== --- lib/ii.c 2012-12-21 11:59:07 +0900 (d7dda44) +++ lib/ii.c 2012-12-21 13:16:44 +0900 (ccc1821) @@ -4714,7 +4714,7 @@ index_add(grn_ctx *ctx, grn_id rid, grn_obj *lexicon, grn_ii *ii, grn_vgram *vgr grn_rc r, rc = GRN_SUCCESS; grn_vgram_buf *sbuf = NULL; if (!rid) { return GRN_INVALID_ARGUMENT; } - if (!(token = grn_token_open(ctx, lexicon, value, value_len, grn_token_add))) { + if (!(token = grn_token_open(ctx, lexicon, value, value_len, GRN_TOKEN_ADD))) { return GRN_NO_MEMORY_AVAILABLE; } if (vgram) { sbuf = grn_vgram_buf_open(value_len); } @@ -4768,7 +4768,7 @@ index_del(grn_ctx *ctx, grn_id rid, grn_obj *lexicon, grn_ii *ii, grn_vgram *vgr grn_ii_updspec **u; grn_id tid, *tp; if (!rid) { return GRN_INVALID_ARGUMENT; } - if (!(token = grn_token_open(ctx, lexicon, value, value_len, grn_token_del))) { + if (!(token = grn_token_open(ctx, lexicon, value, value_len, GRN_TOKEN_DEL))) { return GRN_NO_MEMORY_AVAILABLE; } h = grn_hash_create(ctx, NULL, sizeof(grn_id), sizeof(grn_ii_updspec *), GRN_HASH_TINY); @@ -4846,7 +4846,7 @@ grn_ii_update(grn_ctx *ctx, grn_ii *ii, grn_id rid, grn_vgram *vgram, unsigned i goto exit; } for (j = newvalues->n_values, v = newvalues->values; j; j--, v++) { - if ((token = grn_token_open(ctx, lexicon, v->str, v->str_len, grn_token_add))) { + if ((token = grn_token_open(ctx, lexicon, v->str, v->str_len, GRN_TOKEN_ADD))) { while (!token->status) { if ((tid = grn_token_next(ctx, token))) { if (!grn_hash_add(ctx, new, &tid, sizeof(grn_id), (void **) &u, NULL)) { @@ -4889,7 +4889,7 @@ grn_ii_update(grn_ctx *ctx, grn_ii *ii, grn_id rid, grn_vgram *vgram, unsigned i goto exit; } for (j = oldvalues->n_values, v = oldvalues->values; j; j--, v++) { - if ((token = grn_token_open(ctx, lexicon, v->str, v->str_len, grn_token_del))) { + if ((token = grn_token_open(ctx, lexicon, v->str, v->str_len, GRN_TOKEN_DEL))) { while (!token->status) { if ((tid = grn_token_next(ctx, token))) { if (!grn_hash_add(ctx, old, &tid, sizeof(grn_id), (void **) &u, NULL)) { @@ -5064,7 +5064,7 @@ grn_ii_column_update(grn_ctx *ctx, grn_ii *ii, grn_id rid, unsigned int section, GRN_LOG(ctx, GRN_LOG_ALERT, "grn_hash_create on grn_ii_update failed !"); rc = GRN_NO_MEMORY_AVAILABLE; } else { - rc = grn_vector2updspecs(ctx, ii, rid, section, new_, new, grn_token_add, post); + rc = grn_vector2updspecs(ctx, ii, rid, section, new_, new, GRN_TOKEN_ADD, post); } if (new_ != newvalue) { grn_obj_close(ctx, new_); } if (rc) { goto exit; } @@ -5146,7 +5146,7 @@ grn_ii_column_update(grn_ctx *ctx, grn_ii *ii, grn_id rid, unsigned int section, GRN_LOG(ctx, GRN_LOG_ALERT, "grn_hash_create(ctx, NULL, old) on grn_ii_update failed!"); rc = GRN_NO_MEMORY_AVAILABLE; } else { - rc = grn_vector2updspecs(ctx, ii, rid, section, old_, old, grn_token_del, NULL); + rc = grn_vector2updspecs(ctx, ii, rid, section, old_, old, GRN_TOKEN_DEL, NULL); } if (old_ != oldvalue) { grn_obj_close(ctx, old_); } if (rc) { goto exit; } @@ -5415,7 +5415,7 @@ token_info_build(grn_ctx *ctx, grn_obj *lexicon, grn_ii *ii, const char *string, const char *key; uint32_t size; grn_rc rc = GRN_END_OF_DATA; - grn_token *token = grn_token_open(ctx, lexicon, string, string_len, grn_token_get); + grn_token *token = grn_token_open(ctx, lexicon, string, string_len, GRN_TOKEN_GET); if (!token) { return GRN_NO_MEMORY_AVAILABLE; } if (mode == GRN_OP_UNSPLIT) { if ((ti = token_info_open(ctx, lexicon, ii, (char *)token->orig, token->orig_blen, 0, EX_BOTH))) { @@ -5704,7 +5704,7 @@ grn_ii_similar_search(grn_ctx *ctx, grn_ii *ii, if (!(h = grn_hash_create(ctx, NULL, sizeof(grn_id), sizeof(int), 0))) { return GRN_NO_MEMORY_AVAILABLE; } - if (!(token = grn_token_open(ctx, lexicon, string, string_len, grn_token_get))) { + if (!(token = grn_token_open(ctx, lexicon, string, string_len, GRN_TOKEN_GET))) { grn_hash_close(ctx, h); return GRN_NO_MEMORY_AVAILABLE; } @@ -6818,7 +6818,7 @@ grn_ii_buffer_tokenize(grn_ctx *ctx, grn_ii_buffer *ii_buffer, grn_id rid, buffer[block_pos++] = weight + II_BUFFER_WEIGHT_FLAG; } if ((token = grn_token_open(ctx, tmp_lexicon, value, - value_len, grn_token_add))) { + value_len, GRN_TOKEN_ADD))) { uint32_t pos; for (pos = 0; !token->status; pos++) { grn_id tid; Modified: lib/token.c (+4 -4) =================================================================== --- lib/token.c 2012-12-21 11:59:07 +0900 (3c730a3) +++ lib/token.c 2012-12-21 13:16:44 +0900 (1055a94) @@ -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))) { @@ -516,12 +516,12 @@ grn_token_next(grn_ctx *ctx, grn_token *token) token->curr_size = GRN_TEXT_LEN(curr_); status = GRN_UINT32_VALUE(stat_); token->status = ((status & GRN_TOKEN_LAST) || - (token->mode == grn_token_get && (status & GRN_TOKEN_REACH_END))) + (token->mode == GRN_TOKEN_GET && (status & GRN_TOKEN_REACH_END))) ? grn_token_done : grn_token_doing; token->force_prefix = 0; if (status & GRN_TOKEN_UNMATURED) { if (status & GRN_TOKEN_OVERLAP) { - if (token->mode == grn_token_get) { token->pos++; continue; } + if (token->mode == GRN_TOKEN_GET) { token->pos++; continue; } } else { if (status & GRN_TOKEN_LAST) { token->force_prefix = 1; } } @@ -529,7 +529,7 @@ grn_token_next(grn_ctx *ctx, grn_token *token) } else { token->status = grn_token_done; } - if (token->mode == grn_token_add) { + if (token->mode == GRN_TOKEN_ADD) { switch (table->header.type) { case GRN_TABLE_PAT_KEY : if (grn_io_lock(ctx, ((grn_pat *)table)->io, 10000000)) { Modified: lib/token.h (+3 -3) =================================================================== --- lib/token.h 2012-12-21 11:59:07 +0900 (785c52c) +++ lib/token.h 2012-12-21 13:16:44 +0900 (ddb0210) @@ -38,9 +38,9 @@ extern "C" { #endif typedef enum { - grn_token_get = 0, - grn_token_add, - grn_token_del + GRN_TOKEN_GET = 0, + GRN_TOKEN_ADD, + GRN_TOKEN_DEL } grn_token_mode; typedef struct { -------------- next part -------------- HTML����������������������������... Download