From 2c79c7d38d6dcb41f52eb7f44fb744771408ec39 Mon Sep 17 00:00:00 2001
From: Philipp Gesang <phg42.2a@gmail.com>
Date: Mon, 13 May 2013 20:42:38 +0200
Subject: work around unsupported full paths in anon lookups

windows only: http://tug.org/pipermail/lualatex-dev/2013-May/001519.html
---
 luaotfload.dtx | 40 +++++++++++++++++++++++++++++++++-------
 1 file changed, 33 insertions(+), 7 deletions(-)

(limited to 'luaotfload.dtx')

diff --git a/luaotfload.dtx b/luaotfload.dtx
index e576112..16f7bf6 100644
--- a/luaotfload.dtx
+++ b/luaotfload.dtx
@@ -1832,13 +1832,13 @@ local resolvefile = fonts.names.crude_file_lookup
 --local resolvefile = fonts.names.crude_file_lookup_verbose
 
 function request_resolvers.file(specification)
-  local name=resolvefile(specification.name)
-  local suffix=file.suffix(name)
+  local name    = resolvefile(specification.name)
+  local suffix  = file.suffix(name)
   if formats[suffix] then
-    specification.forced=suffix
-    specification.name=file.removesuffix(name)
+    specification.forced  = suffix
+    specification.name    = file.removesuffix(name)
   else
-    specification.name=name
+    specification.name = name
   end
 end
 
@@ -1869,6 +1869,7 @@ end
 % For this reason, we introduce an extra check with an early return.
 %
 %    \begin{macrocode}
+
 local type1_formats = { "tfm", "ofm", }
 
 request_resolvers.anon = function (specification)
@@ -1880,6 +1881,20 @@ request_resolvers.anon = function (specification)
             return
         end
     end
+    --- under some weird circumstances absolute paths get
+    --- passed to the definer; we have to catch them
+    --- before the name: resolver misinterprets them.
+    name = specification.specification
+    local exists, _ = lfsisfile(name)
+    if exists then --- garbage; we do this because we are nice,
+                   --- not because it is correct
+        logs.names_report("log", 1, "load", "file “%s” exists", name)
+        logs.names_report("log", 1, "load",
+          "... overriding borked anon: lookup with path: lookup")
+        specification.name = name
+        request_resolvers.path(specification)
+        return
+    end
     request_resolvers.name(specification)
 end
 
@@ -1892,9 +1907,21 @@ end
 %
 %    \begin{macrocode}
 request_resolvers.path = function (specification)
-    local exists, _ = lfsisfile(specification.name)
+    local name       = specification.name
+    local exists, _  = lfsisfile(name)
     if not exists then -- resort to file: lookup
+        logs.names_report("log", 1, "load",
+          "path lookup of “%s” unsuccessful, falling back to file:",
+          name)
         request_resolvers.file(specification)
+    else
+      local suffix = file.suffix(name)
+      if formats[suffix] then
+        specification.forced  = suffix
+        specification.name    = file.removesuffix(name)
+      else
+        specification.name = name
+      end
     end
 end
 
@@ -1956,7 +1983,6 @@ loadmodule"auxiliary.lua"   --- additionaly high-level functionality (new)
 
 -- vim:tw=71:sw=4:ts=4:expandtab
 
-
 %    \end{macrocode}
 %
 % \iffalse
-- 
cgit v1.2.3

