From 32a5a40a2f99bf82436bfec8926fe7bfeaa1194d Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 13 Nov 2013 00:38:07 +0100 Subject: [db] simplify loop exit condition --- luaotfload-database.lua | 35 +++++++++++++++++++---------------- luaotfload-tool.lua | 2 +- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 4ee07f4..638f1c3 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -2106,27 +2106,30 @@ local scan_dir = function (dirname, currentnames, targetnames, end report ("both", 4, "db", "Scanning directory %s", dirname) - local n_new = 0 --- total of fonts collected - local n_found = #found + local n_new = 0 --- total of fonts collected + local n_found = #found + local max_fonts = luaotfloadconfig.max_fonts + report ("both", 4, "db", "%d font files detected", n_found) for j=1, n_found do + if max_fonts and fonts_read >= max_fonts then + break + end + local fullname = found[j] fullname = path_normalize(fullname) local new - if not luaotfloadconfig.max_fonts - or luaotfloadconfig.max_fonts and fonts_read < luaotfloadconfig.max_fonts - then - if dry_run == true then - report_status ("both", "db", - "Would have been loading %q", fullname) - else - report_status ("both", "db", "Loading font %q", fullname) - local new = read_font_names (fullname, currentnames, - targetnames, texmf) - if new == true then - fonts_read = fonts_read + 1 - n_new = n_new + 1 - end + + if dry_run == true then + report_status ("both", "db", + "Would have been loading %q", fullname) + else + report_status ("both", "db", "Loading font %q", fullname) + local new = read_font_names (fullname, currentnames, + targetnames, texmf) + if new == true then + fonts_read = fonts_read + 1 + n_new = n_new + 1 end end end diff --git a/luaotfload-tool.lua b/luaotfload-tool.lua index 41ac4d7..a945ee2 100755 --- a/luaotfload-tool.lua +++ b/luaotfload-tool.lua @@ -1224,7 +1224,7 @@ local process_cmdline = function ( ) -- unit -> jobspec elseif v == "max-fonts" then local n = optarg[n] if n then - n = tonumber(lvl) + n = tonumber(n) if n and n > 0 then luaotfloadconfig.max_fonts = n end -- cgit v1.2.3