aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-07 18:19:20 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-07 18:19:20 +0100
commit75a8e1fa3713588d723e05b92686346333800f78 (patch)
tree96659c4a27a6277fade9115e9dea0a44ae372fd6 /contrib
parentfacb4c5d4aaac450609f7f845a6d42b7518008b6 (diff)
downloadrspamd-75a8e1fa3713588d723e05b92686346333800f78.tar.gz
rspamd-75a8e1fa3713588d723e05b92686346333800f78.zip
Fix pushing array to lua from UCL.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/libucl/lua_ucl.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/contrib/libucl/lua_ucl.c b/contrib/libucl/lua_ucl.c
index 682b0b559..1f79b0e16 100644
--- a/contrib/libucl/lua_ucl.c
+++ b/contrib/libucl/lua_ucl.c
@@ -172,19 +172,33 @@ static int
ucl_object_lua_push_array (lua_State *L, const ucl_object_t *obj)
{
const ucl_object_t *cur;
+ ucl_object_iter_t it;
int i = 1, nelt = 0;
- /* Optimize allocation by preallocation of table */
- LL_FOREACH (obj, cur) {
- nelt ++;
+ if (obj->type == UCL_ARRAY) {
+ nelt = obj->len;
+ it = ucl_object_iterate_new (obj);
+ lua_createtable (L, nelt, 0);
+
+ while ((cur = ucl_object_iterate_safe (it, true))) {
+ ucl_object_push_lua (L, cur, false);
+ lua_rawseti (L, -2, i);
+ i ++;
+ }
}
+ else {
+ /* Optimize allocation by preallocation of table */
+ LL_FOREACH (obj, cur) {
+ nelt ++;
+ }
- lua_createtable (L, nelt, 0);
+ lua_createtable (L, nelt, 0);
- LL_FOREACH (obj, cur) {
- ucl_object_push_lua (L, cur, false);
- lua_rawseti (L, -2, i);
- i ++;
+ LL_FOREACH (obj, cur) {
+ ucl_object_push_lua (L, cur, false);
+ lua_rawseti (L, -2, i);
+ i ++;
+ }
}
return 1;
@@ -259,7 +273,7 @@ ucl_object_push_lua (lua_State *L, const ucl_object_t *obj, bool allow_array)
case UCL_OBJECT:
return ucl_object_lua_push_object (L, obj, allow_array);
case UCL_ARRAY:
- return ucl_object_lua_push_array (L, obj->value.av);
+ return ucl_object_lua_push_array (L, obj);
default:
return ucl_object_lua_push_scalar (L, obj, allow_array);
}