*** empty log message ***
[m17n/m17n-lib.git] / src / m17n-core.c
index ec250ca..66fef04 100644 (file)
@@ -17,7 +17,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the m17n library; if not, write to the Free
 
    You should have received a copy of the GNU Lesser General Public
    License along with the m17n library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    02111-1307, USA.  */
 
 /***en
    02111-1307, USA.  */
 
 /***en
 #include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <unistd.h>
 #include <sys/time.h>
 #include <sys/resource.h>
 #include <unistd.h>
@@ -420,6 +421,7 @@ void *(*mdatabase__finder) (MSymbol tag1, MSymbol tag2,
 void *(*mdatabase__loader) (void *);
 
 int mdebug__flag;
 void *(*mdatabase__loader) (void *);
 
 int mdebug__flag;
+FILE *mdebug__output;
 
 void
 mdebug__push_time ()
 
 void
 mdebug__push_time ()
@@ -453,8 +455,13 @@ mdebug__print_time ()
   do {                                         \
     char *env_value = getenv (env_name);       \
                                                \
   do {                                         \
     char *env_value = getenv (env_name);       \
                                                \
-    if (env_value && env_value[0] == '1')      \
-      mdebug__flag |= (mask);                  \
+    if (env_value)                             \
+      {                                                \
+       if (env_value[0] == '1')                \
+         mdebug__flag |= (mask);               \
+       else if (env_value[0] == '0')           \
+         mdebug__flag &= ~(mask);              \
+      }                                                \
   } while (0)
 
 
   } while (0)
 
 
@@ -513,6 +520,7 @@ m17n_init_core (void)
   m17n_memory_full_handler = default_error_handler;
 
   mdebug__flag = 0;
   m17n_memory_full_handler = default_error_handler;
 
   mdebug__flag = 0;
+  SET_DEBUG_FLAG ("MDEBUG_ALL", MDEBUG_ALL);
   SET_DEBUG_FLAG ("MDEBUG_INIT", MDEBUG_INIT);
   SET_DEBUG_FLAG ("MDEBUG_FINI", MDEBUG_FINI);
   SET_DEBUG_FLAG ("MDEBUG_CHARSET", MDEBUG_CHARSET);
   SET_DEBUG_FLAG ("MDEBUG_INIT", MDEBUG_INIT);
   SET_DEBUG_FLAG ("MDEBUG_FINI", MDEBUG_FINI);
   SET_DEBUG_FLAG ("MDEBUG_CHARSET", MDEBUG_CHARSET);
@@ -522,6 +530,20 @@ m17n_init_core (void)
   SET_DEBUG_FLAG ("MDEBUG_FONT_FLT", MDEBUG_FONT_FLT);
   SET_DEBUG_FLAG ("MDEBUG_FONT_OTF", MDEBUG_FONT_OTF);
   SET_DEBUG_FLAG ("MDEBUG_INPUT", MDEBUG_INPUT);
   SET_DEBUG_FLAG ("MDEBUG_FONT_FLT", MDEBUG_FONT_FLT);
   SET_DEBUG_FLAG ("MDEBUG_FONT_OTF", MDEBUG_FONT_OTF);
   SET_DEBUG_FLAG ("MDEBUG_INPUT", MDEBUG_INPUT);
+  {
+    char *env_value = getenv ("MDEBUG_OUTPUT_FILE");
+
+    mdebug__output = NULL;
+    if (env_value)
+      {
+       if (strcmp (env_value, "stdout"))
+         mdebug__output = stdout;
+       else
+         mdebug__output = fopen (env_value, "a");
+      }
+    if (! mdebug__output)
+      mdebug__output = stderr;
+  }
 
   MDEBUG_PUSH_TIME ();
   MDEBUG_PUSH_TIME ();
 
   MDEBUG_PUSH_TIME ();
   MDEBUG_PUSH_TIME ();
@@ -543,6 +565,15 @@ m17n_init_core (void)
   mdatabase__finder = NULL;
   mdatabase__loader = NULL;
 
   mdatabase__finder = NULL;
   mdatabase__loader = NULL;
 
+#if ENABLE_NLS
+  bindtextdomain ("m17n-lib", GETTEXTDIR);
+  bindtextdomain ("m17n-db", GETTEXTDIR);
+  bindtextdomain ("m17n-contrib", GETTEXTDIR);
+  bind_textdomain_codeset ("m17n-lib", "UTF-8");
+  bind_textdomain_codeset ("m17n-db", "UTF-8");
+  bind_textdomain_codeset ("m17n-contrib", "UTF-8");
+#endif
+
  err:
   MDEBUG_POP_TIME ();
   MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize the core modules."));
  err:
   MDEBUG_POP_TIME ();
   MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize the core modules."));
@@ -560,22 +591,26 @@ m17n_fini_core (void)
 
   MDEBUG_PUSH_TIME ();
   MDEBUG_PUSH_TIME ();
 
   MDEBUG_PUSH_TIME ();
   MDEBUG_PUSH_TIME ();
-  MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize chartable module."));
   mchartable__fini ();
   mchartable__fini ();
-  MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize textprop module."));
-  mtext__prop_fini ();
-  MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize mtext module."));
+  MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize chartable module."));
   mtext__fini ();
   mtext__fini ();
-  MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize symbol module."));
+  MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize mtext module."));
   msymbol__fini ();
   msymbol__fini ();
-  MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize plist module."));
+  MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize symbol module."));
   mplist__fini ();
   mplist__fini ();
+  MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize plist module."));
+  /* We must call this after the aboves because it frees interval
+     pools.  */
+  mtext__prop_fini ();
+  MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize textprop module."));
   MDEBUG_POP_TIME ();
   MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize the core modules."));
   MDEBUG_POP_TIME ();
   if (mdebug__flag & MDEBUG_FINI)
     report_object_array ();
   msymbol__free_table ();
   MDEBUG_POP_TIME ();
   MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize the core modules."));
   MDEBUG_POP_TIME ();
   if (mdebug__flag & MDEBUG_FINI)
     report_object_array ();
   msymbol__free_table ();
+  if (mdebug__output != stderr)
+    fclose (mdebug__output);
 }
 
 /*** @} */
 }
 
 /*** @} */
@@ -631,8 +666,8 @@ m17n_status (void)
     zero.
 
     A property whose key is a managing key can have only a managed
     zero.
 
     A property whose key is a managing key can have only a managed
-    object as its value.  Such functions as msymbol_put () and
-    mplist_put () pay special attention to such a property.
+    object as its value.  Some functions, for instance msymbol_put ()
+    and mplist_put (), pay special attention to such a property.
 
     In addition to the predefined managed object types, users can
     define their own managed object types.  See the documentation of
 
     In addition to the predefined managed object types, users can
     define their own managed object types.  See the documentation of
@@ -643,7 +678,7 @@ m17n_status (void)
 
     m17n ¥ª¥Ö¥¸¥§¥¯¥È¤Î¤¢¤ë·¿¤Î¤â¤Î¤Ï¡¢»²¾È¿ô¤Ë¤è¤Ã¤Æ´ÉÍý¤µ¤ì¤Æ¤¤¤ë¡£
     ¤½¤ì¤é¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ï @e ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È ¤È¸Æ¤Ð¤ì¤ë¡£À¸À®¤µ¤ì¤¿»þÅÀ¤Ç¤Î»²¾È¿ô¤Ï
 
     m17n ¥ª¥Ö¥¸¥§¥¯¥È¤Î¤¢¤ë·¿¤Î¤â¤Î¤Ï¡¢»²¾È¿ô¤Ë¤è¤Ã¤Æ´ÉÍý¤µ¤ì¤Æ¤¤¤ë¡£
     ¤½¤ì¤é¤Î¥ª¥Ö¥¸¥§¥¯¥È¤Ï @e ´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È ¤È¸Æ¤Ð¤ì¤ë¡£À¸À®¤µ¤ì¤¿»þÅÀ¤Ç¤Î»²¾È¿ô¤Ï
-    0 ¤Ë½é´ü²½¤µ¤ì¤Æ¤¤¤ë¡£´Ø¿ô m17n_object_ref () ¤Ï´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Î»²¾È¿ô¤ò
+    1 ¤Ë½é´ü²½¤µ¤ì¤Æ¤¤¤ë¡£´Ø¿ô m17n_object_ref () ¤Ï´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Î»²¾È¿ô¤ò
     1 Áý¤ä¤·¡¢´Ø¿ôm17n_object_unref () ¤Ï 1 ¸º¤é¤¹¡£»²¾È¿ô¤¬
     0 ¤Ë¤Ê¤Ã¤¿´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Ï¼«Æ°Åª¤Ë²òÊü¤µ¤ì¤ë¡£
 
     1 Áý¤ä¤·¡¢´Ø¿ôm17n_object_unref () ¤Ï 1 ¸º¤é¤¹¡£»²¾È¿ô¤¬
     0 ¤Ë¤Ê¤Ã¤¿´ÉÍý²¼¥ª¥Ö¥¸¥§¥¯¥È¤Ï¼«Æ°Åª¤Ë²òÊü¤µ¤ì¤ë¡£