summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElie Roux <elie.roux@telecom-bretagne.eu>2013-04-16 18:47:44 +0200
committerElie Roux <elie.roux@telecom-bretagne.eu>2013-04-16 18:47:44 +0200
commit246ef30f958ee3f9a957703a385fcc65607f07a1 (patch)
treeeef3ce6a17b089fb703cbc683c2b0f43c925352f
parentdc4b739a33f3f5f4932945649a11e42fc1d6e957 (diff)
downloadluaotfload-246ef30f958ee3f9a957703a385fcc65607f07a1.tar.gz
Preventing loop-references in fontconfig files
I just had this case on a recent Ubuntu...
-rw-r--r--otfl-font-nms.lua11
1 files changed, 6 insertions, 5 deletions
diff --git a/otfl-font-nms.lua b/otfl-font-nms.lua
index e6faeab..0f44eb4 100644
--- a/otfl-font-nms.lua
+++ b/otfl-font-nms.lua
@@ -518,12 +518,13 @@ end
in OSFONTDIR.
]]
-local function read_fonts_conf(path, results)
+local function read_fonts_conf(path, results, passed_paths)
--[[
This function parses /etc/fonts/fonts.conf and returns all the dir it finds.
The code is minimal, please report any error it may generate.
]]
local f = io.open(path)
+ table.insert(passed_paths, path)
if not f then
logs.info("Warning: unable to read "..path.. ", skipping...")
return results
@@ -575,14 +576,14 @@ local function read_fonts_conf(path, results)
elseif not lfs.isfile(include) and not lfs.isdir(include) then
include = file.join(file.dirname(path), include)
end
- if lfs.isfile(include) and kpse.readable_file(include) then
+ if lfs.isfile(include) and kpse.readable_file(include) and not table.contains(passed_paths, include) then
-- maybe we should prevent loops here?
-- we exclude path with texmf in them, as they should
-- be found otherwise
- read_fonts_conf(include, results)
+ read_fonts_conf(include, results, passed_paths)
elseif lfs.isdir(include) then
for _,f in next, glob(file.join(include, "*.conf")) do
- read_fonts_conf(f, results)
+ read_fonts_conf(f, results, passed_paths)
end
end
end
@@ -608,7 +609,7 @@ local function get_os_dirs()
local windir = os.getenv("WINDIR")
return { file.join(windir, 'Fonts') }
else
- return read_fonts_conf("/etc/fonts/fonts.conf", {})
+ return read_fonts_conf("/etc/fonts/fonts.conf", {}, {})
end
end