mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-14 06:12:01 +01:00
loader: separate lang init from scripting init
Create interp_preinit() to initialize the scripting language to run scripts. Make sure you can call it multiple times, but only the first one has effect, After it's call, you can run scripts in the scripting language. At the moment, no functional change. Sponsored by: Netflix
This commit is contained in:
parent
1d7bdae9ca
commit
68344c9c6c
@ -54,7 +54,8 @@ bool interp_has_builtin_cmd(const char *cmd);
|
|||||||
|
|
||||||
/* Called by interp.c for interp_*.c embedded interpreters */
|
/* Called by interp.c for interp_*.c embedded interpreters */
|
||||||
int interp_include(const char *); /* Execute commands from filename */
|
int interp_include(const char *); /* Execute commands from filename */
|
||||||
void interp_init(void); /* Initialize interpreater */
|
void interp_preinit(void); /* Initialize interpreater execution engine */
|
||||||
|
void interp_init(void); /* Initialize interpreater and run main script */
|
||||||
int interp_run(const char *); /* Run a single command */
|
int interp_run(const char *); /* Run a single command */
|
||||||
|
|
||||||
/* interp_backslash.c */
|
/* interp_backslash.c */
|
||||||
|
@ -60,6 +60,7 @@ interact(void)
|
|||||||
* we need to switch interpreters.
|
* we need to switch interpreters.
|
||||||
*/
|
*/
|
||||||
interp_identifier = bootprog_interp;
|
interp_identifier = bootprog_interp;
|
||||||
|
interp_preinit();
|
||||||
interp_init();
|
interp_init();
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -337,12 +337,21 @@ bf_run(const char *line)
|
|||||||
return (result);
|
return (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool preinit_run = false;
|
||||||
|
|
||||||
|
void
|
||||||
|
interp_preinit(void)
|
||||||
|
{
|
||||||
|
if (preinit_run)
|
||||||
|
return;
|
||||||
|
setenv("script.lang", "forth", 1);
|
||||||
|
bf_init();
|
||||||
|
preinit_run = true;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
interp_init(void)
|
interp_init(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
setenv("script.lang", "forth", 1);
|
|
||||||
bf_init();
|
|
||||||
/* Read our default configuration. */
|
/* Read our default configuration. */
|
||||||
interp_include("/boot/loader.rc");
|
interp_include("/boot/loader.rc");
|
||||||
}
|
}
|
||||||
|
@ -96,17 +96,21 @@ static const luaL_Reg loadedlibs[] = {
|
|||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool preinit_done = false;
|
||||||
|
|
||||||
void
|
void
|
||||||
interp_init(void)
|
interp_preinit(void)
|
||||||
{
|
{
|
||||||
lua_State *luap;
|
lua_State *luap;
|
||||||
struct interp_lua_softc *softc = &lua_softc;
|
struct interp_lua_softc *softc = &lua_softc;
|
||||||
const char *filename;
|
|
||||||
const luaL_Reg *lib;
|
const luaL_Reg *lib;
|
||||||
lua_init_md_t **fnpp;
|
lua_init_md_t **fnpp;
|
||||||
|
|
||||||
TSENTER();
|
TSENTER();
|
||||||
|
|
||||||
|
if (preinit_done)
|
||||||
|
return;
|
||||||
|
|
||||||
setenv("script.lang", "lua", 1);
|
setenv("script.lang", "lua", 1);
|
||||||
LDBG("creating context");
|
LDBG("creating context");
|
||||||
|
|
||||||
@ -126,6 +130,21 @@ interp_init(void)
|
|||||||
LUA_FOREACH_SET(fnpp)
|
LUA_FOREACH_SET(fnpp)
|
||||||
(*fnpp)(luap);
|
(*fnpp)(luap);
|
||||||
|
|
||||||
|
preinit_done = true;
|
||||||
|
|
||||||
|
TSEXIT();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
interp_init(void)
|
||||||
|
{
|
||||||
|
lua_State *luap;
|
||||||
|
struct interp_lua_softc *softc = &lua_softc;
|
||||||
|
const char *filename;
|
||||||
|
|
||||||
|
TSENTER();
|
||||||
|
|
||||||
|
luap = softc->luap;
|
||||||
filename = getenv("loader_lua");
|
filename = getenv("loader_lua");
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
filename = LOADER_LUA;
|
filename = LOADER_LUA;
|
||||||
|
@ -34,6 +34,11 @@
|
|||||||
|
|
||||||
INTERP_DEFINE("simp");
|
INTERP_DEFINE("simp");
|
||||||
|
|
||||||
|
void
|
||||||
|
interp_preinit(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
interp_init(void)
|
interp_init(void)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user