From 4ca37818e1f1ea641dcdab0ec27e8f6a1311af17 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 7 Jun 2020 16:40:24 -0500 Subject: [PATCH] Update: implement --process parameter Looks like I forgot to implement this. The --process parameter is a process name that is prepended to stage file names for the purpose of granting the caller additional flexibility. --- level_3/fake/c/private-build.c | 16 +++++++++++++++- level_3/fake/c/private-build.h | 4 ++++ level_3/fake/c/private-fake.c | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index 763e0fc..462497f 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -2101,6 +2101,20 @@ extern "C" { break; } + if (data.process.used) { + *status = fl_string_append(data.process.string, data.process.used, values[i]); + if (F_status_is_error(*status)) { + fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_append", F_true); + break; + } + + *status = fl_string_append(fake_build_parameter_stage_separator, fake_build_parameter_stage_separator_length, values[i]); + if (F_status_is_error(*status)) { + fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_append", F_true); + break; + } + } + *status = fl_string_append_nulless(names[i], lengths[i], values[i]); if (F_status_is_error(*status)) { fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_dynamic_append_nulless", F_true); @@ -2607,7 +2621,7 @@ extern "C" { *status = f_file_touch(file.string, mode.regular, F_false); if (F_status_is_error(*status)) { - fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "f_file_touch", F_true); + fake_print_error_file(data.context, data.verbosity, F_status_set_fine(*status), "f_file_touch", file.string, "touch", F_true, F_true); } } #endif // _di_fake_build_touch_ diff --git a/level_3/fake/c/private-build.h b/level_3/fake/c/private-build.h index 1cb7df5..db2e898 100644 --- a/level_3/fake/c/private-build.h +++ b/level_3/fake/c/private-build.h @@ -392,6 +392,10 @@ extern "C" { #define fake_build_parameter_object_link_arguments "rcs" #define fake_build_parameter_object_link_arguments_length 3 + + #define fake_build_parameter_stage_separator "-" + + #define fake_build_parameter_stage_separator_length 1 #endif // _di_fake_build_parameter_ /** diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 3397d3a..43447fe 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -482,6 +482,11 @@ extern "C" { &data->settings, }; + bool parameters_validate_word[] = { + F_true, + F_false, + }; + for (uint8_t i = 0; i < 2; i++) { if (data->parameters[parameters_id[i]].result == f_console_result_found) { fake_print_error_parameter_missing_value(data->context, data->verbosity, parameters_name[i]); @@ -497,6 +502,41 @@ extern "C" { f_string_length length = strnlen(arguments.argv[location], f_console_length_size); if (length > 0) { + if (parameters_validate_word[i]) { + f_string_length j = 0; + f_string_length width_max = 0; + + for (j = 0; j < length; j++) { + width_max = length - j; + + status = f_utf_is_word_dash_plus(arguments.argv[location] + j, width_max); + + if (F_status_is_error(status)) { + if (fake_print_error(data->context, data->verbosity, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_unknown && 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 process the parameter '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_process); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "'."); + } + + return status; + } + + if (status == F_false) { + 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 '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s%s", f_console_symbol_long_enable, fake_long_process); + fl_color_print(f_type_error, data->context.error, data->context.reset, "' parameters value '"); + fl_color_print(f_type_error, data->context.notable, data->context.reset, "%s", arguments.argv[location]); + fl_color_print_line(f_type_error, data->context.error, data->context.reset, "' contains non-word, non-dash, and non-plus characters."); + } + + return F_status_set_error(F_parameter); + } + } // for + } + status = fl_string_append(arguments.argv[location], length, parameters_value[i]); if (F_status_is_error(status)) { -- 1.8.3.1