lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Em sáb., 21 de nov. de 2020 às 14:38, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> escreveu:
> /* avoid strlen call or inline */
> lua_pushlstring(L, "cannot close standard file", sizeof("cannot close standard file") - 1);

I suggest you use lua_pushliteral for string literals; it's good documentation.

lua_pushliteral is currently defined as lua_pushstring but in Lua 5.2
and previous versions it was defined as
#define lua_pushliteral(L, s)  lua_pushlstring(L, "" s,
(sizeof(s)/sizeof(char))-1)
See https://www.lua.org/source/5.2/lua.h.html#lua_pushliteral

You may want to redefine lua_pushliteral back to this if you are
worried about strlen on literals.
 It would be better for everyone in the Lua 5.4 git?