mirror of
https://github.com/vxcontrol/lualibs-lrexlib.git
synced 2026-07-01 09:25:08 -04:00
Accept non-string subjects with no __len metamethod in Lua 5.1.
This commit is contained in:
+8
-6
@@ -135,12 +135,14 @@ static void check_subject (lua_State *L, int pos, TArgExec *argE)
|
||||
argE->text = lua_touserdata (L, -1);
|
||||
lua_pop (L, 1);
|
||||
#if LUA_VERSION_NUM == 501
|
||||
if (!luaL_callmeta (L, pos, "__len"))
|
||||
luaL_argerror (L, pos, "subject has no valid __len metamethod");
|
||||
if (lua_type (L, -1) != LUA_TNUMBER)
|
||||
luaL_argerror (L, pos, "subject's length is not a number");
|
||||
argE->textlen = lua_tointeger (L, -1);
|
||||
lua_pop (L, 1);
|
||||
if (luaL_callmeta (L, pos, "__len")) {
|
||||
if (lua_type (L, -1) != LUA_TNUMBER)
|
||||
luaL_argerror (L, pos, "subject's length is not a number");
|
||||
argE->textlen = lua_tointeger (L, -1);
|
||||
lua_pop (L, 1);
|
||||
}
|
||||
else
|
||||
argE->textlen = lua_objlen (L, pos);
|
||||
#else
|
||||
argE->textlen = luaL_len (L, pos);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user