Browse Source

Details

Several small changes from feedback on 5.4 alhpa rc1 (warnings,
typos in the manual, and the like)
pull/23/head
Roberto Ierusalimschy 6 years ago
parent
commit
2c68e66570
  1. 5
      ldebug.c
  2. 4
      lgc.c
  3. 4
      llex.c
  4. 18
      lobject.c
  5. 4
      lstring.c
  6. 2
      ltablib.c
  7. 4
      lvm.c
  8. 5
      manual/manual.of

5
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->ftransfer = ci->u2.transferinfo.ftransfer;
ar->ntransfer = ci->u2.transferinfo.ntransfer; ar->ntransfer = ci->u2.transferinfo.ntransfer;
} }
break;
} }
case 'L': case 'L':
case 'f': /* handled by lua_getinfo */ 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, static const char *getobjname (const Proto *p, int lastpc, int reg,
const char **name) { const char **name) {
int pc; int pc;
*name = luaF_getlocalname(p, reg + 1, lastpc); *name = luaF_getlocalname(p, reg + 1, lastpc);
if (*name) /* is a local? */ if (*name) /* is a local? */

4
lgc.c

@ -484,8 +484,8 @@ static lu_mem traversetable (global_State *g, Table *h) {
const TValue *mode = gfasttm(g, h->metatable, TM_MODE); const TValue *mode = gfasttm(g, h->metatable, TM_MODE);
markobjectN(g, h->metatable); markobjectN(g, h->metatable);
if (mode && ttisstring(mode) && /* is there a weak mode? */ if (mode && ttisstring(mode) && /* is there a weak mode? */
((weakkey = strchr(svalue(mode), 'k')), (cast_void(weakkey = strchr(svalue(mode), 'k')),
(weakvalue = strchr(svalue(mode), 'v')), cast_void(weakvalue = strchr(svalue(mode), 'v')),
(weakkey || weakvalue))) { /* is really weak? */ (weakkey || weakvalue))) { /* is really weak? */
black2gray(h); /* keep table gray */ black2gray(h); /* keep table gray */
if (!weakkey) /* strong keys? */ if (!weakkey) /* strong keys? */

4
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' */ save_and_next(ls); /* skip 'u' */
esccheck(ls, ls->current == '{', "missing '{'"); esccheck(ls, ls->current == '{', "missing '{'");
r = gethexa(ls); /* must have at least one digit */ 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++; i++;
esccheck(ls, r <= (0x7FFFFFFFu >> 4), "UTF-8 value too large"); esccheck(ls, r <= (0x7FFFFFFFu >> 4), "UTF-8 value too large");
r = (r << 4) + luaO_hexavalue(ls->current); r = (r << 4) + luaO_hexavalue(ls->current);

18
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 ** Convert a number object to a string, adding it to a buffer
*/ */
static size_t tostringbuff (TValue *obj, char *buff) { static int tostringbuff (TValue *obj, char *buff) {
size_t len; int len;
lua_assert(ttisnumber(obj)); lua_assert(ttisnumber(obj));
if (ttisinteger(obj)) if (ttisinteger(obj))
len = lua_integer2str(buff, MAXNUMBER2STR, ivalue(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) { void luaO_tostring (lua_State *L, TValue *obj) {
char buff[MAXNUMBER2STR]; char buff[MAXNUMBER2STR];
size_t len = tostringbuff(obj, buff); int len = tostringbuff(obj, buff);
setsvalue(L, obj, luaS_newlstr(L, buff, len)); 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 ** 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); 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); clearbuff(buff);
return buff->space + buff->blen; 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) { static void addstr2buff (BuffFS *buff, const char *str, size_t slen) {
if (slen <= BUFVFS) { /* does string fit into buffer? */ 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 */ memcpy(bf, str, slen); /* add string to buffer */
addsize(buff, slen); addsize(buff, cast_int(slen));
} }
else { /* string larger than buffer */ else { /* string larger than buffer */
clearbuff(buff); /* string comes after buffer's content */ 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) { static void addnum2buff (BuffFS *buff, TValue *num) {
char *numbuff = getbuff(buff, MAXNUMBER2STR); 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); addsize(buff, len);
} }

4
lstring.c

@ -121,8 +121,8 @@ void luaS_clearcache (global_State *g) {
int i, j; int i, j;
for (i = 0; i < STRCACHE_N; i++) for (i = 0; i < STRCACHE_N; i++)
for (j = 0; j < STRCACHE_M; j++) { for (j = 0; j < STRCACHE_M; j++) {
if (iswhite(g->strcache[i][j])) /* will entry be collected? */ if (iswhite(g->strcache[i][j])) /* will entry be collected? */
g->strcache[i][j] = g->memerrmsg; /* replace it with something fixed */ g->strcache[i][j] = g->memerrmsg; /* replace it with something fixed */
} }
} }

2
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 */ /* after the loop, a[i] >= P and a[lo .. i - 1] < P */
/* next loop: repeat --j while P < a[j] */ /* 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 ?? */ if (j < i) /* j < i but a[j] > P ?? */
luaL_error(L, "invalid order function for sorting"); luaL_error(L, "invalid order function for sorting");
lua_pop(L, 1); /* remove a[j] */ lua_pop(L, 1); /* remove a[j] */

4
lvm.c

@ -1151,7 +1151,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
TValue *rc = vRC(i); TValue *rc = vRC(i);
lua_Unsigned n; lua_Unsigned n;
if (ttisinteger(rc) /* fast track for integers? */ 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)) { : luaV_fastget(L, rb, rc, slot, luaH_get)) {
setobj2s(L, ra, slot); setobj2s(L, ra, slot);
} }
@ -1204,7 +1204,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
TValue *rc = RKC(i); /* value */ TValue *rc = RKC(i); /* value */
lua_Unsigned n; lua_Unsigned n;
if (ttisinteger(rb) /* fast track for integers? */ 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_fastget(L, s2v(ra), rb, slot, luaH_get)) {
luaV_finishfastset(L, s2v(ra), slot, rc); luaV_finishfastset(L, s2v(ra), slot, rc);
} }

5
manual/manual.of

@ -1504,7 +1504,7 @@ There are two possible attributes:
@id{const}, which declares a @x{constant variable}, @id{const}, which declares a @x{constant variable},
that is, a variable that cannot be assigned to that is, a variable that cannot be assigned to
after its initialization; 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}, 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, If a coroutine yields inside a block and is never resumed again,
the variables visible at that block will never go out of scope, 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, Similarly, if a coroutine ends with an error,
it does not unwind its stack, it does not unwind its stack,
so it does not close any variable. 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, its global environment,
but has an independent execution stack. but has an independent execution stack.
There is no explicit function to close or to destroy a thread.
Threads are subject to garbage collection, Threads are subject to garbage collection,
like any Lua object. like any Lua object.

Loading…
Cancel
Save