mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-11 06:20:23 +02:00
(scm_primitive_load): Use scm_i_frame_current_load_port instead of
scm_internal_dynamic_wind.
This commit is contained in:
parent
bf6de59d5b
commit
b5623573b4
1 changed files with 13 additions and 30 deletions
|
@ -61,28 +61,6 @@
|
||||||
Applied to the full name of the file. */
|
Applied to the full name of the file. */
|
||||||
static SCM *scm_loc_load_hook;
|
static SCM *scm_loc_load_hook;
|
||||||
|
|
||||||
static void
|
|
||||||
swap_port (void *data)
|
|
||||||
{
|
|
||||||
SCM *save_port = data, tmp = scm_cur_loadp;
|
|
||||||
scm_cur_loadp = *save_port;
|
|
||||||
*save_port = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SCM
|
|
||||||
load (void *data)
|
|
||||||
{
|
|
||||||
SCM port = SCM_PACK (data);
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
SCM form = scm_read (port);
|
|
||||||
if (SCM_EOF_OBJECT_P (form))
|
|
||||||
break;
|
|
||||||
scm_primitive_eval_x (form);
|
|
||||||
}
|
|
||||||
return SCM_UNSPECIFIED;
|
|
||||||
}
|
|
||||||
|
|
||||||
SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0,
|
SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0,
|
||||||
(SCM filename),
|
(SCM filename),
|
||||||
"Load the file named @var{filename} and evaluate its contents in\n"
|
"Load the file named @var{filename} and evaluate its contents in\n"
|
||||||
|
@ -104,14 +82,19 @@ SCM_DEFINE (scm_primitive_load, "primitive-load", 1, 0, 0,
|
||||||
scm_call_1 (hook, filename);
|
scm_call_1 (hook, filename);
|
||||||
|
|
||||||
{ /* scope */
|
{ /* scope */
|
||||||
SCM port, save_port;
|
SCM port = scm_open_file (filename, scm_from_locale_string ("r"));
|
||||||
port = scm_open_file (filename, scm_from_locale_string ("r"));
|
scm_frame_begin (SCM_F_FRAME_REWINDABLE);
|
||||||
save_port = port;
|
scm_i_frame_current_load_port (port);
|
||||||
scm_internal_dynamic_wind (swap_port,
|
|
||||||
load,
|
while (1)
|
||||||
swap_port,
|
{
|
||||||
(void *) SCM_UNPACK (port),
|
SCM form = scm_read (port);
|
||||||
&save_port);
|
if (SCM_EOF_OBJECT_P (form))
|
||||||
|
break;
|
||||||
|
scm_primitive_eval_x (form);
|
||||||
|
}
|
||||||
|
|
||||||
|
scm_frame_end ();
|
||||||
scm_close_port (port);
|
scm_close_port (port);
|
||||||
}
|
}
|
||||||
return SCM_UNSPECIFIED;
|
return SCM_UNSPECIFIED;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue