From: Kevin Day Date: Wed, 30 Mar 2022 02:10:44 +0000 (-0500) Subject: Update: Make Utf8 private data private and move the program data into the main. X-Git-Tag: 0.5.9~49 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=b3cae5d1612ddc6b131559d24b18e0da13b1330e;p=fll Update: Make Utf8 private data private and move the program data into the main. Move parameter initialization and deallocation for fll program data into main.c. Move the utf8 data into the private files. --- diff --git a/level_3/utf8/c/common.c b/level_3/utf8/c/common.c index a02780d..ad3b961 100644 --- a/level_3/utf8/c/common.c +++ b/level_3/utf8/c/common.c @@ -69,13 +69,6 @@ extern "C" { const f_string_static_t utf8_long_to_width_s = macro_f_string_static_t_initialize(UTF8_long_to_width_s, 0, UTF8_long_to_width_s_length); #endif // _di_utf8_parameters_ -#ifndef _di_utf8_main_delete_ - f_status_t utf8_main_delete(fll_program_data_t *main) { - - return fll_program_data_delete(main); - } -#endif // _di_utf8_main_delete_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/utf8/c/common.h b/level_3/utf8/c/common.h index 27213c4..092b240 100644 --- a/level_3/utf8/c/common.h +++ b/level_3/utf8/c/common.h @@ -309,25 +309,6 @@ extern "C" { #define utf8_mode_to_width_d 0x20 #endif // _di_utf8_modes_ -/** - * Deallocate main. - * - * Be sure to call this after executing utf8_main(). - * - * @param main - * The main program data. - * - * @return - * F_none on success. - * - * Status codes (with error bit) are returned on any problem. - * - * @see utf8_main() - */ -#ifndef _di_utf8_main_delete_ - extern f_status_t utf8_main_delete(fll_program_data_t *main); -#endif // _di_utf8_main_delete_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_3/utf8/c/main.c b/level_3/utf8/c/main.c index 89d9858..cacae5f 100644 --- a/level_3/utf8/c/main.c +++ b/level_3/utf8/c/main.c @@ -5,6 +5,10 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { const f_console_arguments_t arguments = macro_f_console_arguments_t_initialize(argc, argv, envp); fll_program_data_t data = fll_program_data_t_initialize; + f_console_parameter_t parameters[] = utf8_console_parameter_t_initialize; + data.parameters.array = parameters; + data.parameters.used = utf8_total_parameters_d; + if (f_pipe_input_exists()) { data.process_pipe = F_true; } @@ -15,6 +19,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { fll_program_standard_setdown(&data.signal); + fll_program_data_delete(&data); + if (F_status_is_error(status)) return 1; return 0; diff --git a/level_3/utf8/c/private-common.c b/level_3/utf8/c/private-common.c index 8152b4a..6a7b232 100644 --- a/level_3/utf8/c/private-common.c +++ b/level_3/utf8/c/private-common.c @@ -6,6 +6,18 @@ extern "C" { #endif +#ifndef _di_utf8_data_delete_ + void utf8_data_delete(utf8_data_t *data) { + + if (data->file.stream != data->main->output.to.stream) { + f_file_stream_close(F_true, &data->file); + } + + f_string_dynamic_resize(0, &data->buffer); + f_string_dynamic_resize(0, &data->text); + } +#endif // _di_utf8_data_delete_ + #ifndef _di_utf8_signal_received_ f_status_t utf8_signal_received(utf8_data_t * const data) { diff --git a/level_3/utf8/c/private-common.h b/level_3/utf8/c/private-common.h index 3baa637..5cff7cf 100644 --- a/level_3/utf8/c/private-common.h +++ b/level_3/utf8/c/private-common.h @@ -82,6 +82,19 @@ extern "C" { #endif // _di_utf8_data_t_ /** + * Deallocate program data. + * + * @param data + * The program data. + * + * @return + * F_none on success. + */ +#ifndef _di_utf8_data_delete_ + extern void utf8_data_delete(utf8_data_t *data) F_attribute_visibility_internal_d; +#endif // _di_utf8_data_delete_ + +/** * Check to see if a process signal is received. * * Only signals that are blocked via main.signal will be received. diff --git a/level_3/utf8/c/private-utf8.c b/level_3/utf8/c/private-utf8.c index ec32490..f616bc9 100644 --- a/level_3/utf8/c/private-utf8.c +++ b/level_3/utf8/c/private-utf8.c @@ -9,18 +9,6 @@ extern "C" { #endif -#ifndef _di_utf8_data_delete_ - void utf8_data_delete(utf8_data_t *data) { - - if (data->file.stream != data->main->output.to.stream) { - f_file_stream_close(F_true, &data->file); - } - - f_string_dynamic_resize(0, &data->buffer); - f_string_dynamic_resize(0, &data->text); - } -#endif // _di_utf8_data_delete_ - #ifndef _di_utf8_process_text_ f_status_t utf8_process_text(utf8_data_t * const data, f_string_static_t text) { diff --git a/level_3/utf8/c/private-utf8.h b/level_3/utf8/c/private-utf8.h index f95bf03..53de6b9 100644 --- a/level_3/utf8/c/private-utf8.h +++ b/level_3/utf8/c/private-utf8.h @@ -13,19 +13,6 @@ extern "C" { #endif /** - * Deallocate program data. - * - * @param data - * The program data. - * - * @return - * F_none on success. - */ -#ifndef _di_utf8_data_delete_ - extern void utf8_data_delete(utf8_data_t *data); -#endif // _di_utf8_data_delete_ - -/** * Convert the text from one format to other another format or verify text. * * @param data diff --git a/level_3/utf8/c/utf8.c b/level_3/utf8/c/utf8.c index 5a36fbd..5e7d92c 100644 --- a/level_3/utf8/c/utf8.c +++ b/level_3/utf8/c/utf8.c @@ -74,10 +74,6 @@ extern "C" { utf8_data_t data = utf8_data_t_initialize; data.main = main; - f_console_parameter_t parameters[] = utf8_console_parameter_t_initialize; - main->parameters.array = parameters; - main->parameters.used = utf8_total_parameters_d; - // Identify priority of color parameters. { f_console_parameter_id_t ids[3] = { utf8_parameter_no_color_e, utf8_parameter_light_e, utf8_parameter_dark_e }; @@ -109,7 +105,6 @@ extern "C" { fll_error_print(main->error, F_status_set_fine(status), "fll_program_parameter_process", F_true); utf8_data_delete(&data); - utf8_main_delete(main); return F_status_set_error(status); } @@ -126,7 +121,6 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_console_parameter_prioritize_right", F_true); - utf8_main_delete(main); utf8_data_delete(&data); return status; @@ -166,7 +160,6 @@ extern "C" { fll_error_print(main->error, F_status_set_fine(status), "f_console_parameter_prioritize_right", F_true); utf8_data_delete(&data); - utf8_main_delete(main); return status; } @@ -199,7 +192,6 @@ extern "C" { fll_error_print(main->error, F_status_set_fine(status), "f_console_parameter_prioritize_right", F_true); utf8_data_delete(&data); - utf8_main_delete(main); return status; } @@ -275,7 +267,6 @@ extern "C" { utf8_print_help(main->output.to, main->context); utf8_data_delete(&data); - utf8_main_delete(main); return F_none; } @@ -284,7 +275,6 @@ extern "C" { fll_program_print_version(main->output.to, utf8_program_version_s); utf8_data_delete(&data); - utf8_main_delete(main); return F_none; } @@ -492,7 +482,6 @@ extern "C" { } utf8_data_delete(&data); - utf8_main_delete(main); if (F_status_is_error(status) || status == F_signal) { return status;