From 2c68e66570206aa1496f9c76fcf2a1a0f550d692 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 3 Jun 2019 11:36:42 -0300 Subject: [PATCH] Details Several small changes from feedback on 5.4 alhpa rc1 (warnings, typos in the manual, and the like) --- ldebug.c | 5 +++-- lgc.c | 4 ++-- llex.c | 4 ++-- lobject.c | 18 +++++++++--------- lstring.c | 4 ++-- ltablib.c | 2 +- lvm.c | 4 ++-- manual/manual.of | 5 ++--- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/ldebug.c b/ldebug.c index 6cd4e071..acaa653a 100644 --- a/ldebug.c +++ b/ldebug.c @@ -373,6 +373,7 @@ static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar, ar->ftransfer = ci->u2.transferinfo.ftransfer; ar->ntransfer = ci->u2.transferinfo.ntransfer; } + break; } case 'L': case 'f': /* handled by lua_getinfo */ @@ -525,8 +526,8 @@ static const char *gxf (const Proto *p, int pc, Instruction i, int isup) { } - const char *getobjname (const Proto *p, int lastpc, int reg, - const char **name) { +static const char *getobjname (const Proto *p, int lastpc, int reg, + const char **name) { int pc; *name = luaF_getlocalname(p, reg + 1, lastpc); if (*name) /* is a local? */ diff --git a/lgc.c b/lgc.c index e9189ac3..69d8a186 100644 --- a/lgc.c +++ b/lgc.c @@ -484,8 +484,8 @@ static lu_mem traversetable (global_State *g, Table *h) { const TValue *mode = gfasttm(g, h->metatable, TM_MODE); markobjectN(g, h->metatable); if (mode && ttisstring(mode) && /* is there a weak mode? */ - ((weakkey = strchr(svalue(mode), 'k')), - (weakvalue = strchr(svalue(mode), 'v')), + (cast_void(weakkey = strchr(svalue(mode), 'k')), + cast_void(weakvalue = strchr(svalue(mode), 'v')), (weakkey || weakvalue))) { /* is really weak? */ black2gray(h); /* keep table gray */ if (!weakkey) /* strong keys? */ diff --git a/llex.c b/llex.c index 226127f6..d99d9015 100644 --- a/llex.c +++ b/llex.c @@ -29,7 +29,7 @@ -#define next(ls) (ls->current = zgetc(ls->z)) +#define next(ls) (ls->current = zgetc(ls->z)) @@ -337,7 +337,7 @@ static unsigned long readutf8esc (LexState *ls) { save_and_next(ls); /* skip 'u' */ esccheck(ls, ls->current == '{', "missing '{'"); r = gethexa(ls); /* must have at least one digit */ - while ((save_and_next(ls), lisxdigit(ls->current))) { + while (cast_void(save_and_next(ls)), lisxdigit(ls->current)) { i++; esccheck(ls, r <= (0x7FFFFFFFu >> 4), "UTF-8 value too large"); r = (r << 4) + luaO_hexavalue(ls->current); diff --git a/lobject.c b/lobject.c index 979a6889..2c265f96 100644 --- a/lobject.c +++ b/lobject.c @@ -366,8 +366,8 @@ int luaO_utf8esc (char *buff, unsigned long x) { /* ** Convert a number object to a string, adding it to a buffer */ -static size_t tostringbuff (TValue *obj, char *buff) { - size_t len; +static int tostringbuff (TValue *obj, char *buff) { + int len; lua_assert(ttisnumber(obj)); if (ttisinteger(obj)) len = lua_integer2str(buff, MAXNUMBER2STR, ivalue(obj)); @@ -387,7 +387,7 @@ static size_t tostringbuff (TValue *obj, char *buff) { */ void luaO_tostring (lua_State *L, TValue *obj) { char buff[MAXNUMBER2STR]; - size_t len = tostringbuff(obj, buff); + int len = tostringbuff(obj, buff); setsvalue(L, obj, luaS_newlstr(L, buff, len)); } @@ -439,11 +439,11 @@ static void clearbuff (BuffFS *buff) { /* ** Get a space of size 'sz' in the buffer. If buffer has not enough -** space, empty it. 'sz' must fit in an empty space. +** space, empty it. 'sz' must fit in an empty buffer. */ -static char *getbuff (BuffFS *buff, size_t sz) { +static char *getbuff (BuffFS *buff, int sz) { lua_assert(buff->blen <= BUFVFS); lua_assert(sz <= BUFVFS); - if (sz > BUFVFS - cast_sizet(buff->blen)) /* string does not fit? */ + if (sz > BUFVFS - buff->blen) /* not enough space? */ clearbuff(buff); return buff->space + buff->blen; } @@ -458,9 +458,9 @@ static char *getbuff (BuffFS *buff, size_t sz) { */ static void addstr2buff (BuffFS *buff, const char *str, size_t slen) { if (slen <= BUFVFS) { /* does string fit into buffer? */ - char *bf = getbuff(buff, slen); + char *bf = getbuff(buff, cast_int(slen)); memcpy(bf, str, slen); /* add string to buffer */ - addsize(buff, slen); + addsize(buff, cast_int(slen)); } else { /* string larger than buffer */ clearbuff(buff); /* string comes after buffer's content */ @@ -474,7 +474,7 @@ static void addstr2buff (BuffFS *buff, const char *str, size_t slen) { */ static void addnum2buff (BuffFS *buff, TValue *num) { char *numbuff = getbuff(buff, MAXNUMBER2STR); - size_t len = tostringbuff(num, numbuff); /* format number into 'numbuff' */ + int len = tostringbuff(num, numbuff); /* format number into 'numbuff' */ addsize(buff, len); } diff --git a/lstring.c b/lstring.c index c52539a6..6ba798d9 100644 --- a/lstring.c +++ b/lstring.c @@ -121,8 +121,8 @@ void luaS_clearcache (global_State *g) { int i, j; for (i = 0; i < STRCACHE_N; i++) for (j = 0; j < STRCACHE_M; j++) { - if (iswhite(g->strcache[i][j])) /* will entry be collected? */ - g->strcache[i][j] = g->memerrmsg; /* replace it with something fixed */ + if (iswhite(g->strcache[i][j])) /* will entry be collected? */ + g->strcache[i][j] = g->memerrmsg; /* replace it with something fixed */ } } diff --git a/ltablib.c b/ltablib.c index 48a6bdfe..7e7a1012 100644 --- a/ltablib.c +++ b/ltablib.c @@ -306,7 +306,7 @@ static IdxT partition (lua_State *L, IdxT lo, IdxT up) { } /* after the loop, a[i] >= P and a[lo .. i - 1] < P */ /* next loop: repeat --j while P < a[j] */ - while (lua_geti(L, 1, --j), sort_comp(L, -3, -1)) { + while ((void)lua_geti(L, 1, --j), sort_comp(L, -3, -1)) { if (j < i) /* j < i but a[j] > P ?? */ luaL_error(L, "invalid order function for sorting"); lua_pop(L, 1); /* remove a[j] */ diff --git a/lvm.c b/lvm.c index 45788a01..d7000791 100644 --- a/lvm.c +++ b/lvm.c @@ -1151,7 +1151,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { TValue *rc = vRC(i); lua_Unsigned n; if (ttisinteger(rc) /* fast track for integers? */ - ? (n = ivalue(rc), luaV_fastgeti(L, rb, n, slot)) + ? (cast_void(n = ivalue(rc)), luaV_fastgeti(L, rb, n, slot)) : luaV_fastget(L, rb, rc, slot, luaH_get)) { setobj2s(L, ra, slot); } @@ -1204,7 +1204,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { TValue *rc = RKC(i); /* value */ lua_Unsigned n; if (ttisinteger(rb) /* fast track for integers? */ - ? (n = ivalue(rb), luaV_fastgeti(L, s2v(ra), n, slot)) + ? (cast_void(n = ivalue(rb)), luaV_fastgeti(L, s2v(ra), n, slot)) : luaV_fastget(L, s2v(ra), rb, slot, luaH_get)) { luaV_finishfastset(L, s2v(ra), slot, rc); } diff --git a/manual/manual.of b/manual/manual.of index ff69cd2c..687a5b89 100644 --- a/manual/manual.of +++ b/manual/manual.of @@ -1504,7 +1504,7 @@ There are two possible attributes: @id{const}, which declares a @x{constant variable}, that is, a variable that cannot be assigned to after its initialization; -and @id{toclose}, wich declares a to-be-closed variable @see{to-be-closed}. +and @id{toclose}, which declares a to-be-closed variable @see{to-be-closed}. A chunk is also a block @see{chunks}, @@ -1549,7 +1549,7 @@ the other pending closing methods will still be called. If a coroutine yields inside a block and is never resumed again, the variables visible at that block will never go out of scope, -and therefore they will not be closed. +and therefore they will never be closed. Similarly, if a coroutine ends with an error, it does not unwind its stack, so it does not close any variable. @@ -3432,7 +3432,6 @@ The new thread returned by this function shares with the original thread its global environment, but has an independent execution stack. -There is no explicit function to close or to destroy a thread. Threads are subject to garbage collection, like any Lua object.