aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa2000-06-30 02:56:45 +0000
committerKenichi Handa2000-06-30 02:56:45 +0000
commit4956c22544e90a3530bfb8205f32d9c067a550e1 (patch)
tree53e1cb392caf2965e3079ea6823f08fda0799d23 /src/coding.c
parentdca9961d8108623065cd3a8f4e74a2b41eac0ed0 (diff)
downloademacs-4956c22544e90a3530bfb8205f32d9c067a550e1.tar.gz
emacs-4956c22544e90a3530bfb8205f32d9c067a550e1.zip
(code_convert_region): Even if the length of text is
zero, try to convert it if coding->type is coding_type_ccl. (decode_coding_string, encode_coding_string): Likewise.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c79
1 files changed, 41 insertions, 38 deletions
diff --git a/src/coding.c b/src/coding.c
index f2af9f5bf35..536ad60f5ca 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -4802,31 +4802,32 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace)
4802 } 4802 }
4803 4803
4804 /* Try to skip the heading and tailing ASCIIs. */ 4804 /* Try to skip the heading and tailing ASCIIs. */
4805 { 4805 if (coding->type != coding_type_ccl)
4806 int from_byte_orig = from_byte, to_byte_orig = to_byte; 4806 {
4807 4807 int from_byte_orig = from_byte, to_byte_orig = to_byte;
4808 if (from < GPT && GPT < to)
4809 move_gap_both (from, from_byte);
4810 SHRINK_CONVERSION_REGION (&from_byte, &to_byte, coding, NULL, encodep);
4811 if (from_byte == to_byte
4812 && (encodep || NILP (coding->post_read_conversion))
4813 && ! CODING_REQUIRE_FLUSHING (coding))
4814 {
4815 coding->produced = len_byte;
4816 coding->produced_char = len;
4817 if (!replace)
4818 /* We must record and adjust for this new text now. */
4819 adjust_after_insert (from, from_byte_orig, to, to_byte_orig, len);
4820 return 0;
4821 }
4822 4808
4823 head_skip = from_byte - from_byte_orig; 4809 if (from < GPT && GPT < to)
4824 tail_skip = to_byte_orig - to_byte; 4810 move_gap_both (from, from_byte);
4825 total_skip = head_skip + tail_skip; 4811 SHRINK_CONVERSION_REGION (&from_byte, &to_byte, coding, NULL, encodep);
4826 from += head_skip; 4812 if (from_byte == to_byte
4827 to -= tail_skip; 4813 && (encodep || NILP (coding->post_read_conversion))
4828 len -= total_skip; len_byte -= total_skip; 4814 && ! CODING_REQUIRE_FLUSHING (coding))
4829 } 4815 {
4816 coding->produced = len_byte;
4817 coding->produced_char = len;
4818 if (!replace)
4819 /* We must record and adjust for this new text now. */
4820 adjust_after_insert (from, from_byte_orig, to, to_byte_orig, len);
4821 return 0;
4822 }
4823
4824 head_skip = from_byte - from_byte_orig;
4825 tail_skip = to_byte_orig - to_byte;
4826 total_skip = head_skip + tail_skip;
4827 from += head_skip;
4828 to -= tail_skip;
4829 len -= total_skip; len_byte -= total_skip;
4830 }
4830 4831
4831 /* The code conversion routine can not preserve text properties for 4832 /* The code conversion routine can not preserve text properties for
4832 now. So, we must remove all text properties in the region. 4833 now. So, we must remove all text properties in the region.
@@ -5227,14 +5228,15 @@ decode_coding_string (str, coding, nocopy)
5227 coding_allocate_composition_data (coding, from); 5228 coding_allocate_composition_data (coding, from);
5228 5229
5229 /* Try to skip the heading and tailing ASCIIs. */ 5230 /* Try to skip the heading and tailing ASCIIs. */
5230 { 5231 if (coding->type != coding_type_ccl)
5231 int from_orig = from; 5232 {
5233 int from_orig = from;
5232 5234
5233 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, 5235 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data,
5234 0); 5236 0);
5235 if (from == to_byte) 5237 if (from == to_byte)
5236 return (nocopy ? str : Fcopy_sequence (str)); 5238 return (nocopy ? str : Fcopy_sequence (str));
5237 } 5239 }
5238 5240
5239 len = decoding_buffer_size (coding, to_byte - from); 5241 len = decoding_buffer_size (coding, to_byte - from);
5240 len += from + STRING_BYTES (XSTRING (str)) - to_byte; 5242 len += from + STRING_BYTES (XSTRING (str)) - to_byte;
@@ -5315,14 +5317,15 @@ encode_coding_string (str, coding, nocopy)
5315 coding_save_composition (coding, from, to, str); 5317 coding_save_composition (coding, from, to, str);
5316 5318
5317 /* Try to skip the heading and tailing ASCIIs. */ 5319 /* Try to skip the heading and tailing ASCIIs. */
5318 { 5320 if (coding->type != coding_type_ccl)
5319 int from_orig = from; 5321 {
5322 int from_orig = from;
5320 5323
5321 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, 5324 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data,
5322 1); 5325 1);
5323 if (from == to_byte) 5326 if (from == to_byte)
5324 return (nocopy ? str : Fcopy_sequence (str)); 5327 return (nocopy ? str : Fcopy_sequence (str));
5325 } 5328 }
5326 5329
5327 len = encoding_buffer_size (coding, to_byte - from); 5330 len = encoding_buffer_size (coding, to_byte - from);
5328 len += from + STRING_BYTES (XSTRING (str)) - to_byte; 5331 len += from + STRING_BYTES (XSTRING (str)) - to_byte;