From owner-svn-src-all@freebsd.org Sat Mar 3 17:13:13 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4139AF2A829; Sat, 3 Mar 2018 17:13:13 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D1E6D6BD92; Sat, 3 Mar 2018 17:13:12 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C6FE312E2; Sat, 3 Mar 2018 17:13:12 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w23HDCQl036762; Sat, 3 Mar 2018 17:13:12 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w23HDCYw036761; Sat, 3 Mar 2018 17:13:12 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201803031713.w23HDCYw036761@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sat, 3 Mar 2018 17:13:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330339 - head/stand/liblua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/liblua X-SVN-Commit-Revision: 330339 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Mar 2018 17:13:13 -0000 Author: kevans Date: Sat Mar 3 17:13:12 2018 New Revision: 330339 URL: https://svnweb.freebsd.org/changeset/base/330339 Log: liblua: Add loader.interpret This allows lua to pass back a command string to be executed as if it were typed at the loader prompt- loader tries to execute the string first as pure lua, then parses it and gives lua a chance to intercept before it tries to execute it itself. This will be used to implement menu_timeout_command, among other things, which *should* be used to execute basic loader commands independent of the chosen interpreter. Modified: head/stand/liblua/lutils.c Modified: head/stand/liblua/lutils.c ============================================================================== --- head/stand/liblua/lutils.c Sat Mar 3 15:10:37 2018 (r330338) +++ head/stand/liblua/lutils.c Sat Mar 3 17:13:12 2018 (r330339) @@ -77,7 +77,26 @@ lua_perform(lua_State *L) return 1; } +/* + * Accepts a space-delimited loader command and runs it through the standard + * loader parsing, as if it were executed at the loader prompt by the user. + */ static int +lua_interpret(lua_State *L) +{ + const char *interp_string; + + if (lua_gettop(L) != 1) { + lua_pushnil(L); + return 1; + } + + interp_string = luaL_checkstring(L, 1); + lua_pushinteger(L, interp_run(interp_string)); + return 1; +} + +static int lua_getchar(lua_State *L) { @@ -305,6 +324,7 @@ lua_writefile(lua_State *L) static const struct luaL_Reg loaderlib[] = { REG_SIMPLE(delay), REG_SIMPLE(command), + REG_SIMPLE(interpret), REG_SIMPLE(getenv), REG_SIMPLE(perform), /* Also registered as the global 'printc' */