From b2235e724443f86716694f4e45df9f1261873069 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 16 Jul 2013 21:30:48 +0200 Subject: adapt strings for 20th century OS Windows appears to still lack a unicode capable terminal emulator. http://tug.org/pipermail/luatex/2013-July/004547.html No comment. --- luaotfload-database.lua | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index e0b977b..0997a46 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -643,7 +643,7 @@ end resolve_cached = function (_, _, specification) if not names.lookups then names.lookups = load_lookups() end local request = hash_request(specification) - report("both", 4, "cache", "Looking for “%s” in cache ...", + report("both", 4, "cache", "Looking for %q in cache ...", request) local found = names.lookups[request] @@ -927,7 +927,7 @@ resolve = function (_, _, specification) -- the 1st two parameters are used by C if not fonts_reloaded then --- last straw: try reloading the database return reload_db( - "unresolved font name: ‘" .. name .. "’", + "unresolved font name: '" .. name .. "'", resolve, nil, nil, specification ) end @@ -954,7 +954,7 @@ end --- string -> ('a -> 'a) -> 'a list -> 'a reload_db = function (why, caller, ...) - report("both", 1, "db", "Reload initiated; reason: “%s”", why) + report("both", 1, "db", "Reload initiated; reason: %q", why) names.data = update_names(names.data, false, false) local success = save_names() if success then @@ -1056,7 +1056,7 @@ find_closest = function (name, limit) local dist = distances[i] local namelst = by_distance[dist] report(false, 0, "query", - "Distance from “" .. name .. "”: " .. dist + "Distance from \"" .. name .. "\": " .. dist .. "\n " .. tableconcat(namelst, "\n ") ) end @@ -1174,7 +1174,7 @@ local load_font = function (fullname, fontnames, newfontnames, texmf) if names.blacklist[fullname] or names.blacklist[basename] then report("log", 2, "db", - "Ignoring blacklisted font “%s”", fullname) + "Ignoring blacklisted font %q", fullname) return false end @@ -1205,7 +1205,7 @@ local load_font = function (fullname, fontnames, newfontnames, texmf) newmappings[location] = fullinfo --- keep newentrystatus.index[index+1] = location --- is this actually used anywhere? end - report("log", 2, "db", "Font “%s” already indexed", basename) + report("log", 2, "db", "Font %q already indexed", basename) return false end @@ -1238,7 +1238,7 @@ local load_font = function (fullname, fontnames, newfontnames, texmf) end else --- missing info - report("log", 1, "db", "Failed to load “%s”", basename) + report("log", 1, "db", "Failed to load %q", basename) return false end return true @@ -1319,7 +1319,7 @@ local create_blacklist = function (blacklist, whitelist) local result = { } local dirs = { } - report("info", 2, "db", "Blacklisting “%d” files and directories", + report("info", 2, "db", "Blacklisting %q files and directories", #blacklist) for i=1, #blacklist do local entry = blacklist[i] @@ -1330,7 +1330,7 @@ local create_blacklist = function (blacklist, whitelist) end end - report("info", 2, "db", "Whitelisting “%d” files", #whitelist) + report("info", 2, "db", "Whitelisting %q files", #whitelist) for i=1, #whitelist do result[whitelist[i]] = nil end @@ -1379,7 +1379,7 @@ read_blacklist = function () line = stringsub(line, 1, cmt - 1) end line = stringstrip(line) - report("log", 2, "db", "Blacklisted file “%s”", line) + report("log", 2, "db", "Blacklisted file %q", line) blacklist[#blacklist+1] = line end end @@ -1467,7 +1467,7 @@ local scan_dir = function (dirname, fontnames, newfontnames, local found = find_font_files (dirname) if not found then report ("both", 3, "db", - "No such directory: “%s”; skipping.", dirname) + "No such directory: %q; skipping.", dirname) return 0, 0 end report ("both", 3, "db", "Scanning directory %s", dirname) @@ -1481,10 +1481,10 @@ local scan_dir = function (dirname, fontnames, newfontnames, local new if dry_run == true then report ("both", 1, "db", - "Would have been loading “%s”", fullname) + "Would have been loading %q", fullname) else report ("both", 4, "db", - "Loading font “%s”", fullname) + "Loading font %q", fullname) local new = load_font (fullname, fontnames, newfontnames, texmf) if new == true then @@ -1841,7 +1841,7 @@ local gen_fast_lookups = function (fontnames) local known = filenames.base[base] or filenames.bare[bare] if known then --- known report("both", 3, "db", - "Font file “%s” already indexed (%d)", + "Font file %q already indexed (%d)", base, idx) report("both", 3, "db", "> old location: %s", (filenames.full[known] or "texmf")) -- cgit v1.2.3 From bc9469bd5d51458cde6d2d6b3c46f3593dc04ea0 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 19 Jul 2013 14:15:15 +0200 Subject: indicate forced db update on terminal --- luaotfload-database.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 0997a46..70a49ff 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -363,11 +363,11 @@ load_names = function (dry_run) local db_version, nms_version = data.version, names.version if db_version ~= nms_version then - report("log", 0, "db", + report("both", 0, "db", [[Version mismatch; expected %4.3f, got %4.3f]], nms_version, db_version) if not fonts_reloaded then - report("log", 0, "db", [[force rebuild]]) + report("both", 0, "db", [[Force rebuild]]) return update_names({ }, true, false) end end -- cgit v1.2.3 From 1de2387071cd286376d178d385dbedcba5168e5b Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 22 Jul 2013 22:35:01 +0200 Subject: avoid building of intermediate list in file locators --- luaotfload-database.lua | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 70a49ff..7eb0e05 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -175,13 +175,13 @@ find_files_indeed = function (acc, dirs, filter) local dir = dirs[#dirs] dirs[#dirs] = nil - local newdirs, newfiles = { }, { } + local newfiles = { } for ent in lfsdir (dir) do if ent ~= "." and ent ~= ".." then local fullpath = dir .. "/" .. ent if filter (fullpath) == true then if lfsisdir (fullpath) then - newdirs[#newdirs+1] = fullpath + dirs[#dirs+1] = fullpath elseif lfsisfile (fullpath) then newfiles[#newfiles+1] = fullpath end @@ -189,8 +189,7 @@ find_files_indeed = function (acc, dirs, filter) end end return find_files_indeed (tableappend (acc, newfiles), - tableappend (dirs, newdirs), - filter) + dirs, filter) end local dummyfilter = function () return true end @@ -1415,7 +1414,7 @@ process_dir_tree = function (acc, dirs) local dir = dirs[#dirs] dirs[#dirs] = nil - local newdirs, newfiles = { }, { } + local newfiles = { } local blacklist = names.blacklist for ent in lfsdir (dir) do --- filter right away @@ -1424,7 +1423,7 @@ process_dir_tree = function (acc, dirs) if lfsisdir (fullpath) and not lpegmatch (p_blacklist, fullpath) then - newdirs[#newdirs+1] = fullpath + dirs[#dirs+1] = fullpath elseif lfsisfile (fullpath) then if lpegmatch (p_font_extensions, stringlower(ent)) then newfiles[#newfiles+1] = fullpath @@ -1432,8 +1431,7 @@ process_dir_tree = function (acc, dirs) end end end - return process_dir_tree (tableappend (acc, newfiles), - tableappend (dirs, newdirs)) + return process_dir_tree (tableappend (acc, newfiles),dirs) end --- string -> string list -- cgit v1.2.3 From 9ba9fbe876feb510ca5ba91f49ca63f984924d59 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 22 Jul 2013 23:17:16 +0200 Subject: check if we can cd into a directory before inspecting it --- luaotfload-database.lua | 68 ++++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 26 deletions(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 7eb0e05..487498b 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -27,7 +27,6 @@ local require = require local tonumber = tonumber local unpack = table.unpack - local fontloaderinfo = fontloader.info local fontloaderopen = fontloader.open local iolines = io.lines @@ -38,6 +37,8 @@ local kpsefind_file = kpse.find_file local kpselookup = kpse.lookup local kpsereadable_file = kpse.readable_file local lfsattributes = lfs.attributes +local lfschdir = lfs.chdir +local lfscurrentdir = lfs.currentdir local lfsdir = lfs.dir local mathabs = math.abs local mathmin = math.min @@ -54,6 +55,7 @@ local tablesort = table.sort local texiowrite_nl = texio.write_nl local utf8gsub = unicode.utf8.gsub local utf8lower = unicode.utf8.lower + --- these come from Lualibs/Context local getwritablepath = caches.getwritablepath local filebasename = file.basename @@ -172,24 +174,31 @@ find_files_indeed = function (acc, dirs, filter) return acc end + local pwd = lfscurrentdir () local dir = dirs[#dirs] dirs[#dirs] = nil - local newfiles = { } - for ent in lfsdir (dir) do - if ent ~= "." and ent ~= ".." then - local fullpath = dir .. "/" .. ent - if filter (fullpath) == true then - if lfsisdir (fullpath) then - dirs[#dirs+1] = fullpath - elseif lfsisfile (fullpath) then - newfiles[#newfiles+1] = fullpath + if lfschdir (dir) then + lfschdir (pwd) + + local newfiles = { } + for ent in lfsdir (dir) do + if ent ~= "." and ent ~= ".." then + local fullpath = dir .. "/" .. ent + if filter (fullpath) == true then + if lfsisdir (fullpath) then + dirs[#dirs+1] = fullpath + elseif lfsisfile (fullpath) then + newfiles[#newfiles+1] = fullpath + end end end end + return find_files_indeed (tableappend (acc, newfiles), + dirs, filter) end - return find_files_indeed (tableappend (acc, newfiles), - dirs, filter) + --- could not cd into, so we skip it + return find_files_indeed (acc, dirs, filter) end local dummyfilter = function () return true end @@ -1411,27 +1420,34 @@ process_dir_tree = function (acc, dirs) return acc end + local pwd = lfscurrentdir () local dir = dirs[#dirs] dirs[#dirs] = nil - local newfiles = { } - local blacklist = names.blacklist - for ent in lfsdir (dir) do - --- filter right away - if ent ~= "." and ent ~= ".." and not blacklist[ent] then - local fullpath = dir .. "/" .. ent - if lfsisdir (fullpath) - and not lpegmatch (p_blacklist, fullpath) - then - dirs[#dirs+1] = fullpath - elseif lfsisfile (fullpath) then - if lpegmatch (p_font_extensions, stringlower(ent)) then - newfiles[#newfiles+1] = fullpath + if lfschdir (dir) then + lfschdir (pwd) + + local newfiles = { } + local blacklist = names.blacklist + for ent in lfsdir (dir) do + --- filter right away + if ent ~= "." and ent ~= ".." and not blacklist[ent] then + local fullpath = dir .. "/" .. ent + if lfsisdir (fullpath) + and not lpegmatch (p_blacklist, fullpath) + then + dirs[#dirs+1] = fullpath + elseif lfsisfile (fullpath) then + if lpegmatch (p_font_extensions, stringlower(ent)) then + newfiles[#newfiles+1] = fullpath + end end end end + return process_dir_tree (tableappend (acc, newfiles), dirs) end - return process_dir_tree (tableappend (acc, newfiles),dirs) + --- cannot cd; skip + return process_dir_tree (acc, dirs) end --- string -> string list -- cgit v1.2.3 From 2331b6838f623d4800e79e92c50ce55f955d7776 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 24 Jul 2013 00:19:09 +0200 Subject: bump version, update NEWS --- luaotfload-database.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'luaotfload-database.lua') diff --git a/luaotfload-database.lua b/luaotfload-database.lua index 487498b..1b75458 100644 --- a/luaotfload-database.lua +++ b/luaotfload-database.lua @@ -1,5 +1,5 @@ if not modules then modules = { } end modules ['luaotfload-database'] = { - version = "2.3a", + version = "2.3b", comment = "companion to luaotfload.lua", author = "Khaled Hosny, Elie Roux, Philipp Gesang", copyright = "Luaotfload Development Team", @@ -2037,7 +2037,7 @@ local purge_from_cache = function (category, path, list, all) local n = 0 for i=1,#list do local filename = list[i] - if string.find(filename,"luatex%-cache") then -- safeguard + if stringfind(filename,"luatex%-cache") then -- safeguard if all then report("info", 5, "cache", "removing %s", filename) osremove(filename) -- cgit v1.2.3