diff options
| author | Kenichi Handa | 1998-10-21 11:50:56 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-10-21 11:50:56 +0000 |
| commit | e133c8fabc3f9acb5ed02cd5466842eeb345768d (patch) | |
| tree | 3e63e91e855eef0803c23598773655924d8deb53 /src/coding.c | |
| parent | 17f2692a45d33097875f51092a59157ece4d6a10 (diff) | |
| download | emacs-e133c8fabc3f9acb5ed02cd5466842eeb345768d.tar.gz emacs-e133c8fabc3f9acb5ed02cd5466842eeb345768d.zip | |
(setup_coding_system): Fix setting up
coding->spec.ccl.valid_codes for CCL based coding system.
(code_convert_region): Set point to FROM before inserting the
result of pre-write-funciton. Preserve original point.
(code_convert_string): If coding->type is coding_type_ccl, do
conversion even if the length of conversion region is zero.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/src/coding.c b/src/coding.c index c9bb4f92344..cb6da188de5 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -3138,7 +3138,7 @@ setup_coding_system (coding_system, coding) | |||
| 3138 | int end = XINT (XCONS (this)->cdr); | 3138 | int end = XINT (XCONS (this)->cdr); |
| 3139 | 3139 | ||
| 3140 | if (start >= 0 && start <= end && end < 256) | 3140 | if (start >= 0 && start <= end && end < 256) |
| 3141 | while (start < end) | 3141 | while (start <= end) |
| 3142 | coding->spec.ccl.valid_codes[start++] = 1; | 3142 | coding->spec.ccl.valid_codes[start++] = 1; |
| 3143 | } | 3143 | } |
| 3144 | } | 3144 | } |
| @@ -4169,12 +4169,16 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace) | |||
| 4169 | int fake_multibyte = 0; | 4169 | int fake_multibyte = 0; |
| 4170 | unsigned char *src, *dst; | 4170 | unsigned char *src, *dst; |
| 4171 | Lisp_Object deletion; | 4171 | Lisp_Object deletion; |
| 4172 | int orig_point = PT, orig_len = len; | ||
| 4172 | 4173 | ||
| 4173 | deletion = Qnil; | 4174 | deletion = Qnil; |
| 4174 | saved_coding_symbol = Qnil; | 4175 | saved_coding_symbol = Qnil; |
| 4175 | 4176 | ||
| 4176 | if (from < PT && PT < to) | 4177 | if (from < PT && PT < to) |
| 4177 | SET_PT_BOTH (from, from_byte); | 4178 | { |
| 4179 | TEMP_SET_PT_BOTH (from, from_byte); | ||
| 4180 | orig_point = from; | ||
| 4181 | } | ||
| 4178 | 4182 | ||
| 4179 | if (replace) | 4183 | if (replace) |
| 4180 | { | 4184 | { |
| @@ -4269,10 +4273,18 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace) | |||
| 4269 | new = current_buffer; | 4273 | new = current_buffer; |
| 4270 | set_buffer_internal_1 (prev); | 4274 | set_buffer_internal_1 (prev); |
| 4271 | del_range_2 (from, from_byte, to, to_byte); | 4275 | del_range_2 (from, from_byte, to, to_byte); |
| 4272 | insert_from_buffer (new, BEG, len, 0); | 4276 | TEMP_SET_PT_BOTH (from, from_byte); |
| 4277 | insert_from_buffer (new, 1, len, 0); | ||
| 4278 | if (orig_point >= to) | ||
| 4279 | orig_point += len - orig_len; | ||
| 4280 | else if (orig_point > from) | ||
| 4281 | orig_point = from; | ||
| 4282 | orig_len = len; | ||
| 4273 | to = from + len; | 4283 | to = from + len; |
| 4284 | from_byte = multibyte ? CHAR_TO_BYTE (from) : from_byte; | ||
| 4274 | to_byte = multibyte ? CHAR_TO_BYTE (to) : to; | 4285 | to_byte = multibyte ? CHAR_TO_BYTE (to) : to; |
| 4275 | len_byte = to_byte - from_byte; | 4286 | len_byte = to_byte - from_byte; |
| 4287 | TEMP_SET_PT_BOTH (from, from_byte); | ||
| 4276 | } | 4288 | } |
| 4277 | } | 4289 | } |
| 4278 | 4290 | ||
| @@ -4516,18 +4528,24 @@ code_convert_region (from, from_byte, to, to_byte, coding, encodep, replace) | |||
| 4516 | if (! encodep && ! NILP (coding->post_read_conversion)) | 4528 | if (! encodep && ! NILP (coding->post_read_conversion)) |
| 4517 | { | 4529 | { |
| 4518 | Lisp_Object val; | 4530 | Lisp_Object val; |
| 4519 | int orig_inserted = inserted, pos = PT; | ||
| 4520 | 4531 | ||
| 4521 | if (from != pos) | 4532 | if (from != PT) |
| 4522 | temp_set_point_both (current_buffer, from, from_byte); | 4533 | TEMP_SET_PT_BOTH (from, from_byte); |
| 4523 | val = call1 (coding->post_read_conversion, make_number (inserted)); | 4534 | val = call1 (coding->post_read_conversion, make_number (inserted)); |
| 4524 | if (! NILP (val)) | 4535 | if (! NILP (val)) |
| 4525 | { | 4536 | { |
| 4526 | CHECK_NUMBER (val, 0); | 4537 | CHECK_NUMBER (val, 0); |
| 4527 | inserted = XFASTINT (val); | 4538 | inserted = XFASTINT (val); |
| 4528 | } | 4539 | } |
| 4529 | if (pos >= from + orig_inserted) | 4540 | } |
| 4530 | temp_set_point (current_buffer, pos + (inserted - orig_inserted)); | 4541 | |
| 4542 | if (orig_point >= from) | ||
| 4543 | { | ||
| 4544 | if (orig_point >= from + orig_len) | ||
| 4545 | orig_point += inserted - orig_len; | ||
| 4546 | else | ||
| 4547 | orig_point = from; | ||
| 4548 | TEMP_SET_PT (orig_point); | ||
| 4531 | } | 4549 | } |
| 4532 | 4550 | ||
| 4533 | signal_after_change (from, to - from, inserted); | 4551 | signal_after_change (from, to - from, inserted); |
| @@ -4565,7 +4583,7 @@ code_convert_string (str, coding, encodep, nocopy) | |||
| 4565 | code_convert_region. */ | 4583 | code_convert_region. */ |
| 4566 | int count = specpdl_ptr - specpdl; | 4584 | int count = specpdl_ptr - specpdl; |
| 4567 | struct buffer *prev = current_buffer; | 4585 | struct buffer *prev = current_buffer; |
| 4568 | 4586 | ||
| 4569 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 4587 | record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
| 4570 | temp_output_buffer_setup (" *code-converting-work*"); | 4588 | temp_output_buffer_setup (" *code-converting-work*"); |
| 4571 | set_buffer_internal (XBUFFER (Vstandard_output)); | 4589 | set_buffer_internal (XBUFFER (Vstandard_output)); |
| @@ -4619,7 +4637,8 @@ code_convert_string (str, coding, encodep, nocopy) | |||
| 4619 | SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, | 4637 | SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data, |
| 4620 | encodep); | 4638 | encodep); |
| 4621 | } | 4639 | } |
| 4622 | if (from == to_byte) | 4640 | if (from == to_byte |
| 4641 | && coding->type != coding_type_ccl) | ||
| 4623 | return (nocopy ? str : Fcopy_sequence (str)); | 4642 | return (nocopy ? str : Fcopy_sequence (str)); |
| 4624 | 4643 | ||
| 4625 | if (encodep) | 4644 | if (encodep) |