summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/supp-ran.lua
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2010-05-24 14:05:02 +0000
committerTaco Hoekwater <taco@elvenkind.com>2010-05-24 14:05:02 +0000
commit57ea7dad48fbf2541c04e434c31bde655ada3ac4 (patch)
tree1f8b43bc7cb92939271e1f5bec610710be69097f /Master/texmf-dist/tex/context/base/supp-ran.lua
parent6ee41e1f1822657f7f23231ec56c0272de3855e3 (diff)
here is context 2010.05.24 13:05
git-svn-id: svn://tug.org/texlive/trunk@18445 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/supp-ran.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/supp-ran.lua31
1 files changed, 26 insertions, 5 deletions
diff --git a/Master/texmf-dist/tex/context/base/supp-ran.lua b/Master/texmf-dist/tex/context/base/supp-ran.lua
index 9e4330f57ca..fe635fc7f9e 100644
--- a/Master/texmf-dist/tex/context/base/supp-ran.lua
+++ b/Master/texmf-dist/tex/context/base/supp-ran.lua
@@ -11,7 +11,20 @@ if not modules then modules = { } end modules ['supp-ran'] = {
commands = commands or { }
-local texwrite, random, seed, last = tex.write, math.random, false, 1
+local random, randomseed, round, seed, last = math.random, math.randomseed, math.round, false, 1
+local texwrite = tex.write
+
+function math.setrandomseedi(n,comment)
+ if n <= 1 then
+ n = n*1073741823 -- maxcount
+ end
+ n = round(n)
+ if false then
+ logs.report("system","setting random seed to %s (%s)",n,comment or "normal")
+ end
+ randomseed(n)
+ last = random(0,1073741823) -- we need an initial value
+end
function commands.getrandomcounta(min,max)
last = random(min,max)
@@ -25,22 +38,30 @@ end
function commands.setrandomseed(n)
last = n
- math.randomseed(n)
+ math.setrandomseedi(n)
end
function commands.getrandomseed(n)
texwrite(last)
end
-function commands.freezerandomseed()
- if seed == false then
+-- maybe stack
+
+function commands.freezerandomseed(n)
+ -- print("<<<<",seed,last)
+ if seed == false or seed == nil then
seed = last
+ math.setrandomseedi(seed,"freeze",seed)
+ end
+ if n then
+ randomseed(n)
end
end
function commands.defrostrandomseed()
+ -- print(">>>>",seed,last)
if seed ~= false then
- math.randomseed(last)
+ math.setrandomseedi(seed,"defrost",seed) -- was last (bug)
seed = false
end
end