]> Kevux Git Server - fll/commitdiff
Bugfix: Condition blocks are still being processed when they should be skipped.
authorKevin Day <thekevinday@gmail.com>
Sat, 9 Jul 2022 04:58:16 +0000 (23:58 -0500)
committerKevin Day <thekevinday@gmail.com>
Sat, 9 Jul 2022 05:27:29 +0000 (00:27 -0500)
Re-design the block code to simplify the logic and make the code more readable.
This is only a partial re-design.
I did not perform an extensive review.
I am considering writing some runtime/program tests to better catch problems and regressions.

level_3/fake/c/private-common.h
level_3/fake/c/private-make-operate.c
level_3/fake/c/private-make-operate.h
level_3/fake/c/private-make-operate_block.c [new file with mode: 0644]
level_3/fake/c/private-make-operate_block.h [new file with mode: 0644]
level_3/fake/c/private-make-operate_process.c
level_3/fake/c/private-make-operate_process.h
level_3/fake/c/private-make-operate_validate.c
level_3/fake/data/build/settings

index d90bb03900c976d4c4ec1bd3c30853dfc0ecf39d..4b6de683355504ac85d6fc5232386a3a6b8492ef 100644 (file)
@@ -1164,7 +1164,8 @@ extern "C" {
   extern const f_string_static_t fake_make_operation_touch_s;
 
   enum {
-    fake_make_operation_type_and_e = 1,
+    fake_make_operation_type_none_e = 0,
+    fake_make_operation_type_and_e,
     fake_make_operation_type_break_e,
     fake_make_operation_type_build_e,
     fake_make_operation_type_clean_e,
@@ -1580,6 +1581,8 @@ extern "C" {
  * condition_result:   The result of the currently processed condition.
  * operation:          The current operation type.
  * operation_previous: The previous operation type.
+ * success:            Current state is considered success when F_true and failure when F_false.
+ * success_block:      Current block state is considered success when F_true and failure when F_false.
  */
 #ifndef _di_fake_state_process_t_
   typedef struct {
@@ -1589,6 +1592,8 @@ extern "C" {
     uint8_t condition_result;
     uint8_t operation;
     uint8_t operation_previous;
+    uint8_t success;
+    uint8_t success_block;
   } fake_state_process_t;
 
   #define fake_state_process_t_initialize { \
@@ -1598,6 +1603,8 @@ extern "C" {
     0, \
     0, \
     0, \
+    F_true, \
+    F_true, \
   }
 #endif // _di_fake_state_process_t_
 
@@ -1606,20 +1613,16 @@ extern "C" {
  *
  * fake_condition_result_*:
  *   - none:    No if-condition is set.
- *   - if:      An if-condition is set and in use.
- *   - if_skip: An else-if-condition that is to be skipped.
- *   - next:    An if-condition completed, process the "else", if found.
- *   - skip:    An if-condition completed, skip the "else", if found.
- *   - else:    An else-condition is set and in use.
+ *   - operate: The condition passed or perform condition, process the next operation or the condition.
+ *   - skip:    The condition failed, skip the next operation.
+ *   - done:    After the condition passed, the next operation was performed, all future operations within block are skipped.
  */
 #ifndef _di_fake_state_process_block_
   enum {
     fake_state_process_block_none_e = 0,
-    fake_state_process_block_if_e,
-    fake_state_process_block_if_skip_e,
-    fake_state_process_block_next_e,
+    fake_state_process_block_operate_e,
     fake_state_process_block_skip_e,
-    fake_state_process_block_else_e,
+    fake_state_process_block_done_e,
   };
 #endif // _di_fake_state_process_block_
 
index e214dc02143d90b22ec00dd5e3eaf3aa2b8101d3..10e6d735b57c1baafa83557837f968357522b27c 100644 (file)
@@ -7,6 +7,7 @@
 #include "private-make-load_parameters.h"
 #include "private-make-load_fakefile.h"
 #include "private-make-operate.h"
+#include "private-make-operate_block.h"
 #include "private-make-operate_process.h"
 #include "private-make-operate_process_type.h"
 #include "private-make-operate_validate.h"
@@ -144,7 +145,7 @@ extern "C" {
 #endif // _di_fake_make_operate_
 
 #ifndef _di_fake_make_operate_expand_
-  void fake_make_operate_expand(fake_make_data_t * const data_make, const f_string_range_t section_name, const f_array_length_t operation, const f_fss_content_t content, const f_fss_quotes_t quotes, f_string_dynamics_t * const arguments, f_status_t * const status) {
+  void fake_make_operate_expand(fake_make_data_t * const data_make, const f_string_range_t section_name, const f_fss_content_t content, const f_fss_quotes_t quotes, f_string_dynamics_t * const arguments, f_status_t * const status) {
 
     if (F_status_is_error(*status)) return;
     if (!content.used) return;
@@ -1084,12 +1085,8 @@ extern "C" {
     };
 
     fake_state_process_t state_process = fake_state_process_t_initialize;
-    bool success = F_true;
-    bool success_block = F_true;
-    int result;
-
     f_string_dynamics_t arguments = f_string_dynamics_t_initialize;
-
+    int result;
     f_array_length_t i = 0;
     f_array_length_t j = 0;
 
@@ -1139,32 +1136,17 @@ extern "C" {
         }
       }
 
-      if (F_status_is_error_not(*status)) {
-        fake_make_operate_expand(data_make, section->name, state_process.operation, section->contents.array[i], section->quotess.array[i], &arguments, status);
-      }
-
-      if (F_status_is_error_not(*status)) {
-        fake_make_operate_validate(data_make, section->name, arguments, &state_process, section_stack, status);
-      }
+      fake_make_operate_expand(data_make, section->name, section->contents.array[i], section->quotess.array[i], &arguments, status);
 
-      // If next or skip is designated and the next operation is not an "else", then this is no longer in the condition block.
-      if (state_process.block == fake_state_process_block_next_e || state_process.block == fake_state_process_block_skip_e) {
-        if (state_process.operation != fake_make_operation_type_else_e) {
-          state_process.block = 0;
-          state_process.block_result = 0;
+      fake_make_operate_block_prepare(&state_process);
 
-          // When the block ends and the block success is false, pass the failure to the success variable so that "failure" conditions can catch this.
-          if (success && !success_block) {
-            success = F_false;
-          }
-
-          success_block = F_true;
-        }
+      if (state_process.block != fake_state_process_block_done_e && state_process.block != fake_state_process_block_skip_e) {
+        fake_make_operate_validate(data_make, section->name, arguments, &state_process, section_stack, status);
       }
 
       if (F_status_is_error(*status)) {
         if (state_process.block || state_process.operation == fake_make_operation_type_if_e || state_process.operation == fake_make_operation_type_and_e || state_process.operation == fake_make_operation_type_or_e) {
-          success_block = F_false;
+          state_process.success_block = F_false;
 
           // Setting error result informs the post-process that the operate process is not run due to an error during the pre-process.
           if (state_process.operation == fake_make_operation_type_if_e || state_process.operation == fake_make_operation_type_and_e || state_process.operation == fake_make_operation_type_or_e || state_process.operation == fake_make_operation_type_else_e) {
@@ -1173,121 +1155,23 @@ extern "C" {
         }
       }
       else {
-        result = fake_make_operate_process(data_make, section->name, arguments, success, &state_process, section_stack, status);
-
-        if (*status == F_child) {
-          f_string_dynamics_resize(0, &arguments);
-
-          return result;
-        }
-
-        if (state_process.block && F_status_is_error(*status)) {
-          state_process.block_result = fake_condition_result_error_e;
-          success_block = F_false;
-        }
-      }
-
-      // When done processing an operation within an if-condition or an else-condition, update the process state.
-      if (state_process.block) {
-        if (state_process.block == fake_state_process_block_if_e || state_process.block == fake_state_process_block_if_skip_e) {
-          if (state_process.operation == fake_make_operation_type_if_e || state_process.operation == fake_make_operation_type_else_e) {
-            state_process.block = 0;
-            state_process.block_result = 0;
-
-            // When the block ends and the block success is false, pass the failure to the success variable so that "failure" conditions can catch this.
-            if (success && !success_block) {
-              success = F_false;
-            }
-
-            success_block = F_true;
-          }
-          else if (state_process.operation == fake_make_operation_type_and_e || state_process.operation == fake_make_operation_type_or_e) {
-            if (state_process.block_result == fake_condition_result_error_e) {
-              state_process.block_result = fake_condition_result_false_e;
-              success_block = F_false;
-            }
-            else {
-              state_process.block_result = state_process.condition_result;
-            }
-          }
-          else {
-            if (state_process.block == fake_state_process_block_if_skip_e || state_process.block == fake_state_process_block_skip_e) {
-              state_process.block = fake_state_process_block_skip_e;
-              state_process.block_result = fake_condition_result_false_e;
-            }
-            else if (state_process.block_result == fake_condition_result_false_e || state_process.block_result == fake_condition_result_error_e) {
-              state_process.block = fake_state_process_block_next_e;
-              state_process.block_result = fake_condition_result_false_e;
+        if (!state_process.block || state_process.block == fake_state_process_block_operate_e) {
+          result = fake_make_operate_process(data_make, section->name, arguments, &state_process, section_stack, status);
 
-              if (state_process.block_result == fake_condition_result_error_e) {
-                success_block = F_false;
-              }
-            }
-            else {
-              state_process.block = fake_state_process_block_skip_e;
-            }
-          }
-        }
-        else if (state_process.block == fake_state_process_block_next_e || state_process.block == fake_state_process_block_skip_e) {
+          if (*status == F_child) {
+            f_string_dynamics_resize(0, &arguments);
 
-          // Anything other than an "else" operation should not make it here.
-          if (state_process.block == fake_state_process_block_next_e) {
-            state_process.block_result = fake_condition_result_true_e;
-          }
-          else {
-            state_process.block_result = fake_condition_result_false_e;
+            return result;
           }
-
-          state_process.block = fake_state_process_block_else_e;
         }
-        else if (state_process.block == fake_state_process_block_else_e) {
-
-          // An "else" followed by an "if" resets the state back to an "if".
-          if (state_process.operation == fake_make_operation_type_if_e) {
-            if (state_process.block_result == fake_condition_result_true_e) {
-              state_process.block = fake_state_process_block_if_e;
-              state_process.block_result = state_process.condition_result;
-            }
-            else {
-              state_process.block = fake_state_process_block_if_skip_e;
-              state_process.block_result = fake_condition_result_false_e;
-            }
-          }
-          else {
-            state_process.block = 0;
-            state_process.block_result = 0;
 
-            // When the block ends and the block success is false, pass the failure to the success variable so that "failure" conditions can catch this.
-            if (success && !success_block) {
-              success = F_false;
-            }
-
-            success_block = F_true;
-          }
-        }
-      }
-      else if (state_process.operation == fake_make_operation_type_if_e || state_process.operation == fake_make_operation_type_and_e || state_process.operation == fake_make_operation_type_or_e) {
-        if (state_process.block_result == fake_condition_result_error_e) {
-          state_process.block = fake_state_process_block_if_skip_e;
-          state_process.block_result = fake_condition_result_false_e;
-          success_block = F_false;
-        }
-        else {
-          state_process.block = fake_state_process_block_if_e;
-          state_process.block_result = state_process.condition_result;
-        }
-      }
-      else if (state_process.operation == fake_make_operation_type_else_e) {
-
-        // An else condition by itself is invalid and the operation associated with it should be skipped.
-        state_process.block = fake_state_process_block_else_e;
-        state_process.block_result = fake_condition_result_false_e;
+        fake_make_operate_block_postprocess(i == section->objects.used, &state_process, status);
       }
 
       if (F_status_set_fine(*status) == F_interrupt) break;
 
       if (F_status_is_error(*status)) {
-        success = F_false;
+        state_process.success = F_false;
 
         // Break acts identical to fail when at the top of the stack.
         if (F_status_set_fine(*status) == F_signal_abort && !section_stack->used) {
@@ -1320,13 +1204,13 @@ extern "C" {
         }
       }
       else if (*status == F_signal_abort) {
-        success = F_true;
+        state_process.success = F_true;
 
         // F_signal_abort is used by the break section operation.
         break;
       }
       else if (*status == F_signal_quit) {
-        success = F_true;
+        state_process.success = F_true;
 
         // F_signal_quit is used by the exit section operation.
         if (!section_stack->used) {
@@ -1340,10 +1224,10 @@ extern "C" {
         // When F_failure (without the error bit) is returned, an error occured but the exit mode is not set to exit.
         // Record the success state and set the status to F_none.
         *status = F_none;
-        success = F_false;
+        state_process.success = F_false;
       }
       else {
-        success = F_true;
+        state_process.success = F_true;
       }
     } // for
 
@@ -1353,20 +1237,26 @@ extern "C" {
       return 0;
     }
 
-    if (i == section->objects.used && F_status_is_error_not(*status) && (state_process.block == fake_state_process_block_if_e || state_process.block == fake_state_process_block_if_skip_e || state_process.block == fake_state_process_block_else_e)) {
+    if (i == section->objects.used && F_status_is_error_not(*status) && (state_process.operation == fake_make_operation_type_and_e || state_process.operation == fake_make_operation_type_else_e || state_process.operation == fake_make_operation_type_if_e || state_process.operation == fake_make_operation_type_or_e)) {
       if (data_make->data->main->error.verbosity != f_console_verbosity_quiet_e && data_make->error.to.stream) {
         flockfile(data_make->error.to.stream);
 
         fl_print_format("%r%[%QIncomplete '%]", data_make->error.to.stream, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context);
 
-        if (state_process.block == fake_state_process_block_else_e) {
+        if (state_process.operation == fake_make_operation_type_and_e) {
+          fl_print_format("%[%r%]", data_make->error.to.stream, data_make->error.notable, fake_make_operation_and_s, data_make->error.notable);
+        }
+        else if (state_process.operation == fake_make_operation_type_else_e) {
           fl_print_format("%[%r%]", data_make->error.to.stream, data_make->error.notable, fake_make_operation_else_s, data_make->error.notable);
         }
-        else {
+        else if (state_process.operation == fake_make_operation_type_if_e) {
           fl_print_format("%[%r%]", data_make->error.to.stream, data_make->error.notable, fake_make_operation_if_s, data_make->error.notable);
         }
+        else {
+          fl_print_format("%[%r%]", data_make->error.to.stream, data_make->error.notable, fake_make_operation_or_s, data_make->error.notable);
+        }
 
-        fl_print_format("%[' at end of section.%]%r", data_make->error.to.stream, data_make->error.context, data_make->error.context, f_string_eol_s);
+        fl_print_format("%[' at end of the section.%]%r", data_make->error.to.stream, data_make->error.context, data_make->error.context, f_string_eol_s);
 
         funlockfile(data_make->error.to.stream);
       }
@@ -1377,7 +1267,7 @@ extern "C" {
     }
 
     // Ensure an error is returned during recursion if the last known section operation failed, except for the main operation.
-    if (success == F_false && F_status_is_error_not(*status) && section_stack->used > 1) {
+    if (state_process.success == F_false && F_status_is_error_not(*status) && section_stack->used > 1) {
       *status = F_status_set_error(F_failure);
     }
 
index 21b4735bd91f533b0999cf1235f7748aaa63a7b0..2f8654fa2442f7cea443525912c80e889462e096 100644 (file)
@@ -41,8 +41,6 @@ extern "C" {
  *   All make related setting data, including data from the fakefile and the build settings file.
  * @param section_name
  *   The section name.
- * @param operation
- *   The operation being performed.
  * @param content
  *   The content array.
  * @param quoteds
@@ -55,7 +53,7 @@ extern "C" {
  *   Status codes (with error bit) are returned on any problem.
  */
 #ifndef _di_fake_make_operate_expand_
-  extern void fake_make_operate_expand(fake_make_data_t * const data_make, const f_string_range_t section_name, const f_array_length_t operation, const f_fss_content_t content, const f_fss_quotes_t quoteds, f_string_dynamics_t * const arguments, f_status_t * const status) F_attribute_visibility_internal_d;
+  extern void fake_make_operate_expand(fake_make_data_t * const data_make, const f_string_range_t section_name, const f_fss_content_t content, const f_fss_quotes_t quoteds, f_string_dynamics_t * const arguments, f_status_t * const status) F_attribute_visibility_internal_d;
 #endif // _di_fake_make_operate_expand_
 
 /**
diff --git a/level_3/fake/c/private-make-operate_block.c b/level_3/fake/c/private-make-operate_block.c
new file mode 100644 (file)
index 0000000..6b643a0
--- /dev/null
@@ -0,0 +1,112 @@
+#include "fake.h"
+#include "private-common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _di_fake_make_operate_block_prepare_
+  void fake_make_operate_block_prepare(fake_state_process_t * const state_process) {
+
+    if (state_process->block) {
+      if (state_process->operation == fake_make_operation_type_and_e || state_process->operation == fake_make_operation_type_else_e || state_process->operation == fake_make_operation_type_if_e || state_process->operation == fake_make_operation_type_or_e) {
+        return;
+      }
+
+      if (state_process->operation_previous == fake_make_operation_type_and_e || state_process->operation_previous == fake_make_operation_type_else_e || state_process->operation_previous == fake_make_operation_type_if_e || state_process->operation_previous == fake_make_operation_type_or_e) {
+        return;
+      }
+
+      // No further block operation detected, so wrap things up.
+      state_process->block = 0;
+      state_process->block_result = 0;
+
+      if (state_process->block_result == fake_condition_result_error_e) {
+
+        // When the block ends and the block success is false, pass the failure to the success variable so that "failure" conditions can catch this.
+        if (state_process->success && !state_process->success_block) {
+          state_process->success = F_false;
+        }
+      }
+      else {
+        state_process->success_block = F_true;
+      }
+    }
+  }
+#endif // _di_fake_make_operate_block_prepare_
+
+#ifndef _di_fake_make_operate_block_postprocess_
+  void fake_make_operate_block_postprocess(const bool last, fake_state_process_t * const state_process, f_status_t * const status) {
+
+    if (F_status_is_error(*status)) {
+      state_process->block_result = fake_condition_result_error_e;
+      state_process->success_block = F_false;
+
+      return;
+    }
+
+    // When done processing an operation within an if/else condition, update the process state.
+    if (state_process->block == fake_state_process_block_done_e) {
+      // Nothing to do.
+    }
+    else if (state_process->block == fake_state_process_block_operate_e) {
+      if (state_process->operation == fake_make_operation_type_and_e || state_process->operation == fake_make_operation_type_if_e || state_process->operation == fake_make_operation_type_or_e) {
+        state_process->block_result = state_process->condition_result;
+
+        if (state_process->block_result == fake_condition_result_false_e) {
+          state_process->block = fake_state_process_block_skip_e;
+        }
+      }
+      else if (state_process->operation == fake_make_operation_type_else_e) {
+        state_process->block_result = 0;
+      }
+      else {
+        state_process->block = fake_state_process_block_done_e;
+        state_process->block_result = state_process->condition_result;
+      }
+    }
+    else if (state_process->block == fake_state_process_block_skip_e) {
+      if (state_process->operation != fake_make_operation_type_and_e && state_process->operation != fake_make_operation_type_if_e && state_process->operation != fake_make_operation_type_or_e) {
+
+        // The operation has been skipped, so reset the block.
+        state_process->block = fake_state_process_block_operate_e;
+      }
+    }
+    else {
+      state_process->block_result = state_process->condition_result;
+
+      // If starting a new if-condition, setup the block.
+      if (state_process->condition_result == fake_condition_result_true_e) {
+        state_process->block = fake_state_process_block_operate_e;
+      }
+      else {
+        state_process->block = fake_state_process_block_skip_e;
+      }
+    }
+
+    if (last) {
+      if (state_process->operation == fake_make_operation_type_and_e || state_process->operation == fake_make_operation_type_else_e || state_process->operation == fake_make_operation_type_if_e || state_process->operation == fake_make_operation_type_or_e) {
+        return;
+      }
+
+      // No further block operation, so wrap things up.
+      state_process->block = 0;
+      state_process->block_result = 0;
+
+      if (state_process->block_result == fake_condition_result_error_e) {
+
+        // When the block ends and the block success is false, pass the failure to the success variable so that "failure" conditions can catch this.
+        if (state_process->success && !state_process->success_block) {
+          state_process->success = F_false;
+        }
+      }
+      else {
+        state_process->success_block = F_true;
+      }
+    }
+  }
+#endif // _di_fake_make_operate_block_postprocess_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
diff --git a/level_3/fake/c/private-make-operate_block.h b/level_3/fake/c/private-make-operate_block.h
new file mode 100644 (file)
index 0000000..e910bd7
--- /dev/null
@@ -0,0 +1,49 @@
+/**
+ * FLL - Level 3
+ *
+ * Project: Featureless Make
+ * API Version: 0.6
+ * Licenses: lgpl-2.1-or-later
+ */
+#ifndef _PRIVATE_make_operate_block_h
+#define _PRIVATE_make_operate_block_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Prepare the block for the next operation.
+ *
+ * This is to be called before validation but after expanding the operation.
+ * Whether or not a block ends can only be done after the next line is processed.
+ *
+ * @param state_process
+ *   The operation and if-condition states.
+ */
+#ifndef _di_fake_make_operate_block_prepare_
+  extern void fake_make_operate_block_prepare(fake_state_process_t * const state_process) F_attribute_visibility_internal_d;
+#endif // _di_fake_make_operate_block_prepare_
+
+/**
+ * Perform block post-processing.
+ *
+ * This is to be called once an operation is performed or skipped.
+ *
+ * @param last
+ *   If TRUE, then this is the last line.
+ *   If FALSE, then this is not the last line.
+ * @param state_process
+ *   The operation and if-condition states.
+ * @param status
+ *   The status code.
+ */
+#ifndef _di_fake_make_operate_block_postprocess_
+  extern void fake_make_operate_block_postprocess(const bool last, fake_state_process_t * const state_process, f_status_t * const status) F_attribute_visibility_internal_d;
+#endif // _di_fake_make_operate_block_postprocess_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _PRIVATE_make_operate_block_h
index 4438f917ea39062c796e5379444ce33c18cd3916..71cdd7e5b91e05482f670eba8de7955c5dc576d3 100644 (file)
@@ -15,49 +15,10 @@ extern "C" {
 #endif
 
 #ifndef _di_fake_make_operate_process_
-  int fake_make_operate_process(fake_make_data_t * const data_make, const f_string_range_t section_name, const f_string_dynamics_t arguments, const bool success, fake_state_process_t * const state_process, f_array_lengths_t * const section_stack, f_status_t * const status) {
+  int fake_make_operate_process(fake_make_data_t * const data_make, const f_string_range_t section_name, const f_string_dynamics_t arguments, fake_state_process_t * const state_process, f_array_lengths_t * const section_stack, f_status_t * const status) {
 
     if (*status == F_child) return data_make->data->main->child;
 
-    if (state_process->block) {
-      if (state_process->block == fake_state_process_block_if_e) {
-        if (state_process->operation == fake_make_operation_type_or_e) {
-
-          // For cases of "or", if the previous condition is true, then don't bother because "true || X" is always true.
-          if (state_process->block_result == fake_condition_result_true_e) {
-            state_process->condition_result = state_process->block_result;
-
-            return 0;
-          }
-        }
-        else {
-
-          // For all other cases, if the previous condition is false, then it is always false because "false && X" is always false.
-          if (state_process->block_result == fake_condition_result_false_e) {
-            state_process->condition_result = state_process->block_result;
-
-            return 0;
-          }
-        }
-      }
-      else if (state_process->block == fake_state_process_block_if_skip_e) {
-        if (!(state_process->operation == fake_make_operation_type_and_e || state_process->operation == fake_make_operation_type_or_e)) {
-          state_process->condition_result = state_process->block_result;
-
-          return 0;
-        }
-      }
-      else if (state_process->block == fake_state_process_block_else_e) {
-        if (state_process->operation != fake_make_operation_type_if_e) {
-          if (state_process->block_result == fake_condition_result_false_e) {
-            state_process->condition_result = state_process->block_result;
-
-            return 0;
-          }
-        }
-      }
-    }
-
     if (state_process->operation == fake_make_operation_type_index_e) {
       const f_status_t result = fake_execute(data_make->data, data_make->environment, data_make->setting_build.build_indexer, arguments, status);
 
@@ -234,7 +195,7 @@ extern "C" {
 
     if (state_process->operation == fake_make_operation_type_if_e || state_process->operation == fake_make_operation_type_and_e || state_process->operation == fake_make_operation_type_or_e) {
       if (state_process->condition == fake_make_operation_if_type_if_success_e) {
-        if (success) {
+        if (state_process->success) {
           state_process->condition_result = fake_condition_result_true_e;
         }
         else {
@@ -248,7 +209,7 @@ extern "C" {
         *status = fake_make_operate_process_type_if_exists(data_make, arguments, F_false, state_process);
       }
       else if (state_process->condition == fake_make_operation_if_type_if_failure_e) {
-        if (success) {
+        if (state_process->success) {
           state_process->condition_result = fake_condition_result_false_e;
         }
         else {
@@ -320,30 +281,22 @@ extern "C" {
         *status = fake_make_operate_process_type_if_owner(data_make, arguments, F_false, state_process);
       }
 
-      // When inside an else block that is already set to false, then all if conditions inside are always considered false.
-      if (state_process->block == fake_state_process_block_else_e && state_process->block_result == fake_condition_result_false_e) {
-        return 0;
-      }
-
-      // When inside an if block designated to be skipped, then all if conditions inside are always considered false.
-      if (state_process->block == fake_state_process_block_if_skip_e) {
-        return 0;
-      }
-
       if (state_process->block) {
-        if (state_process->operation == fake_make_operation_type_or_e) {
-          if (state_process->block_result == fake_condition_result_true_e || state_process->condition_result == fake_condition_result_true_e) {
+        if (state_process->operation == fake_make_operation_type_and_e) {
+          if (state_process->block_result == fake_condition_result_true_e && state_process->condition_result == fake_condition_result_true_e) {
             state_process->condition_result = fake_condition_result_true_e;
           }
           else {
             state_process->condition_result = fake_condition_result_false_e;
           }
         }
-        else if (state_process->block_result == fake_condition_result_true_e && state_process->condition_result == fake_condition_result_true_e) {
-          state_process->condition_result = fake_condition_result_true_e;
-        }
-        else {
-          state_process->condition_result = fake_condition_result_false_e;
+        else if (state_process->operation == fake_make_operation_type_or_e) {
+          if (state_process->block_result == fake_condition_result_true_e || state_process->condition_result == fake_condition_result_true_e) {
+            state_process->condition_result = fake_condition_result_true_e;
+          }
+          else {
+            state_process->condition_result = fake_condition_result_false_e;
+          }
         }
       }
 
index 2337cdfbd73b6265002b7c84a533b275e43c5903..04d97210ea3543b1adf42056f40d6092626c0f01 100644 (file)
@@ -21,8 +21,6 @@ extern "C" {
  *   The section name.
  * @param arguments
  *   The expanded arguments.
- * @param success
- *   Whether or not a previous section operation succeeded or failed.
  * @param state_process
  *   The operation and if-condition states.
  * @param section_stack
@@ -39,7 +37,7 @@ extern "C" {
  *   This generally is only needed when F_child is returned, where this holds the return status of the child process.
  */
 #ifndef _di_fake_make_operate_process_
-  extern int fake_make_operate_process(fake_make_data_t * const data_make, const f_string_range_t section_name, const f_string_dynamics_t arguments, const bool success, fake_state_process_t * const state_process, f_array_lengths_t * const section_stack, f_status_t * const status) F_attribute_visibility_internal_d;
+  extern int fake_make_operate_process(fake_make_data_t * const data_make, const f_string_range_t section_name, const f_string_dynamics_t arguments, fake_state_process_t * const state_process, f_array_lengths_t * const section_stack, f_status_t * const status) F_attribute_visibility_internal_d;
 #endif // _di_fake_make_operate_process_
 
 /**
index ad82d2175c0bfb6762177bcb04fe4d32cebbdfb4..e5c8948bf8f9db97e8acc073ccaa13762f3d8c34 100644 (file)
@@ -5,6 +5,7 @@
 #include "private-clean.h"
 #include "private-make.h"
 #include "private-make-operate.h"
+#include "private-make-operate_block.h"
 #include "private-make-operate_validate.h"
 #include "private-print.h"
 #include "private-skeleton.h"
@@ -407,7 +408,7 @@ extern "C" {
     }
 
     if (state_process->operation == fake_make_operation_type_else_e) {
-      if (state_process->block == fake_make_operation_if_type_else_e) {
+      if (state_process->operation_previous == fake_make_operation_type_else_e) {
         if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->error.to.stream) {
           flockfile(data_make->error.to.stream);
 
@@ -769,6 +770,8 @@ extern "C" {
           return;
         }
 
+        state_process->condition_result = fake_condition_result_true_e;
+
         ++k;
 
         // Identify and convert to the appropriate if not condition.
@@ -844,7 +847,8 @@ extern "C" {
 
             return;
           }
-          else if (state_process->condition == fake_make_operation_if_type_if_equal_e || state_process->condition == fake_make_operation_if_type_if_equal_not_e) {
+
+          if (state_process->condition == fake_make_operation_if_type_if_equal_e || state_process->condition == fake_make_operation_if_type_if_equal_not_e) {
             if (arguments.used < 2 + k) {
               fake_print_error_requires_more_arguments(data_make);
 
@@ -853,10 +857,12 @@ extern "C" {
 
             return;
           }
-          else if (state_process->condition == fake_make_operation_if_type_if_exists_e || state_process->condition == fake_make_operation_if_type_if_not_exists_e) {
+
+          if (state_process->condition == fake_make_operation_if_type_if_exists_e || state_process->condition == fake_make_operation_if_type_if_not_exists_e) {
             return;
           }
-          else if (state_process->condition == fake_make_operation_if_type_if_group_e || state_process->condition == fake_make_operation_if_type_if_is_e || state_process->condition == fake_make_operation_if_type_if_mode_e || state_process->condition > fake_make_operation_if_type_if_not_exists_e && state_process->condition < fake_make_operation_if_type_if_success_e) {
+
+          if (state_process->condition == fake_make_operation_if_type_if_group_e || state_process->condition == fake_make_operation_if_type_if_is_e || state_process->condition == fake_make_operation_if_type_if_mode_e || state_process->condition > fake_make_operation_if_type_if_not_exists_e && state_process->condition < fake_make_operation_if_type_if_success_e) {
 
             if (state_process->condition == fake_make_operation_if_type_if_mode_e || state_process->condition == fake_make_operation_if_type_if_not_mode_e) {
               if (fl_string_dynamic_compare(fake_make_operation_argument_is_s, arguments.array[k]) == F_equal_to_not) {
@@ -996,8 +1002,11 @@ extern "C" {
                 }
               } // for
             }
+
+            return;
           }
-          else if (state_process->condition == fake_make_operation_if_type_if_greater_e || state_process->condition == fake_make_operation_if_type_if_greater_equal_e || state_process->condition == fake_make_operation_if_type_if_less_e || state_process->condition == fake_make_operation_if_type_if_less_equal_e) {
+
+          if (state_process->condition == fake_make_operation_if_type_if_greater_e || state_process->condition == fake_make_operation_if_type_if_greater_equal_e || state_process->condition == fake_make_operation_if_type_if_less_e || state_process->condition == fake_make_operation_if_type_if_less_equal_e) {
             if (arguments.used < 2 + k) {
               fake_print_error_requires_more_arguments(data_make);
 
index 9a5888762c4daadbafe3df68385ab4f512629d7b..142bb841a9651419787d849013e23e83d5cf8596 100644 (file)
@@ -28,7 +28,11 @@ build_libraries-level -lfll_2 -lfll_1 -lfll_0
 build_libraries-monolithic -lfll
 
 build_sources_library fake.c common.c
-build_sources_library private-build.c private-build-library.c private-build-load.c private-build-object.c private-build-objects.c private-build-program.c private-build-skeleton.c private-clean.c private-common.c private-make.c private-fake.c private-fake-path_generate.c private-make-load_fakefile.c private-make-load_parameters.c private-make-operate.c private-make-operate_process.c private-make-operate_process_type.c private-make-operate_validate.c private-print.c private-skeleton.c
+build_sources_library private-build.c private-build-library.c private-build-load.c private-build-object.c private-build-objects.c private-build-program.c private-build-skeleton.c
+build_sources_library private-clean.c private-common.c private-make.c private-print.c private-skeleton.c
+build_sources_library private-make-load_fakefile.c private-make-load_parameters.c
+build_sources_library private-make-operate.c private-make-operate_block.c private-make-operate_process.c private-make-operate_process_type.c private-make-operate_validate.c
+build_sources_library private-fake.c private-fake-path_generate.c
 
 build_sources_program main.c