summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--menus.c28
-rw-r--r--parser.c2
-rw-r--r--string_utils.c27
-rw-r--r--string_utils.h2
4 files changed, 31 insertions, 28 deletions
diff --git a/menus.c b/menus.c
index 7c5f833..7cd12b8 100644
--- a/menus.c
+++ b/menus.c
@@ -1046,12 +1046,10 @@ static void Display_Number_on_LCD(int Is_Item_Visible,int LCD_row,int LCD_col,ch
return;
}
+ gchar *LCD_string = NULL;
gchar *units = NULL;
int channel;
- char LCD_string[LCD_cols+1];
- LCD_string[0]=0;
-
channel=Show_What%100;
if (Show_What!=Show_No_Number) {
@@ -1191,13 +1189,14 @@ static void Display_Number_on_LCD(int Is_Item_Visible,int LCD_row,int LCD_col,ch
units = g_strdup("");
}
- String_Parameter_To_Text(Submenu_Value,significant_digits,start_string,units,LCD_string,show_plus_sign);
+ String_Parameter_To_Text(Submenu_Value,significant_digits,start_string,units,&LCD_string,show_plus_sign);
} else {
- strcpy(LCD_string,start_string);
+ LCD_string = g_strdup(start_string);
}
LCD_write_padded_spaces(LCD_row, LCD_col, LCD_string, width_of_column);
-
+
+ g_free (LCD_string);
g_free (units);
}
@@ -1598,6 +1597,8 @@ static void Submenu_Display(int change_selection)
LCD_write(3,0,Press_Change_Message);
if (Submenu_max_entry>0) {
+ gchar *tmp_str = NULL; //FIXME
+
char mode_name[Submenu_maximum_entries][LCD_col_width+1];
int current_operating_mode = 0;
@@ -1870,10 +1871,12 @@ static void Submenu_Display(int change_selection)
break;
case mode_amp_min:
if (globals.Flash.voltage_enabled[channel]) {
- String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","V",mode_name[i],YES);
+ String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","V",&tmp_str,YES);
} else {
- String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","A",mode_name[i],YES);
+ String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","A",&tmp_str,YES);
}
+
+ strcpy (mode_name[i], tmp_str); // FIXME
if (fabs(globals.ChannelState[channel].amplitude-globals.Flash.min_ampl[channel])<globals.Flash.ampl_zero_equiv[channel]) {
current_operating_mode=i;
@@ -1881,11 +1884,13 @@ static void Submenu_Display(int change_selection)
break;
case mode_amp_max:
if (globals.Flash.voltage_enabled[channel]) {
- String_Parameter_To_Text(globals.Flash.max_ampl[channel],2,"","V",mode_name[i],YES);
+ String_Parameter_To_Text(globals.Flash.max_ampl[channel],2,"","V",&tmp_str,YES);
} else {
- String_Parameter_To_Text(globals.Flash.max_ampl[channel],2,"","A",mode_name[i],YES);
+ String_Parameter_To_Text(globals.Flash.max_ampl[channel],2,"","A",&tmp_str,YES);
}
+ strcpy (mode_name[i], tmp_str); // FIXME
+
if (fabs(globals.ChannelState[channel].amplitude-globals.Flash.max_ampl[channel])<globals.Flash.ampl_zero_equiv[channel]) {
current_operating_mode=i;
}
@@ -1993,7 +1998,8 @@ static void Submenu_Display(int change_selection)
if ((base_entry+3) < Submenu_max_entry) {
LCD_write(3,39,"\x3");
}
-
+
+ g_free (tmp_str);
}
}
diff --git a/parser.c b/parser.c
index 1459ae2..1313fa3 100644
--- a/parser.c
+++ b/parser.c
@@ -3193,7 +3193,7 @@ static int Parse_chan_list(int channel,char *parameter,int *primary_selected, in
int *value_pointer;
#define PARSE_MAX_STRING 20
- char temp[PARSE_MAX_STRING+1];
+ char temp[PARSE_MAX_STRING+1]; // FIXME
if (*response) {
*response[0]=0;
diff --git a/string_utils.c b/string_utils.c
index 5763e27..68091e5 100644
--- a/string_utils.c
+++ b/string_utils.c
@@ -38,7 +38,7 @@ gboolean String_is_it_numeric(char *parameter)
void String_Parameter_To_Text(float Float_To_Convert, int significant_digits,
- char *start_string,char *units,char *LCD_string,int show_plus_sign)
+ char *start_string,char *units,gchar **LCD_string,int show_plus_sign)
{
gchar *floating_val = NULL;
gchar *unit_mult = NULL; /* units multiplier, eg. M, k, u */
@@ -47,23 +47,18 @@ void String_Parameter_To_Text(float Float_To_Convert, int significant_digits,
/* is annoying. (e.g. 1.000 -> 0.999) */
/* Move the decimal with string manipulations instead. */
- strcpy(LCD_string,start_string);
+ GString *out_gstr = g_string_new (start_string);
/* if significant_digits is zero, used the supplied integer rather than the floating number */
if (!significant_digits) {
- gchar *out_val;
- out_val = g_strdup_printf ("%d", (int) Float_To_Convert);
- strcat(LCD_string,out_val);
- g_free (out_val);
+ g_string_append_printf (out_gstr, "%d", (int) Float_To_Convert);
} else {
int i;
int shift_decimal_by; /* if the exponent isn't a multiple of 3, the decimal point will be moved */
int decimal_location; /* where the decimal is in the number string */
int exponent_val; /* the exponent, in integer form */
- GString *out_gstr = g_string_new ("");
-
Float_To_Text(remote_digits_after_decimal,Float_To_Convert,&floating_val);
/* -- COPY FIRST ONE OR TWO CHARACTERS -- */
@@ -132,19 +127,21 @@ void String_Parameter_To_Text(float Float_To_Convert, int significant_digits,
/* -- FINISH UP -- */
- strcat(LCD_string,out_gstr->str);
- g_string_free (out_gstr, TRUE);
-
+
/* -- CHECK FOR TERMINATING DECIMAL POINT -- */
- if (LCD_string[strlen(LCD_string)-1]=='.') {
- LCD_string[strlen(LCD_string)-1]=0;
+ int len = strlen(out_gstr->str);
+ if (LCD_string[len-1]=='.') {
+ out_gstr = g_string_erase (out_gstr, len-1, 1);
}
- strcat(LCD_string,unit_mult);
+ out_gstr = g_string_append (out_gstr, unit_mult);
}
- strcat(LCD_string,units);
+ out_gstr = g_string_append (out_gstr, units);
+
+ *LCD_string = g_strdup (out_gstr->str);
+ g_string_free (out_gstr, TRUE);
g_free (floating_val);
g_free (unit_mult);
}
diff --git a/string_utils.h b/string_utils.h
index 6aaa8a1..bd01a1c 100644
--- a/string_utils.h
+++ b/string_utils.h
@@ -6,6 +6,6 @@
void Float_To_Text(int decimal_digits,float number_in, gchar** text_out);
gboolean String_is_it_numeric(char *parameter);
void String_Parameter_To_Text(float Float_To_Convert, int significant_digits,
- char *start_string,char *units,char *LCD_string,int show_plus_sign);
+ char *start_string,char *units,gchar **LCD_string,int show_plus_sign);
#endif