From ee7d084e8cfb81df6fb578fec74310612af840cb Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 23 Jul 2022 14:31:09 -0500 Subject: [PATCH] Cleanup: Relocate all operation process type operations into functions. Just like with commit 452b0189a610418420119a71907e7b9276ed5c28 do some re-organization. The operate process type operations are not all in their own functions. Change the code to move all of the operate process type operations into their own functions. --- level_3/fake/c/private-make-operate_process.c | 388 +++------------------ level_3/fake/c/private-make-operate_process.h | 1 + level_3/fake/c/private-make-operate_process_type.c | 302 ++++++++++++++++ level_3/fake/c/private-make-operate_process_type.h | 192 ++++++++++ 4 files changed, 538 insertions(+), 345 deletions(-) diff --git a/level_3/fake/c/private-make-operate_process.c b/level_3/fake/c/private-make-operate_process.c index f3ccc90..941910c 100644 --- a/level_3/fake/c/private-make-operate_process.c +++ b/level_3/fake/c/private-make-operate_process.c @@ -18,405 +18,103 @@ extern "C" { if (*status == F_child) return data_make->data->main->child; - 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, data_make->cache_arguments, status); - - if (F_status_is_error(*status)) { - fll_error_print(data_make->error, F_status_set_fine(*status), "fake_execute", F_true); - } - - if (*status == F_child) return result; - - *status = fake_make_operate_process_return(data_make, result); - - return 0; - } - if (state_process->operation == fake_make_operation_type_break_e) { - if (!data_make->cache_arguments.used || fl_string_dynamic_compare(fake_make_operation_argument_success_s, data_make->cache_arguments.array[0]) == F_equal_to) { - *status = F_signal_abort; - } - else if (fl_string_dynamic_compare(fake_make_operation_argument_failure_s, data_make->cache_arguments.array[0]) == F_equal_to) { - *status = F_status_set_error(F_signal_abort); - } - else { - return 0; - } - - if (data_make->main->error.verbosity >= f_console_verbosity_verbose_e) { - flockfile(data_make->main->output.to.stream); - - fl_print_format("%rBreaking as '", data_make->main->output.to.stream, f_string_eol_s); - fl_print_format("%[%Q%]", data_make->main->output.to.stream, data_make->main->context.set.notable, data_make->cache_arguments.used ? data_make->cache_arguments.array[0] : fake_make_operation_argument_success_s, data_make->main->context.set.notable); - fl_print_format("'.%r", data_make->main->output.to.stream, f_string_eol_s); - - funlockfile(data_make->main->output.to.stream); - } - - return 0; + *status = fake_make_operate_process_type_break(data_make); } - - if (state_process->operation == fake_make_operation_type_build_e) { - *status = fake_build_operate(data_make->data, data_make->cache_arguments.used ? &data_make->cache_arguments : 0); - if (F_status_set_fine(*status) == F_interrupt) return 0; - - *status = fake_make_operate_process_return(data_make, F_status_is_error(*status) ? 1 : 0); - - return 0; + else if (state_process->operation == fake_make_operation_type_build_e) { + *status = fake_make_operate_process_type_build(data_make); } - - if (state_process->operation == fake_make_operation_type_clean_e) { - *status = fake_clean_operate(data_make->data); - if (F_status_set_fine(*status) == F_interrupt) return 0; - - *status = fake_make_operate_process_return(data_make, F_status_is_error(*status) ? 1 : 0); - - return 0; + else if (state_process->operation == fake_make_operation_type_clean_e) { + *status = fake_make_operate_process_type_clean(data_make); } - - if (state_process->operation == fake_make_operation_type_clone_e) { + else if (state_process->operation == fake_make_operation_type_clone_e) { *status = fake_make_operate_process_type_copy(data_make, F_true); - - return 0; } - - if (state_process->operation == fake_make_operation_type_compile_e) { - const int result = fake_execute(data_make->data, data_make->environment, data_make->setting_build.build_compiler, data_make->cache_arguments, status); - - if (F_status_is_error(*status)) { - fll_error_print(data_make->error, F_status_set_fine(*status), "fake_execute", F_true); - } - - if (*status == F_child) return result; - - *status = fake_make_operate_process_return(data_make, result); - - return 0; + else if (state_process->operation == fake_make_operation_type_compile_e) { + return fake_make_operate_process_type_compile(data_make, status); } - - if (state_process->operation == fake_make_operation_type_copy_e) { + else if (state_process->operation == fake_make_operation_type_copy_e) { *status = fake_make_operate_process_type_copy(data_make, F_false); - - return 0; } - - if (state_process->operation == fake_make_operation_type_define_e) { - if (data_make->cache_arguments.used > 1) { - *status = f_environment_set(data_make->cache_arguments.array[0], data_make->cache_arguments.array[1], F_true); - } - else { - *status = f_environment_set(data_make->cache_arguments.array[0], f_string_empty_s, F_true); - } - - if (F_status_is_error(*status)) { - fll_error_print(data_make->error, F_status_set_fine(*status), "f_environment_set", F_true); - } - else if (data_make->main->error.verbosity >= f_console_verbosity_verbose_e) { - fll_print_format("%rDefined environment variable '%[%Q%]'.%r", data_make->main->output.to.stream, f_string_eol_s, data_make->main->context.set.notable, data_make->cache_arguments.array[0], data_make->main->context.set.notable, f_string_eol_s); - } - - return 0; + else if (state_process->operation == fake_make_operation_type_define_e) { + *status = fake_make_operate_process_type_define(data_make); } - - if (state_process->operation == fake_make_operation_type_delete_e) { + else if (state_process->operation == fake_make_operation_type_delete_e) { *status = fake_make_operate_process_type_deletes(data_make, F_false); - - return 0; } - - if (state_process->operation == fake_make_operation_type_deletes_e) { + else if (state_process->operation == fake_make_operation_type_deletes_e) { *status = fake_make_operate_process_type_deletes(data_make, F_true); - - return 0; } - - if (state_process->operation == fake_make_operation_type_else_e) { - + else if (state_process->operation == fake_make_operation_type_else_e) { // There is nothing to do. - return 0; } - - if (state_process->operation == fake_make_operation_type_exit_e) { - if (!data_make->cache_arguments.used || fl_string_dynamic_compare(fake_make_operation_argument_success_s, data_make->cache_arguments.array[0]) == F_equal_to) { - *status = F_signal_quit; - } - else if (fl_string_dynamic_compare(fake_make_operation_argument_failure_s, data_make->cache_arguments.array[0]) == F_equal_to) { - *status = F_status_set_error(F_signal_quit); - - // Forcing exit forces fail mode. - data_make->setting_make.fail = fake_make_operation_fail_type_exit_e; - data_make->error.prefix = fl_print_error_s; - data_make->error.suffix = f_string_empty_s; - data_make->error.context = data_make->main->context.set.error; - data_make->error.notable = data_make->main->context.set.notable; - data_make->error.to.stream = F_type_error_d; - data_make->error.to.id = F_type_descriptor_error_d; - data_make->error.set = &data_make->main->context.set; - } - else { - return 0; - } - - if (data_make->main->error.verbosity >= f_console_verbosity_verbose_e) { - fll_print_format("%rExiting as '%[%Q%]'.%r", data_make->main->output.to.stream, f_string_eol_s, data_make->main->context.set.notable, data_make->cache_arguments.used ? data_make->cache_arguments.array[0] : fake_make_operation_argument_success_s, data_make->main->context.set.notable, f_string_eol_s); - } - - return 0; + else if (state_process->operation == fake_make_operation_type_exit_e) { + *status = fake_make_operate_process_type_exit(data_make); } - - if (state_process->operation == fake_make_operation_type_fail_e) { + else if (state_process->operation == fake_make_operation_type_fail_e) { fake_make_operate_process_type_fail(data_make); - - return 0; } - - if (state_process->operation == fake_make_operation_type_group_e) { + else if (state_process->operation == fake_make_operation_type_group_e) { *status = fake_make_operate_process_type_groups(data_make, F_false); - - return 0; } - - if (state_process->operation == fake_make_operation_type_groups_e) { + else if (state_process->operation == fake_make_operation_type_groups_e) { *status = fake_make_operate_process_type_groups(data_make, F_true); - - return 0; } - - 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_define_e) { - fake_make_operate_process_type_if_define(data_make, F_false, state_process); - } - else if (state_process->condition == fake_make_operation_if_type_if_equal_e) { - state_process->condition_result = fake_condition_result_true_e; - - for (f_array_length_t i = 2; i < data_make->cache_arguments.used; ++i) { - - if (fl_string_dynamic_compare(data_make->cache_arguments.array[1], data_make->cache_arguments.array[i]) == F_equal_to_not) { - state_process->condition_result = fake_condition_result_false_e; - - break; - } - } // for - } - else if (state_process->condition == fake_make_operation_if_type_if_equal_not_e) { - state_process->condition_result = fake_condition_result_true_e; - - f_array_length_t i = 1; - f_array_length_t j = 0; - - for (; i < data_make->cache_arguments.used; ++i) { - - for (j = i + 1; j < data_make->cache_arguments.used; ++j) { - - if (fl_string_dynamic_compare(data_make->cache_arguments.array[i], data_make->cache_arguments.array[j]) == F_equal_to) { - state_process->condition_result = fake_condition_result_false_e; - i = data_make->cache_arguments.used; - - break; - } - } // for - } // for - } - else if (state_process->condition == fake_make_operation_if_type_if_exist_e) { - *status = fake_make_operate_process_type_if_exist(data_make, F_false, state_process); - } - else if (state_process->condition == fake_make_operation_if_type_if_failure_e) { - if (state_process->success) { - state_process->condition_result = fake_condition_result_false_e; - } - else { - state_process->condition_result = fake_condition_result_true_e; - } - } - 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) { - *status = fake_make_operate_process_type_if_greater_if_lesser(data_make, state_process); - } - else if (state_process->condition == fake_make_operation_if_type_if_group_e) { - *status = fake_make_operate_process_type_if_group(data_make, F_false, state_process); - } - else if (state_process->condition == fake_make_operation_if_type_if_is_e) { - *status = fake_make_operate_process_type_if_is(data_make, F_false, state_process); - } - else if (state_process->condition == fake_make_operation_if_type_if_mode_e) { - *status = fake_make_operate_process_type_if_mode(data_make, F_false, state_process); - } - else if (state_process->condition == fake_make_operation_if_type_if_not_define_e) { - fake_make_operate_process_type_if_define(data_make, F_true, state_process); - } - else if (state_process->condition == fake_make_operation_if_type_if_not_parameter_e) { - fake_make_operate_process_type_if_parameter(data_make, F_true, state_process); - } - else if (state_process->condition == fake_make_operation_if_type_if_not_exist_e) { - *status = fake_make_operate_process_type_if_exist(data_make, F_true, state_process); - } - else if (state_process->condition == fake_make_operation_if_type_if_not_group_e) { - *status = fake_make_operate_process_type_if_group(data_make, F_true, state_process); - } - else if (state_process->condition == fake_make_operation_if_type_if_not_is_e) { - *status = fake_make_operate_process_type_if_is(data_make, F_true, state_process); - } - else if (state_process->condition == fake_make_operation_if_type_if_not_mode_e) { - *status = fake_make_operate_process_type_if_mode(data_make, F_true, state_process); - } - else if (state_process->condition == fake_make_operation_if_type_if_not_owner_e) { - *status = fake_make_operate_process_type_if_owner(data_make, F_true, state_process); - } - else if (state_process->condition == fake_make_operation_if_type_if_owner_e) { - *status = fake_make_operate_process_type_if_owner(data_make, F_false, state_process); - } - else if (state_process->condition == fake_make_operation_if_type_if_parameter_e) { - fake_make_operate_process_type_if_parameter(data_make, F_false, state_process); - } - else if (state_process->condition == fake_make_operation_if_type_if_success_e) { - if (state_process->success) { - state_process->condition_result = fake_condition_result_true_e; - } - else { - state_process->condition_result = fake_condition_result_false_e; - } - } - - if (state_process->block) { - 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->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; - } - } - } - - return 0; + 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) { + *status = fake_make_operate_process_type_condition(data_make, state_process); } - - if (state_process->operation == fake_make_operation_type_link_e) { + else if (state_process->operation == fake_make_operation_type_index_e) { + return fake_make_operate_process_type_index(data_make, status); + } + else if (state_process->operation == fake_make_operation_type_link_e) { *status = fake_make_operate_process_type_link(data_make); - - return 0; } - - if (state_process->operation == fake_make_operation_type_mode_e) { + else if (state_process->operation == fake_make_operation_type_mode_e) { *status = fake_make_operate_process_type_modes(data_make, F_false); - - return 0; } - - if (state_process->operation == fake_make_operation_type_modes_e) { + else if (state_process->operation == fake_make_operation_type_modes_e) { *status = fake_make_operate_process_type_modes(data_make, F_true); - - return 0; } - - if (state_process->operation == fake_make_operation_type_move_e) { + else if (state_process->operation == fake_make_operation_type_move_e) { *status = fake_make_operate_process_type_move(data_make); - - return 0; } - - if (state_process->operation == fake_make_operation_type_operate_e) { - f_array_length_t id_section = 0; - - for (; id_section < data_make->fakefile.used; ++id_section) { - - if (fl_string_dynamic_partial_compare_string(data_make->cache_arguments.array[0].string, data_make->buffer, data_make->cache_arguments.array[0].used, data_make->fakefile.array[id_section].name) == F_equal_to) { - break; - } - } // for - - if (id_section == data_make->fakefile.used) { - return 0; - } - - const int result = fake_make_operate_section(data_make, id_section, section_stack, status); - - // Ensure that a break only happens within its active state_process->operation stack. - if (*status == F_signal_abort) { - *status = F_none; - } - else if (F_status_set_fine(*status) == F_signal_abort) { - *status = F_status_set_error(F_failure); - } - - return result; + else if (state_process->operation == fake_make_operation_type_operate_e) { + return fake_make_operate_process_type_operate(data_make, section_stack, status); } - - if (state_process->operation == fake_make_operation_type_owner_e) { + else if (state_process->operation == fake_make_operation_type_owner_e) { *status = fake_make_operate_process_type_owners(data_make, F_false); - - return 0; } - - if (state_process->operation == fake_make_operation_type_owners_e) { + else if (state_process->operation == fake_make_operation_type_owners_e) { *status = fake_make_operate_process_type_owners(data_make, F_true); - - return 0; } - - if (state_process->operation == fake_make_operation_type_parameter_e) { + else if (state_process->operation == fake_make_operation_type_parameter_e) { *status = fake_make_operate_process_type_parameter(data_make); - - return 0; } - - if (state_process->operation == fake_make_operation_type_pop_e) { + else if (state_process->operation == fake_make_operation_type_pop_e) { *status = fake_make_operate_process_type_pop(data_make); - - return 0; } - - if (state_process->operation == fake_make_operation_type_print_e) { + else if (state_process->operation == fake_make_operation_type_print_e) { *status = fake_make_operate_process_type_print(data_make); - - return 0; } - - if (state_process->operation == fake_make_operation_type_run_e) { + else if (state_process->operation == fake_make_operation_type_run_e) { *status = fake_make_operate_process_run(data_make, F_false); - - return 0; } - - if (state_process->operation == fake_make_operation_type_shell_e) { + else if (state_process->operation == fake_make_operation_type_shell_e) { *status = fake_make_operate_process_run(data_make, F_true); - - return 0; } - - if (state_process->operation == fake_make_operation_type_skeleton_e) { - *status = fake_skeleton_operate(data_make->data); - if (F_status_set_fine(*status) == F_interrupt) return 0; - - *status = fake_make_operate_process_return(data_make, F_status_is_error(*status) ? 1 : 0); - - return 0; + else if (state_process->operation == fake_make_operation_type_skeleton_e) { + *status = fake_make_operate_process_type_skeleton(data_make); } - - if (state_process->operation == fake_make_operation_type_to_e) { + else if (state_process->operation == fake_make_operation_type_to_e) { *status = fake_make_operate_process_type_to(data_make); - - return 0; } - - if (state_process->operation == fake_make_operation_type_top_e) { + else if (state_process->operation == fake_make_operation_type_top_e) { *status = fake_make_operate_process_type_top(data_make); - - return 0; } - - if (state_process->operation == fake_make_operation_type_touch_e) { + else if (state_process->operation == fake_make_operation_type_touch_e) { *status = fake_make_operate_process_type_touch(data_make); } - - if (state_process->operation == fake_make_operation_type_write_e) { + else if (state_process->operation == fake_make_operation_type_write_e) { *status = fake_make_operate_process_type_write(data_make); } diff --git a/level_3/fake/c/private-make-operate_process.h b/level_3/fake/c/private-make-operate_process.h index a0b2809..aa04bc4 100644 --- a/level_3/fake/c/private-make-operate_process.h +++ b/level_3/fake/c/private-make-operate_process.h @@ -32,6 +32,7 @@ extern "C" { * * @return * The return code of the execution process. + * * 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_ diff --git a/level_3/fake/c/private-make-operate_process_type.c b/level_3/fake/c/private-make-operate_process_type.c index e93f887..375ff31 100644 --- a/level_3/fake/c/private-make-operate_process_type.c +++ b/level_3/fake/c/private-make-operate_process_type.c @@ -1,16 +1,207 @@ #include "fake.h" #include "private-common.h" #include "private-fake.h" +#include "private-build.h" #include "private-clean.h" #include "private-make.h" +#include "private-make-operate.h" #include "private-make-operate_process.h" #include "private-make-operate_process_type.h" #include "private-print.h" +#include "private-skeleton.h" #ifdef __cplusplus extern "C" { #endif +#ifndef _di_fake_make_operate_process_type_break_ + f_status_t fake_make_operate_process_type_break(fake_make_data_t * const data_make) { + + f_status_t status = F_none; + + if (!data_make->cache_arguments.used || fl_string_dynamic_compare(fake_make_operation_argument_success_s, data_make->cache_arguments.array[0]) == F_equal_to) { + status = F_signal_abort; + } + else if (fl_string_dynamic_compare(fake_make_operation_argument_failure_s, data_make->cache_arguments.array[0]) == F_equal_to) { + status = F_status_set_error(F_signal_abort); + } + else { + return F_none; + } + + if (data_make->main->error.verbosity >= f_console_verbosity_verbose_e) { + flockfile(data_make->main->output.to.stream); + + fl_print_format("%rBreaking as '", data_make->main->output.to.stream, f_string_eol_s); + fl_print_format("%[%Q%]", data_make->main->output.to.stream, data_make->main->context.set.notable, data_make->cache_arguments.used ? data_make->cache_arguments.array[0] : fake_make_operation_argument_success_s, data_make->main->context.set.notable); + fl_print_format("'.%r", data_make->main->output.to.stream, f_string_eol_s); + + funlockfile(data_make->main->output.to.stream); + } + + return status; + } +#endif // _di_fake_make_operate_process_type_break_ + +#ifndef _di_fake_make_operate_process_type_build_ + f_status_t fake_make_operate_process_type_build(fake_make_data_t * const data_make) { + + const f_status_t status = fake_build_operate(data_make->data, data_make->cache_arguments.used ? &data_make->cache_arguments : 0); + if (F_status_set_fine(status) == F_interrupt) return status; + + return fake_make_operate_process_return(data_make, F_status_is_error(status) ? 1 : 0); + } +#endif // _di_fake_make_operate_process_type_build_ + +#ifndef _di_fake_make_operate_process_type_clean_ + f_status_t fake_make_operate_process_type_clean(fake_make_data_t * const data_make) { + + const f_status_t status = fake_clean_operate(data_make->data); + if (F_status_set_fine(status) == F_interrupt) return status; + + return fake_make_operate_process_return(data_make, F_status_is_error(status) ? 1 : 0); + } +#endif // _di_fake_make_operate_process_type_clean_ + +#ifndef _di_fake_make_operate_process_type_compile_ + int fake_make_operate_process_type_compile(fake_make_data_t * const data_make, f_status_t * const status) { + + const int result = fake_execute(data_make->data, data_make->environment, data_make->setting_build.build_compiler, data_make->cache_arguments, status); + + if (F_status_is_error(*status)) { + fll_error_print(data_make->error, F_status_set_fine(*status), "fake_execute", F_true); + } + else if (*status == F_child) { + return result; + } + + *status = fake_make_operate_process_return(data_make, result); + + return 0; + } +#endif // _di_fake_make_operate_process_type_compile_ + +#ifndef _di_fake_make_operate_process_type_condition_ + f_status_t fake_make_operate_process_type_condition(fake_make_data_t * const data_make, fake_state_process_t * const state_process) { + + f_status_t status = F_none; + + if (state_process->condition == fake_make_operation_if_type_if_define_e) { + fake_make_operate_process_type_if_define(data_make, F_false, state_process); + } + else if (state_process->condition == fake_make_operation_if_type_if_equal_e) { + state_process->condition_result = fake_condition_result_true_e; + + for (f_array_length_t i = 2; i < data_make->cache_arguments.used; ++i) { + + if (fl_string_dynamic_compare(data_make->cache_arguments.array[1], data_make->cache_arguments.array[i]) == F_equal_to_not) { + state_process->condition_result = fake_condition_result_false_e; + + break; + } + } // for + } + else if (state_process->condition == fake_make_operation_if_type_if_equal_not_e) { + state_process->condition_result = fake_condition_result_true_e; + + f_array_length_t i = 1; + f_array_length_t j = 0; + + for (; i < data_make->cache_arguments.used; ++i) { + + for (j = i + 1; j < data_make->cache_arguments.used; ++j) { + + if (fl_string_dynamic_compare(data_make->cache_arguments.array[i], data_make->cache_arguments.array[j]) == F_equal_to) { + state_process->condition_result = fake_condition_result_false_e; + i = data_make->cache_arguments.used; + + break; + } + } // for + } // for + } + else if (state_process->condition == fake_make_operation_if_type_if_exist_e) { + status = fake_make_operate_process_type_if_exist(data_make, F_false, state_process); + } + else if (state_process->condition == fake_make_operation_if_type_if_failure_e) { + if (state_process->success) { + state_process->condition_result = fake_condition_result_false_e; + } + else { + state_process->condition_result = fake_condition_result_true_e; + } + } + 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) { + status = fake_make_operate_process_type_if_greater_if_lesser(data_make, state_process); + } + else if (state_process->condition == fake_make_operation_if_type_if_group_e) { + status = fake_make_operate_process_type_if_group(data_make, F_false, state_process); + } + else if (state_process->condition == fake_make_operation_if_type_if_is_e) { + status = fake_make_operate_process_type_if_is(data_make, F_false, state_process); + } + else if (state_process->condition == fake_make_operation_if_type_if_mode_e) { + status = fake_make_operate_process_type_if_mode(data_make, F_false, state_process); + } + else if (state_process->condition == fake_make_operation_if_type_if_not_define_e) { + fake_make_operate_process_type_if_define(data_make, F_true, state_process); + } + else if (state_process->condition == fake_make_operation_if_type_if_not_parameter_e) { + fake_make_operate_process_type_if_parameter(data_make, F_true, state_process); + } + else if (state_process->condition == fake_make_operation_if_type_if_not_exist_e) { + status = fake_make_operate_process_type_if_exist(data_make, F_true, state_process); + } + else if (state_process->condition == fake_make_operation_if_type_if_not_group_e) { + status = fake_make_operate_process_type_if_group(data_make, F_true, state_process); + } + else if (state_process->condition == fake_make_operation_if_type_if_not_is_e) { + status = fake_make_operate_process_type_if_is(data_make, F_true, state_process); + } + else if (state_process->condition == fake_make_operation_if_type_if_not_mode_e) { + status = fake_make_operate_process_type_if_mode(data_make, F_true, state_process); + } + else if (state_process->condition == fake_make_operation_if_type_if_not_owner_e) { + status = fake_make_operate_process_type_if_owner(data_make, F_true, state_process); + } + else if (state_process->condition == fake_make_operation_if_type_if_owner_e) { + status = fake_make_operate_process_type_if_owner(data_make, F_false, state_process); + } + else if (state_process->condition == fake_make_operation_if_type_if_parameter_e) { + fake_make_operate_process_type_if_parameter(data_make, F_false, state_process); + } + else if (state_process->condition == fake_make_operation_if_type_if_success_e) { + if (state_process->success) { + state_process->condition_result = fake_condition_result_true_e; + } + else { + state_process->condition_result = fake_condition_result_false_e; + } + } + + if (state_process->block) { + 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->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; + } + } + } + + return status; + } +#endif // _di_fake_make_operate_process_type_condition_ + #ifndef _di_fake_make_operate_process_type_copy_ f_status_t fake_make_operate_process_type_copy(fake_make_data_t * const data_make, const bool clone) { @@ -155,6 +346,29 @@ extern "C" { } #endif // _di_fake_make_operate_process_type_copy_ +#ifndef _di_fake_make_operate_process_type_define_ + f_status_t fake_make_operate_process_type_define(fake_make_data_t * const data_make) { + + f_status_t status = F_none; + + if (data_make->cache_arguments.used > 1) { + status = f_environment_set(data_make->cache_arguments.array[0], data_make->cache_arguments.array[1], F_true); + } + else { + status = f_environment_set(data_make->cache_arguments.array[0], f_string_empty_s, F_true); + } + + if (F_status_is_error(status)) { + fll_error_print(data_make->error, F_status_set_fine(status), "f_environment_set", F_true); + } + else if (data_make->main->error.verbosity >= f_console_verbosity_verbose_e) { + fll_print_format("%rDefined environment variable '%[%Q%]'.%r", data_make->main->output.to.stream, f_string_eol_s, data_make->main->context.set.notable, data_make->cache_arguments.array[0], data_make->main->context.set.notable, f_string_eol_s); + } + + return status; + } +#endif // _di_fake_make_operate_process_type_define_ + #ifndef _di_fake_make_operate_process_type_deletes_ f_status_t fake_make_operate_process_type_deletes(fake_make_data_t * const data_make, const bool all) { @@ -242,6 +456,39 @@ extern "C" { } #endif // _di_fake_make_operate_process_type_deletes_ +#ifndef _di_fake_make_operate_process_type_exit_ + f_status_t fake_make_operate_process_type_exit(fake_make_data_t * const data_make) { + + f_status_t status = F_none; + + if (!data_make->cache_arguments.used || fl_string_dynamic_compare(fake_make_operation_argument_success_s, data_make->cache_arguments.array[0]) == F_equal_to) { + status = F_signal_quit; + } + else if (fl_string_dynamic_compare(fake_make_operation_argument_failure_s, data_make->cache_arguments.array[0]) == F_equal_to) { + status = F_status_set_error(F_signal_quit); + + // Forcing exit forces fail mode. + data_make->setting_make.fail = fake_make_operation_fail_type_exit_e; + data_make->error.prefix = fl_print_error_s; + data_make->error.suffix = f_string_empty_s; + data_make->error.context = data_make->main->context.set.error; + data_make->error.notable = data_make->main->context.set.notable; + data_make->error.to.stream = F_type_error_d; + data_make->error.to.id = F_type_descriptor_error_d; + data_make->error.set = &data_make->main->context.set; + } + else { + return F_none; + } + + if (data_make->main->error.verbosity >= f_console_verbosity_verbose_e) { + fll_print_format("%rExiting as '%[%Q%]'.%r", data_make->main->output.to.stream, f_string_eol_s, data_make->main->context.set.notable, data_make->cache_arguments.used ? data_make->cache_arguments.array[0] : fake_make_operation_argument_success_s, data_make->main->context.set.notable, f_string_eol_s); + } + + return status; + } +#endif // _di_fake_make_operate_process_type_exit_ + #ifndef _di_fake_make_operate_process_type_fail_ void fake_make_operate_process_type_fail(fake_make_data_t * const data_make) { @@ -1043,6 +1290,23 @@ extern "C" { } #endif // _di_fake_make_operate_process_type_if_parameter_ +#ifndef _di_fake_make_operate_process_type_index_ + int fake_make_operate_process_type_index(fake_make_data_t * const data_make, f_status_t * const status) { + + const int result = fake_execute(data_make->data, data_make->environment, data_make->setting_build.build_indexer, data_make->cache_arguments, status); + + if (F_status_is_error(*status)) { + fll_error_print(data_make->error, F_status_set_fine(*status), "fake_execute", F_true); + } + + if (*status == F_child) return result; + + *status = fake_make_operate_process_return(data_make, result); + + return 0; + } +#endif // _di_fake_make_operate_process_type_index_ + #ifndef _di_fake_make_operate_process_type_link_ f_status_t fake_make_operate_process_type_link(fake_make_data_t * const data_make) { @@ -1215,6 +1479,34 @@ extern "C" { } #endif // _di_fake_make_operate_process_type_move_ +#ifndef _di_fake_make_operate_process_type_operate_ + int fake_make_operate_process_type_operate(fake_make_data_t * const data_make, f_array_lengths_t * const section_stack, f_status_t * const status) { + + f_array_length_t id_section = 0; + + for (; id_section < data_make->fakefile.used; ++id_section) { + + if (fl_string_dynamic_partial_compare_string(data_make->cache_arguments.array[0].string, data_make->buffer, data_make->cache_arguments.array[0].used, data_make->fakefile.array[id_section].name) == F_equal_to) { + break; + } + } // for + + if (id_section == data_make->fakefile.used) return 0; + + const int result = fake_make_operate_section(data_make, id_section, section_stack, status); + + // Ensure that a break only happens within its active state_process->operation stack. + if (*status == F_signal_abort) { + *status = F_none; + } + else if (F_status_set_fine(*status) == F_signal_abort) { + *status = F_status_set_error(F_failure); + } + + return result; + } +#endif // _di_fake_make_operate_process_type_operate_ + #ifndef _di_fake_make_operate_process_type_owners_ f_status_t fake_make_operate_process_type_owners(fake_make_data_t * const data_make, const bool all) { @@ -1450,6 +1742,16 @@ extern "C" { } #endif // _di_fake_make_operate_process_type_print_ +#ifndef _di_fake_make_operate_process_type_skeleton_ + f_status_t fake_make_operate_process_type_skeleton(fake_make_data_t * const data_make) { + + const f_status_t status = fake_skeleton_operate(data_make->data); + if (F_status_set_fine(status) == F_interrupt) return status; + + return fake_make_operate_process_return(data_make, F_status_is_error(status) ? 1 : 0); + } +#endif // _di_fake_make_operate_process_type_skeleton_ + #ifndef _di_fake_make_operate_process_type_to_ f_status_t fake_make_operate_process_type_to(fake_make_data_t * const data_make) { diff --git a/level_3/fake/c/private-make-operate_process_type.h b/level_3/fake/c/private-make-operate_process_type.h index 3d6c862..5b72787 100644 --- a/level_3/fake/c/private-make-operate_process_type.h +++ b/level_3/fake/c/private-make-operate_process_type.h @@ -13,6 +13,99 @@ extern "C" { #endif /** + * Perform the break operations process. + * + * @param data_make + * All make related setting data, including data from the fakefile and the build settings file. + * + * @return + * F_none on success. + * + * F_failure (with error bit) on any error. + */ +#ifndef _di_fake_make_operate_process_type_break_ + extern f_status_t fake_make_operate_process_type_break(fake_make_data_t * const data_make) F_attribute_visibility_internal_d; +#endif // _di_fake_make_operate_process_type_break_ + +/** + * Perform the build operations process. + * + * @param data_make + * All make related setting data, including data from the fakefile and the build settings file. + * + * @return + * F_interrupt (with error bit) on interrupt. + * + * Success from: fake_make_operate_process_return(). + * + * Errors (with error bit) from: fake_make_operate_process_return(). + * + * @see fake_build_operate() + * @see fake_make_operate_process_return() + */ +#ifndef _di_fake_make_operate_process_type_build_ + extern f_status_t fake_make_operate_process_type_build(fake_make_data_t * const data_make) F_attribute_visibility_internal_d; +#endif // _di_fake_make_operate_process_type_build_ + +/** + * Perform the clean operations process. + * + * @param data_make + * All make related setting data, including data from the fakefile and the build settings file. + * + * @return + * F_interrupt (with error bit) on interrupt. + * + * Success from: fake_make_operate_process_return(). + * + * Errors (with error bit) from: fake_make_operate_process_return(). + * + * @see fake_clean_operate() + * @see fake_make_operate_process_return() + */ +#ifndef _di_fake_make_operate_process_type_clean_ + extern f_status_t fake_make_operate_process_type_clean(fake_make_data_t * const data_make) F_attribute_visibility_internal_d; +#endif // _di_fake_make_operate_process_type_clean_ + +/** + * Perform the define operation process. + * + * @param data_make + * All make related setting data, including data from the fakefile and the build settings file. + * @param status + * The status code. + * + * Success from: fake_execute(). + * + * Errors (with error bit) from: fake_execute(). + * + * @return + * The return code of the compile operation. + * + * @see fake_execute() + */ +#ifndef _di_fake_make_operate_process_type_compile_ + extern int fake_make_operate_process_type_compile(fake_make_data_t * const data_make, f_status_t * const status) F_attribute_visibility_internal_d; +#endif // _di_fake_make_operate_process_type_compile_ + +/** + * Perform the if, and, and or operations process. + * + * @param data_make + * All make related setting data, including data from the fakefile and the build settings file. + * @param state_process + * The operation and if-condition states. + * + * @return + * F_none on success. + * + * F_failure (with error bit) on any error. + */ +#ifndef _di_fake_make_operate_process_type_condition_ + extern f_status_t fake_make_operate_process_type_condition(fake_make_data_t * const data_make, fake_state_process_t * const state_process) F_attribute_visibility_internal_d; +#endif // _di_fake_make_operate_process_type_condition_ + +/** * Perform the copy and clone operation processes. * * @param data_make @@ -38,6 +131,23 @@ extern "C" { #endif // _di_fake_make_operate_process_type_copy_ /** + * Perform the define operation process. + * + * @param data_make + * All make related setting data, including data from the fakefile and the build settings file. + * + * @return + * Success from: f_environment_set(). + * + * Errors (with error bit) from: f_environment_set(). + * + * @see f_environment_set() + */ +#ifndef _di_fake_make_operate_process_type_define_ + extern f_status_t fake_make_operate_process_type_define(fake_make_data_t * const data_make) F_attribute_visibility_internal_d; +#endif // _di_fake_make_operate_process_type_define_ + +/** * Perform the delete and deletes operation processes. * * @param data_make @@ -61,6 +171,23 @@ extern "C" { #endif // _di_fake_make_operate_process_type_deletes_ /** + * Perform the exit operation process. + * + * @param data_make + * All make related setting data, including data from the fakefile and the build settings file. + * + * @return + * F_none on unknown exit type (only success and failure are known). + * F_signal_quit to designate exit on success. + * + * F_failure (with error bit) on any error. + * F_signal_quit (with error bit) to designate exit on failure. + */ +#ifndef _di_fake_make_operate_process_type_exit_ + extern f_status_t fake_make_operate_process_type_exit(fake_make_data_t * const data_make) F_attribute_visibility_internal_d; +#endif // _di_fake_make_operate_process_type_exit_ + +/** * Perform the fail operation process. * * @param data_make @@ -261,6 +388,28 @@ extern "C" { #endif // _di_fake_make_operate_process_type_if_parameter_ /** + * Perform the index operation process. + * + * @param data_make + * All make related setting data, including data from the fakefile and the build settings file. + * @param status + * F_child on child process returning. + * + * Success from: fake_make_operate_process_return(). + * + * Errors (with error bit) from: fake_make_operate_process_return(). + * + * @return + * The return code of the index operation. + * + * @see fake_execute() + * @see fake_make_operate_process_return() + */ +#ifndef _di_fake_make_operate_process_type_index_ + extern int fake_make_operate_process_type_index(fake_make_data_t * const data_make, f_status_t * const status) F_attribute_visibility_internal_d; +#endif // _di_fake_make_operate_process_type_index_ + +/** * Perform the link operation processes. * * @param data_make @@ -322,6 +471,29 @@ extern "C" { #endif // _di_fake_make_operate_process_type_move_ /** + * Perform the operate operation process. + * + * @param data_make + * All make related setting data, including data from the fakefile and the build settings file. + * @param section_stack + * The current operation stack. + * @param status + * The status code. + * + * F_none on success. + * + * F_failure (with error bit) on any error. + * + * @return + * The return code of the section operation. + * + * @see fake_make_operate_section() + */ +#ifndef _di_fake_make_operate_process_type_operate_ + extern int fake_make_operate_process_type_operate(fake_make_data_t * const data_make, f_array_lengths_t * const section_stack, f_status_t * const status) F_attribute_visibility_internal_d; +#endif // _di_fake_make_operate_process_type_operate_ + +/** * Perform the owner and owners operation processes. * * @param data_make @@ -410,6 +582,26 @@ extern "C" { #endif // _di_fake_make_operate_process_type_print_ /** + * Perform the skeleton operation process. + * + * @param data_make + * All make related setting data, including data from the fakefile and the build settings file. + * + * @return + * F_interrupt (with error bit) on interrupt. + * + * Success from: fake_make_operate_process_return(). + * + * Errors (with error bit) from: fake_make_operate_process_return(). + * + * @see fake_make_operate_process_return() + * @see fake_skeleton_operate() + */ +#ifndef _di_fake_make_operate_process_type_skeleton_ + extern f_status_t fake_make_operate_process_type_skeleton(fake_make_data_t * const data_make) F_attribute_visibility_internal_d; +#endif // _di_fake_make_operate_process_type_skeleton_ + +/** * Perform the to operation process. * * @param data_make -- 1.8.3.1