]> Kevux Git Server - fll/commitdiff
Update: Move the program data into the main for fss_basic_read.
authorKevin Day <thekevinday@gmail.com>
Thu, 31 Mar 2022 00:10:06 +0000 (19:10 -0500)
committerKevin Day <thekevinday@gmail.com>
Thu, 31 Mar 2022 00:10:06 +0000 (19:10 -0500)
Move parameter initialization and deallocation for FLL program data into main.c.

level_3/fss_basic_read/c/common.c
level_3/fss_basic_read/c/common.h
level_3/fss_basic_read/c/fss_basic_read.c
level_3/fss_basic_read/c/fss_basic_read.h
level_3/fss_basic_read/c/main.c

index c0995538e913a547b540b24ae585b715213ffd8e..388b3a55cc96b7aadd696b860966ef02bc37c333 100644 (file)
@@ -60,13 +60,6 @@ extern "C" {
   const f_string_static_t fss_basic_read_delimit_mode_name_lesser_s = macro_f_string_static_t_initialize(FSS_BASIC_READ_delimit_mode_name_lesser_s, 0, FSS_BASIC_READ_delimit_mode_name_lesser_s_length);
 #endif // _di_fss_basic_read_delimit_mode_
 
-#ifndef _di_fss_basic_read_main_delete_
-  f_status_t fss_basic_read_main_delete(fll_program_data_t * const main) {
-
-    return fll_program_data_delete(main);
-  }
-#endif // _di_fss_basic_read_main_delete_
-
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 879b890c6b85c6769d664c8d1ca5597c1ef3327d..8a843bb298ea0b0d9389dc00c8e9f54a7f1bd540 100644 (file)
@@ -286,25 +286,6 @@ extern "C" {
   };
 #endif // _di_fss_basic_read_delimit_modes_
 
-/**
- * Deallocate main.
- *
- * Be sure to call this after executing fss_basic_read_main().
- *
- * @param main
- *   The main program data.
- *
- * @return
- *   F_none on success.
- *
- *   Status codes (with error bit) are returned on any problem.
- *
- * @see fss_basic_read_main()
- */
-#ifndef _di_fss_basic_read_main_delete_
-  extern f_status_t fss_basic_read_main_delete(fll_program_data_t * const main);
-#endif // _di_fss_basic_read_main_delete_
-
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 71acf22b0439f0fb2db263b07de56a76a1d5621e..f4aac89d40df4cc2165f01b66e2b1d17e2cde49e 100644 (file)
@@ -122,10 +122,6 @@ extern "C" {
 
     f_status_t status = F_none;
 
-    f_console_parameter_t parameters[] = fss_basic_read_console_parameter_t_initialize;
-    main->parameters.array = parameters;
-    main->parameters.used = fss_basic_read_total_parameters_d;
-
     {
       f_console_parameter_id_t ids[3] = { fss_basic_read_parameter_no_color_e, fss_basic_read_parameter_light_e, fss_basic_read_parameter_dark_e };
       const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 3);
@@ -152,11 +148,7 @@ extern "C" {
         fll_program_parameter_process_empty(&main->context, sets);
       }
 
-      if (F_status_is_error(status)) {
-        fss_basic_read_main_delete(main);
-
-        return F_status_set_error(status);
-      }
+      if (F_status_is_error(status)) return status;
     }
 
     // Identify priority of verbosity related parameters.
@@ -166,12 +158,7 @@ extern "C" {
       const f_console_parameter_ids_t choices = macro_f_console_parameter_ids_t_initialize(ids, 4);
 
       status = f_console_parameter_prioritize_right(main->parameters, choices, &choice);
-
-      if (F_status_is_error(status)) {
-        fss_basic_read_main_delete(main);
-
-        return status;
-      }
+      if (F_status_is_error(status)) return status;
 
       if (choice == fss_basic_read_parameter_verbosity_quiet_e) {
         main->output.verbosity = f_console_verbosity_quiet_e;
@@ -200,16 +187,12 @@ extern "C" {
     if (main->parameters.array[fss_basic_read_parameter_help_e].result == f_console_result_found_e) {
       fss_basic_read_print_help(main->output.to, main->context);
 
-      fss_basic_read_main_delete(main);
-
       return status;
     }
 
     if (main->parameters.array[fss_basic_read_parameter_version_e].result == f_console_result_found_e) {
       fll_program_print_version(main->output.to, fss_basic_read_program_version_s);
 
-      fss_basic_read_main_delete(main);
-
       return status;
     }
 
@@ -501,7 +484,6 @@ extern "C" {
         }
 
         fss_basic_read_data_delete_simple(&data);
-        fss_basic_read_main_delete(main);
 
         return F_none;
       }
@@ -646,7 +628,6 @@ extern "C" {
     }
 
     fss_basic_read_data_delete_simple(&data);
-    fss_basic_read_main_delete(main);
 
     return status;
   }
index f21ab8a33d76e472400294fef95521d432b396df..d6d10c58eab08dac830dcf9709ace6d9eac124ba 100644 (file)
@@ -72,8 +72,6 @@ extern "C" {
 /**
  * Execute main program.
  *
- * Be sure to call fss_basic_read_main_delete() after executing this.
- *
  * If main.signal is non-zero, then this blocks and handles the following signals:
  *   - F_signal_abort
  *   - F_signal_broken_pipe
@@ -91,8 +89,6 @@ extern "C" {
  *   F_none on success.
  *
  *   Status codes (with error bit) are returned on any problem.
- *
- * @see fss_basic_read_main_delete()
  */
 #ifndef _di_fss_basic_read_main_
   extern f_status_t fss_basic_read_main(fll_program_data_t * const main, const f_console_arguments_t *arguments);
index 7fdb5b69f78a0d461282c0a2b102ce44aaed3527..3c52bea86174f248b5e6734bfb00271955ddbd00 100644 (file)
@@ -5,6 +5,10 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
   f_console_arguments_t arguments = { argc, argv };
   fll_program_data_t data = fll_program_data_t_initialize;
 
+  f_console_parameter_t parameters[] = fss_basic_read_console_parameter_t_initialize;
+  data.parameters.array = parameters;
+  data.parameters.used = fss_basic_read_total_parameters_d;
+
   if (f_pipe_input_exists()) {
     data.process_pipe = F_true;
   }
@@ -13,6 +17,8 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
   const f_status_t status = fss_basic_read_main(&data, &arguments);
 
+  fll_program_data_delete(&data);
+
   fll_program_standard_setdown(&data.signal);
 
   if (F_status_is_error(status)) return 1;