aboutsummaryrefslogtreecommitdiff
path: root/lobject.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-06-03 11:36:42 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-06-03 11:36:42 -0300
commit2c68e66570206aa1496f9c76fcf2a1a0f550d692 (patch)
treebcc6fd7939b12ef3a636d88ce0ac38da036660d8 /lobject.c
parent7d0f41df41e9c513e7282356541b54beaf9ed20d (diff)
downloadlua-2c68e66570206aa1496f9c76fcf2a1a0f550d692.tar.gz
lua-2c68e66570206aa1496f9c76fcf2a1a0f550d692.tar.bz2
lua-2c68e66570206aa1496f9c76fcf2a1a0f550d692.zip
Details
Several small changes from feedback on 5.4 alhpa rc1 (warnings, typos in the manual, and the like)
Diffstat (limited to 'lobject.c')
-rw-r--r--lobject.c18
1 files changed, 9 insertions, 9 deletions
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) {
366/* 366/*
367** Convert a number object to a string, adding it to a buffer 367** Convert a number object to a string, adding it to a buffer
368*/ 368*/
369static size_t tostringbuff (TValue *obj, char *buff) { 369static int tostringbuff (TValue *obj, char *buff) {
370 size_t len; 370 int len;
371 lua_assert(ttisnumber(obj)); 371 lua_assert(ttisnumber(obj));
372 if (ttisinteger(obj)) 372 if (ttisinteger(obj))
373 len = lua_integer2str(buff, MAXNUMBER2STR, ivalue(obj)); 373 len = lua_integer2str(buff, MAXNUMBER2STR, ivalue(obj));
@@ -387,7 +387,7 @@ static size_t tostringbuff (TValue *obj, char *buff) {
387*/ 387*/
388void luaO_tostring (lua_State *L, TValue *obj) { 388void luaO_tostring (lua_State *L, TValue *obj) {
389 char buff[MAXNUMBER2STR]; 389 char buff[MAXNUMBER2STR];
390 size_t len = tostringbuff(obj, buff); 390 int len = tostringbuff(obj, buff);
391 setsvalue(L, obj, luaS_newlstr(L, buff, len)); 391 setsvalue(L, obj, luaS_newlstr(L, buff, len));
392} 392}
393 393
@@ -439,11 +439,11 @@ static void clearbuff (BuffFS *buff) {
439 439
440/* 440/*
441** Get a space of size 'sz' in the buffer. If buffer has not enough 441** Get a space of size 'sz' in the buffer. If buffer has not enough
442** space, empty it. 'sz' must fit in an empty space. 442** space, empty it. 'sz' must fit in an empty buffer.
443*/ 443*/
444static char *getbuff (BuffFS *buff, size_t sz) { 444static char *getbuff (BuffFS *buff, int sz) {
445 lua_assert(buff->blen <= BUFVFS); lua_assert(sz <= BUFVFS); 445 lua_assert(buff->blen <= BUFVFS); lua_assert(sz <= BUFVFS);
446 if (sz > BUFVFS - cast_sizet(buff->blen)) /* string does not fit? */ 446 if (sz > BUFVFS - buff->blen) /* not enough space? */
447 clearbuff(buff); 447 clearbuff(buff);
448 return buff->space + buff->blen; 448 return buff->space + buff->blen;
449} 449}
@@ -458,9 +458,9 @@ static char *getbuff (BuffFS *buff, size_t sz) {
458*/ 458*/
459static void addstr2buff (BuffFS *buff, const char *str, size_t slen) { 459static void addstr2buff (BuffFS *buff, const char *str, size_t slen) {
460 if (slen <= BUFVFS) { /* does string fit into buffer? */ 460 if (slen <= BUFVFS) { /* does string fit into buffer? */
461 char *bf = getbuff(buff, slen); 461 char *bf = getbuff(buff, cast_int(slen));
462 memcpy(bf, str, slen); /* add string to buffer */ 462 memcpy(bf, str, slen); /* add string to buffer */
463 addsize(buff, slen); 463 addsize(buff, cast_int(slen));
464 } 464 }
465 else { /* string larger than buffer */ 465 else { /* string larger than buffer */
466 clearbuff(buff); /* string comes after buffer's content */ 466 clearbuff(buff); /* string comes after buffer's content */
@@ -474,7 +474,7 @@ static void addstr2buff (BuffFS *buff, const char *str, size_t slen) {
474*/ 474*/
475static void addnum2buff (BuffFS *buff, TValue *num) { 475static void addnum2buff (BuffFS *buff, TValue *num) {
476 char *numbuff = getbuff(buff, MAXNUMBER2STR); 476 char *numbuff = getbuff(buff, MAXNUMBER2STR);
477 size_t len = tostringbuff(num, numbuff); /* format number into 'numbuff' */ 477 int len = tostringbuff(num, numbuff); /* format number into 'numbuff' */
478 addsize(buff, len); 478 addsize(buff, len);
479} 479}
480 480