mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 19:50:24 +02:00
Merge commit '5943a62042
'
This commit is contained in:
commit
1cd779140d
1 changed files with 51 additions and 25 deletions
|
@ -67,6 +67,9 @@
|
||||||
static size_t display_string (const void *, int, size_t, SCM,
|
static size_t display_string (const void *, int, size_t, SCM,
|
||||||
scm_t_string_failed_conversion_handler);
|
scm_t_string_failed_conversion_handler);
|
||||||
|
|
||||||
|
static size_t write_string (const void *, int, size_t, SCM,
|
||||||
|
scm_t_string_failed_conversion_handler);
|
||||||
|
|
||||||
static int display_character (scm_t_wchar, SCM,
|
static int display_character (scm_t_wchar, SCM,
|
||||||
scm_t_string_failed_conversion_handler);
|
scm_t_string_failed_conversion_handler);
|
||||||
|
|
||||||
|
@ -705,27 +708,24 @@ iprin1 (SCM exp, SCM port, scm_print_state *pstate)
|
||||||
scm_i_print_stringbuf (exp, port, pstate);
|
scm_i_print_stringbuf (exp, port, pstate);
|
||||||
break;
|
break;
|
||||||
case scm_tc7_string:
|
case scm_tc7_string:
|
||||||
if (SCM_WRITINGP (pstate))
|
|
||||||
{
|
|
||||||
size_t len, i;
|
|
||||||
|
|
||||||
display_character ('"', port, iconveh_question_mark);
|
|
||||||
len = scm_i_string_length (exp);
|
|
||||||
for (i = 0; i < len; ++i)
|
|
||||||
write_character (scm_i_string_ref (exp, i), port, 1);
|
|
||||||
|
|
||||||
display_character ('"', port, iconveh_question_mark);
|
|
||||||
scm_remember_upto_here_1 (exp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
size_t len, printed;
|
size_t len, printed;
|
||||||
|
|
||||||
len = scm_i_string_length (exp);
|
len = scm_i_string_length (exp);
|
||||||
|
if (SCM_WRITINGP (pstate))
|
||||||
|
{
|
||||||
|
printed = write_string (scm_i_string_data (exp),
|
||||||
|
scm_i_is_narrow_string (exp),
|
||||||
|
len, port,
|
||||||
|
PORT_CONVERSION_HANDLER (port));
|
||||||
|
len += 2; /* account for the quotes */
|
||||||
|
}
|
||||||
|
else
|
||||||
printed = display_string (scm_i_string_data (exp),
|
printed = display_string (scm_i_string_data (exp),
|
||||||
scm_i_is_narrow_string (exp),
|
scm_i_is_narrow_string (exp),
|
||||||
len, port,
|
len, port,
|
||||||
PORT_CONVERSION_HANDLER (port));
|
PORT_CONVERSION_HANDLER (port));
|
||||||
|
|
||||||
if (SCM_UNLIKELY (printed < len))
|
if (SCM_UNLIKELY (printed < len))
|
||||||
scm_encoding_error (__func__, errno,
|
scm_encoding_error (__func__, errno,
|
||||||
"cannot convert to output locale",
|
"cannot convert to output locale",
|
||||||
|
@ -1125,8 +1125,6 @@ display_string_using_iconv (const void *str, int narrow_p, size_t len,
|
||||||
return printed;
|
return printed;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef STR_REF
|
|
||||||
|
|
||||||
/* Display the LEN codepoints in STR to PORT according to STRATEGY;
|
/* Display the LEN codepoints in STR to PORT according to STRATEGY;
|
||||||
return the number of codepoints successfully displayed. If NARROW_P,
|
return the number of codepoints successfully displayed. If NARROW_P,
|
||||||
then STR is interpreted as a sequence of `char', denoting a Latin-1
|
then STR is interpreted as a sequence of `char', denoting a Latin-1
|
||||||
|
@ -1149,8 +1147,8 @@ display_string (const void *str, int narrow_p,
|
||||||
return display_string_using_iconv (str, narrow_p, len, port, strategy);
|
return display_string_using_iconv (str, narrow_p, len, port, strategy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Attempt to display CH to PORT according to STRATEGY. Return non-zero
|
/* Attempt to display CH to PORT according to STRATEGY. Return one if
|
||||||
if CH was successfully displayed, zero otherwise (e.g., if it was not
|
CH was successfully displayed, zero otherwise (e.g., if it was not
|
||||||
representable in PORT's encoding.) */
|
representable in PORT's encoding.) */
|
||||||
static int
|
static int
|
||||||
display_character (scm_t_wchar ch, SCM port,
|
display_character (scm_t_wchar ch, SCM port,
|
||||||
|
@ -1159,6 +1157,34 @@ display_character (scm_t_wchar ch, SCM port,
|
||||||
return display_string (&ch, 0, 1, port, strategy) == 1;
|
return display_string (&ch, 0, 1, port, strategy) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Same as 'display_string', but using the 'write' syntax. */
|
||||||
|
static size_t
|
||||||
|
write_string (const void *str, int narrow_p,
|
||||||
|
size_t len, SCM port,
|
||||||
|
scm_t_string_failed_conversion_handler strategy)
|
||||||
|
{
|
||||||
|
size_t printed;
|
||||||
|
|
||||||
|
printed = display_character ('"', port, strategy);
|
||||||
|
|
||||||
|
if (printed > 0)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for (i = 0; i < len; ++i)
|
||||||
|
{
|
||||||
|
write_character (STR_REF (str, i), port, 1);
|
||||||
|
printed++;
|
||||||
|
}
|
||||||
|
|
||||||
|
printed += display_character ('"', port, strategy);
|
||||||
|
}
|
||||||
|
|
||||||
|
return printed;
|
||||||
|
}
|
||||||
|
|
||||||
|
#undef STR_REF
|
||||||
|
|
||||||
/* Attempt to pretty-print CH, a combining character, to PORT. Return
|
/* Attempt to pretty-print CH, a combining character, to PORT. Return
|
||||||
zero upon failure, non-zero otherwise. The idea is to print CH above
|
zero upon failure, non-zero otherwise. The idea is to print CH above
|
||||||
a dotted circle to make it more visible. */
|
a dotted circle to make it more visible. */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue