summaryrefslogtreecommitdiff
path: root/debian/patches/bootshell0005-bootshell-add-facility-to-load-embedded-scripts.patch
blob: e5ec18821b8c90ffa4e68c3c1daab92d91d3a028 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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