comparison src/coding.c @ 91838:7bed61cbed0c

(decode_coding_object, encode_coding_object): Preserve Vdeactivate_mark. Delete unnecessary call of Fcurrnet_buffer.
author Kenichi Handa <handa@m17n.org>
date Thu, 14 Feb 2008 12:24:15 +0000
parents 507bcfb4342c
children 52c3ba60b54b
comparison
equal deleted inserted replaced
91837:3ef9dcc38460 91838:7bed61cbed0c
6850 unsigned char *destination; 6850 unsigned char *destination;
6851 EMACS_INT dst_bytes; 6851 EMACS_INT dst_bytes;
6852 EMACS_INT chars = to - from; 6852 EMACS_INT chars = to - from;
6853 EMACS_INT bytes = to_byte - from_byte; 6853 EMACS_INT bytes = to_byte - from_byte;
6854 Lisp_Object attrs; 6854 Lisp_Object attrs;
6855 Lisp_Object buffer;
6856 int saved_pt = -1, saved_pt_byte; 6855 int saved_pt = -1, saved_pt_byte;
6857 int need_marker_adjustment = 0; 6856 int need_marker_adjustment = 0;
6858 6857 Lisp_Object old_deactivate_mark;
6859 buffer = Fcurrent_buffer (); 6858
6859 old_deactivate_mark = Vdeactivate_mark;
6860 6860
6861 if (NILP (dst_object)) 6861 if (NILP (dst_object))
6862 { 6862 {
6863 destination = coding->destination; 6863 destination = coding->destination;
6864 dst_bytes = coding->dst_bytes; 6864 dst_bytes = coding->dst_bytes;
6936 if (BUFFERP (coding->dst_object)) 6936 if (BUFFERP (coding->dst_object))
6937 set_buffer_internal (XBUFFER (coding->dst_object)); 6937 set_buffer_internal (XBUFFER (coding->dst_object));
6938 6938
6939 if (! NILP (CODING_ATTR_POST_READ (attrs))) 6939 if (! NILP (CODING_ATTR_POST_READ (attrs)))
6940 { 6940 {
6941 struct gcpro gcpro1, gcpro2; 6941 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
6942 EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE; 6942 EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE;
6943 Lisp_Object val; 6943 Lisp_Object val;
6944 6944
6945 TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); 6945 TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte);
6946 GCPRO2 (coding->src_object, coding->dst_object); 6946 GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object,
6947 old_deactivate_mark);
6947 val = safe_call1 (CODING_ATTR_POST_READ (attrs), 6948 val = safe_call1 (CODING_ATTR_POST_READ (attrs),
6948 make_number (coding->produced_char)); 6949 make_number (coding->produced_char));
6949 UNGCPRO; 6950 UNGCPRO;
6950 CHECK_NATNUM (val); 6951 CHECK_NATNUM (val);
6951 coding->produced_char += Z - prev_Z; 6952 coding->produced_char += Z - prev_Z;
6959 else if (NILP (dst_object) && BUFFERP (coding->dst_object)) 6960 else if (NILP (dst_object) && BUFFERP (coding->dst_object))
6960 { 6961 {
6961 set_buffer_internal (XBUFFER (coding->dst_object)); 6962 set_buffer_internal (XBUFFER (coding->dst_object));
6962 if (dst_bytes < coding->produced) 6963 if (dst_bytes < coding->produced)
6963 { 6964 {
6964 destination 6965 destination = xrealloc (destination, coding->produced);
6965 = (unsigned char *) xrealloc (destination, coding->produced);
6966 if (! destination) 6966 if (! destination)
6967 { 6967 {
6968 record_conversion_result (coding, 6968 record_conversion_result (coding,
6969 CODING_RESULT_INSUFFICIENT_DST); 6969 CODING_RESULT_INSUFFICIENT_DST);
6970 unbind_to (count, Qnil); 6970 unbind_to (count, Qnil);
7017 } 7017 }
7018 } 7018 }
7019 } 7019 }
7020 } 7020 }
7021 7021
7022 Vdeactivate_mark = old_deactivate_mark;
7022 unbind_to (count, coding->dst_object); 7023 unbind_to (count, coding->dst_object);
7023 } 7024 }
7024 7025
7025 7026
7026 void 7027 void
7033 { 7034 {
7034 int count = specpdl_ptr - specpdl; 7035 int count = specpdl_ptr - specpdl;
7035 EMACS_INT chars = to - from; 7036 EMACS_INT chars = to - from;
7036 EMACS_INT bytes = to_byte - from_byte; 7037 EMACS_INT bytes = to_byte - from_byte;
7037 Lisp_Object attrs; 7038 Lisp_Object attrs;
7038 Lisp_Object buffer;
7039 int saved_pt = -1, saved_pt_byte; 7039 int saved_pt = -1, saved_pt_byte;
7040 int need_marker_adjustment = 0; 7040 int need_marker_adjustment = 0;
7041 int kill_src_buffer = 0; 7041 int kill_src_buffer = 0;
7042 7042 Lisp_Object old_deactivate_mark;
7043 buffer = Fcurrent_buffer (); 7043
7044 old_deactivate_mark = Vdeactivate_mark;
7044 7045
7045 coding->src_object = src_object; 7046 coding->src_object = src_object;
7046 coding->src_chars = chars; 7047 coding->src_chars = chars;
7047 coding->src_bytes = bytes; 7048 coding->src_bytes = bytes;
7048 coding->src_multibyte = chars < bytes; 7049 coding->src_multibyte = chars < bytes;
7080 set_buffer_internal (XBUFFER (coding->src_object)); 7081 set_buffer_internal (XBUFFER (coding->src_object));
7081 } 7082 }
7082 7083
7083 { 7084 {
7084 Lisp_Object args[3]; 7085 Lisp_Object args[3];
7085 7086 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
7087
7088 GCPRO5 (coding->src_object, coding->dst_object, src_object, dst_object,
7089 old_deactivate_mark);
7086 args[0] = CODING_ATTR_PRE_WRITE (attrs); 7090 args[0] = CODING_ATTR_PRE_WRITE (attrs);
7087 args[1] = make_number (BEG); 7091 args[1] = make_number (BEG);
7088 args[2] = make_number (Z); 7092 args[2] = make_number (Z);
7089 safe_call (3, args); 7093 safe_call (3, args);
7094 UNGCPRO;
7090 } 7095 }
7091 if (XBUFFER (coding->src_object) != current_buffer) 7096 if (XBUFFER (coding->src_object) != current_buffer)
7092 kill_src_buffer = 1; 7097 kill_src_buffer = 1;
7093 coding->src_object = Fcurrent_buffer (); 7098 coding->src_object = Fcurrent_buffer ();
7094 if (BEG != GPT) 7099 if (BEG != GPT)
7215 } 7220 }
7216 } 7221 }
7217 7222
7218 if (kill_src_buffer) 7223 if (kill_src_buffer)
7219 Fkill_buffer (coding->src_object); 7224 Fkill_buffer (coding->src_object);
7225
7226 Vdeactivate_mark = old_deactivate_mark;
7220 unbind_to (count, Qnil); 7227 unbind_to (count, Qnil);
7221 } 7228 }
7222 7229
7223 7230
7224 Lisp_Object 7231 Lisp_Object