From: Kevin Day Date: Tue, 21 Feb 2023 04:24:43 +0000 (-0600) Subject: Progress: Continue working on Featureless Make, focusing on printing. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=43352e2ee41a11d74f35ae22ab5bdf5f60d6cea7;p=fll Progress: Continue working on Featureless Make, focusing on printing. I noticed some odd behavior during this process where the file size of the resulting binary is increasing by as little as 72 bytes per function created. I experimentally created a "void example_print(void) { }" function and was able to get that 72 number. Fully populating or using the example_print function did not reduce or noticeably increase the file size. I gave up experimenting and decided to continue on. When I got close to wrapping up the print functions in the make, the resulting binary file size suddenly dropped 10k or so at least. Once that dropped happened the functions no longer appeared to increase file size. I suspect that there was some sort of weird optimization going on. Some of the generic print functions in the fake make will probably be moved into the common directory as common print functions. --- diff --git a/level_3/fake/c/main/make/load_fakefile.c b/level_3/fake/c/main/make/load_fakefile.c index 398c698..c5b2020 100644 --- a/level_3/fake/c/main/make/load_fakefile.c +++ b/level_3/fake/c/main/make/load_fakefile.c @@ -123,7 +123,7 @@ extern "C" { if (fl_string_dynamic_partial_compare_string(fake_make_item_settings_s.string, data_make->buffer, fake_make_item_settings_s.used, list_objects.array[i]) == F_equal_to) { if (!missing_settings) { - fake_make_print_warning_settings_object_multiple(data_make->setting, data_make->main->warning, data_make->data->file_data_build_fakefile, fake_common_setting_list_s, fake_make_item_settings_s); + fake_make_print_warning_settings_object_multiple(data_make->setting, data_make->main->warning, data_make->data->file_data_build_fakefile, fake_make_item_settings_s); continue; } @@ -154,7 +154,7 @@ extern "C" { if (fl_string_dynamic_partial_compare_string(fake_make_item_main_s.string, data_make->buffer, fake_make_item_main_s.used, list_objects.array[i]) == F_equal_to) { if (!missing_main) { - fake_make_print_warning_settings_object_multiple(data_make->setting, data_make->main->warning, data_make->data->file_data_build_fakefile, fake_common_setting_list_s, fake_make_item_main_s); + fake_make_print_warning_settings_object_multiple(data_make->setting, data_make->main->warning, data_make->data->file_data_build_fakefile, fake_make_item_main_s); continue; } diff --git a/level_3/fake/c/main/make/operate_process_type.c b/level_3/fake/c/main/make/operate_process_type.c index a1fd979..eb82cf9 100644 --- a/level_3/fake/c/main/make/operate_process_type.c +++ b/level_3/fake/c/main/make/operate_process_type.c @@ -873,21 +873,11 @@ extern "C" { if (F_status_is_error(status)) { state_process->condition_result = fake_condition_result_error_e; - if (data_make->main->error.verbosity > f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - f_file_stream_lock(data_make->main->error.to); - - if ((i == 1 && number_left > F_number_t_size_unsigned_d) || (i > 1 && number_right > F_number_t_size_unsigned_d)) { - fl_print_format("%r%[%QThe number '%]", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); - fl_print_format("%[%Q%]", data_make->main->error.to, data_make->error.notable, data_make->cache_arguments.array[i], data_make->error.notable); - fl_print_format("%[' may only be between the ranges -%un to %un.%]%r", data_make->main->error.to, data_make->error.context, F_number_t_size_unsigned_d, F_number_t_size_unsigned_d, data_make->error.context, f_string_eol_s); - } - else { - fl_print_format("%r%[%QInvalid or unsupported number provided '%]", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); - fl_print_format("%[%Q%]", data_make->main->error.to, data_make->error.notable, data_make->cache_arguments.array[i], data_make->error.notable); - fl_print_format("%['.%]%r", data_make->main->error.to, data_make->error.context, F_number_t_size_unsigned_d, F_number_t_size_unsigned_d, data_make->error.context, f_string_eol_s); - } - - f_file_stream_unlock(data_make->main->error.to); + if ((i == 1 && number_left > F_number_t_size_unsigned_d) || (i > 1 && number_right > F_number_t_size_unsigned_d)) { + fake_make_print_error_out_of_range_number(data_make->setting, data_make->main->error, data_make->cache_arguments.array[i], F_number_t_size_unsigned_d, F_number_t_size_unsigned_d); + } + else { + fake_make_print_error_unsupported_number(data_make->setting, data_make->main->error, data_make->cache_arguments.array[i]); } return F_status_set_error(F_failure); diff --git a/level_3/fake/c/main/make/operate_validate.c b/level_3/fake/c/main/make/operate_validate.c index 3a6a380..4d64e09 100644 --- a/level_3/fake/c/main/make/operate_validate.c +++ b/level_3/fake/c/main/make/operate_validate.c @@ -91,16 +91,10 @@ extern "C" { f_status_t fake_make_operate_validate_define_name(const f_string_static_t name) { if (!name.used) return F_none; - - if (!isalpha(name.string[0]) && name.string[0] != '_') { - return F_false; - } + if (!isalpha(name.string[0]) && name.string[0] != '_') return F_false; for (f_array_length_t i = 1; i < name.used; ++i) { - - if (!isalnum(name.string[i]) && name.string[i] != '_') { - return F_false; - } + if (!isalnum(name.string[i]) && name.string[i] != '_') return F_false; } // for return F_true; diff --git a/level_3/fake/c/main/make/operate_validate_type.c b/level_3/fake/c/main/make/operate_validate_type.c index 65dc896..3e0e79b 100644 --- a/level_3/fake/c/main/make/operate_validate_type.c +++ b/level_3/fake/c/main/make/operate_validate_type.c @@ -178,14 +178,14 @@ extern "C" { if (state_process->operation == fake_make_operation_type_if_e) { if (state_process->operation_previous == fake_make_operation_type_if_e) { - fake_make_print_error_not_after_condition(data_make->setting, data_make->main->error, "Must not be"); + fake_make_print_error_after_condition_must_not(data_make->setting, data_make->main->error); return F_status_set_error(F_failure); } } else { if (!(state_process->operation_previous == fake_make_operation_type_if_e || state_process->operation_previous == fake_make_operation_type_and_e || state_process->operation_previous == fake_make_operation_type_or_e)) { - fake_make_print_error_not_after_condition(data_make->setting, data_make->main->error, "May only be"); + fake_make_print_error_after_condition_may_only(data_make->setting, data_make->main->error); return F_status_set_error(F_failure); } @@ -715,53 +715,19 @@ extern "C" { f_status_t fake_make_operate_validate_type_else(fake_make_data_t * const data_make, fake_state_process_t * const state_process) { if (state_process->operation_previous == fake_make_operation_type_else_e) { - //fake_make_print_operate_set_path_verbose(data_make->setting, data_make->main->error, f_string_empty_s); - - if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - f_file_stream_lock(data_make->main->error.to); - - fl_print_format("%r%[%QMust not be used immediately after another '%]", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); - fl_print_format("%[%r%]", data_make->main->error.to, data_make->error.notable, fake_make_operation_else_s, data_make->error.notable); - fl_print_format("%[' section operation.%]%r", data_make->main->error.to, data_make->error.context, data_make->error.context, f_string_eol_s); - - f_file_stream_unlock(data_make->main->error.to); - } + fake_make_print_error_after_condition_must_not(data_make->setting, data_make->main->error); return F_status_set_error(F_failure); } if (state_process->operation_previous == fake_make_operation_type_if_e || state_process->operation_previous == fake_make_operation_type_and_e || state_process->operation_previous == fake_make_operation_type_or_e) { - //fake_make_print_operate_set_path_verbose(data_make->setting, data_make->main->error, f_string_empty_s); - - if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - f_file_stream_lock(data_make->main->error.to); - - fl_print_format("%r%[%QMust not be used immediately after an '%]", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); - fl_print_format("%[%r%]", data_make->main->error.to, data_make->error.notable, fake_make_operation_if_s, data_make->error.notable); - fl_print_format("%[', '%]", data_make->main->error.to, data_make->error.context, data_make->error.context); - fl_print_format("%[%r%]", data_make->main->error.to, data_make->error.notable, fake_make_operation_and_s, data_make->error.notable); - fl_print_format("%[', or '%]", data_make->main->error.to, data_make->error.context, data_make->error.context); - fl_print_format("%[%r%]", data_make->main->error.to, data_make->error.notable, fake_make_operation_or_s, data_make->error.notable); - fl_print_format("%[' section operation.%]%r", data_make->main->error.to, data_make->error.context, data_make->error.context, f_string_eol_s); - - f_file_stream_unlock(data_make->main->error.to); - } + fake_make_print_error_after_condition_must_not(data_make->setting, data_make->main->error); return F_status_set_error(F_failure); } if (!state_process->block) { - //fake_make_print_operate_set_path_verbose(data_make->setting, data_make->main->error, f_string_empty_s); - - if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - fl_print_format("%r%[%QHas no preceding '%]", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); - fl_print_format("%[%r%]", data_make->main->error.to, data_make->error.notable, fake_make_operation_if_s, data_make->error.notable); - fl_print_format("%[', '%]", data_make->main->error.to, data_make->error.context, data_make->error.context); - fl_print_format("%[%r%]", data_make->main->error.to, data_make->error.notable, fake_make_operation_and_s, data_make->error.notable); - fl_print_format("%[', or '%]", data_make->main->error.to, data_make->error.context, data_make->error.context); - fl_print_format("%[%r%]", data_make->main->error.to, data_make->error.notable, fake_make_operation_or_s, data_make->error.notable); - fl_print_format("%[' section operation.%]%r", data_make->main->error.to, data_make->error.context, data_make->error.context, f_string_eol_s); - } + fake_make_print_error_after_condition_no_preceding(data_make->setting, data_make->main->error); return F_status_set_error(F_failure); } @@ -832,17 +798,7 @@ extern "C" { } if (!data_make->setting_build.build_indexer.used) { - //fake_make_print_operate_set_path_verbose(data_make->setting, data_make->main->error, f_string_empty_s); - - if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - f_file_stream_lock(data_make->main->error.to); - - fl_print_format("%r%[%QNo indexer has been specified, cannot perform '%]", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context); - fl_print_format("%[%r%]", data_make->main->error.to, data_make->error.notable, fake_make_operation_index_s, data_make->error.notable); - fl_print_format("%[' section operation.%]%r", data_make->main->error.to, data_make->error.context, data_make->error.context, f_string_eol_s); - - f_file_stream_unlock(data_make->main->error.to); - } + fake_make_print_error_indexer_not_specified(data_make->setting, data_make->main->error, fake_make_operation_index_s); return F_status_set_error(F_failure); } @@ -995,11 +951,9 @@ extern "C" { } } else { - //fake_make_print_operate_set_path_verbose(data_make->setting, data_make->main->error, f_string_empty_s); + fake_make_print_error_target_file_name_empty(data_make->setting, data_make->main->error); - if (data_make->error.verbosity != f_console_verbosity_quiet_e && data_make->main->error.to.stream) { - fll_print_format("%r%[%QTarget filename argument must not be an empty string.%]%r", data_make->main->error.to, f_string_eol_s, data_make->error.context, data_make->error.prefix, data_make->error.context, f_string_eol_s); - } + status = F_status_set_error(F_failure); } } diff --git a/level_3/fake/c/main/make/print-error.c b/level_3/fake/c/main/make/print-error.c index e422c83..01eb7b3 100644 --- a/level_3/fake/c/main/make/print-error.c +++ b/level_3/fake/c/main/make/print-error.c @@ -64,7 +64,7 @@ extern "C" { fl_print_format("%[%QThe fakefile '%]", print.to, print.context, print.prefix, print.context); fl_print_format("%[%Q%]", print.to, print.notable, fakefile, print.notable); fl_print_format("%[' is missing the required '%]", print.to, print.context, print.context); - fl_print_format("%[%r%]", print.to, print.notable, section, print.notable); + fl_print_format("%[%Q%]", print.to, print.notable, section, print.notable); fl_print_format("%[' section.%]%r", print.to, print.context, print.context, f_string_eol_s); f_file_stream_unlock(print.to); @@ -99,8 +99,15 @@ extern "C" { } #endif // _di_fake_make_print_error_file_type_ -#ifndef _di_fake_make_print_error_not_after_condition_ - f_status_t fake_make_print_error_not_after_condition(fake_setting_t * const setting, const fl_print_t print, const f_string_t message) { +#ifndef _di_fake_make_print_error_indexer_not_specified_ + f_status_t fake_make_print_error_indexer_not_specified(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t action) { + + return fake_make_print_error_simple_variable(setting, print, "No indexer has been specified, cannot perform", action, " section operation"); + } +#endif // _di_fake_make_print_error_indexer_not_specified_ + +#ifndef _di_fake_make_print_error_after_condition_ + f_status_t fake_make_print_error_after_condition(fake_setting_t * const setting, const fl_print_t print, const f_string_t message) { if (print.verbosity < f_console_verbosity_error_e) return F_output_not; @@ -108,7 +115,7 @@ extern "C" { fake_print_line_first_unlocked(setting, print); - fl_print_format("%[%Q%S used immediately after another '%]", print.to, print.context, print.prefix, message, print.context); + fl_print_format("%[%Q%S '%]", print.to, print.context, print.prefix, message, print.context); fl_print_format("%[%r%]", print.to, print.notable, fake_make_operation_if_s, print.notable); fl_print_format("%[', '%]", print.to, print.context, print.context); fl_print_format("%[%r%]", print.to, print.notable, fake_make_operation_and_s, print.notable); @@ -120,7 +127,28 @@ extern "C" { return F_none; } -#endif // _di_fake_make_print_error_not_after_condition_ +#endif // _di_fake_make_print_error_after_condition_ + +#ifndef _di_fake_make_print_error_after_condition_may_only_ + f_status_t fake_make_print_error_after_condition_may_only(fake_setting_t * const setting, const fl_print_t print) { + + return fake_make_print_error_after_condition(setting, print, "May only be used immediately after"); + } +#endif // _di_fake_make_print_error_after_condition_may_only_ + +#ifndef _di_fake_make_print_error_after_condition_must_not_ + f_status_t fake_make_print_error_after_condition_must_not(fake_setting_t * const setting, const fl_print_t print) { + + return fake_make_print_error_after_condition(setting, print, "Must not be used immediately after"); + } +#endif // _di_fake_make_print_error_after_condition_must_not_ + +#ifndef _di_fake_make_print_error_after_condition_no_preceding_ + f_status_t fake_make_print_error_after_condition_no_preceding(fake_setting_t * const setting, const fl_print_t print) { + + return fake_make_print_error_after_condition(setting, print, "Has no preceding"); + } +#endif // _di_fake_make_print_error_after_condition_no_preceding_ #ifndef _di_fake_make_print_error_operation_incomplete_ f_status_t fake_make_print_error_operation_incomplete(fake_setting_t * const setting, const fl_print_t print, const uint8_t operation) { @@ -275,10 +303,17 @@ extern "C" { } #endif // _di_fake_make_print_error_simple_variable_ +#ifndef _di_fake_make_print_error_target_file_name_empty_ + f_status_t fake_make_print_error_target_file_name_empty(fake_setting_t * const setting, const fl_print_t print) { + + return fake_make_print_error_simple(setting, print, "Target file name argument must not be an empty string"); + } +#endif // _di_fake_make_print_error_target_file_name_empty_ + #ifndef _di_fake_make_print_error_unsupported_number_ f_status_t fake_make_print_error_unsupported_number(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t number) { - return fake_make_print_error_simple_variable(setting, print, "setting, print, Invalid or unsupported number provided", number, 0); + return fake_make_print_error_simple_variable(setting, print, "Invalid or unsupported number provided", number, 0); } #endif // _di_fake_make_print_error_unsupported_number_ diff --git a/level_3/fake/c/main/make/print-error.h b/level_3/fake/c/main/make/print-error.h index a6dfa97..fa13ac4 100644 --- a/level_3/fake/c/main/make/print-error.h +++ b/level_3/fake/c/main/make/print-error.h @@ -112,10 +112,6 @@ extern "C" { * This does not alter setting.status. * @param print * The output structure to print to. - * @param fakefile - * The name or path of the file that is empty. - * @param section - * The name of the missing section. * * @return * F_none on success. @@ -191,7 +187,28 @@ extern "C" { #endif // _di_fake_make_print_error_file_type_ /** - * Print error about how using something immediately after a condition statement. + * Print error about a indexer not being specified. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param action + * The action that cannot be performed due to a lack of a compiler. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_error_indexer_not_specified_ + extern f_status_t fake_make_print_error_indexer_not_specified(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t action); +#endif // _di_fake_make_print_error_indexer_not_specified_ + +/** + * Print error about how using something after a condition statement. * * @param setting * The main program settings. @@ -207,9 +224,66 @@ extern "C" { * F_none on success. * F_output_not on success, but no printing is performed. */ -#ifndef _di_fake_make_print_error_not_after_condition_ - extern f_status_t fake_make_print_error_not_after_condition(fake_setting_t * const setting, const fl_print_t print, const f_string_t message); -#endif // _di_fake_make_print_error_not_after_condition_ +#ifndef _di_fake_make_print_error_after_condition_ + extern f_status_t fake_make_print_error_after_condition(fake_setting_t * const setting, const fl_print_t print, const f_string_t message); +#endif // _di_fake_make_print_error_after_condition_ + +/** + * Print error about how using something after a condition statement, for the "may only" case. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_error_after_condition_may_only_ + extern f_status_t fake_make_print_error_after_condition_may_only(fake_setting_t * const setting, const fl_print_t print); +#endif // _di_fake_make_print_error_after_condition_may_only_ + +/** + * Print error about how using something after a condition statement, for the "must not" case. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_error_after_condition_must_not_ + extern f_status_t fake_make_print_error_after_condition_must_not(fake_setting_t * const setting, const fl_print_t print); +#endif // _di_fake_make_print_error_after_condition_must_not_ + +/** + * Print error about how using something after a condition statement, for the "no preceding" case. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_error_after_condition_no_preceding_ + extern f_status_t fake_make_print_error_after_condition_no_preceding(fake_setting_t * const setting, const fl_print_t print); +#endif // _di_fake_make_print_error_after_condition_no_preceding_ /** * Print error about an incomplete operation at the end of a section. @@ -385,7 +459,7 @@ extern "C" { * Print a simple error message with a single string message. * * This is primarily used by numerous error print functions to reduce code. - * This is not used for any error print functions that has more complex format structures. + * This is not used for any error print functions that has complex format structures. * * @param setting * The main program settings. @@ -409,7 +483,7 @@ extern "C" { * Print a simple error message with a before string, an after string, and a string variable. * * This is primarily used by numerous error print functions to reduce code. - * This is not used for any error print functions that has more complex format structures. + * This is not used for any error print functions that has complex format structures. * * @param setting * The main program settings. @@ -422,7 +496,7 @@ extern "C" { * The string being printed before the variable. * @param variable * The string representing the variable. - * @param before + * @param after * The string being printed after the variable. * * @return @@ -434,6 +508,25 @@ extern "C" { #endif // _di_fake_make_print_error_simple_variable_ /** + * Print error about a target file name being an empty string. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_error_target_file_name_empty_ + extern f_status_t fake_make_print_error_target_file_name_empty(fake_setting_t * const setting, const fl_print_t print); +#endif // _di_fake_make_print_error_target_file_name_empty_ + +/** * Print error about number not being supported. * * @param setting diff --git a/level_3/fake/c/main/make/print-warning.c b/level_3/fake/c/main/make/print-warning.c index dbda387..4d2a88b 100644 --- a/level_3/fake/c/main/make/print-warning.c +++ b/level_3/fake/c/main/make/print-warning.c @@ -29,74 +29,28 @@ extern "C" { #ifndef _di_fake_make_print_warning_environment_name_already_added_ f_status_t fake_make_print_warning_environment_name_already_added(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t name) { - if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; - - f_file_stream_lock(print.to); - - fake_print_line_first_unlocked(setting, print); - - fl_print_format("%[%QThe environment name '%]", print.to, print.context, print.prefix, print.context); - fl_print_format("%[%Q%]", print.to, print.notable, name, print.notable); - fl_print_format("%[' is already added, replacing previous value.%]%r", print.to, print.context, print.context, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; + return fake_make_print_warning_simple_variable(setting, print, "The environment name", name, "is already added, replacing previous value"); } #endif // _di_fake_make_print_warning_environment_name_already_added_ #ifndef _di_fake_make_print_warning_environment_name_invalid_ f_status_t fake_make_print_warning_environment_name_invalid(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t name) { - if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; - - f_file_stream_lock(print.to); - - fake_print_line_first_unlocked(setting, print); - - fl_print_format("%[%QThe environment name '%]", print.to, print.context, print.prefix, print.context); - fl_print_format("%[%Q%]", print.to, print.notable, name, print.notable); - fl_print_format("%[' is invalid, ignoring.%]%r", print.to, print.context, print.context, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; + return fake_make_print_warning_simple_variable(setting, print, "The environment name", name, "is invalid, ignoring"); } #endif // _di_fake_make_print_warning_environment_name_invalid_ #ifndef _di_fake_make_print_warning_fakefile_empty_ f_status_t fake_make_print_warning_fakefile_empty(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t fakefile) { - if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; - - f_file_stream_lock(print.to); - - fake_print_line_first_unlocked(setting, print); - - fl_print_format("%[%QThe fakefile '%]", print.to, print.context, print.prefix, print.context); - fl_print_format("%[%Q%]", print.to, print.notable, fakefile, print.notable); - fl_print_format("%[' is empty.%]%r", print.to, print.context, print.context, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; + return fake_make_print_warning_simple_variable(setting, print, "The fakefile", fakefile, "is empty"); } #endif // _di_fake_make_print_warning_fakefile_empty_ #ifndef _di_fake_make_print_warning_file_not_found_ f_status_t fake_make_print_warning_file_not_found(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t file) { - if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; - - f_file_stream_lock(print.to); - - fl_print_format("%[%QThe file '%]", print.to, print.context, print.prefix, print.context); - fl_print_format("%[%Q%]", print.to, print.notable, file, print.notable); - fl_print_format("%[' cannot be found.%]%r", print.to, print.context, print.prefix, print.context, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; + return fake_make_print_warning_simple_variable(setting, print, "The file", file, "cannot be found"); } #endif // _di_fake_make_print_warning_file_not_found_ @@ -112,7 +66,7 @@ extern "C" { fl_print_format("%[%QThe fakefile '%]", print.to, print.context, print.prefix, print.context); fl_print_format("%[%Q%]", print.to, print.notable, fakefile, print.notable); fl_print_format("%[' has empty content for the '%]", print.to, print.context, print.context); - fl_print_format("%[%r%]", print.to, print.notable, name, print.notable); + fl_print_format("%[%Q%]", print.to, print.notable, name, print.notable); fl_print_format("%[' object '%]", print.to, print.context, print.context); fl_print_format("%[%/Q%]", print.to, print.notable, buffer, range, print.notable); fl_print_format("%['.%]%r", print.to, print.context, print.context, f_string_eol_s); @@ -137,7 +91,7 @@ extern "C" { fl_print_format("%[' has invalid content '%]", print.to, print.context, print.context); fl_print_format("%[%/Q%]", print.to, print.notable, buffer, content, print.notable); fl_print_format("%[' for the '%]", print.to, print.context, print.context); - fl_print_format("%[%r%]", print.to, print.notable, name, print.notable); + fl_print_format("%[%Q%]", print.to, print.notable, name, print.notable); fl_print_format("%[' object '%]", print.to, print.context, print.context); fl_print_format("%[%/Q%]", print.to, print.notable, buffer, object, print.notable); fl_print_format("%['.%]%r", print.to, print.context, print.context, f_string_eol_s); @@ -151,26 +105,38 @@ extern "C" { #ifndef _di_fake_make_print_warning_settings_content_multiple_ f_status_t fake_make_print_warning_settings_content_multiple(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t fakefile, const f_string_static_t name) { + return fake_make_print_warning_simple_variables(setting, print, "The fakefile", fakefile, "may only have a single content for the object", name, ", only using the first"); + } +#endif // _di_fake_make_print_warning_settings_content_multiple_ + +#ifndef _di_fake_make_print_warning_settings_object_multiple_ + f_status_t fake_make_print_warning_settings_object_multiple(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t fakefile, const f_string_static_t name) { + + return fake_make_print_warning_simple_variables(setting, print, "The object", name, "in the fakefile", fakefile, "may only be specified once, only using the first"); + } +#endif // _di_fake_make_print_warning_settings_object_multiple_ + +#ifndef _di_fake_make_print_warning_simple_variable_ + f_status_t fake_make_print_warning_simple_variable(fake_setting_t * const setting, const fl_print_t print, const f_string_t before, const f_string_static_t variable, const f_string_t after) { + if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; f_file_stream_lock(print.to); fake_print_line_first_unlocked(setting, print); - fl_print_format("%[%QThe fakefile '%]", print.to, print.context, print.prefix, print.context); - fl_print_format("%[%r%]", print.to, print.notable, fakefile, print.notable); - fl_print_format("%[' may only have a single content for the object '%]", print.to, print.context, print.context); - fl_print_format("%[%Q%]", print.to, print.notable, name, print.notable); - fl_print_format("%[', only using the first.%]%r", print.to, print.context, print.context, f_string_eol_s); + fl_print_format("%[%Q%S '%]", print.to, print.context, print.prefix, before, print.context); + fl_print_format("%[%Q%]", print.to, print.notable, variable, print.notable); + fl_print_format("%['%S.%]%r", print.to, print.context, after, print.context, f_string_eol_s); f_file_stream_unlock(print.to); return F_none; } -#endif // _di_fake_make_print_warning_settings_content_multiple_ +#endif // _di_fake_make_print_warning_simple_variable_ -#ifndef _di_fake_make_print_warning_settings_object_multiple_ - f_status_t fake_make_print_warning_settings_object_multiple(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t fakefile, const f_string_static_t label, const f_string_static_t name) { +#ifndef _di_fake_make_print_warning_simple_variables_ + f_status_t fake_make_print_warning_simple_variables(fake_setting_t * const setting, const fl_print_t print, const f_string_t before, const f_string_static_t first, const f_string_t between, const f_string_static_t second, const f_string_t after) { if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; @@ -178,17 +144,17 @@ extern "C" { fake_print_line_first_unlocked(setting, print); - fl_print_format("%[%QThe object '%]", print.to, print.context, print.prefix, print.context); - fl_print_format("%[%r%]", print.to, print.notable, name, print.notable); - fl_print_format("%[' in the fakefile '%]", print.to, print.context, print.context); - fl_print_format("%[%Q%]", print.to, print.notable, fakefile, print.notable); - fl_print_format("%[' may only be specified once, only using the first.%]%r", print.to, print.context, print.context, f_string_eol_s); + fl_print_format("%[%Q%S '%]", print.to, print.context, print.prefix, before, print.context); + fl_print_format("%[%Q%]", print.to, print.notable, first, print.notable); + fl_print_format("%[' %S '%]", print.to, print.context, between, print.context); + fl_print_format("%[%Q%]", print.to, print.notable, second, print.notable); + fl_print_format("%['%S.%]%r", print.to, print.context, after, print.context, f_string_eol_s); f_file_stream_unlock(print.to); return F_none; } -#endif // _di_fake_make_print_warning_settings_object_multiple_ +#endif // _di_fake_make_print_warning_simple_variables_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fake/c/main/make/print-warning.h b/level_3/fake/c/main/make/print-warning.h index cbbaa06..595cd2c 100644 --- a/level_3/fake/c/main/make/print-warning.h +++ b/level_3/fake/c/main/make/print-warning.h @@ -187,8 +187,6 @@ extern "C" { * The output structure to print to. * @param fakefile * The name or path of the file that is empty. - * @param buffer - * The buffer containing the loaded file content. * @param name * The name of the content. * @@ -212,10 +210,6 @@ extern "C" { * The output structure to print to. * @param fakefile * The name or path of the file that is empty. - * @param buffer - * The buffer containing the loaded file content. - * @param label - * A label describing what this object belongs to. * @param name * The name of the object. * @@ -224,9 +218,69 @@ extern "C" { * F_output_not on success, but no printing is performed. */ #ifndef _di_fake_make_print_warning_settings_object_multiple_ - extern f_status_t fake_make_print_warning_settings_object_multiple(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t fakefile, const f_string_static_t label, const f_string_static_t name); + extern f_status_t fake_make_print_warning_settings_object_multiple(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t fakefile, const f_string_static_t name); #endif // _di_fake_make_print_warning_settings_object_multiple_ +/** + * Print a simple warning message with a before string, an after string, and a string variable. + * + * This is primarily used by numerous error print functions to reduce code. + * This is not used for any error print functions that has more format structures. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param before + * The string being printed before the variable. + * @param variable + * The string representing the variable. + * @param after + * The string being printed after the variable. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_warning_simple_variable_ + extern f_status_t fake_make_print_warning_simple_variable(fake_setting_t * const setting, const fl_print_t print, const f_string_t before, const f_string_static_t variable, const f_string_t after); +#endif // _di_fake_make_print_warning_simple_variable_ + +/** + * Print a simple warning message with a before string, a middle strng, an after string, and two string variables. + * + * This is primarily used by numerous error print functions to reduce code. + * This is not used for any error print functions that has more format structures. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param before + * The string being printed before the variable. + * @param first + * The string representing the first variable. + * @param between + * The string being printed before the variable. + * @param second + * The string representing the second variable. + * @param after + * The string being printed after the variable. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_warning_simple_variables_ + extern f_status_t fake_make_print_warning_simple_variables(fake_setting_t * const setting, const fl_print_t print, const f_string_t before, const f_string_static_t first, const f_string_t between, const f_string_static_t second, const f_string_t after); +#endif // _di_fake_make_print_warning_simple_variables_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/fake/c/main/make/print.c b/level_3/fake/c/main/make/print.c index 6fbdefc..92cca46 100644 --- a/level_3/fake/c/main/make/print.c +++ b/level_3/fake/c/main/make/print.c @@ -41,17 +41,7 @@ extern "C" { #ifndef _di_fake_make_print_operate_break_verbose_ f_status_t fake_make_print_operate_break_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_statics_t arguments) { - if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; - - f_file_stream_lock(print.to); - - fake_print_line_first_unlocked(setting, print); - - fl_print_format("Breaking as '%[%Q%]'.%r", print.to, print.set->notable, arguments.used ? arguments.array[0] : fake_make_operation_argument_success_s, print.set->notable, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; + return fake_make_print_simple_variable_operate_verbose(setting, print, "Breaking as", arguments.used ? arguments.array[0] : fake_make_operation_argument_success_s); } #endif // _di_fake_make_print_operate_break_verbose_ @@ -76,51 +66,21 @@ extern "C" { #ifndef _di_fake_make_print_operate_define_verbose_ f_status_t fake_make_print_operate_define_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t variable) { - if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; - - f_file_stream_lock(print.to); - - fake_print_line_first_unlocked(setting, print); - - fll_print_format("Defined environment variable '%[%Q%]'.%r", print.to, print.set->notable, variable, print.set->notable, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; + return fake_make_print_simple_variable_operate_verbose(setting, print, "Defined environment variable", variable); } #endif // _di_fake_make_print_operate_define_verbose_ #ifndef _di_fake_make_print_operate_delete_verbose_ f_status_t fake_make_print_operate_delete_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t path) { - if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; - - f_file_stream_lock(print.to); - - fake_print_line_first_unlocked(setting, print); - - fll_print_format("Removed '%[%Q%]'.%r", print.to, print.set->notable, path, print.set->notable, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; + return fake_make_print_simple_variable_operate_verbose(setting, print, "Removed", path); } #endif // _di_fake_make_print_operate_delete_verbose_ #ifndef _di_fake_make_print_operate_exiting_as_verbose_ f_status_t fake_make_print_operate_exiting_as_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_statics_t arguments) { - if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; - - f_file_stream_lock(print.to); - - fake_print_line_first_unlocked(setting, print); - - fl_print_format("Exiting as '%[%Q%]'.%r", print.to, print.set->notable, arguments.used ? arguments.array[0] : fake_make_operation_argument_success_s, print.set->notable, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; + return fake_make_print_simple_variable_operate_verbose(setting, print, "Exiting as", arguments.used ? arguments.array[0] : fake_make_operation_argument_success_s); } #endif // _di_fake_make_print_operate_exiting_as_verbose_ @@ -223,17 +183,7 @@ extern "C" { #ifndef _di_fake_make_print_operate_set_path_verbose_ f_status_t fake_make_print_operate_set_path_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t path) { - if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; - - f_file_stream_lock(print.to); - - fake_print_line_first_unlocked(setting, print); - - fl_print_format("Changed project path to '%[%Q%]'.%r", print.to, print.set->notable, path, print.set->notable, f_string_eol_s); - - f_file_stream_unlock(print.to); - - return F_none; + return fake_make_print_simple_variable_operate_verbose(setting, print, "Changed project path to", path); } #endif // _di_fake_make_print_operate_set_path_verbose_ @@ -276,38 +226,45 @@ extern "C" { #ifndef _di_fake_make_print_operate_touch_verbose_ f_status_t fake_make_print_operate_touch_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t path) { - if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; + return fake_make_print_simple_variable_operate_verbose(setting, print, "Touched", path); + } +#endif // _di_fake_make_print_operate_touch_verbose_ + +#ifndef _di_fake_make_print_processing_section_ + f_status_t fake_make_print_processing_section(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t buffer, const f_fss_named_t section) { + + if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; f_file_stream_lock(print.to); fake_print_line_first_unlocked(setting, print); - fl_print_format("Touched '%[%Q%]'.%r", print.to, print.set->notable, path, print.set->notable, f_string_eol_s); + fl_print_format("%[Processing Section '%]", print.to, print.set->important, print.set->important); + fl_print_format("%[%/Q%]", print.to, print.set->notable, buffer, section.name, print.set->notable); + fl_print_format("%['.%]%r", print.to, print.set->important, print.set->important, f_string_eol_s); f_file_stream_unlock(print.to); return F_none; } -#endif // _di_fake_make_print_operate_touch_verbose_ +#endif // _di_fake_make_print_processing_section_ -#ifndef _di_fake_make_print_processing_section_ - f_status_t fake_make_print_processing_section(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t buffer, const f_fss_named_t section) { +#ifndef _di_fake_make_print_simple_variable_operate_verbose_ + f_status_t fake_make_print_simple_variable_operate_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_t message, const f_string_static_t variable) { - if (print.verbosity < f_console_verbosity_normal_e) return F_output_not; + if (print.verbosity < f_console_verbosity_verbose_e) return F_output_not; f_file_stream_lock(print.to); fake_print_line_first_unlocked(setting, print); - fl_print_format("%[Processing Section '%]", print.to, print.set->important, print.set->important); - fl_print_format("%[%/Q%]", print.to, print.set->notable, buffer, section.name, print.set->notable); - fl_print_format("%['.%]%r", print.to, print.set->important, print.set->important, f_string_eol_s); + fll_print_format("%S '%[%Q%]'.%r", print.to, message, print.set->notable, variable, print.set->notable, f_string_eol_s); f_file_stream_unlock(print.to); return F_none; } -#endif // _di_fake_make_print_processing_section_ +#endif // _di_fake_make_print_simple_variable_operate_verbose_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fake/c/main/make/print.h b/level_3/fake/c/main/make/print.h index 6d049c0..d491ecb 100644 --- a/level_3/fake/c/main/make/print.h +++ b/level_3/fake/c/main/make/print.h @@ -351,6 +351,32 @@ extern "C" { extern f_status_t fake_make_print_processing_section(fake_setting_t * const setting, const fl_print_t print, const f_string_static_t buffer, const f_fss_named_t section); #endif // _di_fake_make_print_processing_section_ +/** + * Print simple operate verbose message with a value. + * + * This is primarily used by numerous print functions to reduce code. + * This is not used for any print functions that has complex format structures. + * + * @param setting + * The main program settings. + * (Must be of type fake_setting_t.) + * + * This does not alter setting.status. + * @param print + * The output structure to print to. + * @param message + * The message to print. + * @param variable + * The string representing the variable. + * + * @return + * F_none on success. + * F_output_not on success, but no printing is performed. + */ +#ifndef _di_fake_make_print_simple_variable_operate_verbose_ + extern f_status_t fake_make_print_simple_variable_operate_verbose(fake_setting_t * const setting, const fl_print_t print, const f_string_t message, const f_string_static_t variable); +#endif // _di_fake_make_print_simple_variable_operate_verbose_ + #ifdef __cplusplus } // extern "C" #endif