aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
authorKenichi Handa2002-05-07 04:50:48 +0000
committerKenichi Handa2002-05-07 04:50:48 +0000
commit2c78b7e182a6bf208e0f5b0de2f7be9d1b9a3f22 (patch)
tree0db561a7edd83e3a1658c1b18147020d1aaeda62 /src/coding.c
parente9ce014c7b75a858f3b8412e997dc91516e42e36 (diff)
downloademacs-2c78b7e182a6bf208e0f5b0de2f7be9d1b9a3f22.tar.gz
emacs-2c78b7e182a6bf208e0f5b0de2f7be9d1b9a3f22.zip
(coding_alloc_by_making_gap): Check the case that the
source and destination are the same correctly. (decode_coding_raw_text): Set coding->consumed_char and coding->consumed to 0. (produce_chars): If coding->chars_at_source is nonzero, update coding->consumed_char and coding->consumed before calling alloc_destination. (Fdefine_coding_system_alias): Register ALIAS in Vcoding_system_alist. (syms_of_coding): Define `no-convesion' coding system at the tail.
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c121
1 files changed, 68 insertions, 53 deletions
diff --git a/src/coding.c b/src/coding.c
index bbfa9daaef1..8067df78d6c 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -928,7 +928,6 @@ coding_set_destination (coding)
928 coding->destination = (BUF_BEG_ADDR (XBUFFER (coding->dst_object)) 928 coding->destination = (BUF_BEG_ADDR (XBUFFER (coding->dst_object))
929 + coding->dst_pos_byte - 1); 929 + coding->dst_pos_byte - 1);
930 if (coding->src_pos < 0) 930 if (coding->src_pos < 0)
931 /* The source and destination is in the same buffer. */
932 coding->dst_bytes = (GAP_END_ADDR 931 coding->dst_bytes = (GAP_END_ADDR
933 - (coding->src_bytes - coding->consumed) 932 - (coding->src_bytes - coding->consumed)
934 - coding->destination); 933 - coding->destination);
@@ -958,10 +957,8 @@ coding_alloc_by_making_gap (coding, bytes)
958 struct coding_system *coding; 957 struct coding_system *coding;
959 EMACS_INT bytes; 958 EMACS_INT bytes;
960{ 959{
961 Lisp_Object this_buffer; 960 if (BUFFERP (coding->dst_object)
962 961 && EQ (coding->src_object, coding->dst_object))
963 this_buffer = Fcurrent_buffer ();
964 if (EQ (this_buffer, coding->dst_object))
965 { 962 {
966 EMACS_INT add = coding->src_bytes - coding->consumed; 963 EMACS_INT add = coding->src_bytes - coding->consumed;
967 964
@@ -971,6 +968,9 @@ coding_alloc_by_making_gap (coding, bytes)
971 } 968 }
972 else 969 else
973 { 970 {
971 Lisp_Object this_buffer;
972
973 this_buffer = Fcurrent_buffer ();
974 set_buffer_internal (XBUFFER (coding->dst_object)); 974 set_buffer_internal (XBUFFER (coding->dst_object));
975 make_gap (bytes); 975 make_gap (bytes);
976 set_buffer_internal (XBUFFER (this_buffer)); 976 set_buffer_internal (XBUFFER (this_buffer));
@@ -4130,8 +4130,8 @@ decode_coding_raw_text (coding)
4130 struct coding_system *coding; 4130 struct coding_system *coding;
4131{ 4131{
4132 coding->chars_at_source = 1; 4132 coding->chars_at_source = 1;
4133 coding->consumed_char = coding->src_chars; 4133 coding->consumed_char = 0;
4134 coding->consumed = coding->src_bytes; 4134 coding->consumed = 0;
4135 coding->result = CODING_RESULT_SUCCESS; 4135 coding->result = CODING_RESULT_SUCCESS;
4136} 4136}
4137 4137
@@ -5124,13 +5124,19 @@ produce_chars (coding)
5124 } 5124 }
5125 if (dst == dst_end) 5125 if (dst == dst_end)
5126 { 5126 {
5127 EMACS_INT offset = src - coding->source; 5127 coding->consumed = src - coding->source;
5128 5128
5129 dst = alloc_destination (coding, src_end - src + 1, dst); 5129 if (EQ (coding->src_object, coding->dst_object))
5130 dst_end = coding->destination + coding->dst_bytes; 5130 dst_end = src;
5131 coding_set_source (coding); 5131 if (dst == dst_end)
5132 src = coding->source + offset; 5132 {
5133 src_end = coding->source + coding->src_bytes; 5133 dst = alloc_destination (coding, src_end - src + 1,
5134 dst);
5135 dst_end = coding->destination + coding->dst_bytes;
5136 coding_set_source (coding);
5137 src = coding->source + coding->consumed;
5138 src_end = coding->source + coding->src_bytes;
5139 }
5134 } 5140 }
5135 *dst++ = c; 5141 *dst++ = c;
5136 produced_chars++; 5142 produced_chars++;
@@ -5157,13 +5163,19 @@ produce_chars (coding)
5157 } 5163 }
5158 if (dst >= dst_end - 1) 5164 if (dst >= dst_end - 1)
5159 { 5165 {
5160 EMACS_INT offset = src - coding->source; 5166 coding->consumed = src - coding->source;
5161 5167
5162 dst = alloc_destination (coding, src_end - src + 2, dst); 5168 if (EQ (coding->src_object, coding->dst_object))
5163 dst_end = coding->destination + coding->dst_bytes; 5169 dst_end = src;
5164 coding_set_source (coding); 5170 if (dst >= dst_end - 1)
5165 src = coding->source + offset; 5171 {
5166 src_end = coding->source + coding->src_bytes; 5172 dst = alloc_destination (coding, src_end - src + 2,
5173 dst);
5174 dst_end = coding->destination + coding->dst_bytes;
5175 coding_set_source (coding);
5176 src = coding->source + coding->consumed;
5177 src_end = coding->source + coding->src_bytes;
5178 }
5167 } 5179 }
5168 EMIT_ONE_BYTE (c); 5180 EMIT_ONE_BYTE (c);
5169 } 5181 }
@@ -5204,6 +5216,8 @@ produce_chars (coding)
5204 *dst++ = c; 5216 *dst++ = c;
5205 } 5217 }
5206 } 5218 }
5219 coding->consumed = coding->src_bytes;
5220 coding->consumed_char = coding->src_chars;
5207 } 5221 }
5208 5222
5209 produced = dst - (coding->destination + coding->produced); 5223 produced = dst - (coding->destination + coding->produced);
@@ -7574,6 +7588,7 @@ DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias,
7574 } 7588 }
7575 7589
7576 Fputhash (alias, spec, Vcoding_system_hash_table); 7590 Fputhash (alias, spec, Vcoding_system_hash_table);
7591 Vcoding_system_alist = Fcons (Fcons (alias, Qnil), Vcoding_system_alist);
7577 7592
7578 return Qnil; 7593 return Qnil;
7579} 7594}
@@ -7847,40 +7862,6 @@ syms_of_coding ()
7847 ASET (Vcoding_category_table, coding_category_undecided, 7862 ASET (Vcoding_category_table, coding_category_undecided,
7848 intern ("coding-category-undecided")); 7863 intern ("coding-category-undecided"));
7849 7864
7850 {
7851 Lisp_Object args[coding_arg_max];
7852 Lisp_Object plist[14];
7853 int i;
7854
7855 for (i = 0; i < coding_arg_max; i++)
7856 args[i] = Qnil;
7857
7858 plist[0] = intern (":name");
7859 plist[1] = args[coding_arg_name] = Qno_conversion;
7860 plist[2] = intern (":mnemonic");
7861 plist[3] = args[coding_arg_mnemonic] = make_number ('=');
7862 plist[4] = intern (":coding-type");
7863 plist[5] = args[coding_arg_coding_type] = Qraw_text;
7864 plist[6] = intern (":ascii-compatible-p");
7865 plist[7] = args[coding_arg_ascii_compatible_p] = Qt;
7866 plist[8] = intern (":default-char");
7867 plist[9] = args[coding_arg_default_char] = make_number (0);
7868 plist[10] = intern (":docstring");
7869 plist[11] = build_string ("Do no conversion.\n\
7870\n\
7871When you visit a file with this coding, the file is read into a\n\
7872unibyte buffer as is, thus each byte of a file is treated as a\n\
7873character.");
7874 plist[12] = intern (":eol-type");
7875 plist[13] = args[coding_arg_eol_type] = Qunix;
7876 args[coding_arg_plist] = Flist (14, plist);
7877 Fdefine_coding_system_internal (coding_arg_max, args);
7878 }
7879
7880 setup_coding_system (Qno_conversion, &keyboard_coding);
7881 setup_coding_system (Qno_conversion, &terminal_coding);
7882 setup_coding_system (Qno_conversion, &safe_terminal_coding);
7883
7884 defsubr (&Scoding_system_p); 7865 defsubr (&Scoding_system_p);
7885 defsubr (&Sread_coding_system); 7866 defsubr (&Sread_coding_system);
7886 defsubr (&Sread_non_nil_coding_system); 7867 defsubr (&Sread_non_nil_coding_system);
@@ -8153,6 +8134,40 @@ The other way to read escape sequences in a file without decoding is
8153to explicitly specify some coding system that doesn't use ISO2022's 8134to explicitly specify some coding system that doesn't use ISO2022's
8154escape sequence (e.g `latin-1') on reading by \\[universal-coding-system-argument]. */); 8135escape sequence (e.g `latin-1') on reading by \\[universal-coding-system-argument]. */);
8155 inhibit_iso_escape_detection = 0; 8136 inhibit_iso_escape_detection = 0;
8137
8138 {
8139 Lisp_Object args[coding_arg_max];
8140 Lisp_Object plist[14];
8141 int i;
8142
8143 for (i = 0; i < coding_arg_max; i++)
8144 args[i] = Qnil;
8145
8146 plist[0] = intern (":name");
8147 plist[1] = args[coding_arg_name] = Qno_conversion;
8148 plist[2] = intern (":mnemonic");
8149 plist[3] = args[coding_arg_mnemonic] = make_number ('=');
8150 plist[4] = intern (":coding-type");
8151 plist[5] = args[coding_arg_coding_type] = Qraw_text;
8152 plist[6] = intern (":ascii-compatible-p");
8153 plist[7] = args[coding_arg_ascii_compatible_p] = Qt;
8154 plist[8] = intern (":default-char");
8155 plist[9] = args[coding_arg_default_char] = make_number (0);
8156 plist[10] = intern (":docstring");
8157 plist[11] = build_string ("Do no conversion.\n\
8158\n\
8159When you visit a file with this coding, the file is read into a\n\
8160unibyte buffer as is, thus each byte of a file is treated as a\n\
8161character.");
8162 plist[12] = intern (":eol-type");
8163 plist[13] = args[coding_arg_eol_type] = Qunix;
8164 args[coding_arg_plist] = Flist (14, plist);
8165 Fdefine_coding_system_internal (coding_arg_max, args);
8166 }
8167
8168 setup_coding_system (Qno_conversion, &keyboard_coding);
8169 setup_coding_system (Qno_conversion, &terminal_coding);
8170 setup_coding_system (Qno_conversion, &safe_terminal_coding);
8156} 8171}
8157 8172
8158char * 8173char *