Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Feb 2018 20:21:22 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r329927 - head/stand/lua
Message-ID:  <201802242021.w1OKLMvc076925@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Sat Feb 24 20:21:21 2018
New Revision: 329927
URL: https://svnweb.freebsd.org/changeset/base/329927

Log:
  lualoader: Clean up naming conventions a little bit
  
  We mostly use camel case for function names, but some local functions got
  mixed in using internal underscores. Doubles down on camel case.

Modified:
  head/stand/lua/cli.lua
  head/stand/lua/config.lua
  head/stand/lua/core.lua
  head/stand/lua/drawer.lua
  head/stand/lua/menu.lua
  head/stand/lua/password.lua

Modified: head/stand/lua/cli.lua
==============================================================================
--- head/stand/lua/cli.lua	Sat Feb 24 20:19:31 2018	(r329926)
+++ head/stand/lua/cli.lua	Sat Feb 24 20:21:21 2018	(r329927)
@@ -38,7 +38,7 @@ local cli = {}
 -- Defaults to nil and "" respectively.
 -- This will also parse arguments to autoboot, but the with_kernel argument
 -- will need to be explicitly overwritten to false
-local function parse_boot_args(argv, with_kernel)
+local function parseBootArgs(argv, with_kernel)
 	if with_kernel == nil then
 		with_kernel = true
 	end
@@ -95,17 +95,17 @@ end
 
 function cli.boot(...)
 	local _, argv = cli.arguments(...)
-	local kernel, argstr = parse_boot_args(argv)
+	local kernel, argstr = parseBootArgs(argv)
 	if kernel ~= nil then
 		loader.perform("unload")
-		config.selectkernel(kernel)
+		config.selectKernel(kernel)
 	end
 	core.boot(argstr)
 end
 
 function cli.autoboot(...)
 	local _, argv = cli.arguments(...)
-	local argstr = parse_boot_args(argv, false)
+	local argstr = parseBootArgs(argv, false)
 	core.autoboot(argstr)
 end
 

Modified: head/stand/lua/config.lua
==============================================================================
--- head/stand/lua/config.lua	Sat Feb 24 20:19:31 2018	(r329926)
+++ head/stand/lua/config.lua	Sat Feb 24 20:21:21 2018	(r329927)
@@ -124,7 +124,7 @@ pattern_table = {
 	}
 }
 
-local function read_file(name, silent)
+local function readFile(name, silent)
 	local f = io.open(name)
 	if f == nil then
 		if not silent then
@@ -146,13 +146,13 @@ local function read_file(name, silent)
 	return text
 end
 
-local function check_nextboot()
+local function checkNextboot()
 	local nextboot_file = loader.getenv("nextboot_file")
 	if nextboot_file == nil then
 		return
 	end
 
-	local text = read_file(nextboot_file, true)
+	local text = readFile(nextboot_file, true)
 	if text == nil then
 		return
 	end
@@ -169,7 +169,7 @@ local function check_nextboot()
 
 	-- Attempt to rewrite the first line and only the first line of the
 	-- nextboot_file. We overwrite it with nextboot_enable="NO", then
-	-- check for that on load. See: check_nextboot_enabled
+	-- check for that on load. See: checkNextboot_enabled
 	-- It's worth noting that this won't work on every filesystem, so we
 	-- won't do anything notable if we have any errors in this process.
 	local nfile = io.open(nextboot_file, 'w')
@@ -336,7 +336,7 @@ function config.processFile(name, silent)
 		silent = false
 	end
 
-	local text = read_file(name, silent)
+	local text = readFile(name, silent)
 	if text == nil then
 		return not silent
 	end
@@ -386,11 +386,11 @@ end
 
 -- other_kernel is optionally the name of a kernel to load, if not the default
 -- or autoloaded default from the module_path
-function config.loadkernel(other_kernel)
+function config.loadKernel(other_kernel)
 	local flags = loader.getenv("kernel_options") or ""
 	local kernel = other_kernel or loader.getenv("kernel")
 
-	local function try_load(names)
+	local function tryLoad(names)
 		for name in names:gmatch("([^;]+)%s*;?") do
 			local r = loader.perform("load " .. flags ..
 			    " " .. name)
@@ -401,7 +401,7 @@ function config.loadkernel(other_kernel)
 		return nil
 	end
 
-	local function load_bootfile()
+	local function loadBootfile()
 		local bootfile = loader.getenv("bootfile")
 
 		-- append default kernel name
@@ -411,12 +411,12 @@ function config.loadkernel(other_kernel)
 			bootfile = bootfile .. ";kernel"
 		end
 
-		return try_load(bootfile)
+		return tryLoad(bootfile)
 	end
 
 	-- kernel not set, try load from default module_path
 	if kernel == nil then
-		local res = load_bootfile()
+		local res = loadBootfile()
 
 		if res ~= nil then
 			-- Default kernel is loaded
@@ -441,7 +441,7 @@ function config.loadkernel(other_kernel)
 
 		for _, v in pairs(paths) do
 			loader.setenv("module_path", v)
-			res = load_bootfile()
+			res = loadBootfile()
 
 			-- succeeded, add path to module_path
 			if res ~= nil then
@@ -456,7 +456,7 @@ function config.loadkernel(other_kernel)
 
 		-- failed to load with ${kernel} as a directory
 		-- try as a file
-		res = try_load(kernel)
+		res = tryLoad(kernel)
 		if res ~= nil then
 			config.kernel_loaded = kernel
 			return true
@@ -467,7 +467,7 @@ function config.loadkernel(other_kernel)
 	end
 end
 
-function config.selectkernel(kernel)
+function config.selectKernel(kernel)
 	config.kernel_selected = kernel
 end
 
@@ -493,7 +493,7 @@ function config.load(file)
 		end
 	end
 
-	check_nextboot()
+	checkNextboot()
 
 	-- Cache the provided module_path at load time for later use
 	config.module_path = loader.getenv("module_path")
@@ -511,7 +511,7 @@ function config.loadelf()
 	local loaded
 
 	print("Loading kernel...")
-	loaded = config.loadkernel(kernel)
+	loaded = config.loadKernel(kernel)
 
 	if not loaded then
 		print("Failed to load any kernel")

Modified: head/stand/lua/core.lua
==============================================================================
--- head/stand/lua/core.lua	Sat Feb 24 20:19:31 2018	(r329926)
+++ head/stand/lua/core.lua	Sat Feb 24 20:21:21 2018	(r329927)
@@ -33,7 +33,7 @@ local config = require("config")
 
 local core = {}
 
-local function compose_loader_cmd(cmd_name, argstr)
+local function composeLoaderCmd(cmd_name, argstr)
 	if argstr ~= nil then
 		cmd_name = cmd_name .. " " .. argstr
 	end
@@ -238,12 +238,12 @@ end
 
 function core.autoboot(argstr)
 	config.loadelf()
-	loader.perform(compose_loader_cmd("autoboot", argstr))
+	loader.perform(composeLoaderCmd("autoboot", argstr))
 end
 
 function core.boot(argstr)
 	config.loadelf()
-	loader.perform(compose_loader_cmd("boot", argstr))
+	loader.perform(composeLoaderCmd("boot", argstr))
 end
 
 function core.isSingleUserBoot()

Modified: head/stand/lua/drawer.lua
==============================================================================
--- head/stand/lua/drawer.lua	Sat Feb 24 20:19:31 2018	(r329926)
+++ head/stand/lua/drawer.lua	Sat Feb 24 20:21:21 2018	(r329927)
@@ -45,7 +45,7 @@ local orb
 local none
 local none_shifted = false
 
-local function menu_entry_name(drawing_menu, entry)
+local function menuEntryName(drawing_menu, entry)
 	local name_handler = drawer.menu_name_handlers[entry.entry_type]
 
 	if name_handler ~= nil then
@@ -57,7 +57,7 @@ local function menu_entry_name(drawing_menu, entry)
 	return entry.name
 end
 
-local function shift_brand_text(shift)
+local function shiftBrandText(shift)
 	drawer.brand_position.x = drawer.brand_position.x + shift.x
 	drawer.brand_position.y = drawer.brand_position.y + shift.y
 	drawer.menu_position.x = drawer.menu_position.x + shift.x
@@ -288,7 +288,7 @@ function drawer.drawmenu(m)
 			entry_num = entry_num + 1
 			screen.setcursor(x, y + effective_line_num)
 
-			print(entry_num .. ". " .. menu_entry_name(m, e))
+			print(entry_num .. ". " .. menuEntryName(m, e))
 
 			-- fill the alias table
 			alias_table[tostring(entry_num)] = e
@@ -299,7 +299,7 @@ function drawer.drawmenu(m)
 			end
 		else
 			screen.setcursor(x, y + effective_line_num)
-			print(menu_entry_name(m, e))
+			print(menuEntryName(m, e))
 		end
 		::continue::
 	end
@@ -379,7 +379,7 @@ function drawer.drawlogo()
 	if logodef ~= nil and logodef.graphic == none then
 		-- centre brand and text if no logo
 		if not none_shifted then
-			shift_brand_text(logodef.shift)
+			shiftBrandText(logodef.shift)
 			none_shifted = true
 		end
 	elseif logodef == nil or logodef.graphic == nil or

Modified: head/stand/lua/menu.lua
==============================================================================
--- head/stand/lua/menu.lua	Sat Feb 24 20:19:31 2018	(r329926)
+++ head/stand/lua/menu.lua	Sat Feb 24 20:21:21 2018	(r329927)
@@ -315,7 +315,7 @@ menu.welcome = {
 				    #all_choices .. ")"
 			end,
 			func = function(_, choice, _)
-				config.selectkernel(choice)
+				config.selectKernel(choice)
 			end,
 			alias = {"k", "K"}
 		},

Modified: head/stand/lua/password.lua
==============================================================================
--- head/stand/lua/password.lua	Sat Feb 24 20:19:31 2018	(r329926)
+++ head/stand/lua/password.lua	Sat Feb 24 20:21:21 2018	(r329927)
@@ -65,7 +65,7 @@ function password.check()
 	screen.clear()
 	screen.defcursor()
 	-- pwd is optionally supplied if we want to check it
-	local function do_prompt(prompt, pwd)
+	local function doPrompt(prompt, pwd)
 		while true do
 			loader.printc(prompt)
 			local read_pwd = password.read()
@@ -82,7 +82,7 @@ function password.check()
 		if pwd == nil then
 			return
 		end
-		do_prompt(prompt, pwd)
+		doPrompt(prompt, pwd)
 	end
 
 	local boot_pwd = loader.getenv("bootlock_password")
@@ -90,7 +90,7 @@ function password.check()
 
 	local geli_prompt = loader.getenv("geom_eli_passphrase_prompt")
 	if geli_prompt ~= nil and geli_prompt:lower() == "yes" then
-		local passphrase = do_prompt("GELI Passphrase: ")
+		local passphrase = doPrompt("GELI Passphrase: ")
 		loader.setenv("kern.geom.eli.passphrase", passphrase)
 	end
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802242021.w1OKLMvc076925>