From 45453184e212d35229e33045fd5e641c85beec68 Mon Sep 17 00:00:00 2001 From: "Michael J. Chudobiak" Date: Wed, 14 Nov 2012 08:49:02 -0500 Subject: remove fixed-length strings in mode_names --- menus.c | 169 ++++++++++++++++++++++++++++------------------------------------ 1 file changed, 73 insertions(+), 96 deletions(-) (limited to 'menus.c') diff --git a/menus.c b/menus.c index f50481a..0946d11 100644 --- a/menus.c +++ b/menus.c @@ -1600,9 +1600,9 @@ 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]; + gchar* mode_name[Submenu_maximum_entries]; + int current_operating_mode = 0; LCD_write(0,19,"Mode:"); @@ -1610,351 +1610,333 @@ static void Submenu_Display(int change_selection) for (i=0; i<=Submenu_max_entry; ++i) { switch (Submenu_Structure[i]-channel) { case mode_freq_int: - strcpy(mode_name[i],"Internal"); + mode_name[i] = g_strdup("Internal"); if (globals.ChannelState[channel].trigger_source==source_internal) { current_operating_mode=i; } break; case mode_freq_ext: - strcpy(mode_name[i],"External"); + mode_name[i] = g_strdup("External"); if (globals.ChannelState[channel].trigger_source==source_external) { current_operating_mode=i; } break; case mode_freq_man: - strcpy(mode_name[i],"Manual"); + mode_name[i] = g_strdup("Manual"); if (globals.ChannelState[channel].trigger_source==source_manual) { current_operating_mode=i; } break; case mode_freq_hold: - strcpy(mode_name[i],"Hold"); + mode_name[i] = g_strdup("Hold"); if (globals.ChannelState[channel].trigger_source==source_hold) { current_operating_mode=i; } break; case mode_func_sin: - strcpy(mode_name[i],"Sine"); + mode_name[i] = g_strdup("Sine"); if (globals.ChannelState[channel].func_mode==sin_mode_on) { current_operating_mode=i; } break; case mode_func_tri: - strcpy(mode_name[i],"Triangle"); + mode_name[i] = g_strdup("Triangle"); if (globals.ChannelState[channel].func_mode==tri_mode_on) { current_operating_mode=i; } break; case mode_func_squ: - strcpy(mode_name[i],"Square"); + mode_name[i] = g_strdup("Square"); if (globals.ChannelState[channel].func_mode==squ_mode_on) { current_operating_mode=i; } break; case mode_func_pulse: - strcpy(mode_name[i],"Pulse"); + mode_name[i] = g_strdup("Pulse"); if (globals.ChannelState[channel].func_mode==pulse_mode_on) { current_operating_mode=i; } break; case mode_func_amp: - strcpy(mode_name[i],"Amplify"); + mode_name[i] = g_strdup("Amplify"); if (globals.ChannelState[channel].func_mode==amp_mode_on) { current_operating_mode=i; } break; case mode_delay_norm: - strcpy(mode_name[i],"Normal"); + mode_name[i] = g_strdup("Normal"); if (globals.ChannelState[channel].double_pulse==double_off) { current_operating_mode=i; } break; case mode_delay_dbl: - strcpy(mode_name[i],"Double Pulse"); + mode_name[i] = g_strdup("Double Pulse"); if (globals.ChannelState[channel].double_pulse==double_on) { current_operating_mode=i; } break; case mode_pw_norm: - strcpy(mode_name[i],"Normal"); + mode_name[i] = g_strdup("Normal"); if (globals.ChannelState[channel].func_mode==pulse_mode_on && globals.ChannelState[channel].hold_setting==hold_width && globals.ChannelState[channel].ab_mode==pw_normal) { current_operating_mode=i; } break; case mode_pw_duty: - strcpy(mode_name[i],"Duty Cycle"); + mode_name[i] = g_strdup("Duty Cycle"); if (globals.ChannelState[channel].func_mode==pulse_mode_on && globals.ChannelState[channel].hold_setting==hold_duty && globals.ChannelState[channel].ab_mode==pw_normal) { current_operating_mode=i; } break; case mode_pw_inout: - strcpy(mode_name[i],"PWin=PWout"); + mode_name[i] = g_strdup("PWin=PWout"); if (globals.ChannelState[channel].func_mode==pulse_mode_on && globals.ChannelState[channel].ab_mode==pw_in_out) { current_operating_mode=i; } break; case mode_pw_dc: - strcpy(mode_name[i],"DC output"); + mode_name[i] = g_strdup("DC output"); if (globals.ChannelState[channel].func_mode==dc_mode_on) { current_operating_mode=i; } break; case mode_output_on: - strcpy(mode_name[i],"Output On"); + mode_name[i] = g_strdup("Output On"); if (globals.ChannelState[channel].output_state==output_on) { current_operating_mode=i; } break; case mode_output_off: - strcpy(mode_name[i],"Output Off"); + mode_name[i] = g_strdup("Output Off"); if (globals.ChannelState[channel].output_state==output_off) { current_operating_mode=i; } break; case mode_go_to_local: - strcpy(mode_name[i],"Go To Local"); + mode_name[i] = g_strdup("Go To Local"); break; case mode_inv_no: - strcpy(mode_name[i],"NO (normal)"); + mode_name[i] = g_strdup("NO (normal)"); if (globals.ChannelState[channel].polarity==pol_norm) { current_operating_mode=i; } break; case mode_inv_yes: - strcpy(mode_name[i],"YES (inverted)"); + mode_name[i] = g_strdup("YES (inverted)"); if (globals.ChannelState[channel].polarity==pol_complement) { current_operating_mode=i; } break; case mode_gate_losync: - strcpy(mode_name[i],"Sync,TTL-low"); + mode_name[i] = g_strdup("Sync,TTL-low"); if (globals.ChannelState[channel].gate_type==gate_sync && globals.ChannelState[channel].gate_level==gate_low) { current_operating_mode=i; } break; case mode_gate_hisync: - strcpy(mode_name[i],"Sync,TTL-hi"); + mode_name[i] = g_strdup("Sync,TTL-hi"); if (globals.ChannelState[channel].gate_type==gate_sync && globals.ChannelState[channel].gate_level==gate_high) { current_operating_mode=i; } break; case mode_gate_loasync: - strcpy(mode_name[i],"Async,TTL-low"); + mode_name[i] = g_strdup("Async,TTL-low"); if (globals.ChannelState[channel].gate_type==gate_async && globals.ChannelState[channel].gate_level==gate_low) { current_operating_mode=i; } break; case mode_gate_hiasync: - strcpy(mode_name[i],"Async,TTL-hi"); + mode_name[i] = g_strdup("Async,TTL-hi"); if (globals.ChannelState[channel].gate_type==gate_async && globals.ChannelState[channel].gate_level==gate_high) { current_operating_mode=i; } break; case mode_gpib_address: - strcpy(mode_name[i],"GPIB address"); + mode_name[i] = g_strdup("GPIB address"); break; case mode_rs232_settings: - strcpy(mode_name[i],"RS232 setup"); + mode_name[i] = g_strdup("RS232 setup"); break; case mode_model_info: - strcpy(mode_name[i],"Model info"); + mode_name[i] = g_strdup("Model info"); break; case mode_network: - strcpy(mode_name[i],"Network info"); + mode_name[i] = g_strdup("Network info"); break; case mode_password: - strcpy(mode_name[i],"Pwd~default"); + mode_name[i] = g_strdup("Pwd~default"); break; case mode_selfcal: - strcpy(mode_name[i],"Self Cal"); + mode_name[i] = g_strdup("Self Cal"); break; case mode_exit_normal_submenu: - strcpy(mode_name[i],"Exit"); + mode_name[i] = g_strdup("Exit"); break; case mode_load: - strcpy(mode_name[i],"Load Settings"); + mode_name[i] = g_strdup("Load Settings"); break; case mode_save: - strcpy(mode_name[i],"Save Settings"); + mode_name[i] = g_strdup("Save Settings"); break; case mode_load_0: - strcpy(mode_name[i],"Storage 0"); + case mode_save_0: + mode_name[i] = g_strdup("Storage 0"); break; case mode_load_1: - strcpy(mode_name[i],"Storage 1"); + case mode_save_1: + mode_name[i] = g_strdup("Storage 1"); break; case mode_load_2: - strcpy(mode_name[i],"Storage 2"); + case mode_save_2: + mode_name[i] = g_strdup("Storage 2"); break; case mode_load_3: - strcpy(mode_name[i],"Storage 3"); - break; - case mode_save_0: - strcpy(mode_name[i],"Storage 0"); - break; - case mode_save_1: - strcpy(mode_name[i],"Storage 1"); - break; - case mode_save_2: - strcpy(mode_name[i],"Storage 2"); - break; - case mode_save_3: - strcpy(mode_name[i],"Storage 3"); + case mode_save_3: + mode_name[i] = g_strdup("Storage 3"); break; case mode_change_rs232: - strcpy(mode_name[i],"Change values"); + mode_name[i] = g_strdup("Change values"); break; case mode_default_rs232: - strcpy(mode_name[i],"Default"); + mode_name[i] = g_strdup("Default"); break; case mode_exit_rs232: - strcpy(mode_name[i],"Exit"); + mode_name[i] = g_strdup("Exit"); break; case mode_zout_max: - strcpy(mode_name[i],"Zout = "); - gchar *temp1 = g_strdup_printf ("%d\xf4", globals.Flash.zout_max[channel]); - strcat(mode_name[i],temp1); - g_free (temp1); + mode_name[i] = g_strdup_printf ("Zout = %d\xf4", globals.Flash.zout_max[channel]); if (globals.ChannelState[channel].zout==globals.Flash.zout_max[channel]) { current_operating_mode=i; } break; case mode_zout_min: - strcpy(mode_name[i],"Zout = "); - gchar *temp2 = g_strdup_printf ("%d\xf4", globals.Flash.zout_min[channel]); - strcat(mode_name[i],temp2); - g_free (temp2); + mode_name[i] = g_strdup_printf ("Zout = %d\xf4", globals.Flash.zout_min[channel]); if (globals.ChannelState[channel].zout==globals.Flash.zout_min[channel]) { current_operating_mode=i; } break; case mode_logic_ttl: - strcpy(mode_name[i],"TTL levels"); + mode_name[i] = g_strdup("TTL levels"); if (globals.ChannelState[channel].logic_level==logic_ttl) { current_operating_mode=i; } break; case mode_logic_ecl: - strcpy(mode_name[i],"ECL levels"); + mode_name[i] = g_strdup("ECL levels"); if (globals.ChannelState[channel].logic_level==logic_ecl) { current_operating_mode=i; } break; case mode_amp_normal: - strcpy(mode_name[i],"Normal"); + mode_name[i] = g_strdup("Normal"); if (globals.ChannelState[channel].amp_mode==amp_mode_normal) { current_operating_mode=i; } break; case mode_amp_ea: - strcpy(mode_name[i],"Ext Control"); + mode_name[i] = g_strdup("Ext Control"); if (globals.ChannelState[channel].amp_mode==amp_mode_ea) { current_operating_mode=i; } break; case mode_amp_amplify: - strcpy(mode_name[i],"Ext Amplify"); + mode_name[i] = g_strdup("Ext Amplify"); if (globals.ChannelState[channel].amp_mode==amp_mode_amplify) { current_operating_mode=i; } break; case mode_os_normal: - strcpy(mode_name[i],"Normal"); + mode_name[i] = g_strdup("Normal"); if (globals.ChannelState[channel].os_mode==os_mode_normal) { current_operating_mode=i; } break; case mode_os_eo: - strcpy(mode_name[i],"Ext Control"); + mode_name[i] = g_strdup("Ext Control"); if (globals.ChannelState[channel].os_mode==os_mode_eo) { current_operating_mode=i; } break; case mode_amp_min: if (globals.Flash.voltage_enabled[channel]) { - String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","V",&tmp_str,YES,LCD_col_width); + String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","V",mode_name[i],YES,LCD_col_width); } else { - String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","A",&tmp_str,YES,LCD_col_width); + String_Parameter_To_Text(globals.Flash.min_ampl[channel],2,"","A",mode_name[i],YES,LCD_col_width); } - strcpy (mode_name[i], tmp_str); // FIXME - if (fabs(globals.ChannelState[channel].amplitude-globals.Flash.min_ampl[channel])