From f54a2384f021e6ff409c90d825f6e310bd6003bb Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 30 Mar 2023 23:55:36 -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 6c05c66f50719c9edaa36dea75669e03cd558ee4, 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/main/make/load_fakefile.c | 9 ++------- level_3/fake/c/main/make/operate.c | 31 +++++++++++++++++++------------ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/level_3/fake/c/main/make/load_fakefile.c b/level_3/fake/c/main/make/load_fakefile.c index 6c24be1..d5fb93a 100644 --- a/level_3/fake/c/main/make/load_fakefile.c +++ b/level_3/fake/c/main/make/load_fakefile.c @@ -197,14 +197,9 @@ extern "C" { return; } + // Set the id out of range to designate that it is missing. if (missing_main) { - fake_make_print_error_fakefile_section_missing(&data_make->main->program.warning, data_make->data->file_data_build_fakefile, fake_make_item_main_s); - - data_make->main->setting.state.status = F_status_set_error(F_failure); - - f_fss_set_resize(0, &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/main/make/operate.c b/level_3/fake/c/main/make/operate.c index 09f92c1..d89830e 100644 --- a/level_3/fake/c/main/make/operate.c +++ b/level_3/fake/c/main/make/operate.c @@ -183,24 +183,31 @@ extern "C" { } } else { - { - const int result = fake_make_operate_section(&data_make, data_make.id_main, §ion_stack); + if (data_make.id_main == data_make.fakefile.used) { + fake_make_print_error_fakefile_section_missing(&data->main->program.error, data->file_data_build_fakefile, fake_make_item_main_s); - if (data->main->setting.state.status == F_child) { - data->main->program.child = result; - } + data->main->setting.state.status = F_status_set_error(F_failure); } + else { + { + const int result = fake_make_operate_section(&data_make, data_make.id_main, §ion_stack); + + if (data->main->setting.state.status == F_child) { + data->main->program.child = result; + } + } - if (data->main->setting.state.status != F_child) { - const f_status_t status = data->main->setting.state.status; + if (data->main->setting.state.status != F_child) { + const f_status_t status = data->main->setting.state.status; - data->main->setting.state.status = f_path_change_at(data_make.path.top.id); + data->main->setting.state.status = f_path_change_at(data_make.path.top.id); - if (F_status_is_error(data->main->setting.state.status)) { - fake_make_print_warning_cannot_change_back(&data->main->program.warning, data_make.path.stack.array[0]); - } + if (F_status_is_error(data->main->setting.state.status)) { + fake_make_print_warning_cannot_change_back(&data->main->program.warning, data_make.path.stack.array[0]); + } - data->main->setting.state.status = status; + data->main->setting.state.status = status; + } } } -- 1.8.3.1