diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-05-31 16:41:52 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-05-31 16:41:52 -0300 |
commit | 0dfd04eb60a7b9d54a6348ef4d9a3fa3963682aa (patch) | |
tree | 7f2353754af0783c2713af728be68878f149b3ce /lapi.c | |
parent | 1e0aaf2156bb261787606b8cf00f812d75344ff2 (diff) | |
download | lua-0dfd04eb60a7b9d54a6348ef4d9a3fa3963682aa.tar.gz lua-0dfd04eb60a7b9d54a6348ef4d9a3fa3963682aa.tar.bz2 lua-0dfd04eb60a7b9d54a6348ef4d9a3fa3963682aa.zip |
`lua_strlen' upgraded to `lua_objsize' (which also works with userdata)
Diffstat (limited to 'lapi.c')
-rw-r--r-- | lapi.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 2.8 2004/05/11 16:52:08 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.9 2004/05/14 19:25:09 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -323,10 +323,12 @@ LUA_API const char *lua_tostring (lua_State *L, int idx) { | |||
323 | } | 323 | } |
324 | 324 | ||
325 | 325 | ||
326 | LUA_API size_t lua_strlen (lua_State *L, int idx) { | 326 | LUA_API size_t lua_objsize (lua_State *L, int idx) { |
327 | StkId o = luaA_index(L, idx); | 327 | StkId o = luaA_index(L, idx); |
328 | if (ttisstring(o)) | 328 | if (ttisstring(o)) |
329 | return tsvalue(o)->len; | 329 | return tsvalue(o)->len; |
330 | else if (ttisuserdata(o)) | ||
331 | return uvalue(o)->len; | ||
330 | else { | 332 | else { |
331 | size_t l; | 333 | size_t l; |
332 | lua_lock(L); /* `luaV_tostring' may create a new string */ | 334 | lua_lock(L); /* `luaV_tostring' may create a new string */ |