[latex3-commits] [git/LaTeX3-latex3-luaotfload] wildcard-dev: Allow * globbing in luaotfload-tool (524b2ef)
Marcel Fabian Krüger
tex at 2krueger.de
Tue Feb 18 22:35:56 CET 2020
Repository : https://github.com/latex3/luaotfload
On branch : wildcard-dev
Link : https://github.com/latex3/luaotfload/commit/524b2ef0f99ff5f9e17690428a0514a55e923bd8
>---------------------------------------------------------------
commit 524b2ef0f99ff5f9e17690428a0514a55e923bd8
Author: Marcel Fabian Krüger <tex at 2krueger.de>
Date: Tue Feb 18 21:43:35 2020 +0100
Allow * globbing in luaotfload-tool
>---------------------------------------------------------------
524b2ef0f99ff5f9e17690428a0514a55e923bd8
doc/luaotfload-tool.rst | 3 ++-
src/luaotfload-tool.lua | 14 ++++++++++++--
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/doc/luaotfload-tool.rst b/doc/luaotfload-tool.rst
index 2c62138..4e50db8 100644
--- a/doc/luaotfload-tool.rst
+++ b/doc/luaotfload-tool.rst
@@ -132,7 +132,8 @@ query mode
containing ``->`` be properly quoted!
3) an expression of the form ``field:value`` to
limit the output to entries whose ``field``
- matches ``value``.
+ matches ``value``. The ``value`` can contain
+ ``*`` to match an arbitrary number of characters.
For example, in order to output file names and
corresponding versions, sorted by the font
diff --git a/src/luaotfload-tool.lua b/src/luaotfload-tool.lua
index d20c3a1..109176d 100755
--- a/src/luaotfload-tool.lua
+++ b/src/luaotfload-tool.lua
@@ -1289,6 +1289,16 @@ local function set_primary_field (fields, addme, acc, n)
return acc
end
+local function sane_pattern (p)
+ local l = lpeg or require'lpeg'
+ local special = l.Cg(l.P'*' * l.Cc'.*')
+ local pattern = l.Cs(l.Cc'^' * (special + (1 - special)^1/fonts.names.sanitize_fontname)^0 * l.Cc'$')
+ function sane_pattern (p)
+ return pattern:match(p)
+ end
+ return sane_pattern(p)
+end
+
function actions.list (job)
local criterion = job.criterion
local asked_fields = job.asked_fields
@@ -1324,7 +1334,7 @@ function actions.list (job)
else
criterion = stringexplode(criterion, ":") --> { field, value }
local asked_value = criterion[2]
- local sane_asked_value = fonts.names.sanitize_fontname(criterion[2])
+ local sane_asked_pattern = sane_pattern(criterion[2])
criterion = criterion[1]
asked_fields = set_primary_field(asked_fields, criterion)
@@ -1338,7 +1348,7 @@ function actions.list (job)
local entry = mappings[i]
local entryvalue = tostring(entry[criterion])
if entryvalue
- and (entryvalue == asked_value or entryvalue == sane_asked_value)
+ and (entryvalue == asked_value or entryvalue:match(sane_asked_pattern))
then
targets[#targets+1] = entry
end
More information about the latex3-commits
mailing list.