From 3541cb204f524adf524ee6ee2189ffb9e1c245ec Mon Sep 17 00:00:00 2001 From: Pixel Date: Mon, 1 Jun 2009 23:15:16 +0000 Subject: Full control over ucl_compress/decompress from Lua. --- lib/LuaHandle.cc | 16 +++++++++++----- 1 file 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(1); d = L->recast(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(1); d = L->recast(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); -- cgit v1.2.3