From nobody Tue Apr 16 20:12:42 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VJwFQ3BBTz5HT5Z; Tue, 16 Apr 2024 20:12:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VJwFQ268Lz4t2c; Tue, 16 Apr 2024 20:12:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713298362; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kLLqox1usmukP3K7oe34aDqPeR0MJtGlsMqocSmdGPk=; b=HzNNGZwSAPwzHGS4IHSW08/IRujhRsEyyfBRmPhI+ECH8sp0x/upnBXgz9HAfw3yb1qceS Zfq84UzxfJ8ppnWj+/GzNQ9Ekm36zR19i6NPDU+Sj5+9F3WGHTr9iYtd8dGTvx//J6A93p rqCAJ0d8tK4H50HHugA/TgOHfaMxEZGCc2uaQRO+CrRZt/EB25c5PJ42yRiUCOWPQa9gE4 h10q3t0229iY935vtog8wlcNX++hDH98eO5/fl3GLyAiSHHyYakeq7kDb9WDQMdDbFsnQV 3RWGwJU1Twe1jFh2A031/xvl5sEyph0IZBOL3QqrtyEq3rZ/lFxfBVy752GfYA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713298362; a=rsa-sha256; cv=none; b=UiqbGiBKJqf04mvuABNiTgFI/m0c8gjKn4ZJL7Oa1KISTSNjIz4iTTXY6QEFKfJvGEp/K/ O6tUR74M1y7cq71t7v/Y6evJBUVMx8AtJGuOAwVDv40zdWnLUsug3jS2MJQ8Do6KB3EwvV aE3C7gKCJEwjISy3VYiNSecqhRUvdanQEXH8PbqEWAcM1asHsn6xuDAXQWLDw7TgYUws6U SqEHfUjicI9nLiLb/ZVczJgXQrU6gIwrn1HvSbIskD963OZtMjLLTvwRqEIkDLjBnSZHn6 DaO85qEC2epymHP/18uOxriW3REwRHCLV9Vj2XOzk8p3giQ+CuaJ3tLBPNItRQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713298362; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kLLqox1usmukP3K7oe34aDqPeR0MJtGlsMqocSmdGPk=; b=sgqLDYQSWSiq/4K+swkqCQYb5QMy2DEceupTTnUodPJnHquxx00+Qow2NSVPVHhlbRnUqj W01JRdoJ4a/J+WUT3RHw/DAP6KBjPXpOTBRMh2gUQTZGFFQN5bgndJ85QEAEgbpJocptzc VI5FVj6X2c0QvmrjNFSelOFmcHgcwbnBZUjPaIm6nDMKcboIPpGixG3BpRssfaP3P5Ng+H U1e37CixjraZtLmIqlpA7gqepA0Rq1ptn6p4/F1MUkYLLN/j43AHFONGCC07lGzKmsAzbz 7uw3k50CumoTNThF9hSV3QDQHLPK1VEr/IKGCrFK/hcTI/jtoQ5AkMyzJKAHqw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VJwFQ1gwgzwhd; Tue, 16 Apr 2024 20:12:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43GKCgRA037644; Tue, 16 Apr 2024 20:12:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43GKCgCT037641; Tue, 16 Apr 2024 20:12:42 GMT (envelope-from git) Date: Tue, 16 Apr 2024 20:12:42 GMT Message-Id: <202404162012.43GKCgCT037641@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: c54653978ebd - stable/14 - loader: Simplify the loader.has_command List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: c54653978ebd2ad8f6cea4b8220bb620b1f3db40 Auto-Submitted: auto-generated The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=c54653978ebd2ad8f6cea4b8220bb620b1f3db40 commit c54653978ebd2ad8f6cea4b8220bb620b1f3db40 Author: Warner Losh AuthorDate: 2024-02-16 03:52:41 +0000 Commit: Warner Losh CommitDate: 2024-04-16 19:54:23 +0000 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 (cherry picked from commit 7fc95c31f007ef01c53aa5f9d8802e9579f408ee) --- stand/liblua/lutils.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/stand/liblua/lutils.c b/stand/liblua/lutils.c index 8066d3f685f7..182bd699dbc3 100644 --- a/stand/liblua/lutils.c +++ b/stand/liblua/lutils.c @@ -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