1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

* * strports.c, strports.h: Make scm_eval_0str return the value of

the last expression evaluated (previously, it returned void).

*	* strports.c, strports.h: New function: scm_read_0str.  Does what
	it sounds like.
This commit is contained in:
Mikael Djurfeldt 1996-12-13 19:41:18 +00:00
parent dbe2648143
commit a8aa30d896
2 changed files with 29 additions and 7 deletions

View file

@ -229,10 +229,10 @@ scm_call_with_input_string (str, proc)
/* Given a null-terminated string EXPR containing Scheme program text,
evaluate it, and discard the result. */
void
scm_eval_0str (expr)
/* 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),
@ -242,10 +242,31 @@ scm_eval_0str (expr)
SCM form;
/* 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);
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 return the result of the last expression evaluated. */
SCM
scm_eval_0str (expr)
char *expr;
{
SCM port = scm_mkstrport (SCM_MAKINUM (0),
scm_makfrom0str (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)
ans = scm_eval_x (form);
scm_close_port (port);
return ans;
}

View file

@ -54,7 +54,8 @@ extern SCM scm_mkstrport SCM_P ((SCM pos, SCM str, long modes, char * caller));
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 */