Mercurial > emacs
comparison src/coding.c @ 89042:2b9f8973f240
(coding_set_destination): Fix coding->destination for
the case converting a region.
(encode_coding_utf_8): Encode eight-bit chars as single byte.
(encode_coding_object): Fix coding->dst_pos and
coding->dst_pos_byte for the case converting a region.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 21 Aug 2002 12:53:56 +0000 |
parents | 3b05c02eebf2 |
children | 88a9e962e183 |
comparison
equal
deleted
inserted
replaced
89041:2ce9656d788b | 89042:2b9f8973f240 |
---|---|
922 coding_set_destination (coding) | 922 coding_set_destination (coding) |
923 struct coding_system *coding; | 923 struct coding_system *coding; |
924 { | 924 { |
925 if (BUFFERP (coding->dst_object)) | 925 if (BUFFERP (coding->dst_object)) |
926 { | 926 { |
927 /* We are sure that coding->dst_pos_byte is before the gap of the | |
928 buffer. */ | |
929 coding->destination = (BUF_BEG_ADDR (XBUFFER (coding->dst_object)) | |
930 + coding->dst_pos_byte - 1); | |
931 if (coding->src_pos < 0) | 927 if (coding->src_pos < 0) |
932 coding->dst_bytes = (GAP_END_ADDR | 928 { |
933 - (coding->src_bytes - coding->consumed) | 929 coding->destination = BEG_ADDR + coding->dst_pos_byte - 1; |
934 - coding->destination); | 930 coding->dst_bytes = (GAP_END_ADDR |
931 - (coding->src_bytes - coding->consumed) | |
932 - coding->destination); | |
933 } | |
935 else | 934 else |
936 coding->dst_bytes = (BUF_GAP_END_ADDR (XBUFFER (coding->dst_object)) | 935 { |
937 - coding->destination); | 936 /* We are sure that coding->dst_pos_byte is before the gap |
937 of the buffer. */ | |
938 coding->destination = (BUF_BEG_ADDR (XBUFFER (coding->dst_object)) | |
939 + coding->dst_pos_byte - 1); | |
940 coding->dst_bytes = (BUF_GAP_END_ADDR (XBUFFER (coding->dst_object)) | |
941 - coding->destination); | |
942 } | |
938 } | 943 } |
939 else | 944 else |
940 /* Otherwise, the destination is C string and is never relocated | 945 /* Otherwise, the destination is C string and is never relocated |
941 automatically. Thus we don't have to update anything. */ | 946 automatically. Thus we don't have to update anything. */ |
942 ; | 947 ; |
1221 { | 1226 { |
1222 unsigned char str[MAX_MULTIBYTE_LENGTH], *p, *pend = str; | 1227 unsigned char str[MAX_MULTIBYTE_LENGTH], *p, *pend = str; |
1223 | 1228 |
1224 ASSURE_DESTINATION (safe_room); | 1229 ASSURE_DESTINATION (safe_room); |
1225 c = *charbuf++; | 1230 c = *charbuf++; |
1226 CHAR_STRING_ADVANCE (c, pend); | 1231 if (CHAR_BYTE8_P (c)) |
1227 for (p = str; p < pend; p++) | 1232 { |
1228 EMIT_ONE_BYTE (*p); | 1233 c = CHAR_TO_BYTE8 (c); |
1234 EMIT_ONE_BYTE (c); | |
1235 } | |
1236 else | |
1237 { | |
1238 CHAR_STRING_ADVANCE (c, pend); | |
1239 for (p = str; p < pend; p++) | |
1240 EMIT_ONE_BYTE (*p); | |
1241 } | |
1229 } | 1242 } |
1230 } | 1243 } |
1231 else | 1244 else |
1232 { | 1245 { |
1233 int safe_room = MAX_MULTIBYTE_LENGTH; | 1246 int safe_room = MAX_MULTIBYTE_LENGTH; |
6113 } | 6126 } |
6114 | 6127 |
6115 if (BUFFERP (dst_object)) | 6128 if (BUFFERP (dst_object)) |
6116 { | 6129 { |
6117 coding->dst_object = dst_object; | 6130 coding->dst_object = dst_object; |
6118 coding->dst_pos = BUF_PT (XBUFFER (dst_object)); | 6131 if (EQ (src_object, dst_object)) |
6119 coding->dst_pos_byte = BUF_PT_BYTE (XBUFFER (dst_object)); | 6132 { |
6133 coding->dst_pos = from; | |
6134 coding->dst_pos_byte = from_byte; | |
6135 } | |
6136 else | |
6137 { | |
6138 coding->dst_pos = BUF_PT (XBUFFER (dst_object)); | |
6139 coding->dst_pos_byte = BUF_PT_BYTE (XBUFFER (dst_object)); | |
6140 } | |
6120 coding->dst_multibyte | 6141 coding->dst_multibyte |
6121 = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters); | 6142 = ! NILP (XBUFFER (dst_object)->enable_multibyte_characters); |
6122 } | 6143 } |
6123 else if (EQ (dst_object, Qt)) | 6144 else if (EQ (dst_object, Qt)) |
6124 { | 6145 { |