diff options
author | Andy Wingo <wingo@pobox.com> | 2013-10-24 10:19:07 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2013-10-26 13:13:17 +0200 |
commit | db071766650d10c67524b3ddb00decfd60c55741 (patch) | |
tree | 3ee6cc0468fde846cd431a3bfce2d19230dee588 /libguile/strings.c | |
parent | 0f676d8725ebc79cd166047203c5400d8c639a25 (diff) | |
download | guile-db071766650d10c67524b3ddb00decfd60c55741.tar.gz |
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.
Diffstat (limited to 'libguile/strings.c')
-rw-r--r-- | libguile/strings.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libguile/strings.c b/libguile/strings.c index 8ee909bca..1f492bd0c 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -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) +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; /* Create a scheme string with space for LEN 8-bit Latin-1-encoded |