*** empty log message ***
[m17n/m17n-lib.git] / src / mtext.c
index 975a4b4..6da7170 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
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    02111-1307, USA.  */
 
 /***en
@@ -971,6 +971,7 @@ mtext__init ()
   M17N_OBJECT_ADD_ARRAY (mtext_table, "M-text");
   M_charbag = msymbol_as_managing_key ("  charbag");
   mtext_table.count = 0;
+  Mlanguage = msymbol ("language");
   return 0;
 }
 
@@ -1585,6 +1586,12 @@ const int MTEXT_FORMAT_UTF_32 = MTEXT_FORMAT_UTF_32LE;
 /*** @{ */
 /*=*/
 
+/***en The symbol whose name is "language".  */
+/***ja "language" ¤È¤¤¤¦Ì¾Á°¤ò»ý¤Ä¥·¥ó¥Ü¥ë.  */
+MSymbol Mlanguage;
+
+/*=*/
+
 /***en
     @brief Allocate a new M-text.
 
@@ -2016,7 +2023,7 @@ mtext_cat_char (MText *mt, int c)
   nunits = CHAR_UNITS (c, mt->format);
   if ((mt->nbytes + nunits + 1) * unit_bytes > mt->allocated)
     {
-      mt->allocated = (mt->nbytes + nunits + 1) * unit_bytes;
+      mt->allocated = (mt->nbytes + nunits * 16 + 1) * unit_bytes;
       MTABLE_REALLOC (mt->data, mt->allocated, MERROR_MTEXT);
     }
   
@@ -2622,8 +2629,8 @@ mtext_ins_char (MText *mt, int pos, int c, int n)
     @brief Replace sub-text of M-text with another.
 
     The mtext_replace () function replaces sub-text of M-text $MT1
-    between $FROM1 (inclusive) and $TO1 (exclusinve) with the sub-text
-    of M-text $MT2 between $FROM2 (inclusive) and $TO2 (exclusinve).
+    between $FROM1 (inclusive) and $TO1 (exclusive) with the sub-text
+    of M-text $MT2 between $FROM2 (inclusive) and $TO2 (exclusive).
     The new sub-text inherits text properties of the old sub-text.
 
     @return If the operation was successful, mtext_replace () returns
@@ -3454,7 +3461,7 @@ mtext_lowercase (MText *mt)
     The mtext_titlecase () function destructively converts the first
     character with the cased property in M-text $MT to titlecase and
     the others to lowercase.  The length of $MT may change.  If the
-    character cannot be converted to titlercase, it is left unchanged.
+    character cannot be converted to titlecase, it is left unchanged.
     All the text properties are inherited.
 
     @return
@@ -3589,35 +3596,39 @@ mtext_uppercase (MText *mt)
 MText *
 mdebug_dump_mtext (MText *mt, int indent, int fullp)
 {
-  char *prefix = (char *) alloca (indent + 1);
   int i;
-  unsigned char *p;
-
-  memset (prefix, 32, indent);
-  prefix[indent] = 0;
 
-  fprintf (stderr,
-          "(mtext (size %d %d %d) (cache %d %d)",
-          mt->nchars, mt->nbytes, mt->allocated,
-          mt->cache_char_pos, mt->cache_byte_pos);
   if (! fullp)
     {
-      fprintf (stderr, " \"");
+      fprintf (stderr, "\"");
       for (i = 0; i < mt->nchars; i++)
        {
          int c = mtext_ref_char (mt, i);
 
          if (c == '"' || c == '\\')
            fprintf (stderr, "\\%c", c);
-         else if (c >= ' ' && c < 127)
+         else if ((c >= ' ' && c < 127) || c == '\n')
            fprintf (stderr, "%c", c);
          else
            fprintf (stderr, "\\x%02X", c);
        }
       fprintf (stderr, "\"");
+      return mt;
     }
-  else if (mt->nchars > 0)
+
+  fprintf (stderr,
+          "(mtext (size %d %d %d) (cache %d %d)",
+          mt->nchars, mt->nbytes, mt->allocated,
+          mt->cache_char_pos, mt->cache_byte_pos);
+
+  if (mt->nchars > 0)
     {
+      char *prefix = (char *) alloca (indent + 1);
+      unsigned char *p;
+
+      memset (prefix, 32, indent);
+      prefix[indent] = 0;
+
       fprintf (stderr, "\n%s (bytes \"", prefix);
       for (i = 0; i < mt->nbytes; i++)
        fprintf (stderr, "\\x%02x", mt->data[i]);