summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-15 15:39:11 -0400
committerMichael J. Chudobiak <mjc@avtechpulse.com>2012-08-15 15:39:11 -0400
commitb30576989c2dadd2fa4d64cf81da98b2be4cf584 (patch)
treeb64a12fe071ecb93324096707874c8a79309a4a1
parentf6d11094382e205d56b1c2b6b334265ab23b0803 (diff)
fix errors in last commit; enhance regex filter
-rw-r--r--parser.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/parser.c b/parser.c
index 4e9df89..450cfde 100644
--- a/parser.c
+++ b/parser.c
@@ -528,12 +528,18 @@ static gchar* filter_input (gchar *raw_in)
g_regex_unref (end_semi);
g_free (step3);
+ // remove leading spaces, colons, semicolons
+ GRegex *leading = g_regex_new ("^[\\s:;]*", 0, 0, NULL);
+ gchar *step5 = g_regex_replace_literal (leading, step4, -1, 0, "", 0, NULL);
+ g_regex_unref (end_semi);
+ g_free (step4);
+
// last step may leave hanging whitespace at end
- g_strstrip (step4);
+ g_strstrip (step5);
// add single space to terminate
- gchar *filt = g_strdup_printf ("%s ", step4);
- g_free (step4);
+ gchar *filt = g_strdup_printf ("%s ", step5);
+ g_free (step5);
return filt;
}
@@ -573,12 +579,6 @@ void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer
old_command_depth=0;
dont_use_this_header=NO;
- while (isspace(in[in_pos]) || in[in_pos]==':' || in[in_pos]==';') {
- /* ignore leading spaces */
- ++in_pos;
- }
-
-
/* examine each letter in the string until EOS */
while (in[in_pos] != 0) {
@@ -968,7 +968,7 @@ static int query_min_max_int (gchar** response, char *parameter, int min_val, in
return SyntaxError;
}
- *response = g_printf ("%d", report_val);
+ *response = g_strdup_printf ("%d", report_val);
return OK;
}
@@ -1036,7 +1036,7 @@ static int process_float_param (char *parameter, float *value, float min_val, fl
#define NO_ON_OFF 1
static int process_int_param (char *parameter, int *value, int item_count, int *valid_nums, int allow_on_off)
{
- int status, i, min_val, max_val, is_valid, items_in_list;
+ int status, i, min_val, max_val, is_valid;
status = OK;
is_valid = 0;
@@ -1092,7 +1092,7 @@ static int process_int_range (char *parameter, int *value, int min_val, int max_
static int process_on_off (char *parameter, int *value)
{
- static const int valid_choices[2] = {0, 1};
+ int valid_choices[2] = {0, 1};
return process_int_param (parameter, value, 2, valid_choices, USE_ON_OFF);
}