From 22dc6f817a3ec342996359fd3b39acea65601c53 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 23 Mar 2014 15:15:49 +0100 Subject: [tool] reimplement bisect status directive --- src/luaotfload-tool.lua | 55 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua index 4c915cf..6f1f0a1 100755 --- a/src/luaotfload-tool.lua +++ b/src/luaotfload-tool.lua @@ -793,6 +793,13 @@ local bisect_status_fmt = [[ --- vim:ft=lua:ts=8:et:sw=2 ]] +--[[doc-- + + write_bisect_status -- Write the history of the current bisection to disk. + +--doc]]-- + +--- state list -> bool local write_bisect_status = function (data) local payload = tableserialize (data, true) local status = stringformat (bisect_status_fmt, @@ -808,6 +815,29 @@ local write_bisect_status = function (data) return false end +--[[doc-- + + read_bisect_status -- Read the bisect log from disk. + +--doc]]-- + +--- unit -> state list +local read_bisect_status = function () + report ("info", 4, "bisect", "Testing for status file: %q.", bisect_status_file) + if not lfsisfile (bisect_status_file) then + report ("info", 2, "bisect", "No such file: %q.", bisect_status_file) + report ("info", 0, "bisect", "Not in bisect mode.") + return false + end + report ("info", 4, "bisect", "Reading status file: %q.", bisect_status_file) + local success, status = pcall (dofile, bisect_status_file) + if not success then + report ("info", 0, "bisect", "Could not read status file.") + return false + end + return status +end + --[[doc-- bisect_start -- Begin a bisect session. Determines the number of @@ -875,24 +905,21 @@ end --doc]]-- local bisect_status = function () - report ("info", 4, "bisect", "Testing for status file: %q.", bisect_status_file) - if not lfsisfile (bisect_status_file) then - report ("info", 2, "bisect", "No such file: %q.", bisect_status_file) - report ("info", 0, "bisect", "Not in bisect mode.") - return true - end - report ("info", 4, "bisect", "Reading status file: %q.", bisect_status_file) - local status = pcall (dofile, bisect_status_file) + local status = read_bisect_status () if not status then - report ("info", 0, "bisect", "Could not read status file.") return false end - report ("info", 0, "bisect", "Bisecting through %d font files.", #status) - for i = #status, 1, -1 do - local step = status[i] - report ("info", 0, "bisect", "Step %d: lo=%d, hi=%d, pivot=%d.", - i, unpack (step)) + local nsteps = #status + if nsteps > 1 then + for i = nsteps - 1, 1, -1 do + local step = status[i] + report ("info", 2, "bisect", "Step %d: lo=%d, hi=%d, pivot=%d.", + i, unpack (step)) + end end + local current = status[nsteps] + report ("info", 0, "bisect", "Step %d: lo=%d, hi=%d, pivot=%d.", + nsteps, unpack (current)) return true end -- cgit v1.2.3