comparison src/coding.c @ 90054:f2ebccfa87d4

Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-74 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-709 Update from CVS: src/indent.c (Fvertical_motion): Fix last change. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-710 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-715 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-716 Merge from gnus--rel--5.10 * miles@gnu.org--gnu-2004/gnus--rel--5.10--patch-74 Update from CVS
author Miles Bader <miles@gnu.org>
date Wed, 08 Dec 2004 05:02:30 +0000
parents ade0c9a12f99 ff8a37b5299b
children 48210be97b12
comparison
equal deleted inserted replaced
90053:fff5f1a61d92 90054:f2ebccfa87d4
6576 } 6576 }
6577 set_buffer_internal (XBUFFER (current)); 6577 set_buffer_internal (XBUFFER (current));
6578 return Qnil; 6578 return Qnil;
6579 } 6579 }
6580 6580
6581 /* Name (or base name) of work buffer for code conversion. */
6582 static Lisp_Object Vcode_conversion_workbuf_name;
6583
6584 /* Set the current buffer to the working buffer prepared for
6585 code-conversion. MULTIBYTE specifies the multibyteness of the
6586 buffer. */
6587
6588 static struct buffer *
6589 set_conversion_work_buffer (multibyte)
6590 int multibyte;
6591 {
6592 Lisp_Object buffer;
6593 struct buffer *buf;
6594
6595 buffer = Fget_buffer_create (Vcode_conversion_workbuf_name);
6596 buf = XBUFFER (buffer);
6597 delete_all_overlays (buf);
6598 buf->directory = current_buffer->directory;
6599 buf->read_only = Qnil;
6600 buf->filename = Qnil;
6601 buf->undo_list = Qt;
6602 eassert (buf->overlays_before == NULL);
6603 eassert (buf->overlays_after == NULL);
6604 set_buffer_internal (buf);
6605 if (BEG != BEGV || Z != ZV)
6606 Fwiden ();
6607 del_range_2 (BEG, BEG_BYTE, Z, Z_BYTE, 0);
6608 buf->enable_multibyte_characters = multibyte ? Qt : Qnil;
6609 return buf;
6610 }
6611
6581 Lisp_Object 6612 Lisp_Object
6582 code_conversion_save (with_work_buf, multibyte) 6613 code_conversion_save (with_work_buf, multibyte)
6583 int with_work_buf, multibyte; 6614 int with_work_buf, multibyte;
6584 { 6615 {
6585 Lisp_Object workbuf = Qnil; 6616 Lisp_Object workbuf = Qnil;
6990 TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes), 7021 TEMP_SET_PT_BOTH (saved_pt + (coding->produced - bytes),
6991 saved_pt_byte + (coding->produced - bytes)); 7022 saved_pt_byte + (coding->produced - bytes));
6992 } 7023 }
6993 7024
6994 unbind_to (count, Qnil); 7025 unbind_to (count, Qnil);
7026 }
7027
7028
7029
7030 /* Run pre-write-conversion function of CODING on NCHARS/NBYTES
7031 text in *STR. *SIZE is the allocated bytes for STR. As it
7032 is intended that this function is called from encode_terminal_code,
7033 the pre-write-conversion function is run by safe_call and thus
7034 "Error during redisplay: ..." is logged when an error occurs.
7035
7036 Store the resulting text in *STR and set CODING->produced_char and
7037 CODING->produced to the number of characters and bytes
7038 respectively. If the size of *STR is too small, enlarge it by
7039 xrealloc and update *STR and *SIZE. */
7040
7041 void
7042 run_pre_write_conversin_on_c_str (str, size, nchars, nbytes, coding)
7043 unsigned char **str;
7044 int *size, nchars, nbytes;
7045 struct coding_system *coding;
7046 {
7047 struct gcpro gcpro1, gcpro2;
7048 struct buffer *cur = current_buffer;
7049 Lisp_Object old_deactivate_mark, old_last_coding_system_used;
7050 Lisp_Object args[3];
7051
7052 /* It is not crucial to specbind this. */
7053 old_deactivate_mark = Vdeactivate_mark;
7054 old_last_coding_system_used = Vlast_coding_system_used;
7055 GCPRO2 (old_deactivate_mark, old_last_coding_system_used);
7056
7057 /* We must insert the contents of STR as is without
7058 unibyte<->multibyte conversion. For that, we adjust the
7059 multibyteness of the working buffer to that of STR. */
7060 set_conversion_work_buffer (coding->src_multibyte);
7061 insert_1_both (*str, nchars, nbytes, 0, 0, 0);
7062 UNGCPRO;
7063 inhibit_pre_post_conversion = 1;
7064 args[0] = coding->pre_write_conversion;
7065 args[1] = make_number (BEG);
7066 args[2] = make_number (Z);
7067 safe_call (3, args);
7068 inhibit_pre_post_conversion = 0;
7069 Vdeactivate_mark = old_deactivate_mark;
7070 Vlast_coding_system_used = old_last_coding_system_used;
7071 coding->produced_char = Z - BEG;
7072 coding->produced = Z_BYTE - BEG_BYTE;
7073 if (coding->produced > *size)
7074 {
7075 *size = coding->produced;
7076 *str = xrealloc (*str, *size);
7077 }
7078 if (BEG < GPT && GPT < Z)
7079 move_gap (BEG);
7080 bcopy (BEG_ADDR, *str, coding->produced);
7081 coding->src_multibyte
7082 = ! NILP (current_buffer->enable_multibyte_characters);
7083 set_buffer_internal (cur);
6995 } 7084 }
6996 7085
6997 7086
6998 Lisp_Object 7087 Lisp_Object
6999 preferred_coding_system () 7088 preferred_coding_system ()