changeset 57285:9093a2e9c3fd

(code_convert_region): Don't skip ASCIIs if there are compositions to encode. Free composition data. (encode_coding_string): Likewise.
author Kenichi Handa <handa@m17n.org>
date Wed, 29 Sep 2004 23:40:30 +0000
parents 5293cc67f41d
children 32c7a00069f2
files src/coding.c
diffstat 1 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/coding.c	Wed Sep 29 22:52:05 2004 +0000
+++ b/src/coding.c	Wed Sep 29 23:40:30 2004 +0000
@@ -5650,8 +5650,11 @@
 	coding_allocate_composition_data (coding, from);
     }
 
-  /* Try to skip the heading and tailing ASCIIs.  */
-  if (coding->type != coding_type_ccl)
+  /* Try to skip the heading and tailing ASCIIs.  We can't skip them
+     if we must run CCL program or there are compositions to
+     encode.  */
+  if (coding->type != coding_type_ccl
+      && (! coding->cmp_data || coding->cmp_data->used == 0))
     {
       int from_byte_orig = from_byte, to_byte_orig = to_byte;
 
@@ -5667,6 +5670,7 @@
 	  if (!replace)
 	    /* We must record and adjust for this new text now.  */
 	    adjust_after_insert (from, from_byte_orig, to, to_byte_orig, len);
+	  coding_free_composition_data (coding);
 	  return 0;
 	}
 
@@ -6297,13 +6301,19 @@
   if (coding->composing != COMPOSITION_DISABLED)
     coding_save_composition (coding, from, to, str);
 
-  /* Try to skip the heading and tailing ASCIIs.  */
-  if (coding->type != coding_type_ccl)
+  /* Try to skip the heading and tailing ASCIIs.  We can't skip them
+     if we must run CCL program or there are compositions to
+     encode.  */
+  if (coding->type != coding_type_ccl
+      && (! coding->cmp_data || coding->cmp_data->used == 0))
     {
       SHRINK_CONVERSION_REGION (&from, &to_byte, coding, SDATA (str),
 				1);
       if (from == to_byte)
-	return (nocopy ? str : Fcopy_sequence (str));
+	{
+	  coding_free_composition_data (coding);
+	  return (nocopy ? str : Fcopy_sequence (str));
+	}
       shrinked_bytes = from + (SBYTES (str) - to_byte);
     }