summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2016-05-14 12:38:49 +0200
committerAndy Wingo <wingo@pobox.com>2016-05-14 12:42:17 +0200
commit9ecf77a82d6060a26f6891181f4582cc19dec65e (patch)
tree4f9b55e6026841a380c9e3f1c95a6b2a39a9547d
parent9322902d02ecc23ec4c8534dbbc03c3074b78217 (diff)
downloadguile-9ecf77a82d6060a26f6891181f4582cc19dec65e.tar.gz
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.
-rw-r--r--libguile/ports.c7
-rw-r--r--libguile/print.c4
-rw-r--r--libguile/r6rs-ports.c15
-rw-r--r--libguile/strports.c23
4 files changed, 16 insertions, 33 deletions
diff --git a/libguile/ports.c b/libguile/ports.c
index 464f8f2a9..a89c7e48e 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -485,9 +485,8 @@ 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')
- || scm_i_string_contains_char (modes, '+') ? SCM_RDNG : 0)
+ 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')
|| scm_i_string_contains_char (modes, '+') ? SCM_WRTNG : 0)
@@ -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);
diff --git a/libguile/print.c b/libguile/print.c
index b1ddf58b6..562057722 100644
--- a/libguile/print.c
+++ b/libguile/print.c
@@ -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
diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c
index 7b18d8294..c53b53bf2 100644
--- a/libguile/r6rs-ports.c
+++ b/libguile/r6rs-ports.c
@@ -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
diff --git a/libguile/strports.c b/libguile/strports.c
index 1a893ac34..e2bbe53ca 100644
--- a/libguile/strports.c
+++ b/libguile/strports.c
@@ -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;
}