Mercurial > emacs
comparison src/coding.c @ 32445:05513a882886
(decode_coding_string): Set coding->src_multibyte and
coding->dst_multibyte before using CODING_REQUIRE_DECODING.
(encode_coding_string): Set coding->src_multibyte and
coding->dst_multibyte before using CODING_REQUIRE_ENCODING.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 13 Oct 2000 08:21:20 +0000 |
parents | 57fa108c491f |
children | 70dcd0333504 |
comparison
equal
deleted
inserted
replaced
32444:dd1d1067760b | 32445:05513a882886 |
---|---|
5273 encounter an inconsitent eol format while decoding. */ | 5273 encounter an inconsitent eol format while decoding. */ |
5274 coding->mode |= CODING_MODE_INHIBIT_INCONSISTENT_EOL; | 5274 coding->mode |= CODING_MODE_INHIBIT_INCONSISTENT_EOL; |
5275 } | 5275 } |
5276 } | 5276 } |
5277 | 5277 |
5278 coding->src_multibyte = 0; | |
5279 coding->dst_multibyte = (coding->type != coding_type_no_conversion | |
5280 && coding->type != coding_type_raw_text); | |
5278 require_decoding = CODING_REQUIRE_DECODING (coding); | 5281 require_decoding = CODING_REQUIRE_DECODING (coding); |
5279 | 5282 |
5280 if (STRING_MULTIBYTE (str)) | 5283 if (STRING_MULTIBYTE (str)) |
5281 { | 5284 { |
5282 /* Decoding routines expect the source text to be unibyte. */ | 5285 /* Decoding routines expect the source text to be unibyte. */ |
5283 str = Fstring_as_unibyte (str); | 5286 str = Fstring_as_unibyte (str); |
5284 to_byte = STRING_BYTES (XSTRING (str)); | 5287 to_byte = STRING_BYTES (XSTRING (str)); |
5285 nocopy = 1; | 5288 nocopy = 1; |
5286 } | 5289 } |
5287 coding->src_multibyte = 0; | |
5288 coding->dst_multibyte = (coding->type != coding_type_no_conversion | |
5289 && coding->type != coding_type_raw_text); | |
5290 | 5290 |
5291 /* Try to skip the heading and tailing ASCIIs. */ | 5291 /* Try to skip the heading and tailing ASCIIs. */ |
5292 if (require_decoding && coding->type != coding_type_ccl) | 5292 if (require_decoding && coding->type != coding_type_ccl) |
5293 { | 5293 { |
5294 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, | 5294 SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, |
5418 from = 0; | 5418 from = 0; |
5419 to = XSTRING (str)->size; | 5419 to = XSTRING (str)->size; |
5420 to_byte = STRING_BYTES (XSTRING (str)); | 5420 to_byte = STRING_BYTES (XSTRING (str)); |
5421 | 5421 |
5422 saved_coding_symbol = Qnil; | 5422 saved_coding_symbol = Qnil; |
5423 if (! CODING_REQUIRE_ENCODING (coding)) | |
5424 { | |
5425 coding->consumed = STRING_BYTES (XSTRING (str)); | |
5426 coding->consumed_char = XSTRING (str)->size; | |
5427 if (STRING_MULTIBYTE (str)) | |
5428 { | |
5429 str = Fstring_as_unibyte (str); | |
5430 nocopy = 1; | |
5431 } | |
5432 coding->produced = STRING_BYTES (XSTRING (str)); | |
5433 coding->produced_char = XSTRING (str)->size; | |
5434 return (nocopy ? str : Fcopy_sequence (str)); | |
5435 } | |
5436 | 5423 |
5437 /* Encoding routines determine the multibyteness of the source text | 5424 /* Encoding routines determine the multibyteness of the source text |
5438 by coding->src_multibyte. */ | 5425 by coding->src_multibyte. */ |
5439 coding->src_multibyte = STRING_MULTIBYTE (str); | 5426 coding->src_multibyte = STRING_MULTIBYTE (str); |
5440 coding->dst_multibyte = 0; | 5427 coding->dst_multibyte = 0; |
5428 if (! CODING_REQUIRE_ENCODING (coding)) | |
5429 { | |
5430 coding->consumed = STRING_BYTES (XSTRING (str)); | |
5431 coding->consumed_char = XSTRING (str)->size; | |
5432 if (STRING_MULTIBYTE (str)) | |
5433 { | |
5434 str = Fstring_as_unibyte (str); | |
5435 nocopy = 1; | |
5436 } | |
5437 coding->produced = STRING_BYTES (XSTRING (str)); | |
5438 coding->produced_char = XSTRING (str)->size; | |
5439 return (nocopy ? str : Fcopy_sequence (str)); | |
5440 } | |
5441 | 5441 |
5442 if (coding->composing != COMPOSITION_DISABLED) | 5442 if (coding->composing != COMPOSITION_DISABLED) |
5443 coding_save_composition (coding, from, to, str); | 5443 coding_save_composition (coding, from, to, str); |
5444 | 5444 |
5445 /* Try to skip the heading and tailing ASCIIs. */ | 5445 /* Try to skip the heading and tailing ASCIIs. */ |