-/* Copyright (C) 1995,1996 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1998 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307 USA
*
* As a special exception, the Free Software Foundation gives permission
* for additional uses of the text contained in its release of GUILE.
*
* If you write modifications of your own for GUILE, it is your choice
* whether to permit this exception to apply to your modifications.
- * If you do not wish that, delete this exception notice.
- */
+ * If you do not wish that, delete this exception notice. */
\f
#include <stdio.h>
*/
-static int prinstpt SCM_P ((SCM exp, SCM port, scm_print_state *pstate));
-
static int
-prinstpt (exp, port, pstate)
- SCM exp;
- SCM port;
- scm_print_state *pstate;
+prinstpt (SCM exp, SCM port, scm_print_state *pstate)
{
scm_prinport (exp, port, "string");
return !0;
}
-static int stputc SCM_P ((int c, SCM p));
-
static int
-stputc (c, p)
- int c;
- SCM p;
+stputc (int c, SCM port)
{
+ SCM p = SCM_STREAM (port);
scm_sizet ind = SCM_INUM (SCM_CAR (p));
SCM_DEFER_INTS;
if (ind >= SCM_LENGTH (SCM_CDR (p)))
}
-static scm_sizet stwrite SCM_P ((char *str, scm_sizet siz, scm_sizet num, SCM p));
-
static scm_sizet
-stwrite (str, siz, num, p)
- char *str;
- scm_sizet siz;
- scm_sizet num;
- SCM p;
+stwrite (char *str,
+ scm_sizet siz,
+ scm_sizet num,
+ SCM port)
{
+ SCM p = SCM_STREAM (port);
+
scm_sizet ind = SCM_INUM (SCM_CAR (p));
scm_sizet len = siz * num;
char *dst;
}
-static int stputs SCM_P ((char *s, SCM p));
-
static int
-stputs (s, p)
- char *s;
- SCM p;
+stputs (char *s, SCM port)
{
- stwrite (s, 1, strlen (s), p);
+ stwrite (s, 1, strlen (s), port);
return 0;
}
-static int stgetc SCM_P ((SCM p));
-
static int
-stgetc (p)
- SCM p;
+stgetc (SCM port)
{
+ SCM p = SCM_STREAM (port);
+
scm_sizet ind = SCM_INUM (SCM_CAR (p));
if (ind >= SCM_ROLENGTH (SCM_CDR (p)))
return EOF;
SCM form;
/* Read expressions from that port; ignore the values. */
- form = scm_read (port, SCM_BOOL_F, SCM_BOOL_F);
+ form = scm_read (port);
scm_close_port (port);
return form;
scm_eval_0str (expr)
char *expr;
{
- SCM port = scm_mkstrport (SCM_MAKINUM (0),
- scm_makfrom0str (expr),
- SCM_OPN | SCM_RDNG,
+ return scm_eval_string (scm_makfrom0str (expr));
+}
+
+
+SCM_PROC (s_eval_string, "eval-string", 1, 0, 0, scm_eval_string);
+
+SCM
+scm_eval_string (string)
+ SCM string;
+{
+ SCM port = scm_mkstrport (SCM_MAKINUM (0), string, SCM_OPN | SCM_RDNG,
"scm_eval_0str");
SCM form;
- SCM ans = SCM_EOL;
+ SCM ans = SCM_UNSPECIFIED;
/* Read expressions from that port; ignore the values. */
- while ((form = scm_read (port, SCM_BOOL_F, SCM_BOOL_F)) != SCM_EOF_VAL)
+ while (!SCM_EOF_OBJECT_P (form = scm_read (port)))
ans = scm_eval_x (form);
- scm_close_port (port);
+ /* 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;
}
+
static int noop0 SCM_P ((SCM stream));
static int
stwrite,
noop0,
stgetc,
+ scm_generic_fgets,
0
};