Kouhei Sutou
null+****@clear*****
Thu May 5 12:15:31 JST 2016
Kouhei Sutou 2016-05-05 12:15:31 +0900 (Thu, 05 May 2016) New Revision: 98a78398330b4e8a06def00a8f0e1e81179ea02e https://github.com/groonga/groonga/commit/98a78398330b4e8a06def00a8f0e1e81179ea02e Message: Export column_create flags parser internally Modified files: lib/grn_proc.h lib/proc/proc_column.c Modified: lib/grn_proc.h (+5 -0) =================================================================== --- lib/grn_proc.h 2016-05-05 12:14:50 +0900 (1cc20f0) +++ lib/grn_proc.h 2016-05-05 12:15:31 +0900 (92932ab) @@ -83,6 +83,11 @@ grn_bool grn_proc_table_set_token_filters(grn_ctx *ctx, grn_obj *table, grn_obj *token_filter_names); +grn_obj_flags grn_proc_column_parse_flags(grn_ctx *ctx, + const char *error_message_tag, + const char *text, + const char *end); + void grn_proc_select_output_columns(grn_ctx *ctx, grn_obj *res, int n_hits, int offset, int limit, Modified: lib/proc/proc_column.c (+18 -15) =================================================================== --- lib/proc/proc_column.c 2016-05-05 12:14:50 +0900 (28ac7d6) +++ lib/proc/proc_column.c 2016-05-05 12:15:31 +0900 (7d95db9) @@ -24,26 +24,27 @@ #include <groonga/plugin.h> -static grn_obj_flags -command_column_create_parse_flags(grn_ctx *ctx, - const char *nptr, - const char *end) +grn_obj_flags +grn_proc_column_parse_flags(grn_ctx *ctx, + const char *error_message_tag, + const char *text, + const char *end) { grn_obj_flags flags = 0; - while (nptr < end) { + while (text < end) { size_t name_size; - if (*nptr == '|' || *nptr == ' ') { - nptr += 1; + if (*text == '|' || *text == ' ') { + text += 1; continue; } #define CHECK_FLAG(name) \ name_size = strlen(#name); \ - if ((end - nptr) >= name_size && \ - memcmp(nptr, #name, name_size) == 0) { \ + if ((end - text) >= name_size && \ + memcmp(text, #name, name_size) == 0) { \ flags |= GRN_OBJ_ ## name; \ - nptr += name_size; \ + text += name_size; \ continue; \ } @@ -60,8 +61,9 @@ command_column_create_parse_flags(grn_ctx *ctx, #undef CHECK_FLAG ERR(GRN_INVALID_ARGUMENT, - "[column][create][flags] unknown flag: <%.*s>", - (int)(end - nptr), nptr); + "%s unknown flag: <%.*s>", + error_message_tag, + (int)(end - text), text); return 0; } return flags; @@ -199,9 +201,10 @@ command_column_create(grn_ctx *ctx, int nargs, grn_obj **args, GRN_BULK_CURR(flags_raw), &rest); if (GRN_TEXT_VALUE(flags_raw) == rest) { - flags = command_column_create_parse_flags(ctx, - GRN_TEXT_VALUE(flags_raw), - GRN_BULK_CURR(flags_raw)); + flags = grn_proc_column_parse_flags(ctx, + "[column][create][flags]", + GRN_TEXT_VALUE(flags_raw), + GRN_BULK_CURR(flags_raw)); if (ctx->rc) { succeeded = GRN_FALSE; goto exit; -------------- next part -------------- HTML����������������������������...ダウンロード