Author: yamakenz
Date: Mon Aug 20 02:30:57 2007
New Revision: 4869

Modified:
   trunk/configure.ac
   trunk/uim/iconv.c
   trunk/uim/plugin.c
   trunk/uim/uim-error.c
   trunk/uim/uim-helper.c
   trunk/uim/uim-internal.h
   trunk/uim/uim-key.c
   trunk/uim/uim-util.c
   trunk/uim/uim.c

Log:
* uim/uim-internal.h
  - Disable/enable error-related decls according to UIM_USE_ERROR_GUARD
  - (uim_catch_error_begin): Rename to UIM_CATCH_ERROR_BEGIN()
  - (UIM_CATCH_ERROR_BEGIN):
    * Renamed from uim_catch_error_begin()
    * Make UIM_USE_ERROR_GUARD sensitive
  - (UIM_CATCH_ERROR_END):
    * New macro
    * Make UIM_USE_ERROR_GUARD sensitive
  - (uim_print_caught_error): Removed decl
* uim/uim-error.c
  - Disable/enable some definitions according to UIM_USE_ERROR_GUARD
  - (uim_print_caught_error): Rename to print_caught_error()
  - (print_caught_error):
    * Renamed from uim_print_caught_error()
    * Make static
  - (uim_catch_error_begin_post): Follow the renaming
  - (uim_throw_error): Add error printing on non-guarded error
* uim/uim.c
* uim/uim-key.c
* uim/uim-util.c
* uim/uim-helper.c
* uim/plugin.c
* uim/iconv.c
  - Replace all uim_catch_error_begin() with UIM_CATCH_ERROR_BEGIN()
  - Replace all uim_catch_error_end() with UIM_CATCH_ERROR_END()
* configure.ac
  - AC_DEFINE UIM_USE_ERROR_GUARD to 1


Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac  (original)
+++ trunk/configure.ac  Mon Aug 20 02:30:57 2007
@@ -1256,6 +1256,8 @@
 
 AM_CONDITIONAL(ENABLE_ANTHY_UTF8_STATIC, test x$build_anthy_utf8_static = xyes)
 
+AC_DEFINE(UIM_USE_ERROR_GUARD, 1, [Define to 1 if you want to use 
longjmp-based error handlings])
+
 #
 # Compiler options
 #

Modified: trunk/uim/iconv.c
==============================================================================
--- trunk/uim/iconv.c   (original)
+++ trunk/uim/iconv.c   Mon Aug 20 02:30:57 2007
@@ -124,7 +124,7 @@
   iconv_t ic;
   uim_bool result;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return UIM_FALSE;
 
   assert(tocode);
@@ -146,7 +146,7 @@
     result = UIM_TRUE;
   } while (/* CONSTCOND */ 0);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return result;
 }
@@ -221,7 +221,7 @@
 {
   iconv_t ic;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return NULL;
 
   assert(tocode);
@@ -240,7 +240,7 @@
     }
   } while (/* CONSTCOND */ 0);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return (void *)ic;
 }
@@ -253,7 +253,7 @@
   char *outbuf, *realbuf, *copied;
   const char *inbuf, *src;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return NULL;
 
   do {
@@ -280,7 +280,7 @@
     copied = uim_strdup(src);
   } while (/* CONSTCOND */ 0);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return copied;
 }
@@ -290,11 +290,11 @@
 {
   int err;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   if (obj)
     err = iconv_close((iconv_t)obj);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }

Modified: trunk/uim/plugin.c
==============================================================================
--- trunk/uim/plugin.c  (original)
+++ trunk/uim/plugin.c  Mon Aug 20 02:30:57 2007
@@ -244,25 +244,25 @@
 void
 uim_init_plugin(void)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   uim_scm_init_subr_1("load-plugin", plugin_load);
   uim_scm_init_subr_1("unload-plugin", plugin_unload);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 /* Called from uim_quit */
 void
 uim_quit_plugin(void)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   uim_scm_call_with_gc_ready_stack(uim_quit_plugin_internal, NULL);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 static void *

Modified: trunk/uim/uim-error.c
==============================================================================
--- trunk/uim/uim-error.c       (original)
+++ trunk/uim/uim-error.c       Mon Aug 20 02:30:57 2007
@@ -49,9 +49,13 @@
 #define EX_SOFTWARE 70
 #endif
 
+static void print_caught_error(void);
+
 /* Immediately returns UIM_TRUE if uim is disabled by a fatal error. */
 
+#if UIM_USE_ERROR_GUARD
 JMP_BUF uim_catch_block_env;
+#endif
 static uim_bool fatal_errored;
 static int guarded;
 static const char *err_msg;
@@ -66,8 +70,8 @@
   /* fatal_errored must not be cleared even if libuim is re-initialized. */
 }
 
-void
-uim_print_caught_error(void)
+static void
+print_caught_error(void)
 {
   if (err_msg) {
     fputs("libuim: ", stderr);
@@ -82,6 +86,7 @@
   }
 }
 
+#if UIM_USE_ERROR_GUARD
 uim_bool
 uim_caught_fatal_error(void)
 {
@@ -100,7 +105,7 @@
 uim_catch_error_begin_post(void)
 {
   guarded = 0;
-  uim_print_caught_error();
+  print_caught_error();
 
   return UIM_TRUE;
 }
@@ -112,17 +117,25 @@
 
   assert(guarded >= 0);
 }
+#endif /* UIM_USE_ERROR_GUARD */
 
 void
 uim_throw_error(const char *msg)
 {
   assert(msg || !msg);
 
-  if (!guarded)
+  err_msg = msg;
+
+  if (!guarded) {
+    print_caught_error();
     exit(EX_SOFTWARE);
+  }
 
-  err_msg = msg;
+#if UIM_USE_ERROR_GUARD
+  /* To run print_caught_error() on roomed stack space, exit to the
+   * guarded point first. */
   LONGJMP(uim_catch_block_env, guarded);
+#endif
 }
 
 void

Modified: trunk/uim/uim-helper.c
==============================================================================
--- trunk/uim/uim-helper.c      (original)
+++ trunk/uim/uim-helper.c      Mon Aug 20 02:30:57 2007
@@ -95,7 +95,7 @@
   sig_t old_sigpipe;
   char *buf, *bufp;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   if (fd < 0 || !message)
@@ -123,7 +123,7 @@
   free(buf);
   signal(SIGPIPE, old_sigpipe);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return;
 }
@@ -148,7 +148,7 @@
   struct passwd *pw;
   int len;
  
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return NULL;
 
   pw = getpwuid(getuid());
@@ -183,7 +183,7 @@
   path = uim_realloc(path, len + 1);
   strlcat(path, "/uim-helper", len + 1);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return path;
 }
@@ -258,7 +258,7 @@
   size_t msg_size;
   char *msg, *msg_term;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return NULL;
 
   msg_term = strstr(buf, "\n\n");
@@ -272,7 +272,7 @@
     msg = NULL;
   }
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return msg;
 }

Modified: trunk/uim/uim-internal.h
==============================================================================
--- trunk/uim/uim-internal.h    (original)
+++ trunk/uim/uim-internal.h    Mon Aug 20 02:30:57 2007
@@ -35,7 +35,9 @@
 
 #include <config.h>
 
+#if UIM_USE_ERROR_GUARD
 #include <setjmp.h>
+#endif
 
 #include "uim.h"
 #include "uim-scm.h"
@@ -45,6 +47,7 @@
 #endif
 
 
+#if UIM_USE_ERROR_GUARD
 #if HAVE_SIGSETJMP
 #define JMP_BUF           sigjmp_buf
 #define SETJMP(env)       sigsetjmp((env), 1)
@@ -54,6 +57,7 @@
 #define SETJMP(env)       setjmp(env)
 #define LONGJMP(env, val) longjmp((env), (val))
 #endif
+#endif /* UIM_USE_ERROR_GUARD */
 
 
 struct uim_candidate_ {
@@ -120,20 +124,27 @@
   void (*switch_system_global_im_cb)(void *ptr, const char *name);
 };
 
-/* internal functions */
-void     uim_init_error(void);
-void     uim_print_caught_error(void);
+void uim_init_error(void);
+#if UIM_USE_ERROR_GUARD
+/* internal functions: don't call directly */
 uim_bool uim_caught_fatal_error(void);
 uim_bool uim_catch_error_begin_pre(void);
 uim_bool uim_catch_error_begin_post(void);
+void     uim_catch_error_end(void);
 
 /* can be nested */
-#define uim_catch_error_begin()                                                
\
+#define UIM_CATCH_ERROR_BEGIN()                                                
\
   (uim_caught_fatal_error()                                            \
    || (uim_catch_error_begin_pre()                                     \
        && SETJMP(uim_catch_block_env)                                  \
        && uim_catch_error_begin_post()))
-void    uim_catch_error_end(void);
+#define UIM_CATCH_ERROR_END() uim_catch_error_end()
+#else /* not UIM_USE_ERROR_GUARD */
+/* if !UIM_USE_ERROR_GUARD, uim immediately exit(3)s on any error. */
+#define UIM_CATCH_ERROR_BEGIN() UIM_FALSE
+#define UIM_CATCH_ERROR_END()   ((void)0)
+#endif /* not UIM_USE_ERROR_GUARD */
+/* throw recoverable error */
 void    uim_throw_error(const char *msg);
 
 void uim_scm_init(const char *system_load_path);
@@ -153,8 +164,10 @@
 uim_bool uim_issetugid(void);
 
 
+#if UIM_USE_ERROR_GUARD
 /* don't touch directly */
 extern JMP_BUF uim_catch_block_env;
+#endif
 
 #ifdef __cplusplus
 }

Modified: trunk/uim/uim-key.c
==============================================================================
--- trunk/uim/uim-key.c (original)
+++ trunk/uim/uim-key.c Mon Aug 20 02:30:57 2007
@@ -382,7 +382,7 @@
 {
   uim_bool filtered;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return PASSTHROUGH;
 
   assert(uim_scm_gc_any_contextp());
@@ -392,7 +392,7 @@
 
   filtered = filter_key(uc, key, state, UIM_TRUE);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return (filtered) ? FILTERED : PASSTHROUGH;
 }
@@ -402,7 +402,7 @@
 {
   uim_bool filtered;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return PASSTHROUGH;
 
   assert(uim_scm_gc_any_contextp());
@@ -412,7 +412,7 @@
 
   filtered = filter_key(uc, key, state, UIM_FALSE);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return (filtered) ? FILTERED : PASSTHROUGH;
 }

Modified: trunk/uim/uim-util.c
==============================================================================
--- trunk/uim/uim-util.c        (original)
+++ trunk/uim/uim-util.c        Mon Aug 20 02:30:57 2007
@@ -244,7 +244,7 @@
   uim_lisp lang_code, lang_name;
   const char *name;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return "-";
 
   assert(uim_scm_gc_any_contextp());
@@ -258,7 +258,7 @@
     lang_name = uim_scm_callf("lang-code->lang-name", "o", lang_code);
   name = uim_scm_refer_c_str(lang_name);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return name;
 }
@@ -269,7 +269,7 @@
   uim_lisp lang_code;
   const char *name;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return "-";
 
   assert(uim_scm_gc_any_contextp());
@@ -279,7 +279,7 @@
     lang_code = uim_scm_callf("lang-name->lang-code", "s", language_name);
   name = uim_scm_refer_c_str(lang_code);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return name;
 }

Modified: trunk/uim/uim.c
==============================================================================
--- trunk/uim/uim.c     (original)
+++ trunk/uim/uim.c     Mon Aug 20 02:30:57 2007
@@ -94,7 +94,7 @@
 
   uim_init_error();
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return FAILED;
 
   sys_load_path = (uim_issetugid()) ? NULL : getenv("LIBUIM_SYSTEM_SCM_FILES");
@@ -103,7 +103,7 @@
 
   ret = 
(int)uim_scm_call_with_gc_ready_stack((uim_gc_gate_func_ptr)uim_init_internal, 
NULL);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return ret;
 }
@@ -152,7 +152,7 @@
   if (!uim_initialized)
     return;
 
-  if (uim_catch_error_begin()) {
+  if (UIM_CATCH_ERROR_BEGIN()) {
     /* Leave uim_initialized uncleared to keep libuim disabled. */
     return;
   }
@@ -179,7 +179,7 @@
   uim_context uc;
   uim_lisp lang_, engine_;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return NULL;
 
   assert(uim_scm_gc_any_contextp());
@@ -209,7 +209,7 @@
   uim_scm_gc_protect(&uc->sc);
   uim_scm_callf("setup-context", "o", uc->sc);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return uc;
 }
@@ -219,7 +219,7 @@
 {
   int i;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -240,13 +240,13 @@
   free(uc->client_encoding);
   free(uc);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 void
 uim_reset_context(uim_context uc)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -254,13 +254,13 @@
 
   uim_scm_callf("reset-handler", "p", uc);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 void
 uim_focus_in_context(uim_context uc)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -268,13 +268,13 @@
 
   uim_scm_callf("focus-in-handler", "p", uc);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 void
 uim_focus_out_context(uim_context uc)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -282,13 +282,13 @@
 
   uim_scm_callf("focus-out-handler", "p", uc);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 void
 uim_place_context(uim_context uc)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -296,13 +296,13 @@
 
   uim_scm_callf("place-handler", "p", uc);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 void
 uim_displace_context(uim_context uc)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -310,7 +310,7 @@
 
   uim_scm_callf("displace-handler", "p", uc);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 void
@@ -319,7 +319,7 @@
                   void (*pushback_cb)(void *ptr, int attr, const char *str),
                   void (*update_cb)(void *ptr))
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -329,7 +329,7 @@
   uc->preedit_pushback_cb = pushback_cb;
   uc->preedit_update_cb = update_cb;
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 void
@@ -340,7 +340,7 @@
                               void (*shift_page_cb)(void *ptr, int direction),
                               void (*deactivate_cb)(void *ptr))
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -351,7 +351,7 @@
   uc->candidate_selector_deactivate_cb = deactivate_cb;
   uc->candidate_selector_shift_page_cb = shift_page_cb;
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 uim_candidate
@@ -360,7 +360,7 @@
   struct uim_get_candidate_args args;
   uim_candidate cand;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return NULL;
 
   assert(uim_scm_gc_any_contextp());
@@ -374,7 +374,7 @@
 
   cand = 
(uim_candidate)uim_scm_call_with_gc_ready_stack((uim_gc_gate_func_ptr)uim_get_candidate_internal,
 &args);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return cand;
 }
@@ -409,14 +409,14 @@
 const char *
 uim_candidate_get_cand_str(uim_candidate cand)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return "";
 
   assert(uim_scm_gc_any_contextp());
   if (!cand)
     uim_fatal_error("null candidate");
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return cand->str;
 }
@@ -424,14 +424,14 @@
 const char *
 uim_candidate_get_heading_label(uim_candidate cand)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return "";
 
   assert(uim_scm_gc_any_contextp());
   if (!cand)
     uim_fatal_error("null candidate");
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return cand->heading_label;
 }
@@ -439,14 +439,14 @@
 const char *
 uim_candidate_get_annotation_str(uim_candidate cand)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return "";
 
   assert(uim_scm_gc_any_contextp());
   if (!cand)
     uim_fatal_error("null candidate");
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return cand->annotation;
 }
@@ -454,7 +454,7 @@
 void
 uim_candidate_free(uim_candidate cand)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -466,19 +466,19 @@
   free(cand->annotation);
   free(cand);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 int
 uim_get_candidate_index(uim_context uc)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return 0;
 
   assert(uim_scm_gc_any_contextp());
   assert(uc);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return 0;
 }
@@ -486,7 +486,7 @@
 void
 uim_set_candidate_index(uim_context uc, int nth)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -495,7 +495,7 @@
 
   uim_scm_callf("set-candidate-index", "pi", uc, nth);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 void
@@ -509,7 +509,7 @@
                                             enum UTextOrigin origin,
                                             int former_len, int latter_len))
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -518,7 +518,7 @@
   uc->acquire_text_cb = acquire_cb;
   uc->delete_text_cb = delete_cb;
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 uim_bool
@@ -528,7 +528,7 @@
   uim_lisp consumed;
   char *conv;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return UIM_FALSE;
 
   assert(uim_scm_gc_any_contextp());
@@ -546,7 +546,7 @@
     ret = UIM_FALSE;
   }
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return ret;
 }
@@ -558,7 +558,7 @@
 uim_set_configuration_changed_cb(uim_context uc,
                                 void (*changed_cb)(void *ptr))
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -566,7 +566,7 @@
 
   uc->configuration_changed_cb = changed_cb;
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 void
@@ -575,7 +575,7 @@
                             void (*sw_system_im_cb)(void *ptr,
                                                      const char *name))
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -584,13 +584,13 @@
   uc->switch_app_global_im_cb = sw_app_im_cb;
   uc->switch_system_global_im_cb = sw_system_im_cb;
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 void
 uim_switch_im(uim_context uc, const char *engine)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   /* related to the commit log of r1400:
@@ -609,7 +609,7 @@
 
   uim_scm_callf("uim-switch-im", "py", uc, engine);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 const char *
@@ -618,7 +618,7 @@
   uim_lisp im, ret;
   const char *name;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return "direct";
 
   assert(uim_scm_gc_any_contextp());
@@ -628,7 +628,7 @@
   protected1 = ret = uim_scm_callf("im-name", "o", im);
   name = uim_scm_refer_c_str(ret);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return name;
 }
@@ -639,7 +639,7 @@
   uim_lisp ret;
   const char *name;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return "direct";
 
   assert(uim_scm_gc_any_contextp());
@@ -648,7 +648,7 @@
   protected0 = ret = uim_scm_callf("uim-get-default-im-name", "s", localename);
   name = uim_scm_refer_c_str(ret);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return name;
 }
@@ -659,7 +659,7 @@
   uim_lisp ret;
   const char *name;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return "direct";
 
   assert(uim_scm_gc_any_contextp());
@@ -669,7 +669,7 @@
     ret = uim_scm_callf("uim-get-im-name-for-locale", "s", localename);
   name = uim_scm_refer_c_str(ret);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return name;
 }
@@ -680,13 +680,13 @@
 int
 uim_get_nr_modes(uim_context uc)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return 0;
 
   assert(uim_scm_gc_any_contextp());
   assert(uc);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return uc->nr_modes;
 }
@@ -694,7 +694,7 @@
 const char *
 uim_get_mode_name(uim_context uc, int nth)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return NULL;
 
   assert(uim_scm_gc_any_contextp());
@@ -702,7 +702,7 @@
   assert(nth >= 0);
   assert(nth < uc->nr_modes);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return uc->modes[nth];
 }
@@ -710,13 +710,13 @@
 int
 uim_get_current_mode(uim_context uc)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return 0;
 
   assert(uim_scm_gc_any_contextp());
   assert(uc);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return uc->mode;
 }
@@ -724,7 +724,7 @@
 void
 uim_set_mode(uim_context uc, int mode)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -734,19 +734,19 @@
   uc->mode = mode;
   uim_scm_callf("mode-handler", "pi", uc, mode);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 void
 uim_set_mode_cb(uim_context uc, void (*update_cb)(void *ptr, int mode))
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
   assert(uc);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   uc->mode_update_cb = update_cb;
 }
@@ -754,13 +754,13 @@
 void
 uim_set_mode_list_update_cb(uim_context uc, void (*update_cb)(void *ptr))
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
   assert(uc);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   uc->mode_list_update_cb = update_cb;
 }
@@ -772,7 +772,7 @@
 uim_set_prop_list_update_cb(uim_context uc,
                            void (*update_cb)(void *ptr, const char *str))
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -780,7 +780,7 @@
 
   uc->prop_list_update_cb = update_cb;
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 /* Obsolete */
@@ -788,19 +788,19 @@
 uim_set_prop_label_update_cb(uim_context uc,
                             void (*update_cb)(void *ptr, const char *str))
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
   assert(uc);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 void
 uim_prop_list_update(uim_context uc)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -809,26 +809,26 @@
   if (uc->propstr && uc->prop_list_update_cb)
     uc->prop_list_update_cb(uc->ptr, uc->propstr);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 /* Obsolete */
 void
 uim_prop_label_update(uim_context uc)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
   assert(uc);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 void
 uim_prop_activate(uim_context uc, const char *str)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -837,7 +837,7 @@
       
   uim_scm_callf("prop-activate-handler", "ps", uc, str);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 /****************************************************************
@@ -861,7 +861,7 @@
 void
 uim_prop_update_custom(uim_context uc, const char *custom, const char *val)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return;
 
   assert(uim_scm_gc_any_contextp());
@@ -872,13 +872,13 @@
   uim_scm_callf("custom-set-handler", "pyo",
                 uc, custom, uim_scm_eval_c_string(val));
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 }
 
 uim_bool
 uim_prop_reload_configs(void)
 {
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return UIM_FALSE;
 
   assert(uim_scm_gc_any_contextp());
@@ -886,7 +886,7 @@
   /* FIXME: handle return value properly. */
   uim_scm_callf("custom-reload-user-configs", "");
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return UIM_TRUE;
 }
@@ -900,7 +900,7 @@
   uim_lisp n_;
   int n;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return 0;
 
   assert(uim_scm_gc_any_contextp());
@@ -909,7 +909,7 @@
   protected0 = n_ = uim_scm_callf("uim-n-convertible-ims", "p", uc);
   n = uim_scm_c_int(n_);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return n;
 }
@@ -930,14 +930,14 @@
   uim_lisp im, str_;
   const char *str;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return NULL;
 
   protected0 = im = get_nth_im(uc, nth);
   protected1 = str_ = uim_scm_callf("im-name", "o", im);
   str = uim_scm_refer_c_str(str_);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return str;
 }
@@ -948,14 +948,14 @@
   uim_lisp im, str_;
   const char *str;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return NULL;
 
   protected0 = im = get_nth_im(uc, nth);
   protected1 = str_ = uim_scm_callf("im-lang", "o", im);
   str = uim_scm_refer_c_str(str_);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return str;
 }
@@ -966,14 +966,14 @@
   uim_lisp im, str_;
   const char *str;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return NULL;
 
   protected0 = im = get_nth_im(uc, nth);
   protected1 = str_ = uim_scm_callf("im-encoding", "o", im);
   str = uim_scm_refer_c_str(str_);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return str;
 }
@@ -984,14 +984,14 @@
   uim_lisp im, short_desc;
   const char *str;
 
-  if (uim_catch_error_begin())
+  if (UIM_CATCH_ERROR_BEGIN())
     return NULL;
 
   protected0 = im = get_nth_im(uc, nth);
   protected1 = short_desc = uim_scm_callf("im-short-desc", "o", im);
   str = UIM_SCM_FALSEP(short_desc) ? "-" : uim_scm_refer_c_str(short_desc);
 
-  uim_catch_error_end();
+  UIM_CATCH_ERROR_END();
 
   return str;
 }

Reply via email to