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'. --- doc/ref/api-io.texi | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'doc/ref/api-io.texi') diff --git a/doc/ref/api-io.texi b/doc/ref/api-io.texi index 24c2706df..de3684c31 100644 --- a/doc/ref/api-io.texi +++ b/doc/ref/api-io.texi @@ -166,6 +166,21 @@ returned. New ports will have this default behavior when they are created. @end deffn +@deffn {Scheme Variable} %default-port-conversion-strategy +The fluid that defines the conversion strategy for newly created ports, +and for other conversion routines such as @code{scm_to_stringn}, +@code{scm_from_stringn}, @code{string->pointer}, and +@code{pointer->string}. + +Its value must be one of the symbols described above, with the same +semantics: @code{'error}, @code{'substitute}, or @code{'escape}. + +When Guile starts, its value is @code{'substitute}. + +Note that @code{(set-port-conversion-strategy! #f @var{sym})} is +equivalent to @code{(fluid-set! %default-port-conversion-strategy +@var{sym})}. +@end deffn @node Reading -- cgit v1.2.3