[uim-commit] r507 - in trunk: scm uim

yamaken at freedesktop.org yamaken at freedesktop.org
Thu Feb 3 13:38:02 PST 2005


Author: yamaken
Date: 2005-02-03 13:37:59 -0800 (Thu, 03 Feb 2005)
New Revision: 507

Modified:
   trunk/scm/im-custom.scm
   trunk/scm/lazy-load.scm
   trunk/uim/plugin.c
   trunk/uim/uim.c
Log:
* scm/im-custom.scm
  - (custom-installed-im-list): Avoid infinite loop while reloading
    all modules

* scm/lazy-load.scm
  - (stub-im-generate-init-handler): Add error check for possible stub
    IM actualization failure

* uim/plugin.c
  - (plugin_load): Add error check for scm file loading

* uim/uim.c
  - (uim_create_context): Add error check whether uim_init() had been
    called


Modified: trunk/scm/im-custom.scm
===================================================================
--- trunk/scm/im-custom.scm	2005-02-03 19:58:21 UTC (rev 506)
+++ trunk/scm/im-custom.scm	2005-02-03 21:37:59 UTC (rev 507)
@@ -171,7 +171,22 @@
 	  (orig-require require))
       (set! enabled-im-list ())  ;; enable all IMs
       ;; XXX temporary solution to register all IM in a file
-      (set! require load)
+      (set! require
+	    (lambda (file)
+	      (let* ((file-sym (string->symbol file))
+		     (loaded-sym (symbolconc '* file-sym '-loaded*))
+		     (reloaded-sym (symbolconc '* file-sym '-reloaded*)))
+		(cond
+		 ((symbol-bound? reloaded-sym)
+		  loaded-sym)
+		 ((try-load file)
+		  (eval (list 'define loaded-sym #t)
+			toplevel-env)
+		  (eval (list 'define reloaded-sym #t)
+			toplevel-env)
+		  loaded-sym)
+		 (else
+		  #f)))))
       (for-each require-module installed-im-module-list)
       (set! require orig-require)
       (set! enabled-im-list orig-enabled-im-list)

Modified: trunk/scm/lazy-load.scm
===================================================================
--- trunk/scm/lazy-load.scm	2005-02-03 19:58:21 UTC (rev 506)
+++ trunk/scm/lazy-load.scm	2005-02-03 21:37:59 UTC (rev 507)
@@ -34,12 +34,18 @@
 (define stub-im-generate-init-handler
   (lambda (name module-name)
     (lambda (id fake-im fake-arg)
-      (and (require-module module-name)
-	   (let* ((im (retrieve-im name))
-		  (init-handler (im-init-handler im))
-		  (arg (im-init-arg im))
-		  (context (init-handler id im arg)))
-	     context)))))
+      (let ((stub-im (retrieve-im name)))
+	(and (require-module module-name)
+	     (let* ((im (retrieve-im name))
+		    (init-handler (im-init-handler im))
+		    (arg (im-init-arg im))
+		    (context (if (not (eq? init-handler
+					   (im-init-handler stub-im)))
+				 (init-handler id im arg)
+				 (begin
+				   (error "stub IM actualization failed")
+				   #f))))
+	       context))))))
 
 (define register-stub-im
   (lambda (name lang encoding name-label short-desc module-name)

Modified: trunk/uim/plugin.c
===================================================================
--- trunk/uim/plugin.c	2005-02-03 19:58:21 UTC (rev 506)
+++ trunk/uim/plugin.c	2005-02-03 21:37:59 UTC (rev 507)
@@ -157,9 +157,19 @@
   }
 
   (plugin_instance_init)();
-  if (plugin_scm_filename)
-    uim_scm_require_file(plugin_scm_filename);
+  if (plugin_scm_filename) {
+    uim_bool succeeded;
 
+    succeeded = uim_scm_require_file(plugin_scm_filename);
+    if (!succeeded) {
+      fprintf(stderr, "%s plugin subsequent %s loading failed\n",
+	      plugin_name, plugin_scm_filename);
+      free(plugin_scm_filename);
+      free(plugin_name);
+      return uim_scm_f();
+    }
+  }
+
   {
     uim_lisp form;
     form = uim_scm_list5(uim_scm_make_symbol("plugin-list-append"),

Modified: trunk/uim/uim.c
===================================================================
--- trunk/uim/uim.c	2005-02-03 19:58:21 UTC (rev 506)
+++ trunk/uim/uim.c	2005-02-03 21:37:59 UTC (rev 507)
@@ -102,6 +102,11 @@
 {
   uim_context uc;
 
+  if (!uim_initialized) {
+    fprintf(stderr, "uim_create_context() before uim_init()\n");
+    return 0;
+  }
+
   if (!conv) {
     conv = uim_iconv;
   }



More information about the Uim-commit mailing list