From: Kevin Day Date: Tue, 6 Oct 2020 04:51:51 +0000 (-0500) Subject: Update: console improvements and fixes. X-Git-Tag: 0.5.1~42 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=6d97cf20f6c82242ce5a73a92c2e1a22eb52825d;p=fll Update: console improvements and fixes. Get rid of total property. This is redundant and too short. Instead, use the location.used, which is an unsigned long as opposed to a uint8_t. When I changed the result from an f_string_length_t to an f_array_length_t, I missed some places where the type needed to be replaced. --- diff --git a/level_0/f_console/c/console-common.h b/level_0/f_console/c/console-common.h index f1a1a13..c587747 100644 --- a/level_0/f_console/c/console-common.h +++ b/level_0/f_console/c/console-common.h @@ -215,7 +215,6 @@ extern "C" { * - type: One of the f_console_type_* codes, defining how this parameter is to be processed. * * - result: A code representing that the parameter is found and how it is found ('-h' vs '--help'). - * - total: A number representing the total number of times this parameter is found ('-h -h' would result in a total of 2). * * - location: The last location in argv[] where this parameter is found. * - location_sub: The last sub-location at location in argv (only used by short parameters, such as -h or +l). @@ -232,19 +231,17 @@ extern "C" { const uint8_t has_additional; const uint8_t type; - uint8_t result; - uint8_t total; // @todo locations.used could instead be used to represent the total. - - f_array_length_t location; + f_array_length_t result; + f_array_length_t location; f_string_length_t location_sub; f_array_lengths_t locations; f_array_lengths_t locations_sub; f_array_lengths_t additional; } f_console_parameter_t; - #define f_console_parameter_t_initialize(symbol_short, symbol_long, symbol_other, has_additional, type_value) { symbol_short, symbol_long, symbol_other, has_additional, type_value, f_console_result_none, 0, 0, 0, f_array_lengths_t_initialize, f_array_lengths_t_initialize, f_array_lengths_t_initialize } + #define f_console_parameter_t_initialize(symbol_short, symbol_long, symbol_other, has_additional, type_value) { symbol_short, symbol_long, symbol_other, has_additional, type_value, f_console_result_none, 0, 0, f_array_lengths_t_initialize, f_array_lengths_t_initialize, f_array_lengths_t_initialize } - #define f_macro_console_parameter_t_initialize(symbol_short, symbol_long, symbol_other, has_additional, type_value, result, total, location, location_sub, locations, locations_sub, additional) { symbol_short, symbol_long, symbol_other, has_additional, type_value, result, total, location, location_sub, locations, locations_sub, additional } + #define f_macro_console_parameter_t_initialize(symbol_short, symbol_long, symbol_other, has_additional, type_value, result, location, location_sub, locations, locations_sub, additional) { symbol_short, symbol_long, symbol_other, has_additional, type_value, result, total, location, location_sub, locations, locations_sub, additional } #endif // _di_f_console_parameter_t_ /** diff --git a/level_0/f_console/c/console.c b/level_0/f_console/c/console.c index f73f307..aeea10f 100644 --- a/level_0/f_console/c/console.c +++ b/level_0/f_console/c/console.c @@ -221,7 +221,6 @@ extern "C" { parameters.parameter[i].result = f_console_result_found; parameters.parameter[i].location = location; parameters.parameter[i].location_sub = 0; - parameters.parameter[i].total++; if (result == console_short) { parameters.parameter[i].location_sub = sub_location; @@ -287,7 +286,6 @@ extern "C" { parameters.parameter[i].result = f_console_result_found; parameters.parameter[i].location = location; parameters.parameter[i].location_sub = 0; - parameters.parameter[i].total++; if (parameters.parameter[i].has_additional) { if (needs_additional.used + parameters.parameter[i].has_additional > needs_additional.size) { diff --git a/level_2/fll_program/c/program.c b/level_2/fll_program/c/program.c index 7f1a087..072d912 100644 --- a/level_2/fll_program/c/program.c +++ b/level_2/fll_program/c/program.c @@ -133,7 +133,7 @@ extern "C" { #endif // _di_fll_program_parameter_process_ #ifndef _di_fll_program_parameter_additional_append_ - f_return_status fll_program_parameter_additional_append(const f_string_t *argv, const f_string_lengths_t additional, f_string_dynamics_t *destination) { + f_return_status fll_program_parameter_additional_append(const f_string_t *argv, const f_array_lengths_t additional, f_string_dynamics_t *destination) { #ifndef _di_level_2_parameter_checking_ if (!argv) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -176,7 +176,7 @@ extern "C" { #endif // _di_fll_program_parameter_additional_append_ #ifndef _di_fll_program_parameter_additional_mash_ - f_return_status fll_program_parameter_additional_mash(const f_string_t glue, const f_string_length_t glue_length, const f_string_t *argv, const f_string_lengths_t additional, f_string_dynamic_t *destination) { + f_return_status fll_program_parameter_additional_mash(const f_string_t glue, const f_string_length_t glue_length, const f_string_t *argv, const f_array_lengths_t additional, f_string_dynamic_t *destination) { #ifndef _di_level_2_parameter_checking_ if (!argv) return F_status_set_error(F_parameter); if (glue_length < 1) return F_status_set_error(F_parameter); @@ -207,7 +207,7 @@ extern "C" { #endif // _di_fll_program_parameter_additional_mash_ #ifndef _di_fll_program_parameter_additional_rip_ - f_return_status fll_program_parameter_additional_rip(const f_string_t *argv, const f_string_lengths_t additional, f_string_dynamics_t *destination) { + f_return_status fll_program_parameter_additional_rip(const f_string_t *argv, const f_array_lengths_t additional, f_string_dynamics_t *destination) { #ifndef _di_level_2_parameter_checking_ if (!argv) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -251,7 +251,7 @@ extern "C" { #endif // _di_fll_program_parameter_additional_rip_ #ifndef _di_fll_program_parameter_additional_rip_mash_ - f_return_status fll_program_parameter_additional_rip_mash(const f_string_t glue, const f_string_length_t glue_length, const f_string_t *argv, const f_string_lengths_t additional, f_string_dynamic_t *destination) { + f_return_status fll_program_parameter_additional_rip_mash(const f_string_t glue, const f_string_length_t glue_length, const f_string_t *argv, const f_array_lengths_t additional, f_string_dynamic_t *destination) { #ifndef _di_level_2_parameter_checking_ if (!argv) return F_status_set_error(F_parameter); if (glue_length < 1) return F_status_set_error(F_parameter); diff --git a/level_2/fll_program/c/program.h b/level_2/fll_program/c/program.h index cc04b2d..2092a70 100644 --- a/level_2/fll_program/c/program.h +++ b/level_2/fll_program/c/program.h @@ -232,7 +232,7 @@ extern "C" { * @see fl_string_append() */ #ifndef _di_fll_program_parameter_additional_append_ - extern f_return_status fll_program_parameter_additional_append(const f_string_t *argv, const f_string_lengths_t additional, f_string_dynamics_t *destination); + extern f_return_status fll_program_parameter_additional_append(const f_string_t *argv, const f_array_lengths_t additional, f_string_dynamics_t *destination); #endif // _di_fll_program_parameter_additional_append_ /** @@ -262,7 +262,7 @@ extern "C" { * @see fl_string_mash() */ #ifndef _di_fll_program_parameter_additional_mash_ - extern f_return_status fll_program_parameter_additional_mash(const f_string_t glue, const f_string_length_t glue_length, const f_string_t *argv, const f_string_lengths_t additional, f_string_dynamic_t *destination); + extern f_return_status fll_program_parameter_additional_mash(const f_string_t glue, const f_string_length_t glue_length, const f_string_t *argv, const f_array_lengths_t additional, f_string_dynamic_t *destination); #endif // _di_fll_program_parameter_additional_mash_ /** @@ -289,7 +289,7 @@ extern "C" { * @see fl_string_rip() */ #ifndef _di_fll_program_parameter_additional_rip_ - extern f_return_status fll_program_parameter_additional_rip(const f_string_t *argv, const f_string_lengths_t additional, f_string_dynamics_t *destination); + extern f_return_status fll_program_parameter_additional_rip(const f_string_t *argv, const f_array_lengths_t additional, f_string_dynamics_t *destination); #endif // _di_fll_program_parameter_additional_rip_ /** @@ -323,7 +323,7 @@ extern "C" { * @see fl_string_rip() */ #ifndef _di_fll_program_parameter_additional_rip_mash_ - extern f_return_status fll_program_parameter_additional_rip_mash(const f_string_t glue, const f_string_length_t glue_length, const f_string_t *argv, const f_string_lengths_t additional, f_string_dynamic_t *destination); + extern f_return_status fll_program_parameter_additional_rip_mash(const f_string_t glue, const f_string_length_t glue_length, const f_string_t *argv, const f_array_lengths_t additional, f_string_dynamic_t *destination); #endif // _di_fll_program_parameter_additional_rip_mash_ #ifdef __cplusplus diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 8f4ed28..ffb6cb8 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -623,7 +623,7 @@ extern "C" { return F_status_set_error(F_parameter); } else if (data->parameters[parameters_id[i]].result == f_console_result_additional) { - if (data->parameters[parameters_id[i]].total > 1) { + if (data->parameters[parameters_id[i]].locations.used > 1) { fake_print_error_parameter_too_many(*data, parameters_name[i]); return F_status_set_error(F_parameter); }