summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/luaotfload-configuration.lua136
-rw-r--r--src/luaotfload-main.lua4
-rw-r--r--src/luaotfload-parsers.lua96
-rwxr-xr-xsrc/luaotfload-tool.lua36
-rw-r--r--src/luaotfload.sty2
5 files changed, 206 insertions, 68 deletions
diff --git a/src/luaotfload-configuration.lua b/src/luaotfload-configuration.lua
index dfa222c..10e791a 100644
--- a/src/luaotfload-configuration.lua
+++ b/src/luaotfload-configuration.lua
@@ -5,7 +5,7 @@
-- REQUIREMENTS: Luaotfload 2.5 or above
-- AUTHOR: Philipp Gesang (Phg), <phg42.2a@gmail.com>
-- VERSION: same as Luaotfload
--- MODIFIED: 2014-07-13 14:19:32+0200
+-- MODIFIED: 2014-07-24 21:49:31+0200
-------------------------------------------------------------------------------
--
@@ -24,16 +24,17 @@ config.luaotfload = { }
local status_file = "luaotfload-status"
local luaotfloadstatus = require (status_file)
-local string = string
-local stringsub = string.sub
local stringexplode = string.explode
-local stringstrip = string.strip
local stringfind = string.find
+local stringformat = string.format
+local string = string
+local stringstrip = string.strip
+local stringsub = string.sub
-local table = table
local tableappend = table.append
-local tablecopy = table.copy
local tableconcat = table.concat
+local tablecopy = table.copy
+local table = table
local tabletohash = table.tohash
local math = math
@@ -42,8 +43,10 @@ local mathfloor = math.floor
local io = io
local ioloaddata = io.loaddata
local iopopen = io.popen
+local iowrite = io.write
local os = os
+local osdate = os.date
local osgetenv = os.getenv
local lpeg = require "lpeg"
@@ -475,6 +478,92 @@ local option_spec = {
}
-------------------------------------------------------------------------------
+--- FORMATTERS
+-------------------------------------------------------------------------------
+
+local indent = " "
+local format_string = function (var, val)
+ return stringformat (indent .. "%s = %s", var, val)
+end
+
+local format_integer = function (var, val)
+ return stringformat (indent .. "%s = %d", var, val)
+end
+
+local format_boolean = function (var, val)
+ return stringformat (indent .. "%s = %s", var, val == true and "true" or "false")
+end
+
+local format_section = function (title)
+ return stringformat ("[%s]", title)
+end
+
+local commented = function (str)
+ return ";" .. str
+end
+
+local underscore_replacer = lpeg.replacer ("_", "-", true)
+
+local dashed = function (var)
+ --- INI spec dictates that dashes are valid in variable names, not
+ --- underscores.
+ return underscore_replacer (var) or var
+end
+
+local conf_header = [==[
+;;-----------------------------------------------------------------------------
+;; Luaotfload Configuration
+;;-----------------------------------------------------------------------------
+;;
+;; This file was generated by luaotfload-tool
+;; on %s. Configuration variables
+;; are documented in the manual to luaotfload.conf(5).
+;;
+;;-----------------------------------------------------------------------------
+
+]==]
+
+local conf_footer = [==[
+
+;; vim:filetype=dosini:expandtab:shiftwidth=2
+]==]
+
+--- Each dumpable variable (the ones mentioned in the man page) receives a
+--- formatter that will be used in dumping the variable. Each value receives a
+--- “commented” flag that indicates whether or not the line should be printed
+--- as a comment.
+
+local formatters = {
+ db = {
+ compress = { false, format_boolean },
+ formats = { false, format_string },
+ max_fonts = { false, format_integer },
+ scan_local = { false, format_boolean },
+ skip_read = { false, format_boolean },
+ strip = { false, format_boolean },
+ update_live = { false, format_boolean },
+ },
+ misc = {
+ bisect = { false, format_boolean },
+ statistics = { false, format_boolean },
+ termwidth = { true , format_integer },
+ version = { true , format_string },
+ },
+ paths = {
+ cache_dir = { false, format_string },
+ names_dir = { false, format_string },
+ index_file = { false, format_string },
+ lookups_file = { false, format_string },
+ },
+ run = {
+ color_callback = { false, format_string },
+ definer = { false, format_string },
+ log_level = { false, format_integer },
+ resolver = { false, format_string },
+ },
+}
+
+-------------------------------------------------------------------------------
--- MAIN FUNCTIONALITY
-------------------------------------------------------------------------------
@@ -689,6 +778,40 @@ local apply_defaults = function ()
return reconfigure ()
end
+local dump = function ()
+ local sections = table.sortedkeys (config.luaotfload)
+ local confdata = { }
+ for i = 1, #sections do
+ local section = sections[i]
+ local vars = config.luaotfload[section]
+ local varnames = table.sortedkeys (vars)
+ local sformats = formatters[section]
+ if sformats then
+ confdata[#confdata + 1] = format_section (section)
+ for j = 1, #varnames do
+ local var = varnames[j]
+ local val = vars[var]
+ local comment, sformat = unpack (sformats[var] or { })
+ if sformat then
+ local dashedvar = dashed (var)
+ if comment then
+ confdata[#confdata + 1] = commented (sformat (dashedvar, val))
+ else
+ confdata[#confdata + 1] = sformat (dashedvar, val)
+ end
+ end
+ end
+ confdata[#confdata + 1] = ""
+ end
+ end
+ if next(confdata) then
+ iowrite (stringformat (conf_header,
+ osdate ("%Y-%m-d %H:%M:%S", os.time ())))
+ iowrite (tableconcat (confdata, "\n"))
+ iowrite (conf_footer)
+ end
+end
+
-------------------------------------------------------------------------------
--- EXPORTS
-------------------------------------------------------------------------------
@@ -700,5 +823,6 @@ config.actions = {
apply = apply,
apply_defaults = apply_defaults,
reconfigure = reconfigure,
+ dump = dump,
}
diff --git a/src/luaotfload-main.lua b/src/luaotfload-main.lua
index 0d81abb..773a3cf 100644
--- a/src/luaotfload-main.lua
+++ b/src/luaotfload-main.lua
@@ -4,7 +4,7 @@
-- REQUIREMENTS: luatex v.0.79 or later; packages lualibs, luatexbase
-- AUTHOR: Élie Roux, Khaled Hosny, Philipp Gesang
-- VERSION: same as Luaotfload
--- MODIFIED: 2014-07-16 19:48:30+0200
+-- MODIFIED: 2014-07-24 22:08:34+0200
-----------------------------------------------------------------------
--
--- Note:
@@ -48,7 +48,7 @@ local initial_log_level = 0
luaotfload = luaotfload or { }
local luaotfload = luaotfload
luaotfload.log = luaotfload.log or { }
-luaotfload.version = "2.5-1" -- FIXME version belongs in common init
+luaotfload.version = "2.5-2" -- FIXME version belongs in common init
luaotfload.module = {
name = "luaotfload-main",
diff --git a/src/luaotfload-parsers.lua b/src/luaotfload-parsers.lua
index 0461e24..3a4faea 100644
--- a/src/luaotfload-parsers.lua
+++ b/src/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--
@@ -452,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--
@@ -470,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--
@@ -496,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--
@@ -509,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
@@ -648,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")
@@ -726,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
diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua
index 89f5483..02c5a45 100755
--- a/src/luaotfload-tool.lua
+++ b/src/luaotfload-tool.lua
@@ -6,11 +6,11 @@
-- AUTHOR: Khaled Hosny, Élie Roux, Philipp Gesang
-- VERSION: 2.5
-- LICENSE: GPL v2.0
--- MODIFIED: 2014-07-16 19:45:40+0200
+-- MODIFIED: 2014-07-24 22:10:32+0200
-----------------------------------------------------------------------
luaotfload = luaotfload or { }
-local version = "2.5-1" --- <int: major>.<int: minor>-<int: fixes>
+local version = "2.5-2" --- <int: major>.<int: minor>-<int: fixes>
luaotfload.version = version
luaotfload.self = "luaotfload-tool"
@@ -739,9 +739,10 @@ set.
--]]--
local action_sequence = {
- "config", "loglevel", "help", "version",
- "diagnose", "blacklist", "cache", "flush",
- "bisect", "generate", "list", "query",
+ "config" , "loglevel" , "help" , "version" ,
+ "dumpconf" , "diagnose" , "blacklist" , "cache" ,
+ "flush" , "bisect" , "generate" , "list" ,
+ "query" ,
}
local action_pending = tabletohash(action_sequence, false)
@@ -781,6 +782,11 @@ actions.version = function (job)
return true, false
end
+actions.dumpconf = function (job)
+ config.actions.dump ()
+ return true, false
+end
+
actions.help = function (job)
help_msg (job.help_version or "luaotfload-tool")
return true, false
@@ -1413,6 +1419,7 @@ local process_cmdline = function ( ) -- unit -> jobspec
cache = 1,
conf = 1,
diagnose = 1,
+ dumpconf = 0,
["dry-run"] = "D",
["flush-lookups"] = "l",
fields = 1,
@@ -1551,15 +1558,20 @@ local process_cmdline = function ( ) -- unit -> jobspec
result.bisect = optarg[n]
action_pending.bisect = true
elseif v == "conf" then
- local extra = stringexplode (optarg[n], ",+")
- if extra then
- local extra_config = result.extra_config
- if extra_config then
- table.append (extra_config, extra)
- else
- result.extra_config = extra
+ local confname = optarg[n]
+ if confname then
+ local extra = stringexplode (optarg[n], ",+")
+ if extra then
+ local extra_config = result.extra_config
+ if extra_config then
+ table.append (extra_config, extra)
+ else
+ result.extra_config = extra
+ end
end
end
+ elseif v == "dumpconf" then
+ action_pending["dumpconf"] = true
elseif v == "print-conf" then
result.print_config = true
end
diff --git a/src/luaotfload.sty b/src/luaotfload.sty
index f09193b..4ebe3cb 100644
--- a/src/luaotfload.sty
+++ b/src/luaotfload.sty
@@ -40,7 +40,7 @@
\ProvidesPackage{luaotfload}%
%% FIXME The date is meaningless, we need to find a way to
%% use the git revision instead.
- [2014/07/16 v2.5-1 OpenType layout system]
+ [2014/07/24 v2.5-2 OpenType layout system]
\RequirePackage{luatexbase}
\fi
\RequireLuaModule{luaotfload-main}