tag.lua: check name argument to add() is valid

Signed-off-by: Perry Hargrave <perry.hargrave@gmail.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Perry Hargrave 2010-05-31 22:15:56 -07:00 committed by Julien Danjou
parent 5b86896c90
commit 4f754a0d41
1 changed files with 7 additions and 1 deletions

View File

@ -55,8 +55,14 @@ end
--- Add a tag.
-- @param name The tag name, a string
-- @param props The tags properties, a table
-- @return The created tag
-- @return The created tag or nil if not created.
-- If the name is a valid string then the tag will be created and each key,value
-- pair in 'props' table is iterated and applied to the tag. If the 'name'
-- argument is nil or its string length is zero then the function returns nil.
function add(name, props)
-- abort if the name is not provided
if not name or #(tostring(name)) == 0 then return end
local properties = props or {}
local newtag = capi.tag{name = name}
newtag.screen = properties.screen or capi.mouse.screen