From 9ba8d2aea994c832316f111354668f52de831043 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Sat, 5 Apr 2008 18:35:33 +0000 Subject: * Remove ffluci.util.__file__ as it relies on debug information * Added ffluci.debug for things that rely on debug information * Fixed a bug regarding path detection when Luci is bytecompiled --- Makefile | 2 +- src/ffluci/cbi.lua | 3 ++- src/ffluci/config.lua | 4 ++++ src/ffluci/debug.lua | 2 ++ src/ffluci/i18n.lua | 4 +--- src/ffluci/menu.lua | 3 ++- src/ffluci/template.lua | 2 +- src/ffluci/util.lua | 6 ------ 8 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 src/ffluci/debug.lua diff --git a/Makefile b/Makefile index 0aefd193c1..57b3efd629 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ LUAC = luac LUAC_OPTIONS = -s -FILES = +FILES = ffluci/debug.lua CFILES = ffluci/util.lua ffluci/http.lua ffluci/fs.lua \ ffluci/sys.lua ffluci/model/uci.lua ffluci/model/ipkg.lua \ diff --git a/src/ffluci/cbi.lua b/src/ffluci/cbi.lua index 5bc40499c8..1ccf2e56d2 100644 --- a/src/ffluci/cbi.lua +++ b/src/ffluci/cbi.lua @@ -38,8 +38,9 @@ local instanceof = ffluci.util.instanceof function load(cbimap) require("ffluci.fs") require("ffluci.i18n") + require("ffluci.config") - local cbidir = ffluci.fs.dirname(ffluci.util.__file__()) .. "/model/cbi/" + local cbidir = ffluci.config.path .. "/model/cbi/" local func, err = loadfile(cbidir..cbimap..".lua") if not func then diff --git a/src/ffluci/config.lua b/src/ffluci/config.lua index 8b94db8089..8b1a73dc7e 100644 --- a/src/ffluci/config.lua +++ b/src/ffluci/config.lua @@ -28,6 +28,10 @@ limitations under the License. module("ffluci.config", package.seeall) require("ffluci.model.uci") require("ffluci.util") +require("ffluci.debug") + +-- Our path (wtf Lua lacks __file__ support) +path = ffluci.debug.path -- Warning! This is only for fallback and compatibility purporses! -- main = {} diff --git a/src/ffluci/debug.lua b/src/ffluci/debug.lua new file mode 100644 index 0000000000..f1132edcc4 --- /dev/null +++ b/src/ffluci/debug.lua @@ -0,0 +1,2 @@ +module("ffluci.debug", package.seeall) +path = require("ffluci.fs").dirname(debug.getinfo(1, 'S').source:sub(2)) \ No newline at end of file diff --git a/src/ffluci/i18n.lua b/src/ffluci/i18n.lua index c362d3e5f0..11f4afe871 100644 --- a/src/ffluci/i18n.lua +++ b/src/ffluci/i18n.lua @@ -26,12 +26,10 @@ limitations under the License. module("ffluci.i18n", package.seeall) -require("ffluci.fs") -require("ffluci.util") require("ffluci.config") table = {} -i18ndir = ffluci.fs.dirname(ffluci.util.__file__()) .. "/i18n/" +i18ndir = ffluci.config.path .. "/i18n/" -- Clears the translation table function clear() diff --git a/src/ffluci/menu.lua b/src/ffluci/menu.lua index cbf47e2e3e..5a5f421e9d 100644 --- a/src/ffluci/menu.lua +++ b/src/ffluci/menu.lua @@ -29,9 +29,10 @@ require("ffluci.fs") require("ffluci.util") require("ffluci.template") require("ffluci.i18n") +require("ffluci.config") -- Default modelpath -modelpath = ffluci.fs.dirname(ffluci.util.__file__()) .. "/model/menu/" +modelpath = ffluci.config.path .. "/model/menu/" -- Menu definition extra scope scope = { diff --git a/src/ffluci/template.lua b/src/ffluci/template.lua index 52bebbcf4a..589f43c679 100644 --- a/src/ffluci/template.lua +++ b/src/ffluci/template.lua @@ -31,7 +31,7 @@ require("ffluci.fs") require("ffluci.i18n") require("ffluci.model.uci") -viewdir = ffluci.fs.dirname(ffluci.util.__file__()) .. "/view/" +viewdir = ffluci.config.path .. "/view/" -- Compile modes: diff --git a/src/ffluci/util.lua b/src/ffluci/util.lua index a33d141e60..dfc88e3e41 100644 --- a/src/ffluci/util.lua +++ b/src/ffluci/util.lua @@ -205,10 +205,4 @@ function validate(value, cast_number, cast_int) end return value -end - - --- Returns the filename of the calling script -function __file__() - return debug.getinfo(2, 'S').source:sub(2) end \ No newline at end of file -- cgit v1.2.3