summaryrefslogtreecommitdiff
path: root/libguile/ports.c
diff options
context:
space:
mode:
Diffstat (limited to 'libguile/ports.c')
-rw-r--r--libguile/ports.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/libguile/ports.c b/libguile/ports.c
index 50e73dd35..6c763c1c7 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -1226,7 +1226,7 @@ swap_buffer (void *data)
}
size_t
-scm_c_read (SCM port, void *buffer, size_t size)
+scm_c_read_unlocked (SCM port, void *buffer, size_t size)
#define FUNC_NAME "scm_c_read"
{
scm_t_port *pt;
@@ -1329,6 +1329,18 @@ scm_c_read (SCM port, void *buffer, size_t size)
}
#undef FUNC_NAME
+size_t
+scm_c_read (SCM port, void *buffer, size_t size)
+{
+ size_t ret;
+
+ scm_c_lock_port (port);
+ ret = scm_c_read_unlocked (port, buffer, size);
+ scm_c_unlock_port (port);
+
+ return ret;
+}
+
/* Update the line and column number of PORT after consumption of C. */
static inline void
update_port_lf (scm_t_wchar c, SCM port)
@@ -1633,7 +1645,7 @@ get_codepoint (SCM port, scm_t_wchar *codepoint,
/* Read a codepoint from PORT and return it. */
scm_t_wchar
-scm_getc (SCM port)
+scm_getc_unlocked (SCM port)
#define FUNC_NAME "scm_getc"
{
int err;
@@ -1651,6 +1663,18 @@ scm_getc (SCM port)
}
#undef FUNC_NAME
+scm_t_wchar
+scm_getc (SCM port)
+{
+ scm_t_wchar ret;
+
+ scm_c_lock_port (port);
+ ret = scm_getc_unlocked (port);
+ scm_c_unlock_port (port);
+
+ return ret;
+}
+
SCM_DEFINE (scm_read_char, "read-char", 0, 1, 0,
(SCM port),
"Return the next character available from @var{port}, updating\n"
@@ -1666,7 +1690,7 @@ SCM_DEFINE (scm_read_char, "read-char", 0, 1, 0,
if (SCM_UNBNDP (port))
port = scm_current_input_port ();
SCM_VALIDATE_OPINPORT (1, port);
- c = scm_getc (port);
+ c = scm_getc_unlocked (port);
if (EOF == c)
return SCM_EOF_VAL;
return SCM_MAKE_CHAR (c);