summaryrefslogtreecommitdiff
path: root/libguile/strports.c
diff options
context:
space:
mode:
Diffstat (limited to 'libguile/strports.c')
-rw-r--r--libguile/strports.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/libguile/strports.c b/libguile/strports.c
index f718c07cb..30ce38509 100644
--- a/libguile/strports.c
+++ b/libguile/strports.c
@@ -250,13 +250,12 @@ scm_mkstrport (SCM pos, SCM str, long modes, const char *caller)
{
SCM z;
scm_t_port *pt;
- size_t str_len;
+ size_t str_len, c_pos;
- SCM_ASSERT (SCM_INUMP(pos) && SCM_INUM(pos) >= 0, pos, SCM_ARG1, caller);
SCM_ASSERT (SCM_STRINGP (str), str, SCM_ARG1, caller);
str_len = SCM_STRING_LENGTH (str);
- if (SCM_INUM (pos) > str_len)
- scm_out_of_range (caller, pos);
+ c_pos = scm_to_unsigned_integer (pos, 0, str_len);
+
if (!((modes & SCM_WRTNG) || (modes & SCM_RDNG)))
scm_misc_error ("scm_mkstrport", "port must read or write", SCM_EOL);
@@ -266,7 +265,7 @@ scm_mkstrport (SCM pos, SCM str, long modes, const char *caller)
SCM_SETSTREAM (z, SCM_UNPACK (str));
SCM_SET_CELL_TYPE(z, scm_tc16_strport|modes);
pt->write_buf = pt->read_buf = SCM_STRING_UCHARS (str);
- pt->read_pos = pt->write_pos = pt->read_buf + SCM_INUM (pos);
+ pt->read_pos = pt->write_pos = pt->read_buf + c_pos;
pt->write_buf_size = pt->read_buf_size = str_len;
pt->write_end = pt->read_end = pt->read_buf + pt->read_buf_size;