diff options
author | Pixel <pixel@nobis-crew.org> | 2009-06-01 23:15:16 +0000 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2009-06-01 23:15:16 +0000 |
commit | 3541cb204f524adf524ee6ee2189ffb9e1c245ec (patch) | |
tree | 32b34548467a11a674b73ffba41aeb577f47d15d | |
parent | 11dc9cf95ad1cf60773e87f6a83be2867c9b6f0e (diff) |
Full control over ucl_compress/decompress from Lua.
-rw-r--r-- | lib/LuaHandle.cc | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/LuaHandle.cc b/lib/LuaHandle.cc index ec1f573..329c7e7 100644 --- a/lib/LuaHandle.cc +++ b/lib/LuaHandle.cc @@ -590,14 +590,17 @@ int sLuaHandle::ucl_compress(lua_State * __L) { Lua * L = Lua::find(__L); int n = L->gettop(); Handle * s, * d; - int r; + int r, l = -1; - if (n != 2) { + if (!((n >= 2) && (n <= 3))) { L->error("Incorrect arguments to method `Handle::ucl_compress'"); } s = L->recast<Handle>(1); d = L->recast<Handle>(2); + if (n == 3) { + l = L->tonumber(3); + } r = Handle::ucl_compress(s, d); @@ -610,17 +613,20 @@ int sLuaHandle::ucl_decompress(lua_State * __L) { Lua * L = Lua::find(__L); int n = L->gettop(); Handle * s, * d; - int r, l; + int r, l, l_in = -1; - if ((n != 3) || (!L->isnumber(3))) { + if (!((n >= 3) && (n <= 4)) || (!L->isnumber(3))) { L->error("Incorrect arguments to method `Handle::ucl_decompress'"); } s = L->recast<Handle>(1); d = L->recast<Handle>(2); l = L->tonumber(3); + if (n == 4) { + l_in = L->tonumber(4); + } - r = Handle::ucl_decompress(s, d, l); + r = Handle::ucl_decompress(s, d, l, l_in); L->push((lua_Number) r); |