Skip to content

Commit

Permalink
[Minor] Fix return values in Lua API
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Sep 27, 2019
1 parent 24a0be9 commit 2a8231d
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/lua/lua_regexp.c
Expand Up @@ -588,12 +588,14 @@ lua_regexp_search (lua_State *L)
if (capture) {
g_array_free (captures, TRUE);
}

return 1;
}
else {
lua_pushnil (L);
}
}

lua_pushnil (L);
else {
return luaL_error (L, "invalid arguments");
}

return 1;
}
Expand Down Expand Up @@ -644,11 +646,14 @@ lua_regexp_match (lua_State *L)
else {
lua_pushboolean (L, FALSE);
}
return 1;
}
else {
lua_pushboolean (L, FALSE);
}
}

lua_pushnil (L);
else {
return luaL_error (L, "invalid arguments");
}

return 1;
}
Expand Down Expand Up @@ -689,13 +694,13 @@ lua_regexp_matchn (lua_State *L)
}

max_matches = lua_tointeger (L, 3);
matches = 0;

if (lua_gettop (L) == 4) {
raw = lua_toboolean (L, 4);
}

if (data && len > 0) {
matches = 0;

if (re->match_limit > 0) {
len = MIN (len, re->match_limit);
Expand All @@ -714,14 +719,14 @@ lua_regexp_matchn (lua_State *L)
break;
}
}

lua_pushinteger (L, matches);

return 1;
}

lua_pushinteger (L, matches);
}
else {
return luaL_error (L, "invalid arguments");
}

lua_pushnil (L);

return 1;
}
Expand Down Expand Up @@ -825,6 +830,9 @@ lua_regexp_split (lua_State *L)
return 1;
}
}
else {
return luaL_error (L, "invalid arguments");
}

lua_pushnil (L);
return 1;
Expand Down

0 comments on commit 2a8231d

Please sign in to comment.