Skip to content

Lua 5.4 #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ A lua library to spawn programs

- High level functions for common cases
- Bindings to the full `posix_spawn` family of functions
- Compatible with Lua 5.1, 5.2, 5.3 and [LuaJIT](http://luajit.org/)
- Compatible with Lua 5.1, 5.2, 5.3, 5.4 and [LuaJIT](http://luajit.org/)

Currently only works on POSIXy systems, but the high level module should be portable to Windows; someone just needs to put the work in.

Expand Down
2 changes: 1 addition & 1 deletion spawn-scm-0.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ supported_platforms = {
"unix";
}
dependencies = {
"lua >= 5.1, < 5.4";
"lua >= 5.1, < 5.5";
"lunix";
}
build = {
Expand Down
5 changes: 3 additions & 2 deletions vendor/compat-5.3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ require("compat53")
a meaningful return value, so the usual idiom of storing the return of
`require` in a local variable makes no sense.

When run under Lua 5.3, this module does nothing.
When run under Lua 5.3+, this module does nothing.

When run under Lua 5.2 or 5.1, it replaces some of your standard
functions and adds new ones to bring your environment closer to that
Expand Down Expand Up @@ -125,6 +125,7 @@ For Lua 5.1 additionally:
* `lua_KContext` (see [here][14])
* `lua_KFunction` (see [here][14])
* `lua_dump` (extra `strip` parameter, ignored, see [here][15])
* `lua_getextraspace` (limited compatibilitiy, see [here][24])
* `lua_getfield` (return value)
* `lua_geti` and `lua_seti`
* `lua_getglobal` (return value)
Expand Down Expand Up @@ -186,7 +187,6 @@ For Lua 5.1 additionally:
[`lua-compat-5.2`][2] for a detailed list.
* the following C API functions/macros:
* `lua_isyieldable`
* `lua_getextraspace`
* `lua_arith` (new operators missing)
* `lua_push(v)fstring` (new formats missing)
* `lua_upvalueid` (5.1)
Expand Down Expand Up @@ -236,4 +236,5 @@ This package contains code written by:
[21]: https://github.com./keplerproject/lua-compat-5.3/wiki/luaL_checkversion
[22]: https://github.com./keplerproject/lua-compat-5.3/wiki/luaL_Buffer
[23]: https://github.com./keplerproject/lua-compat-5.3/wiki/coroutine.running
[24]: https://github.com./keplerproject/lua-compat-5.3/wiki/lua_getextraspace

66 changes: 63 additions & 3 deletions vendor/compat-5.3/c-api/compat-5.3.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
#endif /* VC++ _fsopen for share-allowed file read */

#ifndef COMPAT53_HAVE_STRERROR_R
# if defined(__GLIBC__) || defined(_POSIX_VERSION) || defined(__APPLE__) || \
(!defined (__MINGW32__) && defined(__GNUC__) && (__GNUC__ < 6))
# if (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) || \
(defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) || \
defined(__APPLE__)
# define COMPAT53_HAVE_STRERROR_R 1
# else /* none of the defines matched: define to 0 */
# define COMPAT53_HAVE_STRERROR_R 0
Expand Down Expand Up @@ -448,7 +449,9 @@ static const char *compat53_reader (lua_State *L, void *ud, size_t *size) {

COMPAT53_API int lua_load (lua_State *L, lua_Reader reader, void *data, const char *source, const char *mode) {
int status = LUA_OK;
compat53_reader_data compat53_data = { reader, data, 1, 0, 0 };
compat53_reader_data compat53_data = { 0, NULL, 1, 0, 0 };
compat53_data.reader = reader;
compat53_data.ud = data;
compat53_data.peeked_data = reader(L, data, &(compat53_data.peeked_data_size));
if (compat53_data.peeked_data && compat53_data.peeked_data_size &&
compat53_data.peeked_data[0] == LUA_SIGNATURE[0]) /* binary file? */
Expand Down Expand Up @@ -720,6 +723,63 @@ COMPAT53_API int lua_geti (lua_State *L, int index, lua_Integer i) {
}


#ifndef LUA_EXTRASPACE
#define LUA_EXTRASPACE (sizeof(void*))
#endif

COMPAT53_API void *lua_getextraspace (lua_State *L) {
int is_main = 0;
void *ptr = NULL;
luaL_checkstack(L, 4, "not enough stack slots available");
lua_pushliteral(L, "__compat53_extraspace");
lua_pushvalue(L, -1);
lua_rawget(L, LUA_REGISTRYINDEX);
if (!lua_istable(L, -1)) {
lua_pop(L, 1);
lua_createtable(L, 0, 2);
lua_createtable(L, 0, 1);
lua_pushliteral(L, "k");
lua_setfield(L, -2, "__mode");
lua_setmetatable(L, -2);
lua_pushvalue(L, -2);
lua_pushvalue(L, -2);
lua_rawset(L, LUA_REGISTRYINDEX);
}
lua_replace(L, -2);
is_main = lua_pushthread(L);
lua_rawget(L, -2);
ptr = lua_touserdata(L, -1);
if (!ptr) {
lua_pop(L, 1);
ptr = lua_newuserdata(L, LUA_EXTRASPACE);
if (is_main) {
memset(ptr, '\0', LUA_EXTRASPACE);
lua_pushthread(L);
lua_pushvalue(L, -2);
lua_rawset(L, -4);
lua_pushboolean(L, 1);
lua_pushvalue(L, -2);
lua_rawset(L, -4);
} else {
void* mptr = NULL;
lua_pushboolean(L, 1);
lua_rawget(L, -3);
mptr = lua_touserdata(L, -1);
if (mptr)
memcpy(ptr, mptr, LUA_EXTRASPACE);
else
memset(ptr, '\0', LUA_EXTRASPACE);
lua_pop(L, 1);
lua_pushthread(L);
lua_pushvalue(L, -2);
lua_rawset(L, -4);
}
}
lua_pop(L, 2);
return ptr;
}


COMPAT53_API int lua_isinteger (lua_State *L, int index) {
if (lua_type(L, index) == LUA_TNUMBER) {
lua_Number n = lua_tonumber(L, index);
Expand Down
10 changes: 6 additions & 4 deletions vendor/compat-5.3/c-api/compat-5.3.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ typedef int (*lua_KFunction)(lua_State *L, int status, lua_KContext ctx);
#define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti)
COMPAT53_API int lua_geti (lua_State *L, int index, lua_Integer i);

#define lua_getextraspace COMPAT53_CONCAT(COMPAT53_PREFIX, _getextraspace)
COMPAT53_API void *lua_getextraspace (lua_State *L);

#define lua_isinteger COMPAT53_CONCAT(COMPAT53_PREFIX, _isinteger)
COMPAT53_API int lua_isinteger (lua_State *L, int index);

Expand Down Expand Up @@ -339,7 +342,6 @@ COMPAT53_API void luaL_requiref (lua_State *L, const char *modname,

/* XXX not implemented:
* lua_isyieldable
* lua_getextraspace
* lua_arith (new operators)
* lua_pushfstring (new formats)
*/
Expand Down Expand Up @@ -397,11 +399,11 @@ COMPAT53_API void luaL_requiref (lua_State *L, const char *modname,


/* other Lua versions */
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 503
#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 501 || LUA_VERSION_NUM > 504

# error "unsupported Lua version (i.e. not Lua 5.1, 5.2, or 5.3)"
# error "unsupported Lua version (i.e. not Lua 5.1, 5.2, 5.3, or 5.4)"

#endif /* other Lua versions except 5.1, 5.2, and 5.3 */
#endif /* other Lua versions except 5.1, 5.2, 5.3, and 5.4 */



Expand Down
Loading