From db357ebedb451a277448b831ff5c17399e34579b Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 31 Jul 2024 22:06:49 -0500 Subject: [PATCH] Cleanup: Use a pointer to make the code more readable in fake_build_load_setting_process(). --- level_3/fake/c/private-build-load.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/level_3/fake/c/private-build-load.c b/level_3/fake/c/private-build-load.c index 01dbbbb..2cd4484 100644 --- a/level_3/fake/c/private-build-load.c +++ b/level_3/fake/c/private-build-load.c @@ -1191,6 +1191,7 @@ extern "C" { }; f_array_length_t j = 0; + f_string_dynamic_t *single_source = 0; for (f_array_length_t i = 0; i < 42; ++i) { @@ -1209,11 +1210,13 @@ extern "C" { if (!settings_single_source[i]->used) continue; + single_source = &settings_single_source[i]->array[settings_single_source[i]->used - 1]; + if (settings_single_type[i] == 1) { - if (fl_string_dynamic_compare_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_common_setting_bool_yes_s) == F_equal_to) { + if (fl_string_dynamic_compare_trim(*single_source, fake_common_setting_bool_yes_s) == F_equal_to) { *settings_single_bool[i] = F_true; } - else if (fl_string_dynamic_compare_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_common_setting_bool_no_s) == F_equal_to) { + else if (fl_string_dynamic_compare_trim(*single_source, fake_common_setting_bool_no_s) == F_equal_to) { *settings_single_bool[i] = F_false; } else { @@ -1239,13 +1242,13 @@ extern "C" { } } else if (settings_single_type[i] == 4) { - if (fl_string_dynamic_compare_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_build_language_bash_s) == F_equal_to) { + if (fl_string_dynamic_compare_trim(*single_source, fake_build_language_bash_s) == F_equal_to) { *settings_single_language[i] = fake_build_language_type_bash_e; } - else if (fl_string_dynamic_compare_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_build_language_c_s) == F_equal_to) { + else if (fl_string_dynamic_compare_trim(*single_source, fake_build_language_c_s) == F_equal_to) { *settings_single_language[i] = fake_build_language_type_c_e; } - else if (fl_string_dynamic_compare_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_build_language_cpp_s) == F_equal_to) { + else if (fl_string_dynamic_compare_trim(*single_source, fake_build_language_cpp_s) == F_equal_to) { *settings_single_language[i] = fake_build_language_type_cpp_e; } else { @@ -1273,16 +1276,16 @@ extern "C" { } } else if (settings_single_type[i] == 5) { - if (fl_string_dynamic_compare_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_build_version_major_s) == F_equal_to) { + if (fl_string_dynamic_compare_trim(*single_source, fake_build_version_major_s) == F_equal_to) { *settings_single_version[i] = fake_build_version_type_major_e; } - else if (fl_string_dynamic_compare_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_build_version_minor_s) == F_equal_to) { + else if (fl_string_dynamic_compare_trim(*single_source, fake_build_version_minor_s) == F_equal_to) { *settings_single_version[i] = fake_build_version_type_minor_e; } - else if (fl_string_dynamic_compare_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_build_version_micro_s) == F_equal_to) { + else if (fl_string_dynamic_compare_trim(*single_source, fake_build_version_micro_s) == F_equal_to) { *settings_single_version[i] = fake_build_version_type_micro_e; } - else if (fl_string_dynamic_compare_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_build_version_nano_s) == F_equal_to) { + else if (fl_string_dynamic_compare_trim(*single_source, fake_build_version_nano_s) == F_equal_to) { *settings_single_version[i] = fake_build_version_type_nano_e; } else { @@ -1317,7 +1320,7 @@ extern "C" { settings_single_destination[i]->used = 0; if (settings_single_type[i] == 2) { - *status = f_path_directory_cleanup(settings_single_source[i]->array[settings_single_source[i]->used - 1], settings_single_destination[i]); + *status = f_path_directory_cleanup(*single_source, settings_single_destination[i]); if (F_status_is_error(*status)) { fll_error_print(data->main->error, F_status_set_fine(*status), "f_path_directory_cleanup", F_true); @@ -1326,7 +1329,7 @@ extern "C" { } } else { - *status = f_string_dynamic_increase_by(settings_single_source[i]->array[settings_single_source[i]->used - 1].used + 1, settings_single_destination[i]); + *status = f_string_dynamic_increase_by(single_source->used + 1, settings_single_destination[i]); if (F_status_is_error(*status)) { fll_error_print(data->main->error, F_status_set_fine(*status), "f_string_dynamic_increase_by", F_true); @@ -1338,13 +1341,13 @@ extern "C" { if (settings_single_type[i] == 6) { *status = F_none; - for (j = 0; j < settings_single_source[i]->array[settings_single_source[i]->used - 1].used; ++j) { + for (j = 0; j < single_source->used; ++j) { - if (settings_single_source[i]->array[settings_single_source[i]->used - 1].string[j] == f_string_ascii_slash_forward_s.string[0] || settings_single_source[i]->array[settings_single_source[i]->used - 1].string[j] == f_string_ascii_slash_backward_s.string[0]) { + if (single_source->string[j] == f_string_ascii_slash_forward_s.string[0] || single_source->string[j] == f_string_ascii_slash_backward_s.string[0]) { *status = F_warning; // Prevent the slash from being copied. - settings_single_source[i]->array[settings_single_source[i]->used - 1].string[j] = 0; + single_source->string[j] = 0; } } // for @@ -1363,7 +1366,7 @@ extern "C" { } } - *status = f_string_dynamic_append_nulless(settings_single_source[i]->array[settings_single_source[i]->used - 1], settings_single_destination[i]); + *status = f_string_dynamic_append_nulless(*single_source, settings_single_destination[i]); if (F_status_is_error(*status)) { fll_error_print(data->main->error, F_status_set_fine(*status), "f_string_dynamic_append_nulless", F_true); -- 1.8.3.1