diff options
author | Andy Wingo <wingo@pobox.com> | 2016-05-05 13:00:19 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2016-05-05 13:00:19 +0200 |
commit | 86267af8b30be0901b6bb29cbdc730c0a5844bfd (patch) | |
tree | 19d636fc933fb71202c892971418eab95999d996 /libguile/print.c | |
parent | d7a111b0ec96840ccf8ce4dc31e497e00c3a16a6 (diff) | |
download | guile-86267af8b30be0901b6bb29cbdc730c0a5844bfd.tar.gz |
Handle BOM around fill/flush instead of peek/put
* libguile/print.c (display_string_using_iconv): Remove BOM handling;
this is now handled by scm_lfwrite.
* libguile/ports.c (open_iconv_descriptors): Refactor to take encoding
as a symbol.
(prepare_iconv_descriptors): New helper.
(scm_i_port_iconv_descriptors): Remove scm_t_port_rw_active argument,
and don't sniff UTF-16/UTF-32 byte orders here. Instead BOM handlers
will call prepare_iconv_descriptors.
(scm_c_read_bytes): Call new port_clear_stream_start_for_bom_read
helper.
(port_maybe_consume_initial_byte_order_mark)
(scm_port_maybe_consume_initial_byte_order_mark): Remove. Leaves
Scheme %peek-char broken but it's unused currently so that's OK.
(peek_iconv_codepoint): Fetch iconv descriptors after doing fill-input
because it's fill-input that will sniff the BOM.
(peek_codepoint): Instead of handling BOM at every character, handle
in fill-input instead.
(maybe_consume_bom, port_clear_stream_start_for_bom_read)
(port_clear_stream_start_for_bom_write): New helpers.
(scm_fill_input): Slurp a BOM if needed.
(scm_i_write): Clear the start-of-stream-for-bom-write flag.
(scm_lfwrite): Write a BOM if needed.
Diffstat (limited to 'libguile/print.c')
-rw-r--r-- | libguile/print.c | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/libguile/print.c b/libguile/print.c index 0b2d19340..8dcd375f9 100644 --- a/libguile/print.c +++ b/libguile/print.c @@ -1027,24 +1027,8 @@ display_string_using_iconv (const void *str, int narrow_p, size_t len, { size_t printed; scm_t_iconv_descriptors *id; - scm_t_port_internal *pti = SCM_PORT_GET_INTERNAL (port); - id = scm_i_port_iconv_descriptors (port, SCM_PORT_WRITE); - - if (SCM_UNLIKELY (pti->at_stream_start_for_bom_write && len > 0)) - { - scm_t_port *pt = SCM_PTAB_ENTRY (port); - - /* Record that we're no longer at stream start. */ - pti->at_stream_start_for_bom_write = 0; - if (pt->rw_random) - pti->at_stream_start_for_bom_read = 0; - - /* Write a BOM if appropriate. */ - if (SCM_UNLIKELY (scm_is_eq (pt->encoding, sym_UTF_16) - || scm_is_eq (pt->encoding, sym_UTF_32))) - display_character (SCM_UNICODE_BOM, port, iconveh_error); - } + id = scm_i_port_iconv_descriptors (port); printed = 0; |