summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-parsers.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/luaotfload/luaotfload-parsers.lua')
-rw-r--r--Master/texmf-dist/tex/luatex/luaotfload/luaotfload-parsers.lua200
1 files changed, 115 insertions, 85 deletions
diff --git a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-parsers.lua b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-parsers.lua
index 3eeb614a202..3a4faea9b56 100644
--- a/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-parsers.lua
+++ b/Master/texmf-dist/tex/luatex/luaotfload/luaotfload-parsers.lua
@@ -145,21 +145,21 @@ local xml_attr_list = Cf(Ct"" * xml_attr^1, rawset)
--doc]]--
--- string -> bool -> lpeg_t
local scan_node = function (tag)
- --- Node attributes go into a table with the index “attributes”
- --- (relevant for “prefix="xdg"” and the likes).
- local p_tag = P(tag)
- local with_attributes = P"<" * p_tag
- * Cg(xml_attr_list, "attributes")^-1
- * xmlws^-1
- * P">"
- local plain = P"<" * p_tag * xmlws^-1 * P">"
- local node_start = plain + with_attributes
- local node_stop = P"</" * p_tag * xmlws^-1 * P">"
- --- there is no nesting, the earth is flat ...
- local node = node_start
- * Cc(tag) * C(comment + (1 - node_stop)^1)
- * node_stop
- return Ct(node) -- returns {string, string [, attributes = { key = val }] }
+ --- Node attributes go into a table with the index “attributes”
+ --- (relevant for “prefix="xdg"” and the likes).
+ local p_tag = P(tag)
+ local with_attributes = P"<" * p_tag
+ * Cg(xml_attr_list, "attributes")^-1
+ * xmlws^-1
+ * P">"
+ local plain = P"<" * p_tag * xmlws^-1 * P">"
+ local node_start = plain + with_attributes
+ local node_stop = P"</" * p_tag * xmlws^-1 * P">"
+ --- there is no nesting, the earth is flat ...
+ local node = node_start
+ * Cc(tag) * C(comment + (1 - node_stop)^1)
+ * node_stop
+ return Ct(node) -- returns {string, string [, attributes = { key = val }] }
end
--[[doc--
@@ -217,20 +217,35 @@ local conf_filter = function (path)
end
--[[doc--
- read_fonts_conf_indeed() is called with seven arguments; the
- latter three are tables that represent the state and are
- always returned.
+
+ read_fonts_conf_indeed() -- Scan paths included from fontconfig
+ configuration files recursively. Called with eight arguments.
The first four are
+
· the path to the file
· the expanded $HOME
· the expanded $XDG_CONFIG_HOME
· the expanded $XDG_DATA_HOME
+
+ determining the path to be checked. Another three arguments are
+ tables that represent the state of the current job as lists of
+ strings; these are always returned. Finally a reference to the
+ find_files function is passed.
+
--doc]]--
---- string -> string -> string -> tab -> tab -> (tab * tab * tab)
+
+--- string -> string -> string -> string
+--- -> string list -> string list -> string list
+--- -> (string -> fun option -> string list)
+--- -> tab * tab * tab
local read_fonts_conf_indeed
-read_fonts_conf_indeed = function (start, home, xdg_config_home,
+read_fonts_conf_indeed = function (start,
+ home,
+ xdg_config_home,
xdg_data_home,
- acc, done, dirs_done,
+ acc,
+ done,
+ dirs_done,
find_files)
local paths = fonts_conf_scanner(start)
@@ -267,40 +282,50 @@ read_fonts_conf_indeed = function (start, home, xdg_config_home,
path = filejoin(xdg_config_home, path)
end
--- here the path can be four things: a directory or a file,
- --- in absolute or relative path.
+ --- an absolute or relative path.
if stringsub(path, 1, 1) == "~" then
path = filejoin(home, stringsub(path, 2))
elseif --- if the path is relative, we make it absolute
not ( lfsisfile(path) or lfsisdir(path) )
- then
+ then
path = filejoin(filedirname(start), path)
- end
- if lfsisfile(path)
- and kpsereadable_file(path)
- and not done[path]
- then
- --- we exclude path with texmf in them, as they should
- --- be found otherwise
- acc = read_fonts_conf_indeed(
- 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_config_home, xdg_data_home,
- acc, done, dirs_done)
- end
- end
- end --- match “kind”
- end --- iterate paths
end
+ if lfsisfile(path)
+ and kpsereadable_file(path)
+ and not done[path]
+ then
+ --- we exclude path with texmf in them, as they should
+ --- be found otherwise
+ acc = read_fonts_conf_indeed(path,
+ home,
+ xdg_config_home,
+ xdg_data_home,
+ acc,
+ done,
+ dirs_done,
+ find_files)
+ 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_config_home,
+ xdg_data_home,
+ acc,
+ done,
+ dirs_done,
+ find_files)
+ end
+ end
+ end --- match “kind”
+ end --- iterate paths
+ end
- --inspect(acc)
- --inspect(done)
- return acc, done, dirs_done
- end --- read_fonts_conf_indeed()
+ --inspect(acc)
+ --inspect(done)
+ return acc, done, dirs_done
+end --- read_fonts_conf_indeed()
--[[doc--
read_fonts_conf() sets up an accumulator and two sets
@@ -325,11 +350,14 @@ local read_fonts_conf = function (path_list, find_files)
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_config_home,
- xdg_data_home,
- acc, done, dirs_done,
- find_files)
+ acc, done, dirs_done = read_fonts_conf_indeed(path_list[i],
+ home,
+ xdg_config_home,
+ xdg_data_home,
+ acc,
+ done,
+ dirs_done,
+ find_files)
end
return acc
end
@@ -424,14 +452,14 @@ parsers.splitcomma = splitcomma
local handle_normal_option = function (key, val)
- val = stringlower(val)
- --- the former “toboolean()” handler
- if val == "true" then
- val = true
- elseif val == "false" then
- val = false
- end
- return key, val
+ val = stringlower(val)
+ --- the former “toboolean()” handler
+ if val == "true" then
+ val = true
+ elseif val == "false" then
+ val = false
+ end
+ return key, val
end
--[[doc--
@@ -442,18 +470,18 @@ end
--doc]]--
local handle_xetex_option = function (key, val)
- val = stringlower(val)
- local numeric = tonumber(val) --- decimal only; keeps colors intact
- if numeric then --- ugh
- if mathceil(numeric) == numeric then -- integer, possible index
- val = tostring(numeric + 1)
- end
- elseif val == "true" then
- val = true
- elseif val == "false" then
- val = false
+ val = stringlower(val)
+ local numeric = tonumber(val) --- decimal only; keeps colors intact
+ if numeric then --- ugh
+ if mathceil(numeric) == numeric then -- integer, possible index
+ val = tostring(numeric + 1)
end
- return key, val
+ elseif val == "true" then
+ val = true
+ elseif val == "false" then
+ val = false
+ end
+ return key, val
end
--[[doc--
@@ -468,8 +496,8 @@ end
--doc]]--
local handle_invalid_option = function (opt)
- logreport("log", 0, "load", "font option %q unknown.", opt)
- return "", false
+ logreport("log", 0, "load", "font option %q unknown.", opt)
+ return "", false
end
--[[doc--
@@ -481,16 +509,16 @@ end
--doc]]--
local check_garbage = function (_,i, garbage)
- if stringfind(garbage, "/") then
- logreport("log", 0, "load", --- ffs use path!
- "warning: path in file: lookups is deprecated; ")
- logreport("log", 0, "load", "use bracket syntax instead!")
- logreport("log", 0, "load",
- "position: %d; full match: %q",
- i, garbage)
- return true
- end
- return false
+ if stringfind(garbage, "/") then
+ logreport("log", 0, "load", --- ffs use path!
+ "warning: path in file: lookups is deprecated; ")
+ logreport("log", 0, "load", "use bracket syntax instead!")
+ logreport("log", 0, "load",
+ "position: %d; full match: %q",
+ i, garbage)
+ return true
+ end
+ return false
end
local featuresep = comma + semicolon
@@ -620,9 +648,11 @@ local maybe_cast = function (var)
end
return tonumber (var) or var
end
+
local escape = function (chr, repl)
return (backslash * P(chr) / (repl or chr))
end
+
local valid_escapes = escape "\""
+ escape "\\"
+ escape ("n", "\n")
@@ -698,4 +728,4 @@ local config = Ct (ini_sections)
luaotfload.parsers.config = config
--- vim:ft=lua:tw=71:et:sts=4:ts=8
+-- vim:ft=lua:tw=71:et:sw=2:sts=4:ts=8