[Groonga-commit] groonga/groonga at 3837a72 [master] Split too destructive processes from predicate function

Back to archive index

Kouhei Sutou null+****@clear*****
Tue May 21 15:52:15 JST 2013


Kouhei Sutou	2013-05-21 15:52:15 +0900 (Tue, 21 May 2013)

  New Revision: 3837a72c71e3dfc4c57f5aafcc79394be6582abd
  https://github.com/groonga/groonga/commit/3837a72c71e3dfc4c57f5aafcc79394be6582abd

  Message:
    Split too destructive processes from predicate function
    
    A predicate function does destructive processes will confuse.
    
    Note that the predicate function still has an incrmenet process. It is
    also a destructive process. But it is OK because it is natural that
    the process exists in the predicate function. The increment process
    counts the number of the predicate function is called.
    
    Suggested by Ichiro Suzuki. Thanks!!!

  Modified files:
    lib/ctx.c
    lib/ctx.h

  Modified: lib/ctx.c (+10 -3)
===================================================================
--- lib/ctx.c    2013-05-21 14:23:25 +0900 (4bbfe3f)
+++ lib/ctx.c    2013-05-21 15:52:15 +0900 (bdf2b02)
@@ -554,11 +554,18 @@ grn_ctx_impl_should_log(grn_ctx *ctx)
     return GRN_FALSE;
   }
 
-  grn_ctx_impl_clear_n_same_error_mssagges(ctx);
+  return GRN_TRUE;
+}
 
-  strcpy(ctx->impl->previous_errbuf, ctx->errbuf);
+void
+grn_ctx_impl_set_current_error_message(grn_ctx *ctx)
+{
+  if (!ctx->impl) {
+    return;
+  }
 
-  return GRN_TRUE;
+  grn_ctx_impl_clear_n_same_error_mssagges(ctx);
+  strcpy(ctx->impl->previous_errbuf, ctx->errbuf);
 }
 
 grn_rc

  Modified: lib/ctx.h (+2 -0)
===================================================================
--- lib/ctx.h    2013-05-21 14:23:25 +0900 (20511ee)
+++ lib/ctx.h    2013-05-21 15:52:15 +0900 (21fea9b)
@@ -97,6 +97,7 @@ extern "C" {
 
 GRN_API void grn_ctx_impl_err(grn_ctx *ctx);
 GRN_API grn_bool grn_ctx_impl_should_log(grn_ctx *ctx);
+GRN_API void grn_ctx_impl_set_current_error_message(grn_ctx *ctx);
 
 #ifdef HAVE_BACKTRACE
 #define LOGTRACE(ctx,lvl) do {\
@@ -123,6 +124,7 @@ GRN_API grn_bool grn_ctx_impl_should_log(grn_ctx *ctx);
   grn_ctx_impl_err(ctx);\
   grn_ctx_log(ctx, __VA_ARGS__);\
   if (grn_ctx_impl_should_log(ctx)) {\
+    grn_ctx_impl_set_current_error_message(ctx);\
     GRN_LOG(ctx, lvl, __VA_ARGS__);\
     BACKTRACE(ctx);\
     if (lvl <= GRN_LOG_ERROR) { LOGTRACE(ctx, lvl); }\
-------------- next part --------------
HTML����������������������������...
Download 



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