aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa2005-09-14 07:06:20 +0000
committerKenichi Handa2005-09-14 07:06:20 +0000
commit24a2b282278cd0e245894851bfc208bd53e9b2e3 (patch)
treecdeb8a28b26ddb37d6d3d748c0f08e74a4ac07dc /src/coding.c
parent2b046a720b0564ae3f8685cb153370586c87e17c (diff)
downloademacs-24a2b282278cd0e245894851bfc208bd53e9b2e3.tar.gz
emacs-24a2b282278cd0e245894851bfc208bd53e9b2e3.zip
(code_convert_region_unwind): Argument format changed.
(run_pre_post_conversion_on_str): If pre-write-conversion function changed the current buffer, delete the new buffer. (run_pre_write_conversin_on_c_str): Likewise.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/src/coding.c b/src/coding.c
index 794f49495fb..fa9a37b9452 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -5353,8 +5353,8 @@ static int shrink_conversion_region_threshhold = 1024;
5353 } \ 5353 } \
5354 } while (0) 5354 } while (0)
5355 5355
5356/* ARG is (CODING . BUFFER) where CODING is what to be set in 5356/* ARG is (CODING BUFFER ...) where CODING is what to be set in
5357 Vlast_coding_system_used and BUFFER if non-nil is a buffer to 5357 Vlast_coding_system_used and the remaining elements are buffers to
5358 kill. */ 5358 kill. */
5359static Lisp_Object 5359static Lisp_Object
5360code_convert_region_unwind (arg) 5360code_convert_region_unwind (arg)
@@ -5362,8 +5362,8 @@ code_convert_region_unwind (arg)
5362{ 5362{
5363 inhibit_pre_post_conversion = 0; 5363 inhibit_pre_post_conversion = 0;
5364 Vlast_coding_system_used = XCAR (arg); 5364 Vlast_coding_system_used = XCAR (arg);
5365 if (! NILP (XCDR (arg))) 5365 for (arg = XCDR (arg); ! NILP (arg); arg = XCDR (arg))
5366 Fkill_buffer (XCDR (arg)); 5366 Fkill_buffer (XCAR (arg));
5367 return Qnil; 5367 return Qnil;
5368} 5368}
5369 5369
@@ -6081,6 +6081,7 @@ run_pre_post_conversion_on_str (str, coding, encodep)
6081 int multibyte = STRING_MULTIBYTE (str); 6081 int multibyte = STRING_MULTIBYTE (str);
6082 Lisp_Object old_deactivate_mark; 6082 Lisp_Object old_deactivate_mark;
6083 Lisp_Object buffer_to_kill; 6083 Lisp_Object buffer_to_kill;
6084 Lisp_Object unwind_arg;
6084 6085
6085 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 6086 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
6086 /* It is not crucial to specbind this. */ 6087 /* It is not crucial to specbind this. */
@@ -6091,15 +6092,25 @@ run_pre_post_conversion_on_str (str, coding, encodep)
6091 unibyte<->multibyte conversion. For that, we adjust the 6092 unibyte<->multibyte conversion. For that, we adjust the
6092 multibyteness of the working buffer to that of STR. */ 6093 multibyteness of the working buffer to that of STR. */
6093 buffer_to_kill = set_conversion_work_buffer (multibyte); 6094 buffer_to_kill = set_conversion_work_buffer (multibyte);
6094 record_unwind_protect (code_convert_region_unwind, 6095 if (NILP (buffer_to_kill))
6095 Fcons (Vlast_coding_system_used, buffer_to_kill)); 6096 unwind_arg = Fcons (Vlast_coding_system_used, Qnil);
6097 else
6098 unwind_arg = list2 (Vlast_coding_system_used, buffer_to_kill);
6099 record_unwind_protect (code_convert_region_unwind, unwind_arg);
6096 6100
6097 insert_from_string (str, 0, 0, 6101 insert_from_string (str, 0, 0,
6098 SCHARS (str), SBYTES (str), 0); 6102 SCHARS (str), SBYTES (str), 0);
6099 UNGCPRO; 6103 UNGCPRO;
6100 inhibit_pre_post_conversion = 1; 6104 inhibit_pre_post_conversion = 1;
6101 if (encodep) 6105 if (encodep)
6102 call2 (coding->pre_write_conversion, make_number (BEG), make_number (Z)); 6106 {
6107 struct buffer *prev = current_buffer;
6108
6109 call2 (coding->pre_write_conversion, make_number (BEG), make_number (Z));
6110 if (prev != current_buffer)
6111 /* We must kill the current buffer too. */
6112 Fsetcdr (unwind_arg, Fcons (Fcurrent_buffer (), XCDR (unwind_arg)));
6113 }
6103 else 6114 else
6104 { 6115 {
6105 Vlast_coding_system_used = coding->symbol; 6116 Vlast_coding_system_used = coding->symbol;
@@ -6133,6 +6144,7 @@ run_pre_write_conversin_on_c_str (str, size, nchars, nbytes, coding)
6133{ 6144{
6134 struct gcpro gcpro1, gcpro2; 6145 struct gcpro gcpro1, gcpro2;
6135 struct buffer *cur = current_buffer; 6146 struct buffer *cur = current_buffer;
6147 struct buffer *prev;
6136 Lisp_Object old_deactivate_mark, old_last_coding_system_used; 6148 Lisp_Object old_deactivate_mark, old_last_coding_system_used;
6137 Lisp_Object args[3]; 6149 Lisp_Object args[3];
6138 Lisp_Object buffer_to_kill; 6150 Lisp_Object buffer_to_kill;
@@ -6149,6 +6161,7 @@ run_pre_write_conversin_on_c_str (str, size, nchars, nbytes, coding)
6149 insert_1_both (*str, nchars, nbytes, 0, 0, 0); 6161 insert_1_both (*str, nchars, nbytes, 0, 0, 0);
6150 UNGCPRO; 6162 UNGCPRO;
6151 inhibit_pre_post_conversion = 1; 6163 inhibit_pre_post_conversion = 1;
6164 prev = current_buffer;
6152 args[0] = coding->pre_write_conversion; 6165 args[0] = coding->pre_write_conversion;
6153 args[1] = make_number (BEG); 6166 args[1] = make_number (BEG);
6154 args[2] = make_number (Z); 6167 args[2] = make_number (Z);
@@ -6168,6 +6181,8 @@ run_pre_write_conversin_on_c_str (str, size, nchars, nbytes, coding)
6168 bcopy (BEG_ADDR, *str, coding->produced); 6181 bcopy (BEG_ADDR, *str, coding->produced);
6169 coding->src_multibyte 6182 coding->src_multibyte
6170 = ! NILP (current_buffer->enable_multibyte_characters); 6183 = ! NILP (current_buffer->enable_multibyte_characters);
6184 if (prev != current_buffer)
6185 Fkill_buffer (Fcurrent_buffer ());
6171 set_buffer_internal (cur); 6186 set_buffer_internal (cur);
6172 if (! NILP (buffer_to_kill)) 6187 if (! NILP (buffer_to_kill))
6173 Fkill_buffer (buffer_to_kill); 6188 Fkill_buffer (buffer_to_kill);