summaryrefslogtreecommitdiff
path: root/src/luaotfload-parsers.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2014-06-07 22:38:42 +0200
committerPhilipp Gesang <phg42.2a@gmail.com>2014-06-07 22:38:42 +0200
commit9642b4b6f21e96362fde0204236622600657f154 (patch)
tree3069b9e27f6153c6182b6c6a3287eb9fd308806a /src/luaotfload-parsers.lua
parent3e542973ad5965223d1da8550a3c573990b2d9d1 (diff)
parent056e50fc1e530c45eb84d15e33a0ab80b05e359c (diff)
downloadluaotfload-9642b4b6f21e96362fde0204236622600657f154.tar.gz
Merge branch 'texlive2014' of github:lualatex/luaotfload into texlive2014
Diffstat (limited to 'src/luaotfload-parsers.lua')
-rw-r--r--src/luaotfload-parsers.lua41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/luaotfload-parsers.lua b/src/luaotfload-parsers.lua
index 6a99ad7..73be67a 100644
--- a/src/luaotfload-parsers.lua
+++ b/src/luaotfload-parsers.lua
@@ -217,17 +217,19 @@ local conf_filter = function (path)
end
--[[doc--
- read_fonts_conf_indeed() is called with six arguments; the
+ read_fonts_conf_indeed() is called with seven arguments; the
latter three are tables that represent the state and are
always returned.
- The first three are
+ The first four are
· the path to the file
· the expanded $HOME
- · the expanded $XDG_CONFIG_DIR
+ · the expanded $XDG_CONFIG_HOME
+ · the expanded $XDG_DATA_HOME
--doc]]--
--- string -> string -> string -> tab -> tab -> (tab * tab * tab)
local read_fonts_conf_indeed
-read_fonts_conf_indeed = function (start, home, xdg_home,
+read_fonts_conf_indeed = function (start, home, xdg_config_home,
+ xdg_data_home,
acc, done, dirs_done,
find_files)
@@ -240,12 +242,11 @@ read_fonts_conf_indeed = function (start, home, xdg_home,
local pathobj = paths[i]
local kind, path = pathobj[1], pathobj[2]
local attributes = pathobj.attributes
- if attributes and attributes.prefix == "xdg" then
- --- this prepends the xdg root (usually ~/.config)
- path = filejoin(xdg_home, path)
- end
if kind == "dir" then
+ if attributes and attributes.prefix == "xdg" then
+ path = filejoin(xdg_data_home, path)
+ end
if stringsub(path, 1, 1) == "~" then
path = filejoin(home, stringsub(path, 2))
end
@@ -262,6 +263,9 @@ read_fonts_conf_indeed = function (start, home, xdg_home,
end
elseif kind == "include" then
+ if attributes and attributes.prefix == "xdg" then
+ path = filejoin(xdg_config_home, path)
+ end
--- here the path can be four things: a directory or a file,
--- in absolute or relative path.
if stringsub(path, 1, 1) == "~" then
@@ -278,14 +282,14 @@ read_fonts_conf_indeed = function (start, home, xdg_home,
--- we exclude path with texmf in them, as they should
--- be found otherwise
acc = read_fonts_conf_indeed(
- path, home, xdg_home,
+ path, home, xdg_config_home, xdg_data_home,
acc, done, dirs_done)
elseif lfsisdir(path) then --- arrow code ahead
local config_files = find_files (path, conf_filter)
for _, filename in next, config_files do
if not done[filename] then
acc = read_fonts_conf_indeed(
- filename, home, xdg_home,
+ filename, home, xdg_config_home, xdg_data_home,
acc, done, dirs_done)
end
end
@@ -302,10 +306,10 @@ read_fonts_conf_indeed = function (start, home, xdg_home,
read_fonts_conf() sets up an accumulator and two sets
for tracking what’s been done.
- Also, the environment variables HOME and XDG_CONFIG_HOME --
- which are constants anyways -- are expanded so don’t have to
- repeat that over and over again as with the old parser.
- Now they’re just passed on to every call of
+ Also, the environment variables HOME, XDG_DATA_HOME and
+ XDG_CONFIG_HOME -- which are constants anyways -- are expanded
+ so we don’t have to repeat that over and over again as with the
+ old parser. Now they’re just passed on to every call of
read_fonts_conf_indeed().
read_fonts_conf() is also the only reference visible outside
@@ -316,14 +320,17 @@ read_fonts_conf_indeed = function (start, home, xdg_home,
local read_fonts_conf = function (path_list, find_files)
local home = kpseexpand_path"~" --- could be os.getenv"HOME"
- local xdg_home = kpseexpand_path"$XDG_CONFIG_HOME"
- if xdg_home == "" then xdg_home = filejoin(home, ".config") end
+ local xdg_config_home = kpseexpand_path"$XDG_CONFIG_HOME"
+ if xdg_config_home == "" then xdg_config_home = filejoin(home, ".config") end
+ local xdg_data_home = kpseexpand_path"$XDG_DATA_HOME"
+ if xdg_data_home == "" then xdg_data_home = filejoin(home, ".local/share") end
local acc = { } ---> list: paths collected
local done = { } ---> set: files inspected
local dirs_done = { } ---> set: dirs in list
for i=1, #path_list do --- we keep the state between files
acc, done, dirs_done = read_fonts_conf_indeed(
- path_list[i], home, xdg_home,
+ path_list[i], home, xdg_config_home,
+ xdg_data_home,
acc, done, dirs_done,
find_files)
end