X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/dedb5504d3464bd50b6c591d36791c5535af68c1..c02d943bc2b0cceeb2b0db7503e74a8232333ea9:/src/coding.c diff --git a/src/coding.c b/src/coding.c index 635031772c..15130b9071 100644 --- a/src/coding.c +++ b/src/coding.c @@ -1,7 +1,7 @@ /* Coding system handler (conversion, detection, etc). Copyright (C) 1995, 1997, 1998 Electrotechnical Laboratory, JAPAN. Licensed to the Free Software Foundation. - Copyright (C) 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. Copyright (C) 2003 National Institute of Advanced Industrial Science and Technology (AIST) Registration Number H13PRO009 @@ -20,8 +20,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs; see the file COPYING. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA. */ +the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +Boston, MA 02110-1301, USA. */ /*** TABLE OF CONTENTS *** @@ -314,9 +314,10 @@ Lisp_Object Qvalid_codes; Lisp_Object QCcategory, QCmnemonic, QCdefalut_char; Lisp_Object QCdecode_translation_table, QCencode_translation_table; Lisp_Object QCpost_read_conversion, QCpre_write_conversion; +Lisp_Object QCascii_compatible_p; extern Lisp_Object Qinsert_file_contents, Qwrite_region; -Lisp_Object Qcall_process, Qcall_process_region, Qprocess_argument; +Lisp_Object Qcall_process, Qcall_process_region; Lisp_Object Qstart_process, Qopen_network_stream; Lisp_Object Qtarget_idx; @@ -706,7 +707,8 @@ static struct coding_system coding_categories[coding_category_max]; c = ((c & 1) << 6) | *src++; \ else \ { \ - c = - string_char (--src, &src, NULL); \ + src--; \ + c = - string_char (src, &src, NULL); \ record_conversion_result \ (coding, CODING_RESULT_INVALID_SRC); \ } \ @@ -724,7 +726,8 @@ static struct coding_system coding_categories[coding_category_max]; c = ((c & 1) << 6) | *src++; \ else \ { \ - c = - string_char (--src, &src, NULL); \ + src--; \ + c = - string_char (src, &src, NULL); \ record_conversion_result \ (coding, CODING_RESULT_INVALID_SRC); \ } \ @@ -918,6 +921,8 @@ record_conversion_result (struct coding_system *coding, case CODING_RESULT_INSUFFICIENT_MEM: Vlast_code_conversion_error = Qinsufficient_memory; break; + default: + Vlast_code_conversion_error = intern ("Unknown error"); } } @@ -5091,7 +5096,7 @@ Lisp_Object coding_charset_list (coding) struct coding_system *coding; { - Lisp_Object attrs, charset_list, coding_type; + Lisp_Object attrs, charset_list; CODING_GET_INFO (coding, attrs, charset_list); if (EQ (CODING_ATTR_TYPE (attrs), Qiso_2022)) @@ -6812,8 +6817,8 @@ decode_coding_object (coding, src_object, from, from_byte, to, to_byte, TEMP_SET_PT_BOTH (coding->dst_pos, coding->dst_pos_byte); GCPRO2 (coding->src_object, coding->dst_object); - val = call1 (CODING_ATTR_POST_READ (attrs), - make_number (coding->produced_char)); + val = safe_call1 (CODING_ATTR_POST_READ (attrs), + make_number (coding->produced_char)); UNGCPRO; CHECK_NATNUM (val); coding->produced_char += Z - prev_Z; @@ -6882,6 +6887,7 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte, Lisp_Object attrs; Lisp_Object buffer; int saved_pt = -1, saved_pt_byte; + int kill_src_buffer = 0; buffer = Fcurrent_buffer (); @@ -6911,8 +6917,16 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte, set_buffer_internal (XBUFFER (coding->src_object)); } - call2 (CODING_ATTR_PRE_WRITE (attrs), - make_number (BEG), make_number (Z)); + { + Lisp_Object args[3]; + + args[0] = CODING_ATTR_PRE_WRITE (attrs); + args[1] = make_number (BEG); + args[2] = make_number (Z); + safe_call (3, args); + } + if (XBUFFER (coding->src_object) != current_buffer) + kill_src_buffer = 1; coding->src_object = Fcurrent_buffer (); if (BEG != GPT) move_gap_both (BEG, BEG_BYTE); @@ -7015,6 +7029,8 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte, saved_pt_byte + (coding->produced - bytes)); } + if (kill_src_buffer) + Fkill_buffer (coding->src_object); unbind_to (count, Qnil); } @@ -8865,6 +8881,10 @@ usage: (define-coding-system-internal ...) */) CODING_ATTR_PLIST (attrs) = Fcons (QCcategory, Fcons (AREF (Vcoding_category_table, category), CODING_ATTR_PLIST (attrs))); + CODING_ATTR_PLIST (attrs) + = Fcons (QCascii_compatible_p, + Fcons (CODING_ATTR_ASCII_COMPAT (attrs), + CODING_ATTR_PLIST (attrs))); eol_type = args[coding_arg_eol_type]; if (! NILP (eol_type) @@ -8966,6 +8986,10 @@ DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put, CHECK_SYMBOL (val); CODING_ATTR_PRE_WRITE (attrs) = val; } + else if (EQ (prop, QCascii_compatible_p)) + { + CODING_ATTR_ASCII_COMPAT (attrs) = val; + } CODING_ATTR_PLIST (attrs) = Fplist_put (CODING_ATTR_PLIST (attrs), prop, val); @@ -9241,6 +9265,7 @@ syms_of_coding () DEFSYM (QCencode_translation_table, ":encode-translation-table"); DEFSYM (QCpost_read_conversion, ":post-read-conversion"); DEFSYM (QCpre_write_conversion, ":pre-write-conversion"); + DEFSYM (QCascii_compatible_p, ":ascii-compatible-p"); Vcoding_category_table = Fmake_vector (make_number (coding_category_max), Qnil); @@ -9349,7 +9374,9 @@ updated by the functions `make-coding-system' and On detecting a coding system, Emacs tries code detection algorithms associated with each coding-category one by one in this order. When one algorithm agrees with a byte sequence of source text, the coding -system bound to the corresponding coding-category is selected. */); +system bound to the corresponding coding-category is selected. + +Don't modify this variable directly, but use `set-coding-priority'. */); { int i; @@ -9627,7 +9654,7 @@ character."); plist[3] = args[coding_arg_mnemonic] = make_number ('-'); plist[5] = args[coding_arg_coding_type] = Qundecided; /* This is already set. - /*plist[7] = args[coding_arg_ascii_compatible_p] = Qt;*/ + plist[7] = args[coding_arg_ascii_compatible_p] = Qt; */ plist[8] = intern (":charset-list"); plist[9] = args[coding_arg_charset_list] = Fcons (Qascii, Qnil); plist[11] = args[coding_arg_for_unibyte] = Qnil;