[Pkg-privacy-commits] [irssi-plugin-otr] 15/267: regexes are now optional for glib < 2.13 compatibility.

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:26:12 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch debian
in repository irssi-plugin-otr.

commit d961f851ff080d4af64e576a4a6e62383a783654
Author: Uli Meis <a.sporto+bee at gmail.com>
Date:   Sat Jun 7 15:32:51 2008 +0200

    regexes are now optional for glib < 2.13 compatibility.
    
    Without regexes HTML won't be stripped and no nicks will be ignored.
---
 CMakeLists.txt | 20 +++++++++++++++++++-
 formats.txt    |  2 +-
 makeformats.py |  5 ++++-
 otr.c          | 17 ++++++++++++++++-
 otr_ops.c      | 37 +++++++++++++++++++++++++++----------
 5 files changed, 67 insertions(+), 14 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a12ce73..3af3e22 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,6 +25,7 @@ SET(CMAKE_MODULE_PATH
 
 INCLUDE(cmake-extensions/cscope.cmake)
 INCLUDE(CheckFunctionExists)
+INCLUDE(CheckIncludeFile)
 
 # wget
 
@@ -106,6 +107,16 @@ SET(IRSSIOTR_INCLUDE_DIRS
   ${IRSSI_INCLUDE_DIR}/irssi/src/core)
 
 include_directories(${IRSSIOTR_INCLUDE_DIRS})
+SET(CMAKE_REQUIRED_INCLUDES ${IRSSIOTR_INCLUDE_DIRS})
+
+# gregex.h 
+# available since 2.13 AFAIK
+# optional for html stripping and nick ignoring
+
+CHECK_INCLUDE_FILE(glib/gregex.h HAVE_GREGEX_H)
+IF(HAVE_GREGEX_H)
+  ADD_DEFINITIONS(-DHAVE_GREGEX_H)
+ENDIF(HAVE_GREGEX_H)
 
 # check for strsignal
 
@@ -117,7 +128,14 @@ ENDIF(HAVE_STRSIGNAL)
 
 # defs
 
-ADD_DEFINITIONS(-DHAVE_CONFIG_H -Wall -g)
+IF(NOT CMAKE_BUILD_TYPE)
+  SET(CMAKE_BUILD_TYPE debug)
+  SET(CMAKE_C_FLAGS_DEBUG -g)
+ENDIF(NOT CMAKE_BUILD_TYPE)
+
+MESSAGE(STATUS "This is a ${CMAKE_BUILD_TYPE} build")
+
+ADD_DEFINITIONS(-DHAVE_CONFIG_H -Wall)
 
 # generate otr-formats.{c,h}
 
diff --git a/formats.txt b/formats.txt
index 7e3117c..d53ae19 100644
--- a/formats.txt
+++ b/formats.txt
@@ -71,7 +71,7 @@ cmd_debug_off	Debug mode is off
 cmd_finish	Finished conversation with %s
 peer_finished	%s has finished the OTR conversation
 Nickignore
-nickignore	xmlconsole
+nickignore	xmlconsole[0-9]*
 Statusbar
 st_plaintext	{sb plaintext}
 st_untrusted	{sb %rOTR(not auth'ed)%n}
diff --git a/makeformats.py b/makeformats.py
index a0a3ccf..ceda075 100755
--- a/makeformats.py
+++ b/makeformats.py
@@ -35,6 +35,8 @@ hdr.write("TXT_OTR_MODULE_NAME")
 
 fills = 0
 
+section = None
+
 for line in lines:
 	src.write(",\n")
 
@@ -42,6 +44,7 @@ for line in lines:
 
 	if len(e)==1:
 		# Section name
+		section = e[0]
 		src.write("""{ NULL, "%s", 0 }\n""" % (e[0]))
 
 		hdr.write(",\nTXT_OTR_FILL_%d" % fills)
@@ -72,7 +75,7 @@ for line in lines:
 	#print "Handling line %s with elen %d" % (line,len(e))
 
 	premsg = ""
-	if e[1][0] != "{":
+	if e[1][0] != "{" and section!="Nickignore":
 		premsg = "%9OTR%9: "
 
 	src.write("""{ "%s", "%s%s", %s""" % (e[0],premsg,e[1],e[2]))
diff --git a/otr.c b/otr.c
index 94e34db..a3a1e50 100644
--- a/otr.c
+++ b/otr.c
@@ -20,7 +20,10 @@
 #include "otr.h"
 
 int debug = FALSE;
+
+#ifdef HAVE_GREGEX_H
 GRegex *regex_nickignore;
+#endif
 
 /*
  * Pipes all outgoing private messages through OTR
@@ -29,7 +32,13 @@ static void sig_server_sendmsg(SERVER_REC *server, const char *target,
 			       const char *msg, void *target_type_p)
 {
 	if (GPOINTER_TO_INT(target_type_p)==SEND_TARGET_NICK) {
-		char *otrmsg = otr_send(server,msg,target);
+		char *otrmsg;
+
+#ifdef HAVE_GREGEX_H
+		if (g_regex_match(regex_nickignore,target,0,NULL))
+			return;
+#endif
+		otrmsg = otr_send(server,msg,target);
 		if (otrmsg&&(otrmsg!=msg)) {
 			signal_continue(4,server,target,otrmsg,target_type_p);
 			otrl_message_free(otrmsg);
@@ -46,8 +55,10 @@ static void sig_message_private(SERVER_REC *server, const char *msg,
 {
 	char *newmsg;
 
+#ifdef HAVE_GREGEX_H
 	if (g_regex_match(regex_nickignore,nick,0,NULL))
 		return;
+#endif
 
 	newmsg = otr_receive(server,msg,nick);
 
@@ -195,7 +206,9 @@ static void otr_statusbar(SBAR_ITEM_REC *item, int get_size_only)
  */
 void otr_init(void)
 {
+#ifdef HAVE_GREGEX_H
 	regex_nickignore = g_regex_new(formats[TXT_NICKIGNORE].def,0,0,NULL);
+#endif
 
 	module_register(MODULE_NAME, "core");
 
@@ -228,7 +241,9 @@ void otr_init(void)
  */
 void otr_deinit(void)
 {
+#ifdef HAVE_GREGEX_H
 	g_regex_unref(regex_nickignore);
+#endif
 
 	signal_remove("server sendmsg", (SIGNAL_FUNC) sig_server_sendmsg);
 	signal_remove("message private", (SIGNAL_FUNC) sig_message_private);
diff --git a/otr_ops.c b/otr_ops.c
index 75258cf..1a85d86 100644
--- a/otr_ops.c
+++ b/otr_ops.c
@@ -83,6 +83,27 @@ void ops_notify(void *opdata, OtrlNotifyLevel level, const char *accountname,
 		   title,primary,secondary);
 }
 
+#ifdef HAVE_GREGEX_H
+
+/* This is kind of messy. */
+const char *convert_otr_msg(const char *msg) 
+{
+	GRegex *regex_bold  = g_regex_new("</?i([ /][^>]*)?>",0,0,NULL);
+	GRegex *regex_del   = g_regex_new("</?b([ /][^>]*)?>",0,0,NULL);
+	gchar *msgnohtml = 
+		g_regex_replace_literal(regex_del,msg,-1,0,"",0,NULL);
+
+	msg = g_regex_replace_literal(regex_bold,msgnohtml,-1,0,"*",0,NULL);
+
+	g_free(msgnohtml);
+	g_regex_unref(regex_del);
+	g_regex_unref(regex_bold);
+
+	return msg;
+}
+
+#endif
+
 /*
  * OTR message. E.g. "following has been transmitted in clear: ...".
  * We're trying to kill the ugly HTML.
@@ -94,12 +115,6 @@ int ops_display_msg(void *opdata, const char *accountname,
 	ConnContext *co = otr_getcontext(accountname,username,FALSE,NULL);
 	SERVER_REC *server = active_win->active_server;
 	struct co_info *coi;
-	/* This is kind of messy. */
-	GRegex *regex_bold  = g_regex_new("</?i([ /][^>]*)?>",0,0,NULL);
-	GRegex *regex_del   = g_regex_new("</?b([ /][^>]*)?>",0,0,NULL);
-	gchar *msgnohtml = 
-		g_regex_replace_literal(regex_del,msg,-1,0,"",0,NULL);
-	msg = g_regex_replace_literal(regex_bold,msgnohtml,-1,0,"*",0,NULL);
 
 	if (co) {
 		coi = co->app_data;
@@ -107,12 +122,14 @@ int ops_display_msg(void *opdata, const char *accountname,
 	} else 
 		otr_notice(server,username,TXT_OPS_DISPLAY_BUG);
 
+#ifdef HAVE_GREGEX_H
+	msg = convert_otr_msg(msg);
 	otr_notice(server,username,TXT_OPS_DISPLAY,msg);
-
-	g_free(msgnohtml);
 	g_free((char*)msg);
-	g_regex_unref(regex_del);
-	g_regex_unref(regex_bold);
+#else
+	otr_notice(server,username,TXT_OPS_DISPLAY,msg);
+#endif
+
 	return 0;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/irssi-plugin-otr.git



More information about the Pkg-privacy-commits mailing list