]> Kevux Git Server - fll/commitdiff
Update: Simplify code slightly aad remove redundant `fll_program_print_help_header...
authorKevin Day <Kevin@kevux.org>
Wed, 4 Dec 2024 02:05:22 +0000 (20:05 -0600)
committerKevin Day <Kevin@kevux.org>
Wed, 4 Dec 2024 02:05:22 +0000 (20:05 -0600)
Use the variable for `parameters` to simplify code.
This simplifies the code at the cost of using a variable.

Remove include that is not needed from the c files.

Update the documentation comments to have `Properties: `.

Remove redundant `fll_program_print_help_header()` call.

level_3/iki_write/c/eki/eki_write.c
level_3/iki_write/c/iki/iki_write.c
level_3/iki_write/c/main/common.c
level_3/iki_write/c/main/common/type.h
level_3/iki_write/c/main/print/message.c

index eafe5073d91284053fc697689805ad880a030335..c2eb05371a444098f5403f082c23f2823b7a2b2b 100644 (file)
@@ -1,5 +1,4 @@
 #include "eki_write.h"
-#include "../main/iki_write.h"
 
 #ifdef __cplusplus
 extern "C" {
index 42626dd25523038fcd989f39f8630308333ca777..4bd708c8342cff4c47f82f503f1e281e84f8dc7e 100644 (file)
@@ -1,5 +1,4 @@
 #include "iki_write.h"
-#include "../main/iki_write.h"
 
 #ifdef __cplusplus
 extern "C" {
index 2ef9099fbacc44d8fe61e83e0ce40f01ceb6d45d..3fe102848985e1caa004d41eceb69e5511d31513 100644 (file)
@@ -9,9 +9,15 @@ extern "C" {
 
     if (!main) return;
 
+    main->program.output.to.id = F_type_descriptor_output_d;
+    main->program.output.to.stream = F_type_output_d;
+    main->program.output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d;
+
+    f_console_parameters_t * const parameters = &main->program.parameters;
+
     main->setting.state.step_small = iki_write_allocation_console_d;
 
-    f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0);
+    f_console_parameter_process(arguments, parameters, &main->setting.state, 0);
 
     main->setting.state.step_small = iki_write_allocation_small_d;
 
@@ -37,10 +43,6 @@ extern "C" {
       return;
     }
 
-    main->program.output.to.id = F_type_descriptor_output_d;
-    main->program.output.to.stream = F_type_output_d;
-    main->program.output.to.flag = F_file_flag_create_d | F_file_flag_write_only_d | F_file_flag_append_d;
-
     if (callback) {
       callback(arguments, main);
       if (F_status_is_error(main->setting.state.status)) return;
@@ -52,19 +54,19 @@ extern "C" {
       }
     }
 
-    if (main->program.parameters.array[f_console_standard_parameter_help_e].result & f_console_result_found_e) {
+    if (parameters->array[f_console_standard_parameter_help_e].result & f_console_result_found_e) {
       main->setting.flag |= iki_write_main_flag_help_d;
 
       return;
     }
 
-    if (main->program.parameters.array[f_console_standard_parameter_version_e].result & f_console_result_found_e) {
+    if (parameters->array[f_console_standard_parameter_version_e].result & f_console_result_found_e) {
       main->setting.flag |= iki_write_main_flag_version_d;
 
       return;
     }
 
-    if (main->program.parameters.array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) {
+    if (parameters->array[f_console_standard_parameter_copyright_e].result & f_console_result_found_e) {
       main->setting.flag |= iki_write_main_flag_copyright_d;
 
       return;
@@ -77,8 +79,8 @@ extern "C" {
       main->setting.flag &= ~iki_write_main_flag_pipe_d;
     }
 
-    if (main->program.parameters.array[iki_write_parameter_file_e].result & f_console_result_value_e && main->program.parameters.array[iki_write_parameter_file_e].values.used) {
-      if (main->program.parameters.array[iki_write_parameter_file_e].values.used > 1) {
+    if (parameters->array[iki_write_parameter_file_e].result & f_console_result_value_e && parameters->array[iki_write_parameter_file_e].values.used) {
+      if (parameters->array[iki_write_parameter_file_e].values.used > 1) {
         main->setting.state.status = F_status_set_error(F_parameter);
 
         fll_program_print_error_parameter_must_specify_once(&main->program.error, f_console_symbol_long_normal_s, iki_write_long_file_s);
@@ -86,22 +88,22 @@ extern "C" {
         return;
       }
 
-      const f_number_unsigned_t index = main->program.parameters.array[iki_write_parameter_file_e].values.array[0];
+      const f_number_unsigned_t index = parameters->array[iki_write_parameter_file_e].values.array[0];
 
       main->program.output.to.id = -1;
       main->program.output.to.stream = 0;
 
-      main->setting.state.status = f_file_stream_open(main->program.parameters.arguments.array[index], f_string_empty_s, &main->program.output.to);
+      main->setting.state.status = f_file_stream_open(parameters->arguments.array[index], f_string_empty_s, &main->program.output.to);
 
       if (F_status_is_error(main->setting.state.status)) {
-        fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_iki_write_f(f_file_stream_open), fll_error_file_flag_fallback_e, main->program.parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e);
+        fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_iki_write_f(f_file_stream_open), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e);
 
         return;
       }
 
       main->setting.flag |= iki_write_main_flag_file_to_d;
     }
-    else if (main->program.parameters.array[iki_write_parameter_file_e].result & f_console_result_found_e) {
+    else if (parameters->array[iki_write_parameter_file_e].result & f_console_result_found_e) {
       main->setting.state.status = F_status_set_error(F_parameter);
 
       fll_program_print_error_parameter_missing_value(&main->program.error, f_console_symbol_long_normal_s, iki_write_long_file_s);
@@ -117,7 +119,7 @@ extern "C" {
       return;
     }
 
-    if (main->program.parameters.array[iki_write_parameter_wrap_e].result & f_console_result_found_e) {
+    if (parameters->array[iki_write_parameter_wrap_e].result & f_console_result_found_e) {
       main->setting.flag |= iki_write_main_flag_wrap_d;
       main->setting.state.flag |= f_iki_state_flag_force_wrap_e;
     }
@@ -127,39 +129,39 @@ extern "C" {
 
     main->setting.quote = f_iki_syntax_quote_double_s;
 
-    if (main->program.parameters.array[iki_write_parameter_double_e].result & f_console_result_found_e) {
-      if (main->program.parameters.array[iki_write_parameter_single_e].result & f_console_result_found_e) {
-        if (main->program.parameters.array[iki_write_parameter_double_e].location < main->program.parameters.array[iki_write_parameter_single_e].location) {
+    if (parameters->array[iki_write_parameter_double_e].result & f_console_result_found_e) {
+      if (parameters->array[iki_write_parameter_single_e].result & f_console_result_found_e) {
+        if (parameters->array[iki_write_parameter_double_e].location < parameters->array[iki_write_parameter_single_e].location) {
           main->setting.quote = f_iki_syntax_quote_single_s;
 
-          if (main->program.parameters.array[iki_write_parameter_grave_e].result & f_console_result_found_e) {
-            if (main->program.parameters.array[iki_write_parameter_single_e].location < main->program.parameters.array[iki_write_parameter_grave_e].location) {
+          if (parameters->array[iki_write_parameter_grave_e].result & f_console_result_found_e) {
+            if (parameters->array[iki_write_parameter_single_e].location < parameters->array[iki_write_parameter_grave_e].location) {
               main->setting.quote = f_iki_syntax_quote_grave_s;
             }
           }
         }
-        else if (main->program.parameters.array[iki_write_parameter_grave_e].result & f_console_result_found_e) {
-          if (main->program.parameters.array[iki_write_parameter_double_e].location < main->program.parameters.array[iki_write_parameter_grave_e].location) {
+        else if (parameters->array[iki_write_parameter_grave_e].result & f_console_result_found_e) {
+          if (parameters->array[iki_write_parameter_double_e].location < parameters->array[iki_write_parameter_grave_e].location) {
             main->setting.quote = f_iki_syntax_quote_grave_s;
           }
         }
       }
-      else if (main->program.parameters.array[iki_write_parameter_grave_e].result & f_console_result_found_e) {
-        if (main->program.parameters.array[iki_write_parameter_double_e].location < main->program.parameters.array[iki_write_parameter_grave_e].location) {
+      else if (parameters->array[iki_write_parameter_grave_e].result & f_console_result_found_e) {
+        if (parameters->array[iki_write_parameter_double_e].location < parameters->array[iki_write_parameter_grave_e].location) {
           main->setting.quote = f_iki_syntax_quote_grave_s;
         }
       }
     }
-    else if (main->program.parameters.array[iki_write_parameter_single_e].result & f_console_result_found_e) {
+    else if (parameters->array[iki_write_parameter_single_e].result & f_console_result_found_e) {
       main->setting.quote = f_iki_syntax_quote_single_s;
 
-      if (main->program.parameters.array[iki_write_parameter_grave_e].result & f_console_result_found_e) {
-        if (main->program.parameters.array[iki_write_parameter_single_e].location < main->program.parameters.array[iki_write_parameter_grave_e].location) {
+      if (parameters->array[iki_write_parameter_grave_e].result & f_console_result_found_e) {
+        if (parameters->array[iki_write_parameter_single_e].location < parameters->array[iki_write_parameter_grave_e].location) {
           main->setting.quote = f_iki_syntax_quote_grave_s;
         }
       }
     }
-    else if (main->program.parameters.array[iki_write_parameter_grave_e].result & f_console_result_found_e) {
+    else if (parameters->array[iki_write_parameter_grave_e].result & f_console_result_found_e) {
       main->setting.quote = f_iki_syntax_quote_grave_s;
     }
   }
index 296c68f8382127caea0803a38f1d6b91e09bd068..876cf4ea5155e9c38b7c19036f45acac4f24aa66 100644 (file)
@@ -17,12 +17,13 @@ extern "C" {
 #endif
 
 /**
- * The iki write main program cache.
+ * The IKI write main program cache.
  *
- * buffer:  A buffer used during processing the file.
- * content: A buffer used to hold a Content during processing.
- * iki:     A buffer used for writing the IKI during processing.
- * objects: A buffer used to hold Objects during processing.
+ * Properties:
+ *   - buffer:  A buffer used during processing the file.
+ *   - content: A buffer used to hold a Content during processing.
+ *   - iki:     A buffer used for writing the IKI during processing.
+ *   - objects: A buffer used to hold Objects during processing.
  */
 #ifndef _di_iki_write_setting_t_
   typedef struct {
@@ -44,11 +45,12 @@ extern "C" {
 /**
  * The IKI write callbacks.
  *
- * load_objects_content_pipe: Load the Objects and Content from the pipe.
+ * Properties:
+ *   - load_objects_content_pipe: Load the Objects and Content from the pipe.
  *
- * print_help: Print the main help message.
+ *   - print_help: Print the main help message.
  *
- * process_objects_content: Process an Objects and Content set.
+ *   - process_objects_content: Process an Objects and Content set.
  */
 #ifndef _di_iki_write_callback_t_
   typedef struct {
@@ -68,20 +70,21 @@ extern "C" {
 #endif // _di_iki_write_callback_t_
 
 /**
- * The iki write main program settings.
+ * The IKI write main program settings.
  *
  * This is passed to the program-specific main entry point to designate program settings.
  * These program settings are often processed from the program arguments (often called the command line arguments).
  *
- * flag: Flags passed to the main function.
+ * Properties:
+ *   - flag: Flags passed to the main function.
  *
- * status_signal: A status used eclusively by the threaded signal handler.
- * state:         The state data used when processing the FSS data.
+ *   - status_signal: A status used eclusively by the threaded signal handler.
+ *   - state:         The state data used when processing the FSS data.
  *
- * quote: This holds the quote used during processing.
+ *   - quote: This holds the quote used during processing.
  *
- * contents: An array of content passed as values to the "--content" parameter and must match the length of objects.
- * objectss: An array of an array of objects passed as values to the "--object" parameter.
+ *   - contents: An array of content passed as values to the "--content" parameter and must match the length of objects.
+ *   - objectss: An array of an array of objects passed as values to the "--object" parameter.
  */
 #ifndef _di_iki_write_setting_t_
   typedef struct {
@@ -110,10 +113,11 @@ extern "C" {
 /**
  * The main program data as a single structure.
  *
- * cache:    The cache data.
- * callback: The callbacks.
- * program:  The main program data.
- * setting:  The settings data.
+ * Properties:
+ *   - cache:    The cache data.
+ *   - callback: The callbacks.
+ *   - program:  The main program data.
+ *   - setting:  The settings data.
  */
 #ifndef _di_iki_write_main_t_
   typedef struct {
index 161d546c5e9203611a86c8b4dd7f7efbfbdcb6f0..97a399b9dce18ca05c747111612b4643eb138863 100644 (file)
@@ -9,8 +9,6 @@ extern "C" {
 
     if (!print) return;
 
-    fll_program_print_help_header(print, iki_write_program_name_long_s, iki_write_program_version_s);
-
     fll_program_print_help_option(print, f_console_standard_short_help_s, f_console_standard_long_help_s, f_console_symbol_short_normal_s, f_console_symbol_long_normal_s, "    Print this help message.");
     fll_program_print_help_option(print, f_console_standard_short_dark_s, f_console_standard_long_dark_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, "    Output using colors that show up better on dark backgrounds.");
     fll_program_print_help_option(print, f_console_standard_short_light_s, f_console_standard_long_light_s, f_console_symbol_short_inverse_s, f_console_symbol_long_inverse_s, "   Output using colors that show up better on light backgrounds.");