From owner-svn-src-head@freebsd.org Sun Apr 1 00:22:52 2018 Return-Path: Delivered-To: svn-src-head@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 0EF98F6B3BA; Sun, 1 Apr 2018 00:22:52 +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 AF0AC7EBBB; Sun, 1 Apr 2018 00:22:51 +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 A71091F204; Sun, 1 Apr 2018 00:22:51 +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 w310Mphn024400; Sun, 1 Apr 2018 00:22:51 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w310Mp8t024399; Sun, 1 Apr 2018 00:22:51 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201804010022.w310Mp8t024399@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Sun, 1 Apr 2018 00:22:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331857 - head/stand/lua X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/stand/lua X-SVN-Commit-Revision: 331857 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Apr 2018 00:22:52 -0000 Author: kevans Date: Sun Apr 1 00:22:51 2018 New Revision: 331857 URL: https://svnweb.freebsd.org/changeset/base/331857 Log: lualoader: Simplify some expressions - No need for a 'goto' when our entire loop body is then wrapped in a conditional. - No need to leave commented out prints laying around - If an expression is clearly going to be either nil or an expression that isn't likely to be a boolean, we might as well use `or` to specify a default value for the expression. e.g. `loader.getenv(...) or "no"` Modified: head/stand/lua/config.lua Modified: head/stand/lua/config.lua ============================================================================== --- head/stand/lua/config.lua Sat Mar 31 23:50:20 2018 (r331856) +++ head/stand/lua/config.lua Sun Apr 1 00:22:51 2018 (r331857) @@ -205,10 +205,7 @@ local function loadModule(mod, silent) local status = true local pstatus for k, v in pairs(mod) do - if v.load == nil then - goto continue - end - if v.load:lower() == "yes" then + if v.load ~= nil and v.load:lower() == "yes" then local str = "load " if v.flags ~= nil then str = str .. v.flags .. " " @@ -247,12 +244,7 @@ local function loadModule(mod, silent) status = status and pstatus end --- else --- if not silent then --- print("Skipping module '". . k .. "'") --- end end - ::continue:: end return status @@ -272,11 +264,8 @@ local function readFile(name, silent) -- We might have read in the whole file, this won't be needed any more. io.close(f) - if text == nil then - if not silent then - print(MSG_FAILREADCFG:format(name)) - end - return nil + if text == nil and not silent then + print(MSG_FAILREADCFG:format(name)) end return text end @@ -322,11 +311,7 @@ config.verbose = false -- The first item in every carousel is always the default item. function config.getCarouselIndex(id) - local val = carousel_choices[id] - if val == nil then - return 1 - end - return val + return carousel_choices[id] or 1 end function config.setCarouselIndex(id, idx) @@ -498,10 +483,7 @@ function config.load(file) -- Cache the provided module_path at load time for later use config.module_path = loader.getenv("module_path") - local verbose = loader.getenv("verbose_loading") - if verbose == nil then - verbose = "no" - end + local verbose = loader.getenv("verbose_loading") or "no" config.verbose = verbose:lower() == "yes" end