]> Kevux Git Server - fll/commitdiff
Bugfix: Support for passing a fakefile Section incorrectly fails.
authorKevin Day <thekevinday@gmail.com>
Fri, 6 Jan 2023 03:57:27 +0000 (21:57 -0600)
committerKevin Day <thekevinday@gmail.com>
Fri, 6 Jan 2023 03:57:27 +0000 (21:57 -0600)
The commit 25671e39d0a275b4a14b1db6612ae46d497c38c7 added a loop around the code.
I forget to handle the return status and break out of the loop appropriately.

Move the variable declaration outside of the loop to avoid re-declaring it inside.

An error or a child signal should cause the loop to terminate.

When the string comparison is matched, do not continue processing the inner loop.

level_3/fake/c/private-make-operate.c

index dd21b4a69a1db9092989556a8aaca0fe9b33247f..f5aab14167163d98393e3b629e104e8ab2e7a75f 100644 (file)
@@ -175,6 +175,8 @@ extern "C" {
         }
       }
       else {
+        int result = 0;
+
         for (i = 0; i < data->main->parameters.remaining.used; ++i) {
 
           index = data->main->parameters.remaining.array[i];
@@ -185,30 +187,36 @@ extern "C" {
 
             if (fl_string_dynamic_partial_compare(data->main->parameters.arguments.array[index], data_make.buffer, range, data_make.fakefile.array[j].name) == F_equal_to) {
               {
-                const int result = fake_make_operate_section(&data_make, j, &section_stack, &status);
+                int result = fake_make_operate_section(&data_make, j, &section_stack, &status);
 
                 if (status == F_child) {
                   data->main->child = result;
+
+                  break;
                 }
               }
 
-              if (status != F_child) {
-                const f_status_t status_path = f_path_change_at(data_make.path.top.id);
+              const f_status_t status_path = f_path_change_at(data_make.path.top.id);
 
-                if (F_status_is_error(status_path) && data->main->warning.verbosity >= f_console_verbosity_verbose_e) {
-                  flockfile(data->main->warning.to.stream);
+              if (F_status_is_error(status_path) && data->main->warning.verbosity >= f_console_verbosity_verbose_e) {
+                flockfile(data->main->warning.to.stream);
 
-                  fl_print_format("%r%[%QFailed change back to orignal path '%]", data->main->warning.to.stream, f_string_eol_s, data->main->warning.context, data->main->warning.prefix, data->main->warning.context);
-                  fl_print_format("%[%Q%]", data->main->warning.to.stream, data->main->warning.notable, data_make.path.stack.array[0], data->main->warning.notable);
-                  fl_print_format("%[', status code =%] ", data->main->warning.to.stream, data->main->warning.context, data->main->warning.context);
-                  fl_print_format("%[%ui%]", data->main->warning.to.stream, data->main->warning.notable, F_status_set_fine(status_path), data->main->warning.notable);
-                  fl_print_format("%['.%]%r", data->main->warning.to.stream, data->main->warning.context, data->main->warning.context, f_string_eol_s);
+                fl_print_format("%r%[%QFailed change back to orignal path '%]", data->main->warning.to.stream, f_string_eol_s, data->main->warning.context, data->main->warning.prefix, data->main->warning.context);
+                fl_print_format("%[%Q%]", data->main->warning.to.stream, data->main->warning.notable, data_make.path.stack.array[0], data->main->warning.notable);
+                fl_print_format("%[', status code =%] ", data->main->warning.to.stream, data->main->warning.context, data->main->warning.context);
+                fl_print_format("%[%ui%]", data->main->warning.to.stream, data->main->warning.notable, F_status_set_fine(status_path), data->main->warning.notable);
+                fl_print_format("%['.%]%r", data->main->warning.to.stream, data->main->warning.context, data->main->warning.context, f_string_eol_s);
 
-                  funlockfile(data->main->warning.to.stream);
-                }
+                funlockfile(data->main->warning.to.stream);
               }
+
+              break;
             }
+
+            if (F_status_is_error(status)) break;
           } // for
+
+          if (status == F_child || F_status_is_error(status)) break;
         } // for
       }
     }