1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-17 01:00:20 +02:00

Fix bytevector and custom binary ports to actually use ISO-8859-1 encoding.

Fixes <http://bugs.gnu.org/20200>, introduced in
  commit 337edc591f.
Reported by David Kastrup <dak@gnu.org>.

* libguile/r6rs-ports.c (make_bip, make_cbip, make_bop, make_cbop):
  After setting port encoding = NULL, update 'encoding_mode'
  accordingly.
* libguile/ports.c (scm_i_set_port_encoding_x): Add warning comment.
* test-suite/tests/r6rs-ports.test: Add tests.
This commit is contained in:
Mark H Weaver 2015-03-28 16:01:23 -04:00
parent 2c032c2215
commit d574d96f87
3 changed files with 59 additions and 0 deletions

View file

@ -2580,6 +2580,11 @@ scm_i_set_port_encoding_x (SCM port, const char *encoding)
because we do I/O ourselves. This saves 100+ KiB for each
descriptor. */
pt->encoding = scm_gc_strdup (encoding, "port");
/* IMPORTANT: If the set of encoding modes is changed, or if more
would need to be done after setting pt->encoding = NULL, then
update 'make_bip', 'make_cbip', 'make_bop', and 'make_cbop' in
r6rs-ports.c accordingly. This will be cleaned up in 2.2. */
if (c_strcasecmp (encoding, "UTF-8") == 0)
pti->encoding_mode = SCM_PORT_ENCODING_MODE_UTF8;
else

View file

@ -89,6 +89,8 @@ make_bip (SCM bv)
/* Match the expectation of `binary-port?'. */
c_port->encoding = NULL;
/* XXX Manually update encoding_mode. This will be cleaned up in 2.2. */
SCM_PORT_GET_INTERNAL (port)->encoding_mode = SCM_PORT_ENCODING_MODE_ICONV;
/* Prevent BV from being GC'd. */
SCM_SETSTREAM (port, SCM_UNPACK (bv));
@ -362,6 +364,8 @@ make_cbip (SCM read_proc, SCM get_position_proc,
/* Match the expectation of `binary-port?'. */
c_port->encoding = NULL;
/* XXX Manually update encoding_mode. This will be cleaned up in 2.2. */
SCM_PORT_GET_INTERNAL (port)->encoding_mode = SCM_PORT_ENCODING_MODE_ICONV;
/* Attach it the method vector. */
SCM_SETSTREAM (port, SCM_UNPACK (method_vector));
@ -912,6 +916,8 @@ make_bop (void)
/* Match the expectation of `binary-port?'. */
c_port->encoding = NULL;
/* XXX Manually update encoding_mode. This will be cleaned up in 2.2. */
SCM_PORT_GET_INTERNAL (port)->encoding_mode = SCM_PORT_ENCODING_MODE_ICONV;
buf = (scm_t_bop_buffer *) scm_gc_malloc (sizeof (* buf), SCM_GC_BOP);
bop_buffer_init (buf);
@ -1071,6 +1077,8 @@ make_cbop (SCM write_proc, SCM get_position_proc,
/* Match the expectation of `binary-port?'. */
c_port->encoding = NULL;
/* XXX Manually update encoding_mode. This will be cleaned up in 2.2. */
SCM_PORT_GET_INTERNAL (port)->encoding_mode = SCM_PORT_ENCODING_MODE_ICONV;
/* Attach it the method vector. */
SCM_SETSTREAM (port, SCM_UNPACK (method_vector));