summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <megas.kapaneus@gmail.com>2013-04-07 18:10:32 +0200
committerPhilipp Gesang <megas.kapaneus@gmail.com>2013-04-07 18:10:32 +0200
commit44173ba49717a356edf1c09f892f6909cad43481 (patch)
treefab8ac56a994832e29a441d075a618ebdd3ec373
parent6252afeb5d04e9860f9f4b587f269de1bcaa9489 (diff)
downloadlualibs-44173ba49717a356edf1c09f892f6909cad43481.tar.gz
update l-boolean
-rw-r--r--lualibs-boolean.lua16
1 files changed, 7 insertions, 9 deletions
diff --git a/lualibs-boolean.lua b/lualibs-boolean.lua
index 2b94de7..f087f1a 100644
--- a/lualibs-boolean.lua
+++ b/lualibs-boolean.lua
@@ -15,7 +15,7 @@ function boolean.tonumber(b)
if b then return 1 else return 0 end -- test and return or return
end
-function toboolean(str,tolerant)
+function toboolean(str,tolerant) -- global
if str == nil then
return false
elseif str == false then
@@ -40,18 +40,16 @@ end
string.toboolean = toboolean
function string.booleanstring(str)
- if str == nil then
- return false
- elseif str == false then
+ if str == "0" then
return false
- elseif str == true then
- return true
- elseif str == "true" then
+ elseif str == "1" then
return true
- elseif str == "false" then
+ elseif str == "" then
return false
- elseif str == 0 then
+ elseif str == "false" then
return false
+ elseif str == "true" then
+ return true
elseif (tonumber(str) or 0) > 0 then
return true
else