summaryrefslogtreecommitdiff
path: root/parser.c
diff options
context:
space:
mode:
authorMike <mjc@avtechpulse.com>2000-01-01 02:16:19 +0900
committerMike <mjc@avtechpulse.com>2000-01-01 02:16:19 +0900
commit8b01a22ac70e86118b232bd2ae35433ac97f8418 (patch)
tree23fbfc18c233811a4ef7d256b699c3e8ed1b1cd5 /parser.c
parent58fd38e868db4dd690a3c2164857f377b19df841 (diff)
Split inputs into separate lines when multiple interactive commands are received
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/parser.c b/parser.c
index bcb2f46..e5a1643 100644
--- a/parser.c
+++ b/parser.c
@@ -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);
}