1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Access `pt->ilseq_handler' directly when needed.

* libguile/print.c (PORT_CONVERSION_HANDLER): New macro.
  (print_extended_symbol, iprin1, write_character, scm_write_char): Use
  it instead of `scm_i_get_conversion_strategy'.

* libguile/strports.c (scm_mkstrport): Assign `pt->ilseq_handler'
  directly instead of via `scm_i_set_conversion_strategy_x'.
This commit is contained in:
Ludovic Courtès 2012-05-29 23:39:05 +02:00
parent 1a6ff60da8
commit 478848cb70
2 changed files with 12 additions and 8 deletions

View file

@ -61,6 +61,9 @@
/* Character printers. */ /* Character printers. */
#define PORT_CONVERSION_HANDLER(port) \
SCM_PTAB_ENTRY (port)->ilseq_handler
static size_t display_string (const void *, int, size_t, SCM, static size_t display_string (const void *, int, size_t, SCM,
scm_t_string_failed_conversion_handler); scm_t_string_failed_conversion_handler);
@ -393,7 +396,7 @@ print_extended_symbol (SCM sym, SCM port)
scm_t_string_failed_conversion_handler strategy; scm_t_string_failed_conversion_handler strategy;
len = scm_i_symbol_length (sym); len = scm_i_symbol_length (sym);
strategy = scm_i_get_conversion_strategy (port); strategy = PORT_CONVERSION_HANDLER (port);
scm_lfwrite ("#{", 2, port); scm_lfwrite ("#{", 2, port);
@ -500,7 +503,7 @@ iprin1 (SCM exp, SCM port, scm_print_state *pstate)
else else
{ {
if (!display_character (SCM_CHAR (exp), port, if (!display_character (SCM_CHAR (exp), port,
scm_i_get_conversion_strategy (port))) PORT_CONVERSION_HANDLER (port)))
scm_encoding_error (__func__, errno, scm_encoding_error (__func__, errno,
"cannot convert to output locale", "cannot convert to output locale",
port, exp); port, exp);
@ -586,7 +589,7 @@ iprin1 (SCM exp, SCM port, scm_print_state *pstate)
printed = display_string (scm_i_string_data (exp), printed = display_string (scm_i_string_data (exp),
scm_i_is_narrow_string (exp), scm_i_is_narrow_string (exp),
len, port, len, port,
scm_i_get_conversion_strategy (port)); PORT_CONVERSION_HANDLER (port));
if (SCM_UNLIKELY (printed < len)) if (SCM_UNLIKELY (printed < len))
scm_encoding_error (__func__, errno, scm_encoding_error (__func__, errno,
"cannot convert to output locale", "cannot convert to output locale",
@ -1116,7 +1119,7 @@ write_character (scm_t_wchar ch, SCM port, int string_escapes_p)
int printed = 0; int printed = 0;
scm_t_string_failed_conversion_handler strategy; scm_t_string_failed_conversion_handler strategy;
strategy = scm_i_get_conversion_strategy (port); strategy = PORT_CONVERSION_HANDLER (port);
if (string_escapes_p) if (string_escapes_p)
{ {
@ -1469,7 +1472,7 @@ SCM_DEFINE (scm_write_char, "write-char", 1, 1, 0,
port = SCM_COERCE_OUTPORT (port); port = SCM_COERCE_OUTPORT (port);
if (!display_character (SCM_CHAR (chr), port, if (!display_character (SCM_CHAR (chr), port,
scm_i_get_conversion_strategy (port))) PORT_CONVERSION_HANDLER (port)))
scm_encoding_error (__func__, errno, scm_encoding_error (__func__, errno,
"cannot convert to output locale", "cannot convert to output locale",
port, chr); port, chr);

View file

@ -1,5 +1,6 @@
/* Copyright (C) 1995,1996,1998,1999,2000,2001,2002, 2003, 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc. /* Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006,
* * 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License * modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3 of * as published by the Free Software Foundation; either version 3 of
@ -336,7 +337,7 @@ scm_mkstrport (SCM pos, SCM str, long modes, const char *caller)
if ((modes & SCM_WRTNG) && pt->write_pos == pt->write_end) if ((modes & SCM_WRTNG) && pt->write_pos == pt->write_end)
st_flush (z); st_flush (z);
scm_i_set_conversion_strategy_x (z, SCM_FAILED_CONVERSION_ERROR); pt->ilseq_handler = SCM_FAILED_CONVERSION_ERROR;
return z; return z;
} }