]> Kevux Git Server - fll/commitdiff
Progress: Continue work on refactoring fss_*_read into fss_read.
authorKevin Day <kevin@kevux.org>
Sun, 28 May 2023 03:56:35 +0000 (22:56 -0500)
committerKevin Day <kevin@kevux.org>
Sun, 28 May 2023 03:56:35 +0000 (22:56 -0500)
Get the programs into better working state.
Now I need to next focus on ensuring that they work as expected.

The payload and embedded list need special handling and are very much not implemented.

27 files changed:
level_3/fss_read/c/basic/fss_read.c
level_3/fss_read/c/basic/fss_read.h
level_3/fss_read/c/basic/main.c
level_3/fss_read/c/basic_list/fss_read.c
level_3/fss_read/c/basic_list/fss_read.h
level_3/fss_read/c/basic_list/main.c
level_3/fss_read/c/embedded_list/fss_read.c
level_3/fss_read/c/embedded_list/fss_read.h
level_3/fss_read/c/embedded_list/main.c
level_3/fss_read/c/extended/fss_read.c
level_3/fss_read/c/extended/fss_read.h
level_3/fss_read/c/extended/main.c
level_3/fss_read/c/extended/print.c
level_3/fss_read/c/extended_list/fss_read.c
level_3/fss_read/c/extended_list/fss_read.h
level_3/fss_read/c/extended_list/main.c
level_3/fss_read/c/main/common.c
level_3/fss_read/c/main/common.h
level_3/fss_read/c/main/common/print.c
level_3/fss_read/c/main/common/print.h
level_3/fss_read/c/main/common/type.c
level_3/fss_read/c/main/common/type.h
level_3/fss_read/c/main/main.c
level_3/fss_read/c/main/print/data.c
level_3/fss_read/c/payload/fss_read.c
level_3/fss_read/c/payload/fss_read.h
level_3/fss_read/c/payload/main.c

index e29857a63b94865f57319228ee4fd35524f12fc5..b0cadec9f999f9292d8f3b0204eb39b64a958fb9 100644 (file)
@@ -63,6 +63,14 @@ extern "C" {
       }
     }
 
+    fss_read_ensure_quotes_length(main);
+
+    if (F_status_is_error(main->setting.state.status)) {
+      fss_read_print_error(&main->program.error, macro_fss_read_f(fss_read_ensure_quotes_length));
+
+      return;
+    }
+
     main->setting.state.status = F_none;
   }
 #endif // _di_fss_read_basic_process_load_
index 3d8973549912c22efebe329e8b23247ec98ddc34..6b232c5edca44bbdf43ba04e22d1123a311310ec 100644 (file)
@@ -103,8 +103,11 @@ extern "C" {
  *
  *     Errors (with error bit) from: fll_fss_basic_read()
  *
+ *     Errors (with error bit) from: fss_read_ensure_quotes_length()
+ *
  * @see fll_fss_basic_read()
  *
+ * @see fss_read_ensure_quotes_length()
  * @see fss_read_file_identify()
  */
 #ifndef _di_fss_read_basic_process_load_
index a46a8f71ff70cb6e7a0939f99d14eb7a73d04022..21da79ae4d13a432bd0cefdd805525ebd7a509dc 100644 (file)
@@ -25,7 +25,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
   data.callback.process_help = &fss_read_basic_process_help;
   data.callback.process_last_line = &fss_read_process_last_line;
-  data.callback.process_load_depth = &fss_read_setting_load_depth;
   data.callback.process_normal = &fss_read_process_normal;
 
   data.callback.process_at = &fss_read_process_normal_at;
index 36574dde1cad28c5f327345cc5b1a8ed3cb81315..fbdc775b5974e0a27a39f8e44769549f7e870046 100644 (file)
@@ -63,6 +63,14 @@ extern "C" {
       }
     }
 
+    fss_read_ensure_quotes_length(main);
+
+    if (F_status_is_error(main->setting.state.status)) {
+      fss_read_print_error(&main->program.error, macro_fss_read_f(fss_read_ensure_quotes_length));
+
+      return;
+    }
+
     main->setting.state.status = F_none;
   }
 #endif // _di_fss_read_basic_list_process_load_
index 5ff936b8a3c43c84c0afa6c73391fd7038136260..2b574745d18f48f788a3787710080ad098fdadc7 100644 (file)
@@ -103,8 +103,11 @@ extern "C" {
  *
  *     Errors (with error bit) from: fll_fss_basic_list_read()
  *
+ *     Errors (with error bit) from: fss_read_ensure_quotes_length()
+ *
  * @see fll_fss_basic_list_read()
  *
+ * @see fss_read_ensure_quotes_length()
  * @see fss_read_file_identify()
  */
 #ifndef _di_fss_read_basic_list_process_load_
index d12db003ca8810920720f146cd47bcd7655b4609..3004244d47f232100bfe667a3f40f9658e422270 100644 (file)
@@ -17,14 +17,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
   data.program.output.custom = (void *) &data;
   data.program.warning.custom = (void *) &data;
 
-  data.setting.flag |= fss_read_main_flag_trim_object_e;
-
   data.setting.state.custom = (void *) &data;
   data.setting.standard = fss_read_basic_list_standard_s;
 
   data.callback.process_help = &fss_read_basic_list_process_help;
   data.callback.process_last_line = &fss_read_process_last_line;
-  data.callback.process_load_depth = &fss_read_setting_load_depth;
   data.callback.process_normal = &fss_read_process_normal;
 
   data.callback.process_at = &fss_read_process_normal_at;
index e6a1434f3aa074e2ef27aa6a3ce6c1e4b8d655d8..9cb252913df5db124916f8b6c2920c5ff67e469c 100644 (file)
@@ -63,6 +63,14 @@ extern "C" {
       }
     }
 
+    fss_read_ensure_quotes_length(main);
+
+    if (F_status_is_error(main->setting.state.status)) {
+      fss_read_print_error(&main->program.error, macro_fss_read_f(fss_read_ensure_quotes_length));
+
+      return;
+    }
+
     main->setting.state.status = F_none;
   }
 #endif // _di_fss_read_embedded_list_process_load_
index ea7b932cd68270c5bcb80cd1f2d171afab90833a..6b77918325c33ce06cbd7ec7ec9a572438f6fa85 100644 (file)
@@ -103,8 +103,11 @@ extern "C" {
  *
  *     Errors (with error bit) from: fll_fss_embedded_list_read()
  *
+ *     Errors (with error bit) from: fss_read_ensure_quotes_length()
+ *
  * @see fll_fss_embedded_list_read()
  *
+ * @see fss_read_ensure_quotes_length()
  * @see fss_read_file_identify()
  */
 #ifndef _di_fss_read_embedded_list_process_load_
index f07e183bb24c9d0b29da0de7a0e9eec8832f39ff..0abcb9fddef11b71ceec30f557423c678fc3e472 100644 (file)
@@ -24,7 +24,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
   data.callback.process_help = &fss_read_embedded_list_process_help;
   data.callback.process_last_line = &fss_read_process_last_line;
-  data.callback.process_load_depth = &fss_read_setting_load_depth;
   data.callback.process_normal = &fss_read_process_normal;
 
   data.callback.process_at = &fss_read_process_normal_at;
index d79b7bb71c7a4e42ad11d13b423c35d88288c6cb..2dc54052d484ba0948aa0fe810c432461136d6e1 100644 (file)
@@ -63,6 +63,14 @@ extern "C" {
       }
     }
 
+    fss_read_ensure_quotes_length(main);
+
+    if (F_status_is_error(main->setting.state.status)) {
+      fss_read_print_error(&main->program.error, macro_fss_read_f(fss_read_ensure_quotes_length));
+
+      return;
+    }
+
     main->setting.state.status = F_none;
   }
 #endif // _di_fss_read_extended_process_load_
index 477f27b23e965bcc6b89a40805f2db7e44507291..db910e6233e7c337a079f0abd5711dc7a99328ea 100644 (file)
@@ -122,8 +122,11 @@ extern "C" {
  *
  *     Errors (with error bit) from: fll_fss_extended_read()
  *
+ *     Errors (with error bit) from: fss_read_ensure_quotes_length()
+ *
  * @see fll_fss_extended_read()
  *
+ * @see fss_read_ensure_quotes_length()
  * @see fss_read_file_identify()
  */
 #ifndef _di_fss_read_extended_process_load_
index 0c78dd57de3e7c9aacc7c4b50b4a4777ec835aff..46410f55eb1a80986203748cb769f8dceae4bfa2 100644 (file)
@@ -25,7 +25,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
   data.callback.process_help = &fss_read_extended_process_help;
   data.callback.process_last_line = &fss_read_process_last_line;
-  data.callback.process_load_depth = &fss_read_setting_load_depth;
   data.callback.process_normal = &fss_read_process_normal;
 
   data.callback.process_at = &fss_read_process_normal_at;
index 7f321e27f780d337afe8ef96bd5780eccf816f46..43b4c21b129a5dc4a20ab48159fddc19e126b627 100644 (file)
@@ -30,7 +30,7 @@ extern "C" {
 
       if ((main->setting.flag & fss_read_main_flag_content_e) && main->setting.contents.array[at].used) {
         if (main->callback.print_content) {
-          main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[0], main->setting.quotes_content.array[at].array[0], delimits_content);
+          main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[0], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[0] : 0, delimits_content);
         }
       }
 
index d332ce5bc2d5a50e316e486ddac8a10a93793aa8..6989420c405663c91ad61cd2a3e8429b18dbfdb2 100644 (file)
@@ -63,6 +63,14 @@ extern "C" {
       }
     }
 
+    fss_read_ensure_quotes_length(main);
+
+    if (F_status_is_error(main->setting.state.status)) {
+      fss_read_print_error(&main->program.error, macro_fss_read_f(fss_read_ensure_quotes_length));
+
+      return;
+    }
+
     main->setting.state.status = F_none;
   }
 #endif // _di_fss_read_extended_list_process_load_
index 0a3a4d886f63aeeb1609ccf0029bd8d488051fbe..ca8ed26a3dccc1f5dcc40ab3114e556a89fe9778 100644 (file)
@@ -103,8 +103,11 @@ extern "C" {
  *
  *     Errors (with error bit) from: fll_fss_extended_list_read()
  *
+ *     Errors (with error bit) from: fss_read_ensure_quotes_length()
+ *
  * @see fll_fss_extended_list_read()
  *
+ * @see fss_read_ensure_quotes_length()
  * @see fss_read_file_identify()
  */
 #ifndef _di_fss_read_extended_list_process_load_
index 3adffc55558fd5ed265e5b783f95fe02030997dc..555bfa34b55b4db793339480680ff237eebc1464 100644 (file)
@@ -17,14 +17,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
   data.program.output.custom = (void *) &data;
   data.program.warning.custom = (void *) &data;
 
-  data.setting.flag |= fss_read_main_flag_trim_object_e;
-
   data.setting.state.custom = (void *) &data;
   data.setting.standard = fss_read_extended_list_standard_s;
 
   data.callback.process_help = &fss_read_extended_list_process_help;
   data.callback.process_last_line = &fss_read_process_last_line;
-  data.callback.process_load_depth = &fss_read_setting_load_depth;
   data.callback.process_normal = &fss_read_process_normal;
 
   data.callback.process_at = &fss_read_process_normal_at;
index 0ed95ceb0500fc2fa833ec0779196d167d2fabeb..79008c100a1705bc1864a853bd71071bc3e8ff5f 100644 (file)
@@ -4,6 +4,23 @@
 extern "C" {
 #endif
 
+#ifndef _di_fss_read_ensure_quotes_length_
+  void fss_read_ensure_quotes_length(fss_read_main_t * const main) {
+
+    if (main->setting.quotes_object.size < main->setting.objects.used) {
+      main->setting.state.status = f_uint8s_increase_by(main->setting.objects.used - main->setting.quotes_object.size, &main->setting.quotes_object);
+      if (F_status_is_error(main->setting.state.status)) return;
+    }
+
+    if (main->setting.quotes_content.size < main->setting.contents.used) {
+      main->setting.state.status = f_uint8ss_increase_by(main->setting.contents.used - main->setting.quotes_content.size, &main->setting.quotes_content);
+      if (F_status_is_error(main->setting.state.status)) return;
+    }
+
+    main->setting.state.status = F_none;
+  }
+#endif // _di_fss_read_ensure_quotes_length_
+
 #ifndef _di_fss_read_setting_load_
   void fss_read_setting_load(const f_console_arguments_t arguments, fss_read_main_t * const main, void (*callback)(const f_console_arguments_t arguments, fss_read_main_t * const main)) {
 
@@ -417,16 +434,10 @@ extern "C" {
 
     if (parameters->array[fss_read_parameter_content_e].result & f_console_result_found_e) {
       if (parameters->array[fss_read_parameter_object_e].result & f_console_result_found_e) {
-        if (parameters->array[fss_read_parameter_content_e].location < parameters->array[fss_read_parameter_object_e].location) {
-          main->setting.flag |= fss_read_main_flag_object_e;
-        }
-        else {
-          main->setting.flag |= fss_read_main_flag_content_e;
-        }
-      }
-      else {
-        main->setting.flag |= fss_read_main_flag_content_e;
+        main->setting.flag |= fss_read_main_flag_object_e;
       }
+
+      main->setting.flag |= fss_read_main_flag_content_e;
     }
     else if (parameters->array[fss_read_parameter_object_e].result & f_console_result_found_e) {
       main->setting.flag |= fss_read_main_flag_object_e;
@@ -516,12 +527,15 @@ extern "C" {
         main->setting.files.array[0].range.stop = main->setting.buffer.used - 1;
 
         if (main->callback.process_last_line) {
-          main->callback.process_last_line((void *) &main);
+          main->callback.process_last_line((void *) main);
           if (F_status_is_error(main->setting.state.status)) return;
         }
+
+        ++main->setting.files.used;
       }
       else {
         main->setting.files.array[0].range.start = 1;
+        main->setting.files.array[0].range.stop = 0;
       }
     }
 
@@ -529,20 +543,21 @@ extern "C" {
       off_t size_block = 0;
       off_t size_file = 0;
       off_t size_read = 0;
+      fss_read_file_t *file_data = 0;
 
       for (i = 0; i < parameters->remaining.used; ++i) {
 
         if (fss_read_signal_check(main)) return;
 
         index = parameters->remaining.array[i];
-
-        main->setting.files.array[main->setting.files.used].name = parameters->arguments.array[index];
-        main->setting.files.array[main->setting.files.used].range.start = main->setting.buffer.used;
+        file_data = &main->setting.files.array[main->setting.files.used];
+        file_data->name = parameters->arguments.array[index];
+        file_data->range.start = main->setting.buffer.used;
 
         file.id = -1;
         file.stream = 0;
 
-        main->setting.state.status = f_file_stream_open(main->setting.files.array[main->setting.files.used].name, f_string_empty_s, &file);
+        main->setting.state.status = f_file_stream_open(file_data->name, f_string_empty_s, &file);
 
         if (F_status_is_error(main->setting.state.status)) {
           if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) {
@@ -556,14 +571,14 @@ extern "C" {
 
         size_file = 0;
 
-        main->setting.state.status = f_file_size_by_id(file, &size_file);
+        main->setting.state.status = f_file_size(file_data->name, F_true, &size_file);
 
         if (F_status_is_error(main->setting.state.status)) {
           if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) {
             fll_print_dynamic_raw(f_string_eol_s, main->program.message.to);
           }
 
-          fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_size_by_id), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_read_s, fll_error_file_type_file_e);
+          fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_size), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_read_s, fll_error_file_type_file_e);
 
           break;
         }
@@ -574,18 +589,15 @@ extern "C" {
           if (size_file > fss_read_allocation_block_max_d) {
             file.size_read = fss_read_allocation_block_read_large_d;
             size_block = fss_read_allocation_block_max_d;
-
-            // Pre-allocate entire file buffer plus space for the terminating NULL.
-            f_string_dynamic_increase_by(size_file + (size_block - (size_file % size_block)) + 1, &main->setting.buffer);
           }
           else {
             file.size_read = fss_read_allocation_block_read_small_d;
             size_block = size_file;
-
-            // Pre-allocate entire file buffer plus space for the terminating NULL.
-            f_string_dynamic_increase_by(size_file + 1, &main->setting.buffer);
           }
 
+          // Pre-allocate entire file buffer plus space for the terminating NULL.
+          f_string_dynamic_increase_by(size_file + 1, &main->setting.buffer);
+
           if (F_status_is_error(main->setting.state.status)) {
             if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) {
               fll_print_dynamic_raw(f_string_eol_s, main->program.message.to);
@@ -616,11 +628,11 @@ extern "C" {
             break;
           }
 
-          if (main->setting.buffer.used > main->setting.files.array[main->setting.files.used].range.start) {
+          if (main->setting.buffer.used > file_data->range.start) {
             main->setting.files.array[main->setting.files.used++].range.stop = main->setting.buffer.used - 1;
 
             if (main->callback.process_last_line) {
-              main->callback.process_last_line((void *) &main);
+              main->callback.process_last_line((void *) main);
               if (F_status_is_error(main->setting.state.status)) break;
             }
           }
@@ -629,8 +641,8 @@ extern "C" {
           f_file_stream_close(&file);
         }
         else {
-          main->setting.files.array[main->setting.files.used].range.start = 1;
-          main->setting.files.array[main->setting.files.used].range.stop = 1;
+          file_data->range.start = 1;
+          file_data->range.stop = 0;
         }
       } // for
 
@@ -653,9 +665,8 @@ extern "C" {
       i = parameters->array[fss_read_parameter_depth_e].values.used;
     }
 
-    // @fixme: much of the logic in this depths handling was static and is now dynamic, this needs to be reviewed and updated.
-    if (i + 1 > main->setting.depths.size) {
-      main->setting.state.status = fss_read_depths_resize(i + 1, &main->setting.depths);
+    if (i > main->setting.depths.size) {
+      main->setting.state.status = fss_read_depths_resize(i, &main->setting.depths);
 
       if (F_status_is_error(main->setting.state.status)) {
         if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) {
@@ -673,24 +684,23 @@ extern "C" {
     f_array_length_t position_depth = 0;
     f_array_length_t position_at = 0;
     f_array_length_t position_name = 0;
+    fss_read_depth_t *current = 0;
 
     for (i = 0; i < main->setting.depths.used; ++i) {
 
       if (fss_read_signal_check(main)) return;
 
-      main->setting.depths.array[i].depth = 0;
-      main->setting.depths.array[i].index_at = 0;
-      main->setting.depths.array[i].index_name = 0;
-      main->setting.depths.array[i].value_at = 0;
-      main->setting.depths.array[i].value_name.used = 0; // @fixme this needs to be fully reset to 0.
+      current = &main->setting.depths.array[i];
+      current->depth = 0;
+      current->index_at = 0;
+      current->index_name = 0;
+      current->value_at = 0;
+      current->value_name.used = 0;
 
-      if (!parameters->array[fss_read_parameter_depth_e].values.used) {
-        position_depth = 0;
-      }
-      else {
+      if (parameters->array[fss_read_parameter_depth_e].values.used) {
         position_depth = parameters->array[fss_read_parameter_depth_e].values.array[i];
 
-        main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[position_depth], &main->setting.depths.array[i].depth);
+        main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[position_depth], &current->depth);
 
         if (F_status_is_error(main->setting.state.status)) {
           if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) {
@@ -702,6 +712,9 @@ extern "C" {
           return;
         }
       }
+      else {
+        position_depth = 0;
+      }
 
       if (parameters->array[fss_read_parameter_at_e].result & f_console_result_value_e) {
         for (; position_at < parameters->array[fss_read_parameter_at_e].values.used; ++position_at) {
@@ -714,16 +727,16 @@ extern "C" {
             break;
           }
 
-          main->setting.depths.array[i].index_at = parameters->array[fss_read_parameter_at_e].values.array[position_at];
+          current->index_at = parameters->array[fss_read_parameter_at_e].values.array[position_at];
 
-          main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[main->setting.depths.array[i].index_at], &main->setting.depths.array[i].value_at);
+          main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[current->index_at], &current->value_at);
 
           if (F_status_is_error(main->setting.state.status)) {
             if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) {
               fll_print_dynamic_raw(f_string_eol_s, main->program.message.to);
             }
 
-            fll_error_parameter_integer_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(fl_conversion_dynamic_to_unsigned_detect), F_true, fss_read_long_at_s, parameters->arguments.array[main->setting.depths.array[i].index_at]);
+            fll_error_parameter_integer_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(fl_conversion_dynamic_to_unsigned_detect), F_true, fss_read_long_at_s, parameters->arguments.array[current->index_at]);
 
             return;
           }
@@ -741,13 +754,13 @@ extern "C" {
             break;
           }
 
-          main->setting.depths.array[i].index_name = parameters->array[fss_read_parameter_name_e].values.array[position_name];
+          current->index_name = parameters->array[fss_read_parameter_name_e].values.array[position_name];
 
           if (parameters->array[fss_read_parameter_trim_e].result & f_console_result_found_e) {
-            main->setting.state.status = f_rip_dynamic(parameters->arguments.array[main->setting.depths.array[i].index_name], &main->setting.depths.array[i].value_name);
+            main->setting.state.status = f_rip_dynamic(parameters->arguments.array[current->index_name], &current->value_name);
           }
           else {
-            main->setting.state.status = f_string_dynamic_append(parameters->arguments.array[main->setting.depths.array[i].index_name], &main->setting.depths.array[i].value_name);
+            main->setting.state.status = f_string_dynamic_append(parameters->arguments.array[current->index_name], &current->value_name);
           }
 
           if (F_status_is_error(main->setting.state.status)) {
@@ -771,37 +784,34 @@ extern "C" {
 
         if (fss_read_signal_check(main)) return;
 
-        if (main->setting.depths.array[i].depth == main->setting.depths.array[j].depth) {
+        current = &main->setting.depths.array[i];
+
+        if (current->depth == main->setting.depths.array[j].depth) {
           main->setting.state.status = F_status_set_error(F_parameter);
 
           if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) {
             fll_print_dynamic_raw(f_string_eol_s, main->program.message.to);
           }
 
-          fss_read_print_error_parameter_value_once_only_number(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_depth_s, main->setting.depths.array[i].depth);
+          fss_read_print_error_parameter_value_once_only_number(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_depth_s, current->depth);
 
           return;
         }
 
-        if (main->setting.depths.array[i].depth > main->setting.depths.array[j].depth) {
+        if (current->depth > main->setting.depths.array[j].depth) {
           main->setting.state.status = F_status_set_error(F_parameter);
 
           if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) {
             fll_print_dynamic_raw(f_string_eol_s, main->program.message.to);
           }
 
-          fss_read_print_error_parameter_value_before_value_number(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_depth_s, main->setting.depths.array[i].depth, main->setting.depths.array[j].depth);
+          fss_read_print_error_parameter_value_before_value_number(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_depth_s, current->depth, main->setting.depths.array[j].depth);
 
           return;
         }
       } // for
     } // for
 
-    if (main->callback.process_load_depth) {
-      main->callback.process_load_depth(arguments, (void *) main, parameters);
-      if (F_status_is_error(main->setting.state.status)) return;
-    }
-
     main->setting.state.status = F_none;
   }
 #endif // _di_fss_read_setting_load_depth_
index a4f96dc865e1264500368385c0dfeb67339299c6..6469691b1014bfc0bfd513b494df364c151c6492 100644 (file)
@@ -17,6 +17,25 @@ extern "C" {
 #endif
 
 /**
+ * Make sure the array size of quotes_object and quotes_content matches the respective objects and contents.
+ *
+ * @param main
+ *   The main program data.
+ *
+ *   This alters main.setting.state.status:
+ *     F_none on success.
+ *
+ *     Errors (with error bit) from: f_uint8s_increase_by().
+ *     Errors (with error bit) from: f_uint8ss_increase_by().
+ *
+ * @see f_uint8s_increase_by()
+ * @see f_uint8ss_increase_by()
+ */
+#ifndef _di_fss_read_ensure_quotes_length_
+  extern void fss_read_ensure_quotes_length(fss_read_main_t * const main);
+#endif // _di_fss_read_ensure_quotes_length_
+
+/**
  * Perform the standard program setting load process.
  *
  * This prints error messages as appropriate.
@@ -82,8 +101,6 @@ extern "C" {
  *   Must not be NULL.
  *   Must be of type fss_read_main_t.
  *
- *   This calls main.callback.process_load_depth() if not NULL.
- *
  *   This alters main.setting.state.status:
  *     F_none on success.
  *
index b773af0c7b9d372e16868c8962d4bfb49e75b24d..eb112e3a258103d5030b153effc126da33fb34e0 100644 (file)
@@ -8,7 +8,7 @@ extern "C" {
   const f_string_t fss_read_f_a[] = {
     "f_console_parameter_process",
     "f_file_read_block",
-    "f_file_size_by_id",
+    "f_file_size",
     "f_file_stream_open",
     "f_file_stream_read",
     "f_file_stream_read_block",
@@ -52,6 +52,7 @@ extern "C" {
     "fll_program_parameter_process_context",
     "fll_program_parameter_process_verbosity",
     "fss_read_depths_resize",
+    "fss_read_ensure_quotes_length",
     "fss_read_files_resize",
     "fss_read_setting_load_depth",
   };
index d49f1cf46e7c9868097131bae6a476474723233f..8a3da056ea06e28e4b65a48074a28e2c03094645 100644 (file)
@@ -41,7 +41,7 @@ extern "C" {
   enum {
     fss_read_f_f_console_parameter_process_e,
     fss_read_f_f_file_read_block_e,
-    fss_read_f_f_file_size_by_id_e,
+    fss_read_f_f_file_size_e,
     fss_read_f_f_file_stream_open_e,
     fss_read_f_f_file_stream_read_e,
     fss_read_f_f_file_stream_read_block_e,
@@ -85,6 +85,7 @@ extern "C" {
     fss_read_f_fll_program_parameter_process_context_e,
     fss_read_f_fll_program_parameter_process_verbosity_e,
     fss_read_f_fss_read_depths_resize_e,
+    fss_read_f_fss_read_ensure_quotes_length_e,
     fss_read_f_fss_read_files_resize_e,
     fss_read_f_fss_read_setting_load_depth_e,
   }; // enum
index 5315e618c28efb34171e1adefb86267e25171436..26162dd4f6982a6d1ee7ab4cc6a6bc30788fdca5 100644 (file)
@@ -19,13 +19,11 @@ extern "C" {
     if (!depths) return F_status_set_error(F_parameter);
     if (depths->used + length > F_array_length_t_size_d) return F_status_set_error(F_array_too_large);
 
-    f_status_t status = F_none;
-
     for (f_array_length_t i = length; i < depths->size; ++i) {
       fss_read_depth_delete(&depths->array[i]);
     } // for
 
-    status = f_memory_resize(depths->size, length, sizeof(fss_read_file_t), (void **) & depths->array);
+    const f_status_t status = f_memory_resize(depths->size, length, sizeof(fss_read_depth_t), (void **) & depths->array);
     if (F_status_is_error(status)) return status;
 
     depths->size = length;
index e239c4f7b460124703d95335dc7a5436f02dc645..b759328c5053db2b1f43f8398d25f6c68c7cd1e0 100644 (file)
@@ -35,7 +35,7 @@ extern "C" {
     f_array_length_t index_name;
 
     f_number_unsigned_t value_at;
-    f_string_dynamic_t  value_name;
+    f_string_dynamic_t value_name;
   } fss_read_depth_t;
 
   #define fss_read_depth_t_initialize \
@@ -119,17 +119,16 @@ extern "C" {
 /**
  * The FSS read callbacks.
  *
- * process_help:       Process help (generally printing help).
- * process_last_line:  Process printing last line if necessary when loading in a file (or pipe).
- * process_load_depth: Process loading of the depth related parameters when loading the settings.
- * process_normal:     Process normally (data from parameters and files).
+ * process_help:      Process help (generally printing help).
+ * process_last_line: Process printing last line if necessary when loading in a file (or pipe).
+ * process_normal:    Process normally (data from parameters and files).
  *
- * process_at:       Process at parameter, usually called by the process_normal() callback.
- * process_columns:  Process columns parameter, usually called by the process_normal() callback.
- * process_line:     Process line parameter, usually called by the process_normal() callback.
- * process_load:     Process loading of FSS data from buffer (not to be confused with loading settings), usually called by the process_normal() callback.
- * process_name:     Process name parameter, usually called by the process_normal() callback.
- * process_total:    Process total parameter, usually called by the process_normal() callback.
+ * process_at:      Process at parameter, usually called by the process_normal() callback.
+ * process_columns: Process columns parameter, usually called by the process_normal() callback.
+ * process_line:    Process line parameter, usually called by the process_normal() callback.
+ * process_load:    Process loading of FSS data from buffer (not to be confused with loading settings), usually called by the process_normal() callback.
+ * process_name:    Process name parameter, usually called by the process_normal() callback.
+ * process_total:   Process total parameter, usually called by the process_normal() callback.
  *
  * print_at:             Print at the given location, usually called by the process_normal() callback.
  * print_object:         Print the Object, usually called by the process_normal() callback.
@@ -142,7 +141,6 @@ extern "C" {
   typedef struct {
     void (*process_help)(void * const main);
     void (*process_last_line)(void * const main);
-    void (*process_load_depth)(const f_console_arguments_t arguments, void * const main, f_console_parameters_t * const parameters);
     void (*process_normal)(void * const main);
 
     void (*process_at)(void * const main, const bool names[], const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content);
index ff36084c63eb2ad0d44c95e9601be80c6b296819..25d0bbf30013740ec4a0b78ea8e42c1f43d7a87e 100644 (file)
@@ -100,7 +100,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
     main->callback.process_help = &fss_read_main_process_help;
     main->callback.process_last_line = &fss_read_process_last_line;
-    main->callback.process_load_depth = &fss_read_setting_load_depth;
     main->callback.process_normal = &fss_read_process_normal;
 
     main->callback.process_at = &fss_read_process_normal_at;
@@ -181,8 +180,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
           main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e;
 
-          main->setting.flag |= fss_read_main_flag_trim_object_e;
-
           main->callback.process_help = &fss_read_basic_list_process_help;
           main->callback.process_load = &fss_read_basic_list_process_load;
           main->callback.print_set_end = &fss_read_print_set_end;
@@ -203,8 +200,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
           main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e;
 
-          main->setting.flag |= fss_read_main_flag_trim_object_e;
-
           main->callback.process_help = &fss_read_extended_list_process_help;
           main->callback.process_load = &fss_read_extended_list_process_load;
           main->callback.print_set_end = &fss_read_print_set_end;
@@ -223,7 +218,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
           main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e;
 
-          main->setting.flag |= fss_read_main_flag_trim_object_e;
           main->setting.flag |= fss_read_main_flag_content_multiple_e | fss_read_main_flag_depth_multiple_e;
 
           main->callback.process_help = &fss_read_embedded_list_process_help;
@@ -246,8 +240,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
           main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e;
 
-          main->setting.flag |= fss_read_main_flag_trim_object_e;
-
           main->callback.process_help = &fss_read_payload_process_help;
           main->callback.process_load = &fss_read_payload_process_load;
           main->callback.print_set_end = &fss_read_print_set_end;
index a7cd1b267853a2acb068a5c15c5a25ecc8709c39..cf612bdcbcf05ad99fae65a1667f0bf0686db0de 100644 (file)
@@ -28,7 +28,7 @@ extern "C" {
 
       if ((main->setting.flag & fss_read_main_flag_content_e) && main->setting.contents.array[at].used) {
         if (main->callback.print_content) {
-          main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[0], main->setting.quotes_content.array[at].array[0], delimits_content);
+          main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[0], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[0] : 0, delimits_content);
         }
       }
 
@@ -164,14 +164,16 @@ extern "C" {
 
     if (!print) return F_status_set_error(F_output_not);
 
-    fll_print_dynamic_raw(
-      type == f_fss_quote_type_single_e
-        ? f_fss_quote_single_s
-        : type == f_fss_quote_type_backtick_e
-          ? f_fss_quote_backtick_s
-          : f_fss_quote_double_s,
-      print->to
-    );
+    if (type) {
+      fll_print_dynamic_raw(
+        type == f_fss_quote_type_single_e
+          ? f_fss_quote_single_s
+          : type == f_fss_quote_type_backtick_e
+            ? f_fss_quote_backtick_s
+            : f_fss_quote_double_s,
+        print->to
+      );
+    }
 
     return F_none;
   }
index 5a69c750835513158b0a9ccc0ba5b8e411ef182f..4331a3094c56baf6078e8d9b3da3b9f13886ced5 100644 (file)
@@ -63,6 +63,14 @@ extern "C" {
       }
     }
 
+    fss_read_ensure_quotes_length(main);
+
+    if (F_status_is_error(main->setting.state.status)) {
+      fss_read_print_error(&main->program.error, macro_fss_read_f(fss_read_ensure_quotes_length));
+
+      return;
+    }
+
     main->setting.state.status = F_none;
   }
 #endif // _di_fss_read_payload_process_load_
index 1d717482b567a2c1f1196e9c62a09b099ef5e91a..b97f2a944cb8d1aa2a5f3c2571e779454ec50ca8 100644 (file)
@@ -104,6 +104,9 @@ extern "C" {
  *
  *     Errors (with error bit) from: fll_fss_payload_read()
  *
+ *     Errors (with error bit) from: fss_read_ensure_quotes_length()
+ *
+ * @see fss_read_ensure_quotes_length()
  * @see fll_fss_payload_read()
  *
  * @see fss_read_file_identify()
index 5ee4ae493d685e82411f7519bbf72e864de716dd..034df72a0efd867c75d51af8d4dedadb055a3ea9 100644 (file)
@@ -17,14 +17,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
   data.program.output.custom = (void *) &data;
   data.program.warning.custom = (void *) &data;
 
-  data.setting.flag |= fss_read_main_flag_trim_object_e;
-
   data.setting.state.custom = (void *) &data;
   data.setting.standard = fss_read_payload_standard_s;
 
   data.callback.process_help = &fss_read_payload_process_help;
   data.callback.process_last_line = &fss_read_process_last_line;
-  data.callback.process_load_depth = &fss_read_setting_load_depth;
   data.callback.process_normal = &fss_read_process_normal;
 
   data.callback.process_at = &fss_read_process_normal_at;