summaryrefslogtreecommitdiff
path: root/src/luaotfload-tool.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2014-03-23 17:21:35 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2014-03-23 17:21:35 +0100
commitc160c40265b5eb5670730906614997ad2545f94d (patch)
tree9d0086fd7683bc71cba383f72ca073f55f441653 /src/luaotfload-tool.lua
parent68d04a338b74a585e12df7ab3200cda389b7c964 (diff)
downloadluaotfload-c160c40265b5eb5670730906614997ad2545f94d.tar.gz
[tool] implement good/bad directives for bisection mode
Diffstat (limited to 'src/luaotfload-tool.lua')
-rwxr-xr-xsrc/luaotfload-tool.lua39
1 files changed, 36 insertions, 3 deletions
diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua
index e3f4516..9529a4d 100755
--- a/src/luaotfload-tool.lua
+++ b/src/luaotfload-tool.lua
@@ -894,9 +894,42 @@ end
bisect_set -- Prepare the next bisection step by setting high, low,
and pivot to new values.
+ The “run” directive always picks the segment below the pivot so we
+ can rely on the “outcome parameter” to be referring to that.
+
--doc]]--
local bisect_set = function (outcome)
+ local status = read_bisect_status ()
+ if not status then
+ return false, false
+ end
+
+ local nsteps = #status
+ local lo, hi, pivot = unpack (status[nsteps])
+ report ("info", 3, "bisect", "Previous step %d: lo=%d, hi=%d, pivot=%d.",
+ nsteps, lo, hi, pivot)
+
+ if outcome == "bad" then
+ hi = pivot
+ pivot = mathfloor ((lo + hi) / 2)
+ report ("info", 0, "bisect",
+ "Continuing with the lower segment: lo=%d, hi=%d, pivot=%d.",
+ lo, hi, pivot)
+ elseif outcome == "good" then
+ lo = pivot
+ pivot = mathfloor ((lo + hi) / 2)
+ report ("info", 0, "bisect",
+ "Continuing with the upper segment: lo=%d, hi=%d, pivot=%d.",
+ lo, hi, pivot)
+ else -- can’t happen
+ report ("info", 0, "bisect", "What the hell?", lo, hi, pivot)
+ return false, false
+ end
+
+ status[nsteps + 1] = { lo, hi, pivot }
+ write_bisect_status (status)
+ return true, false
end
--[[doc--
@@ -908,7 +941,7 @@ end
local bisect_status = function ()
local status = read_bisect_status ()
if not status then
- return false
+ return false, false
end
local nsteps = #status
if nsteps > 1 then
@@ -953,8 +986,8 @@ end
local bisect_modes = {
start = bisect_start,
- good = function () bisect_set "good" end,
- bad = function () bisect_set "bad" end,
+ good = function () return bisect_set "good" end,
+ bad = function () return bisect_set "bad" end,
stop = bisect_stop,
status = bisect_status,
run = bisect_run,