comparison src/coding.c @ 83381:d84f940244dc

Merged from miles@gnu.org--gnu-2005 (patch 116-117, 544-550) Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-544 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-545 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-546 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-547 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-548 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-549 Update from CVS * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-550 Update from CVS * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-116 Merge from emacs--cvs-trunk--0 * miles@gnu.org--gnu-2005/gnus--rel--5.10--patch-117 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-421
author Karoly Lorentey <lorentey@elte.hu>
date Sat, 17 Sep 2005 19:10:55 +0000
parents 532e0a9335a9 f376635f5061
children be1f74bffc1d
comparison
equal deleted inserted replaced
83380:94f174e5569d 83381:d84f940244dc
5347 if (encodep) shrink_encoding_region (beg, end, coding, str); \ 5347 if (encodep) shrink_encoding_region (beg, end, coding, str); \
5348 else shrink_decoding_region (beg, end, coding, str); \ 5348 else shrink_decoding_region (beg, end, coding, str); \
5349 } \ 5349 } \
5350 } while (0) 5350 } while (0)
5351 5351
5352 /* ARG is (CODING . BUFFER) where CODING is what to be set in 5352 /* ARG is (CODING BUFFER ...) where CODING is what to be set in
5353 Vlast_coding_system_used and BUFFER if non-nil is a buffer to 5353 Vlast_coding_system_used and the remaining elements are buffers to
5354 kill. */ 5354 kill. */
5355 static Lisp_Object 5355 static Lisp_Object
5356 code_convert_region_unwind (arg) 5356 code_convert_region_unwind (arg)
5357 Lisp_Object arg; 5357 Lisp_Object arg;
5358 { 5358 {
5359 inhibit_pre_post_conversion = 0; 5359 inhibit_pre_post_conversion = 0;
5360 Vlast_coding_system_used = XCAR (arg); 5360 Vlast_coding_system_used = XCAR (arg);
5361 if (! NILP (XCDR (arg))) 5361 for (arg = XCDR (arg); ! NILP (arg); arg = XCDR (arg))
5362 Fkill_buffer (XCDR (arg)); 5362 Fkill_buffer (XCAR (arg));
5363 return Qnil; 5363 return Qnil;
5364 } 5364 }
5365 5365
5366 /* Store information about all compositions in the range FROM and TO 5366 /* Store information about all compositions in the range FROM and TO
5367 of OBJ in memory blocks pointed by CODING->cmp_data. OBJ is a 5367 of OBJ in memory blocks pointed by CODING->cmp_data. OBJ is a
6075 int count = SPECPDL_INDEX (); 6075 int count = SPECPDL_INDEX ();
6076 struct gcpro gcpro1, gcpro2; 6076 struct gcpro gcpro1, gcpro2;
6077 int multibyte = STRING_MULTIBYTE (str); 6077 int multibyte = STRING_MULTIBYTE (str);
6078 Lisp_Object old_deactivate_mark; 6078 Lisp_Object old_deactivate_mark;
6079 Lisp_Object buffer_to_kill; 6079 Lisp_Object buffer_to_kill;
6080 Lisp_Object unwind_arg;
6080 6081
6081 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); 6082 record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
6082 /* It is not crucial to specbind this. */ 6083 /* It is not crucial to specbind this. */
6083 old_deactivate_mark = Vdeactivate_mark; 6084 old_deactivate_mark = Vdeactivate_mark;
6084 GCPRO2 (str, old_deactivate_mark); 6085 GCPRO2 (str, old_deactivate_mark);
6085 6086
6086 /* We must insert the contents of STR as is without 6087 /* We must insert the contents of STR as is without
6087 unibyte<->multibyte conversion. For that, we adjust the 6088 unibyte<->multibyte conversion. For that, we adjust the
6088 multibyteness of the working buffer to that of STR. */ 6089 multibyteness of the working buffer to that of STR. */
6089 buffer_to_kill = set_conversion_work_buffer (multibyte); 6090 buffer_to_kill = set_conversion_work_buffer (multibyte);
6090 record_unwind_protect (code_convert_region_unwind, 6091 if (NILP (buffer_to_kill))
6091 Fcons (Vlast_coding_system_used, buffer_to_kill)); 6092 unwind_arg = Fcons (Vlast_coding_system_used, Qnil);
6093 else
6094 unwind_arg = list2 (Vlast_coding_system_used, buffer_to_kill);
6095 record_unwind_protect (code_convert_region_unwind, unwind_arg);
6092 6096
6093 insert_from_string (str, 0, 0, 6097 insert_from_string (str, 0, 0,
6094 SCHARS (str), SBYTES (str), 0); 6098 SCHARS (str), SBYTES (str), 0);
6095 UNGCPRO; 6099 UNGCPRO;
6096 inhibit_pre_post_conversion = 1; 6100 inhibit_pre_post_conversion = 1;
6097 if (encodep) 6101 if (encodep)
6098 call2 (coding->pre_write_conversion, make_number (BEG), make_number (Z)); 6102 {
6103 struct buffer *prev = current_buffer;
6104
6105 call2 (coding->pre_write_conversion, make_number (BEG), make_number (Z));
6106 if (prev != current_buffer)
6107 /* We must kill the current buffer too. */
6108 Fsetcdr (unwind_arg, Fcons (Fcurrent_buffer (), XCDR (unwind_arg)));
6109 }
6099 else 6110 else
6100 { 6111 {
6101 Vlast_coding_system_used = coding->symbol; 6112 Vlast_coding_system_used = coding->symbol;
6102 TEMP_SET_PT_BOTH (BEG, BEG_BYTE); 6113 TEMP_SET_PT_BOTH (BEG, BEG_BYTE);
6103 call1 (coding->post_read_conversion, make_number (Z - BEG)); 6114 call1 (coding->post_read_conversion, make_number (Z - BEG));
6127 int *size, nchars, nbytes; 6138 int *size, nchars, nbytes;
6128 struct coding_system *coding; 6139 struct coding_system *coding;
6129 { 6140 {
6130 struct gcpro gcpro1, gcpro2; 6141 struct gcpro gcpro1, gcpro2;
6131 struct buffer *cur = current_buffer; 6142 struct buffer *cur = current_buffer;
6143 struct buffer *prev;
6132 Lisp_Object old_deactivate_mark, old_last_coding_system_used; 6144 Lisp_Object old_deactivate_mark, old_last_coding_system_used;
6133 Lisp_Object args[3]; 6145 Lisp_Object args[3];
6134 Lisp_Object buffer_to_kill; 6146 Lisp_Object buffer_to_kill;
6135 6147
6136 /* It is not crucial to specbind this. */ 6148 /* It is not crucial to specbind this. */
6143 multibyteness of the working buffer to that of STR. */ 6155 multibyteness of the working buffer to that of STR. */
6144 buffer_to_kill = set_conversion_work_buffer (coding->src_multibyte); 6156 buffer_to_kill = set_conversion_work_buffer (coding->src_multibyte);
6145 insert_1_both (*str, nchars, nbytes, 0, 0, 0); 6157 insert_1_both (*str, nchars, nbytes, 0, 0, 0);
6146 UNGCPRO; 6158 UNGCPRO;
6147 inhibit_pre_post_conversion = 1; 6159 inhibit_pre_post_conversion = 1;
6160 prev = current_buffer;
6148 args[0] = coding->pre_write_conversion; 6161 args[0] = coding->pre_write_conversion;
6149 args[1] = make_number (BEG); 6162 args[1] = make_number (BEG);
6150 args[2] = make_number (Z); 6163 args[2] = make_number (Z);
6151 safe_call (3, args); 6164 safe_call (3, args);
6152 inhibit_pre_post_conversion = 0; 6165 inhibit_pre_post_conversion = 0;
6162 if (BEG < GPT && GPT < Z) 6175 if (BEG < GPT && GPT < Z)
6163 move_gap (BEG); 6176 move_gap (BEG);
6164 bcopy (BEG_ADDR, *str, coding->produced); 6177 bcopy (BEG_ADDR, *str, coding->produced);
6165 coding->src_multibyte 6178 coding->src_multibyte
6166 = ! NILP (current_buffer->enable_multibyte_characters); 6179 = ! NILP (current_buffer->enable_multibyte_characters);
6180 if (prev != current_buffer)
6181 Fkill_buffer (Fcurrent_buffer ());
6167 set_buffer_internal (cur); 6182 set_buffer_internal (cur);
6168 if (! NILP (buffer_to_kill)) 6183 if (! NILP (buffer_to_kill))
6169 Fkill_buffer (buffer_to_kill); 6184 Fkill_buffer (buffer_to_kill);
6170 } 6185 }
6171 6186