diff options
author | Andy Wingo <wingo@pobox.com> | 2016-05-04 10:31:21 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2016-05-04 10:41:07 +0200 |
commit | 383df7976f04c45b4f67d9138f238a2d02483e9a (patch) | |
tree | 177e7325d53d49c51623465e660888842adee7f3 /libguile/strports.c | |
parent | d8711b97596fc52bad1d3139f5be4c8442e1b896 (diff) | |
download | guile-383df7976f04c45b4f67d9138f238a2d02483e9a.tar.gz |
Port conversion strategies internally are symbols
* libguile/ports.h (scm_t_port): Represent the conversion strategy as a
symbol, to make things easier for Scheme. Rename to
"conversion_strategy".
(scm_c_make_port_with_encoding): Change to take encoding and
conversion_strategy arguments as symbols.
(scm_i_string_failed_conversion_handler): New internal helper, to turn
a symbol to a scm_t_string_failed_conversion_handler.
(scm_i_default_port_encoding): Return the default port encoding as a
symbol.
(scm_i_default_port_conversion_strategy)
(scm_i_set_default_port_conversion_strategy): Rename from
scm_i_default_port_conversion_handler et al. Take and return Scheme
symbols.
* libguile/foreign.c (scm_string_to_pointer, scm_pointer_to_string): Use
scm_i_default_string_failed_conversion_handler instead of
scm_i_default_port_conversion_handler.
* libguile/print.c (PORT_CONVERSION_HANDLER): Update definition.
(print_normal_symbol): Use PORT_CONVERSION_HANDLER.
* libguile/r6rs-ports.c (make_bytevector_input_port):
(make_custom_binary_input_port, make_bytevector_output_port): Adapt to
changes in scm_c_make_port_with_encoding.
* libguile/strings.h:
* libguile/strings.c (scm_i_default_string_failed_conversion_handler):
New helper.
(scm_from_locale_stringn, scm_from_port_stringn):
(scm_to_locale_stringn, scm_to_port_stringn): Adapt to interface
changes.
* libguile/strports.c (scm_mkstrport): Adapt to
scm_c_make_port_with_encoding change.
* libguile/ports.c (scm_c_make_port): Adapt to
scm_c_make_port_with_encoding change.
(ascii_toupper, encoding_matches, canonicalize_encoding): Move down in
the file.
(peek_codepoint, get_codepoint, scm_ungetc): Adapt to port conversion
strategy change. Remove duplicate case in get_codepoint.
(scm_init_ports): Move symbol initializations to the same place.
Diffstat (limited to 'libguile/strports.c')
-rw-r--r-- | libguile/strports.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libguile/strports.c b/libguile/strports.c index e8ce67a8f..1aecc481b 100644 --- a/libguile/strports.c +++ b/libguile/strports.c @@ -52,6 +52,8 @@ * */ +SCM_SYMBOL (sym_UTF_8, "UTF-8"); + scm_t_bits scm_tc16_strport; struct string_port { @@ -178,10 +180,10 @@ scm_mkstrport (SCM pos, SCM str, long modes, const char *caller) stream->pos = byte_pos; stream->len = len; - return scm_c_make_port_with_encoding (scm_tc16_strport, modes, - "UTF-8", - scm_i_default_port_conversion_handler (), - (scm_t_bits) stream); + return + scm_c_make_port_with_encoding (scm_tc16_strport, modes, sym_UTF_8, + scm_i_default_port_conversion_strategy (), + (scm_t_bits) stream); } /* Create a new string from the buffer of PORT, a string port, converting from |