changeset 50200:fdeb795fc0ec

(make_specified_string): Fix previous change.
author Kenichi Handa <handa@m17n.org>
date Wed, 19 Mar 2003 12:24:43 +0000
parents 2e56eaaf925b
children d0449a23c8d9
files src/alloc.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/alloc.c	Wed Mar 19 12:09:37 2003 +0000
+++ b/src/alloc.c	Wed Mar 19 12:24:43 2003 +0000
@@ -1819,7 +1819,8 @@
 
 /* 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 @@
      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)