commit 00c9ae4: [Minor] Move function to the common routines

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Jan 1 19:49:06 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-01-01 19:45:48 +0000
URL: https://github.com/rspamd/rspamd/commit/00c9ae4c698cd63b9ab7cb155d5c342f50281cd6

[Minor] Move function to the common routines

---
 src/lua/lua_common.c | 31 +++++++++++++++++++++++++++++++
 src/lua/lua_common.h |  7 +++++++
 src/lua/lua_regexp.c | 31 -------------------------------
 3 files changed, 38 insertions(+), 31 deletions(-)

diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index 80a9423d9..248f1dbc3 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -2346,4 +2346,35 @@ rspamd_lua_push_words (lua_State *L, GArray *words,
 	}
 
 	return 1;
+}
+
+gchar *
+rspamd_lua_get_module_name (lua_State *L)
+{
+	lua_Debug d;
+	gchar *p;
+	gchar func_buf[128];
+
+	if (lua_getstack (L, 1, &d) == 1) {
+		(void) lua_getinfo (L, "Sl", &d);
+		if ((p = strrchr (d.short_src, '/')) == NULL) {
+			p = d.short_src;
+		}
+		else {
+			p++;
+		}
+
+		if (strlen (p) > 20) {
+			rspamd_snprintf (func_buf, sizeof (func_buf), "%10s...]:%d", p,
+					d.currentline);
+		}
+		else {
+			rspamd_snprintf (func_buf, sizeof (func_buf), "%s:%d", p,
+					d.currentline);
+		}
+
+		return g_strdup (func_buf);
+	}
+
+	return NULL;
 }
\ No newline at end of file
diff --git a/src/lua/lua_common.h b/src/lua/lua_common.h
index 7980272ea..935a7c7d7 100644
--- a/src/lua/lua_common.h
+++ b/src/lua/lua_common.h
@@ -559,6 +559,13 @@ enum rspamd_lua_words_type {
 gint rspamd_lua_push_words (lua_State *L, GArray *words,
 							enum rspamd_lua_words_type how);
 
+/**
+ * Returns newly allocated name for caller module name
+ * @param L
+ * @return
+ */
+gchar *rspamd_lua_get_module_name (lua_State *L);
+
 /* Paths defs */
 #define RSPAMD_CONFDIR_INDEX "CONFDIR"
 #define RSPAMD_LOCAL_CONFDIR_INDEX "LOCAL_CONFDIR"
diff --git a/src/lua/lua_regexp.c b/src/lua/lua_regexp.c
index 70a5a5df4..b782ef7f1 100644
--- a/src/lua/lua_regexp.c
+++ b/src/lua/lua_regexp.c
@@ -81,37 +81,6 @@ lua_check_regexp (lua_State * L, gint pos)
 	return ud ? *((struct rspamd_lua_regexp **)ud) : NULL;
 }
 
-static gchar *
-rspamd_lua_get_module_name (lua_State *L)
-{
-	lua_Debug d;
-	gchar *p;
-	gchar func_buf[128];
-
-	if (lua_getstack (L, 1, &d) == 1) {
-		(void) lua_getinfo (L, "Sl", &d);
-		if ((p = strrchr (d.short_src, '/')) == NULL) {
-			p = d.short_src;
-		}
-		else {
-			p++;
-		}
-
-		if (strlen (p) > 20) {
-			rspamd_snprintf (func_buf, sizeof (func_buf), "%10s...]:%d", p,
-					d.currentline);
-		}
-		else {
-			rspamd_snprintf (func_buf, sizeof (func_buf), "%s:%d", p,
-					d.currentline);
-		}
-
-		return g_strdup (func_buf);
-	}
-
-	return NULL;
-}
-
 /***
  * @function rspamd_regexp.create(pattern[, flags])
  * Creates new rspamd_regexp


More information about the Commits mailing list