aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-15 16:20:41 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-08-15 16:20:59 +0100
commit938a0dba32a7f1632c3e14b92d986384aff19d7a (patch)
tree32e64f23e9bbed4c9123fb19972406ed6349d1d1 /src
parent46d32375ac0fe58156da513670ea7c9bccf0aed2 (diff)
downloadrspamd-938a0dba32a7f1632c3e14b92d986384aff19d7a.tar.gz
rspamd-938a0dba32a7f1632c3e14b92d986384aff19d7a.zip
[Minor] Better Lua 5.3 compatibility
Diffstat (limited to 'src')
-rw-r--r--src/controller.c4
-rw-r--r--src/libstat/classifiers/lua_classifier.c12
-rw-r--r--src/log_helper.c6
-rw-r--r--src/lua/lua_common.c10
-rw-r--r--src/lua/lua_common.h2
-rw-r--r--src/lua/lua_config.c16
-rw-r--r--src/lua/lua_dns.c12
-rw-r--r--src/lua/lua_html.c26
-rw-r--r--src/lua/lua_http.c2
-rw-r--r--src/lua/lua_ip.c6
-rw-r--r--src/lua/lua_map.c4
-rw-r--r--src/lua/lua_mempool.c6
-rw-r--r--src/lua/lua_mimepart.c36
-rw-r--r--src/lua/lua_redis.c2
-rw-r--r--src/lua/lua_regexp.c10
-rw-r--r--src/lua/lua_task.c34
-rw-r--r--src/lua/lua_trie.c4
-rw-r--r--src/lua/lua_url.c10
-rw-r--r--src/lua/lua_util.c28
-rw-r--r--src/lua/lua_xmlrpc.c2
-rw-r--r--src/rspamadm/lua_repl.c2
21 files changed, 117 insertions, 117 deletions
diff --git a/src/controller.c b/src/controller.c
index 05d3b238e..5591db264 100644
--- a/src/controller.c
+++ b/src/controller.c
@@ -1525,8 +1525,8 @@ rspamd_controller_handle_lua_history (lua_State *L,
pconn_ent = lua_newuserdata (L, sizeof (*pconn_ent));
*pconn_ent = conn_ent;
rspamd_lua_setclass (L, "rspamd{csession}", -1);
- lua_pushnumber (L, from);
- lua_pushnumber (L, to);
+ lua_pushinteger (L, from);
+ lua_pushinteger (L, to);
lua_pushboolean (L, reset);
if (lua_pcall (L, 5, 0, 0) != 0) {
diff --git a/src/libstat/classifiers/lua_classifier.c b/src/libstat/classifiers/lua_classifier.c
index b76893920..7b495b165 100644
--- a/src/libstat/classifiers/lua_classifier.c
+++ b/src/libstat/classifiers/lua_classifier.c
@@ -156,11 +156,11 @@ lua_classifier_classify (struct rspamd_classifier *cl,
v = tok->data;
lua_createtable (L, 3, 0);
/* High word, low word, order */
- lua_pushnumber (L, (guint32)(v >> 32));
+ lua_pushinteger (L, (guint32)(v >> 32));
lua_rawseti (L, -2, 1);
- lua_pushnumber (L, (guint32)(v));
+ lua_pushinteger (L, (guint32)(v));
lua_rawseti (L, -2, 2);
- lua_pushnumber (L, tok->window_idx);
+ lua_pushinteger (L, tok->window_idx);
lua_rawseti (L, -2, 3);
lua_rawseti (L, -2, i + 1);
}
@@ -212,11 +212,11 @@ lua_classifier_learn_spam (struct rspamd_classifier *cl,
v = tok->data;
lua_createtable (L, 3, 0);
/* High word, low word, order */
- lua_pushnumber (L, (guint32)(v >> 32));
+ lua_pushinteger (L, (guint32)(v >> 32));
lua_rawseti (L, -2, 1);
- lua_pushnumber (L, (guint32)(v));
+ lua_pushinteger (L, (guint32)(v));
lua_rawseti (L, -2, 2);
- lua_pushnumber (L, tok->window_idx);
+ lua_pushinteger (L, tok->window_idx);
lua_rawseti (L, -2, 3);
lua_rawseti (L, -2, i + 1);
}
diff --git a/src/log_helper.c b/src/log_helper.c
index 2635e6099..b62593db8 100644
--- a/src/log_helper.c
+++ b/src/log_helper.c
@@ -114,7 +114,7 @@ rspamd_log_helper_read (gint fd, short what, gpointer ud)
lua_createtable (ctx->L, n, 0);
for (i = 0; i < n; i ++) {
lua_createtable (ctx->L, 2, 0);
- lua_pushnumber (ctx->L, sm->results[i].id);
+ lua_pushinteger (ctx->L, sm->results[i].id);
lua_rawseti (ctx->L, -2, 1);
lua_pushnumber (ctx->L, sm->results[i].score);
lua_rawseti (ctx->L, -2, 2);
@@ -125,12 +125,12 @@ rspamd_log_helper_read (gint fd, short what, gpointer ud)
pcfg = lua_newuserdata (ctx->L, sizeof (*pcfg));
*pcfg = ctx->cfg;
rspamd_lua_setclass (ctx->L, "rspamd{config}", -1);
- lua_pushnumber (ctx->L, sm->settings_id);
+ lua_pushinteger (ctx->L, sm->settings_id);
lua_createtable (ctx->L, nextra, 0);
for (i = 0; i < nextra; i ++) {
lua_createtable (ctx->L, 2, 0);
- lua_pushnumber (ctx->L, sm->results[i + n].id);
+ lua_pushinteger (ctx->L, sm->results[i + n].id);
lua_rawseti (ctx->L, -2, 1);
lua_pushnumber (ctx->L, sm->results[i + n].score);
lua_rawseti (ctx->L, -2, 2);
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index 7d9e525bb..63a95f177 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -439,7 +439,7 @@ rspamd_lua_rspamd_version_cmp (lua_State *L)
set:
g_strfreev (components);
- lua_pushnumber (L, ret);
+ lua_pushinteger (L, ret);
return 1;
}
@@ -472,7 +472,7 @@ rspamd_lua_rspamd_version_numeric (lua_State *L)
}
}
- lua_pushnumber (L, version_num);
+ lua_pushinteger (L, version_num);
return 1;
}
@@ -766,7 +766,7 @@ rspamd_lua_init ()
lua_getglobal (L, "math");
lua_pushstring (L, "randomseed");
lua_gettable (L, -2);
- lua_pushnumber (L, ottery_rand_uint64 ());
+ lua_pushinteger (L, ottery_rand_uint64 ());
lua_pcall (L, 1, 0, 0);
lua_pop (L, 1); /* math table */
@@ -1785,7 +1785,7 @@ lua_worker_get_index (lua_State *L)
struct rspamd_worker *w = lua_check_worker (L, 1);
if (w) {
- lua_pushnumber (L, w->index);
+ lua_pushinteger (L, w->index);
}
else {
return luaL_error (L, "invalid arguments");
@@ -1800,7 +1800,7 @@ lua_worker_get_pid (lua_State *L)
struct rspamd_worker *w = lua_check_worker (L, 1);
if (w) {
- lua_pushnumber (L, w->pid);
+ lua_pushinteger (L, w->pid);
}
else {
return luaL_error (L, "invalid arguments");
diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h
index 45baa5549..913ebcb60 100644
--- a/src/lua/lua_common.h
+++ b/src/lua/lua_common.h
@@ -22,7 +22,7 @@
#define LUA_ENUM(L, name, val) \
lua_pushlstring (L, # name, sizeof(# name) - 1); \
- lua_pushnumber (L, val); \
+ lua_pushinteger (L, val); \
lua_settable (L, -3);
#if LUA_VERSION_NUM > 501 && !defined LUA_COMPAT_MODULE
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index d7af3956f..815b09e63 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -939,7 +939,7 @@ lua_config_get_all_opt (lua_State * L)
i = 1;
LL_FOREACH (obj, cur) {
- lua_pushnumber (L, i++);
+ lua_pushinteger (L, i++);
ucl_object_push_lua (L, cur, true);
lua_settable (L, -3);
}
@@ -1735,7 +1735,7 @@ lua_config_register_symbol (lua_State * L)
return luaL_error (L, "invalid arguments");
}
- lua_pushnumber (L, ret);
+ lua_pushinteger (L, ret);
return 1;
}
@@ -1809,7 +1809,7 @@ lua_config_register_symbols (lua_State *L)
}
}
- lua_pushnumber (L, ret);
+ lua_pushinteger (L, ret);
return 1;
}
@@ -1838,7 +1838,7 @@ lua_config_register_virtual_symbol (lua_State * L)
}
}
- lua_pushnumber (L, ret);
+ lua_pushinteger (L, ret);
return 1;
}
@@ -1879,7 +1879,7 @@ lua_config_register_callback_symbol (lua_State * L)
lua_type (L, top + 1) == LUA_TSTRING);
}
- lua_pushnumber (L, ret);
+ lua_pushinteger (L, ret);
return 1;
}
@@ -1922,7 +1922,7 @@ lua_config_register_callback_symbol_priority (lua_State * L)
lua_type (L, top + 2) == LUA_TSTRING);
}
- lua_pushnumber (L, ret);
+ lua_pushinteger (L, ret);
return 1;
}
@@ -2912,7 +2912,7 @@ lua_config_get_symbols_count (lua_State *L)
return luaL_error (L, "invalid arguments");
}
- lua_pushnumber (L, res);
+ lua_pushinteger (L, res);
return 1;
}
@@ -3092,7 +3092,7 @@ lua_config_get_symbol_stat (lua_State *L)
lua_pushnumber (L, tm);
lua_settable (L, -3);
lua_pushstring (L, "hits");
- lua_pushnumber (L, hits);
+ lua_pushinteger (L, hits);
lua_settable (L, -3);
}
}
diff --git a/src/lua/lua_dns.c b/src/lua/lua_dns.c
index f6ba88f2e..389b9d4f1 100644
--- a/src/lua/lua_dns.c
+++ b/src/lua/lua_dns.c
@@ -190,7 +190,7 @@ lua_dns_callback (struct rdns_reply *reply, gpointer arg)
lua_createtable (cd->L, 0, 2);
rspamd_lua_table_set (cd->L, "name", elt->content.mx.name);
lua_pushstring (cd->L, "priority");
- lua_pushnumber (cd->L, elt->content.mx.priority);
+ lua_pushinteger (cd->L, elt->content.mx.priority);
lua_settable (cd->L, -3);
lua_rawseti (cd->L, -2, ++i);
@@ -200,20 +200,20 @@ lua_dns_callback (struct rdns_reply *reply, gpointer arg)
rspamd_lua_table_set (cd->L, "ns", elt->content.soa.mname);
rspamd_lua_table_set (cd->L, "contact", elt->content.soa.admin);
lua_pushstring (cd->L, "serial");
- lua_pushnumber (cd->L, elt->content.soa.serial);
+ lua_pushinteger (cd->L, elt->content.soa.serial);
lua_settable (cd->L, -3);
lua_pushstring (cd->L, "refresh");
- lua_pushnumber (cd->L, elt->content.soa.refresh);
+ lua_pushinteger (cd->L, elt->content.soa.refresh);
lua_settable (cd->L, -3);
lua_pushstring (cd->L, "retry");
- lua_pushnumber (cd->L, elt->content.soa.retry);
+ lua_pushinteger (cd->L, elt->content.soa.retry);
lua_settable (cd->L, -3);
lua_pushstring (cd->L, "expiry");
- lua_pushnumber (cd->L, elt->content.soa.expire);
+ lua_pushinteger (cd->L, elt->content.soa.expire);
lua_settable (cd->L, -3);
/* Negative TTL */
lua_pushstring (cd->L, "nx");
- lua_pushnumber (cd->L, elt->content.soa.minimum);
+ lua_pushinteger (cd->L, elt->content.soa.minimum);
lua_settable (cd->L, -3);
lua_rawseti (cd->L, -2, ++i);
diff --git a/src/lua/lua_html.c b/src/lua/lua_html.c
index c79fb33fd..95072fe6c 100644
--- a/src/lua/lua_html.c
+++ b/src/lua/lua_html.c
@@ -278,10 +278,10 @@ lua_html_push_image (lua_State *L, struct html_image *img)
}
lua_pushstring (L, "height");
- lua_pushnumber (L, img->height);
+ lua_pushinteger (L, img->height);
lua_settable (L, -3);
lua_pushstring (L, "width");
- lua_pushnumber (L, img->width);
+ lua_pushinteger (L, img->width);
lua_settable (L, -3);
lua_pushstring (L, "embedded");
lua_pushboolean (L, img->flags & RSPAMD_HTML_FLAG_IMAGE_EMBEDDED);
@@ -335,26 +335,26 @@ lua_html_push_block (lua_State *L, struct html_block *bl)
if (bl->font_color.valid) {
lua_pushstring (L, "color");
lua_createtable (L, 4, 0);
- lua_pushnumber (L, bl->font_color.d.comp.r);
+ lua_pushinteger (L, bl->font_color.d.comp.r);
lua_rawseti (L, -2, 1);
- lua_pushnumber (L, bl->font_color.d.comp.g);
+ lua_pushinteger (L, bl->font_color.d.comp.g);
lua_rawseti (L, -2, 2);
- lua_pushnumber (L, bl->font_color.d.comp.b);
+ lua_pushinteger (L, bl->font_color.d.comp.b);
lua_rawseti (L, -2, 3);
- lua_pushnumber (L, bl->font_color.d.comp.alpha);
+ lua_pushinteger (L, bl->font_color.d.comp.alpha);
lua_rawseti (L, -2, 4);
lua_settable (L, -3);
}
if (bl->background_color.valid) {
lua_pushstring (L, "bgcolor");
lua_createtable (L, 4, 0);
- lua_pushnumber (L, bl->background_color.d.comp.r);
+ lua_pushinteger (L, bl->background_color.d.comp.r);
lua_rawseti (L, -2, 1);
- lua_pushnumber (L, bl->background_color.d.comp.g);
+ lua_pushinteger (L, bl->background_color.d.comp.g);
lua_rawseti (L, -2, 2);
- lua_pushnumber (L, bl->background_color.d.comp.b);
+ lua_pushinteger (L, bl->background_color.d.comp.b);
lua_rawseti (L, -2, 3);
- lua_pushnumber (L, bl->background_color.d.comp.alpha);
+ lua_pushinteger (L, bl->background_color.d.comp.alpha);
lua_rawseti (L, -2, 4);
lua_settable (L, -3);
}
@@ -374,7 +374,7 @@ lua_html_push_block (lua_State *L, struct html_block *bl)
lua_settable (L, -3);
lua_pushstring (L, "font_size");
- lua_pushnumber (L, bl->font_size);
+ lua_pushinteger (L, bl->font_size);
lua_settable (L, -3);
}
@@ -429,7 +429,7 @@ lua_html_node_foreach_cb (GNode *n, gpointer d)
ptag = lua_newuserdata (ud->L, sizeof (*ptag));
*ptag = tag;
rspamd_lua_setclass (ud->L, "rspamd{html_tag}", -1);
- lua_pushnumber (ud->L, tag->content_length);
+ lua_pushinteger (ud->L, tag->content_length);
if (lua_pcall (ud->L, 2, 1, 0) != 0) {
msg_err ("error in foreach_tag callback: %s", lua_tostring (ud->L, -1));
@@ -640,7 +640,7 @@ lua_html_tag_get_content_length (lua_State *L)
struct html_tag *tag = lua_check_html_tag (L, 1);
if (tag) {
- lua_pushnumber (L, tag->content_length);
+ lua_pushinteger (L, tag->content_length);
}
else {
return luaL_error (L, "invalid arguments");
diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c
index cb2026421..c292428c2 100644
--- a/src/lua/lua_http.c
+++ b/src/lua/lua_http.c
@@ -183,7 +183,7 @@ lua_http_finish_handler (struct rspamd_http_connection *conn,
/* Error */
lua_pushnil (cbd->L);
/* Reply code */
- lua_pushnumber (cbd->L, msg->code);
+ lua_pushinteger (cbd->L, msg->code);
/* Body */
body = rspamd_http_message_get_body (msg, &body_len);
diff --git a/src/lua/lua_ip.c b/src/lua/lua_ip.c
index dc6271e7e..800c9765c 100644
--- a/src/lua/lua_ip.c
+++ b/src/lua/lua_ip.c
@@ -229,7 +229,7 @@ lua_ip_to_table (lua_State *L)
lua_createtable (L, max, 0);
for (i = 1; i <= max; i++, ptr++) {
- lua_pushnumber (L, *ptr);
+ lua_pushinteger (L, *ptr);
lua_rawseti (L, -2, i);
}
}
@@ -351,7 +351,7 @@ lua_ip_get_port (lua_State *L)
struct rspamd_lua_ip *ip = lua_check_ip (L, 1);
if (ip != NULL && ip->addr) {
- lua_pushnumber (L, rspamd_inet_address_get_port (ip->addr));
+ lua_pushinteger (L, rspamd_inet_address_get_port (ip->addr));
}
else {
lua_pushnil (L);
@@ -433,7 +433,7 @@ lua_ip_get_version (lua_State *L)
struct rspamd_lua_ip *ip = lua_check_ip (L, 1);
if (ip && ip->addr) {
- lua_pushnumber (L, rspamd_inet_address_get_af (ip->addr) == AF_INET6 ?
+ lua_pushinteger (L, rspamd_inet_address_get_af (ip->addr) == AF_INET6 ?
6 : 4);
}
else {
diff --git a/src/lua/lua_map.c b/src/lua/lua_map.c
index 5af724577..1621abf0d 100644
--- a/src/lua/lua_map.c
+++ b/src/lua/lua_map.c
@@ -894,7 +894,7 @@ lua_map_traverse_cb (gconstpointer key,
lua_State *L = (lua_State *)ud;
lua_pushstring (L, key);
- lua_pushnumber (L, hits);
+ lua_pushinteger (L, hits);
lua_settable (L, -3);
return TRUE;
@@ -950,7 +950,7 @@ lua_map_get_nelts (lua_State * L)
struct rspamd_lua_map *map = lua_check_map (L, 1);
if (map != NULL) {
- lua_pushnumber (L, map->map->nelts);
+ lua_pushinteger (L, map->map->nelts);
}
else {
return luaL_error (L, "invalid arguments");
diff --git a/src/lua/lua_mempool.c b/src/lua/lua_mempool.c
index e5cb94219..4fce73aac 100644
--- a/src/lua/lua_mempool.c
+++ b/src/lua/lua_mempool.c
@@ -252,7 +252,7 @@ lua_mempool_suggest_size (lua_State *L)
struct memory_pool_s *mempool = rspamd_lua_check_mempool (L, 1);
if (mempool) {
- lua_pushnumber (L, rspamd_mempool_suggest_size ());
+ lua_pushinteger (L, rspamd_mempool_suggest_size ());
return 0;
}
else {
@@ -437,12 +437,12 @@ lua_mempool_get_variable (lua_State *L)
}
else if (len == sizeof ("int") - 1 &&
g_ascii_strncasecmp (pt, "int", len) == 0) {
- lua_pushnumber (L, *(gint *)pv);
+ lua_pushinteger (L, *(gint *)pv);
pv += sizeof (gint);
}
else if (len == sizeof ("int64") - 1 &&
g_ascii_strncasecmp (pt, "int64", len) == 0) {
- lua_pushnumber (L, *(gint64 *)pv);
+ lua_pushinteger (L, *(gint64 *)pv);
pv += sizeof (gint64);
}
else if (len == sizeof ("bool") - 1 &&
diff --git a/src/lua/lua_mimepart.c b/src/lua/lua_mimepart.c
index f3ea62b98..bb3406e80 100644
--- a/src/lua/lua_mimepart.c
+++ b/src/lua/lua_mimepart.c
@@ -637,10 +637,10 @@ lua_textpart_get_length (lua_State * L)
}
if (IS_PART_EMPTY (part) || part->content == NULL) {
- lua_pushnumber (L, 0);
+ lua_pushinteger (L, 0);
}
else {
- lua_pushnumber (L, part->content->len);
+ lua_pushinteger (L, part->content->len);
}
return 1;
@@ -657,7 +657,7 @@ lua_textpart_get_raw_length (lua_State * L)
return 1;
}
- lua_pushnumber (L, part->raw.len);
+ lua_pushinteger (L, part->raw.len);
return 1;
}
@@ -684,7 +684,7 @@ lua_textpart_get_urls_length (lua_State * L)
}
}
- lua_pushnumber (L, total);
+ lua_pushinteger (L, total);
return 1;
}
@@ -701,10 +701,10 @@ lua_textpart_get_lines_count (lua_State * L)
}
if (IS_PART_EMPTY (part)) {
- lua_pushnumber (L, 0);
+ lua_pushinteger (L, 0);
}
else {
- lua_pushnumber (L, part->nlines);
+ lua_pushinteger (L, part->nlines);
}
return 1;
@@ -722,10 +722,10 @@ lua_textpart_get_words_count (lua_State *L)
}
if (IS_PART_EMPTY (part) || part->normalized_words == NULL) {
- lua_pushnumber (L, 0);
+ lua_pushinteger (L, 0);
}
else {
- lua_pushnumber (L, part->normalized_words->len);
+ lua_pushinteger (L, part->normalized_words->len);
}
return 1;
@@ -1028,31 +1028,31 @@ lua_textpart_get_stats (lua_State * L)
lua_createtable (L, 0, 9);
lua_pushstring (L, "lines");
- lua_pushnumber (L, part->nlines);
+ lua_pushinteger (L, part->nlines);
lua_settable (L, -3);
lua_pushstring (L, "empty_lines");
- lua_pushnumber (L, part->empty_lines);
+ lua_pushinteger (L, part->empty_lines);
lua_settable (L, -3);
lua_pushstring (L, "spaces");
- lua_pushnumber (L, part->spaces);
+ lua_pushinteger (L, part->spaces);
lua_settable (L, -3);
lua_pushstring (L, "non_spaces");
- lua_pushnumber (L, part->non_spaces);
+ lua_pushinteger (L, part->non_spaces);
lua_settable (L, -3);
lua_pushstring (L, "double_spaces");
- lua_pushnumber (L, part->double_spaces);
+ lua_pushinteger (L, part->double_spaces);
lua_settable (L, -3);
lua_pushstring (L, "ascii_characters");
- lua_pushnumber (L, part->ascii_chars);
+ lua_pushinteger (L, part->ascii_chars);
lua_settable (L, -3);
lua_pushstring (L, "non_ascii_characters");
- lua_pushnumber (L, part->non_ascii_chars);
+ lua_pushinteger (L, part->non_ascii_chars);
lua_settable (L, -3);
lua_pushstring (L, "capital_letters");
- lua_pushnumber (L, part->capital_letters);
+ lua_pushinteger (L, part->capital_letters);
lua_settable (L, -3);
lua_pushstring (L, "numeric_characters");
- lua_pushnumber (L, part->numeric_characters);
+ lua_pushinteger (L, part->numeric_characters);
lua_settable (L, -3);
}
else {
@@ -1117,7 +1117,7 @@ lua_mimepart_get_length (lua_State * L)
return 1;
}
- lua_pushnumber (L, part->parsed_data.len);
+ lua_pushinteger (L, part->parsed_data.len);
return 1;
}
diff --git a/src/lua/lua_redis.c b/src/lua/lua_redis.c
index 82ef0c53b..e5b97ebeb 100644
--- a/src/lua/lua_redis.c
+++ b/src/lua/lua_redis.c
@@ -281,7 +281,7 @@ lua_redis_push_reply (lua_State *L, const redisReply *r, gboolean text_data)
switch (r->type) {
case REDIS_REPLY_INTEGER:
- lua_pushnumber (L, r->integer);
+ lua_pushinteger (L, r->integer);
break;
case REDIS_REPLY_NIL:
/* XXX: not the best approach */
diff --git a/src/lua/lua_regexp.c b/src/lua/lua_regexp.c
index 896fb3d9b..e88dc1bcc 100644
--- a/src/lua/lua_regexp.c
+++ b/src/lua/lua_regexp.c
@@ -318,10 +318,10 @@ lua_regexp_set_max_hits (lua_State *L)
struct rspamd_lua_regexp *re = lua_check_regexp (L);
guint lim;
- lim = luaL_checknumber (L, 2);
+ lim = luaL_checkinteger (L, 2);
if (re && re->re && !IS_DESTROYED (re)) {
- lua_pushnumber (L, rspamd_regexp_set_maxhits (re->re, lim));
+ lua_pushinteger (L, rspamd_regexp_set_maxhits (re->re, lim));
}
else {
lua_pushnil (L);
@@ -342,10 +342,10 @@ lua_regexp_get_max_hits (lua_State *L)
struct rspamd_lua_regexp *re = lua_check_regexp (L);
if (re && re->re && !IS_DESTROYED (re)) {
- lua_pushnumber (L, rspamd_regexp_get_maxhits (re->re));
+ lua_pushinteger (L, rspamd_regexp_get_maxhits (re->re));
}
else {
- lua_pushnumber (L, 1);
+ lua_pushinteger (L, 1);
}
return 1;
@@ -580,7 +580,7 @@ lua_regexp_matchn (lua_State *L)
}
}
- lua_pushnumber (L, matches);
+ lua_pushinteger (L, matches);
return 1;
}
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index e60fe6592..868554174 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -2023,7 +2023,7 @@ rspamd_lua_push_header (lua_State *L, struct rspamd_mime_header *rh,
lua_settable (L, -3);
rspamd_lua_table_set (L, "separator", rh->separator);
lua_pushstring (L, "order");
- lua_pushnumber (L, rh->order);
+ lua_pushinteger (L, rh->order);
lua_settable (L, -3);
break;
case RSPAMD_TASK_HEADER_PUSH_RAW:
@@ -2079,7 +2079,7 @@ rspamd_lua_push_header_array (lua_State * L,
}
}
else if (how == RSPAMD_TASK_HEADER_PUSH_COUNT) {
- lua_pushnumber (L, ar->len);
+ lua_pushinteger (L, ar->len);
}
else {
rh = g_ptr_array_index (ar, 0);
@@ -2265,7 +2265,7 @@ lua_task_get_received_headers (lua_State * L)
lua_settable (L, -3);
lua_pushstring (L, "timestamp");
- lua_pushnumber (L, rh->timestamp);
+ lua_pushinteger (L, rh->timestamp);
lua_settable (L, -3);
rspamd_lua_table_set (L, "by_hostname", rh->by_hostname);
@@ -2362,7 +2362,7 @@ lua_task_get_dns_req (lua_State *L)
struct rspamd_task *task = lua_check_task (L, 1);
if (task != NULL) {
- lua_pushnumber (L, task->dns_requests);
+ lua_pushinteger (L, task->dns_requests);
}
else {
return luaL_error (L, "invalid arguments");
@@ -3578,7 +3578,7 @@ lua_task_get_symbols_numeric (lua_State *L)
if (!(s->flags & RSPAMD_SYMBOL_RESULT_IGNORED)) {
id = rspamd_symbols_cache_find_symbol (task->cfg->cache,
s->name);
- lua_pushnumber (L, id);
+ lua_pushinteger (L, id);
lua_rawseti (L, -3, i);
lua_pushnumber (L, s->score);
lua_rawseti (L, -2, i);
@@ -3823,10 +3823,10 @@ lua_task_get_timeval (lua_State *L)
if (task != NULL) {
lua_createtable (L, 0, 2);
lua_pushstring (L, "tv_sec");
- lua_pushnumber (L, (lua_Number)task->tv.tv_sec);
+ lua_pushinteger (L, (lua_Integer)task->tv.tv_sec);
lua_settable (L, -3);
lua_pushstring (L, "tv_usec");
- lua_pushnumber (L, (lua_Number)task->tv.tv_usec);
+ lua_pushinteger (L, (lua_Integer)task->tv.tv_usec);
lua_settable (L, -3);
}
else {
@@ -3843,7 +3843,7 @@ lua_task_get_size (lua_State *L)
struct rspamd_task *task = lua_check_task (L, 1);
if (task != NULL) {
- lua_pushnumber (L, task->msg.len);
+ lua_pushinteger (L, task->msg.len);
}
else {
return luaL_error (L, "invalid arguments");
@@ -4486,7 +4486,7 @@ lua_task_process_regexp (lua_State *L)
return luaL_error (L, "invalid arguments");
}
- lua_pushnumber (L, ret);
+ lua_pushinteger (L, ret);
return 1;
}
@@ -4669,7 +4669,7 @@ lua_push_stat_token (lua_State *L, rspamd_token_t *tok)
}
lua_pushstring (L, "win");
- lua_pushnumber (L, tok->window_idx);
+ lua_pushinteger (L, tok->window_idx);
lua_settable (L, -3);
lua_pushstring (L, "flags");
@@ -4918,7 +4918,7 @@ lua_image_get_width (lua_State *L)
struct rspamd_image *img = lua_check_image (L);
if (img != NULL) {
- lua_pushnumber (L, img->width);
+ lua_pushinteger (L, img->width);
}
else {
return luaL_error (L, "invalid arguments");
@@ -4934,7 +4934,7 @@ lua_image_get_height (lua_State *L)
struct rspamd_image *img = lua_check_image (L);
if (img != NULL) {
- lua_pushnumber (L, img->height);
+ lua_pushinteger (L, img->height);
}
else {
return luaL_error (L, "invalid arguments");
@@ -4966,7 +4966,7 @@ lua_image_get_size (lua_State *L)
struct rspamd_image *img = lua_check_image (L);
if (img != NULL) {
- lua_pushnumber (L, img->data->len);
+ lua_pushinteger (L, img->data->len);
}
else {
return luaL_error (L, "invalid arguments");
@@ -5054,11 +5054,11 @@ lua_archive_get_files_full (lua_State *L)
lua_settable (L, -3);
lua_pushstring (L, "compressed_size");
- lua_pushnumber (L, f->compressed_size);
+ lua_pushinteger (L, f->compressed_size);
lua_settable (L, -3);
lua_pushstring (L, "uncompressed_size");
- lua_pushnumber (L, f->uncompressed_size);
+ lua_pushinteger (L, f->uncompressed_size);
lua_settable (L, -3);
lua_pushstring (L, "encrypted");
@@ -5098,7 +5098,7 @@ lua_archive_get_size (lua_State *L)
struct rspamd_archive *arch = lua_check_archive (L);
if (arch != NULL) {
- lua_pushnumber (L, arch->size);
+ lua_pushinteger (L, arch->size);
}
else {
return luaL_error (L, "invalid arguments");
@@ -5138,7 +5138,7 @@ lua_text_len (lua_State *L)
return luaL_error (L, "invalid arguments");
}
- lua_pushnumber (L, l);
+ lua_pushinteger (L, l);
return 1;
}
diff --git a/src/lua/lua_trie.c b/src/lua/lua_trie.c
index 362564ce8..16a8ace0c 100644
--- a/src/lua/lua_trie.c
+++ b/src/lua/lua_trie.c
@@ -156,8 +156,8 @@ lua_trie_callback (struct rspamd_multipattern *mp,
/* Function */
lua_pushvalue (L, 3);
- lua_pushnumber (L, strnum + 1);
- lua_pushnumber (L, textpos);
+ lua_pushinteger (L, strnum + 1);
+ lua_pushinteger (L, textpos);
if (lua_pcall (L, 2, 1, 0) != 0) {
msg_info ("call to trie callback has failed: %s",
diff --git a/src/lua/lua_url.c b/src/lua/lua_url.c
index 1507684cc..5dee14224 100644
--- a/src/lua/lua_url.c
+++ b/src/lua/lua_url.c
@@ -121,7 +121,7 @@ lua_url_get_length (lua_State *L)
struct rspamd_lua_url *url = lua_check_url (L, 1);
if (url != NULL) {
- lua_pushnumber (L, url->url->urllen);
+ lua_pushinteger (L, url->url->urllen);
}
else {
lua_pushnil (L);
@@ -161,7 +161,7 @@ lua_url_get_port (lua_State *L)
struct rspamd_lua_url *url = lua_check_url (L, 1);
if (url != NULL) {
- lua_pushnumber (L, url->url->port);
+ lua_pushinteger (L, url->url->port);
}
else {
lua_pushnil (L);
@@ -585,7 +585,7 @@ lua_url_get_count (lua_State *L)
struct rspamd_lua_url *url = lua_check_url (L, 1);
if (url != NULL && url->url != NULL) {
- lua_pushnumber (L, url->url->count);
+ lua_pushinteger (L, url->url->count);
}
else {
lua_pushnil (L);
@@ -628,7 +628,7 @@ lua_url_to_table (lua_State *L)
if (u->port != 0) {
lua_pushstring (L, "port");
- lua_pushnumber (L, u->port);
+ lua_pushinteger (L, u->port);
lua_settable (L, -3);
}
@@ -787,7 +787,7 @@ lua_url_table_inserter (struct rspamd_url *url, gsize start_offset,
lua_url = lua_newuserdata (L, sizeof (struct rspamd_lua_url));
rspamd_lua_setclass (L, "rspamd{url}", -1);
lua_url->url = url;
- lua_pushnumber (L, n + 1);
+ lua_pushinteger (L, n + 1);
lua_pushlstring (L, url->string, url->urllen);
lua_settable (L, -3);
}
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index 49d643087..70e16118d 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -1242,7 +1242,7 @@ lua_util_levenshtein_distance (lua_State *L)
replace_cost);
}
- lua_pushnumber (L, dist);
+ lua_pushinteger (L, dist);
return 1;
}
@@ -1514,7 +1514,7 @@ lua_util_strlen_utf8 (lua_State *L)
+ (len - (end - str)) /* raw part */;
}
- lua_pushnumber (L, len);
+ lua_pushinteger (L, len);
}
else {
return luaL_error (L, "invalid arguments");
@@ -1547,7 +1547,7 @@ lua_util_strcasecmp_utf8 (lua_State *L)
return luaL_error (L, "invalid arguments");
}
- lua_pushnumber (L, ret);
+ lua_pushinteger (L, ret);
return 1;
}
@@ -1575,7 +1575,7 @@ lua_util_strcasecmp_ascii (lua_State *L)
return luaL_error (L, "invalid arguments");
}
- lua_pushnumber (L, ret);
+ lua_pushinteger (L, ret);
return 1;
}
@@ -1688,11 +1688,11 @@ lua_util_stat (lua_State *L)
lua_createtable (L, 0, 3);
lua_pushstring (L, "size");
- lua_pushnumber (L, st.st_size);
+ lua_pushinteger (L, st.st_size);
lua_settable (L, -3);
lua_pushstring (L, "mtime");
- lua_pushnumber (L, st.st_mtime);
+ lua_pushinteger (L, st.st_mtime);
lua_settable (L, -3);
lua_pushstring (L, "type");
@@ -1793,7 +1793,7 @@ lua_util_lock_file (lua_State *L)
return 2;
}
- lua_pushnumber (L, fd);
+ lua_pushinteger (L, fd);
}
else {
return luaL_error (L, "invalid arguments");
@@ -1819,7 +1819,7 @@ lua_util_unlock_file (lua_State *L)
#endif
if (lua_isnumber (L, 1)) {
- fd = lua_tonumber (L, 1);
+ fd = lua_tointeger (L, 1);
if (lua_isboolean (L, 2)) {
do_close = lua_toboolean (L, 2);
@@ -1864,7 +1864,7 @@ lua_util_create_file (lua_State *L)
if (fpath) {
if (lua_isnumber (L, 2)) {
- mode = lua_tonumber (L, 2);
+ mode = lua_tointeger (L, 2);
}
fd = rspamd_file_xopen (fpath, O_RDWR | O_CREAT | O_EXCL, mode, 0);
@@ -1876,7 +1876,7 @@ lua_util_create_file (lua_State *L)
return 2;
}
- lua_pushnumber (L, fd);
+ lua_pushinteger (L, fd);
}
else {
return luaL_error (L, "invalid arguments");
@@ -1892,7 +1892,7 @@ lua_util_close_file (lua_State *L)
gint fd = -1;
if (lua_isnumber (L, 1)) {
- fd = lua_tonumber (L, 1);
+ fd = lua_tointeger (L, 1);
if (close (fd) == -1) {
lua_pushboolean (L, false);
@@ -1917,7 +1917,7 @@ lua_util_random_hex (lua_State *L)
gchar *buf;
gint buflen;
- buflen = lua_tonumber (L, 1);
+ buflen = lua_tointeger (L, 1);
if (buflen <= 0) {
return luaL_error (L, "invalid arguments");
@@ -2607,7 +2607,7 @@ lua_util_umask (lua_State *L)
old = umask (mask);
- lua_pushnumber (L, old);
+ lua_pushinteger (L, old);
return 1;
}
@@ -3426,7 +3426,7 @@ lua_ev_base_loop (lua_State *L)
}
int ret = event_base_loop (ev_base, flags);
- lua_pushnumber (L, ret);
+ lua_pushinteger (L, ret);
return 1;
}
diff --git a/src/lua/lua_xmlrpc.c b/src/lua/lua_xmlrpc.c
index b13c98b8d..d4aa87888 100644
--- a/src/lua/lua_xmlrpc.c
+++ b/src/lua/lua_xmlrpc.c
@@ -580,7 +580,7 @@ xmlrpc_text (GMarkupParseContext *context,
case read_int:
/* Push integer value */
rspamd_strtoul (text, text_len, &num);
- lua_pushnumber (ud->L, num);
+ lua_pushinteger (ud->L, num);
break;
case read_double:
/* Push integer value */
diff --git a/src/rspamadm/lua_repl.c b/src/rspamadm/lua_repl.c
index a807101e0..26b642871 100644
--- a/src/rspamadm/lua_repl.c
+++ b/src/rspamadm/lua_repl.c
@@ -703,7 +703,7 @@ rspamadm_lua (gint argc, gchar **argv, const struct rspamadm_command *cmd)
lua_newtable (L);
for (elt = lua_args; *elt != NULL; elt ++) {
- lua_pushnumber (L, i);
+ lua_pushinteger (L, i);
lua_pushstring (L, *elt);
lua_settable (L, -3);
i++;