aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libucl
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2020-01-28 20:12:59 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2020-01-28 20:12:59 +0000
commit01cf03d4c97df081bb4cf9d0f385f7f6fb17d796 (patch)
treecb67176afbe9f2c09971555f368e0b4b0a0376fd /contrib/libucl
parentb5a80192d7db1ec7715b5845e6d165cb11d3b1ca (diff)
downloadrspamd-01cf03d4c97df081bb4cf9d0f385f7f6fb17d796.tar.gz
rspamd-01cf03d4c97df081bb4cf9d0f385f7f6fb17d796.zip
[Minor] Slightly improve numeric checks (not finished)
Diffstat (limited to 'contrib/libucl')
-rw-r--r--contrib/libucl/lua_ucl.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/contrib/libucl/lua_ucl.c b/contrib/libucl/lua_ucl.c
index d240d12e0..8edea5868 100644
--- a/contrib/libucl/lua_ucl.c
+++ b/contrib/libucl/lua_ucl.c
@@ -343,24 +343,30 @@ ucl_object_lua_fromtable (lua_State *L, int idx, ucl_string_flags_t flags)
}
if (!found_mt) {
- /* Check for array */
+ /* Check for array (it is all inefficient) */
lua_pushnil (L);
+
while (lua_next (L, idx) != 0) {
- if (lua_type (L, -2) == LUA_TNUMBER) {
- double num = lua_tonumber (L, -2);
+ lua_pushvalue (L, -2);
+
+ if (lua_type (L, -1) == LUA_TNUMBER) {
+ double num = lua_tonumber (L, -1);
if (num == (int) num) {
if (num > max) {
max = num;
}
- } else {
+ }
+ else {
/* Keys are not integer */
is_array = false;
}
- } else {
+ }
+ else {
/* Keys are not numeric */
is_array = false;
}
- lua_pop (L, 1);
+
+ lua_pop (L, 2);
nelts ++;
}
}