From 2d7567b653cabaa0d259996a47227cefa9b54563 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 23 Mar 2014 17:57:42 +0100 Subject: [db,tool] implement termination of bisect session --- src/luaotfload-tool.lua | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/luaotfload-tool.lua') diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua index 9529a4d..2301636 100755 --- a/src/luaotfload-tool.lua +++ b/src/luaotfload-tool.lua @@ -889,6 +889,21 @@ local bisect_stop = function () return true, false end +--[[doc-- + + bisect_terminate -- Wrap up a bisect session by printing the + offending font and removing the state file. + +--doc]]-- + +local bisect_terminate = function (nsteps, culprit) + report ("info", 1, "bisect", + "Bisection completed after %d steps.", nsteps) + report ("info", 0, "bisect", + "Bad file: %s.", names.nth_font_filename (culprit)) + return bisect_stop () +end + --[[doc-- bisect_set -- Prepare the next bisection step by setting high, low, @@ -911,13 +926,19 @@ local bisect_set = function (outcome) nsteps, lo, hi, pivot) if outcome == "bad" then - hi = pivot + hi = pivot + if lo >= hi then --- complete + return bisect_terminate (nsteps, lo) + end 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 + lo = pivot + 1 + if lo >= hi then --- complete + return bisect_terminate (nsteps, lo) + end pivot = mathfloor ((lo + hi) / 2) report ("info", 0, "bisect", "Continuing with the upper segment: lo=%d, hi=%d, pivot=%d.", @@ -987,7 +1008,7 @@ end local bisect_modes = { start = bisect_start, good = function () return bisect_set "good" end, - bad = function () return bisect_set "bad" end, + bad = function () return bisect_set "bad" end, stop = bisect_stop, status = bisect_status, run = bisect_run, -- cgit v1.2.3