diff options
| author | Miles Bader | 2004-12-08 05:02:30 +0000 |
|---|---|---|
| committer | Miles Bader | 2004-12-08 05:02:30 +0000 |
| commit | 000fc2b1fad05ccd9e6cdb5810febb091f4b5738 (patch) | |
| tree | 808f1473847c7c44bc8b28d8edfa086ec25035d1 /src/coding.c | |
| parent | 5bc63b073c3c75dbfab1f14423f01cc615e26eeb (diff) | |
| parent | ad136a7c3b310fa7240dd2adf62f23b454782bd0 (diff) | |
| download | emacs-000fc2b1fad05ccd9e6cdb5810febb091f4b5738.tar.gz emacs-000fc2b1fad05ccd9e6cdb5810febb091f4b5738.zip | |
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
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/src/coding.c b/src/coding.c index 8ca1d19c4c3..de65884254f 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -6578,6 +6578,37 @@ code_conversion_restore (arg) | |||
| 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; |
| @@ -6995,6 +7026,64 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte, | |||
| 6995 | } | 7026 | } |
| 6996 | 7027 | ||
| 6997 | 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); | ||
| 7084 | } | ||
| 7085 | |||
| 7086 | |||
| 6998 | Lisp_Object | 7087 | Lisp_Object |
| 6999 | preferred_coding_system () | 7088 | preferred_coding_system () |
| 7000 | { | 7089 | { |