Comments (mosty typos)

This commit is contained in:
Roberto Ierusalimschy 2019-12-30 11:45:08 -03:00
parent d7bb8df841
commit bd1b87c579
15 changed files with 28 additions and 21 deletions

2
lapi.h
View File

@ -19,7 +19,7 @@
/* /*
** If a call returns too many multiple returns, the callee may not have ** If a call returns too many multiple returns, the callee may not have
** stack space to accomodate all results. In this case, this macro ** stack space to accommodate all results. In this case, this macro
** increases its stack space ('L->ci->top'). ** increases its stack space ('L->ci->top').
*/ */
#define adjustresults(L,nres) \ #define adjustresults(L,nres) \

View File

@ -1509,7 +1509,7 @@ static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) {
lua_assert(e1->k == VK || e1->k == VKINT || e1->k == VKFLT); lua_assert(e1->k == VK || e1->k == VKINT || e1->k == VKFLT);
swapexps(e1, e2); swapexps(e1, e2);
} }
r1 = luaK_exp2anyreg(fs, e1); /* 1nd expression must be in register */ r1 = luaK_exp2anyreg(fs, e1); /* 1st expression must be in register */
if (isSCnumber(e2, &im, &isfloat)) { if (isSCnumber(e2, &im, &isfloat)) {
op = OP_EQI; op = OP_EQI;
r2 = im; /* immediate operand */ r2 = im; /* immediate operand */

View File

@ -165,7 +165,7 @@ static int callclosemth (lua_State *L, StkId level, int status) {
if (newstatus != LUA_OK && status == CLOSEPROTECT) /* first error? */ if (newstatus != LUA_OK && status == CLOSEPROTECT) /* first error? */
status = newstatus; /* this will be the new error */ status = newstatus; /* this will be the new error */
else { else {
if (newstatus != LUA_OK) /* supressed error? */ if (newstatus != LUA_OK) /* suppressed error? */
luaE_warnerror(L, "__close metamethod"); luaE_warnerror(L, "__close metamethod");
/* leave original error (or nil) on top */ /* leave original error (or nil) on top */
L->top = restorestack(L, oldtop); L->top = restorestack(L, oldtop);

2
lmem.c
View File

@ -26,7 +26,7 @@
/* /*
** First allocation will fail whenever not building initial state ** First allocation will fail whenever not building initial state
** and not shrinking a block. (This fail will trigger 'tryagain' and ** and not shrinking a block. (This fail will trigger 'tryagain' and
** a full GC cycle at every alocation.) ** a full GC cycle at every allocation.)
*/ */
static void *firsttry (global_State *g, void *block, size_t os, size_t ns) { static void *firsttry (global_State *g, void *block, size_t os, size_t ns) {
if (ttisnil(&g->nilvalue) && ns > os) if (ttisnil(&g->nilvalue) && ns > os)

View File

@ -196,7 +196,7 @@ static int os_clock (lua_State *L) {
*/ */
/* /*
** About the overflow check: an overflow cannot occurr when time ** About the overflow check: an overflow cannot occur when time
** is represented by a lua_Integer, because either lua_Integer is ** is represented by a lua_Integer, because either lua_Integer is
** large enough to represent all int fields or it is not large enough ** large enough to represent all int fields or it is not large enough
** to represent a time that cause a field to overflow. However, if ** to represent a time that cause a field to overflow. However, if

View File

@ -476,7 +476,7 @@ static void checkrefs (global_State *g, GCObject *o) {
/* /*
** Check consistency of an object: ** Check consistency of an object:
** - Dead objects can only happen in the 'allgc' list during a sweep ** - Dead objects can only happen in the 'allgc' list during a sweep
** phase (controled by the caller through 'maybedead'). ** phase (controlled by the caller through 'maybedead').
** - During pause, all objects must be white. ** - During pause, all objects must be white.
** - In generational mode: ** - In generational mode:
** * objects must be old enough for their lists ('listage'). ** * objects must be old enough for their lists ('listage').
@ -783,7 +783,7 @@ static int mem_query (lua_State *L) {
return 1; return 1;
} }
} }
return luaL_error(L, "unkown type '%s'", t); return luaL_error(L, "unknown type '%s'", t);
} }
} }

View File

@ -805,7 +805,7 @@ F = function (x)
if A ~= nil then if A ~= nil then
assert(type(A) == "userdata") assert(type(A) == "userdata")
assert(T.udataval(A) == B) assert(T.udataval(A) == B)
debug.getmetatable(A) -- just acess it debug.getmetatable(A) -- just access it
end end
A = x -- ressucita userdata A = x -- ressucita userdata
B = udval B = udval
@ -1112,7 +1112,7 @@ do
-- non-closable value -- non-closable value
local a, b = pcall(T.makeCfunc[[ local a, b = pcall(T.makeCfunc[[
newtable # create non-closable object newtable # create non-closable object
toclose -1 # mark it to be closed (shoud raise an error) toclose -1 # mark it to be closed (should raise an error)
abort # will not be executed abort # will not be executed
]]) ]])
assert(a == false and assert(a == false and

View File

@ -28,7 +28,7 @@ do
local path = table.concat(t, ";") local path = table.concat(t, ";")
-- use that path in a search -- use that path in a search
local s, err = package.searchpath("xuxu", path) local s, err = package.searchpath("xuxu", path)
-- search fails; check that message has an occurence of -- search fails; check that message has an occurrence of
-- '??????????' with ? replaced by xuxu and at least 'max' lines -- '??????????' with ? replaced by xuxu and at least 'max' lines
assert(not s and assert(not s and
string.find(err, string.rep("xuxu", 10)) and string.find(err, string.rep("xuxu", 10)) and

View File

@ -66,7 +66,7 @@ assert(repstrings * ssize > 2.0^32) -- it should be larger than maximum size
local longs = string.rep("\0", ssize) -- create one long string local longs = string.rep("\0", ssize) -- create one long string
-- create function to concatentate 'repstrings' copies of its argument -- create function to concatenate 'repstrings' copies of its argument
local rep = assert(load( local rep = assert(load(
"local a = ...; return " .. string.rep("a", repstrings, ".."))) "local a = ...; return " .. string.rep("a", repstrings, "..")))

View File

@ -763,7 +763,7 @@ assert(run(function() return "a" .. "b" .. a .. "c" .. c .. b .. "x" end,
{"concat", "concat", "concat"}) == "ab10chello12x") {"concat", "concat", "concat"}) == "ab10chello12x")
do -- a few more tests for comparsion operators do -- a few more tests for comparison operators
local mt1 = { local mt1 = {
__le = function (a,b) __le = function (a,b)
coroutine.yield(10) coroutine.yield(10)

View File

@ -4,7 +4,7 @@
local debug = require "debug" local debug = require "debug"
print"testing C-stack overflow detection" print"testing C-stack overflow detection"
print"If this test craches, see its file ('cstack.lua')" print"If this test crashes, see its file ('cstack.lua')"
-- Segmentation faults in these tests probably result from a C-stack -- Segmentation faults in these tests probably result from a C-stack
-- overflow. To avoid these errors, you can use the function -- overflow. To avoid these errors, you can use the function
@ -19,10 +19,13 @@ print"If this test craches, see its file ('cstack.lua')"
-- higher than 2_000. -- higher than 2_000.
-- get and print original limit
local origlimit = debug.setcstacklimit(400) local origlimit = debug.setcstacklimit(400)
print("default stack limit: " .. origlimit) print("default stack limit: " .. origlimit)
-- change this value for different limits for this test suite -- Do the tests using the original limit. Or else you may want to change
-- 'currentlimit' to lower values to avoid a seg. fault or to higher
-- values to check whether they are reliable.
local currentlimit = origlimit local currentlimit = origlimit
debug.setcstacklimit(currentlimit) debug.setcstacklimit(currentlimit)
print("current stack limit: " .. currentlimit) print("current stack limit: " .. currentlimit)
@ -33,12 +36,14 @@ local function checkerror (msg, f, ...)
assert(not s and string.find(err, msg)) assert(not s and string.find(err, msg))
end end
-- auxiliary function to keep 'count' on the screen even if the program
-- crashes.
local count local count
local back = string.rep("\b", 8) local back = string.rep("\b", 8)
local function progress () local function progress ()
count = count + 1 count = count + 1
local n = string.format("%-8d", count) local n = string.format("%-8d", count)
io.stderr:write(back, n) io.stderr:write(back, n) -- erase previous value and write new one
end end
@ -46,7 +51,7 @@ do print("testing simple recursion:")
count = 0 count = 0
local function foo () local function foo ()
progress() progress()
foo() foo() -- do recursive calls until a stack error (or crash)
end end
checkerror("stack overflow", foo) checkerror("stack overflow", foo)
print("\tfinal count: ", count) print("\tfinal count: ", count)
@ -118,9 +123,11 @@ do print("testing changes in C-stack limit")
return n return n
end end
-- set limit to 400
assert(debug.setcstacklimit(400) == currentlimit) assert(debug.setcstacklimit(400) == currentlimit)
local lim400 = check() local lim400 = check()
-- a very low limit (given that the several calls to arive here) -- set a very low limit (given that there are already several active
-- calls to arrive here)
local lowlimit = 38 local lowlimit = 38
assert(debug.setcstacklimit(lowlimit) == 400) assert(debug.setcstacklimit(lowlimit) == 400)
assert(check() < lowlimit - 30) assert(check() < lowlimit - 30)

View File

@ -182,7 +182,7 @@ assert(~a == a); checkcap{"bnot", a, a}
assert(a << 3 == a); checkcap{"shl", a, 3} assert(a << 3 == a); checkcap{"shl", a, 3}
assert(1.5 >> a == 1.5); checkcap{"shr", 1.5, a} assert(1.5 >> a == 1.5); checkcap{"shr", 1.5, a}
-- for comparsion operators, all results are true -- for comparison operators, all results are true
assert(5.0 > a); checkcap{"lt", a, 5.0} assert(5.0 > a); checkcap{"lt", a, 5.0}
assert(a >= 10); checkcap{"le", 10, a} assert(a >= 10); checkcap{"le", 10, a}
assert(a <= -10.0); checkcap{"le", a, -10.0} assert(a <= -10.0); checkcap{"le", a, -10.0}

View File

@ -640,7 +640,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 -- ressurect object! ___Glob = o -- ressurrect 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

View File

@ -114,7 +114,7 @@ if rawget(_G, "T") then
local t = T.querytab(a) local t = T.querytab(a)
for k,_ in pairs(a) do a[k] = undef end for k,_ in pairs(a) do a[k] = undef end
collectgarbage() -- restore GC and collect dead fiels in `a' collectgarbage() -- restore GC and collect dead fields in 'a'
for i=0,t-1 do for i=0,t-1 do
local k = querytab(a, i) local k = querytab(a, i)
assert(k == nil or type(k) == 'number' or k == 'alo') assert(k == nil or type(k) == 'number' or k == 'alo')

View File

@ -758,7 +758,7 @@ do -- testing max/min
assert(eqT(math.min(maxint, maxint - 1), maxint - 1)) assert(eqT(math.min(maxint, maxint - 1), maxint - 1))
assert(eqT(math.min(maxint - 2, maxint, maxint - 1), maxint - 2)) assert(eqT(math.min(maxint - 2, maxint, maxint - 1), maxint - 2))
end end
-- testing implicit convertions -- testing implicit conversions
local a,b = '10', '20' local a,b = '10', '20'
assert(a*b == 200 and a+b == 30 and a-b == -10 and a/b == 0.5 and -b == -20) assert(a*b == 200 and a+b == 30 and a-b == -10 and a/b == 0.5 and -b == -20)