From: Kevin Day Date: Sat, 29 Nov 2025 16:05:13 +0000 (-0600) Subject: Feature: Add fll_program_print_error_parameter_too_few() and fll_program_print_error_... X-Git-Tag: 0.8.0~75 X-Git-Url: https://www.git.kevux.org/?a=commitdiff_plain;h=85f803ec6c585d418f2dbad066f7e3f856f1051e;p=fll Feature: Add fll_program_print_error_parameter_too_few() and fll_program_print_error_parameter_too_many(). --- diff --git a/level_2/fll_program/c/program/print.c b/level_2/fll_program/c/program/print.c index 2e6644a..dde3f6a 100644 --- a/level_2/fll_program/c/program/print.c +++ b/level_2/fll_program/c/program/print.c @@ -492,6 +492,58 @@ extern "C" { } #endif // _di_fll_program_print_error_parameter_support_not_ +#ifndef _di_fll_program_print_error_parameter_too_few_ + f_status_t fll_program_print_error_parameter_too_few(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_number_unsigned_t times) { + #ifndef _di_level_2_parameter_checking_ + if (!print) return F_status_set_error(F_parameter); + #endif // _di_level_2_parameter_checking_ + + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format(macro_fll_program_s(033_the_parameter_single_quote), print->to, print->set->error, print->prefix, print->set->error); + fl_print_format(f_string_format_QQ_single_s.string, print->to, print->notable, symbol, name, print->notable); + + if (times) { + fl_print_format(macro_fll_program_s(072_too_few_times), print->to, print->set->error, print->set->error, print->set->notable, times, print->set->notable, print->set->error, print->set->error, f_string_eol_s); + } + else { + fl_print_format(macro_fll_program_s(071_too_few), print->to, print->set->error, print->set->error, f_string_eol_s); + } + + f_file_stream_unlock(print->to); + + return F_okay; + } +#endif // _di_fll_program_print_error_parameter_too_few_ + +#ifndef _di_fll_program_print_error_parameter_too_many_ + f_status_t fll_program_print_error_parameter_too_many(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_number_unsigned_t times) { + #ifndef _di_level_2_parameter_checking_ + if (!print) return F_status_set_error(F_parameter); + #endif // _di_level_2_parameter_checking_ + + if (print->verbosity < f_console_verbosity_error_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format(macro_fll_program_s(033_the_parameter_single_quote), print->to, print->set->error, print->prefix, print->set->error); + fl_print_format(f_string_format_QQ_single_s.string, print->to, print->notable, symbol, name, print->notable); + + if (times) { + fl_print_format(macro_fll_program_s(070_too_many_times), print->to, print->set->error, print->set->error, print->set->notable, times, print->set->notable, print->set->error, print->set->error, f_string_eol_s); + } + else { + fl_print_format(macro_fll_program_s(069_too_many), print->to, print->set->error, print->set->error, f_string_eol_s); + } + + f_file_stream_unlock(print->to); + + return F_okay; + } +#endif // _di_fll_program_print_error_parameter_too_many_ + #ifndef _di_fll_program_print_error_parameter_value_too_long_ f_status_t fll_program_print_error_parameter_value_too_long(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name) { #ifndef _di_level_2_parameter_checking_ diff --git a/level_2/fll_program/c/program/print.h b/level_2/fll_program/c/program/print.h index 07b2f63..6ecf9c5 100644 --- a/level_2/fll_program/c/program/print.h +++ b/level_2/fll_program/c/program/print.h @@ -712,6 +712,60 @@ extern "C" { #endif // _di_fll_program_print_error_parameter_support_not_ /** + * Print error message for when the parameter is specified too few times. + * + * @param print + * The output structure. + * This locks, uses, and unlocks the file stream. + * @param symbol + * The symbol string prepended to the parameter. + * This locks, uses, and unlocks the file stream. + * This is usually f_console_symbol_few_normal_s. + * @param name + * The parameter name. + * @param times + * (optional) The number of times that is too few. + * + * Set to 0 to not print this number. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_fll_program_print_error_parameter_too_few_ + extern f_status_t fll_program_print_error_parameter_too_few(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_number_unsigned_t times); +#endif // _di_fll_program_print_error_parameter_too_few_ + +/** + * Print error message for when the parameter is specified too many times. + * + * @param print + * The output structure. + * This locks, uses, and unlocks the file stream. + * @param symbol + * The symbol string prepended to the parameter. + * This locks, uses, and unlocks the file stream. + * This is usually f_console_symbol_many_normal_s. + * @param name + * The parameter name. + * @param times + * (optional) The number of times that is too many. + * + * Set to 0 to not print this number. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_fll_program_print_error_parameter_too_many_ + extern f_status_t fll_program_print_error_parameter_too_many(fl_print_t * const print, const f_string_static_t symbol, const f_string_static_t name, const f_number_unsigned_t times); +#endif // _di_fll_program_print_error_parameter_too_many_ + +/** * Print error message for when the parameter value is too long. * * @param print diff --git a/level_2/fll_program/c/program/string.c b/level_2/fll_program/c/program/string.c index 7666a12..903dfb6 100644 --- a/level_2/fll_program/c/program/string.c +++ b/level_2/fll_program/c/program/string.c @@ -76,6 +76,10 @@ extern "C" { " %[[%] options %[]%]", " %[[%] %Q %[]%]", "%]\n%[Received signal code %]", + "%[' is specified too many times.%]%r", + "%[' is specified%] %[%ul%] %[too many times.%]%r", + "%[' is specified too few times.%]%r", + "%[' is specified%] %[%ul%] %[too few times.%]%r", }; #endif // _di_fll_program_s_a_ diff --git a/level_2/fll_program/c/program/string.h b/level_2/fll_program/c/program/string.h index b8b663d..a8dfcbe 100644 --- a/level_2/fll_program/c/program/string.h +++ b/level_2/fll_program/c/program/string.h @@ -106,6 +106,10 @@ extern "C" { fll_program_s_066_option_e, fll_program_s_067_q_bracket_e, fll_program_s_068_receive_signal_e, + fll_program_s_069_too_many_e, + fll_program_s_070_too_many_times_e, + fll_program_s_071_too_few_e, + fll_program_s_072_too_few_times_e, }; // enum #endif // _di_fll_program_s_e_