From: Kevin Day Date: Thu, 5 Jan 2023 03:07:56 +0000 (-0600) Subject: Feature: Support passing a fakefile Section name to the main program. X-Git-Tag: 0.6.3~44 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=25671e39d0a275b4a14b1db6612ae46d497c38c7;p=fll Feature: Support passing a fakefile Section name to the main program. This is intuitive and should have already been supported in the project to better transition from GNU Make into Featureless Make. The unknown parameter error is to no longer be thrown. Instead, when the make process in being followed, check to see if any Sections exist in the fakefile matching the main program Section parameters. Fail when this happens. If the Section exists in the fakefile then that Section is operated on. This, for example, now allows for doing something like "fake install" in the same way "make install" works. The "install" Section must exist in the fakefile for this to work. --- diff --git a/level_3/fake/c/common.h b/level_3/fake/c/common.h index d58f0b5..32f311b 100644 --- a/level_3/fake/c/common.h +++ b/level_3/fake/c/common.h @@ -63,8 +63,8 @@ extern "C" { * The program help related data. */ #ifndef _di_fake_program_help_parameters_ - #define FAKE_program_help_parameters_s "operation" - #define FAKE_program_help_parameters_s_length 9 + #define FAKE_program_help_parameters_s "operation / section" + #define FAKE_program_help_parameters_s_length 19 extern const f_string_static_t fake_program_help_parameters_s; #endif // _di_fake_program_help_parameters_ diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index 61e1bc9..3cda2f8 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -82,6 +82,8 @@ extern "C" { fl_print_format(" When piping data to this program, the piped data is treated as if it were prepended to the %[%r%]", file.stream, context.set.notable, fake_make_parameter_variable_fakefile_s, context.set.notable); fl_print_format(" or the %[%r%], depending on the operation.%r%r", file.stream, context.set.notable, fake_make_parameter_variable_settings_s, context.set.notable, f_string_eol_s, f_string_eol_s); + fl_print_format(" A section name from the fakefile that does not conflict with an operation name may be specified when performing the %[%r%] operation.%r%r", file.stream, context.set.notable, fake_other_operation_make_s, context.set.notable, f_string_eol_s, f_string_eol_s); + funlockfile(file.stream); return F_none; @@ -276,14 +278,6 @@ extern "C" { } else { operations[0] = fake_operation_make_e; - - if (!main->process_pipe && main->parameters.remaining.used) { - status = F_status_set_error(F_parameter); - - if (main->error.verbosity != f_console_verbosity_quiet_e) { - fll_print_format("%r%[%QYou failed to specify a valid operation.%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); - } - } } if (F_status_is_error_not(status)) { diff --git a/level_3/fake/c/private-make-operate.c b/level_3/fake/c/private-make-operate.c index c955eec..dd21b4a 100644 --- a/level_3/fake/c/private-make-operate.c +++ b/level_3/fake/c/private-make-operate.c @@ -128,27 +128,113 @@ extern "C" { data_make.error.verbosity = data->main->output.verbosity; - { - const int result = fake_make_operate_section(&data_make, data_make.id_main, §ion_stack, &status); + if (data->main->parameters.remaining.used) { + f_array_length_t i = 0; + f_array_length_t j = 0; + f_string_range_t range = f_string_range_t_initialize; + f_array_length_t index = 0; + + status = F_none; + + // Validate the remaining parameters. + for (i = 0; i < data->main->parameters.remaining.used; ++i) { + + index = data->main->parameters.remaining.array[i]; + + if (!data->main->parameters.arguments.array[index].used) { + status = F_status_set_error(F_parameter); + + break; + } + + range.start = 0; + range.stop = data->main->parameters.arguments.array[index].used - 1; + + for (j = 0; j < data_make.fakefile.used; ++j) { + if (fl_string_dynamic_partial_compare(data->main->parameters.arguments.array[index], data_make.buffer, range, data_make.fakefile.array[j].name) == F_equal_to) break; + } // for + + if (j == data_make.fakefile.used) { + status = F_status_set_error(F_parameter); + + break; + } + } // for + + if (F_status_is_error(status)) { + if (data->main->error.verbosity != f_console_verbosity_quiet_e) { + index = data->main->parameters.remaining.array[i]; + + flockfile(data->main->error.to.stream); + + fl_print_format("%r%[%QThe argument '%]", 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->main->parameters.arguments.array[index], data->main->error.notable); + fl_print_format("%[' is not a valid section name.%]%r", data->main->error.to.stream, data->main->error.context, data->main->error.context, f_string_eol_s); + + funlockfile(data->main->error.to.stream); + } + } + else { + for (i = 0; i < data->main->parameters.remaining.used; ++i) { + + index = data->main->parameters.remaining.array[i]; + range.start = 0; + range.stop = data->main->parameters.arguments.array[index].used - 1; + + for (j = 0; j < data_make.fakefile.used; ++j) { + + if (fl_string_dynamic_partial_compare(data->main->parameters.arguments.array[index], data_make.buffer, range, data_make.fakefile.array[j].name) == F_equal_to) { + { + const int result = fake_make_operate_section(&data_make, j, §ion_stack, &status); + + if (status == F_child) { + data->main->child = result; + } + } + + if (status != F_child) { + const f_status_t status_path = f_path_change_at(data_make.path.top.id); + + if (F_status_is_error(status_path) && data->main->warning.verbosity >= f_console_verbosity_verbose_e) { + flockfile(data->main->warning.to.stream); + + fl_print_format("%r%[%QFailed change back to orignal 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 (status == F_child) { - data->main->child = result; + funlockfile(data->main->warning.to.stream); + } + } + } + } // for + } // for } } + 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 orignal 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 orignal 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); + } } }