]> Kevux Git Server - fll/commitdiff
Update: Make Utf8 private data private and move the program data into the main.
authorKevin Day <thekevinday@gmail.com>
Wed, 30 Mar 2022 02:10:44 +0000 (21:10 -0500)
committerKevin Day <thekevinday@gmail.com>
Wed, 30 Mar 2022 02:37:26 +0000 (21:37 -0500)
Move parameter initialization and deallocation for fll program data into main.c.

Move the utf8 data into the private files.

level_3/utf8/c/common.c
level_3/utf8/c/common.h
level_3/utf8/c/main.c
level_3/utf8/c/private-common.c
level_3/utf8/c/private-common.h
level_3/utf8/c/private-utf8.c
level_3/utf8/c/private-utf8.h
level_3/utf8/c/utf8.c

index a02780d740eb4f35769f80204ffe9551f1236668..ad3b9613fdff56c7c804422fbdeeb53c637f4b00 100644 (file)
@@ -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
index 27213c4a8ace3604eb13eeeb53f030c06949f7ea..092b2406d3823b059b701e1456ca403d70c7c03d 100644 (file)
@@ -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
index 89d98583be6d5c70efd65f7383d10d307e9bc338..cacae5f0a5df5f188d879d61f8a2d0f976d10a95 100644 (file)
@@ -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;
index 8152b4aa83134fbd90db3cb812b48a2dcab909e8..6a7b232ce7742f60d8964c6d429704a3dc667e7b 100644 (file)
@@ -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) {
 
index 3baa637a6f4e411506e830d11ed2a2180864c4b5..5cff7cf7d95c91bfe647bfd1956fdfaa38a0fa98 100644 (file)
@@ -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.
index ec3249029feba39562d357bb87b345f555997ba8..f616bc945346850d6c032b1c9742727e9133c429 100644 (file)
@@ -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) {
 
index f95bf03290e78d079465d9847090c97028f4dca1..53de6b95878064a8986a7dc22e37b7952012775d 100644 (file)
@@ -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
index 5a36fbdc8d8ec536bf6e29061d64bd251ed988eb..5e7d92ca1b4ef6c6ada8e95726ece031cb3cf4de 100644 (file)
@@ -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;