aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa2005-07-14 07:57:42 +0000
committerKenichi Handa2005-07-14 07:57:42 +0000
commit16ef9c5612fdd85f6a7ca16e433f05af6e51e221 (patch)
treeebf8950be988c06ac8ab1049c3609fed1af3f2c9 /src/coding.c
parentead25b5cabbe092711864eae13a76437e6a65ce1 (diff)
downloademacs-16ef9c5612fdd85f6a7ca16e433f05af6e51e221.tar.gz
emacs-16ef9c5612fdd85f6a7ca16e433f05af6e51e221.zip
(code_convert_region_unwind): ARG is changed to a cons.
(code_convert_region): Adjusted for the above change. (set_conversion_work_buffer): If the work buffer is already in use, generate a new buffer and return it. Otherwise return Qnil. (run_pre_post_conversion_on_str): Adjusted for the above change. (run_pre_write_conversin_on_c_str): Likewise.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/src/coding.c b/src/coding.c
index d74f4a93ce9..a4f03c70d96 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -5353,12 +5353,17 @@ 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
5357 Vlast_coding_system_used and BUFFER if non-nil is a buffer to
5358 kill. */
5356static Lisp_Object 5359static Lisp_Object
5357code_convert_region_unwind (arg) 5360code_convert_region_unwind (arg)
5358 Lisp_Object arg; 5361 Lisp_Object arg;
5359{ 5362{
5360 inhibit_pre_post_conversion = 0; 5363 inhibit_pre_post_conversion = 0;
5361 Vlast_coding_system_used = arg; 5364 Vlast_coding_system_used = XCAR (arg);
5365 if (! NILP (XCDR (arg)))
5366 Fkill_buffer (XCDR (arg));
5362 return Qnil; 5367 return Qnil;
5363} 5368}
5364 5369
@@ -5611,7 +5616,7 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace)
5611 Lisp_Object new; 5616 Lisp_Object new;
5612 5617
5613 record_unwind_protect (code_convert_region_unwind, 5618 record_unwind_protect (code_convert_region_unwind,
5614 Vlast_coding_system_used); 5619 Fcons (Vlast_coding_system_used, Qnil));
5615 /* We should not call any more pre-write/post-read-conversion 5620 /* We should not call any more pre-write/post-read-conversion
5616 functions while this pre-write-conversion is running. */ 5621 functions while this pre-write-conversion is running. */
5617 inhibit_pre_post_conversion = 1; 5622 inhibit_pre_post_conversion = 1;
@@ -5979,7 +5984,7 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace)
5979 TEMP_SET_PT_BOTH (from, from_byte); 5984 TEMP_SET_PT_BOTH (from, from_byte);
5980 prev_Z = Z; 5985 prev_Z = Z;
5981 record_unwind_protect (code_convert_region_unwind, 5986 record_unwind_protect (code_convert_region_unwind,
5982 Vlast_coding_system_used); 5987 Fcons (Vlast_coding_system_used, Qnil));
5983 saved_coding_system = Vlast_coding_system_used; 5988 saved_coding_system = Vlast_coding_system_used;
5984 Vlast_coding_system_used = coding->symbol; 5989 Vlast_coding_system_used = coding->symbol;
5985 /* We should not call any more pre-write/post-read-conversion 5990 /* We should not call any more pre-write/post-read-conversion
@@ -6025,17 +6030,31 @@ static Lisp_Object Vcode_conversion_workbuf_name;
6025 6030
6026/* Set the current buffer to the working buffer prepared for 6031/* Set the current buffer to the working buffer prepared for
6027 code-conversion. MULTIBYTE specifies the multibyteness of the 6032 code-conversion. MULTIBYTE specifies the multibyteness of the
6028 buffer. */ 6033 buffer. Return the buffer we set if it must be killed after use.
6034 Otherwise return Qnil. */
6029 6035
6030static struct buffer * 6036static Lisp_Object
6031set_conversion_work_buffer (multibyte) 6037set_conversion_work_buffer (multibyte)
6032 int multibyte; 6038 int multibyte;
6033{ 6039{
6034 Lisp_Object buffer; 6040 Lisp_Object buffer, buffer_to_kill;
6035 struct buffer *buf; 6041 struct buffer *buf;
6036 6042
6037 buffer = Fget_buffer_create (Vcode_conversion_workbuf_name); 6043 buffer = Fget_buffer_create (Vcode_conversion_workbuf_name);
6038 buf = XBUFFER (buffer); 6044 buf = XBUFFER (buffer);
6045 if (buf == current_buffer)
6046 {
6047 /* As we are already in the work buffer, we must generate a new
6048 buffer for the work. */
6049 Lisp_Object name;
6050
6051 name = Fgenerate_new_buffer_name (Vcode_conversion_workbuf_name, Qnil);
6052 buffer = buffer_to_kill = Fget_buffer_create (name);
6053 buf = XBUFFER (buffer);
6054 }
6055 else
6056 buffer_to_kill = Qnil;
6057
6039 delete_all_overlays (buf); 6058 delete_all_overlays (buf);
6040 buf->directory = current_buffer->directory; 6059 buf->directory = current_buffer->directory;
6041 buf->read_only = Qnil; 6060 buf->read_only = Qnil;
@@ -6048,7 +6067,7 @@ set_conversion_work_buffer (multibyte)
6048 Fwiden (); 6067 Fwiden ();
6049 del_range_2 (BEG, BEG_BYTE, Z, Z_BYTE, 0); 6068 del_range_2 (BEG, BEG_BYTE, Z, Z_BYTE, 0);
6050 buf->enable_multibyte_characters = multibyte ? Qt : Qnil; 6069 buf->enable_multibyte_characters = multibyte ? Qt : Qnil;
6051 return buf; 6070 return buffer_to_kill;
6052} 6071}
6053 6072
6054Lisp_Object 6073Lisp_Object
@@ -6061,10 +6080,9 @@ run_pre_post_conversion_on_str (str, coding, encodep)
6061 struct gcpro gcpro1, gcpro2; 6080 struct gcpro gcpro1, gcpro2;
6062 int multibyte = STRING_MULTIBYTE (str); 6081 int multibyte = STRING_MULTIBYTE (str);
6063 Lisp_Object old_deactivate_mark; 6082 Lisp_Object old_deactivate_mark;
6083 Lisp_Object buffer_to_kill;
6064 6084
6065 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 6085 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
6066 record_unwind_protect (code_convert_region_unwind,
6067 Vlast_coding_system_used);
6068 /* It is not crucial to specbind this. */ 6086 /* It is not crucial to specbind this. */
6069 old_deactivate_mark = Vdeactivate_mark; 6087 old_deactivate_mark = Vdeactivate_mark;
6070 GCPRO2 (str, old_deactivate_mark); 6088 GCPRO2 (str, old_deactivate_mark);
@@ -6072,7 +6090,9 @@ run_pre_post_conversion_on_str (str, coding, encodep)
6072 /* We must insert the contents of STR as is without 6090 /* We must insert the contents of STR as is without
6073 unibyte<->multibyte conversion. For that, we adjust the 6091 unibyte<->multibyte conversion. For that, we adjust the
6074 multibyteness of the working buffer to that of STR. */ 6092 multibyteness of the working buffer to that of STR. */
6075 set_conversion_work_buffer (multibyte); 6093 buffer_to_kill = set_conversion_work_buffer (multibyte);
6094 record_unwind_protect (code_convert_region_unwind,
6095 Fcons (Vlast_coding_system_used, buffer_to_kill));
6076 6096
6077 insert_from_string (str, 0, 0, 6097 insert_from_string (str, 0, 0,
6078 SCHARS (str), SBYTES (str), 0); 6098 SCHARS (str), SBYTES (str), 0);
@@ -6115,6 +6135,7 @@ run_pre_write_conversin_on_c_str (str, size, nchars, nbytes, coding)
6115 struct buffer *cur = current_buffer; 6135 struct buffer *cur = current_buffer;
6116 Lisp_Object old_deactivate_mark, old_last_coding_system_used; 6136 Lisp_Object old_deactivate_mark, old_last_coding_system_used;
6117 Lisp_Object args[3]; 6137 Lisp_Object args[3];
6138 Lisp_Object buffer_to_kill;
6118 6139
6119 /* It is not crucial to specbind this. */ 6140 /* It is not crucial to specbind this. */
6120 old_deactivate_mark = Vdeactivate_mark; 6141 old_deactivate_mark = Vdeactivate_mark;
@@ -6124,7 +6145,7 @@ run_pre_write_conversin_on_c_str (str, size, nchars, nbytes, coding)
6124 /* We must insert the contents of STR as is without 6145 /* We must insert the contents of STR as is without
6125 unibyte<->multibyte conversion. For that, we adjust the 6146 unibyte<->multibyte conversion. For that, we adjust the
6126 multibyteness of the working buffer to that of STR. */ 6147 multibyteness of the working buffer to that of STR. */
6127 set_conversion_work_buffer (coding->src_multibyte); 6148 buffer_to_kill = set_conversion_work_buffer (coding->src_multibyte);
6128 insert_1_both (*str, nchars, nbytes, 0, 0, 0); 6149 insert_1_both (*str, nchars, nbytes, 0, 0, 0);
6129 UNGCPRO; 6150 UNGCPRO;
6130 inhibit_pre_post_conversion = 1; 6151 inhibit_pre_post_conversion = 1;
@@ -6148,6 +6169,8 @@ run_pre_write_conversin_on_c_str (str, size, nchars, nbytes, coding)
6148 coding->src_multibyte 6169 coding->src_multibyte
6149 = ! NILP (current_buffer->enable_multibyte_characters); 6170 = ! NILP (current_buffer->enable_multibyte_characters);
6150 set_buffer_internal (cur); 6171 set_buffer_internal (cur);
6172 if (! NILP (buffer_to_kill))
6173 Fkill_buffer (buffer_to_kill);
6151} 6174}
6152 6175
6153 6176