svn commit: r280947 - projects/lua-bootloader/sys/boot/common
Rui Paulo
rpaulo at FreeBSD.org
Wed Apr 1 05:55:05 UTC 2015
Author: rpaulo
Date: Wed Apr 1 05:55:03 2015
New Revision: 280947
URL: https://svnweb.freebsd.org/changeset/base/280947
Log:
Parse lines as loader commands if we could not parse it as Lua.
This lets us type 'reset', 'boot', etc. in the interpreter. Forth has
an advantage here because it compiles the loader commands as verbs, so
it automatically executes Forth verbs (functions).
The loader command syntax is very different from Lua syntax, so this
workaround should be good enough.
Modified:
projects/lua-bootloader/sys/boot/common/interp_lua.c
Modified: projects/lua-bootloader/sys/boot/common/interp_lua.c
==============================================================================
--- projects/lua-bootloader/sys/boot/common/interp_lua.c Wed Apr 1 05:46:57 2015 (r280946)
+++ projects/lua-bootloader/sys/boot/common/interp_lua.c Wed Apr 1 05:55:03 2015 (r280947)
@@ -88,12 +88,26 @@ interp_lua_run(void *data, const char *l
struct interp_lua_softc *softc;
int argc, ret;
char **argv;
+ char loader_line[128];
+ int status;
+ int len;
softc = data;
luap = softc->luap;
- LDBG("running line...");
- if (ldo_string(luap, line, strlen(line)) != 0)
- printf("failed to parse \'%s\'\n", line);
+ LDBG("executing line...");
+ if ((status = ldo_string(luap, line, strlen(line))) != 0) {
+ /*
+ * If we could not parse the line as Lua syntax,
+ * try parsing it as a loader command.
+ */
+ len = snprintf(loader_line, sizeof(loader_line),
+ "loader.perform(\"%s\")", line);
+ if (len > 0)
+ status = ldo_string(luap, loader_line,
+ len + 1);
+ }
+ if (status != 0)
+ printf("Failed to parse \'%s\'\n", line);
return (0);
}
More information about the svn-src-projects
mailing list