diff options
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -609,7 +609,11 @@ static gchar* regex_replace (gchar* in_string, gchar* regex_string, gchar* repla static gchar* filter_input (gchar *raw_in) { g_strstrip (raw_in); - gchar *step1 = g_strdup (raw_in); + gchar *step0 = g_strdup (raw_in); + + // replace weird characters with a space + gchar *step1 = regex_replace (step0, "[^\x20-\x7E]+", " "); + g_free (step0); // replace multiple whitespace with single space gchar *step2 = regex_replace (step1, "\\s+", " "); @@ -643,6 +647,14 @@ void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer static GStaticMutex mutex = G_STATIC_MUTEX_INIT; g_static_mutex_lock (&mutex); + gchar **v; + v = g_strsplit_set (raw_in, "\r\n", STDBUFSIZE); + + int str_chunk; + + for (str_chunk=0; v[str_chunk] > 0; ++str_chunk) { + gchar *in = filter_input (v[str_chunk]); + int in_pos; /* this identifies the single character of in being processed */ int command_depth; /* how many command words have been parsed */ int old_command_depth; /* save this if in case of a compound message */ @@ -665,8 +677,6 @@ void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer int channel; int with_id_code; - gchar *in = filter_input (raw_in); - in_pos = 0; /* start at the beginning of the input string */ semicolon_found = 0; compound_message = 0; @@ -1118,6 +1128,8 @@ void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer } g_free (in); + } + g_strfreev (v); g_static_mutex_unlock (&mutex); } |