Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 1 changed file with 18 additions and 6 deletions. Show diff stats Hide diff stats

  1. +18 6 lualint
24 lualint
@@ -80,6 +80,9 @@ Jay Carlson (nop@nop.com)
80 80 This is all Ben Jackson's (ben@ben.com) fault, who did some similar
81 81 tricks in MOO.
82 82
  83 +FIXED:
  84 +Section "5.3 - Modules" in http://www.lua.org/manual/5.1/manual.html describes the syntax of the LUA_PATH string as follows:
  85 +"./?.lua;./?.lc;/usr/local/?/init.lua".
83 86 ]]
84 87
85 88
@@ -113,18 +116,27 @@ end
113 116
114 117 -- borrowed from LTN11
115 118 local function locate(name)
116   - local path = LUA_PATH
117 119
118   - if type(path) ~= "string" then
119   - path = os.getenv "LUA_PATH" .. ";"
  120 + local paths = ""
  121 +
  122 + if type(LUA_PATH) == "string" then
  123 + -- Use the LUA_PATH variable
  124 + paths = LUA_PATH
  125 + else
  126 + -- Try to get the LUA_PATH env variable
  127 + local env_lua_path = os.getenv "LUA_PATH"
  128 + if type(env_lua_path) == "string" then
  129 + paths = env_lua_path
  130 + end
120 131 end
121 132
122 133 -- Add current directory
123   - path = path .. "./"
  134 + paths = paths .. ";./?.lua"
124 135
125   - for path in string.gfind(path, "[^;]+") do
  136 + for path in string.gfind(paths, "[^;]+") do
126 137 -- Construct full filename from path, module name and file extension
127   - path = path .. name .. ".lua"
  138 + path = string.gsub(path, "?", name)
  139 +
128 140 if fileexists(path) then
129 141 return path
130 142 end

0 comments on commit 9926e29

Please sign in to comment.
Something went wrong with that request. Please try again.