int require_decoding;
int shrinked_bytes = 0;
Lisp_Object newstr;
- int consumed, produced, produced_char;
+ int consumed, consumed_char, produced, produced_char;
from = 0;
to = XSTRING (str)->size;
len = decoding_buffer_size (coding, to_byte - from);
allocate_conversion_buffer (buf, len);
- consumed = produced = produced_char = 0;
+ consumed = consumed_char = produced = produced_char = 0;
while (1)
{
result = decode_coding (coding, XSTRING (str)->data + from + consumed,
buf.data + produced, to_byte - from - consumed,
buf.size - produced);
consumed += coding->consumed;
+ consumed_char += coding->consumed_char;
produced += coding->produced;
produced_char += coding->produced_char;
- if (result == CODING_FINISH_NORMAL)
+ if (result == CODING_FINISH_NORMAL
+ || (result == CODING_FINISH_INSUFFICIENT_SRC
+ && coding->consumed == 0))
break;
if (result == CODING_FINISH_INSUFFICIENT_CMP)
coding_allocate_composition_data (coding, from + produced_char);
}
}
+ coding->consumed = consumed;
+ coding->consumed_char = consumed_char;
+ coding->produced = produced;
+ coding->produced_char = produced_char;
+
if (coding->dst_multibyte)
newstr = make_uninit_multibyte_string (produced_char + shrinked_bytes,
produced + shrinked_bytes);
int result;
int shrinked_bytes = 0;
Lisp_Object newstr;
- int consumed, consumed_char, produced;
+ int consumed, consumed_char, produced, produced_char;
if (SYMBOLP (coding->pre_write_conversion)
&& !NILP (Ffboundp (coding->pre_write_conversion)))
saved_coding_symbol = Qnil;
if (! CODING_REQUIRE_ENCODING (coding))
{
+ coding->consumed = STRING_BYTES (XSTRING (str));
+ coding->consumed_char = XSTRING (str)->size;
if (STRING_MULTIBYTE (str))
{
str = Fstring_as_unibyte (str);
nocopy = 1;
}
+ coding->produced = STRING_BYTES (XSTRING (str));
+ coding->produced_char = XSTRING (str)->size;
return (nocopy ? str : Fcopy_sequence (str));
}
len = encoding_buffer_size (coding, to_byte - from);
allocate_conversion_buffer (buf, len);
- consumed = consumed_char = produced = 0;
-
+ consumed = consumed_char = produced = produced_char = 0;
while (1)
{
result = encode_coding (coding, XSTRING (str)->data + from + consumed,
buf.data + produced, to_byte - from - consumed,
buf.size - produced);
consumed += coding->consumed;
- produced += coding->produced;
- if (result == CODING_FINISH_NORMAL)
+ consumed_char += coding->consumed_char;
+ produced_char += coding->produced_char;
+ if (result == CODING_FINISH_NORMAL
+ || (result == CODING_FINISH_INSUFFICIENT_SRC
+ && coding->consumed == 0))
break;
/* Now result should be CODING_FINISH_INSUFFICIENT_DST. */
extend_conversion_buffer (&buf);
}
+ coding->consumed = consumed;
+ coding->consumed_char = consumed_char;
+ coding->produced = produced;
+ coding->produced_char = produced_char;
+
newstr = make_uninit_string (produced + shrinked_bytes);
if (from > 0)
bcopy (XSTRING (str)->data, XSTRING (newstr)->data, from);