(make_specified_string): Fix previous change.
authorKenichi Handa <handa@m17n.org>
Wed, 19 Mar 2003 12:24:43 +0000 (12:24 +0000)
committerKenichi Handa <handa@m17n.org>
Wed, 19 Mar 2003 12:24:43 +0000 (12:24 +0000)
src/alloc.c

index d703d3d..2c1d09a 100644 (file)
@@ -1819,7 +1819,8 @@ make_string_from_bytes (contents, nchars, nbytes)
 
 /* Make a string from NCHARS characters occupying NBYTES bytes at
    CONTENTS.  The argument MULTIBYTE controls whether to label the
-   string as multibyte.  */
+   string as multibyte.  If NCHARS is negative, it counts the number of
+   characters by itself.  */
 
 Lisp_Object
 make_specified_string (contents, nchars, nbytes, multibyte)
@@ -1828,6 +1829,14 @@ make_specified_string (contents, nchars, nbytes, multibyte)
      int multibyte;
 {
   register Lisp_Object val;
+
+  if (nchars < 0)
+    {
+      if (multibyte)
+       nchars = multibyte_chars_in_text (contents, nbytes);
+      else
+       nchars = nbytes;
+    }
   val = make_uninit_multibyte_string (nchars, nbytes);
   bcopy (contents, SDATA (val), nbytes);
   if (!multibyte)