mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 20:00:19 +02:00
Add stringbuf printer
* libguile/strings.h: * libguile/strings.c (scm_i_print_stringbuf): * libguile/print.c (iprin1): Add a printer for stringbufs. The disassembler can print a stringbuf.
This commit is contained in:
parent
0f676d8725
commit
db07176665
3 changed files with 22 additions and 0 deletions
|
@ -609,6 +609,9 @@ iprin1 (SCM exp, SCM port, scm_print_state *pstate)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case scm_tc7_stringbuf:
|
||||||
|
scm_i_print_stringbuf (exp, port, pstate);
|
||||||
|
break;
|
||||||
case scm_tc7_string:
|
case scm_tc7_string:
|
||||||
if (SCM_WRITINGP (pstate))
|
if (SCM_WRITINGP (pstate))
|
||||||
{
|
{
|
||||||
|
|
|
@ -261,6 +261,23 @@ scm_i_pthread_mutex_t stringbuf_write_mutex = SCM_I_PTHREAD_MUTEX_INITIALIZER;
|
||||||
|
|
||||||
#define IS_SH_STRING(str) (SCM_CELL_TYPE(str)==SH_STRING_TAG)
|
#define IS_SH_STRING(str) (SCM_CELL_TYPE(str)==SH_STRING_TAG)
|
||||||
|
|
||||||
|
void
|
||||||
|
scm_i_print_stringbuf (SCM exp, SCM port, scm_print_state *pstate)
|
||||||
|
{
|
||||||
|
SCM str;
|
||||||
|
|
||||||
|
scm_i_pthread_mutex_lock (&stringbuf_write_mutex);
|
||||||
|
SET_STRINGBUF_SHARED (exp);
|
||||||
|
scm_i_pthread_mutex_unlock (&stringbuf_write_mutex);
|
||||||
|
|
||||||
|
str = scm_double_cell (RO_STRING_TAG, SCM_UNPACK(exp),
|
||||||
|
0, STRINGBUF_LENGTH (exp));
|
||||||
|
|
||||||
|
scm_puts ("#<stringbuf ", port);
|
||||||
|
scm_iprin1 (str, port, pstate);
|
||||||
|
scm_puts (">", port);
|
||||||
|
}
|
||||||
|
|
||||||
SCM scm_nullstr;
|
SCM scm_nullstr;
|
||||||
|
|
||||||
/* Create a scheme string with space for LEN 8-bit Latin-1-encoded
|
/* Create a scheme string with space for LEN 8-bit Latin-1-encoded
|
||||||
|
|
|
@ -179,6 +179,8 @@ SCM_API SCM scm_makfromstrs (int argc, char **argv);
|
||||||
#define SCM_I_STRINGBUF_F_SHARED 0x100
|
#define SCM_I_STRINGBUF_F_SHARED 0x100
|
||||||
#define SCM_I_STRINGBUF_F_WIDE 0x400
|
#define SCM_I_STRINGBUF_F_WIDE 0x400
|
||||||
|
|
||||||
|
SCM_INTERNAL void scm_i_print_stringbuf (SCM exp, SCM port,
|
||||||
|
scm_print_state *pstate);
|
||||||
|
|
||||||
/* internal accessor functions. Arguments must be valid. */
|
/* internal accessor functions. Arguments must be valid. */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue