summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorDaniel Atallah <datallah@pidgin.im>2012-10-13 07:06:38 +0200
committerBerke Viktor <bviktor@hexchat.org>2012-10-13 07:06:38 +0200
commitdbef9c9eb419d756d8e2b7db880467e881d8943d (patch)
treed33772409f02f080ad7d9b6f79668bd7cb944f34 /src
parent902063d932a37e8bcc47df1fdad173a44595ad39 (diff)
Speed up Non-BMP filtering
Diffstat (limited to 'src')
-rw-r--r--src/common/server.c7
-rw-r--r--src/common/text.c30
-rw-r--r--src/common/text.h3
3 files changed, 40 insertions, 0 deletions
diff --git a/src/common/server.c b/src/common/server.c
index a7166876..3aa3c694 100644
--- a/src/common/server.c
+++ b/src/common/server.c
@@ -312,9 +312,11 @@ server_inline (server *serv, char *line, int len)
 	char *utf_line_allocated = NULL;
 
 #ifdef WIN32
+#if 0
 	char *cleaned_line;
 	int cleaned_len;
 #endif
+#endif
 
 	/* Checks whether we're set to use UTF-8 charset */
 	if (serv->using_irc ||				/* 1. using CP1252/UTF-8 Hybrid */
@@ -403,12 +405,15 @@ server_inline (server *serv, char *line, int len)
 	}
 
 #ifdef WIN32
+#if 0
 	cleaned_line = text_replace_non_bmp (line, len, &cleaned_len);
 	if (cleaned_line != NULL ) {
 		line = cleaned_line;
 		len = cleaned_len;
 	}
 #endif
+	text_replace_non_bmp2 (line);
+#endif
 
 	fe_add_rawlog (serv, line, len, FALSE);
 
@@ -416,8 +421,10 @@ server_inline (server *serv, char *line, int len)
 	serv->p_inline (serv, line, len);
 
 #ifdef WIN32
+#if 0
 	g_free (cleaned_line);
 #endif
+#endif
 
 	if (utf_line_allocated != NULL) /* only if a special copy was allocated */
 		g_free (utf_line_allocated);
diff --git a/src/common/text.c b/src/common/text.c
index c24c8358..b558affd 100644
--- a/src/common/text.c
+++ b/src/common/text.c
@@ -278,8 +278,10 @@ scrollback_load (session *sess)
 	int lines;
 
 #ifdef WIN32
+#if 0
 	char *cleaned_text;
 	int cleaned_len;
+#endif
 #else
 	char *map, *end_map;
 	struct stat statbuf;
@@ -385,6 +387,7 @@ scrollback_load (session *sess)
 				{
 					text = strip_color (text + 1, -1, STRIP_COLOR);
 				}
+#if 0
 				cleaned_text = text_replace_non_bmp (text, -1, &cleaned_len);
 				if (cleaned_text != NULL)
 				{
@@ -394,6 +397,8 @@ scrollback_load (session *sess)
 					}
 					text = cleaned_text;
 				}
+#endif
+				text_replace_non_bmp2 (text);
 				fe_print_text (sess, text, stamp);
 				if (prefs.text_stripcolor_replay)
 				{
@@ -925,6 +930,7 @@ iso_8859_1_to_utf8 (unsigned char *text, int len, gsize *bytes_written)
 #ifdef WIN32
 /* replace characters outside of the Basic Multilingual Plane with
  * replacement characters (0xFFFD) */
+#if 0
 char *
 text_replace_non_bmp (char *utf8_input, int input_length, glong *output_length)
 {
@@ -962,6 +968,30 @@ text_replace_non_bmp (char *utf8_input, int input_length, glong *output_length)
 }
 #endif
 
+void
+text_replace_non_bmp2 (char *utf8_input)
+{
+	char *tmp = utf8_input, *next;
+	gunichar suspect;
+
+	while (tmp != NULL && *tmp)
+	{
+		next = g_utf8_next_char(tmp);
+		suspect = g_utf8_get_char_validated(tmp, next - tmp);
+		if ((suspect >= 0x1D173 && suspect <= 0x1D17A) || (suspect >= 0xE0001 && suspect <= 0xE007F))
+		{
+			/* 0xFFFD - replacement character */
+			*tmp = 0xEF;
+			*(++tmp) = 0xBF;
+			*(++tmp) = 0xBD;
+			*(++tmp) = 0x1A;	/* ASCII Sub to fill the 4th non-BMP byte */
+		}
+
+		tmp = next;
+	}
+}
+#endif
+
 char *
 text_validate (char **text, int *len)
 {
diff --git a/src/common/text.h b/src/common/text.h
index 6d5ac03e..86e3bff0 100644
--- a/src/common/text.h
+++ b/src/common/text.h
@@ -29,8 +29,11 @@ void pevent_make_pntevts (void);
 void text_emit (int index, session *sess, char *a, char *b, char *c, char *d);
 int text_emit_by_name (char *name, session *sess, char *a, char *b, char *c, char *d);
 #ifdef WIN32
+#if 0
 char *text_replace_non_bmp (char *utf8_input, int input_length, glong *output_length);
 #endif
+void text_replace_non_bmp2 (char *utf8_input);
+#endif
 char *text_validate (char **text, int *len);
 int get_stamp_str (char *fmt, time_t tim, char **ret);
 void format_event (session *sess, int index, char **args, char *o, int sizeofo, unsigned int stripcolor_args);