mirror of
https://github.com/opnsense/src.git
synced 2026-06-04 06:15:33 -04:00
loader: Simplify the loader.has_command
luaL_checkstring already checks for the right number of arguments. There's no need to do that by hand here. Now an exception will be thrown like any other function with the wrong args. Also, push a boolean instead of an int. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43820
This commit is contained in:
parent
33a2406eed
commit
7fc95c31f0
1 changed files with 6 additions and 5 deletions
|
|
@ -65,14 +65,15 @@ lua_has_command(lua_State *L)
|
|||
{
|
||||
const char *cmd;
|
||||
|
||||
if (lua_gettop(L) != 1) {
|
||||
lua_pushnil(L);
|
||||
cmd = luaL_checkstring(L, 1);
|
||||
if (interp_has_builtin_cmd(cmd)) {
|
||||
lua_pushboolean(L, 1);
|
||||
return 1;
|
||||
}
|
||||
cmd = luaL_checkstring(L, 1);
|
||||
lua_pushinteger(L, interp_has_builtin_cmd(cmd));
|
||||
|
||||
return 1;
|
||||
lua_pushnil(L);
|
||||
lua_pushstring(L, "Builtin command not found");
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
|||
Loading…
Reference in a new issue