aboutsummaryrefslogtreecommitdiffstats
path: root/src/coding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/coding.c')
-rw-r--r--src/coding.c49
1 files changed, 35 insertions, 14 deletions
diff --git a/src/coding.c b/src/coding.c
index a6cf9ce7844..c300ce20961 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -924,17 +924,22 @@ coding_set_destination (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
@@ -1223,9 +1228,17 @@ encode_coding_utf_8 (coding)
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
@@ -6115,8 +6128,16 @@ encode_coding_object (coding, src_object, from, from_byte, to, to_byte,
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 }