summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luaotfload-database.lua17
-rwxr-xr-xsrc/luaotfload-tool.lua27
2 files changed, 41 insertions, 3 deletions
diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua
index de1594a..a369d8e 100644
--- a/src/luaotfload-database.lua
+++ b/src/luaotfload-database.lua
@@ -2945,6 +2945,22 @@ local collect_font_filenames = function ()
return filenames
end
+--[[doc--
+
+ nth_font_file -- Return the filename of the nth font.
+
+--doc]]--
+
+--- int -> string
+local nth_font_filename = function (n)
+ report ("info", 4, "db", "Picking the %d font file.", n)
+ if not p_blacklist then
+ read_blacklist ()
+ end
+ local filenames = collect_font_filenames ()
+ return filenames[n] and filenames[n][1] or "<error>"
+end
+
--[[doc
count_font_files -- Return the number of files found by
@@ -3490,6 +3506,7 @@ names.sanitize_fontname = sanitize_fontname
names.getfilename = resolve_fullpath
names.set_location_precedence = set_location_precedence
names.count_font_files = count_font_files
+names.nth_font_filename = nth_font_filename
--- font cache
names.purge_cache = purge_cache
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
@@ -891,6 +891,21 @@ 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,
and pivot to new values.
@@ -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,