From nobody Fri Feb 16 04:00:21 2024 X-Original-To: dev-commits-src-main@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 4TbdW924cbz59Yxd; Fri, 16 Feb 2024 04:00:21 +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 4TbdW91dTCz4H7c; Fri, 16 Feb 2024 04:00:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708056021; 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=IFtuAHsV90ZmUt+kqcQL4erNzAU/gPLxkXBRKOfjK4A=; b=vzpubdkwJB0i11pDUKneSCbNZkDJ4H5cgkBmbjNfYV+JtYsyTzW/E5iBOvsT+G549bAwxX c1oRRELrH/t9YLmaUfs0TFtHJXXW1A68l76i3lRvYVeyxEgJ4AeckKPU/jyTR9gOCLTYst q679Oz7+WVfcHO76RSYzjEnpRaIOo8KQaRclRYOJDCXSYV7gHYxQHveFWODqRwLcRaHnwT tmdzI28zJGNLrVNdZWQv+T2B1yWfJLWeqQYr3lKmf7bVzk6zZ/g6ZmZKi02F+z+PuNhb3/ SHs/UGVxT7un0L0CCrSGkvCh1k9+PhW/89nA/PQq14GxpL4f6QQu2MNNF5yS2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708056021; 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=IFtuAHsV90ZmUt+kqcQL4erNzAU/gPLxkXBRKOfjK4A=; b=kriQ2prYQAbb/7pCPyNKbuxl+Bs6QlsRobZssEu74zK9JW+a3ogSWYFnpbeHPvbwMTvnFY wvHH9eqYc1jj7alL52SJTBn6AYw0IzwNOH68t0X+12Po5omsVOd+c9yt+RHup/t0PwboT9 zXN6sEQlLals1jzKPDqZo0aFXKvWX33Qr2u9KvYmOB79IhBVncokH1f2yxVEyik2dckm0s w4Lhk6kifcUZ58XFTftO/g3RtTLy3BMIWu9R+1BTvTC3062RcTpvQs7r8gXHAQsybYVRP5 cjubOpW8+Imjqn/Ot7pm+HNlJ41NeftNLiECTElnsCgBfrPbGWejL6+CI3PlMA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708056021; a=rsa-sha256; cv=none; b=GV9USp+9xyBfoT7Lw6V5296vdsOszOoJZNO0JUdeWluvD5dAS6buIR2jDtKPxS6xXJ71lJ FzDucOrvGYbkXkOnp1vyariuV6Jo2avZ//IwWkw0MsPI/dO14dcVZ9ocn0jE2RdzYDyoBy zq28GbeNjQ83MF1EcrJ4xh8f12Vp2RnVAwb7LY/QUSOKMNXcE5wkedJbwsfXO744RhZne9 aGoWUDW9rgqj236vOc9Bj215DIaiR2Iur0t7euN1N8uuTDZd5bnX535UbNOYRvVCf2yDGx /G2ZUYikY+uqmTZHVYa2eTAa9E/pX/pMmJ6QDuSdpp0LFNp0sdNO8/VErQyQQw== 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 4TbdW90lTGz18Jj; Fri, 16 Feb 2024 04:00:21 +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 41G40LkI018765; Fri, 16 Feb 2024 04:00:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41G40LGi018762; Fri, 16 Feb 2024 04:00:21 GMT (envelope-from git) Date: Fri, 16 Feb 2024 04:00:21 GMT Message-Id: <202402160400.41G40LGi018762@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 7fc95c31f007 - main - loader: Simplify the loader.has_command List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 7fc95c31f007ef01c53aa5f9d8802e9579f408ee Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=7fc95c31f007ef01c53aa5f9d8802e9579f408ee commit 7fc95c31f007ef01c53aa5f9d8802e9579f408ee Author: Warner Losh AuthorDate: 2024-02-16 03:52:41 +0000 Commit: Warner Losh CommitDate: 2024-02-16 03:59:22 +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 --- 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