This commit is contained in:
Raphael Coeffic
2021-06-09 09:30:18 +02:00
parent b0fb80b264
commit 247ac2a524
+4 -4
View File
@@ -64,14 +64,14 @@ void luaInitThemesAndWidgets();
#define lua_pushtablenumber(L, k, v) (lua_pushstring(L, (k)), lua_pushnumber(L, (v)), lua_settable(L, -3))
// size based string (possibly no null-termination)
#define __lua_strncpy(s) \
char tmp[sizeof(s) + 1]; \
strncpy(tmp, (s), sizeof(s)); \
#define __lua_strncpy(s) \
char tmp[sizeof(s) + 1]; \
strncpy(tmp, (s), sizeof(tmp) - 1); \
tmp[sizeof(s)] = '\0';
// size based string (possibly no null-termination)
#define lua_pushnstring(L, s) { __lua_strncpy(s); lua_pushstring(L, tmp); }
#define lua_pushtablenstring(L, k, v) { __lua_strncpy(s); lua_pushstring(L, (k)); lua_pushstring(L, tmp); lua_settable(L, -3); }
#define lua_pushtablenstring(L, k, v) { __lua_strncpy(v); lua_pushstring(L, (k)); lua_pushstring(L, tmp); lua_settable(L, -3); }
// null-terminated string
#define lua_pushtablestring(L, k, v) (lua_pushstring(L, (k)), lua_pushstring(L, (v)), lua_settable(L, -3))