Skip to content

Commit 293348b

Browse files
Merge pull request #28 from soumith/lua52
async lua 5.2 fixes
2 parents 90b96b7 + 77d7ca8 commit 293348b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

luv/src/luv_functions.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,11 @@ static int luv_spawn(lua_State* L) {
14131413
stdio[2].data.stream = (uv_stream_t*)stderr_pipe;
14141414

14151415
/* Parse the args array */
1416+
#if LUA_VERSION_NUM>= 502
1417+
size_t argc = lua_rawlen(L, 2) + 1;
1418+
#else
14161419
size_t argc = lua_objlen(L, 2) + 1;
1420+
#endif
14171421
char** args = malloc((argc + 1) * sizeof(char*));
14181422
args[0] = strdup(command);
14191423
size_t i;
@@ -1435,7 +1439,11 @@ static int luv_spawn(lua_State* L) {
14351439
lua_getfield(L, 3, "env");
14361440
env = NULL;
14371441
if (lua_type(L, -1) == LUA_TTABLE) {
1442+
#if LUA_VERSION_NUM>= 502
1443+
argc = lua_rawlen(L, -1);
1444+
#else
14381445
argc = lua_objlen(L, -1);
1446+
#endif
14391447
env = malloc((argc + 1) * sizeof(char*));
14401448
for (i = 0; i < argc; i++) {
14411449
lua_rawgeti(L, -1, i + 1);

0 commit comments

Comments
 (0)