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

Add SCM_OPN to mode bits when making ports

* libguile/ports.c (scm_c_make_port_with_encoding): Add SCM_OPN to mode
  bits, so that users don't have to.
  (scm_i_mode_bits_n):
* libguile/print.c (scm_simple_format)
* libguile/r6rs-ports.c (make_bytevector_input_port)
  (make_custom_binary_input_port, make_bytevector_output_port)
  (make_custom_binary_output_port, make_transcoded_port)
* libguile/strports.c (scm_object_to_string, scm_open_input_string)
  (scm_open_output_string, scm_c_read_string): Remove now-unneeded
  SCM_OPN mentions.
This commit is contained in:
Andy Wingo 2016-05-14 12:38:49 +02:00
parent 9322902d02
commit 9ecf77a82d
4 changed files with 16 additions and 33 deletions

View file

@ -485,8 +485,7 @@ scm_c_make_port_buffer (size_t size)
static long
scm_i_mode_bits_n (SCM modes)
{
return (SCM_OPN
| (scm_i_string_contains_char (modes, 'r')
return ((scm_i_string_contains_char (modes, 'r')
|| scm_i_string_contains_char (modes, '+') ? SCM_RDNG : 0)
| (scm_i_string_contains_char (modes, 'w')
|| scm_i_string_contains_char (modes, 'a')
@ -629,7 +628,7 @@ scm_c_make_port_with_encoding (scm_t_port_type *ptob, unsigned long mode_bits,
pt = scm_gc_typed_calloc (scm_t_port);
ret = scm_words (scm_tc7_port | mode_bits, 4);
ret = scm_words (scm_tc7_port | mode_bits | SCM_OPN, 4);
SCM_SET_CELL_WORD_1 (ret, stream);
SCM_SET_CELL_WORD_2 (ret, (scm_t_bits) pt);
SCM_SET_CELL_WORD_3 (ret, (scm_t_bits) ptob);

View file

@ -1565,9 +1565,7 @@ SCM_DEFINE (scm_simple_format, "simple-format", 2, 0, 1,
else if (scm_is_false (destination))
{
fReturnString = 1;
port = scm_mkstrport (SCM_INUM0, SCM_BOOL_F,
SCM_OPN | SCM_WRTNG,
FUNC_NAME);
port = scm_mkstrport (SCM_INUM0, SCM_BOOL_F, SCM_WRTNG, FUNC_NAME);
destination = port;
}
else

View file

@ -92,7 +92,7 @@ struct bytevector_input_port {
static inline SCM
make_bytevector_input_port (SCM bv)
{
const unsigned long mode_bits = SCM_OPN | SCM_RDNG;
const unsigned long mode_bits = SCM_RDNG;
struct bytevector_input_port *stream;
stream = scm_gc_typed_calloc (struct bytevector_input_port);
@ -266,7 +266,7 @@ make_custom_binary_input_port (SCM read_proc, SCM get_position_proc,
SCM set_position_proc, SCM close_proc)
{
struct custom_binary_port *stream;
const unsigned long mode_bits = SCM_OPN | SCM_RDNG;
const unsigned long mode_bits = SCM_RDNG;
stream = scm_gc_typed_calloc (struct custom_binary_port);
stream->read = read_proc;
@ -734,7 +734,7 @@ make_bytevector_output_port (void)
{
SCM port, proc;
scm_t_bytevector_output_port_buffer *buf;
const unsigned long mode_bits = SCM_OPN | SCM_WRTNG;
const unsigned long mode_bits = SCM_WRTNG;
buf = (scm_t_bytevector_output_port_buffer *)
scm_gc_malloc (sizeof (* buf), SCM_GC_BYTEVECTOR_OUTPUT_PORT);
@ -868,7 +868,7 @@ make_custom_binary_output_port (SCM write_proc, SCM get_position_proc,
SCM set_position_proc, SCM close_proc)
{
struct custom_binary_port *stream;
const unsigned long mode_bits = SCM_OPN | SCM_WRTNG;
const unsigned long mode_bits = SCM_WRTNG;
stream = scm_gc_typed_calloc (struct custom_binary_port);
stream->read = SCM_BOOL_F;
@ -957,13 +957,8 @@ static scm_t_port_type *transcoded_port_type = 0;
static inline SCM
make_transcoded_port (SCM binary_port, unsigned long mode)
{
SCM port;
const unsigned long mode_bits = SCM_OPN | mode;
port = scm_c_make_port (transcoded_port_type, mode_bits,
return scm_c_make_port (transcoded_port_type, mode,
SCM_UNPACK (binary_port));
return port;
}
static size_t

View file

@ -215,8 +215,7 @@ SCM_DEFINE (scm_object_to_string, "object->string", 1, 1, 0,
if (!SCM_UNBNDP (printer))
SCM_VALIDATE_PROC (2, printer);
port = scm_mkstrport (SCM_INUM0, SCM_BOOL_F,
SCM_OPN | SCM_WRTNG, FUNC_NAME);
port = scm_mkstrport (SCM_INUM0, SCM_BOOL_F, SCM_WRTNG, FUNC_NAME);
if (SCM_UNBNDP (printer))
scm_write (obj, port);
@ -267,8 +266,7 @@ SCM_DEFINE (scm_open_input_string, "open-input-string", 1, 0, 0,
"by the garbage collector if it becomes inaccessible.")
#define FUNC_NAME s_scm_open_input_string
{
SCM p = scm_mkstrport (SCM_INUM0, str, SCM_OPN | SCM_RDNG, FUNC_NAME);
return p;
return scm_mkstrport (SCM_INUM0, str, SCM_RDNG, FUNC_NAME);
}
#undef FUNC_NAME
@ -281,12 +279,7 @@ SCM_DEFINE (scm_open_output_string, "open-output-string", 0, 0, 0,
"inaccessible.")
#define FUNC_NAME s_scm_open_output_string
{
SCM p;
p = scm_mkstrport (SCM_INUM0, SCM_BOOL_F,
SCM_OPN | SCM_WRTNG,
FUNC_NAME);
return p;
return scm_mkstrport (SCM_INUM0, SCM_BOOL_F, SCM_WRTNG, FUNC_NAME);
}
#undef FUNC_NAME
@ -308,15 +301,13 @@ SCM_DEFINE (scm_get_output_string, "get-output-string", 1, 0, 0,
SCM
scm_c_read_string (const char *expr)
{
SCM port = scm_mkstrport (SCM_INUM0,
scm_from_locale_string (expr),
SCM_OPN | SCM_RDNG,
"scm_c_read_string");
SCM form;
SCM port, form;
port = scm_mkstrport (SCM_INUM0, scm_from_locale_string (expr),
SCM_RDNG, "scm_c_read_string");
form = scm_read (port);
scm_close_port (port);
return form;
}