From: Kevin Day Date: Sat, 18 Feb 2023 04:41:19 +0000 (-0600) Subject: Progress: Continue program related work, focusing on Featureless Make printing. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=4065c73e32a8466bfda639064f575c3a0cbe3584;p=fll Progress: Continue program related work, focusing on Featureless Make printing. The console program has a bug where the found bit is not being properly preserved for value matches. This is happening due to an incomplete refactor from value assignment to bitwise assignment. Allocate extra space for the terminating NULL. Print message rather than an error when termination signal is received. More print related changes. --- diff --git a/level_0/f_console/c/console.c b/level_0/f_console/c/console.c index a686213..09854b0 100644 --- a/level_0/f_console/c/console.c +++ b/level_0/f_console/c/console.c @@ -216,7 +216,7 @@ extern "C" { if (state.status == F_process) { i = state.needs.array[0]; - parameters->array[i].result = f_console_result_value_e; + parameters->array[i].result |= f_console_result_value_e; parameters->array[i].values.array[parameters->array[i].values.used++] = state.location++; } @@ -436,7 +436,7 @@ extern "C" { parameters->array[i].locations.array[parameters->array[i].locations.used++] = state.location; } - parameters->array[i].result = f_console_result_found_e; + parameters->array[i].result |= state.result | f_console_result_found_e; parameters->array[i].location = state.location; parameters->array[i].location_sub = state.location_sub; parameters->array[i].locations_sub.array[parameters->array[i].locations_sub.used++] = state.location_sub; @@ -603,7 +603,7 @@ extern "C" { state.status = f_array_lengths_increase(state_passed.step_small, ¶meters->array[i].locations_sub); if (F_status_is_error(state.status)) break; - parameters->array[i].result = f_console_result_found_e; + parameters->array[i].result |= state.result | f_console_result_found_e; parameters->array[i].location = state.location; parameters->array[i].location_sub = 0; parameters->array[i].locations.array[parameters->array[i].locations.used++] = state.location; diff --git a/level_3/fake/c/main/common.c b/level_3/fake/c/main/common.c index 93b4e03..a6adff9 100644 --- a/level_3/fake/c/main/common.c +++ b/level_3/fake/c/main/common.c @@ -242,12 +242,14 @@ extern "C" { for (i = 0; i < 9; ++i) { - if (main->parameters.array[parameters[i]].result & f_console_result_found_e) { + if ((main->parameters.array[parameters[i]].result & f_console_result_found_e) && !(main->parameters.array[parameters[i]].result & f_console_result_value_e)) { setting->status = F_status_set_error(F_parameter); - fake_print_line_first_locked(setting, main->error); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fake_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, names[i]); + fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, names[i]); + } return; } @@ -365,12 +367,14 @@ extern "C" { for (i = 0; i < 2; ++i) { - if (main->parameters.array[parameters[i]].result & f_console_result_found_e) { + if ((main->parameters.array[parameters[i]].result & f_console_result_found_e) && !(main->parameters.array[parameters[i]].result & f_console_result_value_e)) { setting->status = F_status_set_error(F_parameter); - fake_print_line_first_locked(setting, main->error); + if (main->error.verbosity > f_console_verbosity_quiet_e) { + fake_print_line_first_locked(setting, main->error); - fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, names[i]); + fll_program_print_error_parameter_missing_value(main->error, f_console_symbol_long_normal_s, names[i]); + } return; } diff --git a/level_3/fake/c/main/fake.c b/level_3/fake/c/main/fake.c index 35dc8e5..0ff025b 100644 --- a/level_3/fake/c/main/fake.c +++ b/level_3/fake/c/main/fake.c @@ -203,7 +203,13 @@ extern "C" { } if (F_status_is_error(setting->status)) { - fake_print_error_failure_operation(setting, main->error, data.operation); + if (F_status_set_fine(setting->status) == F_interrupt) { + fake_print_operation_cancelled(setting, main->message, data.operation); + } + else { + fake_print_error_failure_operation(setting, main->error, data.operation); + } + fake_print_line_last_locked(setting, main->error); } else if (setting->status != F_child) { diff --git a/level_3/fake/c/main/make/load_fakefile.c b/level_3/fake/c/main/make/load_fakefile.c index ff88f83..398c698 100644 --- a/level_3/fake/c/main/make/load_fakefile.c +++ b/level_3/fake/c/main/make/load_fakefile.c @@ -204,7 +204,7 @@ extern "C" { } if (missing_main) { - fake_make_print_error_fakefile_item_missing(data_make->setting, data_make->main->warning, data_make->data->file_data_build_fakefile, fake_make_item_main_s); + fake_make_print_error_fakefile_section_missing(data_make->setting, data_make->main->warning, data_make->data->file_data_build_fakefile, fake_make_item_main_s); *status = F_status_set_error(F_failure); diff --git a/level_3/fake/c/main/make/load_parameters.c b/level_3/fake/c/main/make/load_parameters.c index 8619678..8c21779 100644 --- a/level_3/fake/c/main/make/load_parameters.c +++ b/level_3/fake/c/main/make/load_parameters.c @@ -161,9 +161,9 @@ extern "C" { &data_make->main->parameters.array[fake_parameter_mode_e], }; - const f_string_dynamics_t *source[] = { - &data_make->data->setting->defines, - &data_make->data->setting->modes, + const f_string_dynamics_t source[] = { + data_make->data->setting->defines, + data_make->data->setting->modes, }; f_string_dynamics_t * const destination[] = { @@ -181,14 +181,13 @@ extern "C" { &data_make->parameter_value.mode, }; - uint8_t i = 0; f_array_length_t j = 0; - for (; i < 2; ++i) { + for (uint8_t i = 0; i < 2; ++i) { if (!(console[i]->result & f_console_result_found_e)) continue; - for (j = 0; j < source[i]->used; ++j) { + for (j = 0; j < source[i].used; ++j) { if (destination[i]->used + 2 > destination[i]->size) { *status = f_string_dynamics_increase_by(fake_default_allocation_small_d, destination[i]); @@ -244,10 +243,10 @@ extern "C" { return; } - *status = f_string_dynamic_append_nulless(source[i]->array[j], &destination[i]->array[destination[i]->used]); + *status = f_string_dynamic_append_nulless(source[i].array[j], &destination[i]->array[destination[i]->used]); if (F_status_is_error_not(*status)) { - *status = f_string_dynamic_append_nulless(source[i]->array[j], &destination_value[i]->array[destination_value[i]->used]); + *status = f_string_dynamic_append_nulless(source[i].array[j], &destination_value[i]->array[destination_value[i]->used]); } if (F_status_is_error(*status)) { @@ -275,16 +274,16 @@ extern "C" { fake_short_work_s, }; - const f_console_parameter_t console[] = { - data_make->main->parameters.array[fake_parameter_build_e], - data_make->main->parameters.array[fake_parameter_data_e], - data_make->main->parameters.array[fake_parameter_documents_e], - data_make->main->parameters.array[fake_parameter_fakefile_e], - data_make->main->parameters.array[fake_parameter_licenses_e], - data_make->main->parameters.array[fake_parameter_process_e], - data_make->main->parameters.array[fake_parameter_settings_e], - data_make->main->parameters.array[fake_parameter_sources_e], - data_make->main->parameters.array[fake_parameter_work_e], + const f_console_parameter_t *console[] = { + &data_make->main->parameters.array[fake_parameter_build_e], + &data_make->main->parameters.array[fake_parameter_data_e], + &data_make->main->parameters.array[fake_parameter_documents_e], + &data_make->main->parameters.array[fake_parameter_fakefile_e], + &data_make->main->parameters.array[fake_parameter_licenses_e], + &data_make->main->parameters.array[fake_parameter_process_e], + &data_make->main->parameters.array[fake_parameter_settings_e], + &data_make->main->parameters.array[fake_parameter_sources_e], + &data_make->main->parameters.array[fake_parameter_work_e], }; const f_string_dynamic_t source[] = { @@ -337,7 +336,7 @@ extern "C" { for (uint8_t i = 0; i < 9; ++i) { - if (!(console[i].result & f_console_result_found_e)) continue; + if (!(console[i]->result & f_console_result_found_e)) continue; if (destination[i]->used + 2 > destination[i]->size) { *status = f_string_dynamics_increase_by(fake_default_allocation_small_d, destination[i]); @@ -361,10 +360,10 @@ extern "C" { return; } - if (console[i].flag & f_console_flag_normal_e) { + if (console[i]->flag & f_console_flag_normal_e) { *status = f_string_dynamic_append_nulless(f_console_symbol_short_normal_s, &destination[i]->array[destination[i]->used]); } - else if (console[i].flag & f_console_flag_inverse_e) { + else if (console[i]->flag & f_console_flag_inverse_e) { *status = f_string_dynamic_append_nulless(f_console_symbol_short_inverse_s, &destination[i]->array[destination[i]->used]); } diff --git a/level_3/fake/c/main/make/operate.c b/level_3/fake/c/main/make/operate.c index 7bfd9ea..6235191 100644 --- a/level_3/fake/c/main/make/operate.c +++ b/level_3/fake/c/main/make/operate.c @@ -552,7 +552,7 @@ extern "C" { } // for } // for - *status = f_string_dynamic_increase_by(l, &data_make->cache_arguments.array[data_make->cache_arguments.used]); + *status = f_string_dynamic_increase_by(l + f_string_space_s.used + 1, &data_make->cache_arguments.array[data_make->cache_arguments.used]); if (F_status_is_error(*status)) { fake_print_error(data_make->setting, data_make->main->error, *status, macro_fake_f(f_string_dynamic_increase_by)); @@ -650,7 +650,7 @@ extern "C" { } // for } // for - *status = f_string_dynamic_increase_by(l, &data_make->cache_arguments.array[data_make->cache_arguments.used]); + *status = f_string_dynamic_increase_by(l + f_string_space_s.used + 1, &data_make->cache_arguments.array[data_make->cache_arguments.used]); if (F_status_is_error(*status)) { fake_print_error(data_make->setting, data_make->main->error, *status, macro_fake_f(f_string_dynamic_increase_by)); @@ -826,6 +826,7 @@ extern "C" { f_status_t status = F_none; bool unmatched = F_true; + uint8_t i = 0; data_make->cache_1.used = 0; @@ -842,7 +843,7 @@ extern "C" { data_make->setting_build.version_target, }; - for (uint8_t i = 0; i < 3; ++i) { + for (; i < 3; ++i) { status = fl_string_dynamic_partial_compare_string(uint8_name[i].string, data_make->buffer, uint8_name[i].used, range_name); @@ -877,7 +878,7 @@ extern "C" { data_make->setting_build.search_static, }; - for (uint8_t i = 0; i < 7; ++i) { + for (i = 0; i < 7; ++i) { status = fl_string_dynamic_partial_compare_string(bool_name[i].string, data_make->buffer, bool_name[i].used, range_name); @@ -937,7 +938,7 @@ extern "C" { data_make->setting_build.version_minor, }; - for (uint8_t i = 0; i < 17; ++i) { + for (i = 0; i < 17; ++i) { status = fl_string_dynamic_partial_compare_string(dynamic_name[i].string, data_make->buffer, dynamic_name[i].used, range_name); @@ -1069,14 +1070,16 @@ extern "C" { 0, // modes_default }; - for (uint8_t i = 0; i < 36; ++i) { + f_array_length_t j = 0; + + for (i = 0; i < 36; ++i) { status = fl_string_dynamic_partial_compare_string(dynamics_name[i].string, data_make->buffer, dynamics_name[i].used, range_name); if (status == F_equal_to) { unmatched = F_false; - for (f_array_length_t j = 0; j < dynamics_value[i].used; ++j) { + for (j = 0; j < dynamics_value[i].used; ++j) { status = f_string_dynamic_mash(f_string_space_s, dynamics_value[i].array[j], &data_make->cache_1); if (F_status_is_error(status)) break; @@ -1165,7 +1168,7 @@ extern "C" { data_make->cache_1.used = 0; data_make->cache_2.used = 0; - status = f_string_dynamic_increase_by((range_name.stop - range_name.start) + 1, &data_make->cache_1); + status = f_string_dynamic_increase_by((range_name.stop - range_name.start) + 2, &data_make->cache_1); if (F_status_is_error_not(status)) { status = f_string_dynamic_partial_append_nulless(data_make->buffer, range_name, &data_make->cache_1); @@ -1457,28 +1460,7 @@ extern "C" { if (F_status_set_error(*status) == F_interrupt) return 0; 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->main->error.to.stream) { - f_file_stream_lock(data_make->main->error.to); - - fl_print_format("%r%[%QIncomplete '%]", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); - - if (state_process.operation == fake_make_operation_type_and_e) { - fl_print_format("%[%r%]", data_make->main->error.to, 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->main->error.to, data_make->error.notable, fake_make_operation_else_s, data_make->error.notable); - } - else if (state_process.operation == fake_make_operation_type_if_e) { - fl_print_format("%[%r%]", data_make->main->error.to, data_make->error.notable, fake_make_operation_if_s, data_make->error.notable); - } - else { - fl_print_format("%[%r%]", data_make->main->error.to, data_make->error.notable, fake_make_operation_or_s, data_make->error.notable); - } - - fl_print_format("%[' at end of the section.%]%r", data_make->main->error.to, data_make->error.context, data_make->error.context, f_string_eol_s); - - f_file_stream_unlock(data_make->main->error.to); - } + fake_make_print_error_operation_incomplete(data_make->setting, data_make->main->error, state_process.operation); fake_print_message_section_operation_failed(data_make->setting, data_make->error, data_make->buffer, section->name, section->objects.array[section->objects.used - 1]); diff --git a/level_3/fake/c/main/make/operate_process.c b/level_3/fake/c/main/make/operate_process.c index db43d79..99035c1 100644 --- a/level_3/fake/c/main/make/operate_process.c +++ b/level_3/fake/c/main/make/operate_process.c @@ -6,6 +6,8 @@ #include "operate.h" #include "operate_process.h" #include "operate_process_type.h" +#include "print.h" +#include "print-error.h" #ifdef __cplusplus extern "C" { @@ -320,44 +322,17 @@ extern "C" { } } - if (data_make->main->error.verbosity >= f_console_verbosity_verbose_e) { - f_file_stream_lock(data_make->main->message.to); + fake_make_print_program_verbose(data_make->setting, data_make->main->message, program, arguments); - f_array_length_t i = 0; - - if (program.used) { - f_print_dynamic_safely(program, data_make->main->message.to); - } - else { - i = 1; - - f_print_dynamic_safely(arguments.array[0], data_make->main->message.to); - } - - for (; i < arguments.used; ++i) { - - if (arguments.array[i].used) { - fll_print_format(" %Q", data_make->main->message.to, arguments.array[i]); - } - } // for - - f_print_dynamic_raw(f_string_eol_s, data_make->main->message.to); - - f_file_stream_unlock(data_make->main->message.to); - - // Flush to stdout before executing command. - f_file_stream_flush(data_make->main->message.to); - } - - int return_code = 0; - - // child processes should receive all signals, without blocking. + // Child processes should receive all signals, without blocking. f_signal_how_t signals = f_signal_how_t_initialize; f_signal_set_empty(&signals.block); f_signal_set_fill(&signals.block_not); fl_execute_parameter_t parameter = macro_fl_execute_parameter_t_initialize(as_shell ? 0 : FL_execute_parameter_option_path_d, 0, &data_make->environment, &signals, 0); + int return_code = 0; + status = fll_execute_program(program, arguments, ¶meter, 0, (void *) &return_code); if (fll_program_standard_signal_received(data_make->main)) { @@ -370,15 +345,7 @@ extern "C" { if (F_status_set_fine(status) == F_interrupt) return status; if (F_status_set_fine(status) == F_file_found_not) { - if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - f_file_stream_lock(data_make->main->error.to); - - fl_print_format("%r%[%QFailed to find program '%]", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); - fl_print_format("%[%Q%]", data_make->main->error.to, data_make->error.notable, program, data_make->error.notable); - fl_print_format("%[' for executing.%]%r", data_make->main->error.to, data_make->error.context, data_make->error.context, f_string_eol_s); - - f_file_stream_unlock(data_make->main->error.to); - } + fake_make_print_error_program_not_found(data_make->setting, data_make->main->error, program); } else if (F_status_set_fine(status) != F_failure) { fake_print_error(data_make->setting, data_make->main->error, status, macro_fake_f(fll_execute_program)); @@ -438,15 +405,7 @@ extern "C" { return status; } - if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - f_file_stream_lock(data_make->main->error.to); - - fl_print_format("%r%[%QFailed with return code %]", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); - fl_print_format("%[%i%]", data_make->main->error.to, data_make->error.notable, return_code, data_make->error.notable); - fl_print_format("%[.%]%r", data_make->main->error.to, data_make->error.context, data_make->error.context, f_string_eol_s); - - f_file_stream_unlock(data_make->main->error.to); - } + fake_make_print_error_program_failed(data_make->setting, data_make->main->error, return_code); if (data_make->setting_make.fail == fake_make_operation_fail_exit_e) return F_status_set_error(F_failure); diff --git a/level_3/fake/c/main/make/operate_process_type.c b/level_3/fake/c/main/make/operate_process_type.c index f0fe0ce..a267237 100644 --- a/level_3/fake/c/main/make/operate_process_type.c +++ b/level_3/fake/c/main/make/operate_process_type.c @@ -7,6 +7,9 @@ #include "operate.h" #include "operate_process.h" #include "operate_process_type.h" +#include "print.h" +#include "print-error.h" +#include "print-warning.h" #ifdef __cplusplus extern "C" { @@ -27,15 +30,7 @@ extern "C" { return F_none; } - if (data_make->main->error.verbosity >= f_console_verbosity_verbose_e) { - f_file_stream_lock(data_make->main->message.to); - - fl_print_format("%rBreaking as '", data_make->main->message.to, f_string_eol_s); - fl_print_format("%[%Q%]", data_make->main->message.to, 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->message.to, f_string_eol_s); - - f_file_stream_unlock(data_make->main->message.to); - } + fake_make_print_operate_break_verbose(data_make->setting, data_make->main->message, data_make->cache_arguments); return status; } @@ -324,14 +319,7 @@ extern "C" { return F_status_set_error(F_failure); } - if (data_make->main->error.verbosity >= f_console_verbosity_verbose_e) { - f_file_stream_lock(data_make->main->message.to); - - fl_print_format("%r%s '%[%Q%]' to '", data_make->main->message.to, f_string_eol_s, clone ? "Cloned" : "Copied", data_make->main->context.set.notable, data_make->cache_arguments.array[i], data_make->main->context.set.notable); - fl_print_format("%[%Q%]'.%r", data_make->main->message.to, data_make->main->context.set.notable, destination, data_make->main->context.set.notable, f_string_eol_s); - - f_file_stream_unlock(data_make->main->message.to); - } + fake_make_print_operate_copy_verbose(data_make->setting, data_make->main->message, clone, data_make->cache_arguments.array[i], destination); } else if (F_status_is_error(status_file)) { fake_print_error_file(data_make->setting, data_make->main->error, status_file, macro_fake_f(f_directory_is), data_make->cache_arguments.array[i], f_file_operation_identify_s, fll_error_file_type_directory_e); @@ -359,8 +347,8 @@ extern "C" { if (F_status_is_error(status)) { fake_print_error(data_make->setting, data_make->main->error, status, macro_fake_f(f_environment_set)); } - else if (data_make->main->error.verbosity >= f_console_verbosity_verbose_e) { - fll_print_format("%rDefined environment variable '%[%Q%]'.%r", data_make->main->message.to, 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); + else { + fake_make_print_operate_define_verbose(data_make->setting, data_make->main->message, data_make->cache_arguments.array[0]); } return status; @@ -383,15 +371,7 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_file_found_not) { - if (data_make->main->warning.verbosity >= f_console_verbosity_verbose_e) { - f_file_stream_lock(data_make->main->warning.to); - - fl_print_format("%r%[%QThe file '%]", data_make->main->warning.to, data_make->main->warning.prefix, f_string_eol_s); - fl_print_format("%[%Q%]", data_make->main->warning.to, data_make->main->warning.notable, data_make->cache_arguments.array[i], data_make->main->warning.notable); - fl_print_format("%[' cannot be found.%]%r", data_make->main->warning.to, f_string_eol_s); - - f_file_stream_unlock(data_make->main->warning.to); - } + fake_make_print_warning_file_not_found(data_make->setting, data_make->main->warning, data_make->cache_arguments.array[i]); status = F_none; } @@ -410,9 +390,7 @@ extern "C" { } if (F_status_set_fine(status) == F_file_found_not) { - if (data_make->main->error.verbosity >= f_console_verbosity_verbose_e) { - fll_print_format("%rThe directory '%[%Q%]' does not exist.%r", data_make->main->message.to, f_string_eol_s, data_make->main->context.set.notable, data_make->cache_arguments.array[i], data_make->main->context.set.notable, f_string_eol_s); - } + fake_make_print_operate_file_not_found_verbose(data_make->setting, data_make->main->message, F_true, data_make->cache_arguments.array[i]); status = F_none; } @@ -422,17 +400,13 @@ extern "C" { return F_status_set_error(F_failure); } - - if (data_make->main->error.verbosity >= f_console_verbosity_verbose_e) { - fll_print_format("%rRemoved '%[%Q%]'.%r", data_make->main->message.to, f_string_eol_s, data_make->main->context.set.notable, data_make->cache_arguments.array[i], data_make->main->context.set.notable, f_string_eol_s); - } } else { status = f_file_remove(data_make->cache_arguments.array[i]); if (F_status_set_fine(status) == F_file_found_not) { if (data_make->main->error.verbosity >= f_console_verbosity_verbose_e) { - fll_print_format("%rThe file '%[%Q%]' does not exist.%r", data_make->main->message.to, f_string_eol_s, data_make->main->context.set.notable, data_make->cache_arguments.array[i], data_make->main->context.set.notable, f_string_eol_s); + fake_make_print_operate_file_not_found_verbose(data_make->setting, data_make->main->message, F_false, data_make->cache_arguments.array[i]); } status = F_none; @@ -443,11 +417,9 @@ extern "C" { return F_status_set_error(F_failure); } - - if (data_make->main->error.verbosity >= f_console_verbosity_verbose_e) { - fll_print_format("%rRemoved '%[%Q%]'.%r", data_make->main->message.to, f_string_eol_s, data_make->main->context.set.notable, data_make->cache_arguments.array[i], data_make->main->context.set.notable, f_string_eol_s); - } } + + fake_make_print_operate_delete_verbose(data_make->setting, data_make->main->message, data_make->cache_arguments.array[i]); } // for return F_none; diff --git a/level_3/fake/c/main/make/print-error.c b/level_3/fake/c/main/make/print-error.c index 28c2e14..78d9238 100644 --- a/level_3/fake/c/main/make/print-error.c +++ b/level_3/fake/c/main/make/print-error.c @@ -43,8 +43,8 @@ extern "C" { } #endif // _di_fake_make_print_error_define_invalid_character_ -#ifndef _di_fake_make_print_error_fakefile_item_missing_ - f_status_t fake_make_print_error_fakefile_item_missing(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t fakefile, const f_string_static_t item) { +#ifndef _di_fake_make_print_error_fakefile_section_missing_ + f_status_t fake_make_print_error_fakefile_section_missing(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t fakefile, const f_string_static_t section) { if (print.verbosity < f_console_verbosity_error_e) return F_output_not; @@ -55,14 +55,80 @@ extern "C" { fl_print_format("%[%QThe fakefile '%]", print.to, print.context, print.prefix, print.context); fl_print_format("%[%Q%]", print.to, print.notable, fakefile, print.notable); fl_print_format("%[' is missing the required '%]", print.to, print.context, print.context); - fl_print_format("%[%r%]", print.to, print.notable, item, print.notable); - fl_print_format("%[' item.%]%r", print.to, print.context, print.context, f_string_eol_s); + fl_print_format("%[%r%]", print.to, print.notable, section, print.notable); + fl_print_format("%[' section.%]%r", print.to, print.context, print.context, f_string_eol_s); f_file_stream_unlock(print.to); return F_none; } -#endif // _di_fake_make_print_error_fakefile_item_missing_ +#endif // _di_fake_make_print_error_fakefile_section_missing_ + +#ifndef _di_fake_make_print_error_operation_incomplete_ + f_status_t fake_make_print_error_operation_incomplete(fake_setting_t * const setting, const fl_print_t print, const uint8_t operation) { + + if (print.verbosity < f_console_verbosity_error_e) return F_output_not; + + f_file_stream_lock(print.to); + + fake_print_line_first_unlocked(setting, print); + + fl_print_format("%[%QIncomplete '%]", print.to, print.context, print.prefix, print.context); + + if (operation == fake_make_operation_type_and_e) { + fl_print_format("%[%r%]", print.to, print.notable, fake_make_operation_and_s, print.notable); + } + else if (operation == fake_make_operation_type_else_e) { + fl_print_format("%[%r%]", print.to, print.notable, fake_make_operation_else_s, print.notable); + } + else if (operation == fake_make_operation_type_if_e) { + fl_print_format("%[%r%]", print.to, print.notable, fake_make_operation_if_s, print.notable); + } + else { + fl_print_format("%[%r%]", print.to, print.notable, fake_make_operation_or_s, print.notable); + } + + fl_print_format("%[' at end of the section.%]%r", print.to, print.context, print.context, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fake_make_print_error_operation_incomplete_ + +#ifndef _di_fake_make_print_error_program_failed_ + f_status_t fake_make_print_error_program_failed(fake_setting_t * const setting, const fl_print_t print, const int return_code) { + + if (print.verbosity < f_console_verbosity_error_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%[%QFailed with return code %]", print.to, print.context, print.prefix, print.context); + fl_print_format("%[%i%]", print.to, print.notable, return_code, print.notable); + fl_print_format("%[.%]%r", print.to, print.context, print.context, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fake_make_print_error_program_failed_ + +#ifndef _di_fake_make_print_error_program_not_found_ + f_status_t fake_make_print_error_program_not_found(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t program) { + + if (print.verbosity < f_console_verbosity_error_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%[%QFailed to find program '%]", print.to, print.context, print.prefix, print.context); + fl_print_format("%[%Q%]", print.to, print.notable, program, print.notable); + fl_print_format("%[' for executing.%]%r", print.to, print.context, print.context, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fake_make_print_error_program_not_found_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fake/c/main/make/print-error.h b/level_3/fake/c/main/make/print-error.h index d1a76bd..c3ba456 100644 --- a/level_3/fake/c/main/make/print-error.h +++ b/level_3/fake/c/main/make/print-error.h @@ -72,16 +72,79 @@ extern "C" { * The output structure to print to. * @param fakefile * The name or path of the file that is empty. - * @param item + * @param section * The name of the missing section. * * @return * F_none on success. * F_output_not on success, but no printing is performed. */ -#ifndef _di_fake_make_print_error_fakefile_item_missing_ - extern f_status_t fake_make_print_error_fakefile_item_missing(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t fakefile, const f_string_static_t item); -#endif // _di_fake_make_print_error_fakefile_item_missing_ +#ifndef _di_fake_make_print_error_fakefile_section_missing_ + extern f_status_t fake_make_print_error_fakefile_section_missing(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t fakefile, const f_string_static_t section); +#endif // _di_fake_make_print_error_fakefile_section_missing_ + +/** + * Print error about an incomplete operation at the end of a section. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param operation + * The code of the operation. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_error_operation_incomplete_ + extern f_status_t fake_make_print_error_operation_incomplete(fake_setting_t * const setting, const fl_print_t print, const uint8_t operation); +#endif // _di_fake_make_print_error_operation_incomplete_ + +/** + * Print error about program failed. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param return_code + * The return code from the program. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_error_program_failed_ + extern f_status_t fake_make_print_error_program_failed(fake_setting_t * const setting, const fl_print_t print, const int return_code); +#endif // _di_fake_make_print_error_program_failed_ + +/** + * Print error about program not being found. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param program + * The program name. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_error_program_not_found_ + extern f_status_t fake_make_print_error_program_not_found(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t program); +#endif // _di_fake_make_print_error_program_not_found_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fake/c/main/make/print-warning.c b/level_3/fake/c/main/make/print-warning.c index 26ec6fc..dbda387 100644 --- a/level_3/fake/c/main/make/print-warning.c +++ b/level_3/fake/c/main/make/print-warning.c @@ -83,6 +83,23 @@ extern "C" { } #endif // _di_fake_make_print_warning_fakefile_empty_ +#ifndef _di_fake_make_print_warning_file_not_found_ + f_status_t fake_make_print_warning_file_not_found(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t file) { + + if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; + + f_file_stream_lock(print.to); + + fl_print_format("%[%QThe file '%]", print.to, print.context, print.prefix, print.context); + fl_print_format("%[%Q%]", print.to, print.notable, file, print.notable); + fl_print_format("%[' cannot be found.%]%r", print.to, print.context, print.prefix, print.context, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fake_make_print_warning_file_not_found_ + #ifndef _di_fake_make_print_warning_settings_content_empty_ f_status_t fake_make_print_warning_settings_content_empty(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t fakefile, const f_string_dynamic_t buffer, const f_string_range_t range, const f_string_static_t name) { diff --git a/level_3/fake/c/main/make/print-warning.h b/level_3/fake/c/main/make/print-warning.h index b9cd742..cbbaa06 100644 --- a/level_3/fake/c/main/make/print-warning.h +++ b/level_3/fake/c/main/make/print-warning.h @@ -99,6 +99,27 @@ extern "C" { #endif // _di_fake_make_print_warning_fakefile_empty_ /** + * Print warning about a file not being found. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param file + * The name or path of the file that is not found. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_warning_file_not_found_ + extern f_status_t fake_make_print_warning_file_not_found(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t file); +#endif // _di_fake_make_print_warning_file_not_found_ + +/** * Print message when fake settings content is empty. * * @param setting diff --git a/level_3/fake/c/main/make/print.c b/level_3/fake/c/main/make/print.c index a90ea05..0948973 100644 --- a/level_3/fake/c/main/make/print.c +++ b/level_3/fake/c/main/make/print.c @@ -38,6 +38,94 @@ extern "C" { } #endif // _di_fake_make_print_now_making_ +#ifndef _di_fake_make_print_operate_break_verbose_ + f_status_t fake_make_print_operate_break_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_statics_t arguments) { + + if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; + + f_file_stream_lock(print.to); + + fake_print_line_first_unlocked(setting, print); + + fl_print_format("Breaking as '", print.to); + fl_print_format("%[%Q%]", print.to, print.set->notable, arguments.used ? arguments.array[0] : fake_make_operation_argument_success_s, print.set->notable); + fl_print_format("'.%r", print.to, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fake_make_print_operate_break_verbose_ + +#ifndef _di_fake_make_print_operate_copy_verbose_ + f_status_t fake_make_print_operate_copy_verbose(fake_setting_t * const setting, const fl_print_t print, const bool clone, const f_string_static_t source, const f_string_static_t destination) { + + if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; + + f_file_stream_lock(print.to); + + fake_print_line_first_unlocked(setting, print); + + fl_print_format("%s '%[%Q%]' to '", print.to, clone ? "Cloned" : "Copied", print.set->notable, source, print.set->notable); + fl_print_format("%[%Q%]'.%r", print.to, print.set->notable, destination, print.set->notable, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fake_make_print_operate_copy_verbose_ + +#ifndef _di_fake_make_print_operate_define_verbose_ + f_status_t fake_make_print_operate_define_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t variable) { + + if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; + + f_file_stream_lock(print.to); + + fake_print_line_first_unlocked(setting, print); + + fll_print_format("Defined environment variable '%[%Q%]'.%r", print.to, print.set->notable, variable, print.set->notable, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fake_make_print_operate_define_verbose_ + +#ifndef _di_fake_make_print_operate_delete_verbose_ + f_status_t fake_make_print_operate_delete_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t path) { + + if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; + + f_file_stream_lock(print.to); + + fake_print_line_first_unlocked(setting, print); + + fll_print_format("Removed '%[%Q%]'.%r", print.to, print.set->notable, path, print.set->notable, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fake_make_print_operate_delete_verbose_ + +#ifndef _di_fake_make_print_operate_file_not_found_verbose_ + f_status_t fake_make_print_operate_file_not_found_verbose(fake_setting_t * const setting, const fl_print_t print, const bool is_directory, const f_string_static_t file) { + + if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; + + f_file_stream_lock(print.to); + + fake_print_line_first_unlocked(setting, print); + + fl_print_format("The %s '%[%Q%]' is not found.%]%r", print.to, print.notable, is_directory ? "directory" : "file", file, print.notable, f_string_eol_s); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fake_make_print_operate_file_not_found_verbose_ + #ifndef _di_fake_make_print_processing_section_ f_status_t fake_make_print_processing_section(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t buffer, const f_fss_named_t section) { @@ -57,6 +145,39 @@ extern "C" { } #endif // _di_fake_make_print_processing_section_ +#ifndef _di_fake_make_print_program_verbose_ + f_status_t fake_make_print_program_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t program, const f_string_statics_t arguments) { + + if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; + + f_file_stream_lock(print.to); + + f_array_length_t i = 0; + + if (program.used) { + f_print_dynamic_safely(program, print.to); + } + else { + i = 1; + + f_print_dynamic_safely(arguments.array[0], print.to); + } + + for (; i < arguments.used; ++i) { + if (arguments.array[i].used) fll_print_format(" %Q", print.to, arguments.array[i]); + } // for + + f_print_dynamic_raw(f_string_eol_s, print.to); + + // Flush to stdout before executing command. + f_file_stream_flush(print.to); + + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fake_make_print_program_verbose_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fake/c/main/make/print.h b/level_3/fake/c/main/make/print.h index 7814abb..36f0982 100644 --- a/level_3/fake/c/main/make/print.h +++ b/level_3/fake/c/main/make/print.h @@ -34,6 +34,119 @@ extern "C" { #endif // _di_fake_make_print_now_making_ /** + * Print operate break verbose message. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param arguments + * The arguments passed to the break operation. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_operate_break_verbose_ + extern f_status_t fake_make_print_operate_break_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_statics_t arguments); +#endif // _di_fake_make_print_operate_break_verbose_ + +/** + * Print operate copy verbose message. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param clone + * If TRUE, then this is a clone operation. + * If FALSE< then this is a copy operation. + * @param source + * The source to copy from. + * @param destination + * The destination to copy to. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_operate_copy_verbose_ + extern f_status_t fake_make_print_operate_copy_verbose(fake_setting_t * const setting, const fl_print_t print, const bool clone, const f_string_static_t source, const f_string_static_t destination); +#endif // _di_fake_make_print_operate_copy_verbose_ + +/** + * Print operate define verbose message. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param variable + * The environment variable name. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_operate_define_verbose_ + extern f_status_t fake_make_print_operate_define_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t variable); +#endif // _di_fake_make_print_operate_define_verbose_ + +/** + * Print operate delete verbose message. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param path + * The path or file that is deleted. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_operate_delete_verbose_ + extern f_status_t fake_make_print_operate_delete_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t path); +#endif // _di_fake_make_print_operate_delete_verbose_ + +/** + * Print operate file or directory not found verbose message. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param is_directory + * If TRUE, then the file is type directory. + * If FALSE, then the file is type regular. + * @param file + * The file or directory path or name. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_operate_file_not_found_verbose_ + extern f_status_t fake_make_print_operate_file_not_found_verbose(fake_setting_t * const setting, const fl_print_t print, const bool is_directory, const f_string_static_t file); +#endif // _di_fake_make_print_operate_file_not_found_verbose_ + +/** * Print the processing section message. * * @param setting @@ -56,6 +169,29 @@ extern "C" { extern f_status_t fake_make_print_processing_section(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t buffer, const f_fss_named_t section); #endif // _di_fake_make_print_processing_section_ +/** + * Print verbose program message. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param program + * The program name. + * @param arguments + * The arguments pass to the program. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_program_verbose_ + extern f_status_t fake_make_print_program_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t program, const f_string_statics_t arguments); +#endif // _di_fake_make_print_program_verbose_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fake/c/main/print.c b/level_3/fake/c/main/print.c index ce366c5..2dd31ca 100644 --- a/level_3/fake/c/main/print.c +++ b/level_3/fake/c/main/print.c @@ -353,6 +353,39 @@ extern "C" { } #endif // _di_fake_print_operation_all_complete_ +#ifndef _di_fake_print_operation_cancelled_ + f_status_t fake_print_operation_cancelled(fake_setting_t * const setting, const fl_print_t print, const uint8_t operation) { + + if (!setting || print.verbosity < f_console_verbosity_normal_e) return F_output_not; + + f_file_stream_lock(print.to); + + fake_print_line_first_unlocked(setting, print); + + fl_print_format("%[The operation '%]%[", print.to, print.context, print.context, print.notable); + + if (operation == fake_operation_build_e) { + f_print_dynamic(fake_other_operation_build_s, print.to); + } + else if (operation == fake_operation_clean_e) { + f_print_dynamic(fake_other_operation_clean_s, print.to); + } + else if (operation == fake_operation_make_e) { + f_print_dynamic(fake_other_operation_make_s, print.to); + } + else if (operation == fake_operation_skeleton_e) { + f_print_dynamic(fake_other_operation_skeleton_s, print.to); + } + + fl_print_format("%]%[' is cancelled.%]%r", print.to, print.notable, print.context, print.context, f_string_eol_s); + + f_file_stream_flush(print.to); + f_file_stream_unlock(print.to); + + return F_none; + } +#endif // _di_fake_print_operation_cancelled_ + #ifndef _di_fake_print_error_build_operation_file_ f_status_t fake_print_error_build_operation_file(fake_setting_t * const setting, const fl_print_t print, const f_status_t status, const f_string_t function, const f_string_static_t operation, const f_string_static_t source, const f_string_static_t destination, const f_string_static_t how, const bool fallback) { @@ -677,25 +710,6 @@ extern "C" { } #endif // _di_fake_print_error_fss -#ifndef _di_fake_print_error_parameter_missing_value_ - f_status_t fake_print_error_parameter_missing_value(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t parameter) { - - if (print.verbosity == f_console_verbosity_quiet_e) return F_output_not; - - f_file_stream_lock(print.to); - - fake_print_line_first_unlocked(setting, print); - - fl_print_format("%[%QThe parameter '%]", print.to, print.context, print.prefix, print.context); - fl_print_format("%[%r%r%]", print.to, print.notable, f_console_symbol_long_normal_s, parameter, print.notable); - fl_print_format("%[' is specified, but no value is given.%]%r", print.to, print.context, print.context, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; - } -#endif // _di_fake_print_error_parameter_missing_value_ - #ifndef _di_fake_print_error_parameter_too_many_ f_status_t fake_print_error_parameter_too_many(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t parameter) { diff --git a/level_3/fake/c/main/print.h b/level_3/fake/c/main/print.h index 5558465..bb943b0 100644 --- a/level_3/fake/c/main/print.h +++ b/level_3/fake/c/main/print.h @@ -361,6 +361,26 @@ extern "C" { #endif // _di_fake_print_operation_all_complete_ /** + * Print message for when the operation is cancelled. + * + * @param setting + * The main program settings. + * + * This does not alter setting.status. + * @param print + * Designates the how and where to print. + * @param operation + * The identifier of the operation that failed. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_print_operation_cancelled_ + extern f_status_t fake_print_operation_cancelled(fake_setting_t * const setting, const fl_print_t print, const uint8_t operation); +#endif // _di_fake_print_operation_cancelled_ + +/** * Print build operation file error messages. * * @param setting @@ -462,30 +482,6 @@ extern "C" { #endif // _di_fake_print_error_fss_ /** - * Print an error message for when the parameter is missing its accompanying value. - * - * @param setting - * The main program settings. - * - * This does not alter setting.status. - * @param print - * Designates the how and where to print. - * @param parameter - * The parameter name. - * - * @return - * F_none on success. - * F_output_not on success, but no printing is performed. - * - * @see f_file_stream_lock() - * @see f_file_stream_unlock() - * @see fl_print_format() - */ -#ifndef _di_fake_print_error_parameter_missing_value_ - extern f_status_t fake_print_error_parameter_missing_value(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t parameter); -#endif // _di_fake_print_error_parameter_missing_value_ - -/** * Print an error message for when the parameter is specified too many times. * * @param data