From b22e94db7c91d7661204e33f3bc2bfead002c9b7 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 29 May 2012 23:39:05 +0200 Subject: Add the `%default-port-conversion-strategy' fluid. Fixes . * libguile/ports.c (scm_conversion_strategy): Remove. (default_conversion_strategy_var, sym_error, sym_substitute, sym_escape): New variables. (scm_i_get_conversion_strategy, scm_i_set_conversion_strategy_x): Remove. (scm_i_default_port_conversion_handler, scm_i_set_default_port_conversion_handler): New functions. (scm_port_conversion_strategy): Use `scm_i_default_port_conversion_handler' when PORT is #f. (scm_set_port_conversion_strategy_x): Use SYM_ERROR, SYM_SUBSTITUTE, and SYM_ESCAPE. Use `scm_i_set_default_port_conversion_handler' when PORT is #f. (scm_init_ports): Initialize DEFAULT_CONVERSION_STRATEGY_VAR. * libguile/ports.h: Update declarations accordingly. * libguile/foreign.c: Change `scm_i_get_conversion_strategy (SCM_BOOL_F)' to `scm_i_default_port_conversion_handler ()'. * libguile/strings.c: Likewise. * test-suite/tests/ports.test ("%default-port-conversion-strategy"): New test prefix. * test-suite/tests/foreign.test ("pointer<->string")["%default-port-conversion-strategy is error", "%default-port-conversion-strategy is soft"]: New tests. * test-suite/test-suite/lib.scm (exception:encoding-error): Allow the regexp to match `scm_to_stringn' error messages. * doc/ref/api-io.texi (Ports): Document `%default-port-conversion-strategy'. --- libguile/strings.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libguile/strings.c') diff --git a/libguile/strings.c b/libguile/strings.c index 07356fcaf..414951ee1 100644 --- a/libguile/strings.c +++ b/libguile/strings.c @@ -1577,7 +1577,7 @@ SCM scm_from_locale_stringn (const char *str, size_t len) { return scm_from_stringn (str, len, locale_charset (), - scm_i_get_conversion_strategy (SCM_BOOL_F)); + scm_i_default_port_conversion_handler ()); } SCM @@ -1802,9 +1802,9 @@ scm_to_locale_string (SCM str) char * scm_to_locale_stringn (SCM str, size_t *lenp) { - return scm_to_stringn (str, lenp, + return scm_to_stringn (str, lenp, locale_charset (), - scm_i_get_conversion_strategy (SCM_BOOL_F)); + scm_i_default_port_conversion_handler ()); } char * -- cgit v1.2.3