summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--parser.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/parser.c b/parser.c
index 26aa1b7..44a8ec3 100644
--- a/parser.c
+++ b/parser.c
@@ -19,7 +19,7 @@ static int process_float_param (char *parameter, float *value, float min_val, fl
static int check_channel_ok (int channel, int enabled_channels, char chankey);
static int Parser_id_word(char *id_me, int *channel, int *with_id_code);
static int Parser_find_commands(int commands[], int command_depth);
-static int Parser_get_unit(char *parameter, char **units);
+static int Parser_get_unit(char **parameter, char **units);
static int Parser_channel (int *channel,int with_id_code,int routine_num);
static int Go_freq_32_33(gchar** response, int channel, char *parameter,char *units,int command_type);
static int Handle_Units(float *mult,char *units, char *base);
@@ -466,7 +466,7 @@ static int Parser_find_commands(int commands[], int command_depth)
}
-static int Parser_get_unit(char *parameter, char **units)
+static int Parser_get_unit(char **parameter, char **units)
{
/* this function takes a parameter like "1e+6 ms" and breaks it into parameter="1e+6" and
units="ms" */
@@ -474,9 +474,9 @@ static int Parser_get_unit(char *parameter, char **units)
g_assert (*units == NULL);
gchar *end_ptr;
- g_strtod (parameter, &end_ptr);
+ g_strtod (*parameter, &end_ptr);
- if (end_ptr == parameter) {
+ if (end_ptr == *parameter) {
*units = g_strdup ("");
} else {
*units = g_strdup (end_ptr);
@@ -484,7 +484,7 @@ static int Parser_get_unit(char *parameter, char **units)
}
g_strstrip (*units);
- g_strstrip (parameter);
+ g_strstrip (*parameter);
int units_present = (*units[0] != 0);
return units_present;
@@ -502,7 +502,6 @@ void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer
/* last non-common, non-colon-started command*/
int space_found; /* if true, a space was found. parameter may follow */
int parameter_found; /* if true, there is a parameter at the end of the command string */
- char parameter[max_input_word_length]; /* identified parameter */
int semicolon_found; /* to break up lines */
int units_found; /* text found after parameter must be units */
int i; /* counter */
@@ -542,12 +541,12 @@ void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer
gchar *units = NULL;
gchar *response = NULL;
gchar *error_response = NULL;
+ gchar *parameter = NULL;
channel=-1;
with_id_code=0;
space_found = 0;
parameter_found = 0; /* no numeric parameters yet */
- parameter[0] = 0;
units_found = 0;
is_query = 0;
current_command_length = 0;
@@ -597,7 +596,7 @@ void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer
current_command[current_command_length] = '\0';
++parameter_found;
- strcpy(parameter,current_command);
+ parameter = g_strdup (current_command);
} else if (!space_found) {
/* just a regular command word */
@@ -649,7 +648,7 @@ void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer
int error_num=OK;
if (parameter_found) {
- units_found = Parser_get_unit(parameter,&units);
+ units_found = Parser_get_unit(&parameter,&units);
}
if (!error_num) {
@@ -709,6 +708,7 @@ void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer
g_free (units);
g_free (response);
g_free (error_response);
+ g_free (parameter);
if (!is_query) {
Main_update_shift_registers(); /* update values in pulse generator circuit */