]> Kevux Git Server - fll/commitdiff
Cleanup: Use a pointer to make the code more readable in fake_build_load_setting_proc...
authorKevin Day <Kevin@kevux.org>
Thu, 1 Aug 2024 03:07:08 +0000 (22:07 -0500)
committerKevin Day <Kevin@kevux.org>
Thu, 1 Aug 2024 03:08:36 +0000 (22:08 -0500)
level_3/fake/c/main/build/load.c

index 127c3b61de865dae1ad69bfd775fe9d8c775d3ed..22234e4dbdfb771d7884cd4fc05683e286ed8915 100644 (file)
@@ -1125,6 +1125,8 @@ extern "C" {
         5,                                           // version_target
       };
 
+      f_string_dynamic_t *single_source = 0;
+
       for (i = 0; i < 42; ++i) {
 
         // Assign the default for literal and path types.
@@ -1142,11 +1144,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 (f_compare_dynamic_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_common_setting_bool_yes_s) == F_equal_to) {
+          if (f_compare_dynamic_trim(*single_source, fake_common_setting_bool_yes_s) == F_equal_to) {
             *settings_single_bool[i] = F_true;
           }
-          else if (f_compare_dynamic_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_common_setting_bool_no_s) == F_equal_to) {
+          else if (f_compare_dynamic_trim(*single_source, fake_common_setting_bool_no_s) == F_equal_to) {
             *settings_single_bool[i] = F_false;
           }
           else {
@@ -1156,13 +1160,13 @@ extern "C" {
           }
         }
         else if (settings_single_type[i] == 4) {
-          if (f_compare_dynamic_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_build_language_bash_s) == F_equal_to) {
+          if (f_compare_dynamic_trim(*single_source, fake_build_language_bash_s) == F_equal_to) {
             *settings_single_language[i] = fake_build_language_bash_e;
           }
-          else if (f_compare_dynamic_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_build_language_c_s) == F_equal_to) {
+          else if (f_compare_dynamic_trim(*single_source, fake_build_language_c_s) == F_equal_to) {
             *settings_single_language[i] = fake_build_language_c_e;
           }
-          else if (f_compare_dynamic_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_build_language_cpp_s) == F_equal_to) {
+          else if (f_compare_dynamic_trim(*single_source, fake_build_language_cpp_s) == F_equal_to) {
             *settings_single_language[i] = fake_build_language_cpp_e;
           }
           else {
@@ -1172,16 +1176,16 @@ extern "C" {
           }
         }
         else if (settings_single_type[i] == 5) {
-          if (f_compare_dynamic_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_build_version_major_s) == F_equal_to) {
+          if (f_compare_dynamic_trim(*single_source, fake_build_version_major_s) == F_equal_to) {
             *settings_single_version[i] = fake_build_version_major_e;
           }
-          else if (f_compare_dynamic_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_build_version_minor_s) == F_equal_to) {
+          else if (f_compare_dynamic_trim(*single_source, fake_build_version_minor_s) == F_equal_to) {
             *settings_single_version[i] = fake_build_version_minor_e;
           }
-          else if (f_compare_dynamic_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_build_version_micro_s) == F_equal_to) {
+          else if (f_compare_dynamic_trim(*single_source, fake_build_version_micro_s) == F_equal_to) {
             *settings_single_version[i] = fake_build_version_micro_e;
           }
-          else if (f_compare_dynamic_trim(settings_single_source[i]->array[settings_single_source[i]->used - 1], fake_build_version_nano_s) == F_equal_to) {
+          else if (f_compare_dynamic_trim(*single_source, fake_build_version_nano_s) == F_equal_to) {
             *settings_single_version[i] = fake_build_version_nano_e;
           }
           else {
@@ -1196,7 +1200,7 @@ extern "C" {
           settings_single_destination[i]->used = 0;
 
           if (settings_single_type[i] == 2) {
-            main->setting.state.status = f_path_directory_cleanup(settings_single_source[i]->array[settings_single_source[i]->used - 1], settings_single_destination[i]);
+            main->setting.state.status = f_path_directory_cleanup(*single_source, settings_single_destination[i]);
 
             if (F_status_is_error(main->setting.state.status)) {
               fake_print_error(&main->program.error, macro_fake_f(f_path_directory_cleanup));
@@ -1205,7 +1209,7 @@ extern "C" {
             }
           }
           else {
-            main->setting.state.status = f_memory_array_increase_by(settings_single_source[i]->array[settings_single_source[i]->used - 1].used + 1, sizeof(f_char_t), (void **) &settings_single_destination[i]->string, &settings_single_destination[i]->used, &settings_single_destination[i]->size);
+            main->setting.state.status = f_memory_array_increase_by(single_source->used + 1, sizeof(f_char_t), (void **) &settings_single_destination[i]->string, &settings_single_destination[i]->used, &settings_single_destination[i]->size);
 
             if (F_status_is_error(main->setting.state.status)) {
               fake_print_error(&main->program.error, macro_fake_f(f_memory_array_increase_by));
@@ -1217,13 +1221,13 @@ extern "C" {
             if (settings_single_type[i] == 6) {
               main->setting.state.status = F_okay;
 
-              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]) {
                   main->setting.state.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
 
@@ -1232,7 +1236,7 @@ extern "C" {
               }
             }
 
-            main->setting.state.status = f_string_dynamic_append_nulless(settings_single_source[i]->array[settings_single_source[i]->used - 1], settings_single_destination[i]);
+            main->setting.state.status = f_string_dynamic_append_nulless(*single_source, settings_single_destination[i]);
 
             if (F_status_is_error(main->setting.state.status)) {
               fake_print_error(&main->program.error, macro_fake_f(f_string_dynamic_append_nulless));