comparison src/coding.c @ 90772:b15334b4a9c3

(coding_alloc_by_making_gap): New arg offset. (alloc_destination): Call coding_alloc_by_making_gap with the arg offset. (decode_coding_iso_2022): Update coding->safe_charsets. (decode_coding_gap): Temporarily set current_buffer->text->inhibit_shrinking to 1.
author Kenichi Handa <handa@m17n.org>
date Fri, 23 Feb 2007 06:02:23 +0000
parents 95d0cdf160ea
children 3c52757d5f6e
comparison
equal deleted inserted replaced
90771:8380fb3b4013 90772:b15334b4a9c3
876 876
877 static void coding_set_source P_ ((struct coding_system *)); 877 static void coding_set_source P_ ((struct coding_system *));
878 static void coding_set_destination P_ ((struct coding_system *)); 878 static void coding_set_destination P_ ((struct coding_system *));
879 static void coding_alloc_by_realloc P_ ((struct coding_system *, EMACS_INT)); 879 static void coding_alloc_by_realloc P_ ((struct coding_system *, EMACS_INT));
880 static void coding_alloc_by_making_gap P_ ((struct coding_system *, 880 static void coding_alloc_by_making_gap P_ ((struct coding_system *,
881 EMACS_INT)); 881 EMACS_INT, EMACS_INT));
882 static unsigned char *alloc_destination P_ ((struct coding_system *, 882 static unsigned char *alloc_destination P_ ((struct coding_system *,
883 EMACS_INT, unsigned char *)); 883 EMACS_INT, unsigned char *));
884 static void setup_iso_safe_charsets P_ ((Lisp_Object)); 884 static void setup_iso_safe_charsets P_ ((Lisp_Object));
885 static unsigned char *encode_designation_at_bol P_ ((struct coding_system *, 885 static unsigned char *encode_designation_at_bol P_ ((struct coding_system *,
886 int *, int *, 886 int *, int *,
1032 coding->dst_bytes + bytes); 1032 coding->dst_bytes + bytes);
1033 coding->dst_bytes += bytes; 1033 coding->dst_bytes += bytes;
1034 } 1034 }
1035 1035
1036 static void 1036 static void
1037 coding_alloc_by_making_gap (coding, bytes) 1037 coding_alloc_by_making_gap (coding, offset, bytes)
1038 struct coding_system *coding; 1038 struct coding_system *coding;
1039 EMACS_INT bytes; 1039 EMACS_INT offset, bytes;
1040 { 1040 {
1041 if (BUFFERP (coding->dst_object) 1041 if (BUFFERP (coding->dst_object)
1042 && EQ (coding->src_object, coding->dst_object)) 1042 && EQ (coding->src_object, coding->dst_object))
1043 { 1043 {
1044 EMACS_INT add = coding->src_bytes - coding->consumed; 1044 EMACS_INT add = offset + (coding->src_bytes - coding->consumed);
1045 1045
1046 GPT += offset, GPT_BYTE += offset;
1046 GAP_SIZE -= add; ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add; 1047 GAP_SIZE -= add; ZV += add; Z += add; ZV_BYTE += add; Z_BYTE += add;
1047 make_gap (bytes); 1048 make_gap (bytes);
1048 GAP_SIZE += add; ZV -= add; Z -= add; ZV_BYTE -= add; Z_BYTE -= add; 1049 GAP_SIZE += add; ZV -= add; Z -= add; ZV_BYTE -= add; Z_BYTE -= add;
1050 GPT -= offset, GPT_BYTE -= offset;
1049 } 1051 }
1050 else 1052 else
1051 { 1053 {
1052 Lisp_Object this_buffer; 1054 Lisp_Object this_buffer;
1053 1055
1066 unsigned char *dst; 1068 unsigned char *dst;
1067 { 1069 {
1068 EMACS_INT offset = dst - coding->destination; 1070 EMACS_INT offset = dst - coding->destination;
1069 1071
1070 if (BUFFERP (coding->dst_object)) 1072 if (BUFFERP (coding->dst_object))
1071 coding_alloc_by_making_gap (coding, nbytes); 1073 coding_alloc_by_making_gap (coding, offset, nbytes);
1072 else 1074 else
1073 coding_alloc_by_realloc (coding, nbytes); 1075 coding_alloc_by_realloc (coding, nbytes);
1074 record_conversion_result (coding, CODING_RESULT_SUCCESS); 1076 record_conversion_result (coding, CODING_RESULT_SUCCESS);
1075 coding_set_destination (coding); 1077 coding_set_destination (coding);
1076 dst = coding->destination + offset; 1078 dst = coding->destination + offset;
2947 int last_offset = char_offset; 2949 int last_offset = char_offset;
2948 int last_id = charset_ascii; 2950 int last_id = charset_ascii;
2949 2951
2950 CODING_GET_INFO (coding, attrs, charset_list); 2952 CODING_GET_INFO (coding, attrs, charset_list);
2951 setup_iso_safe_charsets (attrs); 2953 setup_iso_safe_charsets (attrs);
2954 /* Charset list may have been changed. */
2955 charset_list = CODING_ATTR_CHARSET_LIST (attrs);
2956 coding->safe_charsets = (char *) SDATA (CODING_ATTR_SAFE_CHARSETS(attrs));
2952 2957
2953 while (1) 2958 while (1)
2954 { 2959 {
2955 int c1, c2; 2960 int c1, c2;
2956 2961
3805 if (VECTORP (eol_type)) 3810 if (VECTORP (eol_type))
3806 eol_type = Qunix; 3811 eol_type = Qunix;
3807 3812
3808 setup_iso_safe_charsets (attrs); 3813 setup_iso_safe_charsets (attrs);
3809 /* Charset list may have been changed. */ 3814 /* Charset list may have been changed. */
3810 charset_list = CODING_ATTR_CHARSET_LIST (attrs); \ 3815 charset_list = CODING_ATTR_CHARSET_LIST (attrs);
3811 coding->safe_charsets = (char *) SDATA (CODING_ATTR_SAFE_CHARSETS(attrs)); 3816 coding->safe_charsets = (char *) SDATA (CODING_ATTR_SAFE_CHARSETS(attrs));
3812 3817
3813 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs)); 3818 ascii_compatible = ! NILP (CODING_ATTR_ASCII_COMPAT (attrs));
3814 3819
3815 while (charbuf < charbuf_end) 3820 while (charbuf < charbuf_end)
6754 6759
6755 if (CODING_REQUIRE_DETECTION (coding)) 6760 if (CODING_REQUIRE_DETECTION (coding))
6756 detect_coding (coding); 6761 detect_coding (coding);
6757 6762
6758 coding->mode |= CODING_MODE_LAST_BLOCK; 6763 coding->mode |= CODING_MODE_LAST_BLOCK;
6764 current_buffer->text->inhibit_shrinking = 1;
6759 decode_coding (coding); 6765 decode_coding (coding);
6766 current_buffer->text->inhibit_shrinking = 0;
6760 6767
6761 attrs = CODING_ID_ATTRS (coding->id); 6768 attrs = CODING_ID_ATTRS (coding->id);
6762 if (! NILP (CODING_ATTR_POST_READ (attrs))) 6769 if (! NILP (CODING_ATTR_POST_READ (attrs)))
6763 { 6770 {
6764 EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE; 6771 EMACS_INT prev_Z = Z, prev_Z_BYTE = Z_BYTE;