diff options
author | Philipp Janda <siffiejoe@gmx.net> | 2021-12-18 11:01:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-18 11:01:43 +0100 |
commit | 22021d7e013dde01376d74e8e09cb00402bd7042 (patch) | |
tree | 37b98462ec1e55a65363f7de267fcf2005eba22b /c-api/compat-5.3.c | |
parent | e00fd0a415694dc15687593e355441af6dfa30bd (diff) | |
download | lua-compat-5.3-22021d7e013dde01376d74e8e09cb00402bd7042.tar.gz lua-compat-5.3-22021d7e013dde01376d74e8e09cb00402bd7042.tar.bz2 lua-compat-5.3-22021d7e013dde01376d74e8e09cb00402bd7042.zip |
Convert lua_pushlstring from a macro to a function (#55)
This should avoid issues with multiple evaluations of the arguments,
which should be very rare, but could in principle happen.
Diffstat (limited to 'c-api/compat-5.3.c')
-rw-r--r-- | c-api/compat-5.3.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/c-api/compat-5.3.c b/c-api/compat-5.3.c index 42b0a4b..64592d6 100644 --- a/c-api/compat-5.3.c +++ b/c-api/compat-5.3.c | |||
@@ -715,6 +715,14 @@ void luaL_pushresult (luaL_Buffer_53 *B) { | |||
715 | #if defined( LUA_VERSION_NUM ) && LUA_VERSION_NUM <= 502 | 715 | #if defined( LUA_VERSION_NUM ) && LUA_VERSION_NUM <= 502 |
716 | 716 | ||
717 | 717 | ||
718 | COMPAT53_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len) { | ||
719 | #undef lua_pushlstring | ||
720 | lua_pushlstring(L, len > 0 ? s : "", len); | ||
721 | #define lua_pushlstring COMPAT53_CONCAT(COMPAT53_PREFIX, _pushlstring_53) | ||
722 | return lua_tostring(L, -1); | ||
723 | } | ||
724 | |||
725 | |||
718 | COMPAT53_API int lua_geti (lua_State *L, int index, lua_Integer i) { | 726 | COMPAT53_API int lua_geti (lua_State *L, int index, lua_Integer i) { |
719 | index = lua_absindex(L, index); | 727 | index = lua_absindex(L, index); |
720 | lua_pushinteger(L, i); | 728 | lua_pushinteger(L, i); |