]> Kevux Git Server - fll/commitdiff
Progress: Continue work on refactoring fss_*_read into fss_read, focusing on fixing...
authorKevin Day <kevin@kevux.org>
Mon, 29 May 2023 05:09:23 +0000 (00:09 -0500)
committerKevin Day <kevin@kevux.org>
Mon, 29 May 2023 05:09:23 +0000 (00:09 -0500)
Get the programs into better working state.
I found several problems resulting from the way in which I migrated and refactored the code.
I think the next thing to do is to instead start writing some runtime tests that can better find problems.

Of particular note, I found problems with the comments being printed properly (which generally means not printed).
Some parameter handling problems are also fixed.

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

31 files changed:
level_3/fss_read/c/basic/fss_read.c
level_3/fss_read/c/basic/main.c
level_3/fss_read/c/basic/print.c
level_3/fss_read/c/basic/print.h
level_3/fss_read/c/basic_list/fss_read.c
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/main.c
level_3/fss_read/c/embedded_list/print.c
level_3/fss_read/c/embedded_list/print.h
level_3/fss_read/c/extended/fss_read.c
level_3/fss_read/c/extended/main.c
level_3/fss_read/c/extended/print.c
level_3/fss_read/c/extended/print.h
level_3/fss_read/c/extended_list/fss_read.c
level_3/fss_read/c/extended_list/main.c
level_3/fss_read/c/extended_list/print.c
level_3/fss_read/c/extended_list/print.h
level_3/fss_read/c/main/common.c
level_3/fss_read/c/main/common/type.h
level_3/fss_read/c/main/fss_read.c
level_3/fss_read/c/main/main.c
level_3/fss_read/c/main/print/data.c
level_3/fss_read/c/main/print/data.h
level_3/fss_read/c/main/print/error.c
level_3/fss_read/c/main/process_normal.c
level_3/fss_read/c/main/process_normal.h
level_3/fss_read/c/payload/fss_read.c
level_3/fss_read/c/payload/main.c
level_3/fss_read/c/payload/print.c
level_3/fss_read/c/payload/print.h

index b0cadec9f999f9292d8f3b0204eb39b64a958fb9..6e7a635c954127c83818bb0d7db38846e7ae87d2 100644 (file)
@@ -21,22 +21,6 @@ extern "C" {
 
     fss_read_main_t * const main = (fss_read_main_t *) void_main;
 
-    if (main->setting.buffer.used) {
-      main->setting.range.start = 0;
-      main->setting.range.stop = main->setting.buffer.used;
-    }
-    else {
-      main->setting.range.start = 1;
-      main->setting.range.stop = 0;
-    }
-
-    main->setting.comments.used = 0;
-    main->setting.delimits_object.used = 0;
-    main->setting.delimits_content.used = 0;
-    main->setting.nest.used = 0;
-    main->setting.quotes_object.used = 0;
-    main->setting.quotes_content.used = 0;
-
     fll_fss_basic_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.quotes_object, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.state);
 
     if (F_status_is_error(main->setting.state.status)) {
index 21da79ae4d13a432bd0cefdd805525ebd7a509dc..ecd2a53a9b483192d60e63b482c673dafa074919 100644 (file)
@@ -36,9 +36,10 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
   data.callback.print_at = &fss_read_print_at;
   data.callback.print_content = &fss_read_print_content;
+  data.callback.print_content_next = 0;
   data.callback.print_content_ignore = 0;
   data.callback.print_object = &fss_read_print_object;
-  data.callback.print_object_end = &fss_read_print_object_end;
+  data.callback.print_object_end = &fss_read_basic_print_object_end;
   data.callback.print_set_end = &fss_read_print_set_end;
 
   f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize;
index e71324a3cafe068cb8e4ae8b7b0171e90a380aae..788c332a8b735fc0f0bbb19ee262a8c139aa129c 100644 (file)
@@ -34,6 +34,26 @@ extern "C" {
   }
 #endif // _di_fss_read_basic_print_help_
 
+#ifndef _di_fss_read_basic_print_object_end_
+  f_status_t fss_read_basic_print_object_end(fl_print_t * const print) {
+
+    if (!print || !print->custom) return F_status_set_error(F_output_not);
+
+    fss_read_main_t * const main = (fss_read_main_t *) print->custom;
+
+    if (main->setting.flag & fss_read_main_flag_content_e) {
+      if (main->setting.flag & fss_read_main_flag_pipe_e) {
+        fll_print_dynamic_raw(fss_read_pipe_content_start_s, print->to);
+      }
+      else {
+        fll_print_dynamic_raw(f_fss_basic_open_s, print->to);
+      }
+    }
+
+    return F_none;
+  }
+#endif // _di_fss_read_basic_print_object_end_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index d153b6eb6e15e0d08c88a51f0d56e8bb5c699aa5..40c5c3ff4f2a55bf47cc8d542a3718ae916612ad 100644 (file)
@@ -30,6 +30,30 @@ extern "C" {
   extern f_status_t fss_read_basic_print_help(fl_print_t * const print);
 #endif // _di_fss_read_basic_print_help_
 
+/**
+ * Print the end of an Object (which is often the start of Content).
+ *
+ * This locks, uses, and unlocks the file stream.
+ *
+ * @param print
+ *   The output structure to print to.
+ *
+ *   The print.custom is expected to be of type fss_read_main_t.
+ *
+ *   This does not alter print.custom.setting.state.status.
+ *
+ * @return
+ *   F_none on success.
+ *   F_output_not on success, but no printing is performed.
+ *
+ *   F_output_not (with error bit) if a parameter is NULL.
+ *
+ * @see fll_print_dynamic_raw()
+ */
+#ifndef _di_fss_read_basic_print_object_end_
+  extern f_status_t fss_read_basic_print_object_end(fl_print_t * const print);
+#endif // _di_fss_read_basic_print_object_end_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index fbdc775b5974e0a27a39f8e44769549f7e870046..6d6e4bf3250e19390cbc3ec956b2ff22627e3ad1 100644 (file)
@@ -21,22 +21,6 @@ extern "C" {
 
     fss_read_main_t * const main = (fss_read_main_t *) void_main;
 
-    if (main->setting.buffer.used) {
-      main->setting.range.start = 0;
-      main->setting.range.stop = main->setting.buffer.used;
-    }
-    else {
-      main->setting.range.start = 1;
-      main->setting.range.stop = 0;
-    }
-
-    main->setting.comments.used = 0;
-    main->setting.delimits_object.used = 0;
-    main->setting.delimits_content.used = 0;
-    main->setting.nest.used = 0;
-    main->setting.quotes_object.used = 0;
-    main->setting.quotes_content.used = 0;
-
     fll_fss_basic_list_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.comments, &main->setting.state);
 
     if (F_status_is_error(main->setting.state.status)) {
index 3004244d47f232100bfe667a3f40f9658e422270..a2fac6f7c54633bf05641e01a8e352c6e94d2044 100644 (file)
@@ -29,10 +29,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
   data.callback.process_line = &fss_read_process_normal_line;
   data.callback.process_load = &fss_read_basic_list_process_load;
   data.callback.process_name = &fss_read_process_normal_name;
-  data.callback.process_total = &fss_read_process_normal_total;
+  data.callback.process_total = &fss_read_process_normal_total_multiple;
 
   data.callback.print_at = &fss_read_print_at;
   data.callback.print_content = &fss_read_print_content;
+  data.callback.print_content_next = 0;
   data.callback.print_content_ignore = &fss_read_print_content_ignore;
   data.callback.print_object = &fss_read_print_object;
   data.callback.print_object_end = &fss_read_basic_list_print_object_end;
index 9cb252913df5db124916f8b6c2920c5ff67e469c..1725b211513ba9b637f7a08e6f302001b78f8f6e 100644 (file)
@@ -21,22 +21,6 @@ extern "C" {
 
     fss_read_main_t * const main = (fss_read_main_t *) void_main;
 
-    if (main->setting.buffer.used) {
-      main->setting.range.start = 0;
-      main->setting.range.stop = main->setting.buffer.used;
-    }
-    else {
-      main->setting.range.start = 1;
-      main->setting.range.stop = 0;
-    }
-
-    main->setting.comments.used = 0;
-    main->setting.delimits_object.used = 0;
-    main->setting.delimits_content.used = 0;
-    main->setting.nest.used = 0;
-    main->setting.quotes_object.used = 0;
-    main->setting.quotes_content.used = 0;
-
     fll_fss_embedded_list_read(main->setting.buffer, &main->setting.range, &main->setting.nest, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.comments, &main->setting.state);
 
     if (F_status_is_error(main->setting.state.status)) {
index 0abcb9fddef11b71ceec30f557423c678fc3e472..089e15442b168e176fec0a71a8eed81ccf8874b5 100644 (file)
@@ -31,13 +31,14 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
   data.callback.process_line = &fss_read_process_normal_line;
   data.callback.process_load = &fss_read_embedded_list_process_load;
   data.callback.process_name = &fss_read_process_normal_name;
-  data.callback.process_total = &fss_read_process_normal_total;
+  data.callback.process_total = &fss_read_process_normal_total_multiple;
 
   data.callback.print_at = &fss_read_print_at;
   data.callback.print_content = &fss_read_print_content;
+  data.callback.print_content_next = 0;
   data.callback.print_content_ignore = &fss_read_print_content_ignore;
   data.callback.print_object = &fss_read_print_object;
-  data.callback.print_object_end = &fss_read_print_object_end;
+  data.callback.print_object_end = &fss_read_embedded_list_print_object_end;
   data.callback.print_set_end = &fss_read_print_set_end;
 
   f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize;
index 5ea1df981817337b3e280a8f82071b26e3b79d03..da4b6512e0af85cbbdf1c5c6aec53f676ce91875 100644 (file)
@@ -34,6 +34,34 @@ extern "C" {
   }
 #endif // _di_fss_read_embedded_list_print_help_
 
+#ifndef _di_fss_read_embedded_list_print_object_end_
+  f_status_t fss_read_embedded_list_print_object_end(fl_print_t * const print) {
+
+    if (!print || !print->custom) return F_status_set_error(F_output_not);
+
+    fss_read_main_t * const main = (fss_read_main_t *) print->custom;
+
+    f_file_stream_lock(print->to);
+
+    if (main->setting.flag & fss_read_main_flag_pipe_e) {
+      f_print_dynamic_raw(fss_read_pipe_content_start_s, print->to);
+    }
+    else {
+      if (main->setting.flag & fss_read_main_flag_content_e) {
+        f_print_dynamic_raw(f_fss_embedded_list_open_s, print->to);
+        f_print_dynamic_raw(f_fss_embedded_list_open_end_s, print->to);
+      }
+      else {
+        f_print_dynamic_raw(f_fss_eol_s, print->to);
+      }
+    }
+
+    f_file_stream_unlock(print->to);
+
+    return F_none;
+  }
+#endif // _di_fss_read_embedded_list_print_object_end_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 39efef1dea28f36ab006bb936824a22dc0172c9a..f87166338578bd4d36981172b6c44e0412cbe28d 100644 (file)
@@ -30,6 +30,32 @@ extern "C" {
   extern f_status_t fss_read_embedded_list_print_help(fl_print_t * const print);
 #endif // _di_fss_read_embedded_list_print_help_
 
+/**
+ * Print the end of an Object (which is often the start of Content).
+ *
+ * This locks, uses, and unlocks the file stream.
+ *
+ * @param print
+ *   The output structure to print to.
+ *
+ *   The print.custom is expected to be of type fss_read_main_t.
+ *
+ *   This does not alter print.custom.setting.state.status.
+ *
+ * @return
+ *   F_none on success.
+ *   F_output_not on success, but no printing is performed.
+ *
+ *   F_output_not (with error bit) if a parameter is NULL.
+ *
+ * @see f_file_stream_lock()
+ * @see f_file_stream_unlock()
+ * @see f_print_dynamic_raw()
+ */
+#ifndef _di_fss_read_embedded_list_print_object_end_
+  extern f_status_t fss_read_embedded_list_print_object_end(fl_print_t * const print);
+#endif // _di_fss_read_embedded_list_print_object_end_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 2dc54052d484ba0948aa0fe810c432461136d6e1..0489d89367de59aa470cf0305fec2894cbf28e70 100644 (file)
@@ -21,22 +21,6 @@ extern "C" {
 
     fss_read_main_t * const main = (fss_read_main_t *) void_main;
 
-    if (main->setting.buffer.used) {
-      main->setting.range.start = 0;
-      main->setting.range.stop = main->setting.buffer.used;
-    }
-    else {
-      main->setting.range.start = 1;
-      main->setting.range.stop = 0;
-    }
-
-    main->setting.comments.used = 0;
-    main->setting.delimits_object.used = 0;
-    main->setting.delimits_content.used = 0;
-    main->setting.nest.used = 0;
-    main->setting.quotes_object.used = 0;
-    main->setting.quotes_content.used = 0;
-
     fll_fss_extended_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.quotes_object, &main->setting.quotes_content, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.state);
 
     if (F_status_is_error(main->setting.state.status)) {
index 46410f55eb1a80986203748cb769f8dceae4bfa2..673b2c119542e9c9073127ea9cf7b807892abd93 100644 (file)
@@ -34,11 +34,12 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
   data.callback.process_name = &fss_read_process_normal_name;
   data.callback.process_total = &fss_read_process_normal_total;
 
-  data.callback.print_at = &fss_read_extended_print_at;
+  data.callback.print_at = &fss_read_print_at;
   data.callback.print_content = &fss_read_print_content;
   data.callback.print_content_ignore = &fss_read_print_content_ignore;
+  data.callback.print_content_next = &fss_read_extended_print_content_next;
   data.callback.print_object = &fss_read_print_object;
-  data.callback.print_object_end = &fss_read_print_object_end;
+  data.callback.print_object_end = &fss_read_extended_print_object_end;
   data.callback.print_set_end = &fss_read_print_set_end;
 
   f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize;
index 43b4c21b129a5dc4a20ab48159fddc19e126b627..fc49463ff1220c06fb968d2f26a782c31e8b501b 100644 (file)
@@ -4,44 +4,20 @@
 extern "C" {
 #endif
 
-#ifndef _di_fss_read_extended_print_at_
-  f_status_t fss_read_extended_print_at(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content) {
+#ifndef _di_fss_read_extended_print_content_next_
+  f_status_t fss_read_extended_print_content_next(fl_print_t * const print) {
 
     if (!print || !print->custom) return F_status_set_error(F_output_not);
 
     fss_read_main_t * const main = (fss_read_main_t *) print->custom;
 
-    if (at >= main->setting.contents.used) return F_output_not;
-
-    // @todo This is copied from fss_read_print_at() and needs to be updated to handle multiple content.
-
-    if ((main->setting.flag & fss_read_main_flag_object_e) || (main->setting.flag & fss_read_main_flag_content_e) && (main->setting.contents.array[at].used || (main->setting.flag & fss_read_main_flag_empty_e))) {
-      if (main->setting.flag & fss_read_main_flag_object_e) {
-        if (main->callback.print_object) {
-          main->callback.print_object(&main->program.output, at, delimits_object);
-        }
-
-        if (main->setting.flag & fss_read_main_flag_content_e) {
-          if (main->callback.print_object_end) {
-            main->callback.print_object_end(&main->program.output);
-          }
-        }
-      }
-
-      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].used ? main->setting.quotes_content.array[at].array[0] : 0, delimits_content);
-        }
-      }
-
-      if (main->callback.print_set_end) {
-        main->callback.print_set_end(&main->program.output);
-      }
+    if (main->setting.flag & fss_read_main_flag_content_e) {
+      fll_print_dynamic_raw((main->setting.flag & fss_read_main_flag_pipe_e) ? fss_read_pipe_content_start_s : f_fss_extended_next_s, print->to);
     }
 
     return F_none;
   }
-#endif // _di_fss_read_extended_print_at_
+#endif // _di_fss_read_extended_print_content_next_
 
 #ifndef _di_fss_read_extended_print_help_
   f_status_t fss_read_extended_print_help(fl_print_t * const print) {
@@ -73,6 +49,26 @@ extern "C" {
   }
 #endif // _di_fss_read_extended_print_help_
 
+#ifndef _di_fss_read_extended_print_object_end_
+  f_status_t fss_read_extended_print_object_end(fl_print_t * const print) {
+
+    if (!print || !print->custom) return F_status_set_error(F_output_not);
+
+    fss_read_main_t * const main = (fss_read_main_t *) print->custom;
+
+    if (main->setting.flag & fss_read_main_flag_content_e) {
+      if (main->setting.flag & fss_read_main_flag_pipe_e) {
+        fll_print_dynamic_raw(fss_read_pipe_content_start_s, print->to);
+      }
+      else {
+        fll_print_dynamic_raw(f_fss_extended_open_s, print->to);
+      }
+    }
+
+    return F_none;
+  }
+#endif // _di_fss_read_extended_print_object_end_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 51d60a9244ff637cad695b12a57561ad5e39aa04..8d7d8342c5a85fd9c8a58c4e5f83c0ae25c8ee52 100644 (file)
@@ -13,24 +13,18 @@ extern "C" {
 #endif
 
 /**
- * Process printing the buffer according to "at" position and given delimits.
+ * Print the next part of a Content.
  *
  * This locks, uses, and unlocks the file stream.
  *
+ * This is not the Content set end.
+ *
  * @param print
  *   The output structure to print to.
  *
  *   The print.custom is expected to be of type fss_read_main_t.
  *
  *   This does not alter print.custom.setting.state.status.
- * @param at
- *   The "at" position to be printed.
- * @param delimits_object
- *   The delimits array representing a delimited Object.
- *   This represents the positions within the current Object at the "at" position.
- * @param delimits_content
- *   The delimits array representing a delimited Content.
- *   This represents the positions within the current Content at the "at" position.
  *
  * @return
  *   F_none on success.
@@ -38,18 +32,11 @@ extern "C" {
  *
  *   F_output_not (with error bit) if a parameter is NULL.
  *
- * @see fll_print_dynamic_partial()
- * @see fll_print_except_dynamic_partial()
- * @see fll_print_trim_dynamic_partial()
- * @see fll_print_trim_except_dynamic_partial()
- *
- * @see main.callback.print_object()
- * @see main.callback.print_object_end()
- * @see main.callback.print_set_end()
+ * @see fll_print_dynamic_raw()
  */
-#ifndef _di_fss_read_extended_print_at_
-  extern f_status_t fss_read_extended_print_at(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content);
-#endif // _di_fss_read_extended_print_at_
+#ifndef _di_fss_read_extended_print_content_next_
+  extern f_status_t fss_read_extended_print_content_next(fl_print_t * const print);
+#endif // _di_fss_read_extended_print_content_next_
 
 /**
  * Print help for FSS-0001 (Extended).
@@ -69,6 +56,30 @@ extern "C" {
   extern f_status_t fss_read_extended_print_help(fl_print_t * const print);
 #endif // _di_fss_read_extended_print_help_
 
+/**
+ * Print the end of an Object (which is often the start of Content).
+ *
+ * This locks, uses, and unlocks the file stream.
+ *
+ * @param print
+ *   The output structure to print to.
+ *
+ *   The print.custom is expected to be of type fss_read_main_t.
+ *
+ *   This does not alter print.custom.setting.state.status.
+ *
+ * @return
+ *   F_none on success.
+ *   F_output_not on success, but no printing is performed.
+ *
+ *   F_output_not (with error bit) if a parameter is NULL.
+ *
+ * @see fll_print_dynamic_raw()
+ */
+#ifndef _di_fss_read_extended_print_object_end_
+  extern f_status_t fss_read_extended_print_object_end(fl_print_t * const print);
+#endif // _di_fss_read_extended_print_object_end_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 6989420c405663c91ad61cd2a3e8429b18dbfdb2..6c130e5734ce8fd71be9d36c83ea9f8aa7946914 100644 (file)
@@ -21,22 +21,6 @@ extern "C" {
 
     fss_read_main_t * const main = (fss_read_main_t *) void_main;
 
-    if (main->setting.buffer.used) {
-      main->setting.range.start = 0;
-      main->setting.range.stop = main->setting.buffer.used;
-    }
-    else {
-      main->setting.range.start = 1;
-      main->setting.range.stop = 0;
-    }
-
-    main->setting.comments.used = 0;
-    main->setting.delimits_object.used = 0;
-    main->setting.delimits_content.used = 0;
-    main->setting.nest.used = 0;
-    main->setting.quotes_object.used = 0;
-    main->setting.quotes_content.used = 0;
-
     fll_fss_extended_list_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.comments, &main->setting.state);
 
     if (F_status_is_error(main->setting.state.status)) {
index 555bfa34b55b4db793339480680ff237eebc1464..270ca22fecb4c4ad3c650d01a493564b0647c85c 100644 (file)
@@ -29,13 +29,14 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
   data.callback.process_line = &fss_read_process_normal_line;
   data.callback.process_load = &fss_read_extended_list_process_load;
   data.callback.process_name = &fss_read_process_normal_name;
-  data.callback.process_total = &fss_read_process_normal_total;
+  data.callback.process_total = &fss_read_process_normal_total_multiple;
 
   data.callback.print_at = &fss_read_print_at;
   data.callback.print_content = &fss_read_print_content;
+  data.callback.print_content_next = 0;
   data.callback.print_content_ignore = &fss_read_print_content_ignore;
   data.callback.print_object = &fss_read_print_object;
-  data.callback.print_object_end = &fss_read_print_object_end;
+  data.callback.print_object_end = &fss_read_extended_list_print_object_end;
   data.callback.print_set_end = &fss_read_extended_list_print_set_end;
 
   f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize;
index 391a1e3978733baf728d8c6d5a591d7772a63103..68ae81e522d7d7ce4c69a3c708647042a355293f 100644 (file)
@@ -34,6 +34,34 @@ extern "C" {
   }
 #endif // _di_fss_read_extended_list_print_help_
 
+#ifndef _di_fss_read_extended_list_print_object_end_
+  f_status_t fss_read_extended_list_print_object_end(fl_print_t * const print) {
+
+    if (!print || !print->custom) return F_status_set_error(F_output_not);
+
+    fss_read_main_t * const main = (fss_read_main_t *) print->custom;
+
+    f_file_stream_lock(print->to);
+
+    if (main->setting.flag & fss_read_main_flag_pipe_e) {
+      f_print_dynamic_raw(fss_read_pipe_content_start_s, print->to);
+    }
+    else {
+      if (main->setting.flag & fss_read_main_flag_content_e) {
+        f_print_dynamic_raw(f_fss_extended_list_open_s, print->to);
+        f_print_dynamic_raw(f_fss_extended_list_open_end_s, print->to);
+      }
+      else {
+        f_print_dynamic_raw(f_fss_eol_s, print->to);
+      }
+    }
+
+    f_file_stream_unlock(print->to);
+
+    return F_none;
+  }
+#endif // _di_fss_read_extended_list_print_object_end_
+
 #ifndef _di_fss_read_extended_list_print_set_end_
   f_status_t fss_read_extended_list_print_set_end(fl_print_t * const print) {
 
index c3d655da663a07eee949c58fe0db2b9e27aff19f..823832e0154b2b85ee8287dd72a8c38d66f01069 100644 (file)
@@ -31,7 +31,7 @@ extern "C" {
 #endif // _di_fss_read_extended_list_print_help_
 
 /**
- * Print the end of an Object/Content set.
+ * Print the end of an Object (which is often the start of Content).
  *
  * This locks, uses, and unlocks the file stream.
  *
@@ -50,6 +50,32 @@ extern "C" {
  *
  * @see fll_print_dynamic_raw()
  */
+#ifndef _di_fss_read_extended_list_print_object_end_
+  extern f_status_t fss_read_extended_list_print_object_end(fl_print_t * const print);
+#endif // _di_fss_read_extended_list_print_object_end_
+
+/**
+ * Print the end of an Object/Content set.
+ *
+ * This locks, uses, and unlocks the file stream.
+ *
+ * @param print
+ *   The output structure to print to.
+ *
+ *   The print.custom is expected to be of type fss_read_main_t.
+ *
+ *   This does not alter print.custom.setting.state.status.
+ *
+ * @return
+ *   F_none on success.
+ *   F_output_not on success, but no printing is performed.
+ *
+ *   F_output_not (with error bit) if a parameter is NULL.
+ *
+ * @see f_file_stream_lock()
+ * @see f_file_stream_unlock()
+ * @see f_print_dynamic_raw()
+ */
 #ifndef _di_fss_read_extended_list_print_set_end_
   extern f_status_t fss_read_extended_list_print_set_end(fl_print_t * const print);
 #endif // _di_fss_read_extended_list_print_set_end_
index 79008c100a1705bc1864a853bd71071bc3e8ff5f..0194308e2357df3318eb8033367875d5f387171f 100644 (file)
@@ -190,22 +190,11 @@ extern "C" {
 
       for (i = 0; i < 6; ++i) {
 
-        if (parameters->array[parameter_code[i]].result & f_console_result_found_e) {
-          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_requires_message(&main->program.error, f_console_symbol_long_normal_s, parameter_name[i], parameter_message[i]);
-
-          return;
-        }
-        else if (parameters->array[parameter_code[i]].result & f_console_result_value_e) {
-          main->setting.state.flag |= parameter_flag[i];
+        if (parameters->array[parameter_code[i]].result & f_console_result_value_e) {
+          main->setting.flag |= parameter_flag[i];
 
           if (parameter_value_digit[i]) {
-            index = parameters->array[parameter_code[i]].values.array[parameters->array[parameter_code[i]].location];
+            index = parameters->array[parameter_code[i]].values.array[parameters->array[parameter_code[i]].values.used - 1];
 
             main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[index], parameter_value_digit[i]);
 
@@ -216,6 +205,17 @@ extern "C" {
             }
           }
         }
+        else if (parameters->array[parameter_code[i]].result & f_console_result_found_e) {
+          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_requires_message(&main->program.error, f_console_symbol_long_normal_s, parameter_name[i], parameter_message[i]);
+
+          return;
+        }
       } // for
     }
 
index b759328c5053db2b1f43f8398d25f6c68c7cd1e0..b574f425415b8809e204810f20ad24620a3782f6 100644 (file)
@@ -134,6 +134,7 @@ extern "C" {
  * print_object:         Print the Object, usually called by the process_normal() callback.
  * print_content:        Print the Content, usually called by the process_normal() callback.
  * print_content_ignore: Print the Content ignore character, usually called by several callbacks within the process_normal() callback for a pipe.
+ * print_content_next:   Print the Content next (content separator), usually called by several callbacks within the process_normal() callback.
  * print_object_end:     Print the Object end, usually called by several callbacks within the process_normal() callback.
  * print_set_end:        Print the Content set end, usually called by several callbacks within the process_normal() callback.
  */
@@ -154,6 +155,7 @@ extern "C" {
     f_status_t (*print_object)(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits);
     f_status_t (*print_content)(fl_print_t * const print, const f_string_range_t range, const uint8_t quote, const f_fss_delimits_t delimits);
     f_status_t (*print_content_ignore)(fl_print_t * const print);
+    f_status_t (*print_content_next)(fl_print_t * const print);
     f_status_t (*print_object_end)(fl_print_t * const print);
     f_status_t (*print_set_end)(fl_print_t * const print);
   } fss_read_callback_t;
@@ -175,6 +177,7 @@ extern "C" {
       0, \
       0, \
       0, \
+      0, \
     }
 #endif // _di_fss_read_callback_t_
 
index 5c2d4c86f2e04c7a140c1a56627c87403515bda4..5ff1439159b4887b3f83418ff2a50bbd6f0a95e5 100644 (file)
@@ -117,10 +117,8 @@ extern "C" {
             main->callback.print_object(&main->program.output, at, delimits_object);
           }
 
-          if (main->setting.flag & fss_read_main_flag_content_e) {
-            if (main->callback.print_object_end) {
-              main->callback.print_object_end(&main->program.output);
-            }
+          if (main->callback.print_object_end) {
+            main->callback.print_object_end(&main->program.output);
           }
         }
 
index 25d0bbf30013740ec4a0b78ea8e42c1f43d7a87e..2544099dcd078c1fe842dade7526665a4a5d89fd 100644 (file)
@@ -107,14 +107,15 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
     main->callback.process_line = &fss_read_process_normal_line;
     main->callback.process_load = 0;
     main->callback.process_name = &fss_read_process_normal_name;
-    main->callback.process_total = &fss_read_process_normal_total;
+    main->callback.process_total = 0;
 
     main->callback.print_at = &fss_read_print_at;
     main->callback.print_content = &fss_read_print_content;
+    main->callback.print_content_next = 0;
     main->callback.print_content_ignore = &fss_read_print_content_ignore;
     main->callback.print_object = &fss_read_print_object;
-    main->callback.print_object_end = &fss_read_print_object_end;
-    main->callback.print_set_end = &fss_read_print_set_end;
+    main->callback.print_object_end = 0;
+    main->callback.print_set_end = 0;
 
     if (main->program.parameters.array[fss_read_parameter_as_e].result & f_console_result_value_e && main->program.parameters.array[fss_read_parameter_as_e].values.used) {
 
@@ -142,9 +143,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
           main->callback.process_help = &fss_read_basic_process_help;
           main->callback.process_load = &fss_read_basic_process_load;
-          main->callback.print_set_end = &fss_read_print_set_end;
+          main->callback.process_total = &fss_read_process_normal_total;
 
-          main->callback.print_object_end = &fss_read_print_object_end;
+          main->callback.print_content_next = 0;
+          main->callback.print_object_end = &fss_read_basic_print_object_end;
+          main->callback.print_set_end = &fss_read_print_set_end;
         }
         else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0001_s) == F_equal_to ||
                  f_compare_dynamic(argv[index], fss_read_format_code_long_0001_s) == F_equal_to ||
@@ -162,9 +165,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
           main->callback.process_help = &fss_read_extended_process_help;
           main->callback.process_load = &fss_read_extended_process_load;
-          main->callback.print_set_end = &fss_read_print_set_end_no_eol;
+          main->callback.process_total = &fss_read_process_normal_total;
 
-          main->callback.print_object_end = &fss_read_print_object_end;
+          main->callback.print_content_next = &fss_read_extended_print_content_next;
+          main->callback.print_object_end = &fss_read_extended_print_object_end;
+          main->callback.print_set_end = &fss_read_print_set_end_no_eol;
         }
         else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0002_s) == F_equal_to ||
                  f_compare_dynamic(argv[index], fss_read_format_code_long_0002_s) == F_equal_to ||
@@ -182,9 +187,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
           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;
+          main->callback.process_total = &fss_read_process_normal_total_multiple;
 
+          main->callback.print_content_next = 0;
           main->callback.print_object_end = &fss_read_basic_list_print_object_end;
+          main->callback.print_set_end = &fss_read_print_set_end;
         }
         else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0003_s) == F_equal_to ||
                  f_compare_dynamic(argv[index], fss_read_format_code_long_0003_s) == F_equal_to ||
@@ -202,9 +209,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
           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;
+          main->callback.process_total = &fss_read_process_normal_total_multiple;
 
-          main->callback.print_object_end = &fss_read_print_object_end;
+          main->callback.print_content_next = 0;
+          main->callback.print_object_end = &fss_read_extended_list_print_object_end;
+          main->callback.print_set_end = &fss_read_print_set_end;
         }
         else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0008_s) == F_equal_to ||
                  f_compare_dynamic(argv[index], fss_read_format_code_long_0008_s) == F_equal_to ||
@@ -222,9 +231,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
           main->callback.process_help = &fss_read_embedded_list_process_help;
           main->callback.process_load = &fss_read_embedded_list_process_load;
-          main->callback.print_set_end = &fss_read_print_set_end;
+          main->callback.process_total = &fss_read_process_normal_total_multiple;
 
-          main->callback.print_object_end = &fss_read_print_object_end;
+          main->callback.print_content_next = 0;
+          main->callback.print_object_end = &fss_read_embedded_list_print_object_end;
+          main->callback.print_set_end = &fss_read_print_set_end;
         }
         else if (f_compare_dynamic(argv[index], fss_read_format_code_short_000e_s) == F_equal_to ||
                  f_compare_dynamic(argv[index], fss_read_format_code_long_000e_s) == F_equal_to ||
@@ -242,9 +253,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
           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;
+          main->callback.process_total = &fss_read_process_normal_total_multiple;
 
-          main->callback.print_object_end = &fss_read_print_object_end;
+          main->callback.print_content_next = 0;
+          main->callback.print_object_end = &fss_read_payload_print_object_end;
+          main->callback.print_set_end = &fss_read_print_set_end;
         }
         else {
           if (main->setting.flag & fss_read_main_flag_help_e) {
index cf612bdcbcf05ad99fae65a1667f0bf0686db0de..4f28b4d2751c74056771e010a81cba0e88c76393 100644 (file)
@@ -19,16 +19,21 @@ extern "C" {
           main->callback.print_object(&main->program.output, at, delimits_object);
         }
 
-        if (main->setting.flag & fss_read_main_flag_content_e) {
-          if (main->callback.print_object_end) {
-            main->callback.print_object_end(&main->program.output);
-          }
+        if (main->callback.print_object_end) {
+          main->callback.print_object_end(&main->program.output);
         }
       }
 
       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].used ? main->setting.quotes_content.array[at].array[0] : 0, delimits_content);
+          for (f_array_length_t i = 0; i < main->setting.contents.array[at].used; ++i) {
+
+            main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[i], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content);
+
+            if (main->callback.print_content_next && i + 1 < main->setting.contents.array[at].used) {
+              main->callback.print_content_next(&main->program.output);
+            }
+          } // for
         }
       }
 
@@ -146,19 +151,6 @@ extern "C" {
   }
 #endif // _di_fss_read_print_object_
 
-#ifndef _di_fss_read_print_object_end_
-  f_status_t fss_read_print_object_end(fl_print_t * const print) {
-
-    if (!print || !print->custom) return F_status_set_error(F_output_not);
-
-    fss_read_main_t * const main = (fss_read_main_t *) print->custom;
-
-    fll_print_dynamic_raw((main->setting.flag & fss_read_main_flag_pipe_e) ? fss_read_pipe_content_start_s : f_fss_space_s, print->to);
-
-    return F_none;
-  }
-#endif // _di_fss_read_print_object_end_
-
 #ifndef _di_fss_read_print_quote_
   f_status_t fss_read_print_quote(fl_print_t * const print, const uint8_t type) {
 
index d013f0960848719603fcb93569aa598246ffc072..8430f65fbd7752844179cf00aea2358e17b49184 100644 (file)
@@ -21,6 +21,8 @@ extern "C" {
  *
  * This locks, uses, and unlocks the file stream.
  *
+ * This processes multiple Content ranges and calls main.callback.print_content() for each individual Content range.
+ *
  * @param print
  *   The output structure to print to.
  *
@@ -61,6 +63,7 @@ extern "C" {
  *
  * This locks, uses, and unlocks the file stream.
  *
+ * This processes single Content range.
  * This does not print a new line after the Content.
  *
  * @param print
@@ -178,30 +181,6 @@ extern "C" {
 #endif // _di_fss_read_print_object_
 
 /**
- * Print the end of an Object (which is often the start of Content).
- *
- * This locks, uses, and unlocks the file stream.
- *
- * @param print
- *   The output structure to print to.
- *
- *   The print.custom is expected to be of type fss_read_main_t.
- *
- *   This does not alter print.custom.setting.state.status.
- *
- * @return
- *   F_none on success.
- *   F_output_not on success, but no printing is performed.
- *
- *   F_output_not (with error bit) if a parameter is NULL.
- *
- * @see fll_print_dynamic_raw()
- */
-#ifndef _di_fss_read_print_object_end_
-  extern f_status_t fss_read_print_object_end(fl_print_t * const print);
-#endif // _di_fss_read_print_object_end_
-
-/**
  * Print the Object at the given position.
  *
  * This locks, uses, and unlocks the file stream.
index 7373fa76017913aa53ba78739e0c96adcb6d285b..d2eb25d1fa8e1617607dc2f69b40cbec753a15a2 100644 (file)
@@ -38,7 +38,7 @@ extern "C" {
 
     fl_print_format("%[%QThe parameter '%]", print->to, print->context, print->prefix, print->context);
     fl_print_format("%[%r%r%]", print->to, print->notable, symbol, name, print->notable);
-    fl_print_format("%[' requires %s.%]%r", print->to, print->context, message, print->context, f_string_eol_s);
+    fl_print_format("%[' requires %Q.%]%r", print->to, print->context, message, print->context, f_string_eol_s);
 
     f_file_stream_unlock(print->to);
 
index 09ac7da1fe1cafa796a1ccd2ab18dcd95502f275..1880e7a072e3ee9429a8ea327df566dd5be13b04 100644 (file)
@@ -29,6 +29,24 @@ extern "C" {
     // The process_load() callback is required to be non-NULL.
     if (!main->callback.process_load) return;
 
+    if (main->setting.buffer.used) {
+      main->setting.range.start = 0;
+      main->setting.range.stop = main->setting.buffer.used;
+    }
+    else {
+      main->setting.range.start = 1;
+      main->setting.range.stop = 0;
+    }
+
+    main->setting.objects.used = 0;
+    main->setting.contents.used = 0;
+    main->setting.comments.used = 0;
+    main->setting.delimits_object.used = 0;
+    main->setting.delimits_content.used = 0;
+    main->setting.nest.used = 0;
+    main->setting.quotes_object.used = 0;
+    main->setting.quotes_content.used = 0;
+
     main->callback.process_load(main);
     if (F_status_is_error(main->setting.state.status)) return;
 
@@ -47,26 +65,34 @@ extern "C" {
       memset(names, F_true, sizeof(bool) * main->setting.objects.used);
     }
 
-    if (main->callback.process_at) {
-      main->callback.process_at(main, names, *delimits_object, *delimits_content);
+    if (main->setting.flag & fss_read_main_flag_at_e) {
+      if (main->callback.process_at) {
+        main->callback.process_at(main, names, *delimits_object, *delimits_content);
+      }
 
       return;
     }
 
-    if ((main->setting.flag & fss_read_main_flag_columns_e) && main->callback.process_columns) {
-      main->callback.process_columns(main, names);
+    if (main->setting.flag & fss_read_main_flag_columns_e) {
+      if (main->callback.process_columns) {
+        main->callback.process_columns(main, names);
+      }
 
       return;
     }
 
-    if ((main->setting.flag & fss_read_main_flag_total_e) && main->callback.process_total) {
-      main->callback.process_total(main, names);
+    if (main->setting.flag & fss_read_main_flag_total_e) {
+      if (main->callback.process_total) {
+        main->callback.process_total(main, names);
+      }
 
       return;
     }
 
-    if ((main->setting.flag & fss_read_main_flag_line_e) && main->callback.process_line) {
-      main->callback.process_line(main, names);
+    if (main->setting.flag & fss_read_main_flag_line_e) {
+      if (main->callback.process_line) {
+        main->callback.process_line(main, names);
+      }
 
       return;
     }
@@ -118,9 +144,11 @@ extern "C" {
     f_array_length_t i = 0;
     f_array_length_t j = 0;
     f_array_length_t k = 0;
+    f_array_length_t l = 0;
     f_array_length_t at = 0;
     f_array_length_t line = 0;
     f_array_length_t total = 0;
+    f_string_range_t range = f_string_range_t_initialize;
 
     for (; i < main->setting.objects.used; ++i) {
 
@@ -130,25 +158,39 @@ extern "C" {
       if (at == main->setting.depths.array[0].value_at) {
         if (main->setting.flag & fss_read_main_flag_line_e) {
 
-          // For standards that only support one line per Object so when using "--at", then the only valid line is line 0.
-          if (main->setting.flag & fss_read_main_flag_line_single_e) break;
+          // If using "--at" for standards that only support one line per Object, then the only valid line is line 0.
+          if ((main->setting.flag & fss_read_main_flag_line_single_e) && !at) break;
 
           line = 0;
 
           if (main->setting.flag & fss_read_main_flag_total_e) {
+            total = 0;
+            l = 0;
+
+            for (j = 0; j < main->setting.contents.array[i].used; ++j) {
+
+              if (main->setting.contents.array[i].array[j].start > main->setting.contents.array[i].array[j].stop) continue;
 
-            // Total is always 1 in this case because "line" parameter forces a single line.
-            fss_read_print_number(&main->program.output, 1);
+              if (l < main->setting.comments.used) {
+                while (main->setting.comments.array[l].stop < k) ++l;
+
+                if (k >= main->setting.comments.array[l].start && k <= main->setting.comments.array[l].stop) {
+                  k = main->setting.comments.array[l++].stop;
+
+                  continue;
+                }
+              }
+
+              total = 1;
+
+              break;
+            } // for
+
+            fss_read_print_number(&main->program.output, total);
           }
           else {
             fss_read_process_at_line(main, i, delimits_object, delimits_content, &line);
           }
-
-          if (main->setting.state.status == F_success) {
-            main->setting.state.status = F_none;
-
-            return;
-          }
         }
         else if (main->setting.flag & fss_read_main_flag_columns_e) {
           fss_read_print_number(&main->program.output, main->setting.contents.array[i].used);
@@ -159,15 +201,28 @@ extern "C" {
           }
           else {
             total = 0;
-            k = 0;
+            l = 0;
 
-            // Count each new line.
             for (j = 0; j < main->setting.contents.array[i].used; ++j) {
 
-              if (main->setting.contents.array[i].array[j].start > main->setting.contents.array[i].array[j].stop) continue;
-              if (main->setting.contents.array[i].array[j].start > main->setting.buffer.used) continue;
+              range.start = main->setting.contents.array[i].array[j].start;
+              range.stop = main->setting.contents.array[i].array[j].stop;
+
+              // This content has no data, do not even check "include empty" because it cannot be counted as a line.
+              if (range.start > range.stop) continue;
+
+              for (k = range.start; k <= range.stop; ++k) {
+
+                if (l < main->setting.comments.used) {
+                  while (main->setting.comments.array[l].stop < k) ++l;
+
+                  if (k >= main->setting.comments.array[l].start && k <= main->setting.comments.array[l].stop) {
+                    k = main->setting.comments.array[l++].stop;
+
+                    continue;
+                  }
+                }
 
-              for (k = main->setting.contents.array[i].array[j].start; k <= main->setting.contents.array[i].array[j].stop && k < main->setting.buffer.used; ++k) {
                 if (main->setting.buffer.string[k] == f_string_eol_s.string[0]) ++total;
               } // for
             } // for
@@ -357,7 +412,7 @@ extern "C" {
       if (!names[i]) continue;
       if (fss_read_signal_check(main)) return;
 
-      if (!(main->setting.flag & fss_read_main_flag_object_e) && main->setting.flag & fss_read_main_flag_content_e) {
+      if (!(main->setting.flag & fss_read_main_flag_object_e) && (main->setting.flag & fss_read_main_flag_content_e)) {
         if (!(main->setting.contents.array[i].used || (main->setting.flag & fss_read_main_flag_empty_e))) continue;
       }
 
@@ -375,6 +430,76 @@ extern "C" {
   }
 #endif // _di_fss_read_process_normal_total_
 
+#ifndef _di_fss_read_process_normal_total_multiple_
+  void fss_read_process_normal_total_multiple(void * const void_main, const bool names[]) {
+
+    if (!void_main) return;
+
+    fss_read_main_t * const main = (fss_read_main_t *) void_main;
+
+    f_array_length_t total = 0;
+    f_string_range_t range = f_string_range_t_initialize;
+    f_array_length_t i = 0;
+    f_array_length_t j = 0;
+    f_array_length_t k = 0;
+
+    for (f_array_length_t at = 0; at < main->setting.contents.used; ++at) {
+
+      if (!names[at]) continue;
+      if (fss_read_signal_check(main)) return;
+
+      if (main->setting.flag & fss_read_main_flag_object_e) {
+        ++total;
+      }
+
+      if (main->setting.flag & fss_read_main_flag_content_e) {
+
+        if (!main->setting.contents.array[at].used) continue;
+
+        for (i = 0; i < main->setting.contents.array[at].used; ++i) {
+
+          range.start = main->setting.contents.array[at].array[i].start;
+          range.stop = main->setting.contents.array[at].array[i].stop;
+
+          // This content has no data, do not even check "include empty" because it cannot be counted as a line.
+          if (range.start > range.stop) continue;
+
+          for (j = range.start; j <= range.stop; ++j) {
+
+            if (k < main->setting.comments.used) {
+              while (main->setting.comments.array[k].stop < j) ++k;
+
+              if (j >= main->setting.comments.array[k].start && j <= main->setting.comments.array[k].stop) {
+                j = main->setting.comments.array[k++].stop;
+
+                continue;
+              }
+            }
+
+            if (main->setting.buffer.string[j] == f_string_eol_s.string[0]) ++total;
+          } // for
+        } // for
+
+        // If Content does not end with a newline, it still must be treated as the last line.
+        if (i) {
+          j = main->setting.contents.array[at].array[i - 1].stop;
+
+          if (main->setting.buffer.string[j] != f_string_eol_s.string[0]) ++total;
+        }
+      }
+    } // for
+
+    fss_read_print_number(
+      &main->program.output,
+      main->setting.flag & fss_read_main_flag_line_e
+        ? main->setting.line < total ? 1 : 0
+        : total
+    );
+
+    main->setting.state.status = F_none;
+  }
+#endif // _di_fss_read_process_normal_total_multiple_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index dfa3e2c8d24c3c461b658c7e7db2d2e1afbfac9a..911301a6cecf7aed6f27f1686356555acc7707d3 100644 (file)
@@ -48,6 +48,8 @@ extern "C" {
 /**
  * Process buffer according to "at" parameter rules.
  *
+ * This handles only a single depth (index 0 of the depth array).
+ *
  * @param main
  *   The program and settings data.
  *
@@ -147,6 +149,8 @@ extern "C" {
 /**
  * Process buffer according to "total" parameter rules.
  *
+ * This processes single line Content only.
+ *
  * @param main
  *   The program and settings data.
  *
@@ -167,6 +171,31 @@ extern "C" {
   extern void fss_read_process_normal_total(void * const main, const bool names[]);
 #endif // _di_fss_read_process_normal_total_
 
+/**
+ * Process buffer according to "total" parameter rules.
+ *
+ * This processes multi-line Content only.
+ *
+ * @param main
+ *   The program and settings data.
+ *
+ *   Must not be NULL.
+ *   Must be of type fss_read_main_t.
+ *
+ *   This alters main.setting.state.status:
+ *     F_none on success.
+ *
+ *     Errors (with error bit) from: fss_read_signal_check().
+ * @param names
+ *   An array of booleans representing if the name at a given index is enabled.
+ *   (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.)
+ *
+ * @see fss_read_signal_check()
+ */
+#ifndef _di_fss_read_process_normal_total_multiple_
+  extern void fss_read_process_normal_total_multiple(void * const main, const bool names[]);
+#endif // _di_fss_read_process_normal_total_multiple_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 4331a3094c56baf6078e8d9b3da3b9f13886ced5..35cb7f8e58942e35e3fc670c0c8dc11dd0406891 100644 (file)
@@ -30,6 +30,8 @@ extern "C" {
       main->setting.range.stop = 0;
     }
 
+    main->setting.objects.used = 0;
+    main->setting.contents.used = 0;
     main->setting.comments.used = 0;
     main->setting.delimits_object.used = 0;
     main->setting.delimits_content.used = 0;
index 034df72a0efd867c75d51af8d4dedadb055a3ea9..60ab2385f32e9d390ad8f83795be7d32988a66d8 100644 (file)
@@ -35,7 +35,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
   data.callback.print_content = &fss_read_print_content;
   data.callback.print_content_ignore = &fss_read_print_content_ignore;
   data.callback.print_object = &fss_read_print_object;
-  data.callback.print_object_end = &fss_read_print_object_end;
+  data.callback.print_object_end = &fss_read_payload_print_object_end;
   data.callback.print_set_end = &fss_read_print_set_end;
 
   f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize;
index 2b5cccafca808865f22bd3f7c4ebf541fa405d44..d502b78b8e76c1c5f1335ec033332f4563df1cc6 100644 (file)
@@ -56,6 +56,35 @@ extern "C" {
   }
 #endif // _di_fss_read_payload_print_help_
 
+#ifndef _di_fss_read_payload_print_object_end_
+  f_status_t fss_read_payload_print_object_end(fl_print_t * const print) {
+
+    if (!print || !print->custom) return F_status_set_error(F_output_not);
+
+    fss_read_main_t * const main = (fss_read_main_t *) print->custom;
+
+
+    f_file_stream_lock(print->to);
+
+    if (main->setting.flag & fss_read_main_flag_pipe_e) {
+      f_print_dynamic_raw(fss_read_pipe_content_start_s, print->to);
+    }
+    else {
+      if (main->setting.flag & fss_read_main_flag_content_e) {
+        f_print_dynamic_raw(f_fss_payload_list_open_s, print->to);
+        f_print_dynamic_raw(f_fss_payload_list_open_end_s, print->to);
+      }
+      else {
+        f_print_dynamic_raw(f_fss_eol_s, print->to);
+      }
+    }
+
+    f_file_stream_unlock(print->to);
+
+    return F_none;
+  }
+#endif // _di_fss_read_payload_print_object_end_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index a2240d6afa42c52487293105059d4ad60a3eb6ee..cd9770704d5e265a14539ec6c64f43c22530da8f 100644 (file)
@@ -50,6 +50,32 @@ extern "C" {
   extern f_status_t fss_read_payload_print_help(fl_print_t * const print);
 #endif // _di_fss_read_payload_print_help_
 
+/**
+ * Print the end of an Object (which is often the start of Content).
+ *
+ * This locks, uses, and unlocks the file stream.
+ *
+ * @param print
+ *   The output structure to print to.
+ *
+ *   The print.custom is expected to be of type fss_read_main_t.
+ *
+ *   This does not alter print.custom.setting.state.status.
+ *
+ * @return
+ *   F_none on success.
+ *   F_output_not on success, but no printing is performed.
+ *
+ *   F_output_not (with error bit) if a parameter is NULL.
+ *
+ * @see f_file_stream_lock()
+ * @see f_file_stream_unlock()
+ * @see f_print_dynamic_raw()
+ */
+#ifndef _di_fss_read_payload_print_object_end_
+  extern f_status_t fss_read_payload_print_object_end(fl_print_t * const print);
+#endif // _di_fss_read_payload_print_object_end_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif