Commits

Jason Perkins  committed 479ad03 Merge

Merge with Premake-dev tip

  • Participants
  • Parent commits 4659476, be830ac

Comments (0)

Files changed (2)

 * Fix linking to external libraries outside of project folder
 * Improve processing of ld.so.conf (Cameron Hart)
 * Patch 154: Fix .def file support for VS2010 (Riccardo Ghetta)
+* Patch 159: Validate all values passed to options (Moi_ioM)
 
 
 -------

File src/base/option.lua

 --
 -- option.lua
 -- Work with the list of registered options.
--- Copyright (c) 2002-2009 Jason Perkins and the Premake project
+-- Copyright (c) 2002-2013 Jason Perkins and the Premake project
 --
 
-	premake.option = { }
+	premake.option = {}
 
 
 --
 -- The list of registered options.
 --
 
-	premake.option.list = { }
-	
+	premake.option.list = {}
+
 
 --
 -- Register a new option.
 --
 -- @param opt
 --    The new option object.
--- 
+--
 
 	function premake.option.add(opt)
 		-- some sanity checking
 				missing = field
 			end
 		end
-		
+
 		if (missing) then
 			error("option needs a " .. missing, 3)
 		end
-		
+
 		-- add it to the master list
 		premake.option.list[opt.trigger] = opt
 	end
 			table.insert(keys, option.trigger)
 		end
 		table.sort(keys)
-		
+
 		local i = 0
 		return function()
 			i = i + 1
 			if (not opt) then
 				return false, "invalid option '" .. key .. "'"
 			end
-			
+
 			-- does it need a value?
 			if (opt.value and value == "") then
 				return false, "no value specified for option '" .. key .. "'"
 			end
-			
+
 			-- is the value allowed?
-			if (opt.allowed) then
+			if opt.allowed then
+				local found = false
 				for _, match in ipairs(opt.allowed) do
-					if (match[1] == value) then return true end
+					if match[1] == value then
+						found = true
+						break
+					end
 				end
-				return false, "invalid value '" .. value .. "' for option '" .. key .. "'"
+				if not found then
+					return false, string.format("invalid value '%s' for option '%s'", value, key)
+				end
 			end
 		end
 		return true