Mercurial > emacs
comparison src/coding.c @ 88510:d266b8fb8761
(encode_coding_object): Give correct arguments ot
pre-write-conversion. Ignore the return value of
pre-write-conversion function. Pay attention for the case that
pre-write-conversion change the current buffer. If dst_object is
Qt, even if coding->src_bytes is zero, allocate at least one byte
to coding->destination.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Tue, 14 May 2002 13:03:23 +0000 |
| parents | a7f0d13affa5 |
| children | f464d728344c |
comparison
equal
deleted
inserted
replaced
| 88509:0ac97e7062f5 | 88510:d266b8fb8761 |
|---|---|
| 5977 | 5977 |
| 5978 attrs = CODING_ID_ATTRS (coding->id); | 5978 attrs = CODING_ID_ATTRS (coding->id); |
| 5979 | 5979 |
| 5980 if (! NILP (CODING_ATTR_PRE_WRITE (attrs))) | 5980 if (! NILP (CODING_ATTR_PRE_WRITE (attrs))) |
| 5981 { | 5981 { |
| 5982 Lisp_Object val; | |
| 5983 | |
| 5984 coding->src_object = make_conversion_work_buffer (coding->src_multibyte); | 5982 coding->src_object = make_conversion_work_buffer (coding->src_multibyte); |
| 5985 set_buffer_internal (XBUFFER (coding->src_object)); | 5983 set_buffer_internal (XBUFFER (coding->src_object)); |
| 5986 if (STRINGP (src_object)) | 5984 if (STRINGP (src_object)) |
| 5987 insert_from_string (src_object, from, from_byte, chars, bytes, 0); | 5985 insert_from_string (src_object, from, from_byte, chars, bytes, 0); |
| 5988 else if (BUFFERP (src_object)) | 5986 else if (BUFFERP (src_object)) |
| 5995 set_buffer_internal (XBUFFER (src_object)); | 5993 set_buffer_internal (XBUFFER (src_object)); |
| 5996 del_range_both (from, from_byte, to, to_byte, 1); | 5994 del_range_both (from, from_byte, to, to_byte, 1); |
| 5997 set_buffer_internal (XBUFFER (coding->src_object)); | 5995 set_buffer_internal (XBUFFER (coding->src_object)); |
| 5998 } | 5996 } |
| 5999 | 5997 |
| 6000 val = call2 (CODING_ATTR_PRE_WRITE (attrs), | 5998 call2 (CODING_ATTR_PRE_WRITE (attrs), |
| 6001 make_number (1), make_number (chars)); | 5999 make_number (BEG), make_number (Z)); |
| 6002 CHECK_NATNUM (val); | 6000 coding->src_object = Fcurrent_buffer (); |
| 6003 if (BEG != GPT) | 6001 if (BEG != GPT) |
| 6004 move_gap_both (BEG, BEG_BYTE); | 6002 move_gap_both (BEG, BEG_BYTE); |
| 6005 coding->src_chars = Z - BEG; | 6003 coding->src_chars = Z - BEG; |
| 6006 coding->src_bytes = Z_BYTE - BEG_BYTE; | 6004 coding->src_bytes = Z_BYTE - BEG_BYTE; |
| 6007 coding->src_pos = BEG; | 6005 coding->src_pos = BEG; |
| 6040 = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters); | 6038 = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters); |
| 6041 } | 6039 } |
| 6042 else if (EQ (dst_object, Qt)) | 6040 else if (EQ (dst_object, Qt)) |
| 6043 { | 6041 { |
| 6044 coding->dst_object = Qnil; | 6042 coding->dst_object = Qnil; |
| 6045 coding->destination = (unsigned char *) xmalloc (coding->src_chars); | |
| 6046 coding->dst_bytes = coding->src_chars; | 6043 coding->dst_bytes = coding->src_chars; |
| 6044 if (coding->dst_bytes == 0) | |
| 6045 coding->dst_bytes = 1; | |
| 6046 coding->destination = (unsigned char *) xmalloc (coding->dst_bytes); | |
| 6047 coding->dst_multibyte = 0; | 6047 coding->dst_multibyte = 0; |
| 6048 } | 6048 } |
| 6049 else | 6049 else |
| 6050 { | 6050 { |
| 6051 coding->dst_object = Qnil; | 6051 coding->dst_object = Qnil; |
