Mercurial > emacs
comparison src/coding.c @ 50484:6818550bfbc7
(code_convert_region_unwind): Set
Vlast_coding_system_used to the argument.
(code_convert_region): If post-read-conversion function changed
the value of last-coding-sytem, keep the new value in
coding->symbol so that it won't be overridden.
(run_pre_post_conversion_on_str): Likewise.
| author | Kenichi Handa <handa@m17n.org> |
|---|---|
| date | Tue, 08 Apr 2003 07:26:05 +0000 |
| parents | b64f1af6e142 |
| children | b67e5e5b8fc4 |
comparison
equal
deleted
inserted
replaced
| 50483:15382232cf57 | 50484:6818550bfbc7 |
|---|---|
| 2895 detect_coding_utf_16 (src, src_end, multibytep) | 2895 detect_coding_utf_16 (src, src_end, multibytep) |
| 2896 unsigned char *src, *src_end; | 2896 unsigned char *src, *src_end; |
| 2897 int multibytep; | 2897 int multibytep; |
| 2898 { | 2898 { |
| 2899 unsigned char c1, c2; | 2899 unsigned char c1, c2; |
| 2900 /* Dummy for TWO_MORE_BYTES. */ | 2900 /* Dummy for ONE_MORE_BYTE_CHECK_MULTIBYTE. */ |
| 2901 struct coding_system dummy_coding; | 2901 struct coding_system dummy_coding; |
| 2902 struct coding_system *coding = &dummy_coding; | 2902 struct coding_system *coding = &dummy_coding; |
| 2903 | 2903 |
| 2904 ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep); | 2904 ONE_MORE_BYTE_CHECK_MULTIBYTE (c1, multibytep); |
| 2905 ONE_MORE_BYTE_CHECK_MULTIBYTE (c2, multibytep); | 2905 ONE_MORE_BYTE_CHECK_MULTIBYTE (c2, multibytep); |
| 5198 else shrink_decoding_region (beg, end, coding, str); \ | 5198 else shrink_decoding_region (beg, end, coding, str); \ |
| 5199 } \ | 5199 } \ |
| 5200 } while (0) | 5200 } while (0) |
| 5201 | 5201 |
| 5202 static Lisp_Object | 5202 static Lisp_Object |
| 5203 code_convert_region_unwind (dummy) | 5203 code_convert_region_unwind (arg) |
| 5204 Lisp_Object dummy; | 5204 Lisp_Object arg; |
| 5205 { | 5205 { |
| 5206 inhibit_pre_post_conversion = 0; | 5206 inhibit_pre_post_conversion = 0; |
| 5207 Vlast_coding_system_used = arg; | |
| 5207 return Qnil; | 5208 return Qnil; |
| 5208 } | 5209 } |
| 5209 | 5210 |
| 5210 /* Store information about all compositions in the range FROM and TO | 5211 /* Store information about all compositions in the range FROM and TO |
| 5211 of OBJ in memory blocks pointed by CODING->cmp_data. OBJ is a | 5212 of OBJ in memory blocks pointed by CODING->cmp_data. OBJ is a |
| 5445 /* The function in pre-write-conversion may put a new text in a | 5446 /* The function in pre-write-conversion may put a new text in a |
| 5446 new buffer. */ | 5447 new buffer. */ |
| 5447 struct buffer *prev = current_buffer; | 5448 struct buffer *prev = current_buffer; |
| 5448 Lisp_Object new; | 5449 Lisp_Object new; |
| 5449 | 5450 |
| 5450 record_unwind_protect (code_convert_region_unwind, Qnil); | 5451 record_unwind_protect (code_convert_region_unwind, |
| 5452 Vlatin_extra_code_table); | |
| 5451 /* We should not call any more pre-write/post-read-conversion | 5453 /* We should not call any more pre-write/post-read-conversion |
| 5452 functions while this pre-write-conversion is running. */ | 5454 functions while this pre-write-conversion is running. */ |
| 5453 inhibit_pre_post_conversion = 1; | 5455 inhibit_pre_post_conversion = 1; |
| 5454 call2 (coding->pre_write_conversion, | 5456 call2 (coding->pre_write_conversion, |
| 5455 make_number (from), make_number (to)); | 5457 make_number (from), make_number (to)); |
| 5803 | 5805 |
| 5804 if (! inhibit_pre_post_conversion | 5806 if (! inhibit_pre_post_conversion |
| 5805 && ! encodep && ! NILP (coding->post_read_conversion)) | 5807 && ! encodep && ! NILP (coding->post_read_conversion)) |
| 5806 { | 5808 { |
| 5807 Lisp_Object val; | 5809 Lisp_Object val; |
| 5810 Lisp_Object saved_coding_system; | |
| 5808 | 5811 |
| 5809 if (from != PT) | 5812 if (from != PT) |
| 5810 TEMP_SET_PT_BOTH (from, from_byte); | 5813 TEMP_SET_PT_BOTH (from, from_byte); |
| 5811 prev_Z = Z; | 5814 prev_Z = Z; |
| 5812 record_unwind_protect (code_convert_region_unwind, Qnil); | 5815 record_unwind_protect (code_convert_region_unwind, |
| 5816 Vlast_coding_system_used); | |
| 5817 saved_coding_system = Vlast_coding_system_used; | |
| 5818 Vlast_coding_system_used = coding->symbol; | |
| 5813 /* We should not call any more pre-write/post-read-conversion | 5819 /* We should not call any more pre-write/post-read-conversion |
| 5814 functions while this post-read-conversion is running. */ | 5820 functions while this post-read-conversion is running. */ |
| 5815 inhibit_pre_post_conversion = 1; | 5821 inhibit_pre_post_conversion = 1; |
| 5816 val = call1 (coding->post_read_conversion, make_number (inserted)); | 5822 val = call1 (coding->post_read_conversion, make_number (inserted)); |
| 5817 inhibit_pre_post_conversion = 0; | 5823 inhibit_pre_post_conversion = 0; |
| 5824 coding->symbol = Vlast_coding_system_used; | |
| 5825 Vlast_coding_system_used = saved_coding_system; | |
| 5818 /* Discard the unwind protect. */ | 5826 /* Discard the unwind protect. */ |
| 5819 specpdl_ptr--; | 5827 specpdl_ptr--; |
| 5820 CHECK_NUMBER (val); | 5828 CHECK_NUMBER (val); |
| 5821 inserted += Z - prev_Z; | 5829 inserted += Z - prev_Z; |
| 5822 } | 5830 } |
| 5858 Lisp_Object buffer; | 5866 Lisp_Object buffer; |
| 5859 struct buffer *buf; | 5867 struct buffer *buf; |
| 5860 Lisp_Object old_deactivate_mark; | 5868 Lisp_Object old_deactivate_mark; |
| 5861 | 5869 |
| 5862 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); | 5870 record_unwind_protect (Fset_buffer, Fcurrent_buffer ()); |
| 5863 record_unwind_protect (code_convert_region_unwind, Qnil); | 5871 record_unwind_protect (code_convert_region_unwind, |
| 5872 Vlast_coding_system_used); | |
| 5864 /* It is not crucial to specbind this. */ | 5873 /* It is not crucial to specbind this. */ |
| 5865 old_deactivate_mark = Vdeactivate_mark; | 5874 old_deactivate_mark = Vdeactivate_mark; |
| 5866 GCPRO2 (str, old_deactivate_mark); | 5875 GCPRO2 (str, old_deactivate_mark); |
| 5867 | 5876 |
| 5868 buffer = Fget_buffer_create (build_string (" *code-converting-work*")); | 5877 buffer = Fget_buffer_create (build_string (" *code-converting-work*")); |
| 5888 inhibit_pre_post_conversion = 1; | 5897 inhibit_pre_post_conversion = 1; |
| 5889 if (encodep) | 5898 if (encodep) |
| 5890 call2 (coding->pre_write_conversion, make_number (BEG), make_number (Z)); | 5899 call2 (coding->pre_write_conversion, make_number (BEG), make_number (Z)); |
| 5891 else | 5900 else |
| 5892 { | 5901 { |
| 5902 Vlast_coding_system_used = coding->symbol; | |
| 5893 TEMP_SET_PT_BOTH (BEG, BEG_BYTE); | 5903 TEMP_SET_PT_BOTH (BEG, BEG_BYTE); |
| 5894 call1 (coding->post_read_conversion, make_number (Z - BEG)); | 5904 call1 (coding->post_read_conversion, make_number (Z - BEG)); |
| 5905 coding->symbol = Vlast_coding_system_used; | |
| 5895 } | 5906 } |
| 5896 inhibit_pre_post_conversion = 0; | 5907 inhibit_pre_post_conversion = 0; |
| 5897 Vdeactivate_mark = old_deactivate_mark; | 5908 Vdeactivate_mark = old_deactivate_mark; |
| 5898 str = make_buffer_string (BEG, Z, 1); | 5909 str = make_buffer_string (BEG, Z, 1); |
| 5899 return unbind_to (count, str); | 5910 return unbind_to (count, str); |
