diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-06-18 11:26:05 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-06-18 11:26:05 -0300 |
commit | 19eb6ae5801a6e3c57031065c104f91de7f2c5e8 (patch) | |
tree | 0aa166d1cc94ea0093486f7b0f4223e16b8cf74e /lobject.c | |
parent | cbe05b48bbfe98b0aac3947a877a4d493f80ab63 (diff) | |
download | lua-19eb6ae5801a6e3c57031065c104f91de7f2c5e8.tar.gz lua-19eb6ae5801a6e3c57031065c104f91de7f2c5e8.tar.bz2 lua-19eb6ae5801a6e3c57031065c104f91de7f2c5e8.zip |
using 'snprintf' in C99 (both for documentation of buffer sizes
and some complains from tools)
Diffstat (limited to 'lobject.c')
-rw-r--r-- | lobject.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 2.103 2015/03/28 19:14:47 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.104 2015/04/11 18:30:08 roberto Exp roberto $ |
3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -333,9 +333,9 @@ void luaO_tostring (lua_State *L, StkId obj) { | |||
333 | size_t len; | 333 | size_t len; |
334 | lua_assert(ttisnumber(obj)); | 334 | lua_assert(ttisnumber(obj)); |
335 | if (ttisinteger(obj)) | 335 | if (ttisinteger(obj)) |
336 | len = lua_integer2str(buff, ivalue(obj)); | 336 | len = lua_integer2str(buff, sizeof(buff), ivalue(obj)); |
337 | else { | 337 | else { |
338 | len = lua_number2str(buff, fltvalue(obj)); | 338 | len = lua_number2str(buff, sizeof(buff), fltvalue(obj)); |
339 | #if !defined(LUA_COMPAT_FLOATSTRING) | 339 | #if !defined(LUA_COMPAT_FLOATSTRING) |
340 | if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */ | 340 | if (buff[strspn(buff, "-0123456789")] == '\0') { /* looks like an int? */ |
341 | buff[len++] = lua_getlocaledecpoint(); | 341 | buff[len++] = lua_getlocaledecpoint(); |
@@ -393,7 +393,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { | |||
393 | } | 393 | } |
394 | case 'p': { | 394 | case 'p': { |
395 | char buff[4*sizeof(void *) + 8]; /* should be enough space for a '%p' */ | 395 | char buff[4*sizeof(void *) + 8]; /* should be enough space for a '%p' */ |
396 | int l = sprintf(buff, "%p", va_arg(argp, void *)); | 396 | int l = l_sprintf(buff, sizeof(buff), "%p", va_arg(argp, void *)); |
397 | pushstr(L, buff, l); | 397 | pushstr(L, buff, l); |
398 | break; | 398 | break; |
399 | } | 399 | } |