summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/l-boolean.lua
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2008-06-12 10:42:53 +0000
committerTaco Hoekwater <taco@elvenkind.com>2008-06-12 10:42:53 +0000
commit0d01365d53c456d246da0ca1f0b3cd9868f02b35 (patch)
tree01a655c8028e17cfb371456b299c1848fe08c05b /Master/texmf-dist/tex/context/base/l-boolean.lua
parent44f3714442da07fdfc36a7f2a8dcd5d4294c5d26 (diff)
ConTeXt release 2008.05.21
git-svn-id: svn://tug.org/texlive/trunk@8691 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/l-boolean.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/l-boolean.lua52
1 files changed, 52 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/l-boolean.lua b/Master/texmf-dist/tex/context/base/l-boolean.lua
new file mode 100644
index 00000000000..66c608cee50
--- /dev/null
+++ b/Master/texmf-dist/tex/context/base/l-boolean.lua
@@ -0,0 +1,52 @@
+-- filename : l-boolean.lua
+-- comment : split off from luat-lib
+-- author : Hans Hagen, PRAGMA-ADE, Hasselt NL
+-- copyright: PRAGMA ADE / ConTeXt Development Team
+-- license : see context related readme files
+
+if not versions then versions = { } end versions['l-boolean'] = 1.001
+if not boolean then boolean = { } end
+
+function boolean.tonumber(b)
+ if b then return 1 else return 0 end
+end
+
+function toboolean(str,tolerant)
+ if tolerant then
+ local tstr = type(str)
+ if tstr == "string" then
+ return str == "true" or str == "yes" or str == "on" or str == "1"
+ elseif tstr == "number" then
+ return tonumber(str) ~= 0
+ elseif tstr == "nil" then
+ return false
+ else
+ return str
+ end
+ elseif str == "true" then
+ return true
+ elseif str == "false" then
+ return false
+ else
+ return str
+ end
+end
+
+function string.is_boolean(str)
+ if type(str) == "string" then
+ if str == "true" or str == "yes" or str == "on" then
+ return true
+ elseif str == "false" or str == "no" or str == "off" then
+ return false
+ end
+ end
+ return nil
+end
+
+function boolean.alwaystrue()
+ return true
+end
+
+function boolean.falsetrue()
+ return false
+end