Print debug information to mdebug__output instead of stderr.
[m17n/m17n-lib.git] / src / mtext.c
index 64a593c..8efe58e 100644 (file)
@@ -3582,8 +3582,9 @@ mtext_uppercase (MText *mt)
     @brief Dump an M-text.
 
     The mdebug_dump_mtext () function prints the M-text $MT in a human
-    readable way to the stderr.  $INDENT specifies how many columns to
-    indent the lines but the first one.  If $FULLP is zero, this
+    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.  If $FULLP is zero, this
     function prints only a character code sequence.  Otherwise, it
     prints the internal byte sequence and text properties as well.
 
@@ -3592,10 +3593,11 @@ mtext_uppercase (MText *mt)
 /***ja
     @brief M-text ¤ò¥À¥ó¥×¤¹¤ë.
 
-    ´Ø¿ô mdebug_dump_mtext () ¤Ï M-text $MT ¤ò stderr 
-    ¤Ë¿Í´Ö¤Ë²ÄÆɤʷÁ¤Ç°õºþ¤¹¤ë¡£ $INDENT ¤Ï£²¹ÔÌܰʹߤΥ¤¥ó¥Ç¥ó¥È¤ò»ØÄꤹ¤ë¡£
-    $FULLP ¤¬ 0 ¤Ê¤é¤Ð¡¢Ê¸»ú¥³¡¼¥ÉÎó¤À¤±¤ò°õºþ¤¹¤ë¡£
-    ¤½¤¦¤Ç¤Ê¤±¤ì¤Ð¡¢ÆâÉô¥Ð¥¤¥ÈÎó¤È¥Æ¥­¥¹¥È¥×¥í¥Ñ¥Æ¥£¤â°õºþ¤¹¤ë¡£
+    ´Ø¿ô mdebug_dump_mtext () ¤Ï M-text $MT ¤òɸ½à¥¨¥é¡¼½ÐÎϤ⤷¤¯¤Ï´Ä
+    ¶­ÊÑ¿ô MDEBUG_DUMP_FONT ¤Ç»ØÄꤵ¤ì¤¿¥Õ¥¡¥¤¥ë¤Ë¿Í´Ö¤Ë²ÄÆɤʷÁ¤Ç°õºþ
+    ¤¹¤ë¡£ $INDENT ¤Ï£²¹ÔÌܰʹߤΥ¤¥ó¥Ç¥ó¥È¤ò»ØÄꤹ¤ë¡£$FULLP ¤¬ 0 ¤Ê¤é
+    ¤Ð¡¢Ê¸»ú¥³¡¼¥ÉÎó¤À¤±¤ò°õºþ¤¹¤ë¡£¤½¤¦¤Ç¤Ê¤±¤ì¤Ð¡¢ÆâÉô¥Ð¥¤¥ÈÎó¤È¥Æ¥­
+    ¥¹¥È¥×¥í¥Ñ¥Æ¥£¤â°õºþ¤¹¤ë¡£
 
     @return
     ¤³¤Î´Ø¿ô¤Ï $MT ¤òÊÖ¤¹¡£  */
@@ -3607,23 +3609,23 @@ mdebug_dump_mtext (MText *mt, int indent, int fullp)
 
   if (! fullp)
     {
-      fprintf (stderr, "\"");
+      fprintf (mdebug__output, "\"");
       for (i = 0; i < mt->nchars; i++)
        {
          int c = mtext_ref_char (mt, i);
 
          if (c == '"' || c == '\\')
-           fprintf (stderr, "\\%c", c);
+           fprintf (mdebug__output, "\\%c", c);
          else if ((c >= ' ' && c < 127) || c == '\n')
-           fprintf (stderr, "%c", c);
+           fprintf (mdebug__output, "%c", c);
          else
-           fprintf (stderr, "\\x%02X", c);
+           fprintf (mdebug__output, "\\x%02X", c);
        }
-      fprintf (stderr, "\"");
+      fprintf (mdebug__output, "\"");
       return mt;
     }
 
-  fprintf (stderr,
+  fprintf (mdebug__output,
           "(mtext (size %d %d %d) (cache %d %d)",
           mt->nchars, mt->nbytes, mt->allocated,
           mt->cache_char_pos, mt->cache_byte_pos);
@@ -3636,11 +3638,11 @@ mdebug_dump_mtext (MText *mt, int indent, int fullp)
       memset (prefix, 32, indent);
       prefix[indent] = 0;
 
-      fprintf (stderr, "\n%s (bytes \"", prefix);
+      fprintf (mdebug__output, "\n%s (bytes \"", prefix);
       for (i = 0; i < mt->nbytes; i++)
-       fprintf (stderr, "\\x%02x", mt->data[i]);
-      fprintf (stderr, "\")\n");
-      fprintf (stderr, "%s (chars \"", prefix);
+       fprintf (mdebug__output, "\\x%02x", mt->data[i]);
+      fprintf (mdebug__output, "\")\n");
+      fprintf (mdebug__output, "%s (chars \"", prefix);
       p = mt->data;
       for (i = 0; i < mt->nchars; i++)
        {
@@ -3648,21 +3650,21 @@ mdebug_dump_mtext (MText *mt, int indent, int fullp)
          int c = STRING_CHAR_AND_BYTES (p, len);
 
          if (c == '"' || c == '\\')
-           fprintf (stderr, "\\%c", c);
+           fprintf (mdebug__output, "\\%c", c);
          else if (c >= ' ' && c < 127)
-           fputc (c, stderr);
+           fputc (c, mdebug__output);
          else
-           fprintf (stderr, "\\x%X", c);
+           fprintf (mdebug__output, "\\x%X", c);
          p += len;
        }
-      fprintf (stderr, "\")");
+      fprintf (mdebug__output, "\")");
       if (mt->plist)
        {
-         fprintf (stderr, "\n%s ", prefix);
+         fprintf (mdebug__output, "\n%s ", prefix);
          dump_textplist (mt->plist, indent + 1);
        }
     }
-  fprintf (stderr, ")");
+  fprintf (mdebug__output, ")");
   return mt;
 }