From 96e83482fba579979c8ff896d69ad3e72b5dd63a Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Sat, 2 Jun 2001 18:34:48 +0000 Subject: [PATCH] (scm_eval_string): Use scm_primitive_eval_x instead of scm_eval_x to allow module changes between the forms in the string. Set/restore module using scm_c_call_with_current_module. --- libguile/strports.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/libguile/strports.c b/libguile/strports.c index de9dfbc79..54a371fd2 100644 --- a/libguile/strports.c +++ b/libguile/strports.c @@ -447,6 +447,24 @@ scm_eval_0str (const char *expr) return scm_eval_string (scm_makfrom0str (expr)); } +static SCM +inner_eval_string (void *data) +{ + SCM port = (SCM)data; + SCM form; + SCM ans = SCM_UNSPECIFIED; + + /* Read expressions from that port; ignore the values. */ + while (!SCM_EOF_OBJECT_P (form = scm_read (port))) + ans = scm_primitive_eval_x (form); + + /* Don't close the port here; if we re-enter this function via a + continuation, then the next time we enter it, we'll get an error. + It's a string port anyway, so there's no advantage to closing it + early. */ + + return ans; +} SCM_DEFINE (scm_eval_string, "eval-string", 1, 0, 0, (SCM string), @@ -458,20 +476,8 @@ SCM_DEFINE (scm_eval_string, "eval-string", 1, 0, 0, { SCM port = scm_mkstrport (SCM_INUM0, string, SCM_OPN | SCM_RDNG, "scm_eval_0str"); - SCM form; - SCM ans = SCM_UNSPECIFIED; - SCM module = scm_interaction_environment (); - - /* Read expressions from that port; ignore the values. */ - while (!SCM_EOF_OBJECT_P (form = scm_read (port))) - ans = scm_eval_x (form, module); - - /* Don't close the port here; if we re-enter this function via a - continuation, then the next time we enter it, we'll get an error. - It's a string port anyway, so there's no advantage to closing it - early. */ - - return ans; + return scm_c_call_with_current_module (scm_interaction_environment (), + inner_eval_string, (void *)port); } #undef FUNC_NAME