diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-31 07:44:29 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-31 07:44:29 -0400 |
commit | 49cfebf2e3ac37624acdbd343809530c0cea9aa3 (patch) | |
tree | eb8238ba802baf5331b0f7954388fefb5285ca23 /menus.c | |
parent | 70369cf4cbce7759601f5ba9f9072215f9738f40 (diff) |
remove more fixed-length strings
Diffstat (limited to 'menus.c')
-rw-r--r-- | menus.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -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 */ |