From c8ef6ca0fc9b3d9419ebd326bf4f7be124600aa8 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 22 Aug 2020 20:31:05 -0500 Subject: [PATCH] Progress: featureless make. Begin adding support for more complicated section operations. Add break/exit to allow for manually exiting or breaking. The error/warning systems needed to be rewritten to handle additional situations where "fail" mode is set to "warn" or "ignore" instead of "exit". Errors may need to be warnings or not printed at all. I noticed that I have been, perhaps habitually, using the system include path logic for including headers in the local source. This is dangerous. Avoid the possibility of including headers from the system that are actually headers provided by the project itself. Other minor fixes and cleanups. --- level_3/fake/c/fake.c | 2 +- level_3/fake/c/private-build.c | 3 +- level_3/fake/c/private-clean.c | 4 +- level_3/fake/c/private-fake.c | 4 +- level_3/fake/c/private-make.c | 729 ++++++++++++++++++++++--------- level_3/fake/c/private-make.h | 37 +- level_3/fake/c/private-print.c | 619 +++++++++++++------------- level_3/fake/c/private-print.h | 289 +++++++----- level_3/fake/c/private-skeleton.c | 3 +- level_3/fake/documents/fakefile.txt | 78 +++- level_3/fake/specifications/fakefile.txt | 31 +- 11 files changed, 1176 insertions(+), 623 deletions(-) diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index a35e47b..209cc88 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -1,4 +1,4 @@ -#include +#include "fake.h" #include "private-fake.h" #include "private-build.h" #include "private-clean.h" diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index 4c9a6e5..3810bb0 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -1,6 +1,7 @@ -#include +#include "fake.h" #include "private-fake.h" #include "private-build.h" +#include "private-make.h" #include "private-print.h" #ifdef __cplusplus diff --git a/level_3/fake/c/private-clean.c b/level_3/fake/c/private-clean.c index c906c10..f212c14 100644 --- a/level_3/fake/c/private-clean.c +++ b/level_3/fake/c/private-clean.c @@ -1,6 +1,8 @@ -#include +#include "fake.h" #include "private-fake.h" +#include "private-build.h" #include "private-clean.h" +#include "private-make.h" #include "private-print.h" #ifdef __cplusplus diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 9b86ed8..50a93bd 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -1,5 +1,7 @@ -#include +#include "fake.h" #include "private-fake.h" +#include "private-build.h" +#include "private-make.h" #include "private-print.h" #ifdef __cplusplus diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index 8f385b5..3c87323 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -1,4 +1,4 @@ -#include +#include "fake.h" #include "private-fake.h" #include "private-build.h" #include "private-clean.h" @@ -232,7 +232,7 @@ extern "C" { for (f_array_length i = 0; i < list_objects.used; i++) { if (fl_string_dynamic_partial_compare(name_settings, data_make->buffer, name_settings_range, list_objects.array[i]) == F_equal_to) { if (!missing_settings) { - fake_print_warning_fakefile_object_multiple(data, data.file_data_build_fakefile.string, "list", name_settings.string); + fake_print_warning_settings_object_multiple(data, data.file_data_build_fakefile.string, "list", name_settings.string); continue; } @@ -253,7 +253,7 @@ extern "C" { } else if (fl_string_dynamic_partial_compare(name_main, data_make->buffer, name_main_range, list_objects.array[i]) == F_equal_to) { if (!missing_main) { - fake_print_warning_fakefile_object_multiple(data, data.file_data_build_fakefile.string, "list", name_main.string); + fake_print_warning_settings_object_multiple(data, data.file_data_build_fakefile.string, "list", name_main.string); continue; } @@ -359,7 +359,7 @@ extern "C" { } } else { - fake_print_error_fakefile_settings_content_empty(data, data.file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], fake_make_section_settings); + fake_print_warning_settings_content_empty(data, data.file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], fake_make_section_settings); } } } @@ -473,7 +473,7 @@ extern "C" { data_make->setting_make.fail = fake_make_operation_fail_type_ignore; } else { - fake_print_error_fakefile_settings_content_invalid(data, data.file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], settings.contents.array[i].array[0], fake_make_section_settings); + fake_print_warning_settings_content_invalid(data, data.file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], settings.contents.array[i].array[0], fake_make_section_settings); } if (settings.contents.array[i].used > 1) { @@ -483,7 +483,7 @@ extern "C" { unmatched_fail = F_false; } else { - fake_print_error_fakefile_settings_content_empty(data, data.file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], fake_make_section_settings); + fake_print_warning_settings_content_empty(data, data.file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], fake_make_section_settings); } } else { @@ -503,7 +503,7 @@ extern "C" { } } else { - fake_print_error_fakefile_settings_content_empty(data, data.file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], fake_make_section_settings); + fake_print_warning_settings_content_empty(data, data.file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], fake_make_section_settings); } } } @@ -517,7 +517,7 @@ extern "C" { data_make->setting_make.load_build = F_false; } else { - fake_print_error_fakefile_settings_content_invalid(data, data.file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], settings.contents.array[i].array[0], fake_make_section_settings); + fake_print_warning_settings_content_invalid(data, data.file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], settings.contents.array[i].array[0], fake_make_section_settings); } unmatched_load = F_false; @@ -527,7 +527,7 @@ extern "C" { } } else { - fake_print_error_fakefile_settings_content_empty(data, data.file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], fake_make_section_settings); + fake_print_warning_settings_content_empty(data, data.file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], fake_make_section_settings); } } else { @@ -568,7 +568,7 @@ extern "C" { } } else { - fake_print_error_fakefile_settings_content_empty(data, data.file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], fake_make_section_settings); + fake_print_warning_settings_content_empty(data, data.file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], fake_make_section_settings); } } } // for @@ -731,6 +731,20 @@ extern "C" { fake_make_load_fakefile(data, &data_make, &status); + if (data_make.setting_make.fail == fake_make_operation_fail_type_exit) { + data_make.print.prefix = fake_make_print_error; + data_make.print.context = data.context.error; + data_make.print.to = f_type_error; + } + else if (data_make.setting_make.fail == fake_make_operation_fail_type_warn) { + data_make.print.prefix = fake_make_print_warning; + data_make.print.context = data.context.warning; + data_make.print.to = f_type_warning; + } + else { + data_make.print.to = 0; + } + fake_make_operate_section(data, data_make.main, &data_make, &list_stack, &status); if (data_make.path.current > 0) { @@ -1398,6 +1412,7 @@ extern "C" { const f_string_static operations_name[] = { f_macro_string_static_initialize(fake_make_operation_archive, fake_make_operation_archive_length), + f_macro_string_static_initialize(fake_make_operation_break, fake_make_operation_break_length), f_macro_string_static_initialize(fake_make_operation_build, fake_make_operation_build_length), f_macro_string_static_initialize(fake_make_operation_clean, fake_make_operation_clean_length), f_macro_string_static_initialize(fake_make_operation_compile, fake_make_operation_compile_length), @@ -1405,6 +1420,7 @@ extern "C" { f_macro_string_static_initialize(fake_make_operation_delete, fake_make_operation_delete_length), f_macro_string_static_initialize(fake_make_operation_deletes, fake_make_operation_deletes_length), f_macro_string_static_initialize(fake_make_operation_else, fake_make_operation_else_length), + f_macro_string_static_initialize(fake_make_operation_exit, fake_make_operation_exit_length), f_macro_string_static_initialize(fake_make_operation_fail, fake_make_operation_fail_length), f_macro_string_static_initialize(fake_make_operation_group, fake_make_operation_group_length), f_macro_string_static_initialize(fake_make_operation_groups, fake_make_operation_groups_length), @@ -1427,6 +1443,7 @@ extern "C" { const f_string_range operations_range[] = { f_macro_string_range_initialize(fake_make_operation_archive_length), + f_macro_string_range_initialize(fake_make_operation_break_length), f_macro_string_range_initialize(fake_make_operation_build_length), f_macro_string_range_initialize(fake_make_operation_clean_length), f_macro_string_range_initialize(fake_make_operation_compile_length), @@ -1434,6 +1451,7 @@ extern "C" { f_macro_string_range_initialize(fake_make_operation_delete_length), f_macro_string_range_initialize(fake_make_operation_deletes_length), f_macro_string_range_initialize(fake_make_operation_else_length), + f_macro_string_range_initialize(fake_make_operation_exit_length), f_macro_string_range_initialize(fake_make_operation_fail_length), f_macro_string_range_initialize(fake_make_operation_group_length), f_macro_string_range_initialize(fake_make_operation_groups_length), @@ -1456,6 +1474,7 @@ extern "C" { const uint8_t operations_type[] = { fake_make_operation_type_archive, + fake_make_operation_type_break, fake_make_operation_type_build, fake_make_operation_type_clean, fake_make_operation_type_compile, @@ -1463,6 +1482,7 @@ extern "C" { fake_make_operation_type_delete, fake_make_operation_type_deletes, fake_make_operation_type_else, + fake_make_operation_type_exit, fake_make_operation_type_fail, fake_make_operation_type_group, fake_make_operation_type_groups, @@ -1497,7 +1517,7 @@ extern "C" { memset(operations, 0, sizeof(uint8_t) * section->objects.used); memset(arguments, 0, sizeof(f_string_dynamics) * section->objects.used); - for (i = 0; i < section->objects.used; i++) { + for (i = 0; i < section->objects.used; i++, *status = F_none) { operation = 0; operation_name = 0; @@ -1510,53 +1530,92 @@ extern "C" { } // for if (operation == 0) { - fake_print_error_fakefile_section_operation_unknown(data, data_make->buffer, section->name, section->objects.array[i]); + fake_print_message_section_operation_unknown(data, data_make->buffer, section->name, section->objects.array[i], data_make->print); *status = F_status_set_error(F_invalid); } else if (operation == fake_make_operation_type_operate) { if (section_stack->used == fake_make_section_stack_max) { - fake_print_error_fakefile_section_operation_stack_max(data, data_make->buffer, section->name, section->objects.array[i], fake_make_section_stack_max); + fake_print_message_section_operation_stack_max(data, data_make->buffer, section->name, section->objects.array[i], fake_make_section_stack_max, data_make->print); *status = F_status_set_error(F_recurse); } } - if (F_status_is_error(*status)) break; - - operations[i] = operation; + if (F_status_is_fine(*status)) { + operations[i] = operation; - fake_make_operate_expand(data, section->name, operation, *operation_name, section->contents.array[i], section->quotedss.array[i], data_make, &arguments[i], status); - if (F_status_is_error(*status)) break; + fake_make_operate_expand(data, section->name, operation, *operation_name, section->contents.array[i], section->quotedss.array[i], data_make, &arguments[i], status); - fake_make_operate_validate(data, section->name, operation, *operation_name, arguments[i], operation_if, data_make, status); + if (F_status_is_fine(*status)) { + fake_make_operate_validate(data, section->name, operation, *operation_name, arguments[i], operation_if, data_make, status); - if (operation_if) { - if (operation_if == fake_make_operation_if_type_if) { - operation_if = fake_make_operation_if_type_else; - } - else if (operation_if == fake_make_operation_if_type_else) { - if (operation == fake_make_operation_type_if) { + if (operation_if) { + if (operation_if == fake_make_operation_if_type_if) { + operation_if = fake_make_operation_if_type_else; + } + else if (operation_if == fake_make_operation_if_type_else) { + if (operation == fake_make_operation_type_if) { + operation_if = fake_make_operation_if_type_if; + } + else { + operation_if = 0; + } + } + else { + operation_if = 0; + } + } + else if (operation == fake_make_operation_type_if) { operation_if = fake_make_operation_if_type_if; } - else { - operation_if = 0; + + if (F_status_is_fine(*status)) { + fake_make_operate_process(data, section->name, operation, *operation_name, arguments[i], operation_if, data_make, status); } } - else { - operation_if = 0; - } - } - else if (operation == fake_make_operation_type_if) { - operation_if = fake_make_operation_if_type_if; } - if (F_status_is_fine(*status)) { - fake_make_operate_process(data, section->name, operation, *operation_name, arguments[i], operation_if, data_make, status); + if (F_status_is_error(*status)) { + + // break acts identical to fail when at the top of the stack. + if (F_status_set_fine(*status) == F_signal_abort && section_stack->used == 0) { + data_make->setting_make.fail = fake_make_operation_fail_type_exit; + data_make->print.prefix = fake_make_print_error; + data_make->print.context = data.context.error; + data_make->print.to = f_type_error; + } + + fake_print_message_section_operation_failed(data, data_make->buffer, section->name, section->objects.array[i], data_make->print); + + // F_signal_abort is used by the break section operation. + if (F_status_set_fine(*status) == F_signal_abort) { + break; + } + + // F_signal_abort is used by the exit section operation. + if (F_status_set_fine(*status) == F_signal_quit) { + if (section_stack->used == 0) { + *status = F_status_set_error(F_failure); + } + + break; + } + + if (data_make->setting_make.fail == fake_make_operation_fail_type_exit) { + break; + } + } + else if (*status == F_signal_abort) { + // F_signal_abort is used by the break section operation. + break; } + else if (*status == F_signal_quit) { + // F_signal_abort is used by the exit section operation. + if (section_stack->used == 0) { + *status = F_none; + } - if (F_status_is_error(*status)) { - fake_print_error_fakefile_section_operation_failed(data, data_make->buffer, section->name, section->objects.array[i]); break; } } // for @@ -1572,23 +1631,32 @@ extern "C" { if (F_status_is_error(*status)) return; if (operation == fake_make_operation_type_archive) { - if (data_make->setting_build.build_linker.used) { - fake_execute(data, data_make->environment, data_make->setting_build.build_linker, arguments, status); + if (!arguments.used) { + return; + } - if (F_status_is_error(*status)) { - fake_print_error(data, F_status_set_fine(*status), "fake_execute", F_true); - return; - } + fake_execute(data, data_make->environment, data_make->setting_build.build_linker, arguments, status); + + if (F_status_is_error(*status)) { + fake_print_error(data, F_status_set_fine(*status), "fake_execute", F_true); + } + + return; + } + + if (operation == fake_make_operation_type_break) { + if (!arguments.used || fl_string_dynamic_compare_string(fake_make_operation_argument_success, arguments.array[0], fake_make_operation_argument_success_length) == F_equal_to) { + *status = F_signal_abort; + } + else if (fl_string_dynamic_compare_string(fake_make_operation_argument_failure, arguments.array[0], fake_make_operation_argument_failure_length) == F_equal_to) { + *status = F_status_set_error(F_signal_abort); } else { - if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: No linker has been specified, cannot perform '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, fake_make_operation_archive); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' section operation."); - } + return; + } - *status = F_status_set_error(F_failure); + if (data.verbosity == fake_verbosity_verbose) { + printf("Breaking as '%s'.", arguments.used ? arguments.array[0].string : fake_make_operation_argument_success); } return; @@ -1609,29 +1677,24 @@ extern "C" { } if (operation == fake_make_operation_type_compile) { - if (data_make->setting_build.build_compiler.used) { - fake_execute(data, data_make->environment, data_make->setting_build.build_compiler, arguments, status); - - if (F_status_is_error(*status)) { - fake_print_error(data, F_status_set_fine(*status), "fake_execute", F_true); - return; - } + if (!arguments.used) { + return; } - else { - if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: No compiler has been specified, cannot perform '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, fake_make_operation_compile); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' section operation."); - } - *status = F_status_set_error(F_failure); + fake_execute(data, data_make->environment, data_make->setting_build.build_compiler, arguments, status); + + if (F_status_is_error(*status)) { + fake_print_error(data, F_status_set_fine(*status), "fake_execute", F_true); } return; } if (operation == fake_make_operation_type_define) { + if (!arguments.used) { + return; + } + if (arguments.used > 1) { *status = f_environment_set(arguments.array[0].string, arguments.array[1].string, F_true); } @@ -1719,15 +1782,50 @@ extern "C" { return; } + if (operation == fake_make_operation_type_exit) { + if (!arguments.used || fl_string_dynamic_compare_string(fake_make_operation_argument_success, arguments.array[0], fake_make_operation_argument_success_length) == F_equal_to) { + *status = F_signal_quit; + } + else if (fl_string_dynamic_compare_string(fake_make_operation_argument_failure, arguments.array[0], fake_make_operation_argument_failure_length) == 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; + data_make->print.prefix = fake_make_print_error; + data_make->print.context = data.context.error; + data_make->print.to = f_type_error; + } + else { + return; + } + + if (data.verbosity == fake_verbosity_verbose) { + printf("Exiting as '%s'.", arguments.used ? arguments.array[0].string : fake_make_operation_argument_success); + } + + return; + } + if (operation == fake_make_operation_type_fail) { - if (fl_string_dynamic_compare_string(fake_make_operation_argument_error, arguments.array[0], fake_make_operation_argument_error_length) == F_equal_to) { + if (!arguments.used) { + return; + } + + if (fl_string_dynamic_compare_string(fake_make_operation_argument_exit, arguments.array[0], fake_make_operation_argument_exit_length) == F_equal_to) { data_make->setting_make.fail = fake_make_operation_fail_type_exit; + data_make->print.prefix = fake_make_print_error; + data_make->print.context = data.context.error; + data_make->print.to = f_type_error; } else if (fl_string_dynamic_compare_string(fake_make_operation_argument_warn, arguments.array[0], fake_make_operation_argument_warn_length) == F_equal_to) { data_make->setting_make.fail = fake_make_operation_fail_type_warn; + data_make->print.prefix = fake_make_print_warning; + data_make->print.context = data.context.warning; + data_make->print.to = f_type_warning; } else if (fl_string_dynamic_compare_string(fake_make_operation_argument_ignore, arguments.array[0], fake_make_operation_argument_ignore_length) == F_equal_to) { data_make->setting_make.fail = fake_make_operation_fail_type_ignore; + data_make->print.to = 0; } if (data.verbosity == fake_verbosity_verbose) { @@ -1750,6 +1848,10 @@ extern "C" { } if (operation == fake_make_operation_type_group) { + if (!arguments.used) { + return; + } + gid_t id = 0; *status = fake_make_get_id_group(data, arguments.array[0], &id); @@ -1770,6 +1872,10 @@ extern "C" { } if (operation == fake_make_operation_type_groups) { + if (!arguments.used) { + return; + } + gid_t id = 0; *status = fake_make_get_id_group(data, arguments.array[0], &id); @@ -1791,11 +1897,19 @@ extern "C" { } if (operation == fake_make_operation_type_if) { + if (!arguments.used) { + return; + } + // @todo: walk through each condition and save success/failure state. return; } if (operation == fake_make_operation_type_link) { + if (!arguments.used) { + return; + } + *status = f_file_link(arguments.array[0].string, arguments.array[1].string); if (F_status_is_error(*status)) { @@ -1809,6 +1923,10 @@ extern "C" { } if (operation == fake_make_operation_type_mode) { + if (!arguments.used) { + return; + } + f_file_mode mode_rule = 0; uint8_t replace = 0; @@ -1825,19 +1943,19 @@ extern "C" { *status = f_file_stat(arguments.array[i].string, F_true, &stat_file); if (F_status_is_error(*status)) { - fake_print_error_file(data, *status, "f_file_stat", arguments.array[i].string, "change mode of", F_true, F_true); + fake_print_error_file(data, F_status_set_fine(*status), "f_file_stat", arguments.array[i].string, "change mode of", F_true, F_true); break; } *status = f_file_mode_determine(stat_file.st_mode, mode_rule, replace, f_macro_file_type_is_directory(stat_file.st_mode), &mode); if (F_status_is_error(*status)) { - fake_print_error_file(data, *status, "f_file_mode_determine", arguments.array[i].string, "change mode of", F_true, F_true); + fake_print_error_file(data, F_status_set_fine(*status), "f_file_mode_determine", arguments.array[i].string, "change mode of", F_true, F_true); break; } *status = f_file_mode_set(arguments.array[i].string, mode); if (F_status_is_error(*status)) { - fake_print_error_file(data, *status, "f_file_mode_set", arguments.array[i].string, "change mode of", F_true, F_true); + fake_print_error_file(data, F_status_set_fine(*status), "f_file_mode_set", arguments.array[i].string, "change mode of", F_true, F_true); break; } @@ -1850,6 +1968,10 @@ extern "C" { } if (operation == fake_make_operation_type_modes) { + if (!arguments.used) { + return; + } + f_file_mode mode_rule = 0; uint8_t replace = 0; @@ -1892,11 +2014,28 @@ extern "C" { } if (operation == fake_make_operation_type_operate) { + if (!arguments.used) { + return; + } + // @todo: call other list, adding it to the stack. + + // Ensure that a break only happens within its active 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; } if (operation == fake_make_operation_type_owner) { + if (!arguments.used) { + return; + } + uid_t id = 0; *status = fake_make_get_id_owner(data, arguments.array[0], &id); @@ -1918,6 +2057,10 @@ extern "C" { } if (operation == fake_make_operation_type_owners) { + if (!arguments.used) { + return; + } + uid_t id = 0; *status = fake_make_get_id_owner(data, arguments.array[0], &id); @@ -1945,7 +2088,7 @@ extern "C" { *status = f_path_change(data_make->path.stack.array[data_make->path.stack.used - 1].string); if (F_status_is_error(*status)) { - fake_print_error_fakefile_path_stack(data, F_status_set_fine(*status), "f_path_change", data_make->path.stack.array[data_make->path.stack.used - 1].string); + fake_print_message_section_operation_path_stack_max(data, F_status_set_fine(*status), "f_path_change", data_make->path.stack.array[data_make->path.stack.used - 1].string, data_make->print); return; } @@ -1995,9 +2138,13 @@ extern "C" { } if (operation == fake_make_operation_type_to) { + if (!arguments.used) { + return; + } + *status = fake_make_assure_inside_project(data, arguments.array[0], data_make); if (F_status_is_error(*status)) { - fake_print_error_fakefile_section_operation_path_outside(data, F_status_set_fine(*status), "fake_make_assure_inside_project", data_make->path_cache.used ? data_make->path_cache.string : arguments.array[0].string); + fake_print_message_section_operation_path_outside(data, F_status_set_fine(*status), "fake_make_assure_inside_project", data_make->path_cache.used ? data_make->path_cache.string : arguments.array[0].string, data_make->print); if (F_status_set_fine(*status) == F_false) { *status = F_status_set_error(F_failure); @@ -2008,13 +2155,13 @@ extern "C" { *status = f_path_change(arguments.array[0].string); if (F_status_is_error(*status)) { - fake_print_error_fakefile_path_stack(data, F_status_set_fine(*status), "f_path_change", arguments.array[0].string); + fake_print_message_section_operation_path_stack_max(data, F_status_set_fine(*status), "f_path_change", arguments.array[0].string, data_make->print); } else { if (data_make->path.stack.used == data_make->path.stack.size) { if (data_make->path.stack.used + 1 >= f_array_length_size) { *status = F_status_set_error(F_buffer_too_large); - fake_print_error_fakefile_path_stack(data, F_buffer_too_large, "f_macro_string_dynamics_resize", "path stack"); + fake_print_message_section_operation_path_stack_max(data, F_buffer_too_large, "f_macro_string_dynamics_resize", "path stack", data_make->print); return; } @@ -2060,9 +2207,13 @@ extern "C" { } if (operation == fake_make_operation_type_top) { + if (!arguments.used) { + return; + } + *status = f_path_change_at(data_make->path.top); if (F_status_is_error(*status)) { - fake_print_error_fakefile_path_stack(data, F_status_set_fine(*status), "f_path_change", arguments.array[0].string); + fake_print_message_section_operation_path_stack_max(data, F_status_set_fine(*status), "f_path_change", arguments.array[0].string, data_make->print); return; } @@ -2080,6 +2231,10 @@ extern "C" { } if (operation == fake_make_operation_type_touch) { + if (!arguments.used) { + return; + } + f_mode mode = f_mode_initialize; f_macro_mode_set_default_umask(mode, data.umask); @@ -2201,11 +2356,11 @@ extern "C" { if (F_status_is_error(status)) { if (F_status_set_fine(status) == F_file_found_not) { - if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Failed to find program '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", program.string); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' for executing."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + fprintf(data_make->print.to, "%c", f_string_eol[0]); + fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: Failed to find program '", data_make->print.prefix); + fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", program.string); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "' for executing."); } } else if (F_status_set_fine(status) != F_failure) { @@ -2273,27 +2428,18 @@ extern "C" { return; } - if (data_make->setting_make.fail == fake_make_operation_fail_type_exit) { - if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Failed with return code '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", data_make->setting_make.parameter.array[0].value.array[0].string); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); - } + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + fprintf(data_make->print.to, "%c", f_string_eol[0]); + fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: Failed with return code '", data_make->print.prefix); + fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", data_make->setting_make.parameter.array[0].value.array[0].string); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "'."); + } + if (data_make->setting_make.fail == fake_make_operation_fail_type_exit) { *status = F_status_set_error(F_failure); - return; } - - *status = F_none; - - if (data_make->setting_make.fail == fake_make_operation_fail_type_warn) { - if (data.verbosity == fake_verbosity_verbose) { - fprintf(f_type_warning, "%c", f_string_eol[0]); - fl_color_print(f_type_warning, data.context.warning, data.context.reset, "WARNING: Failed with return code '"); - fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", data_make->setting_make.parameter.array[0].value.array[0].string); - fl_color_print_line(f_type_warning, data.context.warning, data.context.reset, "'."); - } + else { + *status = F_none; } } #endif // _di_fake_make_operate_process_return_ @@ -2347,16 +2493,64 @@ extern "C" { if (operation == fake_make_operation_type_archive || operation == fake_make_operation_type_run || operation == fake_make_operation_type_shell) { if (arguments.used == 0) { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Requires arguments."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Requires more arguments.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } + else if (operation == fake_make_operation_type_archive) { + if (!data_make->setting_build.build_linker.used) { + + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + fprintf(data_make->print.to, "%c", f_string_eol[0]); + fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: No linker has been specified, cannot perform '", data_make->print.prefix); + fl_color_print(data_make->print.to, data.context.notable, data.context.reset, fake_make_operation_archive); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "' section operation."); + } + + *status = F_status_set_error(F_failure); + } + } + + return; } - else if (operation == fake_make_operation_type_build) { + + if (operation == fake_make_operation_type_break) { if (arguments.used > 1) { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Has too many arguments."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Has too many arguments.", data_make->print.prefix); + } + + *status = F_status_set_error(F_failure); + } + else if (arguments.used) { + if (fl_string_dynamic_compare_string(fake_make_operation_argument_success, arguments.array[0], fake_make_operation_argument_success_length) == F_equal_to_not) { + if (fl_string_dynamic_compare_string(fake_make_operation_argument_failure, arguments.array[0], fake_make_operation_argument_failure_length) == F_equal_to_not) { + + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: Unsupported break type '", data_make->print.prefix); + fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[0].string); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "'."); + } + + *status = F_status_set_error(F_failure); + } + } + } + + return; + } + + if (operation == fake_make_operation_type_build) { + if (arguments.used > 1) { + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Has too many arguments.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } @@ -2365,66 +2559,100 @@ extern "C" { f_status status_file = f_file_is(arguments.array[0].string, f_file_type_regular); if (status_file == F_file_found_not) { - printf("%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Failed to find file '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", arguments.array[0].string); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: Failed to find file '", data_make->print.prefix); + fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[0].string); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "'."); + } *status = F_status_set_error(status_file); } else if (F_status_is_error(status_file)) { + // @todo: print warning file. fake_print_error_file(data, *status, "f_file_is", data.file_data_build_fakefile.string, "find", F_true, F_true); *status = status_file; } - if (!status_file) { - printf("%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The file '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", arguments.array[0].string); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' must be a regular file."); + /*if (!status_file) { // @fixme what is this for? conditional logic seems wrong. + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: The file '", data_make->print.prefix); + fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[0].string); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "' must be a regular file."); + } *status = F_status_set_error(F_failure); - } + }*/ } else { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Filename argument must not be an empty string."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Filename argument must not be an empty string.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } } + + return; } - else if (operation == fake_make_operation_type_clean || operation == fake_make_operation_type_pop || operation == fake_make_operation_type_top || operation == fake_make_operation_type_skeleton) { + + if (operation == fake_make_operation_type_clean || operation == fake_make_operation_type_pop || operation == fake_make_operation_type_top || operation == fake_make_operation_type_skeleton) { if (arguments.used) { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Has too many arguments."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Has too many arguments.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } else if (operation == fake_make_operation_type_pop) { if (data_make->path.stack.used == 1) { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Must not attempt to pop project root off of path stack."); + + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Must not attempt to pop project root off of path stack.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } } + + return; } - else if (operation == fake_make_operation_type_compile) { + + if (operation == fake_make_operation_type_compile) { if (arguments.used == 0) { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Requires arguments."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Requires more arguments.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } + else if (data_make->setting_build.build_compiler.used) { + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + fprintf(data_make->print.to, "%c", f_string_eol[0]); + fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: No compiler has been specified, cannot perform '", data_make->print.prefix); + fl_color_print(data_make->print.to, data.context.notable, data.context.reset, fake_make_operation_compile); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "' section operation."); + } + + *status = F_status_set_error(F_failure); + } + + return; } - else if (operation == fake_make_operation_type_delete || operation == fake_make_operation_type_deletes) { + + if (operation == fake_make_operation_type_delete || operation == fake_make_operation_type_deletes) { if (arguments.used) { for (f_array_length i = 0; i < arguments.used; i++) { *status = fake_make_assure_inside_project(data, arguments.array[i], data_make); if (F_status_is_error(*status)) { - fake_print_error_fakefile_section_operation_path_outside(data, F_status_set_fine(*status), "fake_make_assure_inside_project", data_make->path_cache.used ? data_make->path_cache.string : arguments.array[i].string); + // @todo warning + fake_print_message_section_operation_path_outside(data, F_status_set_fine(*status), "fake_make_assure_inside_project", data_make->path_cache.used ? data_make->path_cache.string : arguments.array[i].string, data_make->print); if (F_status_set_fine(*status) == F_false) { *status = F_status_set_error(F_failure); @@ -2433,65 +2661,117 @@ extern "C" { } // for } else { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Requires arguments."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Requires more arguments.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } + + return; } - else if (operation == fake_make_operation_type_define) { + + if (operation == fake_make_operation_type_define) { if (arguments.used) { *status = fake_make_operate_validate_define_name(arguments.array[0]); if (*status == F_none) { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Define name must not be an empty string."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Define name must not be an empty string.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } else if (*status == F_false) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Invalid characters in the define setting name '"); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + fprintf(data_make->print.to, "%c", f_string_eol[0]); + fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: Invalid characters in the define setting name '", data_make->print.prefix); - fl_color_print_code(f_type_error, data.context.notable); - f_print_string_dynamic(f_type_error, arguments.array[0]); - fl_color_print_code(f_type_error, data.context.reset); + fl_color_print_code(data_make->print.to, data.context.notable); + f_print_string_dynamic(data_make->print.to, arguments.array[0]); + fl_color_print_code(data_make->print.to, data.context.reset); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "', only alpha-numeric ASCII characters and underscore (without a leading digit) is allowed."); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "', only alpha-numeric ASCII characters and underscore (without a leading digit) is allowed."); + } *status = F_status_set_error(F_failure); } } else { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Requires arguments."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Requires more arguments.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } + + return; } - else if (operation == fake_make_operation_type_else) { + + if (operation == fake_make_operation_type_else) { if (operation_if == fake_make_operation_if_type_else) { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Must not be used after another else condition."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Must not be used after another else condition.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } else if (!operation_if) { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Has no preceding if condition."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Has no preceding if condition.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } + + return; } - else if (operation == fake_make_operation_type_fail) { + + if (operation == fake_make_operation_type_exit) { + if (arguments.used > 1) { + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Has too many arguments.", data_make->print.prefix); + } + + *status = F_status_set_error(F_failure); + } + else if (arguments.used) { + if (fl_string_dynamic_compare_string(fake_make_operation_argument_success, arguments.array[0], fake_make_operation_argument_success_length) == F_equal_to_not) { + if (fl_string_dynamic_compare_string(fake_make_operation_argument_failure, arguments.array[0], fake_make_operation_argument_failure_length) == F_equal_to_not) { + + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: Unsupported exit type '", data_make->print.prefix); + fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[0].string); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "'."); + } + + *status = F_status_set_error(F_failure); + } + } + } + + return; + } + + if (operation == fake_make_operation_type_fail) { if (arguments.used) { - if (fl_string_dynamic_compare_string(fake_make_operation_argument_error, arguments.array[0], fake_make_operation_argument_error_length) == F_equal_to_not) { + if (fl_string_dynamic_compare_string(fake_make_operation_argument_exit, arguments.array[0], fake_make_operation_argument_exit_length) == F_equal_to_not) { if (fl_string_dynamic_compare_string(fake_make_operation_argument_warn, arguments.array[0], fake_make_operation_argument_warn_length) == F_equal_to_not) { if (fl_string_dynamic_compare_string(fake_make_operation_argument_ignore, arguments.array[0], fake_make_operation_argument_ignore_length) == F_equal_to_not) { - printf("%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Unsupported fail type '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", arguments.array[0].string); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: Unsupported fail type '", data_make->print.prefix); + fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[0].string); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "'."); + } *status = F_status_set_error(F_failure); } @@ -2499,13 +2779,18 @@ extern "C" { } } else { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Requires arguments."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Requires more arguments.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } + + return; } - else if (operation == fake_make_operation_type_group || operation == fake_make_operation_type_groups || operation == fake_make_operation_type_mode || operation == fake_make_operation_type_modes || operation == fake_make_operation_type_owner || operation == fake_make_operation_type_owners) { + + if (operation == fake_make_operation_type_group || operation == fake_make_operation_type_groups || operation == fake_make_operation_type_mode || operation == fake_make_operation_type_modes || operation == fake_make_operation_type_owner || operation == fake_make_operation_type_owners) { if (arguments.used > 1) { f_status status_file = F_none; @@ -2513,45 +2798,63 @@ extern "C" { status_file = f_file_is(arguments.array[i].string, f_file_type_regular); if (status_file == F_file_found_not) { - printf("%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Failed to find file '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", arguments.array[i].string); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: Failed to find file '", data_make->print.prefix); + fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[i].string); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "'."); + } - *status = status_file; + *status = F_status_set_error(status_file); } else if (F_status_is_error(status_file)) { - fake_print_error_file(data, *status, "f_file_is", arguments.array[i].string, "find", F_true, F_true); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + fake_print_error_file(data, *status, "f_file_is", arguments.array[i].string, "find", F_true, F_true); + } + *status = status_file; } } } else { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Requires arguments."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Requires more arguments.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } + + return; } - else if (operation == fake_make_operation_type_if) { + + if (operation == fake_make_operation_type_if) { if (operation_if == fake_make_operation_if_type_if) { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Must not be used after another if condition."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Must not be used after another if condition.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } + + return; } - else if (operation == fake_make_operation_type_link) { + + if (operation == fake_make_operation_type_link) { if (arguments.used > 2) { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Has too many arguments."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Has too many arguments.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } else if (arguments.used == 2) { *status = fake_make_assure_inside_project(data, arguments.array[0], data_make); if (F_status_is_error(*status)) { - fake_print_error_fakefile_section_operation_path_outside(data, F_status_set_fine(*status), "fake_make_assure_inside_project", data_make->path_cache.used ? data_make->path_cache.string : arguments.array[0].string); + // @todo warning + fake_print_message_section_operation_path_outside(data, F_status_set_fine(*status), "fake_make_assure_inside_project", data_make->path_cache.used ? data_make->path_cache.string : arguments.array[0].string, data_make->print); if (F_status_set_fine(*status) == F_false) { *status = F_status_set_error(F_failure); @@ -2560,7 +2863,8 @@ extern "C" { *status = fake_make_assure_inside_project(data, arguments.array[1], data_make); if (F_status_is_error(*status)) { - fake_print_error_fakefile_section_operation_path_outside(data, F_status_set_fine(*status), "fake_make_assure_inside_project", data_make->path_cache.used ? data_make->path_cache.string : arguments.array[1].string); + // @todo warning + fake_print_message_section_operation_path_outside(data, F_status_set_fine(*status), "fake_make_assure_inside_project", data_make->path_cache.used ? data_make->path_cache.string : arguments.array[1].string, data_make->print); if (F_status_set_fine(*status) == F_false) { *status = F_status_set_error(F_failure); @@ -2568,20 +2872,29 @@ extern "C" { } } else { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Requires arguments."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Requires more arguments.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } + + return; } - else if (operation == fake_make_operation_type_operate) { + + if (operation == fake_make_operation_type_operate) { // @todo: validate if list name exists (and is not reserved, such as 'settings' and 'main'). // @todo: should recursion be checked here as well? + return; } - else if (operation == fake_make_operation_type_to) { + + if (operation == fake_make_operation_type_to) { if (arguments.used > 1) { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Has too many arguments."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Has too many arguments.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } @@ -2590,47 +2903,64 @@ extern "C" { f_status status_file = f_file_is(arguments.array[0].string, f_file_type_directory); if (status_file == F_file_found_not) { - printf("%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Failed to find file '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", arguments.array[0].string); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: Failed to find file '", data_make->print.prefix); + fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[0].string); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "'."); + } - *status = status_file; + *status = F_status_set_error(status_file); } else if (F_status_is_error(status_file)) { - fake_print_error_file(data, *status, "f_file_is", data.file_data_build_fakefile.string, "find", F_true, F_true); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + fake_print_error_file(data, *status, "f_file_is", data.file_data_build_fakefile.string, "find", F_true, F_true); + } + *status = status_file; } - if (!status_file) { - printf("%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The file '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", arguments.array[0].string); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' must be a directory file."); + /*if (!status_file) { // @fixme logic? + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: The file '", data_make->print.prefix); + fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[0].string); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "' must be a directory file."); + } *status = F_status_set_error(F_failure); - } + }*/ } else { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Filename argument must not be an empty string."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Filename argument must not be an empty string.", data_make->print.prefix); + } } } else { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Requires arguments."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Requires more arguments.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } + + return; } - else if (operation == fake_make_operation_type_touch) { + + if (operation == fake_make_operation_type_touch) { if (arguments.used > 1) { if (fl_string_dynamic_compare_string(fake_make_operation_argument_file, arguments.array[0], fake_make_operation_argument_file_length) == F_equal_to_not) { if (fl_string_dynamic_compare_string(fake_make_operation_argument_directory, arguments.array[0], fake_make_operation_argument_directory_length) == F_equal_to_not) { - printf("%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Unsupported file type '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", arguments.array[0].string); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print(data_make->print.to, data_make->print.context, data.context.reset, "%s: Unsupported file type '", data_make->print.prefix); + fl_color_print(data_make->print.to, data.context.notable, data.context.reset, "%s", arguments.array[0].string); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "'."); + } *status = F_status_set_error(F_failure); } @@ -2639,7 +2969,8 @@ extern "C" { for (f_array_length i = 1; i < arguments.used; i++) { *status = fake_make_assure_inside_project(data, arguments.array[i], data_make); if (F_status_is_error(*status)) { - fake_print_error_fakefile_section_operation_path_outside(data, F_status_set_fine(*status), "fake_make_assure_inside_project", data_make->path_cache.used ? data_make->path_cache.string : arguments.array[i].string); + // @todo warning + fake_print_message_section_operation_path_outside(data, F_status_set_fine(*status), "fake_make_assure_inside_project", data_make->path_cache.used ? data_make->path_cache.string : arguments.array[i].string, data_make->print); if (F_status_set_fine(*status) == F_false) { *status = F_status_set_error(F_failure); @@ -2648,11 +2979,15 @@ extern "C" { } // for } else { - printf("%c", f_string_eol[0]); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "ERROR: Requires arguments."); + if (data.verbosity != fake_verbosity_quiet && data_make->print.to) { + printf("%c", f_string_eol[0]); + fl_color_print_line(data_make->print.to, data_make->print.context, data.context.reset, "%s: Requires more arguments.", data_make->print.prefix); + } *status = F_status_set_error(F_failure); } + + return; } // note: there is nothing to validate for fake_make_operation_type_print. diff --git a/level_3/fake/c/private-make.h b/level_3/fake/c/private-make.h index 5ad8716..188aa24 100644 --- a/level_3/fake/c/private-make.h +++ b/level_3/fake/c/private-make.h @@ -63,12 +63,14 @@ extern "C" { #ifndef _di_fake_make_operation_ #define fake_make_operation_archive "archive" #define fake_make_operation_build "build" + #define fake_make_operation_break "break" #define fake_make_operation_clean "clean" #define fake_make_operation_compile "compile" #define fake_make_operation_define "define" #define fake_make_operation_delete "delete" #define fake_make_operation_deletes "deletes" #define fake_make_operation_else "else" + #define fake_make_operation_exit "exit" #define fake_make_operation_fail "fail" #define fake_make_operation_group "group" #define fake_make_operation_groups "groups" @@ -89,6 +91,7 @@ extern "C" { #define fake_make_operation_touch "touch" #define fake_make_operation_archive_length 7 + #define fake_make_operation_break_length 5 #define fake_make_operation_build_length 5 #define fake_make_operation_clean_length 5 #define fake_make_operation_compile_length 7 @@ -96,6 +99,7 @@ extern "C" { #define fake_make_operation_delete_length 6 #define fake_make_operation_deletes_length 7 #define fake_make_operation_else_length 4 + #define fake_make_operation_exit_length 4 #define fake_make_operation_fail_length 4 #define fake_make_operation_group_length 5 #define fake_make_operation_groups_length 6 @@ -117,6 +121,7 @@ extern "C" { enum { fake_make_operation_type_archive = 1, + fake_make_operation_type_break, fake_make_operation_type_build, fake_make_operation_type_clean, fake_make_operation_type_compile, @@ -124,6 +129,7 @@ extern "C" { fake_make_operation_type_delete, fake_make_operation_type_deletes, fake_make_operation_type_else, + fake_make_operation_type_exit, fake_make_operation_type_fail, fake_make_operation_type_group, fake_make_operation_type_groups, @@ -144,8 +150,9 @@ extern "C" { fake_make_operation_type_touch, }; - #define fake_make_operation_total 26 + #define fake_make_operation_total 28 + #define fake_make_operation_argument_failure "failure" #define fake_make_operation_argument_file "file" #define fake_make_operation_argument_directory "directory" #define fake_make_operation_argument_error "error" @@ -153,9 +160,11 @@ extern "C" { #define fake_make_operation_argument_ignore "ignore" #define fake_make_operation_argument_point "point" #define fake_make_operation_argument_recursive "recursive" + #define fake_make_operation_argument_success "success" #define fake_make_operation_argument_target "target" #define fake_make_operation_argument_warn "warn" + #define fake_make_operation_argument_failure_length 7 #define fake_make_operation_argument_file_length 4 #define fake_make_operation_argument_directory_length 9 #define fake_make_operation_argument_error_length 5 @@ -163,6 +172,7 @@ extern "C" { #define fake_make_operation_argument_ignore_length 6 #define fake_make_operation_argument_point_length 5 #define fake_make_operation_argument_recursive_length 9 + #define fake_make_operation_argument_success_length 7 #define fake_make_operation_argument_target_length 6 #define fake_make_operation_argument_warn_length 4 @@ -276,6 +286,29 @@ extern "C" { f_macro_string_dynamics_delete_simple(path.stack) #endif // _di_fake_make_path_ +#ifndef _di_fake_make_print_ + typedef struct { + const char *prefix; + f_string_static context; + + FILE *to; + } fake_make_print; + + #define fake_make_print_initialize { \ + 0, \ + f_string_static_initialize, \ + 0, \ + } + + #define fake_macro_make_print_initialize(prefix, context, to) { prefix, context, to } + + #define fake_make_print_error "ERROR" + #define fake_make_print_warning "WARNING" + + #define fake_make_print_error_length 5 + #define fake_make_print_warning_length 7 +#endif // _di_fake_make_print_ + #ifndef _di_fake_make_data_ typedef struct { fake_build_setting setting_build; @@ -285,6 +318,7 @@ extern "C" { fake_make_parameter parameter; fake_make_path path; + fake_make_print print; f_fss_nameds fakefile; @@ -300,6 +334,7 @@ extern "C" { fake_environment_initialize, \ fake_make_parameter_initialize, \ fake_make_path_initialize, \ + fake_make_print_initialize, \ f_fss_nameds_initialize, \ f_string_dynamic_initialize, \ f_string_dynamic_initialize, \ diff --git a/level_3/fake/c/private-print.c b/level_3/fake/c/private-print.c index 8cca889..127fcb3 100644 --- a/level_3/fake/c/private-print.c +++ b/level_3/fake/c/private-print.c @@ -1,5 +1,8 @@ -#include +#include "fake.h" #include "private-fake.h" +#include "private-build.h" +#include "private-clean.h" +#include "private-make.h" #include "private-print.h" #ifdef __cplusplus @@ -8,60 +11,9 @@ extern "C" { #ifndef _di_fake_print_error_ f_return_status fake_print_error(const fake_data data, const f_status status, const f_string function, const bool fallback) { + const fake_make_print print = fake_macro_make_print_initialize(fake_make_print_error, data.context.error, f_type_error); - if (status == F_parameter) { - if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Invalid parameter"); - - if (function) { - fl_color_print(f_type_error, data.context.error, data.context.reset, " when calling function "); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", function); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "()."); - } - else { - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "."); - } - } - - return F_none; - } - - if (status == F_memory_allocation || status == F_memory_reallocation) { - if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Unable to allocate memory"); - - if (function) { - fl_color_print(f_type_error, data.context.error, data.context.reset, " in function "); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", function); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "()."); - } - else { - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "."); - } - } - - return F_none; - } - - if (fallback && data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", status); - fl_color_print(f_type_error, data.context.error, data.context.reset, ")"); - - if (function) { - fl_color_print(f_type_error, data.context.error, data.context.reset, " in function "); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", function); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "()."); - } - else { - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "."); - } - } - - return F_unknown; + return fake_print_message(data, status, function, fallback, print); } #endif // _di_fake_print_error_ @@ -286,167 +238,151 @@ extern "C" { } #endif // _di_fake_print_error_build_operation_file_ -#ifndef _di_fake_print_error_fakefile_path_stack_ - void fake_print_error_fakefile_path_stack(const fake_data data, const f_status status, const f_string function, const f_string string) { - if (data.verbosity == fake_verbosity_quiet) return; - - if (status == F_buffer_too_large) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Maximum size reached for %s array", string); - - if (function) { - fl_color_print(f_type_error, data.context.error, data.context.reset, " while calling "); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", function); - fl_color_print(f_type_error, data.context.error, data.context.reset, "()"); - } +#ifndef _di_fake_print_error_file_ + bool fake_print_error_file(const fake_data data, const f_status status, const f_string function, const f_string name, const f_string operation, const bool is_file, const bool fallback) { + const fake_make_print print = fake_macro_make_print_initialize(fake_make_print_error, data.context.error, f_type_error); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "."); - } - else { - fake_print_error(data, status, function, F_true); - } + return fake_print_message_file(data, status, function, name, operation, is_file, fallback, print); } -#endif // _di_fake_print_error_fakefile_path_stack_ - -#ifndef _di_fake_print_error_fakefile_section_operation_failed_ - void fake_print_error_fakefile_section_operation_failed(const fake_data data, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name) { - if (data.verbosity == fake_verbosity_quiet) return; +#endif // _di_fake_print_error_file_ - f_string_length line = 1; +#ifndef _di_fake_print_error_fss + bool fake_print_error_fss(const fake_data data, const f_status status, const f_string function, const f_string path_file, const f_string_range range, const bool fallback) { - f_fss_count_lines(buffer, operation_name.start, &line); + if (status == F_file_found_not) { + if (data.verbosity != fake_verbosity_quiet) { + fprintf(f_type_error, "%c", f_string_eol[0]); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%d", range.start); + fl_color_print(f_type_error, data.context.error, data.context.reset, " of setting file '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", path_file); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "')."); + } - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The section operation '"); + return F_false; + } - fl_color_print_code(f_type_error, data.context.notable); - f_print_string_dynamic_partial(f_type_error, buffer, operation_name); - fl_color_print_code(f_type_error, data.context.reset); + if (status == F_status_set_error(F_incomplete_utf_stop)) { + if (data.verbosity != fake_verbosity_quiet) { + fprintf(f_type_error, "%c", f_string_eol[0]); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%d", range.start); + fl_color_print(f_type_error, data.context.error, data.context.reset, " of setting file '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", path_file); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "')."); + } - fl_color_print(f_type_error, data.context.error, data.context.reset, "' from section '"); + return F_false; + } - fl_color_print_code(f_type_error, data.context.notable); - f_print_string_dynamic_partial(f_type_error, buffer, section_name); - fl_color_print_code(f_type_error, data.context.reset); + if (fake_print_error(data, status, function, F_false) == F_unknown && fallback && data.verbosity != fake_verbosity_quiet) { + fprintf(f_type_error, "%c", f_string_eol[0]); + fl_color_print(f_type_error, data.context.error, data.context.reset, "UNKNOWN ERROR: ("); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", status); + fl_color_print(f_type_error, data.context.error, data.context.reset, ") in function "); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", function); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "()."); + } - fl_color_print(f_type_error, data.context.error, data.context.reset, "' on line "); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", line); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, " failed."); + return F_true; } -#endif // _di_fake_print_error_fakefile_section_operation_failed_ +#endif // _di_fake_print_error_fss -#ifndef _di_fake_print_error_fakefile_section_operation_stack_max_ - void fake_print_error_fakefile_section_operation_stack_max(const fake_data data, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name, const f_array_length stack_max) { +#ifndef _di_fake_print_error_parameter_missing_value_ + void fake_print_error_parameter_missing_value(const fake_data data, const f_string parameter) { if (data.verbosity == fake_verbosity_quiet) return; - f_string_length line = 1; - - f_fss_count_lines(buffer, operation_name.start, &line); - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The section operation '"); - - fl_color_print_code(f_type_error, data.context.notable); - f_print_string_dynamic_partial(f_type_error, buffer, operation_name); - fl_color_print_code(f_type_error, data.context.reset); - - fl_color_print(f_type_error, data.context.error, data.context.reset, "' from section '"); - fl_color_print_code(f_type_error, data.context.notable); - f_print_string_dynamic_partial(f_type_error, buffer, section_name); - fl_color_print_code(f_type_error, data.context.reset); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print(f_type_error, data.context.error, data.context.reset, "' on line "); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", line); - fl_color_print(f_type_error, data.context.error, data.context.reset, " cannot be processed because the max stack depth of "); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", stack_max); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, " has been reached."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' was specified, but no value was given."); } -#endif // _di_fake_print_error_fakefile_section_operation_stack_max_ +#endif // _di_fake_print_error_parameter_missing_value_ -#ifndef _di_fake_print_error_fakefile_section_operation_unknown_ - void fake_print_error_fakefile_section_operation_unknown(const fake_data data, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name) { +#ifndef _di_fake_print_error_parameter_too_many_ + void fake_print_error_parameter_too_many(const fake_data data, const f_string parameter) { if (data.verbosity == fake_verbosity_quiet) return; - f_string_length line = 1; - - f_fss_count_lines(buffer, operation_name.start, &line); - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The section operation '"); - - fl_color_print_code(f_type_error, data.context.notable); - f_print_string_dynamic_partial(f_type_error, buffer, operation_name); - fl_color_print_code(f_type_error, data.context.reset); - - fl_color_print(f_type_error, data.context.error, data.context.reset, "' from section '"); - fl_color_print_code(f_type_error, data.context.notable); - f_print_string_dynamic_partial(f_type_error, buffer, section_name); - fl_color_print_code(f_type_error, data.context.reset); + fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The parameter '"); + fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, parameter); - fl_color_print(f_type_error, data.context.error, data.context.reset, "' on line "); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", line); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, " is not a known operation name."); + fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' specified too many times."); } -#endif // _di_fake_print_error_fakefile_section_operation_unknown_ - -#ifndef _di_fake_print_error_fakefile_settings_content_empty_ - void fake_print_error_fakefile_settings_content_empty(const fake_data data, const f_string path_file, const f_string_dynamic buffer, const f_string_range range_object, const f_string settings_name) { - if (data.verbosity != fake_verbosity_verbose) return; +#endif // _di_fake_print_error_parameter_too_many_ - fprintf(f_type_error, "%c", f_string_eol[0]); +#ifndef _di_fake_print_message_ + f_return_status fake_print_message(const fake_data data, const f_status status, const f_string function, const bool fallback, const fake_make_print print) { - fl_color_print(f_type_warning, data.context.warning, data.context.reset, "WARNING: the fakefile '"); - fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", path_file); - fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' has empty content for the '"); - fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", settings_name); - fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' object '"); - - fl_color_print_code(f_type_warning, data.context.notable); - f_print_string_dynamic_partial(f_type_warning, buffer, range_object); - fl_color_print_code(f_type_warning, data.context.reset); + if (status == F_parameter) { + if (data.verbosity != fake_verbosity_quiet) { + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: Invalid parameter", print.prefix); - fl_color_print_line(f_type_warning, data.context.warning, data.context.reset, "'."); - } -#endif // _di_fake_print_error_fakefile_settings_content_empty_ + if (function) { + fl_color_print(print.to, print.context, data.context.reset, " when calling function "); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", function); + fl_color_print_line(print.to, print.context, data.context.reset, "()."); + } + else { + fl_color_print_line(print.to, print.context, data.context.reset, "."); + } + } -#ifndef _di_fake_print_error_fakefile_settings_content_invalid_ - void fake_print_error_fakefile_settings_content_invalid(const fake_data data, const f_string path_file, const f_string_dynamic buffer, const f_string_range range_object, const f_string_range range_content, const f_string settings_name) { - if (data.verbosity != fake_verbosity_verbose) return; + return F_none; + } - fprintf(f_type_error, "%c", f_string_eol[0]); + if (status == F_memory_allocation || status == F_memory_reallocation) { + if (data.verbosity != fake_verbosity_quiet) { + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: Unable to allocate memory", print.prefix); - fl_color_print(f_type_warning, data.context.warning, data.context.reset, "WARNING: the fakefile '"); - fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", path_file); - fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' has an invalid content '"); + if (function) { + fl_color_print(print.to, print.context, data.context.reset, " in function "); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", function); + fl_color_print_line(print.to, print.context, data.context.reset, "()."); + } + else { + fl_color_print_line(print.to, print.context, data.context.reset, "."); + } + } - fl_color_print_code(f_type_warning, data.context.notable); - f_print_string_dynamic_partial(f_type_warning, buffer, range_content); - fl_color_print_code(f_type_warning, data.context.reset); + return F_none; + } - fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' for the '"); - fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", settings_name); - fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' object '"); + if (fallback && data.verbosity != fake_verbosity_quiet) { + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "UNKNOWN %s: (", print.prefix); + fl_color_print(print.to, data.context.notable, data.context.reset, "%llu", status); + fl_color_print(print.to, print.context, data.context.reset, ")"); - fl_color_print_code(f_type_warning, data.context.notable); - f_print_string_dynamic_partial(f_type_warning, buffer, range_object); - fl_color_print_code(f_type_warning, data.context.reset); + if (function) { + fl_color_print(print.to, print.context, data.context.reset, " in function "); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", function); + fl_color_print_line(print.to, print.context, data.context.reset, "()."); + } + else { + fl_color_print_line(print.to, print.context, data.context.reset, "."); + } + } - fl_color_print_line(f_type_warning, data.context.warning, data.context.reset, "'."); + return F_unknown; } -#endif // _di_fake_print_error_fakefile_settings_content_invalid_ +#endif // _di_fake_print_message_ -#ifndef _di_fake_print_error_file_ - bool fake_print_error_file(const fake_data data, const f_status status, const f_string function, const f_string name, const f_string operation, const bool is_file, const bool fallback) { +#ifndef _di_fake_print_message_file_ + bool fake_print_message_file(const fake_data data, const f_status status, const f_string function, const f_string name, const f_string operation, const bool is_file, const bool fallback, const fake_make_print print) { const f_string file_or_directory = is_file ? "file" : "directory"; if (status == F_file_found_not) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Failed to find %s '", file_or_directory); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", name); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: Failed to find %s '", print.prefix, file_or_directory); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", name); + fl_color_print_line(print.to, print.context, data.context.reset, "'."); } return F_false; @@ -454,10 +390,10 @@ extern "C" { if (status == F_file_found) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The %s '", file_or_directory); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", name); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' already exists."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: The %s '", print.prefix, file_or_directory); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", name); + fl_color_print_line(print.to, print.context, data.context.reset, "' already exists."); } return F_false; @@ -465,10 +401,10 @@ extern "C" { if (status == F_directory_empty_not) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The %s '", file_or_directory); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", name); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' is not empty."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: The %s '", print.prefix, file_or_directory); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", name); + fl_color_print_line(print.to, print.context, data.context.reset, "' is not empty."); } return F_false; @@ -476,12 +412,12 @@ extern "C" { if (status == F_parameter) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "INTERNAL ERROR: Invalid parameter when calling "); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", function); - fl_color_print(f_type_error, data.context.error, data.context.reset, "() for the %s '", file_or_directory); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", name); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "INTERNAL %s: Invalid parameter when calling ", print.prefix); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", function); + fl_color_print(print.to, print.context, data.context.reset, "() for the %s '", file_or_directory); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", name); + fl_color_print_line(print.to, print.context, data.context.reset, "'."); } return F_false; @@ -489,10 +425,10 @@ extern "C" { if (status == F_name) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Invalid %s name '", file_or_directory); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", name); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: Invalid %s name '", print.prefix, file_or_directory); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", name); + fl_color_print_line(print.to, print.context, data.context.reset, "'."); } return F_false; @@ -500,10 +436,10 @@ extern "C" { if (status == F_memory_out) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory, while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", name); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "CRITICAL %s: Unable to allocate memory, while trying to %s %s '", print.prefix, operation, file_or_directory); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", name); + fl_color_print_line(print.to, print.context, data.context.reset, "'."); } return F_false; @@ -511,10 +447,10 @@ extern "C" { if (status == F_number_overflow) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Overflow while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", name); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: Overflow while trying to %s %s '", print.prefix, operation, file_or_directory); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", name); + fl_color_print_line(print.to, print.context, data.context.reset, "'."); } return F_false; @@ -522,10 +458,10 @@ extern "C" { if (status == F_directory) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Invalid directory while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", name); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: Invalid directory while trying to %s %s '", print.prefix, operation, file_or_directory); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", name); + fl_color_print_line(print.to, print.context, data.context.reset, "'."); } return F_false; @@ -533,10 +469,10 @@ extern "C" { if (status == F_access_denied) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Access denied while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", name); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: Access denied while trying to %s %s '", print.prefix, operation, file_or_directory); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", name); + fl_color_print_line(print.to, print.context, data.context.reset, "'."); } return F_false; @@ -544,10 +480,10 @@ extern "C" { if (status == F_loop) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Loop while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", name); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: Loop while trying to %s %s '", print.prefix, operation, file_or_directory); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", name); + fl_color_print_line(print.to, print.context, data.context.reset, "'."); } return F_false; @@ -555,10 +491,10 @@ extern "C" { if (status == F_prohibited) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Prohibited by system while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", name); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: Prohibited by system while trying to %s %s '", print.prefix, operation, file_or_directory); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", name); + fl_color_print_line(print.to, print.context, data.context.reset, "'."); } return F_false; @@ -567,10 +503,10 @@ extern "C" { if (is_file) { if (status == F_directory_found_not) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Failed to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", name); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' due to an invalid directory in the path."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: Failed to %s %s '", print.prefix, operation, file_or_directory); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", name); + fl_color_print_line(print.to, print.context, data.context.reset, "' due to an invalid directory in the path."); } return F_false; @@ -579,10 +515,10 @@ extern "C" { else { if (status == F_directory_found_not) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Failed to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", name); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' due to an invalid directory in the path."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: Failed to %s %s '", print.prefix, operation, file_or_directory); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", name); + fl_color_print_line(print.to, print.context, data.context.reset, "' due to an invalid directory in the path."); } return F_false; @@ -590,10 +526,10 @@ extern "C" { if (status == F_failure) { if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: Failed to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", name); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: Failed to %s %s '", print.prefix, operation, file_or_directory); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", name); + fl_color_print_line(print.to, print.context, data.context.reset, "'."); } return F_false; @@ -601,116 +537,184 @@ extern "C" { } if (fake_print_error(data, status, function, F_false) == F_unknown && fallback && data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", status); - fl_color_print(f_type_error, data.context.error, data.context.reset, ") occurred while trying to %s %s '", operation, file_or_directory); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", name); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "'."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "UNKNOWN %s: (", print.prefix); + fl_color_print(print.to, data.context.notable, data.context.reset, "%llu", status); + fl_color_print(print.to, print.context, data.context.reset, ") occurred while trying to %s %s '", operation, file_or_directory); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", name); + fl_color_print_line(print.to, print.context, data.context.reset, "'."); } return F_true; } -#endif // _di_fake_print_error_file_ +#endif // _di_fake_print_message_file_ -#ifndef _di_fake_print_error_fss - bool fake_print_error_fss(const fake_data data, const f_status status, const f_string function, const f_string path_file, const f_string_range range, const bool fallback) { +#ifndef _di_fake_print_message_section_operation_failed_ + void fake_print_message_section_operation_failed(const fake_data data, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name, const fake_make_print print) { + if (data.verbosity == fake_verbosity_quiet || !print.to) return; - if (status == F_file_found_not) { - if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at stop position (at "); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%d", range.start); - fl_color_print(f_type_error, data.context.error, data.context.reset, " of setting file '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", path_file); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "')."); - } + f_string_length line = 1; - return F_false; - } + f_fss_count_lines(buffer, operation_name.start, &line); - if (status == F_status_set_error(F_incomplete_utf_stop)) { - if (data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ENCODING ERROR: error occurred on invalid UTF-8 character at end of string (at "); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%d", range.start); - fl_color_print(f_type_error, data.context.error, data.context.reset, " of setting file '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", path_file); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "')."); - } + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s The section operation '", print.prefix); - return F_false; - } + fl_color_print_code(print.to, data.context.notable); + f_print_string_dynamic_partial(print.to, buffer, operation_name); + fl_color_print_code(print.to, data.context.reset); - if (fake_print_error(data, status, function, F_false) == F_unknown && fallback && data.verbosity != fake_verbosity_quiet) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "UNKNOWN ERROR: ("); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%llu", status); - fl_color_print(f_type_error, data.context.error, data.context.reset, ") in function "); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", function); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "()."); - } + fl_color_print(print.to, print.context, data.context.reset, "' from section '"); - return F_true; + fl_color_print_code(print.to, data.context.notable); + f_print_string_dynamic_partial(print.to, buffer, section_name); + fl_color_print_code(print.to, data.context.reset); + + fl_color_print(print.to, print.context, data.context.reset, "' on line "); + fl_color_print(print.to, data.context.notable, data.context.reset, "%llu", line); + fl_color_print_line(print.to, print.context, data.context.reset, " failed."); } -#endif // _di_fake_print_error_fss +#endif // _di_fake_print_message_section_operation_failed_ -#ifndef _di_fake_print_error_fakefile_section_operation_path_outside_ - void fake_print_error_fakefile_section_operation_path_outside(const fake_data data, const f_status status, const f_string function, const f_string path) { - if (data.verbosity == fake_verbosity_quiet) return; +#ifndef _di_fake_print_message_section_operation_path_outside_ + void fake_print_message_section_operation_path_outside(const fake_data data, const f_status status, const f_string function, const f_string path, const fake_make_print print) { + if (data.verbosity == fake_verbosity_quiet || !print.to) return; if (F_status_set_fine(status) == F_false) { - fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The path '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s", path); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' is outside the project root."); + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: The path '", print.prefix); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", path); + fl_color_print_line(print.to, print.context, data.context.reset, "' is outside the project root."); } else { fake_print_error_file(data, status, function, path, "determine real path of", F_true, F_true); } } -#endif // _di_fake_print_error_fakefile_section_operation_path_outside_ +#endif // _di_fake_print_message_section_operation_path_outside_ -#ifndef _di_fake_print_error_parameter_missing_value_ - void fake_print_error_parameter_missing_value(const fake_data data, const f_string parameter) { - if (data.verbosity == fake_verbosity_quiet) return; +#ifndef _di_fake_print_message_section_operation_path_stack_max_ + void fake_print_message_section_operation_path_stack_max(const fake_data data, const f_status status, const f_string function, const f_string string, const fake_make_print print) { + if (data.verbosity == fake_verbosity_quiet || !print.to) return; - fprintf(f_type_error, "%c", f_string_eol[0]); + if (status == F_buffer_too_large) { + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: Maximum size reached for %s array", print.prefix, string); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The parameter '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, parameter); + if (function) { + fl_color_print(print.to, print.context, data.context.reset, " while calling "); + fl_color_print(print.to, data.context.notable, data.context.reset, "%s", function); + fl_color_print(print.to, print.context, data.context.reset, "()"); + } - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' was specified, but no value was given."); + fl_color_print_line(print.to, print.context, data.context.reset, "."); + } + else { + fake_print_error(data, status, function, F_true); + } } -#endif // _di_fake_print_error_parameter_missing_value_ +#endif // _di_fake_print_message_section_operation_path_stack_max_ -#ifndef _di_fake_print_error_parameter_too_many_ - void fake_print_error_parameter_too_many(const fake_data data, const f_string parameter) { +#ifndef _di_fake_print_message_section_operation_stack_max_ + void fake_print_message_section_operation_stack_max(const fake_data data, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name, const f_array_length stack_max, const fake_make_print print) { + if (data.verbosity == fake_verbosity_quiet || !print.to) return; + + f_string_length line = 1; + + f_fss_count_lines(buffer, operation_name.start, &line); + + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: The section operation '", print.prefix); + + fl_color_print_code(print.to, data.context.notable); + f_print_string_dynamic_partial(print.to, buffer, operation_name); + fl_color_print_code(print.to, data.context.reset); + + fl_color_print(print.to, print.context, data.context.reset, "' from section '"); + + fl_color_print_code(print.to, data.context.notable); + f_print_string_dynamic_partial(print.to, buffer, section_name); + fl_color_print_code(print.to, data.context.reset); + + fl_color_print(print.to, print.context, data.context.reset, "' on line "); + fl_color_print(print.to, data.context.notable, data.context.reset, "%llu", line); + fl_color_print(print.to, print.context, data.context.reset, " cannot be processed because the max stack depth of "); + fl_color_print(print.to, data.context.notable, data.context.reset, "%llu", stack_max); + fl_color_print_line(print.to, print.context, data.context.reset, " has been reached."); + } +#endif // _di_fake_print_message_section_operation_stack_max_ + +#ifndef _di_fake_print_message_section_operation_unknown_ + void fake_print_message_section_operation_unknown(const fake_data data, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name, const fake_make_print print) { + if (data.verbosity == fake_verbosity_quiet || !print.to) return; + + f_string_length line = 1; + + f_fss_count_lines(buffer, operation_name.start, &line); + + fprintf(print.to, "%c", f_string_eol[0]); + fl_color_print(print.to, print.context, data.context.reset, "%s: The section operation '", print.prefix); + + fl_color_print_code(print.to, data.context.notable); + f_print_string_dynamic_partial(print.to, buffer, operation_name); + fl_color_print_code(print.to, data.context.reset); + + fl_color_print(print.to, print.context, data.context.reset, "' from section '"); + + fl_color_print_code(print.to, data.context.notable); + f_print_string_dynamic_partial(print.to, buffer, section_name); + fl_color_print_code(print.to, data.context.reset); + + fl_color_print(print.to, print.context, data.context.reset, "' on line "); + fl_color_print(print.to, data.context.notable, data.context.reset, "%llu", line); + fl_color_print_line(print.to, print.context, data.context.reset, " is not a known operation name."); + } +#endif // _di_fake_print_message_section_operation_unknown_ + +#ifndef _di_fake_print_warning_settings_content_empty_ + void fake_print_warning_settings_content_empty(const fake_data data, const f_string path_file, const f_string_dynamic buffer, const f_string_range range_object, const f_string settings_name) { if (data.verbosity == fake_verbosity_quiet) return; fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_error, data.context.error, data.context.reset, "ERROR: The parameter '"); - fl_color_print(f_type_error, data.context.notable, data.context.reset, "%s%s", f_console_symbol_long_enable, parameter); + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "WARNING: the fakefile '"); + fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", path_file); + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' has empty content for the '"); + fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", settings_name); + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' object '"); - fl_color_print_line(f_type_error, data.context.error, data.context.reset, "' specified too many times."); + fl_color_print_code(f_type_warning, data.context.notable); + f_print_string_dynamic_partial(f_type_warning, buffer, range_object); + fl_color_print_code(f_type_warning, data.context.reset); + + fl_color_print_line(f_type_warning, data.context.warning, data.context.reset, "'."); } -#endif // _di_fake_print_error_parameter_too_many_ +#endif // _di_fake_print_warning_settings_content_empty_ -#ifndef _di_fake_print_warning_fakefile_object_multiple_ - void fake_print_warning_fakefile_object_multiple(const fake_data data, const f_string path_file, const f_string label, const f_string name_object) { - if (data.verbosity != fake_verbosity_verbose) return; +#ifndef _di_fake_print_warning_settings_content_invalid_ + void fake_print_warning_settings_content_invalid(const fake_data data, const f_string path_file, const f_string_dynamic buffer, const f_string_range range_object, const f_string_range range_content, const f_string settings_name) { + if (data.verbosity == fake_verbosity_quiet) return; fprintf(f_type_error, "%c", f_string_eol[0]); - fl_color_print(f_type_warning, data.context.warning, data.context.reset, "WARNING: the %s object '", label); - fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", name_object); - fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' in the file '"); + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "WARNING: the fakefile '"); fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", path_file); + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' has an invalid content '"); - fl_color_print_line(f_type_warning, data.context.warning, data.context.reset, "' may only be specified once, only using the first."); + fl_color_print_code(f_type_warning, data.context.notable); + f_print_string_dynamic_partial(f_type_warning, buffer, range_content); + fl_color_print_code(f_type_warning, data.context.reset); + + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' for the '"); + fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", settings_name); + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' object '"); + + fl_color_print_code(f_type_warning, data.context.notable); + f_print_string_dynamic_partial(f_type_warning, buffer, range_object); + fl_color_print_code(f_type_warning, data.context.reset); + + fl_color_print_line(f_type_warning, data.context.warning, data.context.reset, "'."); } -#endif // _di_fake_print_warning_fakefile_object_multiple_ +#endif // _di_fake_print_warning_settings_content_invalid_ #ifndef _di_fake_print_warning_settings_content_multiple_ void fake_print_warning_settings_content_multiple(const fake_data data, const f_string path_file, const f_string name_object) { @@ -727,6 +731,21 @@ extern "C" { } #endif // _di_fake_print_warning_settings_content_multiple_ +#ifndef _di_fake_print_warning_settings_object_multiple_ + void fake_print_warning_settings_object_multiple(const fake_data data, const f_string path_file, const f_string label, const f_string name_object) { + if (data.verbosity != fake_verbosity_verbose) return; + + fprintf(f_type_error, "%c", f_string_eol[0]); + + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "WARNING: the %s object '", label); + fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", name_object); + fl_color_print(f_type_warning, data.context.warning, data.context.reset, "' in the file '"); + fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", path_file); + + fl_color_print_line(f_type_warning, data.context.warning, data.context.reset, "' may only be specified once, only using the first."); + } +#endif // _di_fake_print_warning_settings_object_multiple_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fake/c/private-print.h b/level_3/fake/c/private-print.h index 9211a7b..aada67b 100644 --- a/level_3/fake/c/private-print.h +++ b/level_3/fake/c/private-print.h @@ -66,7 +66,83 @@ extern "C" { #endif // _di_fake_print_error_operation_file_ /** - * Print error messages when processing some fakefile section, for a specific line and operation. + * Print file/directory error messages. + * + * @todo the fll_file_error_print() needs to be reviewed and possibly changed. + * + * @param data + * The program data. + * @param status + * The error status code to report on. + * @param function + * The function call that returned the error. + * @param name + * The name of the file or directory. + * @param operation + * The operation that fails, such as 'create' or 'access'. + * @param is_file + * Set to TRUE if this is a file and FALSE if this is a directory. + * @param fallback + * Set to F_true to print the fallback error message for unknown errors. + * + * @return + * F_true is returned if the status code has no print message. + * F_false is returned on successful print of known errors. + */ +#ifndef _di_fake_print_error_file_ + extern bool fake_print_error_file(const fake_data data, const f_status status, const f_string function, const f_string name, const f_string operation, const bool is_file, const bool fallback) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_error_file_ + +/** + * Print FSS error messages. + * + * @param data + * The program data. + * @param status + * The error status code to report on. + * @param function + * The function call that returned the error. + * @param path_file + * The path to the file. + * @param range + * The range representing the position in the buffer such that range.start is where the error happened. + * @param fallback + * Set to F_true to print the fallback error message for unknown errors. + * + * @return + * F_true is returned if the status code has no print message. + * F_false is returned on successful print of known errors. + */ +#ifndef _di_fake_print_error_fss_ + extern bool fake_print_error_fss(const fake_data data, const f_status status, const f_string function, const f_string path_file, const f_string_range range, const bool fallback) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_error_fss_ + +/** + * Print an error message for when the parameter is missing its accompanying value. + * + * @param data + * The program data. + * @param parameter + * The parameter name. + */ +#ifndef _di_fake_print_error_parameter_missing_value_ + extern void fake_print_error_parameter_missing_value(const fake_data data, const f_string parameter) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_error_parameter_missing_value_ + +/** + * Print an error message for when the parameter is specified too many times. + * + * @param data + * The program data. + * @param parameter + * The parameter name. + */ +#ifndef _di_fake_print_error_parameter_too_many_ + extern void fake_print_error_parameter_too_many(const fake_data data, const f_string parameter) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_error_parameter_too_many_ + +/** + * Print generic error/warning messages. * * @param data * The program data. @@ -75,12 +151,48 @@ extern "C" { * @param function * The name of the function where the error happened. * Set to 0 to disable. - * @param string - * A string used by certain error conditions. + * @param fallback + * Set to F_true to print the fallback error message for unknown errors. + * @param print + * Designates how the section error/warning should be printed. + * + * @return + * F_none is returned on successful print of known errors. + * F_unknown is returned if the status code has no print message. */ -#ifndef _di_fake_print_error_fakefile_path_stack_ - extern void fake_print_error_fakefile_path_stack(const fake_data data, const f_status status, const f_string function, const f_string string) f_gcc_attribute_visibility_internal; -#endif // _di_fake_print_error_fakefile_path_stack_ +#ifndef _di_fake_print_message_ + extern f_return_status fake_print_message(const fake_data data, const f_status status, const f_string function, const bool fallback, const fake_make_print print) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_message_ + +/** + * Print file/directory error/warning messages. + * + * @todo the fll_file_error_print() needs to be reviewed and possibly changed. + * + * @param data + * The program data. + * @param status + * The error status code to report on. + * @param function + * The function call that returned the error. + * @param name + * The name of the file or directory. + * @param operation + * The operation that fails, such as 'create' or 'access'. + * @param is_file + * Set to TRUE if this is a file and FALSE if this is a directory. + * @param fallback + * Set to F_true to print the fallback error message for unknown errors. + * @param print + * Designates how the section error/warning should be printed. + * + * @return + * F_true is returned if the status code has no print message. + * F_false is returned on successful print of known errors. + */ +#ifndef _di_fake_print_message_file_ + extern bool fake_print_message_file(const fake_data data, const f_status status, const f_string function, const f_string name, const f_string operation, const bool is_file, const bool fallback, const fake_make_print print) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_message_file_ /** * Print error messages when processing some fakefile section, for a specific line and operation, and that operation failed. @@ -93,10 +205,12 @@ extern "C" { * The range within the buffer representing the section name. * @param operation_name * The range within the buffer representing the operation name within the section. + * @param print + * Designates how the section error/warning should be printed. */ -#ifndef _di_fake_print_error_fakefile_section_operation_failed_ - extern void fake_print_error_fakefile_section_operation_failed(const fake_data data, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name) f_gcc_attribute_visibility_internal; -#endif // _di_fake_print_error_fakefile_section_operation_failed_ +#ifndef _di_fake_print_message_section_operation_failed_ + extern void fake_print_message_section_operation_failed(const fake_data data, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name, const fake_make_print print) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_message_section_operation_failed_ /** * Print error messages when processing some fakefile section, for a specific line and operation, and that operation has a path outside of the project root. @@ -109,10 +223,31 @@ extern "C" { * The name of the function where the error happened. * @param path * The path that is outside of the project path. + * @param print + * Designates how the section error/warning should be printed. */ -#ifndef _di_fake_print_error_fakefile_section_operation_path_outside_ - extern void fake_print_error_fakefile_section_operation_path_outside(const fake_data data, const f_status status, const f_string function, const f_string path) f_gcc_attribute_visibility_internal; -#endif // _fake_print_error_fakefile_section_operation_path_outside_ +#ifndef _di_fake_print_message_section_operation_path_outside_ + extern void fake_print_message_section_operation_path_outside(const fake_data data, const f_status status, const f_string function, const f_string path, const fake_make_print print) f_gcc_attribute_visibility_internal; +#endif // _fake_print_message_section_operation_path_outside_ + +/** + * Print error messages when processing some fakefile section, for a specific line and operation. + * + * @param data + * The program data. + * @param status + * The status code representing an error. + * @param function + * The name of the function where the error happened. + * Set to 0 to disable. + * @param string + * A string used by certain error conditions. + * @param print + * Designates how the section error/warning should be printed. + */ +#ifndef _di_fake_print_message_section_operation_path_stack_max_ + extern void fake_print_message_section_operation_path_stack_max(const fake_data data, const f_status status, const f_string function, const f_string string, const fake_make_print print) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_message_section_operation_path_stack_max_ /** * Print error messages when processing some fakefile section, for a specific line and operation, and that the max stack depth is reached. @@ -127,10 +262,12 @@ extern "C" { * The range within the buffer representing the operation name within the section. * @param stack_max * The max stack depth. + * @param print + * Designates how the section error/warning should be printed. */ -#ifndef _di_fake_print_error_fakefile_section_operation_stack_max_ - extern void fake_print_error_fakefile_section_operation_stack_max(const fake_data data, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name, const f_array_length stack_max) f_gcc_attribute_visibility_internal; -#endif // _di_fake_print_error_fakefile_section_operation_stack_max_ +#ifndef _di_fake_print_message_section_operation_stack_max_ + extern void fake_print_message_section_operation_stack_max(const fake_data data, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name, const f_array_length stack_max, const fake_make_print print) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_message_section_operation_stack_max_ /** * Print error messages when processing some fakefile section, for a specific line and operation, and that operation is invalid. @@ -143,13 +280,15 @@ extern "C" { * The range within the buffer representing the section name. * @param operation_name * The range within the buffer representing the operation name within the section. + * @param print + * Designates how the section error/warning should be printed. */ -#ifndef _di_fake_print_error_fakefile_section_operation_unknown_ - extern void fake_print_error_fakefile_section_operation_unknown(const fake_data data, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name) f_gcc_attribute_visibility_internal; -#endif // _di_fake_print_error_fakefile_section_operation_unknown_ +#ifndef _di_fake_print_message_section_operation_unknown_ + extern void fake_print_message_section_operation_unknown(const fake_data data, const f_string_static buffer, const f_string_range section_name, const f_string_range operation_name, const fake_make_print print) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_message_section_operation_unknown_ /** - * Print error message when fake settings content is empty. + * Print message when fake settings content is empty. * * @param data * The program data. @@ -162,12 +301,12 @@ extern "C" { * @param settings_name * The name of the setting that has an invalid value. */ -#ifndef _di_fake_print_error_fakefile_settings_content_empty_ - extern void fake_print_error_fakefile_settings_content_empty(const fake_data data, const f_string path_file, const f_string_dynamic buffer, const f_string_range range_object, const f_string settings_name) f_gcc_attribute_visibility_internal; -#endif // _di_fake_print_error_fakefile_settings_content_empty_ +#ifndef _di_fake_print_warning_settings_content_empty_ + extern void fake_print_warning_settings_content_empty(const fake_data data, const f_string path_file, const f_string_dynamic buffer, const f_string_range range_object, const f_string settings_name) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_warning_settings_content_empty_ /** - * Print error message when fake settings content is invalid. + * Print warning message when fake settings content is invalid. * * @param data * The program data. @@ -181,89 +320,15 @@ extern "C" { * The range within the buffer representing the content. * @param settings_name * The name of the setting that has an invalid value. + * @param print + * Designates how the section error/warning should be printed. */ -#ifndef _di_fake_print_error_fakefile_settings_content_invalid_ - extern void fake_print_error_fakefile_settings_content_invalid(const fake_data data, const f_string path_file, const f_string_dynamic buffer, const f_string_range range_object, const f_string_range range_content, const f_string settings_name) f_gcc_attribute_visibility_internal; -#endif // _di_fake_print_error_fakefile_settings_content_invalid_ - -/** - * Print file/directory error messages. - * - * @todo the fll_file_error_print() needs to be reviewed and possibly changed. - * - * @param data - * The program data. - * @param status - * The error status code to report on. - * @param function - * The function call that returned the error. - * @param name - * The name of the file or directory. - * @param operation - * The operation that fails, such as 'create' or 'access'. - * @param is_file - * Set to TRUE if this is a file and FALSE if this is a directory. - * @param fallback - * Set to F_true to print the fallback error message for unknown errors. - * - * @return - * F_true is returned if the status code has no print message. - * F_false is returned on successful print of known errors. - */ -#ifndef _di_fake_print_error_file_ - extern bool fake_print_error_file(const fake_data data, const f_status status, const f_string function, const f_string name, const f_string operation, const bool is_file, const bool fallback) f_gcc_attribute_visibility_internal; -#endif // _di_fake_print_error_file_ - -/** - * Print FSS error messages. - * - * @param data - * The program data. - * @param status - * The error status code to report on. - * @param function - * The function call that returned the error. - * @param path_file - * The path to the file. - * @param range - * The range representing the position in the buffer such that range.start is where the error happened. - * @param fallback - * Set to F_true to print the fallback error message for unknown errors. - * - * @return - * F_true is returned if the status code has no print message. - * F_false is returned on successful print of known errors. - */ -#ifndef _di_fake_print_error_fss_ - extern bool fake_print_error_fss(const fake_data data, const f_status status, const f_string function, const f_string path_file, const f_string_range range, const bool fallback) f_gcc_attribute_visibility_internal; -#endif // _di_fake_print_error_fss_ - -/** - * Print an error message for when the parameter is missing its accompanying value. - * - * @param data - * The program data. - * @param parameter - * The parameter name. - */ -#ifndef _di_fake_print_error_parameter_missing_value_ - extern void fake_print_error_parameter_missing_value(const fake_data data, const f_string parameter) f_gcc_attribute_visibility_internal; -#endif // _di_fake_print_error_parameter_missing_value_ +#ifndef _di_fake_print_warning_settings_content_invalid_ + extern void fake_print_warning_settings_content_invalid(const fake_data data, const f_string path_file, const f_string_dynamic buffer, const f_string_range range_object, const f_string_range range_content, const f_string settings_name) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_warning_settings_content_invalid_ /** - * Print an error message for when the parameter is specified too many times. - * - * @param data - * The program data. - * @param parameter - * The parameter name. - */ -#ifndef _di_fake_print_error_parameter_too_many_ - extern void fake_print_error_parameter_too_many(const fake_data data, const f_string parameter) f_gcc_attribute_visibility_internal; -#endif // _di_fake_print_error_parameter_too_many_ - -/** - * Print warning message when fakefile has too many objects with the same name. + * Print warning message when settings content has too many values. * * @param data * The program data. @@ -271,17 +336,15 @@ extern "C" { * The path to the fakefile. * @param buffer * The buffer containing the loaded file content. - * @param label - * A label describing what this object belongs to. * @param name_object * The name of the object. */ -#ifndef _di_fake_print_warning_fakefile_object_multiple_ - extern void fake_print_warning_fakefile_object_multiple(const fake_data data, const f_string path_file, const f_string label, const f_string name_object) f_gcc_attribute_visibility_internal; -#endif // _di_fake_print_warning_fakefile_object_multiple_ +#ifndef _di_fake_print_warning_settings_content_multiple_ + extern void fake_print_warning_settings_content_multiple(const fake_data data, const f_string path_file, const f_string name_object) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_warning_settings_content_multiple_ /** - * Print warning message when settings content has too many values. + * Print warning message when fakefile has too many objects with the same name. * * @param data * The program data. @@ -289,12 +352,14 @@ extern "C" { * The path to the fakefile. * @param buffer * The buffer containing the loaded file content. + * @param label + * A label describing what this object belongs to. * @param name_object * The name of the object. */ -#ifndef _di_fake_print_warning_settings_content_multiple_ - extern void fake_print_warning_settings_content_multiple(const fake_data data, const f_string path_file, const f_string name_object) f_gcc_attribute_visibility_internal; -#endif // _di_fake_print_warning_settings_content_multiple_ +#ifndef _di_fake_print_warning_settings_object_multiple_ + extern void fake_print_warning_settings_object_multiple(const fake_data data, const f_string path_file, const f_string label, const f_string name_object) f_gcc_attribute_visibility_internal; +#endif // _di_fake_print_warning_settings_object_multiple_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fake/c/private-skeleton.c b/level_3/fake/c/private-skeleton.c index c051124..e95d3ac 100644 --- a/level_3/fake/c/private-skeleton.c +++ b/level_3/fake/c/private-skeleton.c @@ -1,6 +1,7 @@ -#include +#include "fake.h" #include "private-fake.h" #include "private-build.h" +#include "private-make.h" #include "private-print.h" #include "private-skeleton.h" diff --git a/level_3/fake/documents/fakefile.txt b/level_3/fake/documents/fakefile.txt index 6104a42..56a33b8 100644 --- a/level_3/fake/documents/fakefile.txt +++ b/level_3/fake/documents/fakefile.txt @@ -77,6 +77,13 @@ Fakefile Documentation: Accepts an optional Content that is a path to a build settings file to use instead of the default. + - break\: + Perform an exit from the current make operation. + This only exists the current depth. + If the depth is at the top (aka: 0), then this is identical to the "exit" section operation. + The second Content may be either 'succeed' or 'fail' to designate on whether or not to exit as success or failure. + When set to "failure" this will trigger any failure (with message), depending on the current fail state. + - clean\: Run the fake clean operation as if "fake clean" was run instead of "fake make". Command line arguments are automatically passed to the fake build operation. @@ -110,6 +117,14 @@ Fakefile Documentation: An else operation may not follow this. An if operation may immediately follow to represent an "else if" condition. + - exit\: + Perform an exit from the entire make operation. + This always exits completely, regardless of the operation depth. + The second Content may be either 'success' or 'failure' to designate on whether or not to exit as success or failure. + + When set to "failure" this will trigger a failure message. + When set to "failure", the fail state will be forcibly changed to "fail" regardless of the currrent fail state. + - fail\: Toggle how the to handle an operation failure. @@ -132,7 +147,68 @@ Fakefile Documentation: May be specified following a valid "else" operation. The Content represents a set of conditions to perform. - @todo: determine what these conditions will be, such as "if equals 'some string'", "if defined 'some_variable'", "if exists 'some_file'", "if fail", "if succeed", or "if a == b". + + conditions\: + == "left" "right"\: + compare all parameters to be equal. + requires 2 or more after the "==". + for example, "if == 'a' 'b' 'c' 'd'" would test: 'a' == 'b' && 'b' == 'c' && 'c' == 'd'. + + > "left string" "right string"\: + compare "left" to "right" for greater than. + requires 2 or more after the ">". + for example, "if > 0 1 2 3" would test: 0 > 1 && 1 > 2 && 2 > 3. + + < "left string" "right string"\: + compare "left" to "right" for less than. + requires 2 or more after the ">". + for example, "if < 0 1 2 3" would test: 0 < 1 && 1 < 2 && 2 < 3. + + >= "left string" "right string"\: + compare "left" to "right" for greater than or equal to. + requires 2 or more after the ">=". + for example, "if >= 0 1 2 3" would test: 0 >= 1 && 1 >= 2 && 2 >= 3. + + <= "left string" "right string"\: + compare "left" to "right" for less than or equal to. + requires 2 or more after the ">=". + for example, "if <= 0 1 2 3" would test: 0 <= 1 && 1 <= 2 && 2 <= 3. + + <> "left" "right"\: + compare all parameters to be not equal. + requires 2 or more after the "==". + for example, "if <> 'a' 'b' 'c'" would test: 'a' <> 'b' && 'b' <> 'c' && 'a' <> 'c'. + + exists "file path"\: + test if file exists. + for example, "if exists "a.txt" "b.txt" would test if both the file a.txt and b.txt exist. + + is block,character,directory,fifo,link,regular,socket "file path"\: + test if file exist and is of the given type, comma separated options with one or more files. + for example, "if is regular,directory "a.txt" "b.txt" would test if both the file a.txt and b.txt exist and are either of type "regular" or type "directory". + + fail\: + test if the previous section operation failed. + + succeed\: + test if the previous section operation succeeded. + + mode is/has "some mode" "some file"\: + test if one or more files has the exact mode ("is") or has at least the given modes ("has"). + for example, "if mode is u+r a.txt b.txt" would test if both file a.txt and b.txt only have owner set to read. + for example, "if mode has u+r a.txt b.txt" would test if both file a.txt and b.txt has owner set to read, and all other modes can be anything. + + owner "some mode" "some file"\: + test if one or more files has the given owner. + for example, "if owner me a.txt b.txt" would test if both file a.txt and b.txt have an owner named "me". + + group "some mode" "some file"\: + for example, "if owner we a.txt b.txt" would test if both file a.txt and b.txt have a group named "we". + + defined parameter/environment "some define name"\: + test if one or more names are defined as a "parameter" or an "environment" variable. + for example, "if defined parameter verbose silent" would test if both the "verbose" and the "silent" variables are defined via the "parameter" setting. + for example, "if defined environment PWD SHELL" would test if both the "PWD" and the "SHELL" variables are defined via the "environment" variables. - link\: Create a symbolic link from some point to some target. diff --git a/level_3/fake/specifications/fakefile.txt b/level_3/fake/specifications/fakefile.txt index 279088d..2ac9ada 100644 --- a/level_3/fake/specifications/fakefile.txt +++ b/level_3/fake/specifications/fakefile.txt @@ -4,15 +4,15 @@ Fakefile Specification: The "fakefile" file follows the FSS-0005 (Somewhat Basic List) format with a sub-fomat of IKI-0002 (Simple Script). A fakefile is broken up into multiple Basic Lists, referred to as Sections, with two special purpose reserved Sections. - The Sections are broken up into multiple Extended Objects and their respective Contents, referred to as Operations. + The Sections are broken up into multiple Extended Objects and their respective Contents, referred to as Section Operations. - Each of these non-reserved Sections acts as a set to perform some set of Operations. - Each of these Operations perform a single command or action based on a set of reserved Operation types. - Each of these Operations have a set of Arguments associated with them. + Each of these non-reserved Sections acts as a set to perform some set of Section Operations. + Each of these Section Operations perform a single command or action based on a set of reserved Section Operation types. + Each of these Section Operations have a set of Arguments associated with them. How these Arguments are interpreted and processed are specific to each Operation type. - The Operations are represented by the Extended Object name and the Extended Content represents the Operation Arguments. - Each of these Operations support IKI variable substitution within their respective Arguments. + The Section Operations are represented by the Extended Object name and the Extended Content represents the Operation Arguments. + Each of these Section Operations support IKI variable substitution within their respective Arguments. The Operation Extended Object does not support IKI variable substitution. The reserved Settings Section does not support IKI variable substitution. @@ -43,8 +43,9 @@ Fakefile Specification: The build settings may also be specified in the Settings Section. - The Operation Objects are\: + The Section Operation Objects are\: - archive: One or more Content. + - break: Zero or One Content. If specified, First content must be one of "success" or "failure". - build: Zero or One Content. First Content represents path to the settings file, relative to the project root. - clean: Zero Content. - compile: One or more Content as parameters to compiler. @@ -52,6 +53,7 @@ Fakefile Specification: - delete: One or more Content representing paths to files. - deletes: One or more Content representing paths to files. - else: Zero Content. + - exit: Zero or One Content. If specified, First content must be one of "succeed" or "fail". - fail: One Content. First Content must be one of "exit", "warn", or "ignore" (case-sensitive). - group: Two or more Content. First Content is group name or number, remaining Content are paths to files. - groups: Two or more Content. First Content is group name or number, remaining Content are paths to files. @@ -70,3 +72,18 @@ Fakefile Specification: - to: One Content. First Content is the directory path. - top: Zero Content. - touch: Two or more Content. First content is one of "file" or "directory", remaining Content are paths to files. + + The "if" Section Operation conditions are\: + - ==: Two or more Content. + - >: Two or more Content. + - <: Two or more Content. + - <=: Two or more Content. + - <=: Two or more Content. + - <>: Two or more Content. + - defined: First Content is either "parameter" or "environment". Second or more Content are valid names, such that for "parameter" it is a valid IKI name and for "environment" it is a valid environment variable name. + - fail: has no other Content. + - group: First Content is the name of a group. Second or more Content are paths to files. + - is: First Content is a comma separate list of "block", "character", "directory", "fifo", "link", "regular" , or "socket". Second or more are paths to files. + - mode: First Content is either "is" or "has". Second Content is a valid file mode. Third or more Content are paths to files. + - owner: First Content is the name of an owner. Second or more Content are paths to files. + - succeed: has no other Content. -- 1.8.3.1