diff options
| author | Kenichi Handa | 2000-08-04 05:53:01 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2000-08-04 05:53:01 +0000 |
| commit | 78108bcdccd7e7d265b25ac8b5cd37068208aea5 (patch) | |
| tree | 96fd71fcd7b209b9355e57a8f0e24a7df742dc88 /src/coding.c | |
| parent | ed7a4b2d60dc9806112af7a1a69e8b81bed5a8c2 (diff) | |
| download | emacs-78108bcdccd7e7d265b25ac8b5cd37068208aea5.tar.gz emacs-78108bcdccd7e7d265b25ac8b5cd37068208aea5.zip | |
(coding_restore_composition): Pay attention to the case that
cmp_data is not set properly (because of invalid code in the
source text).
(run_pre_post_conversion_on_str): Include text properties in the
resulting string.
(decode_coding_string): Set members of coding correctly.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/src/coding.c b/src/coding.c index 6c251a583dd..6b8f9297dc0 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -4660,7 +4660,8 @@ coding_restore_composition (coding, obj) | |||
| 4660 | { | 4660 | { |
| 4661 | int i; | 4661 | int i; |
| 4662 | 4662 | ||
| 4663 | for (i = 0; i < cmp_data->used; i += cmp_data->data[i]) | 4663 | for (i = 0; i < cmp_data->used && cmp_data->data[i] > 0; |
| 4664 | i += cmp_data->data[i]) | ||
| 4664 | { | 4665 | { |
| 4665 | int *data = cmp_data->data + i; | 4666 | int *data = cmp_data->data + i; |
| 4666 | enum composition_method method = (enum composition_method) data[3]; | 4667 | enum composition_method method = (enum composition_method) data[3]; |
| @@ -5184,7 +5185,7 @@ run_pre_post_conversion_on_str (str, coding, encodep) | |||
| 5184 | call1 (coding->post_read_conversion, make_number (Z - BEG)); | 5185 | call1 (coding->post_read_conversion, make_number (Z - BEG)); |
| 5185 | } | 5186 | } |
| 5186 | inhibit_pre_post_conversion = 0; | 5187 | inhibit_pre_post_conversion = 0; |
| 5187 | str = make_buffer_string (BEG, Z, 0); | 5188 | str = make_buffer_string (BEG, Z, 1); |
| 5188 | return unbind_to (count, str); | 5189 | return unbind_to (count, str); |
| 5189 | } | 5190 | } |
| 5190 | 5191 | ||
| @@ -5200,6 +5201,7 @@ decode_coding_string (str, coding, nocopy) | |||
| 5200 | struct gcpro gcpro1; | 5201 | struct gcpro gcpro1; |
| 5201 | Lisp_Object saved_coding_symbol; | 5202 | Lisp_Object saved_coding_symbol; |
| 5202 | int result; | 5203 | int result; |
| 5204 | int require_decoding; | ||
| 5203 | 5205 | ||
| 5204 | from = 0; | 5206 | from = 0; |
| 5205 | to = XSTRING (str)->size; | 5207 | to = XSTRING (str)->size; |
| @@ -5228,15 +5230,7 @@ decode_coding_string (str, coding, nocopy) | |||
| 5228 | } | 5230 | } |
| 5229 | } | 5231 | } |
| 5230 | 5232 | ||
| 5231 | if (! CODING_REQUIRE_DECODING (coding)) | 5233 | require_decoding = CODING_REQUIRE_DECODING (coding); |
| 5232 | { | ||
| 5233 | if (!STRING_MULTIBYTE (str)) | ||
| 5234 | { | ||
| 5235 | str = Fstring_as_multibyte (str); | ||
| 5236 | nocopy = 1; | ||
| 5237 | } | ||
| 5238 | return (nocopy ? str : Fcopy_sequence (str)); | ||
| 5239 | } | ||
| 5240 | 5234 | ||
| 5241 | if (STRING_MULTIBYTE (str)) | 5235 | if (STRING_MULTIBYTE (str)) |
| 5242 | { | 5236 | { |
| @@ -5244,24 +5238,39 @@ decode_coding_string (str, coding, nocopy) | |||
| 5244 | str = Fstring_as_unibyte (str); | 5238 | str = Fstring_as_unibyte (str); |
| 5245 | to_byte = STRING_BYTES (XSTRING (str)); | 5239 | to_byte = STRING_BYTES (XSTRING (str)); |
| 5246 | nocopy = 1; | 5240 | nocopy = 1; |
| 5247 | coding->src_multibyte = 0; | ||
| 5248 | } | 5241 | } |
| 5249 | coding->dst_multibyte = 1; | 5242 | coding->src_multibyte = 0; |
| 5250 | 5243 | coding->dst_multibyte = (coding->type != coding_type_no_conversion | |
| 5251 | if (coding->composing != COMPOSITION_DISABLED) | 5244 | && coding->type != coding_type_raw_text); |
| 5252 | coding_allocate_composition_data (coding, from); | ||
| 5253 | 5245 | ||
| 5254 | /* Try to skip the heading and tailing ASCIIs. */ | 5246 | /* Try to skip the heading and tailing ASCIIs. */ |
| 5255 | if (coding->type != coding_type_ccl) | 5247 | if (require_decoding && coding->type != coding_type_ccl) |
| 5256 | { | 5248 | { |
| 5257 | int from_orig = from; | 5249 | int from_orig = from; |
| 5258 | 5250 | ||
| 5259 | SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, | 5251 | SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, |
| 5260 | 0); | 5252 | 0); |
| 5261 | if (from == to_byte) | 5253 | if (from == to_byte) |
| 5262 | return (nocopy ? str : Fcopy_sequence (str)); | 5254 | require_decoding = 0; |
| 5263 | } | 5255 | } |
| 5264 | 5256 | ||
| 5257 | if (!require_decoding) | ||
| 5258 | { | ||
| 5259 | coding->consumed = STRING_BYTES (XSTRING (str)); | ||
| 5260 | coding->consumed_char = XSTRING (str)->size; | ||
| 5261 | if (coding->dst_multibyte) | ||
| 5262 | { | ||
| 5263 | str = Fstring_as_multibyte (str); | ||
| 5264 | nocopy = 1; | ||
| 5265 | } | ||
| 5266 | coding->produced = STRING_BYTES (XSTRING (str)); | ||
| 5267 | coding->produced_char = XSTRING (str)->size; | ||
| 5268 | return (nocopy ? str : Fcopy_sequence (str)); | ||
| 5269 | } | ||
| 5270 | |||
| 5271 | if (coding->composing != COMPOSITION_DISABLED) | ||
| 5272 | coding_allocate_composition_data (coding, from); | ||
| 5273 | |||
| 5265 | len = decoding_buffer_size (coding, to_byte - from); | 5274 | len = decoding_buffer_size (coding, to_byte - from); |
| 5266 | len += from + STRING_BYTES (XSTRING (str)) - to_byte; | 5275 | len += from + STRING_BYTES (XSTRING (str)) - to_byte; |
| 5267 | GCPRO1 (str); | 5276 | GCPRO1 (str); |
| @@ -5286,8 +5295,11 @@ decode_coding_string (str, coding, nocopy) | |||
| 5286 | STRING_BYTES (XSTRING (str)) - to_byte); | 5295 | STRING_BYTES (XSTRING (str)) - to_byte); |
| 5287 | 5296 | ||
| 5288 | len = from + STRING_BYTES (XSTRING (str)) - to_byte; | 5297 | len = from + STRING_BYTES (XSTRING (str)) - to_byte; |
| 5289 | str = make_multibyte_string (buf, len + coding->produced_char, | 5298 | if (coding->dst_multibyte) |
| 5290 | len + coding->produced); | 5299 | str = make_multibyte_string (buf, len + coding->produced_char, |
| 5300 | len + coding->produced); | ||
| 5301 | else | ||
| 5302 | str = make_unibyte_string (buf, len + coding->produced); | ||
| 5291 | 5303 | ||
| 5292 | if (coding->cmp_data && coding->cmp_data->used) | 5304 | if (coding->cmp_data && coding->cmp_data->used) |
| 5293 | coding_restore_composition (coding, str); | 5305 | coding_restore_composition (coding, str); |