From 7c4a045ea303e570abb7119a7ecde0a10180aebf Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 30 Mar 2023 23:40:58 -0500 Subject: [PATCH] Bugfix: When specifying a specific section name, do not care if there is no "main" section. When I implemented the feature represented by commit 25671e39d0a275b4a14b1db6612ae46d497c38c7, I apparently forgot to handle this case. This program correctly errors when there is no "main" section. When specifically asking to run a named section rather than the default "main", who cares if there is no "main"? Based on that logic the lack of a "main" section should not be an error. --- level_3/fake/c/private-make-load_fakefile.c | 19 ++---------- level_3/fake/c/private-make-operate.c | 45 ++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/level_3/fake/c/private-make-load_fakefile.c b/level_3/fake/c/private-make-load_fakefile.c index 01ffa0f..e7037e1 100644 --- a/level_3/fake/c/private-make-load_fakefile.c +++ b/level_3/fake/c/private-make-load_fakefile.c @@ -212,24 +212,9 @@ extern "C" { return; } + // Set the id out of range to designate that it is missing. if (missing_main) { - if (data_make->main->error.verbosity != f_console_verbosity_quiet_e) { - flockfile(data_make->main->error.to.stream); - - fl_print_format("%r%[%QThe fakefile '%]", data_make->main->error.to.stream, f_string_eol_s, data_make->main->error.context, data_make->main->error.prefix, data_make->main->error.context); - fl_print_format("%[%Q%]", data_make->main->error.to.stream, data_make->main->error.notable, data_make->data->file_data_build_fakefile, data_make->main->error.notable); - fl_print_format("%[' is missing the required '%]", data_make->main->error.to.stream, data_make->main->error.context, data_make->main->error.context); - fl_print_format("%[%r%]", data_make->main->error.to.stream, data_make->main->error.notable, fake_make_section_main_s, data_make->main->error.notable); - fl_print_format("%[' object.%]%r", data_make->main->error.to.stream, data_make->main->error.context, data_make->main->error.context, f_string_eol_s); - - funlockfile(data_make->main->error.to.stream); - } - - *status = F_status_set_error(F_failure); - - macro_f_fss_set_t_delete_simple(settings); - - return; + data_make->id_main = data_make->fakefile.used; } // Always have the parameter variable "return" map at index 0 and be pre-initialized. diff --git a/level_3/fake/c/private-make-operate.c b/level_3/fake/c/private-make-operate.c index 6feafad..dc80292 100644 --- a/level_3/fake/c/private-make-operate.c +++ b/level_3/fake/c/private-make-operate.c @@ -221,27 +221,44 @@ extern "C" { } } else { - { - const int result = fake_make_operate_section(&data_make, data_make.id_main, §ion_stack, &status); + if (data_make.id_main == data_make.fakefile.used) { + if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + flockfile(data->main->error.to.stream); + + fl_print_format("%r%[%QThe fakefile '%]", data->main->error.to.stream, f_string_eol_s, data->main->error.context, data->main->error.prefix, data->main->error.context); + fl_print_format("%[%Q%]", data->main->error.to.stream, data->main->error.notable, data->file_data_build_fakefile, data->main->error.notable); + fl_print_format("%[' is missing the required '%]", data->main->error.to.stream, data->main->error.context, data->main->error.context); + fl_print_format("%[%r%]", data->main->error.to.stream, data->main->error.notable, fake_make_section_main_s, data->main->error.notable); + fl_print_format("%[' object.%]%r", data->main->error.to.stream, data->main->error.context, data->main->error.context, f_string_eol_s); - if (status == F_child) { - data->main->child = result; + funlockfile(data->main->error.to.stream); } + + status = F_status_set_error(F_failure); } + else { + { + const int result = fake_make_operate_section(&data_make, data_make.id_main, §ion_stack, &status); - if (status != F_child) { - const f_status_t status_path = f_path_change_at(data_make.path.top.id); + if (status == F_child) { + data->main->child = result; + } + } - if (F_status_is_error(status_path) && data->main->warning.verbosity >= f_console_verbosity_verbose_e) { - flockfile(data->main->warning.to.stream); + if (status != F_child) { + const f_status_t status_path = f_path_change_at(data_make.path.top.id); - fl_print_format("%r%[%QFailed change back to original path '%]", data->main->warning.to.stream, f_string_eol_s, data->main->warning.context, data->main->warning.prefix, data->main->warning.context); - fl_print_format("%[%Q%]", data->main->warning.to.stream, data->main->warning.notable, data_make.path.stack.array[0], data->main->warning.notable); - fl_print_format("%[', status code =%] ", data->main->warning.to.stream, data->main->warning.context, data->main->warning.context); - fl_print_format("%[%ui%]", data->main->warning.to.stream, data->main->warning.notable, F_status_set_fine(status_path), data->main->warning.notable); - fl_print_format("%['.%]%r", data->main->warning.to.stream, data->main->warning.context, data->main->warning.context, f_string_eol_s); + if (F_status_is_error(status_path) && data->main->warning.verbosity >= f_console_verbosity_verbose_e) { + flockfile(data->main->warning.to.stream); - funlockfile(data->main->warning.to.stream); + fl_print_format("%r%[%QFailed change back to original path '%]", data->main->warning.to.stream, f_string_eol_s, data->main->warning.context, data->main->warning.prefix, data->main->warning.context); + fl_print_format("%[%Q%]", data->main->warning.to.stream, data->main->warning.notable, data_make.path.stack.array[0], data->main->warning.notable); + fl_print_format("%[', status code =%] ", data->main->warning.to.stream, data->main->warning.context, data->main->warning.context); + fl_print_format("%[%ui%]", data->main->warning.to.stream, data->main->warning.notable, F_status_set_fine(status_path), data->main->warning.notable); + fl_print_format("%['.%]%r", data->main->warning.to.stream, data->main->warning.context, data->main->warning.context, f_string_eol_s); + + funlockfile(data->main->warning.to.stream); + } } } } -- 1.8.3.1