Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix luapath error

fix luapath error;Section "5.3 - Modules" in
http://www.lua.org/manual/5.1/manual.html describes the syntax of the
LUA_PATH string as follows:
"./?.lua;./?.lc;/usr/local/?/init.lua".
  • Loading branch information...
commit 9926e29409e1a4223963196adc6f6853a724acfd 1 parent 07f36e4
ixiaodou authored
Showing with 18 additions and 6 deletions.
  1. +18 −6 lualint
View
24 lualint
@@ -80,6 +80,9 @@ Jay Carlson (nop@nop.com)
This is all Ben Jackson's (ben@ben.com) fault, who did some similar
tricks in MOO.
+FIXED:
+Section "5.3 - Modules" in http://www.lua.org/manual/5.1/manual.html describes the syntax of the LUA_PATH string as follows:
+"./?.lua;./?.lc;/usr/local/?/init.lua".
]]
@@ -113,18 +116,27 @@ end
-- borrowed from LTN11
local function locate(name)
- local path = LUA_PATH
- if type(path) ~= "string" then
- path = os.getenv "LUA_PATH" .. ";"
+ local paths = ""
+
+ if type(LUA_PATH) == "string" then
+ -- Use the LUA_PATH variable
+ paths = LUA_PATH
+ else
+ -- Try to get the LUA_PATH env variable
+ local env_lua_path = os.getenv "LUA_PATH"
+ if type(env_lua_path) == "string" then
+ paths = env_lua_path
+ end
end
-- Add current directory
- path = path .. "./"
+ paths = paths .. ";./?.lua"
- for path in string.gfind(path, "[^;]+") do
+ for path in string.gfind(paths, "[^;]+") do
-- Construct full filename from path, module name and file extension
- path = path .. name .. ".lua"
+ path = string.gsub(path, "?", name)
+
if fileexists(path) then
return path
end
Please sign in to comment.
Something went wrong with that request. Please try again.