Speed up Non-BMP filtering

This commit is contained in:
Daniel Atallah 2012-10-13 07:06:38 +02:00 committed by Berke Viktor
parent 902063d932
commit dbef9c9eb4
3 changed files with 40 additions and 0 deletions

View File

@ -312,8 +312,10 @@ server_inline (server *serv, char *line, int len)
char *utf_line_allocated = NULL; char *utf_line_allocated = NULL;
#ifdef WIN32 #ifdef WIN32
#if 0
char *cleaned_line; char *cleaned_line;
int cleaned_len; int cleaned_len;
#endif
#endif #endif
/* Checks whether we're set to use UTF-8 charset */ /* Checks whether we're set to use UTF-8 charset */
@ -403,12 +405,15 @@ server_inline (server *serv, char *line, int len)
} }
#ifdef WIN32 #ifdef WIN32
#if 0
cleaned_line = text_replace_non_bmp (line, len, &cleaned_len); cleaned_line = text_replace_non_bmp (line, len, &cleaned_len);
if (cleaned_line != NULL ) { if (cleaned_line != NULL ) {
line = cleaned_line; line = cleaned_line;
len = cleaned_len; len = cleaned_len;
} }
#endif #endif
text_replace_non_bmp2 (line);
#endif
fe_add_rawlog (serv, line, len, FALSE); 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); serv->p_inline (serv, line, len);
#ifdef WIN32 #ifdef WIN32
#if 0
g_free (cleaned_line); g_free (cleaned_line);
#endif
#endif #endif
if (utf_line_allocated != NULL) /* only if a special copy was allocated */ if (utf_line_allocated != NULL) /* only if a special copy was allocated */

View File

@ -278,8 +278,10 @@ scrollback_load (session *sess)
int lines; int lines;
#ifdef WIN32 #ifdef WIN32
#if 0
char *cleaned_text; char *cleaned_text;
int cleaned_len; int cleaned_len;
#endif
#else #else
char *map, *end_map; char *map, *end_map;
struct stat statbuf; struct stat statbuf;
@ -385,6 +387,7 @@ scrollback_load (session *sess)
{ {
text = strip_color (text + 1, -1, STRIP_COLOR); text = strip_color (text + 1, -1, STRIP_COLOR);
} }
#if 0
cleaned_text = text_replace_non_bmp (text, -1, &cleaned_len); cleaned_text = text_replace_non_bmp (text, -1, &cleaned_len);
if (cleaned_text != NULL) if (cleaned_text != NULL)
{ {
@ -394,6 +397,8 @@ scrollback_load (session *sess)
} }
text = cleaned_text; text = cleaned_text;
} }
#endif
text_replace_non_bmp2 (text);
fe_print_text (sess, text, stamp); fe_print_text (sess, text, stamp);
if (prefs.text_stripcolor_replay) if (prefs.text_stripcolor_replay)
{ {
@ -925,6 +930,7 @@ iso_8859_1_to_utf8 (unsigned char *text, int len, gsize *bytes_written)
#ifdef WIN32 #ifdef WIN32
/* replace characters outside of the Basic Multilingual Plane with /* replace characters outside of the Basic Multilingual Plane with
* replacement characters (0xFFFD) */ * replacement characters (0xFFFD) */
#if 0
char * char *
text_replace_non_bmp (char *utf8_input, int input_length, glong *output_length) 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 #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 * char *
text_validate (char **text, int *len) text_validate (char **text, int *len)
{ {

View File

@ -29,8 +29,11 @@ void pevent_make_pntevts (void);
void text_emit (int index, session *sess, char *a, char *b, char *c, char *d); 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); int text_emit_by_name (char *name, session *sess, char *a, char *b, char *c, char *d);
#ifdef WIN32 #ifdef WIN32
#if 0
char *text_replace_non_bmp (char *utf8_input, int input_length, glong *output_length); char *text_replace_non_bmp (char *utf8_input, int input_length, glong *output_length);
#endif #endif
void text_replace_non_bmp2 (char *utf8_input);
#endif
char *text_validate (char **text, int *len); char *text_validate (char **text, int *len);
int get_stamp_str (char *fmt, time_t tim, char **ret); 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); void format_event (session *sess, int index, char **args, char *o, int sizeofo, unsigned int stripcolor_args);