scm_cons (scm_strerror (scm_from_int (en)),
scm_cons (filename, SCM_EOL)), en);
}
- port = scm_fdes_to_port (fdes, md, filename);
+ port = scm_i_fdes_to_port (fdes, scm_i_mode_bits (mode), filename);
scm_frame_end ();
NAME is a string to be used as the port's filename.
*/
SCM
-scm_fdes_to_port (int fdes, char *mode, SCM name)
+scm_i_fdes_to_port (int fdes, long mode_bits, SCM name)
#define FUNC_NAME "scm_fdes_to_port"
{
- long mode_bits = scm_mode_bits (mode);
SCM port;
scm_t_port *pt;
int flags;
}
#undef FUNC_NAME
+SCM
+scm_fdes_to_port (int fdes, char *mode, SCM name)
+{
+ return scm_i_fdes_to_port (fdes, scm_mode_bits (mode), name);
+}
+
/* Return a lower bound on the number of bytes available for input. */
static int
fport_input_waiting (SCM port)
count += pt->saved_read_end - pt->saved_read_pos;
result = scm_allocate_string (count);
- scm_take_from_input_buffers (port, SCM_STRING_CHARS (result), count);
+ scm_take_from_input_buffers (port, SCM_I_STRING_CHARS (result), count);
return result;
}
| (strchr (modes, 'l') ? SCM_BUFLINE : 0));
}
+long
+scm_i_mode_bits (SCM modes)
+{
+ long bits;
+
+ if (!scm_is_string (modes))
+ scm_wrong_type_arg_msg (NULL, 0, modes, "string");
+
+ bits = scm_mode_bits (SCM_I_STRING_CHARS (modes));
+ scm_remember_upto_here_1 (modes);
+ return bits;
+}
/* Return the mode flags from an open port.
* Some modes such as "append" are only used when opening
else
SCM_VALIDATE_OPINPORT (2, port);
- scm_ungets (SCM_STRING_CHARS (str), SCM_STRING_LENGTH (str), port);
+ scm_ungets (SCM_I_STRING_CHARS (str), SCM_I_STRING_LENGTH (str), port);
return str;
}
{
}
-SCM
-scm_void_port (char *mode_str)
+static SCM
+scm_i_void_port (long mode_bits)
{
scm_mutex_lock (&scm_i_port_table_mutex);
{
- int mode_bits = scm_mode_bits (mode_str);
SCM answer = scm_new_port_table_entry (scm_tc16_void_port);
scm_t_port * pt = SCM_PTAB_ENTRY(answer);
}
}
+SCM
+scm_void_port (char *mode_str)
+{
+ return scm_i_void_port (scm_mode_bits (mode_str));
+}
+
SCM_DEFINE (scm_sys_make_void_port, "%make-void-port", 1, 0, 0,
(SCM mode),
"Create and return a new void port. A void port acts like\n"
"documentation for @code{open-file} in @ref{File Ports}.")
#define FUNC_NAME s_scm_sys_make_void_port
{
- SCM_VALIDATE_STRING (1, mode);
- return scm_void_port (SCM_STRING_CHARS (mode));
+ return scm_i_void_port (scm_i_mode_bits (mode));
}
#undef FUNC_NAME
z = scm_new_port_table_entry (scm_tc16_sfport);
pt = SCM_PTAB_ENTRY (z);
scm_port_non_buffer (pt);
- SCM_SET_CELL_TYPE (z, scm_tc16_sfport | scm_mode_bits (SCM_STRING_CHARS (modes)));
+ SCM_SET_CELL_TYPE (z, scm_tc16_sfport | scm_i_mode_bits (modes));
SCM_SETSTREAM (z, SCM_UNPACK (pv));
scm_mutex_unlock (&scm_i_port_table_mutex);