+/* Given a null-terminated string EXPR containing a Scheme expression
+ read it, and return it as an SCM value. */
+SCM
+scm_read_0str (expr)
+ char *expr;
+{
+ SCM port = scm_mkstrport (SCM_MAKINUM (0),
+ scm_makfrom0str (expr),
+ SCM_OPN | SCM_RDNG,
+ "scm_eval_0str");
+ SCM form;
+
+ /* Read expressions from that port; ignore the values. */
+ form = scm_read (port, SCM_BOOL_F, SCM_BOOL_F);
+
+ scm_close_port (port);
+ return form;
+}
+
/* Given a null-terminated string EXPR containing Scheme program text,
- evaluate it, and discard the result. */
-void
+ evaluate it, and return the result of the last expression evaluated. */
+SCM
scm_eval_0str (expr)
char *expr;
{
SCM_OPN | SCM_RDNG,
"scm_eval_0str");
SCM form;
+ SCM ans;
/* Read expressions from that port; ignore the values. */
while ((form = scm_read (port, SCM_BOOL_F, SCM_BOOL_F)) != SCM_EOF_VAL)
- scm_eval_x (form);
+ ans = scm_eval_x (form);
scm_close_port (port);
+ return ans;
}
extern SCM scm_call_with_output_string SCM_P ((SCM proc));
extern SCM scm_strprint_obj SCM_P ((SCM obj));
extern SCM scm_call_with_input_string SCM_P ((SCM str, SCM proc));
-extern void scm_eval_0str SCM_P ((char *expr));
+extern SCM scm_read_0str SCM_P ((char *expr));
+extern SCM scm_eval_0str SCM_P ((char *expr));
extern void scm_init_strports SCM_P ((void));
#endif /* STRPORTSH */