Print debug information to mdebug__output instead of stderr.
[m17n/m17n-lib.git] / src / plist.c
index 05dd737..0c91268 100644 (file)
@@ -526,7 +526,7 @@ read_element (MPlist *plist, MStream *st, MPlist *keys)
     if (MT)                            \
       mtext_cat_char ((MT), (C));      \
     else                               \
-      putc ((C), stderr);              \
+      putc ((C), mdebug__output);      \
   } while (0);
 
 #define PUTS(MT, STR)                  \
@@ -534,7 +534,7 @@ read_element (MPlist *plist, MStream *st, MPlist *keys)
     if (MT)                            \
       MTEXT_CAT_ASCII ((MT), (STR));   \
     else                               \
-      fputs ((STR), stderr);           \
+      fputs ((STR), mdebug__output);   \
   } while (0)
 
 
@@ -654,7 +654,7 @@ write_element (MText *mt, MPlist *plist, int indent)
              unsigned char *end = data + mtext__char_to_byte (this_mt, stop);
 
              while (beg < end)
-               putc (*beg, stderr), beg++;
+               putc (*beg, mdebug__output), beg++;
            }
          if (stop == to)
            break;
@@ -680,7 +680,7 @@ write_element (MText *mt, MPlist *plist, int indent)
          M17N_OBJECT_UNREF (this_mt);
        }
       else
-       fprintf (stderr, "%s", str);
+       fprintf (mdebug__output, "%s", str);
     }
   else 
     {
@@ -1640,16 +1640,18 @@ mplist_deserialize (MText *mt)
     @brief Dump a property list.
 
     The mdebug_dump_plist () function prints a property list $PLIST in
-    a human readable way to the stderr.  $INDENT specifies how many
-    columns to indent the lines but the first one.
+    a human readable way to the stderr or to what specified by the
+    environment variable MDEBUG_OUTPUT_FILE.  $INDENT specifies how
+    many columns to indent the lines but the first one.
 
     @return
     This function returns $PLIST.  */
 /***ja
     @brief ¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È¤ò¥À¥ó¥×¤¹¤ë.
 
-    ´Ø¿ô mdebug_dump_plist () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤ò stderr 
-    ¤Ë¿Í´Ö¤Ë²ÄÆɤʷÁ¤Ç°õºþ¤¹¤ë¡£ $INDENT ¤Ï£²¹ÔÌܰʹߤΥ¤¥ó¥Ç¥ó¥È¤ò»ØÄꤹ¤ë¡£
+    ´Ø¿ô mdebug_dump_plist () ¤Ï¥×¥í¥Ñ¥Æ¥£¥ê¥¹¥È $PLIST ¤òɸ½à¥¨¥é¡¼½Ð
+    ÎϤ⤷¤¯¤Ï´Ä¶­ÊÑ¿ô MDEBUG_DUMP_FONT ¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤Ë¿Í´Ö¤Ë²Ä
+    ÆɤʷÁ¤Ç°õºþ¤¹¤ë¡£ $INDENT ¤Ï£²¹ÔÌܰʹߤΥ¤¥ó¥Ç¥ó¥È¤ò»ØÄꤹ¤ë¡£
 
     @return
     ¤³¤Î´Ø¿ô¤Ï $PLIST ¤òÊÖ¤¹¡£  */
@@ -1662,14 +1664,14 @@ mdebug_dump_plist (MPlist *plist, int indent)
   memset (prefix, 32, indent);
   prefix[indent] = 0;
 
-  fprintf (stderr, "(");
+  fprintf (mdebug__output, "(");
   MPLIST_DO (pl, plist)
     {
       if (pl != plist)
-       fprintf (stderr, "\n%s ", prefix);
+       fprintf (mdebug__output, "\n%s ", prefix);
       write_element (NULL, pl, indent + 1);
     }
-  fprintf (stderr, ")");
+  fprintf (mdebug__output, ")");
   return plist;
 }