comparison src/coding.c @ 89418:a9c2b3712863

(coding_set_source): Fix for the case that the current buffer is different from coding->src_object. (decode_coding_object): Don't use the conversion work buffer if DST_OBJECT is a buffer.
author Kenichi Handa <handa@m17n.org>
date Tue, 06 May 2003 08:16:37 +0000
parents 3e1d187b52c3
children c3e67ce6ee0f
comparison
equal deleted inserted replaced
89417:56c80a95cb5b 89418:a9c2b3712863
897 coding_set_source (coding) 897 coding_set_source (coding)
898 struct coding_system *coding; 898 struct coding_system *coding;
899 { 899 {
900 if (BUFFERP (coding->src_object)) 900 if (BUFFERP (coding->src_object))
901 { 901 {
902 struct buffer *buf = XBUFFER (coding->src_object);
903
902 if (coding->src_pos < 0) 904 if (coding->src_pos < 0)
903 coding->source = GAP_END_ADDR + coding->src_pos_byte; 905 coding->source = BUF_GAP_END_ADDR (buf) + coding->src_pos_byte;
904 else 906 else
905 { 907 coding->source = BUF_BYTE_ADDRESS (buf, coding->src_pos_byte);
906 struct buffer *buf = XBUFFER (coding->src_object);
907 EMACS_INT gpt_byte = BUF_GPT_BYTE (buf);
908 unsigned char *beg_addr = BUF_BEG_ADDR (buf);
909
910 coding->source = beg_addr + coding->src_pos_byte - 1;
911 if (coding->src_pos_byte >= gpt_byte)
912 coding->source += BUF_GAP_SIZE (buf);
913 }
914 } 908 }
915 else if (STRINGP (coding->src_object)) 909 else if (STRINGP (coding->src_object))
916 { 910 {
917 coding->source = (XSTRING (coding->src_object)->data 911 coding->source = (XSTRING (coding->src_object)->data
918 + coding->src_pos_byte); 912 + coding->src_pos_byte);
6229 6223
6230 If it is Qt, a string is made from the decoded text, and 6224 If it is Qt, a string is made from the decoded text, and
6231 set in CODING->dst_object. 6225 set in CODING->dst_object.
6232 6226
6233 If it is Qnil, the decoded text is stored at CODING->destination. 6227 If it is Qnil, the decoded text is stored at CODING->destination.
6234 The called must allocate CODING->dst_bytes bytes at 6228 The caller must allocate CODING->dst_bytes bytes at
6235 CODING->destination by xmalloc. If the decoded text is longer than 6229 CODING->destination by xmalloc. If the decoded text is longer than
6236 CODING->dst_bytes, CODING->destination is relocated by xrealloc. 6230 CODING->dst_bytes, CODING->destination is relocated by xrealloc.
6237 */ 6231 */
6238 6232
6239 void 6233 void
6291 6285
6292 if (CODING_REQUIRE_DETECTION (coding)) 6286 if (CODING_REQUIRE_DETECTION (coding))
6293 detect_coding (coding); 6287 detect_coding (coding);
6294 attrs = CODING_ID_ATTRS (coding->id); 6288 attrs = CODING_ID_ATTRS (coding->id);
6295 6289
6296 if (! NILP (CODING_ATTR_POST_READ (attrs)) 6290 if (EQ (dst_object, Qt)
6297 || EQ (dst_object, Qt)) 6291 || (! NILP (CODING_ATTR_POST_READ (attrs))
6292 && NILP (dst_object)))
6298 { 6293 {
6299 coding->dst_object = make_conversion_work_buffer (1); 6294 coding->dst_object = make_conversion_work_buffer (1);
6300 coding->dst_pos = BEG; 6295 coding->dst_pos = BEG;
6301 coding->dst_pos_byte = BEG_BYTE; 6296 coding->dst_pos_byte = BEG_BYTE;
6302 coding->dst_multibyte = 1; 6297 coding->dst_multibyte = 1;