changeset 31702:ef25c62becab

(Fccl_execute_on_string): Make multibyte string correctly. If output buffer is too small, signal an appropriated error.
author Kenichi Handa <handa@m17n.org>
date Tue, 19 Sep 2000 00:14:17 +0000
parents 1106e8c3d500
children b5664da02625
files src/ccl.c
diffstat 1 files changed, 10 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/ccl.c	Tue Sep 19 00:13:47 2000 +0000
+++ b/src/ccl.c	Tue Sep 19 00:14:17 2000 +0000
@@ -2035,21 +2035,27 @@
   ccl.last_block = NILP (contin);
   ccl.multibyte = STRING_MULTIBYTE (str);
   produced = ccl_driver (&ccl, XSTRING (str)->data, outbuf,
-			 STRING_BYTES (XSTRING (str)), outbufsize, (int *)0);
+			 STRING_BYTES (XSTRING (str)), outbufsize, (int *) 0);
   for (i = 0; i < 8; i++)
     XSET (XVECTOR (status)->contents[i], Lisp_Int, ccl.reg[i]);
   XSETINT (XVECTOR (status)->contents[8], ccl.ic);
   UNGCPRO;
 
   if (NILP (unibyte_p))
-    val = make_string (outbuf, produced);
+    {
+      int nchars;
+
+      produced = str_as_multibyte (outbuf, outbufsize, produced, &nchars);
+      val = make_multibyte_string (outbuf, nchars, produced);
+    }
   else
     val = make_unibyte_string (outbuf, produced);
   xfree (outbuf);
   QUIT;
+  if (ccl.status == CCL_STAT_SUSPEND_BY_DST)
+    error ("Output buffer for the CCL programs overflow");
   if (ccl.status != CCL_STAT_SUCCESS
-      && ccl.status != CCL_STAT_SUSPEND_BY_SRC
-      && ccl.status != CCL_STAT_SUSPEND_BY_DST)
+      && ccl.status != CCL_STAT_SUSPEND_BY_SRC)
     error ("Error in CCL program at %dth code", ccl.ic);
 
   return val;