From: Kevin Day Date: Sun, 25 Jun 2023 21:12:09 +0000 (-0500) Subject: Bugfix: FSS Identify should process all --name parameters and not the last. X-Git-Tag: 0.6.6~10 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=07d7e611a4cfaf4b2617f6b5798188292775b3a5;p=fll Bugfix: FSS Identify should process all --name parameters and not the last. Back port a bug fix from the 0.7.x versions to make sure --name behaves more naturally. All --name parameters should be checked for. --- diff --git a/level_3/fss_identify/c/fss_identify.c b/level_3/fss_identify/c/fss_identify.c index e144229..e72f068 100644 --- a/level_3/fss_identify/c/fss_identify.c +++ b/level_3/fss_identify/c/fss_identify.c @@ -242,48 +242,70 @@ extern "C" { status = F_status_set_error(F_parameter); } else if (main->parameters.array[fss_identify_parameter_name_e].result == f_console_result_additional_e) { - const f_array_length_t index = main->parameters.array[fss_identify_parameter_name_e].values.array[main->parameters.array[fss_identify_parameter_name_e].values.used - 1]; - const f_array_length_t length = data.argv[index].used; - const f_string_range_t range = macro_f_string_range_t_initialize2(length); + data.names.used = 0; - if (length == 0) { - flockfile(main->error.to.stream); + status = f_string_dynamics_increase_by(main->parameters.array[fss_identify_parameter_name_e].values.used, &data.names); - fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_identify_long_name_s, main->error.notable); - fl_print_format("%[' does not allow zero length strings.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); - - funlockfile(main->error.to.stream); - - status = F_status_set_error(F_parameter); + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamics_increase_by", F_true); } else { - status = f_string_dynamic_resize(length, &data.name); + f_array_length_t index = 0; + f_array_length_t i = 0; + f_array_length_t j = 0; - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_utf_is_word", F_true); - } - } + for (; i < main->parameters.array[fss_identify_parameter_name_e].values.used; ++i) { - if (F_status_is_error_not(status)) { + index = main->parameters.array[fss_identify_parameter_name_e].values.array[i]; - for (f_array_length_t i = range.start; i <= range.stop; ++i) { + if (data.argv[index].used) { + data.names.array[data.names.used].used = 0; - status = f_utf_is_word_dash(data.argv[index].string + i, length, F_true); + status = f_string_dynamic_append_nulless(data.argv[index], &data.names.array[data.names.used]); - if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_utf_is_word_dash", F_true); + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true); - break; + break; + } + + for (j = 0; j < data.names.array[data.names.used].used; ++j) { + + status = f_utf_is_word_dash(data.argv[index].string + j, data.argv[index].used, F_true); + + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_utf_is_word_dash", F_true); + + break; + } + + if (status == F_false) { + flockfile(main->error.to.stream); + + fl_print_format("%r%[%QThe value '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%Q%]", main->error.to.stream, main->error.notable, data.argv[index], main->error.notable); + fl_print_format("%[' for the parameter '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_identify_long_name_s, main->error.notable); + fl_print_format("%[' may only contain word characters or the dash (minus) character.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); + + funlockfile(main->error.to.stream); + + status = F_status_set_error(F_parameter); + + break; + } + } // for + + if (F_status_is_error(status)) break; + + ++data.names.used; } - else if (status == F_false) { + else { flockfile(main->error.to.stream); - fl_print_format("%r%[%QThe value '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%Q%]", main->error.to.stream, main->error.notable, data.argv[index], main->error.notable); - fl_print_format("%[' for the parameter '%]", main->error.to.stream, main->error.context, main->error.context); + fl_print_format("%r%[%QThe parameter '%]", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context); fl_print_format("%[%r%r%]", main->error.to.stream, main->error.notable, f_console_symbol_long_enable_s, fss_identify_long_name_s, main->error.notable); - fl_print_format("%[' may only contain word characters or the dash (minus) character.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); + fl_print_format("%[' does not allow zero length strings.%]%r", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s); funlockfile(main->error.to.stream); @@ -291,8 +313,6 @@ extern "C" { break; } - - data.name.string[data.name.used++] = data.argv[index].string[i]; } // for } } diff --git a/level_3/fss_identify/c/private-common.c b/level_3/fss_identify/c/private-common.c index 3d7aba0..887ed1c 100644 --- a/level_3/fss_identify/c/private-common.c +++ b/level_3/fss_identify/c/private-common.c @@ -10,7 +10,7 @@ extern "C" { if (!data) return; - f_string_dynamic_resize(0, &data->name); + f_string_dynamics_resize(0, &data->names); } #endif // _di_fss_identify_data_delete_ diff --git a/level_3/fss_identify/c/private-common.h b/level_3/fss_identify/c/private-common.h index 9de2607..ac22a47 100644 --- a/level_3/fss_identify/c/private-common.h +++ b/level_3/fss_identify/c/private-common.h @@ -18,7 +18,7 @@ extern "C" { * argv: The argument structure in the progam data parameters for simplifying syntax. * current: The current position within the ids, used to determine when the line is matched. * line: The line number to select. - * name: The name to select. + * names: The names to select. * total: The total ids across all files. */ #ifndef _di_fss_identify_data_t_ @@ -29,7 +29,7 @@ extern "C" { f_string_static_t *argv; - f_string_dynamic_t name; + f_string_dynamics_t names; } fss_identify_data_t; #define fss_identify_data_t_initialize \ @@ -38,7 +38,7 @@ extern "C" { 0, \ 0, \ 0, \ - f_string_dynamic_t_initialize, \ + f_string_dynamics_t_initialize, \ } #endif // _di_fss_identify_data_t_ diff --git a/level_3/fss_identify/c/private-identify.c b/level_3/fss_identify/c/private-identify.c index 0441ddb..792811c 100644 --- a/level_3/fss_identify/c/private-identify.c +++ b/level_3/fss_identify/c/private-identify.c @@ -82,21 +82,26 @@ extern "C" { } // 0 = is name, 1 = is type, 2 = is full. - uint8_t mode = 1; + uint8_t modes[data->names.used]; f_array_length_t i = 0; - if (data->name.used) { - for (; i < data->name.used; ++i) { + if (data->names.used) { + for (f_array_length_t j = 0; i < data->names.used; ++i) { - if (data->name.string[i] == f_string_ascii_minus_s.string[0]) { - mode = 2; + modes[i] = 1; - break; - } + for (j = 0; j < data->names.array[i].used; ++j) { - if (f_utf_is_digit(data->name.string + i, data->name.used - i, 0) != F_true) { - mode = 0; - } + if (data->names.array[i].string[j] == f_string_ascii_minus_s.string[0]) { + modes[i] = 2; + + break; + } + + if (f_utf_is_digit(data->names.array[i].string + j, data->names.array[i].used - j, 0) != F_true) { + modes[i] = 0; + } + } // for } // for } @@ -104,8 +109,8 @@ extern "C" { for (i = 0; i < ids.used; ++i, ++data->current) { if (data->current == data->line) { - if (data->name.used) { - if (fss_identify_process_name_compare(data, ids.array[i], mode) != F_equal_to) continue; + if (data->names.used) { + if (fss_identify_process_name_compare(data, ids.array[i], modes) != F_equal_to) continue; } if (main->parameters.array[fss_identify_parameter_total_e].result == f_console_result_found_e) { @@ -122,11 +127,11 @@ extern "C" { } // for } else if (main->parameters.array[fss_identify_parameter_total_e].result == f_console_result_found_e) { - if (data->name.used) { + if (data->names.used) { for (i = 0; i < ids.used; ++i, ++data->current) { - if (fss_identify_process_name_compare(data, ids.array[i], mode) == F_equal_to) { + if (fss_identify_process_name_compare(data, ids.array[i], modes) == F_equal_to) { ++data->total; } } // for @@ -138,8 +143,8 @@ extern "C" { else if (status == F_found || status == F_maybe) { for (i = 0; i < ids.used; ++i) { - if (data->name.used) { - if (fss_identify_process_name_compare(data, ids.array[i], mode) != F_equal_to) continue; + if (data->names.used) { + if (fss_identify_process_name_compare(data, ids.array[i], modes) != F_equal_to) continue; } fss_identify_print(main, ids.array[i]); @@ -153,43 +158,61 @@ extern "C" { #endif // _di_fss_identify_process_ #ifndef _di_fss_identify_process_name_compare_ - f_status_t fss_identify_process_name_compare(fss_identify_data_t * const data, const f_fll_id_t id, const uint8_t mode) { + f_status_t fss_identify_process_name_compare(fss_identify_data_t * const data, const f_fll_id_t id, const uint8_t modes[]) { - if (mode) { - f_array_length_t number = 0; - f_string_range_t range = macro_f_string_range_t_initialize2(data->name.used); + f_status_t status = F_none; + f_array_length_t i = 0; + f_array_length_t j = 0; + f_array_length_t number = 0; + f_string_range_t range = f_string_range_t_initialize; - for (f_array_length_t i = 0; i < data->name.used; ++i) { + for (status = F_equal_to_not; i < data->names.used && status == F_equal_to_not; ++i) { - if (data->name.string[i] == f_string_ascii_minus_s.string[0] && i + 1 < data->name.used) { - range.start = i + 1; + if (modes[i]) { + if (data->names.array[i].used) { + range.start = 0; + range.stop = data->names.array[i].used - 1; + } + else { + range.start = 1; + range.stop = 0; + } - break; + for (j = 0; j < data->names.array[i].used; ++j) { + + if (data->names.array[i].string[j] == f_string_ascii_minus_s.string[0] && j + 1 < data->names.array[i].used) { + range.start = j + 1; + + break; + } + } // for + + { + status = fl_conversion_dynamic_partial_to_unsigned(fl_conversion_data_base_16_c, data->names.array[i], range, &number); + if (F_status_is_error(status)) return F_equal_to_not; } - } // for - { - const f_status_t status = fl_conversion_dynamic_partial_to_unsigned(fl_conversion_data_base_16_c, data->name, range, &number); - if (F_status_is_error(status)) return status; - } + if (id.type != number) { + status = F_equal_to_not; - if (id.type != number) { - return F_equal_to_not; - } + continue; + } - if (mode == 1) { - return F_equal_to; - } + if (modes[i] == 1) return F_equal_to; - if (range.start) { - range.stop = range.start - 2; - range.start = 0; - } + if (range.start) { + range.stop = range.start - 2; + range.start = 0; + } - return fl_string_dynamic_partial_compare_string((const f_string_t) id.name, data->name, id.used, range); - } + status = fl_string_dynamic_partial_compare_string((const f_string_t) id.name, data->names.array[i], id.used, range); + } + else { + status = fl_string_dynamic_compare_string((const f_string_t) id.name, data->names.array[i], id.used); + } + } // for - return fl_string_dynamic_compare_string((const f_string_t) id.name, data->name, id.used); + return status == F_equal_to ? F_equal_to : F_equal_to_not; } #endif // _di_fss_identify_process_name_compare_ diff --git a/level_3/fss_identify/c/private-identify.h b/level_3/fss_identify/c/private-identify.h index 231fd76..7a3af38 100644 --- a/level_3/fss_identify/c/private-identify.h +++ b/level_3/fss_identify/c/private-identify.h @@ -74,11 +74,13 @@ extern "C" { * @param id * The FLL ID to compare against. * @param mode - * A mode specifying how to compare. + * An array of modes specifying how to compare. * 0 = Compare against just the ID Name (such as "fss" in "fss-0001"). * 1 = Compare against just the ID Type (such as "0001" in "fss-0001"). * 2 = Compare against the full name (such as "fss-0001" in "fss-0001"). * + * The length of the array must exactly match data.names.used. + * * @return * F_equal_to on match. * F_equal_to_not on no match. @@ -92,7 +94,7 @@ extern "C" { * @see fl_string_dynamic_partial_compare_string() */ #ifndef _di_fss_identify_process_name_compare_ - extern f_status_t fss_identify_process_name_compare(fss_identify_data_t * const data, const f_fll_id_t id, const uint8_t mode) F_attribute_visibility_internal_d; + extern f_status_t fss_identify_process_name_compare(fss_identify_data_t * const data, const f_fll_id_t id, const uint8_t modes[]) F_attribute_visibility_internal_d; #endif // _di_fss_identify_process_name_compare_ #ifdef __cplusplus