Skip to content

Commit

Permalink
Merge pull request #34 from walterschell/v5.4.7
Browse files Browse the repository at this point in the history
Updated to v5.4.7
  • Loading branch information
walterschell authored Sep 11, 2024
2 parents 88246d6 + 54bbece commit 52674cd
Show file tree
Hide file tree
Showing 123 changed files with 558 additions and 382 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.1)
project(lua LANGUAGES C VERSION 5.4.6)
project(lua LANGUAGES C VERSION 5.4.7)

option(LUA_SUPPORT_DL "Support dynamic loading of compiled modules" OFF)
option(LUA_BUILD_AS_CXX "Build lua as C++" OFF)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Lua
CMake based build of Lua 5.4.6
CMake based build of Lua 5.4.7
| Build as C | Build as C++ |
| --: | --: |
| ![Build Linux](https://github.com/walterschell/Lua/actions/workflows/build-linux.yml/badge.svg?branch=master) | ![Build Linux as C++](https://github.com/walterschell/Lua/actions/workflows/build-linux-cxx.yml/badge.svg?branch=master) |
Expand Down
Binary file removed lua-5.4.6/doc/osi-certified-72x60.png
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 0 additions & 14 deletions lua-5.4.6-tests/calls.lua → lua-5.4.7-tests/calls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -342,20 +342,6 @@ do -- another bug (in 5.4.0)
end


do -- another bug (since 5.2)
-- corrupted binary dump: list of upvalue names is larger than number
-- of upvalues, overflowing the array of upvalues.
local code =
"\x1b\x4c\x75\x61\x54\x00\x19\x93\x0d\x0a\x1a\x0a\x04\x08\x08\x78\x56\z
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x28\x77\x40\x00\x86\x40\z
\x74\x65\x6d\x70\x81\x81\x01\x00\x02\x82\x48\x00\x02\x00\xc7\x00\x01\z
\x00\x80\x80\x80\x82\x00\x00\x80\x81\x82\x78\x80\x82\x81\x86\x40\x74\z
\x65\x6d\x70"

assert(load(code)) -- segfaults in previous versions
end


x = string.dump(load("x = 1; return x"))
a = assert(load(read1(x), nil, "b"))
assert(a() == 1 and _G.x == 1)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -610,18 +610,20 @@ else
-- (bug in 5.2/5.3)
c = coroutine.create(function (a, ...)
T.sethook("yield 0", "l") -- will yield on next two lines
assert(a == 10)
local b = a
return ...
end)

assert(coroutine.resume(c, 1, 2, 3)) -- start coroutine
local n,v = debug.getlocal(c, 0, 1) -- check its local
assert(n == "a" and v == 1)
assert(n == "a" and v == 1 and debug.getlocal(c, 0, 2) ~= "b")
assert(debug.setlocal(c, 0, 1, 10)) -- test 'setlocal'
local t = debug.getinfo(c, 0) -- test 'getinfo'
assert(t.currentline == t.linedefined + 1)
assert(t.currentline == t.linedefined + 2)
assert(not debug.getinfo(c, 1)) -- no other level
assert(coroutine.resume(c)) -- run next line
local n,v = debug.getlocal(c, 0, 2) -- check next local
assert(n == "b" and v == 10)
v = {coroutine.resume(c)} -- finish coroutine
assert(v[1] == true and v[2] == 2 and v[3] == 3 and v[4] == undef)
assert(not coroutine.resume(c))
Expand Down
File renamed without changes.
17 changes: 13 additions & 4 deletions lua-5.4.6-tests/db.lua → lua-5.4.7-tests/db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ do
end


-- bug in 5.4.4-5.4.6: activelines in vararg functions
-- without debug information
do
local func = load(string.dump(load("print(10)"), true))
local actl = debug.getinfo(func, "L").activelines
assert(#actl == 0) -- no line info
end


-- test file and string names truncation
local a = "function f () end"
local function dostring (s, x) return load(s, x)() end
Expand Down Expand Up @@ -345,7 +354,7 @@ function f(a,b)
local _, y = debug.getlocal(1, 2)
assert(x == a and y == b)
assert(debug.setlocal(2, 3, "pera") == "AA".."AA")
assert(debug.setlocal(2, 4, "maçã") == "B")
assert(debug.setlocal(2, 4, "manga") == "B")
x = debug.getinfo(2)
assert(x.func == g and x.what == "Lua" and x.name == 'g' and
x.nups == 2 and string.find(x.source, "^@.*db%.lua$"))
Expand Down Expand Up @@ -373,9 +382,9 @@ function g (...)
local arg = {...}
do local a,b,c; a=math.sin(40); end
local feijao
local AAAA,B = "xuxu", "mamão"
local AAAA,B = "xuxu", "abacate"
f(AAAA,B)
assert(AAAA == "pera" and B == "maçã")
assert(AAAA == "pera" and B == "manga")
do
local B = 13
local x,y = debug.getlocal(1,5)
Expand Down Expand Up @@ -928,7 +937,7 @@ do
local cl = countlines(rest)
-- at most 10 lines in first part, 11 in second, plus '...'
assert(cl <= 10 + 11 + 1)
local brk = string.find(rest, "%.%.%.")
local brk = string.find(rest, "%.%.%.\t%(skip")
if brk then -- does message have '...'?
local rest1 = string.sub(rest, 1, brk)
local rest2 = string.sub(rest, brk, #rest)
Expand Down
26 changes: 21 additions & 5 deletions lua-5.4.6-tests/errors.lua → lua-5.4.7-tests/errors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ end

if not T then
(Message or print)
('\n >>> testC not active: skipping memory message test <<<\n')
('\n >>> testC not active: skipping tests for messages in C <<<\n')
else
print "testing memory error message"
local a = {}
Expand All @@ -104,6 +104,19 @@ else
end)
T.totalmem(0)
assert(not st and msg == "not enough" .. " memory")

-- stack space for luaL_traceback (bug in 5.4.6)
local res = T.testC[[
# push 16 elements on the stack
pushnum 1; pushnum 1; pushnum 1; pushnum 1; pushnum 1;
pushnum 1; pushnum 1; pushnum 1; pushnum 1; pushnum 1;
pushnum 1; pushnum 1; pushnum 1; pushnum 1; pushnum 1;
pushnum 1;
# traceback should work with 4 remaining slots
traceback xuxu 1;
return 1
]]
assert(string.find(res, "xuxu.-main chunk"))
end


Expand All @@ -121,6 +134,9 @@ assert(not string.find(doit"aaa={13}; local bbbb=1; aaa[bbbb](3)", "'bbbb'"))
checkmessage("aaa={13}; local bbbb=1; aaa[bbbb](3)", "number")
checkmessage("aaa=(1)..{}", "a table value")

-- bug in 5.4.6
checkmessage("a = {_ENV = {}}; print(a._ENV.x + 1)", "field 'x'")

_G.aaa, _G.bbbb = nil

-- calls
Expand Down Expand Up @@ -392,19 +408,19 @@ lineerror("a\n=\n-\n\nprint\n;", 3)

lineerror([[
a
(
( -- <<
23)
]], 1)
]], 2)

lineerror([[
local a = {x = 13}
a
.
x
(
( -- <<
23
)
]], 2)
]], 5)

lineerror([[
local a = {x = 13}
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions lua-5.4.6-tests/files.lua → lua-5.4.7-tests/files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ assert(io.output():seek("end") == string.len("alo joao"))

assert(io.output():seek("set") == 0)

assert(io.write('"álo"', "{a}\n", "second line\n", "third line \n"))
assert(io.write('çfourth_line'))
assert(io.write('"alo"', "{a}\n", "second line\n", "third line \n"))
assert(io.write('Xfourth_line'))
io.output(io.stdout)
collectgarbage() -- file should be closed by GC
assert(io.input() == io.stdin and rawequal(io.output(), io.stdout))
Expand Down Expand Up @@ -300,14 +300,14 @@ do -- test error returns
end
checkerr("invalid format", io.read, "x")
assert(io.read(0) == "") -- not eof
assert(io.read(5, 'l') == '"álo"')
assert(io.read(5, 'l') == '"alo"')
assert(io.read(0) == "")
assert(io.read() == "second line")
local x = io.input():seek()
assert(io.read() == "third line ")
assert(io.input():seek("set", x))
assert(io.read('L') == "third line \n")
assert(io.read(1) == "ç")
assert(io.read(1) == "X")
assert(io.read(string.len"fourth_line") == "fourth_line")
assert(io.input():seek("cur", -string.len"fourth_line"))
assert(io.read() == "fourth_line")
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ static void badexit (const char *fmt, const char *s1, const char *s2) {


static int tpanic (lua_State *L) {
const char *msg = lua_tostring(L, -1);
if (msg == NULL) msg = "error object is not a string";
const char *msg = (lua_type(L, -1) == LUA_TSTRING)
? lua_tostring(L, -1)
: "error object is not a string";
return (badexit("PANIC: unprotected error in call to Lua API (%s)\n",
msg, NULL),
0); /* do not return to Lua */
Expand Down Expand Up @@ -1649,6 +1650,11 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) {
int nres;
status = lua_resume(lua_tothread(L1, i), L, getnum, &nres);
}
else if EQ("traceback") {
const char *msg = getstring;
int level = getnum;
luaL_traceback(L1, L1, msg, level);
}
else if EQ("return") {
int n = getnum;
if (L1 != L) {
Expand Down
File renamed without changes.
50 changes: 30 additions & 20 deletions lua-5.4.6-tests/main.lua → lua-5.4.7-tests/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@ do
end
print("progname: "..progname)

local prepfile = function (s, p)
p = p or prog
io.output(p)
io.write(s)
assert(io.close())

local prepfile = function (s, mod, p)
mod = mod and "wb" or "w" -- mod true means binary files
p = p or prog -- file to write the program
local f = io.open(p, mod)
f:write(s)
assert(f:close())
end

local function getoutput ()
io.input(out)
local t = io.read("a")
io.input():close()
local f = io.open(out)
local t = f:read("a")
f:close()
assert(os.remove(out))
return t
end
Expand Down Expand Up @@ -65,10 +67,11 @@ local function RUN (p, ...)
assert(os.execute(s))
end


local function NoRun (msg, p, ...)
p = string.gsub(p, "lua", '"'..progname..'"', 1)
local s = string.format(p, ...)
s = string.format("%s 2> %s", s, out) -- will send error to 'out'
s = string.format("%s >%s 2>&1", s, out) -- send output and error to 'out'
assert(not os.execute(s))
assert(string.find(getoutput(), msg, 1, true)) -- check error message
end
Expand Down Expand Up @@ -108,17 +111,17 @@ RUN('lua %s > %s', prog, out)
checkout("3\n")

-- bad BOMs
prepfile("\xEF")
NoRun("unexpected symbol", 'lua %s > %s', prog, out)
prepfile("\xEF", true)
NoRun("unexpected symbol", 'lua %s', prog)

prepfile("\xEF\xBB")
NoRun("unexpected symbol", 'lua %s > %s', prog, out)
prepfile("\xEF\xBB", true)
NoRun("unexpected symbol", 'lua %s', prog)

prepfile("\xEFprint(3)")
NoRun("unexpected symbol", 'lua %s > %s', prog, out)
prepfile("\xEFprint(3)", true)
NoRun("unexpected symbol", 'lua %s', prog)

prepfile("\xEF\xBBprint(3)")
NoRun("unexpected symbol", 'lua %s > %s', prog, out)
prepfile("\xEF\xBBprint(3)", true)
NoRun("unexpected symbol", 'lua %s', prog)


-- test option '-'
Expand Down Expand Up @@ -213,7 +216,7 @@ convert("a;b;;c")

-- test -l over multiple libraries
prepfile("print(1); a=2; return {x=15}")
prepfile(("print(a); print(_G['%s'].x)"):format(prog), otherprog)
prepfile(("print(a); print(_G['%s'].x)"):format(prog), false, otherprog)
RUN('env LUA_PATH="?;;" lua -l %s -l%s -lstring -l io %s > %s', prog, otherprog, otherprog, out)
checkout("1\n2\n15\n2\n15\n")

Expand All @@ -222,6 +225,13 @@ prepfile("print(str.upper'alo alo', m.max(10, 20))")
RUN("lua -l 'str=string' '-lm=math' -e 'print(m.sin(0))' %s > %s", prog, out)
checkout("0.0\nALO ALO\t20\n")


-- test module names with version sufix ("libs/lib2-v2")
RUN("env LUA_CPATH='./libs/?.so' lua -l lib2-v2 -e 'print(lib2.id())' > %s",
out)
checkout("true\n")


-- test 'arg' table
local a = [[
assert(#arg == 3 and arg[1] == 'a' and
Expand All @@ -237,7 +247,7 @@ RUN('lua "-e " -- %s a b c', prog) -- "-e " runs an empty command

-- test 'arg' availability in libraries
prepfile"assert(arg)"
prepfile("assert(arg)", otherprog)
prepfile("assert(arg)", false, otherprog)
RUN('env LUA_PATH="?;;" lua -l%s - < %s', prog, otherprog)

-- test messing up the 'arg' table
Expand Down Expand Up @@ -413,7 +423,7 @@ prepfile[[#comment in 1st line without \n at the end]]
RUN('lua %s', prog)

-- first-line comment with binary file
prepfile("#comment\n" .. string.dump(load("print(3)")))
prepfile("#comment\n" .. string.dump(load("print(3)")), true)
RUN('lua %s > %s', prog, out)
checkout('3\n')

Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 52674cd

Please sign in to comment.