Kouhei Sutou
null+****@clear*****
Tue Jul 30 12:27:15 JST 2013
Kouhei Sutou 2013-07-30 12:27:15 +0900 (Tue, 30 Jul 2013) New Revision: 3c22c0637dcd2f31de7e9034023b69058319da0e https://github.com/groonga/groonga/commit/3c22c0637dcd2f31de7e9034023b69058319da0e Message: Allocate result place after WITH_SPSAVE() WITH_SPSAVE() keeps result place as a garbage object on stack. So the result place should be allocated after WITH_SPSAVE(). Modified files: lib/expr.c Modified: lib/expr.c (+13 -9) =================================================================== --- lib/expr.c 2013-07-30 11:00:39 +0900 (6af0b76) +++ lib/expr.c 2013-07-30 12:27:15 +0900 (efd1d3b) @@ -2468,11 +2468,12 @@ grn_proc_call(grn_ctx *ctx, grn_obj *proc, int nargs, grn_obj *caller) } \ } while (0) -void -pseudo_query_scan(grn_ctx *ctx, grn_obj *x, grn_obj *y, grn_obj *res) +grn_bool +pseudo_query_scan(grn_ctx *ctx, grn_obj *x, grn_obj *y) { grn_obj *normalizer; grn_obj *a = NULL, *b = NULL; + grn_bool matched = GRN_FALSE; normalizer = grn_ctx_get(ctx, GRN_NORMALIZER_AUTO_NAME, -1); switch (x->header.domain) { @@ -2502,17 +2503,15 @@ pseudo_query_scan(grn_ctx *ctx, grn_obj *x, grn_obj *y, grn_obj *res) const char *a_norm, *b_norm; grn_string_get_normalized(ctx, a, &a_norm, NULL, NULL); grn_string_get_normalized(ctx, b, &b_norm, NULL, NULL); - GRN_INT32_SET(ctx, res, strstr(a_norm, b_norm) != NULL); - } else { - GRN_INT32_SET(ctx, res, 0); + matched = (strstr(a_norm, b_norm) != NULL); } - res->header.type = GRN_BULK; - res->header.domain = GRN_DB_INT32; if (a) { grn_obj_close(ctx, a); } if (b) { grn_obj_close(ctx, b); } if (normalizer) { grn_obj_unlink(ctx, normalizer); } + + return matched; } inline static void @@ -3190,10 +3189,15 @@ grn_expr_exec(grn_ctx *ctx, grn_obj *expr, int nargs) case GRN_OP_MATCH : { grn_obj *x, *y; - POP2ALLOC1(x, y, res); + grn_bool matched; + POP1(y); + POP1(x); WITH_SPSAVE({ - pseudo_query_scan(ctx, x, y, res); + matched = pseudo_query_scan(ctx, x, y); }); + ALLOC1(res); + grn_obj_reinit(ctx, res, GRN_DB_INT32, 0); + GRN_INT32_SET(ctx, res, matched ? 1 : 0); } code++; break; -------------- next part -------------- HTML����������������������������...Download