From ace784b225237d1b59576847cd96e3cab9c70dbb Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sat, 26 Aug 2017 21:22:17 +1000 Subject: Have lua_pushstring return the pushed string Fixes #21 --- README.md | 1 + c-api/compat-5.3.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index 25bc911..6bab5f3 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,7 @@ For Lua 5.1 additionally: * `lua_arith` (see [here][19]) * `lua_compare` * `lua_len`, `lua_rawlen`, and `luaL_len` +* `lua_pushstring` (return value) * `lua_copy` * `lua_pushglobaltable` * `luaL_testudata` diff --git a/c-api/compat-5.3.h b/c-api/compat-5.3.h index 0083eb4..67e1da6 100644 --- a/c-api/compat-5.3.h +++ b/c-api/compat-5.3.h @@ -119,6 +119,9 @@ COMPAT53_API void lua_copy (lua_State *L, int from, int to); #define lua_len COMPAT53_CONCAT(COMPAT53_PREFIX, _len) COMPAT53_API void lua_len (lua_State *L, int i); +#define lua_pushstring(L, s) \ + (lua_pushstring(L, (s)), lua_tostring(L, -1)) + #ifndef luaL_newlibtable # define luaL_newlibtable(L, l) \ (lua_createtable(L, 0, sizeof(l)/sizeof(*(l))-1)) -- cgit v1.2.3-55-g6feb