comparison src/coding.c @ 29985:c17e78d8c720

(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.
author Kenichi Handa <handa@m17n.org>
date Fri, 30 Jun 2000 02:56:45 +0000
parents 37a3b3eae862
children 35aec8514228
comparison
equal deleted inserted replaced
29984:9e8199cd7e3e 29985:c17e78d8c720
4800 else 4800 else
4801 coding_allocate_composition_data (coding, from); 4801 coding_allocate_composition_data (coding, from);
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) 4808
4809 move_gap_both (from, from_byte); 4809 if (from < GPT && GPT < to)
4810 SHRINK_CONVERSION_REGION (&from_byte, &to_byte, coding, NULL, encodep); 4810 move_gap_both (from, from_byte);
4811 if (from_byte == to_byte 4811 SHRINK_CONVERSION_REGION (&from_byte, &to_byte, coding, NULL, encodep);
4812 && (encodep || NILP (coding->post_read_conversion)) 4812 if (from_byte == to_byte
4813 && ! CODING_REQUIRE_FLUSHING (coding)) 4813 && (encodep || NILP (coding->post_read_conversion))
4814 { 4814 && ! CODING_REQUIRE_FLUSHING (coding))
4815 coding->produced = len_byte; 4815 {
4816 coding->produced_char = len; 4816 coding->produced = len_byte;
4817 if (!replace) 4817 coding->produced_char = len;
4818 /* We must record and adjust for this new text now. */ 4818 if (!replace)
4819 adjust_after_insert (from, from_byte_orig, to, to_byte_orig, len); 4819 /* We must record and adjust for this new text now. */
4820 return 0; 4820 adjust_after_insert (from, from_byte_orig, to, to_byte_orig, len);
4821 } 4821 return 0;
4822 4822 }
4823 head_skip = from_byte - from_byte_orig; 4823
4824 tail_skip = to_byte_orig - to_byte; 4824 head_skip = from_byte - from_byte_orig;
4825 total_skip = head_skip + tail_skip; 4825 tail_skip = to_byte_orig - to_byte;
4826 from += head_skip; 4826 total_skip = head_skip + tail_skip;
4827 to -= tail_skip; 4827 from += head_skip;
4828 len -= total_skip; len_byte -= total_skip; 4828 to -= tail_skip;
4829 } 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.
4833 Here, we must suppress all modification hooks. */ 4834 Here, we must suppress all modification hooks. */
4834 if (replace) 4835 if (replace)
5225 5226
5226 if (coding->composing != COMPOSITION_DISABLED) 5227 if (coding->composing != COMPOSITION_DISABLED)
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 {
5232 5233 int from_orig = from;
5233 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, 5234
5234 0); 5235 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data,
5235 if (from == to_byte) 5236 0);
5236 return (nocopy ? str : Fcopy_sequence (str)); 5237 if (from == to_byte)
5237 } 5238 return (nocopy ? str : Fcopy_sequence (str));
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;
5241 GCPRO1 (str); 5243 GCPRO1 (str);
5242 buf = get_conversion_buffer (len); 5244 buf = get_conversion_buffer (len);
5313 5315
5314 if (coding->composing != COMPOSITION_DISABLED) 5316 if (coding->composing != COMPOSITION_DISABLED)
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 {
5320 5322 int from_orig = from;
5321 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, 5323
5322 1); 5324 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data,
5323 if (from == to_byte) 5325 1);
5324 return (nocopy ? str : Fcopy_sequence (str)); 5326 if (from == to_byte)
5325 } 5327 return (nocopy ? str : Fcopy_sequence (str));
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;
5329 GCPRO1 (str); 5332 GCPRO1 (str);
5330 buf = get_conversion_buffer (len); 5333 buf = get_conversion_buffer (len);