comparison src/coding.c @ 89448:de8b460070cc

(setup_coding_system): If coding has post-read-conversion or pre-write-conversion, set CODING_REQUIRE_DECODING_MASK and CODING_REQUIRE_ENCODING_MASK respectively. (decode_coding_gap): Run post-read-conversion if any.
author Kenichi Handa <handa@m17n.org>
date Thu, 29 May 2003 13:17:04 +0000
parents 1c88b057b9d3
children 4e359ebf3984
comparison
equal deleted inserted replaced
89447:afecc4e131a1 89448:de8b460070cc
4821 4821
4822 coding->mode = 0; 4822 coding->mode = 0;
4823 coding->head_ascii = -1; 4823 coding->head_ascii = -1;
4824 coding->common_flags 4824 coding->common_flags
4825 = (VECTORP (eol_type) ? CODING_REQUIRE_DETECTION_MASK : 0); 4825 = (VECTORP (eol_type) ? CODING_REQUIRE_DETECTION_MASK : 0);
4826 if (! NILP (CODING_ATTR_POST_READ (attrs)))
4827 coding->common_flags |= CODING_REQUIRE_DECODING_MASK;
4828 if (! NILP (CODING_ATTR_PRE_WRITE (attrs)))
4829 coding->common_flags |= CODING_REQUIRE_ENCODING_MASK;
4826 4830
4827 val = CODING_ATTR_SAFE_CHARSETS (attrs); 4831 val = CODING_ATTR_SAFE_CHARSETS (attrs);
4828 coding->max_charset_id = XSTRING (val)->size - 1; 4832 coding->max_charset_id = XSTRING (val)->size - 1;
4829 coding->safe_charsets = (char *) XSTRING (val)->data; 4833 coding->safe_charsets = (char *) XSTRING (val)->data;
4830 coding->default_char = XINT (CODING_ATTR_DEFAULT_CHAR (attrs)); 4834 coding->default_char = XINT (CODING_ATTR_DEFAULT_CHAR (attrs));
6225 decode_coding_gap (coding, chars, bytes) 6229 decode_coding_gap (coding, chars, bytes)
6226 struct coding_system *coding; 6230 struct coding_system *coding;
6227 EMACS_INT chars, bytes; 6231 EMACS_INT chars, bytes;
6228 { 6232 {
6229 int count = specpdl_ptr - specpdl; 6233 int count = specpdl_ptr - specpdl;
6234 Lisp_Object attrs;
6230 Lisp_Object buffer; 6235 Lisp_Object buffer;
6231 6236
6232 buffer = Fcurrent_buffer (); 6237 buffer = Fcurrent_buffer ();
6233 code_conversion_save (buffer, 0, 0); 6238 code_conversion_save (buffer, 0, 0);
6234 6239
6236 coding->src_chars = chars; 6241 coding->src_chars = chars;
6237 coding->src_bytes = bytes; 6242 coding->src_bytes = bytes;
6238 coding->src_pos = -chars; 6243 coding->src_pos = -chars;
6239 coding->src_pos_byte = -bytes; 6244 coding->src_pos_byte = -bytes;
6240 coding->src_multibyte = chars < bytes; 6245 coding->src_multibyte = chars < bytes;
6241 coding->dst_object = coding->src_object; 6246 coding->dst_object = buffer;
6242 coding->dst_pos = PT; 6247 coding->dst_pos = PT;
6243 coding->dst_pos_byte = PT_BYTE; 6248 coding->dst_pos_byte = PT_BYTE;
6244 coding->dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters); 6249 coding->dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters);
6245 coding->mode |= CODING_MODE_LAST_BLOCK; 6250 coding->mode |= CODING_MODE_LAST_BLOCK;
6246 6251
6247 if (CODING_REQUIRE_DETECTION (coding)) 6252 if (CODING_REQUIRE_DETECTION (coding))
6248 detect_coding (coding); 6253 detect_coding (coding);
6249 6254
6250 decode_coding (coding); 6255 decode_coding (coding);
6256
6257 attrs = CODING_ID_ATTRS (coding->id);
6258 if (! NILP (CODING_ATTR_POST_READ (attrs)))
6259 {
6260 struct gcpro gcpro1;
6261 EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE;
6262 Lisp_Object val;
6263
6264 TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte);
6265 GCPRO1 (buffer);
6266 val = call1 (CODING_ATTR_POST_READ (attrs),
6267 make_number (coding->produced_char));
6268 UNGCPRO;
6269 CHECK_NATNUM (val);
6270 coding->produced_char += Z - prev_Z;
6271 coding->produced += Z_BYTE - prev_Z_BYTE;
6272 }
6251 6273
6252 unbind_to (count, Qnil); 6274 unbind_to (count, Qnil);
6253 return coding->result; 6275 return coding->result;
6254 } 6276 }
6255 6277