mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-14 08:30:58 +00:00
Lunatic: make require() translate dots to dir separators, make those illegal.
However, from the command line, reverse the situation: dirseps must be passed as '/', dots are forbidden (except in the trailing ".lua"). git-svn-id: https://svn.eduke32.com/eduke32@3867 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
2003954492
commit
224702b619
2 changed files with 21 additions and 6 deletions
|
@ -1477,6 +1477,13 @@ local function our_require(modname, ...)
|
||||||
|
|
||||||
--- Search user modules...
|
--- Search user modules...
|
||||||
|
|
||||||
|
if (modname:find("[/\\]")) then
|
||||||
|
error("Module name must not contain directory separators", ERRLEV-1)
|
||||||
|
end
|
||||||
|
-- Instead, dots are translated to directory separators. For EDuke32's
|
||||||
|
-- virtual file system, this is always a forward slash.
|
||||||
|
modname = modname:gsub("%.", "/")
|
||||||
|
|
||||||
local omod = package_loaded[modname]
|
local omod = package_loaded[modname]
|
||||||
if (omod ~= nil) then
|
if (omod ~= nil) then
|
||||||
if (omod==false) then
|
if (omod==false) then
|
||||||
|
@ -2038,8 +2045,16 @@ end
|
||||||
if (not g_firstRun) then
|
if (not g_firstRun) then
|
||||||
local i=0
|
local i=0
|
||||||
while (ffiC.g_elModules[i] ~= nil) do
|
while (ffiC.g_elModules[i] ~= nil) do
|
||||||
local modname = ffi.string(ffiC.g_elModules[i])
|
-- Get the module name and strip the trailing extension.
|
||||||
our_require((modname:gsub("%.lua$","")))
|
local modname = ffi.string(ffiC.g_elModules[i]):gsub("%.lua$","")
|
||||||
|
|
||||||
|
if (modname:find("%.")) then
|
||||||
|
-- Because they will be replaced by dirseps in our_require().
|
||||||
|
error("Dots are not permitted in module names", 0)
|
||||||
|
end
|
||||||
|
-- Allow forward slashes in module names from the cmdline.
|
||||||
|
our_require((modname:gsub("%.lua$",""):gsub("/",".")))
|
||||||
|
|
||||||
i = i+1
|
i = i+1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -180,7 +180,7 @@ checkfail('local spr = sprite[0]; local x=spr+1', "attempt to perform arithmetic
|
||||||
|
|
||||||
checkfail('gameactor(1680, 0)', "invalid last argument to gameactor: must be a function")
|
checkfail('gameactor(1680, 0)', "invalid last argument to gameactor: must be a function")
|
||||||
|
|
||||||
checkfail("do local bt=require'test/test_bitar'; bt.QWE=1; end", "modifying module table forbidden")
|
checkfail("do local bt=require'test.test_bitar'; bt.QWE=1; end", "modifying module table forbidden")
|
||||||
-- the cdata returned by player[] can't be made into a pointer!
|
-- the cdata returned by player[] can't be made into a pointer!
|
||||||
checkfail("do local pl=player[0]; i=pl[1]; end")
|
checkfail("do local pl=player[0]; i=pl[1]; end")
|
||||||
checkfail("do local ud=gv.ud.camerasprite; end", "access forbidden") -- test for proper decl()
|
checkfail("do local ud=gv.ud.camerasprite; end", "access forbidden") -- test for proper decl()
|
||||||
|
@ -470,11 +470,11 @@ end)
|
||||||
|
|
||||||
printf("EVENT_INIT = %d", gv.EVENT_INIT) -- tests default defines
|
printf("EVENT_INIT = %d", gv.EVENT_INIT) -- tests default defines
|
||||||
|
|
||||||
local bittest = require "test/test_bitar"
|
local bittest = require "test.test_bitar"
|
||||||
bittest.sieve()
|
bittest.sieve()
|
||||||
|
|
||||||
require("test/test_geom")
|
require("test.test_geom")
|
||||||
require("test/test_rotspr")
|
require("test.test_rotspr")
|
||||||
|
|
||||||
do
|
do
|
||||||
-- Test ksin vs. sinb
|
-- Test ksin vs. sinb
|
||||||
|
|
Loading…
Reference in a new issue