mirror of
https://github.com/lua/lua.git
synced 2025-07-25 15:34:30 +00:00
Details (typos in comments)
This commit is contained in:
parent
50fd8d03c3
commit
9b014d4bcd
16 changed files with 29 additions and 30 deletions
2
ldo.c
2
ldo.c
|
@ -513,7 +513,7 @@ l_sinline void genmoveresults (lua_State *L, StkId res, int nres,
|
||||||
** to 'res'. Handle most typical cases (zero results for commands,
|
** to 'res'. Handle most typical cases (zero results for commands,
|
||||||
** one result for expressions, multiple results for tail calls/single
|
** one result for expressions, multiple results for tail calls/single
|
||||||
** parameters) separated. The flag CIST_TBC in 'fwanted', if set,
|
** parameters) separated. The flag CIST_TBC in 'fwanted', if set,
|
||||||
** forces the swicth to go to the default case.
|
** forces the switch to go to the default case.
|
||||||
*/
|
*/
|
||||||
l_sinline void moveresults (lua_State *L, StkId res, int nres,
|
l_sinline void moveresults (lua_State *L, StkId res, int nres,
|
||||||
l_uint32 fwanted) {
|
l_uint32 fwanted) {
|
||||||
|
|
1
lgc.c
1
lgc.c
|
@ -126,7 +126,6 @@ static l_mem objsize (GCObject *o) {
|
||||||
CClosure *cl = gco2ccl(o);
|
CClosure *cl = gco2ccl(o);
|
||||||
res = sizeCclosure(cl->nupvalues);
|
res = sizeCclosure(cl->nupvalues);
|
||||||
break;
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case LUA_VUSERDATA: {
|
case LUA_VUSERDATA: {
|
||||||
Udata *u = gco2u(o);
|
Udata *u = gco2u(o);
|
||||||
|
|
|
@ -561,7 +561,7 @@ static void closegoto (LexState *ls, int g, Labeldesc *label, int bup) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Search for an active label with the given name, starting at
|
** Search for an active label with the given name, starting at
|
||||||
** index 'ilb' (so that it can searh for all labels in current block
|
** index 'ilb' (so that it can search for all labels in current block
|
||||||
** or all labels in current function).
|
** or all labels in current function).
|
||||||
*/
|
*/
|
||||||
static Labeldesc *findlabel (LexState *ls, TString *name, int ilb) {
|
static Labeldesc *findlabel (LexState *ls, TString *name, int ilb) {
|
||||||
|
|
2
lvm.c
2
lvm.c
|
@ -327,7 +327,7 @@ lu_byte luaV_finishget (lua_State *L, const TValue *t, TValue *key,
|
||||||
** Finish a table assignment 't[key] = val'.
|
** Finish a table assignment 't[key] = val'.
|
||||||
** About anchoring the table before the call to 'luaH_finishset':
|
** About anchoring the table before the call to 'luaH_finishset':
|
||||||
** This call may trigger an emergency collection. When loop>0,
|
** This call may trigger an emergency collection. When loop>0,
|
||||||
** the table being acessed is a field in some metatable. If this
|
** the table being accessed is a field in some metatable. If this
|
||||||
** metatable is weak and the table is not anchored, this collection
|
** metatable is weak and the table is not anchored, this collection
|
||||||
** could collect that table while it is being updated.
|
** could collect that table while it is being updated.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -114,7 +114,7 @@ end
|
||||||
|
|
||||||
-- testing warnings
|
-- testing warnings
|
||||||
T.testC([[
|
T.testC([[
|
||||||
warningC "#This shold be a"
|
warningC "#This should be a"
|
||||||
warningC " single "
|
warningC " single "
|
||||||
warning "warning"
|
warning "warning"
|
||||||
warningC "#This should be "
|
warningC "#This should be "
|
||||||
|
@ -162,7 +162,7 @@ do -- test returning more results than fit in the caller stack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
do -- testing multipe returns
|
do -- testing multiple returns
|
||||||
local function foo (n)
|
local function foo (n)
|
||||||
if n > 0 then return n, foo(n - 1) end
|
if n > 0 then return n, foo(n - 1) end
|
||||||
end
|
end
|
||||||
|
@ -902,7 +902,7 @@ F = function (x)
|
||||||
assert(T.udataval(A) == B)
|
assert(T.udataval(A) == B)
|
||||||
debug.getmetatable(A) -- just access it
|
debug.getmetatable(A) -- just access it
|
||||||
end
|
end
|
||||||
A = x -- ressurect userdata
|
A = x -- resurrect userdata
|
||||||
B = udval
|
B = udval
|
||||||
return 1,2,3
|
return 1,2,3
|
||||||
end
|
end
|
||||||
|
|
|
@ -60,7 +60,7 @@ assert((x>y) and x or y == 2);
|
||||||
|
|
||||||
assert(1234567890 == tonumber('1234567890') and 1234567890+1 == 1234567891)
|
assert(1234567890 == tonumber('1234567890') and 1234567890+1 == 1234567891)
|
||||||
|
|
||||||
do -- testing operators with diffent kinds of constants
|
do -- testing operators with different kinds of constants
|
||||||
-- operands to consider:
|
-- operands to consider:
|
||||||
-- * fit in register
|
-- * fit in register
|
||||||
-- * constant doesn't fit in register
|
-- * constant doesn't fit in register
|
||||||
|
|
|
@ -431,7 +431,7 @@ do
|
||||||
assert(a == nil and not b)
|
assert(a == nil and not b)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- testing iteraction between multiple values x hooks
|
-- testing interaction between multiple values x hooks
|
||||||
do
|
do
|
||||||
local function f(...) return 3, ... end
|
local function f(...) return 3, ... end
|
||||||
local count = 0
|
local count = 0
|
||||||
|
@ -587,7 +587,7 @@ t = getupvalues(foo2)
|
||||||
assert(t.a == 1 and t.b == 2 and t.c == 3)
|
assert(t.a == 1 and t.b == 2 and t.c == 3)
|
||||||
assert(debug.setupvalue(foo1, 1, "xuxu") == "b")
|
assert(debug.setupvalue(foo1, 1, "xuxu") == "b")
|
||||||
assert(({debug.getupvalue(foo2, 3)})[2] == "xuxu")
|
assert(({debug.getupvalue(foo2, 3)})[2] == "xuxu")
|
||||||
-- upvalues of C functions are allways "called" "" (the empty string)
|
-- upvalues of C functions are always named "" (the empty string)
|
||||||
assert(debug.getupvalue(string.gmatch("x", "x"), 1) == "")
|
assert(debug.getupvalue(string.gmatch("x", "x"), 1) == "")
|
||||||
|
|
||||||
|
|
||||||
|
@ -839,7 +839,7 @@ t[1] = "'error'"
|
||||||
checktraceback(co, t)
|
checktraceback(co, t)
|
||||||
|
|
||||||
|
|
||||||
-- test acessing line numbers of a coroutine from a resume inside
|
-- test accessing line numbers of a coroutine from a resume inside
|
||||||
-- a C function (this is a known bug in Lua 5.0)
|
-- a C function (this is a known bug in Lua 5.0)
|
||||||
|
|
||||||
local function g(x)
|
local function g(x)
|
||||||
|
@ -966,9 +966,9 @@ local debug = require'debug'
|
||||||
local a = 12 -- a local variable
|
local a = 12 -- a local variable
|
||||||
|
|
||||||
local n, v = debug.getlocal(1, 1)
|
local n, v = debug.getlocal(1, 1)
|
||||||
assert(n == "(temporary)" and v == debug) -- unkown name but known value
|
assert(n == "(temporary)" and v == debug) -- unknown name but known value
|
||||||
n, v = debug.getlocal(1, 2)
|
n, v = debug.getlocal(1, 2)
|
||||||
assert(n == "(temporary)" and v == 12) -- unkown name but known value
|
assert(n == "(temporary)" and v == 12) -- unknown name but known value
|
||||||
|
|
||||||
-- a function with an upvalue
|
-- a function with an upvalue
|
||||||
local f = function () local x; return a end
|
local f = function () local x; return a end
|
||||||
|
@ -1018,7 +1018,7 @@ do -- bug in 5.4.0: line hooks in stripped code
|
||||||
line = l
|
line = l
|
||||||
end, "l")
|
end, "l")
|
||||||
assert(s() == 2); debug.sethook(nil)
|
assert(s() == 2); debug.sethook(nil)
|
||||||
assert(line == nil) -- hook called withoug debug info for 1st instruction
|
assert(line == nil) -- hook called without debug info for 1st instruction
|
||||||
end
|
end
|
||||||
|
|
||||||
do -- tests for 'source' in binary dumps
|
do -- tests for 'source' in binary dumps
|
||||||
|
|
|
@ -507,7 +507,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
if not _soft then
|
if not _soft then
|
||||||
-- several tests that exaust the Lua stack
|
-- several tests that exhaust the Lua stack
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
print"testing stack overflow"
|
print"testing stack overflow"
|
||||||
local C = 0
|
local C = 0
|
||||||
|
|
|
@ -478,7 +478,7 @@ do print("testing flush")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- test for multipe arguments in 'lines'
|
-- test for multiple arguments in 'lines'
|
||||||
io.output(file); io.write"0123456789\n":close()
|
io.output(file); io.write"0123456789\n":close()
|
||||||
for a,b in io.lines(file, 1, 1) do
|
for a,b in io.lines(file, 1, 1) do
|
||||||
if a == "\n" then assert(not b)
|
if a == "\n" then assert(not b)
|
||||||
|
|
|
@ -446,8 +446,8 @@ do -- tests for string keys in weak tables
|
||||||
local m = collectgarbage("count") -- current memory
|
local m = collectgarbage("count") -- current memory
|
||||||
local a = setmetatable({}, {__mode = "kv"})
|
local a = setmetatable({}, {__mode = "kv"})
|
||||||
a[string.rep("a", 2^22)] = 25 -- long string key -> number value
|
a[string.rep("a", 2^22)] = 25 -- long string key -> number value
|
||||||
a[string.rep("b", 2^22)] = {} -- long string key -> colectable value
|
a[string.rep("b", 2^22)] = {} -- long string key -> collectable value
|
||||||
a[{}] = 14 -- colectable key
|
a[{}] = 14 -- collectable key
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
local k, v = next(a) -- string key with number value preserved
|
local k, v = next(a) -- string key with number value preserved
|
||||||
assert(k == string.rep("a", 2^22) and v == 25)
|
assert(k == string.rep("a", 2^22) and v == 25)
|
||||||
|
@ -459,7 +459,7 @@ do -- tests for string keys in weak tables
|
||||||
assert(next(a) == nil)
|
assert(next(a) == nil)
|
||||||
-- make sure will not try to compare with dead key
|
-- make sure will not try to compare with dead key
|
||||||
assert(a[string.rep("b", 100)] == undef)
|
assert(a[string.rep("b", 100)] == undef)
|
||||||
assert(collectgarbage("count") <= m + 1) -- eveything collected
|
assert(collectgarbage("count") <= m + 1) -- everything collected
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ do
|
||||||
local co = coroutine.create(f)
|
local co = coroutine.create(f)
|
||||||
assert(coroutine.resume(co, co))
|
assert(coroutine.resume(co, co))
|
||||||
end
|
end
|
||||||
-- Now, thread and closure are not reacheable any more.
|
-- Now, thread and closure are not reachable any more.
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
assert(collected)
|
assert(collected)
|
||||||
collectgarbage("restart")
|
collectgarbage("restart")
|
||||||
|
@ -644,7 +644,7 @@ do
|
||||||
assert(getmetatable(o) == tt)
|
assert(getmetatable(o) == tt)
|
||||||
-- create new objects during GC
|
-- create new objects during GC
|
||||||
local a = 'xuxu'..(10+3)..'joao', {}
|
local a = 'xuxu'..(10+3)..'joao', {}
|
||||||
___Glob = o -- ressurrect object!
|
___Glob = o -- resurrect object!
|
||||||
setmetatable({}, tt) -- creates a new one with same metatable
|
setmetatable({}, tt) -- creates a new one with same metatable
|
||||||
print(">>> closing state " .. "<<<\n")
|
print(">>> closing state " .. "<<<\n")
|
||||||
end
|
end
|
||||||
|
|
|
@ -1162,7 +1162,7 @@ do
|
||||||
local function open (x)
|
local function open (x)
|
||||||
numopen = numopen + 1
|
numopen = numopen + 1
|
||||||
return
|
return
|
||||||
function () -- iteraction function
|
function () -- iteration function
|
||||||
x = x - 1
|
x = x - 1
|
||||||
if x > 0 then return x end
|
if x > 0 then return x end
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -226,7 +226,7 @@ RUN("lua -l 'str=string' '-lm=math' -e 'print(m.sin(0))' %s > %s", prog, out)
|
||||||
checkout("0.0\nALO ALO\t20\n")
|
checkout("0.0\nALO ALO\t20\n")
|
||||||
|
|
||||||
|
|
||||||
-- test module names with version sufix ("libs/lib2-v2")
|
-- test module names with version suffix ("libs/lib2-v2")
|
||||||
RUN("env LUA_CPATH='./libs/?.so' lua -l lib2-v2 -e 'print(lib2.id())' > %s",
|
RUN("env LUA_CPATH='./libs/?.so' lua -l lib2-v2 -e 'print(lib2.id())' > %s",
|
||||||
out)
|
out)
|
||||||
checkout("true\n")
|
checkout("true\n")
|
||||||
|
@ -347,7 +347,7 @@ checkout("a\n")
|
||||||
RUN([[lua "-eprint(1)" -ea=3 -e "print(a)" > %s]], out)
|
RUN([[lua "-eprint(1)" -ea=3 -e "print(a)" > %s]], out)
|
||||||
checkout("1\n3\n")
|
checkout("1\n3\n")
|
||||||
|
|
||||||
-- test iteractive mode
|
-- test interactive mode
|
||||||
prepfile[[
|
prepfile[[
|
||||||
(6*2-6) -- ===
|
(6*2-6) -- ===
|
||||||
a =
|
a =
|
||||||
|
|
|
@ -1071,7 +1071,7 @@ do
|
||||||
assert(x == tonumber(tostring(x)))
|
assert(x == tonumber(tostring(x)))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- different numbers shold print differently.
|
-- different numbers should print differently.
|
||||||
-- check pairs of floats with minimum detectable difference
|
-- check pairs of floats with minimum detectable difference
|
||||||
local p = floatbits - 1
|
local p = floatbits - 1
|
||||||
for i = 1, maxexp - 1 do
|
for i = 1, maxexp - 1 do
|
||||||
|
|
|
@ -227,7 +227,7 @@ for i = 1,lim do
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- insert and delete elements until a rehash occurr. Caller must ensure
|
-- insert and delete elements until a rehash occur. Caller must ensure
|
||||||
-- that a rehash will change the shape of the table. Must repeat because
|
-- that a rehash will change the shape of the table. Must repeat because
|
||||||
-- the insertion may collide with the deleted element, and then there is
|
-- the insertion may collide with the deleted element, and then there is
|
||||||
-- no rehash.
|
-- no rehash.
|
||||||
|
@ -349,7 +349,7 @@ a,b,c = 1,2,3
|
||||||
a,b,c = nil
|
a,b,c = nil
|
||||||
|
|
||||||
|
|
||||||
-- next uses always the same iteraction function
|
-- next uses always the same iteration function
|
||||||
assert(next{} == next{})
|
assert(next{} == next{})
|
||||||
|
|
||||||
local function find (name)
|
local function find (name)
|
||||||
|
|
|
@ -23,9 +23,9 @@ a,b = string.find('alo', '')
|
||||||
assert(a == 1 and b == 0)
|
assert(a == 1 and b == 0)
|
||||||
a,b = string.find('a\0o a\0o a\0o', 'a', 1) -- first position
|
a,b = string.find('a\0o a\0o a\0o', 'a', 1) -- first position
|
||||||
assert(a == 1 and b == 1)
|
assert(a == 1 and b == 1)
|
||||||
a,b = string.find('a\0o a\0o a\0o', 'a\0o', 2) -- starts in the midle
|
a,b = string.find('a\0o a\0o a\0o', 'a\0o', 2) -- starts in the middle
|
||||||
assert(a == 5 and b == 7)
|
assert(a == 5 and b == 7)
|
||||||
a,b = string.find('a\0o a\0o a\0o', 'a\0o', 9) -- starts in the midle
|
a,b = string.find('a\0o a\0o a\0o', 'a\0o', 9) -- starts in the middle
|
||||||
assert(a == 9 and b == 11)
|
assert(a == 9 and b == 11)
|
||||||
a,b = string.find('a\0a\0a\0a\0\0ab', '\0ab', 2); -- finds at the end
|
a,b = string.find('a\0a\0a\0a\0\0ab', '\0ab', 2); -- finds at the end
|
||||||
assert(a == 9 and b == 11);
|
assert(a == 9 and b == 11);
|
||||||
|
|
|
@ -134,7 +134,7 @@ do
|
||||||
errorcodes("\xbfinvalid")
|
errorcodes("\xbfinvalid")
|
||||||
errorcodes("αλφ\xBFα")
|
errorcodes("αλφ\xBFα")
|
||||||
|
|
||||||
-- calling interation function with invalid arguments
|
-- calling iteration function with invalid arguments
|
||||||
local f = utf8.codes("")
|
local f = utf8.codes("")
|
||||||
assert(f("", 2) == nil)
|
assert(f("", 2) == nil)
|
||||||
assert(f("", -1) == nil)
|
assert(f("", -1) == nil)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue