Mercurial > emacs
comparison src/coding.c @ 23881:20d595402dea
(DECODE_DESIGNATION): Jump to label_invalid_code if
final_char is invalid.
(decode_coding): If coding->type is coding_type_ccl, call
ccl_coding_driver even if SRC_BYTES is zero.
(code_convert_region): Update `inserted' correctly after calling
coding->post_read_conversion. Even after the code converter
consumed all source text, call it once more if it is
coding_type_ccl to flush out data.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 15 Dec 1998 04:35:38 +0000 |
parents | 6eb3e346d1fd |
children | d20160af7b6e |
comparison
equal
deleted
inserted
replaced
23880:522ac99a666d | 23881:20d595402dea |
---|---|
935 } while (0) | 935 } while (0) |
936 | 936 |
937 /* Set designation state into CODING. */ | 937 /* Set designation state into CODING. */ |
938 #define DECODE_DESIGNATION(reg, dimension, chars, final_char) \ | 938 #define DECODE_DESIGNATION(reg, dimension, chars, final_char) \ |
939 do { \ | 939 do { \ |
940 int charset = ISO_CHARSET_TABLE (make_number (dimension), \ | 940 int charset; \ |
941 make_number (chars), \ | 941 \ |
942 make_number (final_char)); \ | 942 if (final_char < '0' || final_char >= 128) \ |
943 goto label_invalid_code; \ | |
944 charset = ISO_CHARSET_TABLE (make_number (dimension), \ | |
945 make_number (chars), \ | |
946 make_number (final_char)); \ | |
943 if (charset >= 0 \ | 947 if (charset >= 0 \ |
944 && (CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) == reg \ | 948 && (CODING_SPEC_ISO_REQUESTED_DESIGNATION (coding, charset) == reg \ |
945 || coding->safe_charsets[charset])) \ | 949 || coding->safe_charsets[charset])) \ |
946 { \ | 950 { \ |
947 if (coding->spec.iso2022.last_invalid_designation_register == 0 \ | 951 if (coding->spec.iso2022.last_invalid_designation_register == 0 \ |
3692 int src_bytes, dst_bytes; | 3696 int src_bytes, dst_bytes; |
3693 { | 3697 { |
3694 int result; | 3698 int result; |
3695 | 3699 |
3696 if (src_bytes <= 0 | 3700 if (src_bytes <= 0 |
3701 && coding->type != coding_type_ccl | |
3697 && ! (coding->mode & CODING_MODE_LAST_BLOCK | 3702 && ! (coding->mode & CODING_MODE_LAST_BLOCK |
3698 && CODING_REQUIRE_FLUSHING (coding))) | 3703 && CODING_REQUIRE_FLUSHING (coding))) |
3699 { | 3704 { |
3700 coding->produced = coding->produced_char = 0; | 3705 coding->produced = coding->produced_char = 0; |
3701 coding->consumed = coding->consumed_char = 0; | 3706 coding->consumed = coding->consumed_char = 0; |
4308 | 4313 |
4309 if (from < GPT && GPT < to) | 4314 if (from < GPT && GPT < to) |
4310 move_gap_both (from, from_byte); | 4315 move_gap_both (from, from_byte); |
4311 SHRINK_CONVERSION_REGION (&from_byte, &to_byte, coding, NULL, encodep); | 4316 SHRINK_CONVERSION_REGION (&from_byte, &to_byte, coding, NULL, encodep); |
4312 if (from_byte == to_byte | 4317 if (from_byte == to_byte |
4318 && coding->type != coding_type_ccl | |
4313 && ! (coding->mode & CODING_MODE_LAST_BLOCK | 4319 && ! (coding->mode & CODING_MODE_LAST_BLOCK |
4314 && CODING_REQUIRE_FLUSHING (coding))) | 4320 && CODING_REQUIRE_FLUSHING (coding))) |
4315 { | 4321 { |
4316 coding->produced = len_byte; | 4322 coding->produced = len_byte; |
4317 coding->produced_char = multibyte ? len : len_byte; | 4323 coding->produced_char = multibyte ? len : len_byte; |
4450 coding->symbol = saved_coding_symbol; | 4456 coding->symbol = saved_coding_symbol; |
4451 | 4457 |
4452 continue; | 4458 continue; |
4453 } | 4459 } |
4454 if (len_byte <= 0) | 4460 if (len_byte <= 0) |
4455 break; | 4461 { |
4462 if (coding->type != coding_type_ccl | |
4463 || coding->mode & CODING_MODE_LAST_BLOCK) | |
4464 break; | |
4465 coding->mode |= CODING_MODE_LAST_BLOCK; | |
4466 continue; | |
4467 } | |
4456 if (result == CODING_FINISH_INSUFFICIENT_SRC) | 4468 if (result == CODING_FINISH_INSUFFICIENT_SRC) |
4457 { | 4469 { |
4458 /* The source text ends in invalid codes. Let's just | 4470 /* The source text ends in invalid codes. Let's just |
4459 make them valid buffer contents, and finish conversion. */ | 4471 make them valid buffer contents, and finish conversion. */ |
4460 inserted += len_byte; | 4472 inserted += len_byte; |
4545 if (from != PT) | 4557 if (from != PT) |
4546 TEMP_SET_PT_BOTH (from, from_byte); | 4558 TEMP_SET_PT_BOTH (from, from_byte); |
4547 prev_Z = Z; | 4559 prev_Z = Z; |
4548 val = call1 (coding->post_read_conversion, make_number (inserted)); | 4560 val = call1 (coding->post_read_conversion, make_number (inserted)); |
4549 CHECK_NUMBER (val, 0); | 4561 CHECK_NUMBER (val, 0); |
4550 inserted = Z - prev_Z; | 4562 inserted += Z - prev_Z; |
4551 } | 4563 } |
4552 | 4564 |
4553 if (orig_point >= from) | 4565 if (orig_point >= from) |
4554 { | 4566 { |
4555 if (orig_point >= from + orig_len) | 4567 if (orig_point >= from + orig_len) |