From 0c0c4dab43a37d90d75a080095e4db307d996f17 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 18 Dec 2021 15:39:17 -0600 Subject: [PATCH] Cleanup: Decompose fakefile setting loading into multiple functions. --- level_3/fake/c/private-make-load_fakefile.c | 607 ++++++++++++++------------ level_3/fake/c/private-make-load_fakefile.h | 160 ++++++- level_3/fake/c/private-make-load_parameters.c | 2 +- level_3/fake/c/private-make-load_parameters.h | 2 +- 4 files changed, 499 insertions(+), 272 deletions(-) diff --git a/level_3/fake/c/private-make-load_fakefile.c b/level_3/fake/c/private-make-load_fakefile.c index 2cc4833..05355d9 100644 --- a/level_3/fake/c/private-make-load_fakefile.c +++ b/level_3/fake/c/private-make-load_fakefile.c @@ -15,7 +15,7 @@ extern "C" { #endif #ifndef _di_fake_make_load_fakefile_ - void fake_make_load_fakefile(fake_main_t * const main, fake_make_data_t *data_make, f_status_t *status) { + void fake_make_load_fakefile(fake_main_t * const main, fake_make_data_t * const data_make, f_status_t *status) { if (F_status_is_error(*status)) return; @@ -263,223 +263,29 @@ extern "C" { if (settings.objects.used) { bool unmatched_fail = F_true; - bool unmatched_load = F_true; + bool unmatched_build = F_true; for (f_array_length_t i = 0; i < settings.objects.used; ++i) { - if (fl_string_dynamic_partial_compare_string(fake_make_setting_compiler_s, data_make->buffer, fake_make_setting_compiler_s_length, settings.objects.array[i]) == F_equal_to) { - if (range_compiler) { - fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_compiler_s); - } - else { - if (settings.contents.array[i].used) { - range_compiler = &settings.contents.array[i].array[0]; - - if (settings.contents.array[i].used > 1) { - fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_compiler_s); - } - } - else { - fake_print_warning_settings_content_empty(main, main->file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], fake_make_section_settings_s); - } - } + if (fl_string_dynamic_partial_compare_string(fake_make_setting_load_build_s, data_make->buffer, fake_make_setting_load_build_s_length, settings.objects.array[i]) == F_equal_to) { + fake_make_load_fakefile_setting_build(main, data_make, &settings.objects.array[i], &settings.contents.array[i], &unmatched_build); + } + else if (fl_string_dynamic_partial_compare_string(fake_make_setting_compiler_s, data_make->buffer, fake_make_setting_compiler_s_length, settings.objects.array[i]) == F_equal_to) { + fake_make_load_fakefile_setting_compiler(main, data_make, &settings.objects.array[i], &settings.contents.array[i], &range_compiler); } else if (fl_string_dynamic_partial_compare_string(fake_make_setting_environment_s, data_make->buffer, fake_make_setting_environment_s_length, settings.objects.array[i]) == F_equal_to) { - f_string_dynamic_t name_define = f_string_dynamic_t_initialize; - - f_array_length_t j = 0; - f_array_length_t k = 0; - - for (; j < settings.contents.array[i].used; ++j) { - - *status = f_string_dynamic_partial_append_nulless(data_make->buffer, settings.contents.array[i].array[j], &name_define); - - if (F_status_is_error(*status)) { - fll_error_print(main->error, F_status_set_fine(*status), "f_string_dynamic_partial_append_nulless", F_true); - break; - } - - *status = f_string_dynamic_terminate_after(&name_define); - - if (F_status_is_error(*status)) { - fll_error_print(main->error, F_status_set_fine(*status), "f_string_dynamic_terminate_after", F_true); - break; - } - - // The environment settings are stored in the build settings rathe than the make settings. - if (fake_make_operate_validate_define_name(name_define) == F_true) { - for (k = 0; k < data_make->setting_build.environment.used; ++k) { - if (fl_string_dynamic_compare(name_define, data_make->setting_build.environment.array[k]) == F_equal_to) { - break; - } - } // for - - if (k == data_make->setting_build.environment.used) { - *status = f_string_dynamics_increase(F_memory_default_allocation_small_d, &data_make->setting_build.environment); - - if (F_status_is_error(*status)) { - fll_error_print(main->error, F_status_set_fine(*status), "f_string_dynamics_increase", F_true); - break; - } - - // Include the terminating NULL when copying. - ++name_define.used; - - *status = f_string_dynamic_append(name_define, &data_make->setting_build.environment.array[data_make->setting_build.environment.used]); - - if (F_status_is_error(*status)) { - fll_error_print(main->error, F_status_set_fine(*status), "f_string_dynamic_append", F_true); - - break; - } - - // Ensure that the terminating NULL is after the end of the string used size. - --data_make->setting_build.environment.array[data_make->setting_build.environment.used++].used; - } - else if (main->warning.verbosity == f_console_verbosity_verbose) { - flockfile(main->warning.to.stream); - - fl_print_format("%c%[%SThe environment name '%]", main->warning.to.stream, f_string_eol_s[0], main->warning.context, main->warning.prefix, main->warning.context); - fl_print_format("%[%Q%]", main->warning.to.stream, main->warning.notable, name_define, main->warning.notable); - fl_print_format("%[' is already added.%]%c", main->warning.to.stream, main->warning.context, main->warning.context, f_string_eol_s[0]); - - funlockfile(main->warning.to.stream); - } - } - else if (main->warning.verbosity == f_console_verbosity_verbose) { - flockfile(main->warning.to.stream); - - fl_print_format("%c%[%SThe environment name '%]", main->warning.to.stream, f_string_eol_s[0], main->warning.context, main->warning.prefix, main->warning.context); - fl_print_format("%[%Q%]", main->warning.to.stream, main->warning.notable, name_define, main->warning.notable); - fl_print_format("%[' is invalid, ignoring.%]%c", main->warning.to.stream, main->warning.context, main->warning.context, f_string_eol_s[0]); - - funlockfile(main->warning.to.stream); - } - - name_define.used = 0; - } // for - - if (F_status_is_error(*status)) { - macro_f_string_dynamic_t_delete_simple(name_define); - - break; - } - - *status = F_none; - macro_f_string_dynamic_t_delete_simple(name_define); + *status = fake_make_load_fakefile_setting_environment(main, data_make, &settings.contents.array[i]); + if (F_status_is_error(*status)) break; } else if (fl_string_dynamic_partial_compare_string(fake_make_setting_fail_s, data_make->buffer, fake_make_setting_fail_s_length, settings.objects.array[i]) == F_equal_to) { - if (unmatched_fail) { - if (settings.contents.array[i].used) { - if (fl_string_dynamic_partial_compare_string(fake_make_operation_argument_exit_s, data_make->buffer, fake_make_operation_argument_exit_s_length, settings.contents.array[i].array[0]) == F_equal_to) { - data_make->setting_make.fail = fake_make_operation_fail_type_exit; - } - else if (fl_string_dynamic_partial_compare_string(fake_make_operation_argument_warn_s, data_make->buffer, fake_make_operation_argument_warn_s_length, settings.contents.array[i].array[0]) == F_equal_to) { - data_make->setting_make.fail = fake_make_operation_fail_type_warn; - } - else if (fl_string_dynamic_partial_compare_string(fake_make_operation_argument_ignore_s, data_make->buffer, fake_make_operation_argument_ignore_s_length, settings.contents.array[i].array[0]) == F_equal_to) { - data_make->setting_make.fail = fake_make_operation_fail_type_ignore; - } - else { - fake_print_warning_settings_content_invalid(main, main->file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], settings.contents.array[i].array[0], fake_make_section_settings_s); - } - - if (settings.contents.array[i].used > 1) { - fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_fail_s); - } - - unmatched_fail = F_false; - } - else { - fake_print_warning_settings_content_empty(main, main->file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], fake_make_section_settings_s); - } - } - else { - fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_fail_s); - } + fake_make_load_fakefile_setting_fail(main, data_make, &settings.objects.array[i], &settings.contents.array[i], &unmatched_fail); } else if (fl_string_dynamic_partial_compare_string(fake_make_setting_indexer_s, data_make->buffer, fake_make_setting_indexer_s_length, settings.objects.array[i]) == F_equal_to) { - if (range_indexer) { - fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_indexer_s); - } - else { - if (settings.contents.array[i].used) { - range_indexer = &settings.contents.array[i].array[0]; - - if (settings.contents.array[i].used > 1) { - fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_indexer_s); - } - } - else { - fake_print_warning_settings_content_empty(main, main->file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], fake_make_section_settings_s); - } - } - } - else if (fl_string_dynamic_partial_compare_string(fake_make_setting_load_build_s, data_make->buffer, fake_make_setting_load_build_s_length, settings.objects.array[i]) == F_equal_to) { - if (unmatched_load) { - if (settings.contents.array[i].used) { - if (fl_string_dynamic_partial_compare_string(fake_common_setting_bool_yes_s, data_make->buffer, fake_common_setting_bool_yes_s_length, settings.contents.array[i].array[0]) == F_equal_to) { - data_make->setting_make.load_build = F_true; - } - else if (fl_string_dynamic_partial_compare_string(fake_common_setting_bool_no_s, data_make->buffer, fake_common_setting_bool_no_s_length, settings.contents.array[i].array[0]) == F_equal_to) { - data_make->setting_make.load_build = F_false; - } - else { - fake_print_warning_settings_content_invalid(main, main->file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], settings.contents.array[i].array[0], fake_make_section_settings_s); - } - - unmatched_load = F_false; - - if (settings.contents.array[i].used > 1) { - fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_load_build_s); - } - } - else { - fake_print_warning_settings_content_empty(main, main->file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], fake_make_section_settings_s); - } - } - else { - fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_load_build_s); - } + fake_make_load_fakefile_setting_indexer(main, data_make, &settings.objects.array[i], &settings.contents.array[i], &range_indexer); } else if (fl_string_dynamic_partial_compare_string(fake_make_setting_parameter_s, data_make->buffer, fake_make_setting_parameter_s_length, settings.objects.array[i]) == F_equal_to) { - if (settings.contents.array[i].used) { - if (fl_string_dynamic_partial_compare_string(fake_make_setting_return_s, data_make->buffer, fake_make_setting_return_s_length, settings.contents.array[i].array[0]) == F_equal_to) { - if (settings.contents.array[i].used > 1) { - f_string_t function_name = 0; - - // Each define replaces the previous define. - data_make->setting_make.parameter.array[0].value.array[0].used = 0; - - for (f_array_length_t j = 1; j < settings.contents.array[i].used; ++j) { - - function_name = "f_string_dynamic_partial_append_nulless"; - *status = f_string_dynamic_partial_append_nulless(data_make->buffer, settings.contents.array[i].array[j], &data_make->setting_make.parameter.array[0].value.array[0]); - - if (F_status_is_error_not(*status)) { - function_name = "f_string_dynamic_terminate_after"; - *status = f_string_dynamic_terminate_after(&data_make->setting_make.parameter.array[0].value.array[0]); - } - - if (F_status_is_error_not(*status) && j + 1 < settings.contents.array[i].used) { - function_name = "f_string_append_assure"; - *status = f_string_append_assure(f_string_space_s, 1, &data_make->setting_make.parameter.array[0].value.array[0]); - } - - if (F_status_is_error(*status)) { - fll_error_print(main->error, F_status_set_fine(*status), function_name, F_true); - - break; - } - } // for - - if (F_status_is_error(*status)) break; - } - } - } - else { - fake_print_warning_settings_content_empty(main, main->file_data_build_fakefile.string, data_make->buffer, settings.objects.array[i], fake_make_section_settings_s); - } + *status = fake_make_load_fakefile_setting_parameter(main, data_make, &settings.objects.array[i], &settings.contents.array[i]); + if (F_status_is_error(*status)) break; } } // for @@ -529,106 +335,369 @@ extern "C" { return; } - f_string_map_multis_t define = f_string_map_multis_t_initialize; + *status = fake_make_load_fakefile_setting_define_and_parameter(main, data_make, &settings); + + macro_f_fss_set_t_delete_simple(settings); + } + } +#endif // _di_fake_make_load_fakefile_ + +#ifndef _di_fake_make_load_fakefile_setting_build_ + void fake_make_load_fakefile_setting_build(fake_main_t * const main, fake_make_data_t * const data_make, f_fss_object_t * const object, f_fss_content_t * const content, bool *unmatched_build) { - // Load the fakefile "settings" as if they are build "settings". - fake_build_load_setting_process(main, F_false, main->file_data_build_fakefile.string, data_make->buffer, settings.objects, settings.contents, &data_make->setting_build, status); + if (*unmatched_build) { + if (content->used) { + if (fl_string_dynamic_partial_compare_string(fake_common_setting_bool_yes_s, data_make->buffer, fake_common_setting_bool_yes_s_length, content->array[0]) == F_equal_to) { + data_make->setting_make.load_build = F_true; + } + else if (fl_string_dynamic_partial_compare_string(fake_common_setting_bool_no_s, data_make->buffer, fake_common_setting_bool_no_s_length, content->array[0]) == F_equal_to) { + data_make->setting_make.load_build = F_false; + } + else { + fake_print_warning_settings_content_invalid(main, main->file_data_build_fakefile.string, data_make->buffer, *object, content->array[0], fake_make_section_settings_s); + } - if (F_status_is_error_not(*status) && settings.objects.used) { - const f_string_t settings_name[] = { - fake_make_setting_define_s, - fake_make_setting_parameter_s, - }; + *unmatched_build = F_false; - const f_array_length_t settings_length[] = { - fake_make_setting_define_s_length, - fake_make_setting_parameter_s_length, - }; + if (content->used > 1) { + fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_load_build_s); + } - f_string_map_multis_t *settings_value[] = { - &define, - &data_make->setting_make.parameter, - }; + return; + } - *status = fll_fss_snatch_map_apart(data_make->buffer, settings.objects, settings.contents, settings_name, settings_length, 2, settings_value, 0, 0); + fake_print_warning_settings_content_empty(main, main->file_data_build_fakefile.string, data_make->buffer, *object, fake_make_section_settings_s); + } + else { + fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_load_build_s); + } + } +#endif // _di_fake_make_load_fakefile_setting_build_ - if (F_status_is_error(*status)) { - fll_error_print(main->error, F_status_set_fine(*status), "fll_fss_snatch_map_apart", F_true); +#ifndef _di_fake_make_load_fakefile_setting_compiler_ + void fake_make_load_fakefile_setting_compiler(fake_main_t * const main, fake_make_data_t * const data_make, f_fss_object_t * const object, f_fss_content_t * const content, f_string_range_t **range_compiler) { - macro_f_string_map_multis_t_delete_simple(define); - macro_f_fss_set_t_delete_simple(settings); + if (*range_compiler) { + fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_compiler_s); - return; - } + return; + } + + if (content->used) { + *range_compiler = &content->array[0]; + + if (content->used > 1) { + fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_compiler_s); } + } + else { + fake_print_warning_settings_content_empty(main, main->file_data_build_fakefile.string, data_make->buffer, *object, fake_make_section_settings_s); + } + } +#endif // _di_fake_make_load_fakefile_setting_compiler_ - if (define.used) { - f_status_t status_validate = F_none; - f_string_dynamic_t combined = f_string_dynamic_t_initialize; +#ifndef _di_fake_make_load_fakefile_setting_define_and_parameter_ + f_status_t fake_make_load_fakefile_setting_define_and_parameter(fake_main_t * const main, fake_make_data_t * const data_make, f_fss_set_t * const settings) { - f_array_length_t i = 0; - f_array_length_t j = 0; + f_status_t status = F_none; + f_string_map_multis_t define = f_string_map_multis_t_initialize; - for (; i < define.used; ++i) { + // Load the fakefile "settings" as if they are build "settings". + fake_build_load_setting_process(main, F_false, main->file_data_build_fakefile.string, data_make->buffer, settings->objects, settings->contents, &data_make->setting_build, &status); - status_validate = fake_make_operate_validate_define_name(define.array[i].name); + if (F_status_is_error_not(status) && settings->objects.used) { + const f_string_t settings_name[] = { + fake_make_setting_define_s, + fake_make_setting_parameter_s, + }; - if (status_validate) { - combined.used = 0; + const f_array_length_t settings_length[] = { + fake_make_setting_define_s_length, + fake_make_setting_parameter_s_length, + }; - for (j = 0; j < define.array[i].value.used; ++j) { + f_string_map_multis_t *settings_value[] = { + &define, + &data_make->setting_make.parameter, + }; - *status = f_string_dynamic_mash(f_string_space_s, 1, define.array[i].value.array[j], &combined); + status = fll_fss_snatch_map_apart(data_make->buffer, settings->objects, settings->contents, settings_name, settings_length, 2, settings_value, 0, 0); - if (F_status_is_error(*status)) { - fll_error_print(main->error, F_status_set_fine(*status), "f_string_dynamic_mash_nulless", F_true); + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "fll_fss_snatch_map_apart", F_true); - break; - } - } // for + macro_f_string_map_multis_t_delete_simple(define); - if (F_status_is_error(*status)) break; + return status; + } + } - *status = f_string_dynamic_terminate_after(&combined); + if (define.used) { + f_status_t status_validate = F_none; + f_string_dynamic_t combined = f_string_dynamic_t_initialize; - if (F_status_is_error(*status)) { - fll_error_print(main->error, F_status_set_fine(*status), "f_string_dynamic_terminate_after", F_true); - break; - } + f_array_length_t i = 0; + f_array_length_t j = 0; - *status = f_environment_set(define.array[i].name.string, combined.string, F_true); + for (; i < define.used; ++i) { - if (F_status_is_error(*status)) { - fll_error_print(main->error, F_status_set_fine(*status), "f_environment_set", F_true); + status_validate = fake_make_operate_validate_define_name(define.array[i].name); + + if (status_validate) { + combined.used = 0; + + for (j = 0; j < define.array[i].value.used; ++j) { + + status = f_string_dynamic_mash(f_string_space_s, 1, define.array[i].value.array[j], &combined); + + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_mash_nulless", F_true); break; } - } - else { - if (main->error.verbosity != f_console_verbosity_quiet) { - flockfile(main->error.to.stream); + } // for - fl_print_format("%c%[%SInvalid characters in the define setting name '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); - fl_print_format("%[%Q%]", main->error.to.stream, main->error.notable, define.array[i].name, main->error.notable); - fl_print_format("%[', only alpha-numeric ASCII characters and underscore (without a leading digit) are allowed.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + if (F_status_is_error(status)) break; - funlockfile(main->error.to.stream); - } + status = f_string_dynamic_terminate_after(&combined); - *status = F_status_set_error(F_failure); + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true); break; } + + status = f_environment_set(define.array[i].name.string, combined.string, F_true); + + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_environment_set", F_true); + + break; + } + } + else { + if (main->error.verbosity != f_console_verbosity_quiet) { + flockfile(main->error.to.stream); + + fl_print_format("%c%[%SInvalid characters in the define setting name '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context); + fl_print_format("%[%Q%]", main->error.to.stream, main->error.notable, define.array[i].name, main->error.notable); + fl_print_format("%[', only alpha-numeric ASCII characters and underscore (without a leading digit) are allowed.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]); + + funlockfile(main->error.to.stream); + } + + status = F_status_set_error(F_failure); + + break; + } + } // for + + macro_f_string_dynamic_t_delete_simple(combined); + } + + macro_f_string_map_multis_t_delete_simple(define); + + if (F_status_is_error(status)) return status; + + return F_none; + } +#endif // _di_fake_make_load_fakefile_setting_define_and_parameter_ + +#ifndef _di_fake_make_load_fakefile_setting_environment_ + f_status_t fake_make_load_fakefile_setting_environment(fake_main_t * const main, fake_make_data_t * const data_make, f_fss_content_t * const content) { + + f_status_t status = F_none; + + f_string_dynamic_t name_define = f_string_dynamic_t_initialize; + + f_array_length_t i = 0; + f_array_length_t j = 0; + + for (; i < content->used; ++i) { + + status = f_string_dynamic_partial_append_nulless(data_make->buffer, content->array[i], &name_define); + + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true); + + break; + } + + status = f_string_dynamic_terminate_after(&name_define); + + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true); + + break; + } + + // The environment settings are stored in the build settings rather than the make settings. + if (fake_make_operate_validate_define_name(name_define) == F_true) { + for (j = 0; j < data_make->setting_build.environment.used; ++j) { + if (fl_string_dynamic_compare(name_define, data_make->setting_build.environment.array[j]) == F_equal_to) break; } // for - macro_f_string_dynamic_t_delete_simple(combined); + if (j == data_make->setting_build.environment.used) { + status = f_string_dynamics_increase(F_memory_default_allocation_small_d, &data_make->setting_build.environment); + + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamics_increase", F_true); + + break; + } + + // Include the terminating NULL when copying. + ++name_define.used; + + status = f_string_dynamic_append(name_define, &data_make->setting_build.environment.array[data_make->setting_build.environment.used]); + + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true); + + break; + } + + // Set the terminating NULL to not being normally included. + --data_make->setting_build.environment.array[data_make->setting_build.environment.used++].used; + } + else if (main->warning.verbosity == f_console_verbosity_verbose) { + flockfile(main->warning.to.stream); + + fl_print_format("%c%[%SThe environment name '%]", main->warning.to.stream, f_string_eol_s[0], main->warning.context, main->warning.prefix, main->warning.context); + fl_print_format("%[%Q%]", main->warning.to.stream, main->warning.notable, name_define, main->warning.notable); + fl_print_format("%[' is already added.%]%c", main->warning.to.stream, main->warning.context, main->warning.context, f_string_eol_s[0]); + + funlockfile(main->warning.to.stream); + } } + else if (main->warning.verbosity == f_console_verbosity_verbose) { + flockfile(main->warning.to.stream); - macro_f_string_map_multis_t_delete_simple(define); - macro_f_fss_set_t_delete_simple(settings); + fl_print_format("%c%[%SThe environment name '%]", main->warning.to.stream, f_string_eol_s[0], main->warning.context, main->warning.prefix, main->warning.context); + fl_print_format("%[%Q%]", main->warning.to.stream, main->warning.notable, name_define, main->warning.notable); + fl_print_format("%[' is invalid, ignoring.%]%c", main->warning.to.stream, main->warning.context, main->warning.context, f_string_eol_s[0]); + + funlockfile(main->warning.to.stream); + } + + name_define.used = 0; + } // for + + macro_f_string_dynamic_t_delete_simple(name_define); + + if (F_status_is_error(status)) return status; + + return F_none; + } +#endif // _di_fake_make_load_fakefile_setting_environment_ + +#ifndef _di_fake_make_load_fakefile_setting_fail_ + void fake_make_load_fakefile_setting_fail(fake_main_t * const main, fake_make_data_t * const data_make, f_fss_object_t * const object, f_fss_content_t * const content, bool *unmatched_fail) { + + if (*unmatched_fail) { + if (content->used) { + if (fl_string_dynamic_partial_compare_string(fake_make_operation_argument_exit_s, data_make->buffer, fake_make_operation_argument_exit_s_length, content->array[0]) == F_equal_to) { + data_make->setting_make.fail = fake_make_operation_fail_type_exit; + } + else if (fl_string_dynamic_partial_compare_string(fake_make_operation_argument_warn_s, data_make->buffer, fake_make_operation_argument_warn_s_length, content->array[0]) == F_equal_to) { + data_make->setting_make.fail = fake_make_operation_fail_type_warn; + } + else if (fl_string_dynamic_partial_compare_string(fake_make_operation_argument_ignore_s, data_make->buffer, fake_make_operation_argument_ignore_s_length, content->array[0]) == F_equal_to) { + data_make->setting_make.fail = fake_make_operation_fail_type_ignore; + } + else { + fake_print_warning_settings_content_invalid(main, main->file_data_build_fakefile.string, data_make->buffer, *object, content->array[0], fake_make_section_settings_s); + } + + if (content->used > 1) { + fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_fail_s); + } + + *unmatched_fail = F_false; + + return; + } + + fake_print_warning_settings_content_empty(main, main->file_data_build_fakefile.string, data_make->buffer, *object, fake_make_section_settings_s); + } + else { + fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_fail_s); } } -#endif // _di_fake_make_load_fakefile_ +#endif // _di_fake_make_load_fakefile_setting_fail_ + +#ifndef _di_fake_make_load_fakefile_setting_indexer_ + void fake_make_load_fakefile_setting_indexer(fake_main_t * const main, fake_make_data_t * const data_make, f_fss_object_t * const object, f_fss_content_t * const content, f_string_range_t **range_indexer) { + + if (*range_indexer) { + fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_indexer_s); + + return; + } + + if (content->used) { + *range_indexer = &content->array[0]; + + if (content->used > 1) { + fake_print_warning_settings_content_multiple(main, main->file_data_build_fakefile.string, fake_make_setting_indexer_s); + } + } + else { + fake_print_warning_settings_content_empty(main, main->file_data_build_fakefile.string, data_make->buffer, *object, fake_make_section_settings_s); + } + } +#endif // _di_fake_make_load_fakefile_setting_indexer_ + +#ifndef _di_fake_make_load_fakefile_setting_parameter_ + f_status_t fake_make_load_fakefile_setting_parameter(fake_main_t * const main, fake_make_data_t * const data_make, f_fss_object_t * const object, f_fss_content_t * const content) { + + if (content->used) { + f_status_t status = F_none; + + if (fl_string_dynamic_partial_compare_string(fake_make_setting_return_s, data_make->buffer, fake_make_setting_return_s_length, content->array[0]) == F_equal_to) { + if (content->used > 1) { + + // Each "return" define replaces the previous "return" define. + data_make->setting_make.parameter.array[0].value.array[0].used = 0; + + for (f_array_length_t i = 1; i < content->used; ++i) { + + status = f_string_dynamic_partial_append_nulless(data_make->buffer, content->array[i], &data_make->setting_make.parameter.array[0].value.array[0]); + + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_partial_append_nulless", F_true); + + break; + } + + status = f_string_dynamic_terminate_after(&data_make->setting_make.parameter.array[0].value.array[0]); + + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true); + + break; + } + + status = f_string_append_assure(f_string_space_s, 1, &data_make->setting_make.parameter.array[0].value.array[0]); + + if (F_status_is_error(status)) { + fll_error_print(main->error, F_status_set_fine(status), "f_string_append_assure", F_true); + + break; + } + } // for + + if (F_status_is_error(status)) return status; + } + } + } + else { + fake_print_warning_settings_content_empty(main, main->file_data_build_fakefile.string, data_make->buffer, *object, fake_make_section_settings_s); + } + + return F_none; + } +#endif // _di_fake_make_load_fakefile_setting_parameter_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fake/c/private-make-load_fakefile.h b/level_3/fake/c/private-make-load_fakefile.h index cec8f52..62994ab 100644 --- a/level_3/fake/c/private-make-load_fakefile.h +++ b/level_3/fake/c/private-make-load_fakefile.h @@ -33,9 +33,167 @@ extern "C" { * @see fake_build_load_setting() */ #ifndef _di_fake_make_load_fakefile_ - extern void fake_make_load_fakefile(fake_main_t * const main, fake_make_data_t *data_make, f_status_t *status) F_attribute_visibility_internal_d; + extern void fake_make_load_fakefile(fake_main_t * const main, fake_make_data_t * const data_make, f_status_t *status) F_attribute_visibility_internal_d; #endif // _di_fake_make_load_fakefile_ +/** + * Load the fakefile setting "build". + * + * @param main + * The main program data. + * @param main_make + * All make related setting data, including data from the fakefile and optionally build settings file. + * @param object + * The setting object. + * @param content + * The setting content. + * @param unmatched_build + * Boolean designating whether or not build is matched and processed. + */ +#ifndef _di_fake_make_load_fakefile_setting_build_ + extern void fake_make_load_fakefile_setting_build(fake_main_t * const main, fake_make_data_t * const data_make, f_fss_object_t * const object, f_fss_content_t * const content, bool *unmatched_build) F_attribute_visibility_internal_d; +#endif // _di_fake_make_load_fakefile_setting_build_ + +/** + * Load the fakefile setting "compiler". + * + * @param main + * The main program data. + * @param main_make + * All make related setting data, including data from the fakefile and optionally build settings file. + * @param object + * The setting object. + * @param content + * The setting content. + * @param range_compiler + * A pointer to the range that representing the compiler setting within the buffer. + */ +#ifndef _di_fake_make_load_fakefile_setting_compiler_ + extern void fake_make_load_fakefile_setting_compiler(fake_main_t * const main, fake_make_data_t * const data_make, f_fss_object_t * const object, f_fss_content_t * const content, f_string_range_t **range_compiler) F_attribute_visibility_internal_d; +#endif // _di_fake_make_load_fakefile_setting_compiler_ + +/** + * Load the fakefile setting "parameter". + * + * @param main + * The main program data. + * @param main_make + * All make related setting data, including data from the fakefile and optionally build settings file. + * @param settings + * The settings data. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_environment_set(). + * Errors (with error bit) from: f_string_dynamic_mash_nulless(). + * Errors (with error bit) from: f_string_dynamic_terminate_after(). + * Errors (with error bit) from: fll_fss_snatch_map_apart(). + * + * @see f_environment_set() + * @see f_string_dynamic_mash_nulless() + * @see f_string_dynamic_terminate_after() + * @see fll_fss_snatch_map_apart() + */ +#ifndef _di_fake_make_load_fakefile_setting_define_and_parameter_ + extern f_status_t fake_make_load_fakefile_setting_define_and_parameter(fake_main_t * const main, fake_make_data_t * const data_make, f_fss_set_t * const settings) F_attribute_visibility_internal_d; +#endif // _di_fake_make_load_fakefile_setting_define_and_parameter_ + +/** + * Load the fakefile setting "environment". + * + * @param main + * The main program data. + * @param main_make + * All make related setting data, including data from the fakefile and optionally build settings file. + * @param content + * The setting content. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_string_dynamic_append(). + * Errors (with error bit) from: f_string_dynamic_partial_append_nulless(). + * Errors (with error bit) from: f_string_dynamic_terminate_after(). + * Errors (with error bit) from: f_string_dynamics_increase(). + * + * @see f_string_dynamic_append() + * @see f_string_dynamic_partial_append_nulless() + * @see f_string_dynamic_terminate_after() + * @see f_string_dynamics_increase() + */ +#ifndef _di_fake_make_load_fakefile_setting_environment_ + extern f_status_t fake_make_load_fakefile_setting_environment(fake_main_t * const main, fake_make_data_t * const data_make, f_fss_content_t * const content) F_attribute_visibility_internal_d; +#endif // _di_fake_make_load_fakefile_setting_environment_ + +/** + * Load the fakefile setting "fail". + * + * @param main + * The main program data. + * @param main_make + * All make related setting data, including data from the fakefile and optionally build settings file. + * @param object + * The setting object. + * @param content + * The setting content. + * @param unmatched_fail + * Boolean designating whether or not fail is matched and processed. + */ +#ifndef _di_fake_make_load_fakefile_setting_fail_ + extern void fake_make_load_fakefile_setting_fail(fake_main_t * const main, fake_make_data_t * const data_make, f_fss_object_t * const object, f_fss_content_t * const content, bool *unmatched_fail) F_attribute_visibility_internal_d; +#endif // _di_fake_make_load_fakefile_setting_fail_ + +/** + * Load the fakefile setting "indexer". + * + * @param main + * The main program data. + * @param main_make + * All make related setting data, including data from the fakefile and optionally build settings file. + * @param object + * The setting object. + * @param content + * The setting content. + * @param range_indexer + * A pointer to the range that representing the indexer setting within the buffer. + */ +#ifndef _di_fake_make_load_fakefile_setting_indexer_ + extern void fake_make_load_fakefile_setting_indexer(fake_main_t * const main, fake_make_data_t * const data_make, f_fss_object_t * const object, f_fss_content_t * const content, f_string_range_t **range_indexer) F_attribute_visibility_internal_d; +#endif // _di_fake_make_load_fakefile_setting_indexer_ + +/** + * Load the fakefile setting "parameter". + * + * This only processes special "parameter" settings, namely "return". + * For all other "parameter" settings, see fake_make_load_fakefile_setting_define_and_parameter(). + * + * @param main + * The main program data. + * @param main_make + * All make related setting data, including data from the fakefile and optionally build settings file. + * @param object + * The setting object. + * @param content + * The setting content. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_string_append_assure(). + * Errors (with error bit) from: f_string_dynamic_partial_append_nulless(). + * Errors (with error bit) from: f_string_dynamic_terminate_after(). + * + * @see f_string_append_assure() + * @see f_string_dynamic_partial_append_nulless() + * @see f_string_dynamic_terminate_after() + * + * @see fake_make_load_fakefile_setting_define_and_parameter() + */ +#ifndef _di_fake_make_load_fakefile_setting_parameter_ + extern f_status_t fake_make_load_fakefile_setting_parameter(fake_main_t * const main, fake_make_data_t * const data_make, f_fss_object_t * const object, f_fss_content_t * const content) F_attribute_visibility_internal_d; +#endif // _di_fake_make_load_fakefile_setting_parameter_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fake/c/private-make-load_parameters.c b/level_3/fake/c/private-make-load_parameters.c index 8c5e03d..53e4613 100644 --- a/level_3/fake/c/private-make-load_parameters.c +++ b/level_3/fake/c/private-make-load_parameters.c @@ -13,7 +13,7 @@ extern "C" { #endif #ifndef _di_fake_make_load_parameters_ - void fake_make_load_parameters(fake_main_t * const main, fake_make_data_t *data_make, f_status_t *status) { + void fake_make_load_parameters(fake_main_t * const main, fake_make_data_t * const data_make, f_status_t *status) { if (F_status_is_error(*status)) return; diff --git a/level_3/fake/c/private-make-load_parameters.h b/level_3/fake/c/private-make-load_parameters.h index cb8f6a1..1c84f7a 100644 --- a/level_3/fake/c/private-make-load_parameters.h +++ b/level_3/fake/c/private-make-load_parameters.h @@ -29,7 +29,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fake_make_load_parameters_ - extern void fake_make_load_parameters(fake_main_t * const main, fake_make_data_t *data_make, f_status_t *status) F_attribute_visibility_internal_d; + extern void fake_make_load_parameters(fake_main_t * const main, fake_make_data_t * const data_make, f_status_t *status) F_attribute_visibility_internal_d; #endif // _di_fake_make_load_parameters_ #ifdef __cplusplus -- 1.8.3.1