From dd3b52c8fe08c94dde400ced4ab875e7120a126d Mon Sep 17 00:00:00 2001
From: Elie Roux <elie.roux@telecom-bretagne.eu>
Date: Mon, 10 May 2010 10:37:31 +0300
Subject: Bug fixing in the loader

When you had gregorio.tex and gregorio.lua, the loader tried to
load gregoriotex.tex as a lua file, and obviously failed.

I added a check on the extention in the case where we look for the
name without any, and also reorganized the search order to avoid
looking for xxx.texluac before looking for xxx.lua.
---
 luatexbase-loader.dtx | 26 ++++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

(limited to 'luatexbase-loader.dtx')

diff --git a/luatexbase-loader.dtx b/luatexbase-loader.dtx
index c3eb1f6..cfbe600 100644
--- a/luatexbase-loader.dtx
+++ b/luatexbase-loader.dtx
@@ -298,17 +298,31 @@ module('luatexbase', package.seeall)
 %    Emulate (approximatively) kpse's lua format search.
 %
 %    \begin{macrocode}
-local lua_suffixes = {
-  "",
-  ".luc", ".luctex", ".texluc",
-  ".lua", ".luatex", ".texlua",
+local lua_search_suffixes = {
+  ".luc", ".lua", "", ".luctex", ".texluc",
+  ".luatex", ".texlua",
+}
+local lua_valid_suffixes = {
+  luc = true,
+  lua = true,
+  luctex = true, 
+  texluc = true,
+  luatex = true,
+  texlua = true,
 }
 local function find_file_lua_emul(name)
-  for _, suf in ipairs(lua_suffixes) do
+  for _, suf in ipairs(lua_search_suffixes) do
     local name = name..suf
     local f = kpse.find_file(name, 'texmfscripts')
       or kpse.find_file(name, 'tex')
-    if f then return f end
+    if suffix == "" and f then
+      local ext = string.match(f,"^.+%.([^/\\]-)$")
+      if lua_valid_suffixes then
+        return f
+      end
+    elseif f then
+      return f
+    end
   end
 end
 %    \end{macrocode}
-- 
cgit v1.2.3

