mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-13 05:41:26 +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 */
|
||||
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 */
|
||||
|
||||
/* interp_backslash.c */
|
||||
|
@ -60,6 +60,7 @@ interact(void)
|
||||
* we need to switch interpreters.
|
||||
*/
|
||||
interp_identifier = bootprog_interp;
|
||||
interp_preinit();
|
||||
interp_init();
|
||||
|
||||
printf("\n");
|
||||
|
@ -337,12 +337,21 @@ bf_run(const char *line)
|
||||
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
|
||||
interp_init(void)
|
||||
{
|
||||
|
||||
setenv("script.lang", "forth", 1);
|
||||
bf_init();
|
||||
/* Read our default configuration. */
|
||||
interp_include("/boot/loader.rc");
|
||||
}
|
||||
|
@ -96,17 +96,21 @@ static const luaL_Reg loadedlibs[] = {
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
static bool preinit_done = false;
|
||||
|
||||
void
|
||||
interp_init(void)
|
||||
interp_preinit(void)
|
||||
{
|
||||
lua_State *luap;
|
||||
struct interp_lua_softc *softc = &lua_softc;
|
||||
const char *filename;
|
||||
const luaL_Reg *lib;
|
||||
lua_init_md_t **fnpp;
|
||||
|
||||
TSENTER();
|
||||
|
||||
if (preinit_done)
|
||||
return;
|
||||
|
||||
setenv("script.lang", "lua", 1);
|
||||
LDBG("creating context");
|
||||
|
||||
@ -126,6 +130,21 @@ interp_init(void)
|
||||
LUA_FOREACH_SET(fnpp)
|
||||
(*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");
|
||||
if (filename == NULL)
|
||||
filename = LOADER_LUA;
|
||||
|
@ -34,6 +34,11 @@
|
||||
|
||||
INTERP_DEFINE("simp");
|
||||
|
||||
void
|
||||
interp_preinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
interp_init(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user