mirror of
https://github.com/moparisthebest/hexchat
synced 2024-11-26 11:12:19 -05:00
Speed up Non-BMP filtering
This commit is contained in:
parent
902063d932
commit
dbef9c9eb4
@ -312,8 +312,10 @@ 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 */
|
||||
@ -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,7 +421,9 @@ 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 */
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user