From e0a38f924842e4054206873f62ce60ce534dcfd3 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 8 Jun 2023 23:15:10 -0500 Subject: [PATCH] Bugfix: Use arguments passed to fake when processing build with the custom build arguments. The custom build arguments are passed when the make mode is being used to call the build mode. The mode arguments passed to the fake program, these should be propagated into the custom build arguments for the build mode. --- level_3/fake/c/main/build/load.c | 28 +++++++++++++++++++++++----- level_3/fake/c/main/print/message.c | 19 ++++--------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/level_3/fake/c/main/build/load.c b/level_3/fake/c/main/build/load.c index 82e862d..46ff6c1 100644 --- a/level_3/fake/c/main/build/load.c +++ b/level_3/fake/c/main/build/load.c @@ -72,15 +72,33 @@ extern "C" { // Strip the build settings name from the build arguments to generate a list of modes. f_string_statics_t modes_custom = f_string_statics_t_initialize; - modes_custom.used = build_arguments && build_arguments->used > 1 ? build_arguments->used - 1 : 0; - modes_custom.size = 0; + + if (build_arguments) { + if (build_arguments->used > 1) { + modes_custom.used = build_arguments->used - 1; + } + else if (main->setting.modes.used) { + modes_custom.used = main->setting.modes.used; + } + } f_string_static_t modes_custom_array[modes_custom.used]; modes_custom.array = modes_custom_array; - for (f_array_length_t i = 0; i < modes_custom.used; ++i) { - modes_custom.array[i] = build_arguments->array[i + 1]; - } // for + if (build_arguments) { + f_array_length_t i = 0; + + if (build_arguments->used > 1) { + for (; i < modes_custom.used; ++i) { + modes_custom.array[i] = build_arguments->array[i + 1]; + } // for + } + else if (main->setting.modes.used) { + for (; i < main->setting.modes.used; ++i) { + modes_custom.array[i] = main->setting.modes.array[i]; + } // for + } + } f_string_static_t path_file = f_string_static_t_initialize; diff --git a/level_3/fake/c/main/print/message.c b/level_3/fake/c/main/print/message.c index 8f9b967..16fb3e8 100644 --- a/level_3/fake/c/main/print/message.c +++ b/level_3/fake/c/main/print/message.c @@ -21,25 +21,14 @@ extern "C" { fl_print_format("%[' with modes '%]", print->to, print->set->important, print->set->important); - f_string_statics_t modes_custom = f_string_statics_t_initialize; - modes_custom.used = build_arguments && build_arguments->used > 1 ? build_arguments->used - 1 : 0; - modes_custom.size = 0; - - f_string_static_t modes_custom_array[modes_custom.used]; - modes_custom.array = modes_custom_array; - - for (f_array_length_t i = 0; i < modes_custom.used; ++i) { - modes_custom.array[i] = build_arguments->array[i + 1]; - } // for - - // Custom modes are always used if provided, otherwise if any mode is specified, the entire defaults is replaced. - const f_string_statics_t * const modes = modes_custom.used - ? &modes_custom + // Custom modes are always used if provided, otherwise fallback to the passed modes or the default modes. + const f_string_statics_t * const modes = build_arguments && build_arguments->used > 1 + ? build_arguments : main->setting.modes.used ? &main->setting.modes : &setting_build->modes_default; - for (f_array_length_t i = 0; i < modes->used; ) { + for (f_array_length_t i = build_arguments && build_arguments->used > 1 ? 1 : 0; i < modes->used; ) { fl_print_format("%[%Q%]", print->to, print->set->notable, modes->array[i], print->set->notable); -- 1.8.3.1