1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

Upon port encoding error, always write as much as possible.

* libguile/print.c (display_string): Upon error, always write the
  OUTPUT_LEN bytes of output, regardless of the conversion strategy.
This commit is contained in:
Ludovic Courtès 2011-02-02 17:33:12 +01:00
parent b1e76e8f2c
commit 7174bc08dd

View file

@ -868,20 +868,20 @@ display_string (const void *str, int narrow_p,
/* Reset the `iconv' state. */
iconv (pt->output_cd, NULL, NULL, NULL, NULL);
/* Print the OUTPUT_LEN bytes successfully converted. */
scm_lfwrite (encoded_output, output_len, port);
/* See how many input codepoints these OUTPUT_LEN bytes
corresponds to. */
codepoints_read = offsets[input - utf8_buf] - printed;
printed += codepoints_read;
if (errno == EILSEQ &&
strategy != SCM_FAILED_CONVERSION_ERROR)
{
/* Conversion failed somewhere in INPUT and we want to
escape or substitute the offending input character. */
/* Print the OUTPUT_LEN bytes successfully converted. */
scm_lfwrite (encoded_output, output_len, port);
/* See how many input codepoints these OUTPUT_LEN bytes
corresponds to. */
codepoints_read = offsets[input - utf8_buf] - printed;
printed += codepoints_read;
if (strategy == SCM_FAILED_CONVERSION_ESCAPE_SEQUENCE)
{
scm_t_wchar ch;