diff options
author | Philipp Gesang <phg42.2a@gmail.com> | 2014-03-24 07:55:34 +0100 |
---|---|---|
committer | Philipp Gesang <phg42.2a@gmail.com> | 2014-03-24 07:55:34 +0100 |
commit | 2d555b40fc580e3ef9328a1f47544d4286b8b860 (patch) | |
tree | fdf6aa12e4ffc178aa0d64a60ee8feb9e1a30516 /src | |
parent | 82a06a10cef0ab4ee3fbe8c83facb1b017fbf6ef (diff) | |
download | luaotfload-2d555b40fc580e3ef9328a1f47544d4286b8b860.tar.gz |
[db,tool] reconcile --bisect with --max-fonts
Diffstat (limited to 'src')
-rw-r--r-- | src/luaotfload-database.lua | 10 | ||||
-rwxr-xr-x | src/luaotfload-tool.lua | 38 |
2 files changed, 40 insertions, 8 deletions
diff --git a/src/luaotfload-database.lua b/src/luaotfload-database.lua index e4188dc..936e380 100644 --- a/src/luaotfload-database.lua +++ b/src/luaotfload-database.lua @@ -2335,7 +2335,6 @@ local retrieve_namedata = function (files, currentnames, targetnames, dry_run) local nfiles = #files local nnew = 0 - local max_fonts = luaotfloadconfig.max_fonts or 2^51 report ("info", 1, "db", "Scanning %d collected font files ...", nfiles) @@ -2344,7 +2343,7 @@ local retrieve_namedata = function (files, currentnames, targetnames, dry_run) , system = { 0, 0 } } report_status_start (2, 4) - for i = 1, (nfiles < max_fonts) and nfiles or max_fonts do + for i = 1, nfiles do local fullname, location = unpack (files[i]) local count = bylocation[location] count[1] = count[1] + 1 @@ -2934,11 +2933,18 @@ local collect_font_filenames = function () local filenames = { } local bisect = luaotfloadconfig.bisect + local max_fonts = luaotfloadconfig.max_fonts or 2^51 --- XXX revisit for lua 5.3 wrt integers + tableappend (filenames, collect_font_filenames_texmf ()) tableappend (filenames, collect_font_filenames_system ()) if luaotfloadconfig.scan_local == true then tableappend (filenames, collect_font_filenames_local ()) end + --- Now drop everything above max_fonts. + if max_fonts < #filenames then + filenames = { unpack (filenames, 1, max_fonts) } + end + --- And choose the requested slice if in bisect mode. if bisect then return { unpack (filenames, bisect[1], bisect[2]) } end diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua index 60d2c2c..47e7ccc 100755 --- a/src/luaotfload-tool.lua +++ b/src/luaotfload-tool.lua @@ -847,6 +847,14 @@ end --doc]]-- local bisect_start = function () + if lfsisfile (bisect_status_file) then + report ("info", 0, "bisect", + "Bisect session in progress.", + bisect_status_file) + report ("info", 0, "bisect", + "Use --bisect=stop to erase it before starting over.") + return false, false + end report ("info", 2, "bisect", "Starting bisection of font database %q.", bisect_status_file) local n = names.count_font_files () @@ -854,7 +862,7 @@ local bisect_start = function () local data = { { 1, n, pivot } } report ("info", 0, "bisect", "Initializing pivot to %d.", pivot) if write_bisect_status (data) then - return true + return true, false end return false, false end @@ -884,7 +892,7 @@ local bisect_stop = function () end end if lfsisfile (bisect_status_file) then - return false + return false, false end return true, false end @@ -901,7 +909,9 @@ local bisect_terminate = function (nsteps, culprit) "Bisection completed after %d steps.", nsteps) report ("info", 0, "bisect", "Bad file: %s.", names.nth_font_filename (culprit)) - return bisect_stop () + report ("info", 0, "bisect", + "Run with --bisect=stop to finish bisection.") + return true, false end --[[doc-- @@ -912,7 +922,7 @@ end local list_remainder = function (lo, hi) local fonts = names.font_slice (lo, hi) - report ("info", 0, "bisect", "%d fonts left.", hi - lo) + report ("info", 0, "bisect", "%d fonts left.", hi - lo + 1) for i = 1, #fonts do report ("info", 1, "bisect", " ยท %2d: %s", lo, fonts[i]) lo = lo + 1 @@ -936,13 +946,26 @@ local bisect_set = function (outcome) end local nsteps = #status - local lo, hi, pivot = unpack (status[nsteps]) + local previous = status[nsteps] + if previous == true then + --- Bisection already completed; we exit early through + --- bisect_terminate() to avoid further writes to the + --- state files that mess up step counting. + nsteps = nsteps - 1 + return bisect_terminate (nsteps, status[nsteps][1]) + end + + local lo, hi, pivot = unpack (previous) + report ("info", 3, "bisect", "Previous step %d: lo=%d, hi=%d, pivot=%d.", nsteps, lo, hi, pivot) if outcome == "bad" then hi = pivot if lo >= hi then --- complete + status[nsteps + 1] = { lo, lo, lo } + status[nsteps + 1] = true + write_bisect_status (status) return bisect_terminate (nsteps, lo) end pivot = mathfloor ((lo + hi) / 2) @@ -952,6 +975,9 @@ local bisect_set = function (outcome) elseif outcome == "good" then lo = pivot + 1 if lo >= hi then --- complete + status[nsteps + 1] = { lo, lo, lo } + write_bisect_status (status) + status[nsteps + 1] = true return bisect_terminate (nsteps, lo) end pivot = mathfloor ((lo + hi) / 2) @@ -1009,7 +1035,7 @@ end local bisect_run = function () local status = read_bisect_status () if not status then - return false + return false, false end local nsteps = #status local currentstep = nsteps + 1 |