From b0b13e37a60ca3d3232fa154b7f195d542fea411 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Sat, 24 Jan 2015 01:54:52 +0100 Subject: [PATCH hurd 05/10] bootshell: add facility to load embedded scripts * bootshell/scheme.c (scheme_load_mem): New function. --- bootshell/scheme.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/bootshell/scheme.c b/bootshell/scheme.c index 99f9106..94c2307 100644 --- a/bootshell/scheme.c +++ b/bootshell/scheme.c @@ -5049,3 +5049,27 @@ Local variables: c-file-style: "k&r" End: */ + +/* Like scheme_load_string, but does not rely on a terminating zero. */ +void +scheme_load_mem (scheme *sc, const char *cmd_start, const char *cmd_end) +{ + dump_stack_reset(sc); + sc->envir = sc->global_env; + sc->file_i=0; + sc->load_stack[0].kind=port_input|port_string; + /* This func respects const */ + sc->load_stack[0].rep.string.start=(char*) cmd_start; + sc->load_stack[0].rep.string.past_the_end=(char*) cmd_end; + sc->load_stack[0].rep.string.curr=(char*) cmd_start; + sc->loadport=mk_port(sc,sc->load_stack); + sc->retcode=0; + sc->interactive_repl=0; + sc->inport=sc->loadport; + sc->args = mk_integer(sc,sc->file_i); + Eval_Cycle(sc, OP_T0LVL); + typeflag(sc->loadport)=T_ATOM; + if(sc->retcode==0) { + sc->retcode=sc->nesting!=0; + } +} -- 2.1.4