diff options
author | Philipp Gesang <phg42.2a@gmail.com> | 2013-11-13 00:38:07 +0100 |
---|---|---|
committer | Philipp Gesang <phg42.2a@gmail.com> | 2013-11-13 00:38:07 +0100 |
commit | 32a5a40a2f99bf82436bfec8926fe7bfeaa1194d (patch) | |
tree | feca35fc413d9be0bfe491e4abc9c3e3ae82ab6a | |
parent | a914c23b674ff6bacb85a9701a828e03ec24cbc0 (diff) | |
download | luaotfload-32a5a40a2f99bf82436bfec8926fe7bfeaa1194d.tar.gz |
[db] simplify loop exit condition
-rw-r--r-- | luaotfload-database.lua | 35 | ||||
-rwxr-xr-x | 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 |