summaryrefslogtreecommitdiff
path: root/menus.c
diff options
context:
space:
mode:
Diffstat (limited to 'menus.c')
-rw-r--r--menus.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/menus.c b/menus.c
index a8c9daa..5eed020 100644
--- a/menus.c
+++ b/menus.c
@@ -2292,9 +2292,7 @@ static void Submenu_Service_Encoder(int encoder_change)
{
int error_num;
- char expon[32]; /* exponent portion of string */
int equivalent_integer; /* non-exponent part stripped of its decimal point */
- char new_string[32]; /* new parameter value to be loaded, string format */
float new_value; /* new parameter value to be loaded */
float abs_Submenu_Value; /* absolute value of Submenu_Value */
int increment_size;
@@ -2488,7 +2486,8 @@ static void Submenu_Service_Encoder(int encoder_change)
Float_To_Text(3,abs_Submenu_Value,&num_string);
/* isolate the exponent and non-exponent parts */
- strcpy(expon,num_string+5);
+ expon = g_strdup (num_string+5);
+
num_string[5]=0;
/* remove the decimal */
@@ -2539,20 +2538,18 @@ static void Submenu_Service_Encoder(int encoder_change)
}
/* get first digit of new number */
- new_string[0]=' ';
- sprintf(new_string+1, "%d", equivalent_integer);
+ gchar* new_string = g_strdup_printf (" %d %s", equivalent_integer, expon);
+ g_free (expon);
/* put in sign if required */
if (Submenu_Value<0) {
new_string[0]='-';
}
+ // "moves" fractional digits to rear, to make room for the decimal point
sprintf(new_string+2, "%d", equivalent_integer);
new_string[2]='.';
- /* finish by adding exponent*/
- strcat(new_string,expon);
-
new_value=atof(new_string);
if (equivalent_integer>9999) {
new_value*=10;
@@ -2560,6 +2557,8 @@ static void Submenu_Service_Encoder(int encoder_change)
if (equivalent_integer<1000) {
new_value/=10;
}
+
+ g_free (new_string);
}
/* update display - correct later if required */