]> Kevux Git Server - fll/commitdiff
Progress: Fix issues in runtime tests for fss_read not relating to Embedded List...
authorKevin Day <kevin@kevux.org>
Thu, 15 Jun 2023 03:13:00 +0000 (22:13 -0500)
committerKevin Day <kevin@kevux.org>
Thu, 15 Jun 2023 04:06:42 +0000 (23:06 -0500)
More runtime tests now pass.

The Extended List tests still fail in some cases.
I noticed that the Extended List line count is not handling the closing brace.
The count is inaccurate.
This is a bug in the 0.6.x branch and needs to be fixed there.
The fix is in place for this branch but the tests currently fail because they generated expect files are incorrect in this case.

There are other similar problems in different FSS read programs regarding --total and parameters like --at or --line that need to be fixed in the 0.6.x branch as well.

The Embedded List and Payload need special handling and are not addressed here.

Other things regarding fss_read not done:
- The help printing needs to be updated for each program.
- Any remaining todo and fixme.
- The pipe input and output.

There is likely a lot of room for improvement but I am going to ignore such things for now as my priorities are elsewhere.

12 files changed:
level_3/fss_read/c/basic/main.c
level_3/fss_read/c/basic_list/main.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_list/main.c
level_3/fss_read/c/extended_list/print.c
level_3/fss_read/c/main/common.h
level_3/fss_read/c/main/common/enumeration.h
level_3/fss_read/c/main/main.c
level_3/fss_read/c/main/process_normal.c
level_3/fss_read/c/payload/main.c

index 4bb2865625709ab9b3f3c123ecab506f913d16e2..77d1654cba04631336db4b2762ebb25ca023358f 100644 (file)
@@ -36,8 +36,8 @@ 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_content_next = 0;
   data.callback.print_object = &fss_read_print_object;
   data.callback.print_object_end = &fss_read_basic_print_object_end;
   data.callback.print_set_end = &fss_read_print_set_end;
index 7c919f6eb2b527d4e6cdfb18444bf41798bd7408..c8798c080af0bbd7018f1ee6d5c1798bf69b0668 100644 (file)
@@ -17,7 +17,7 @@ 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_object_as_line_e;
+  data.setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e;
 
   data.setting.state.custom = (void *) &data;
   data.setting.standard = fss_read_basic_list_standard_s;
@@ -35,8 +35,8 @@ 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 = &fss_read_print_content_ignore;
+  data.callback.print_content_next = 0;
   data.callback.print_object = &fss_read_print_object;
   data.callback.print_object_end = &fss_read_basic_list_print_object_end;
   data.callback.print_set_end = &fss_read_print_set_end_no_eol;
index ca5972ef00b413a71a4cad523b126cdc5686a7ed..1bd71e25ddf3d8780552d125ccedcc88f9714aef 100644 (file)
@@ -17,7 +17,7 @@ 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_object_as_line_e;
+  data.setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_content_has_close_e | fss_read_main_flag_object_trim_e;
   data.setting.flag |= fss_read_main_flag_depth_multiple_e;
 
   data.setting.state.custom = (void *) &data;
@@ -36,8 +36,8 @@ 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 = &fss_read_print_content_ignore;
+  data.callback.print_content_next = 0;
   data.callback.print_object = &fss_read_print_object;
   data.callback.print_object_end = &fss_read_embedded_list_print_object_end;
   data.callback.print_set_end = &fss_read_print_set_end;
index da4b6512e0af85cbbdf1c5c6aec53f676ce91875..243b21a07d2483b9371fd54d77cde45390b2a481 100644 (file)
@@ -62,6 +62,22 @@ extern "C" {
   }
 #endif // _di_fss_read_embedded_list_print_object_end_
 
+#ifndef _di_fss_read_embedded_list_print_set_end_
+  f_status_t fss_read_embedded_list_print_set_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_object_e) && main->setting.flag & fss_read_main_flag_content_e) {
+      f_print_dynamic_raw(f_fss_embedded_list_close_s, print->to);
+      f_print_dynamic_raw(f_fss_embedded_list_close_end_s, print->to);
+    }
+
+    return F_none;
+  }
+#endif // _di_fss_read_embedded_list_print_set_end_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index f87166338578bd4d36981172b6c44e0412cbe28d..6914be9764223a5582000a9458e47bfaa38ccbe4 100644 (file)
@@ -56,6 +56,32 @@ extern "C" {
   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_
 
+/**
+ * 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_embedded_list_print_set_end_
+  extern f_status_t fss_read_embedded_list_print_set_end(fl_print_t * const print);
+#endif // _di_fss_read_embedded_list_print_set_end_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 7cf68bb7e5fb425afc7057658735199e8bb738a5..7ee67eda890ff38840ad631ec7c801dc21570183 100644 (file)
@@ -17,7 +17,7 @@ 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_object_as_line_e;
+  data.setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_content_has_close_e | fss_read_main_flag_object_trim_e;
 
   data.setting.state.custom = (void *) &data;
   data.setting.standard = fss_read_extended_list_standard_s;
@@ -35,8 +35,8 @@ 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 = &fss_read_print_content_ignore;
+  data.callback.print_content_next = 0;
   data.callback.print_object = &fss_read_print_object;
   data.callback.print_object_end = &fss_read_extended_list_print_object_end;
   data.callback.print_set_end = &fss_read_extended_list_print_set_end;
index 68ae81e522d7d7ce4c69a3c708647042a355293f..17e3f52009bb64dba90fe247251ea06d10263644 100644 (file)
@@ -69,8 +69,10 @@ extern "C" {
 
     fss_read_main_t * const main = (fss_read_main_t *) print->custom;
 
-    // @todo
-    //fll_print_dynamic_raw((main->setting.flag & fss_read_main_flag_pipe_e) ? fss_read_pipe_content_end_s : f_string_eol_s, print->to);
+    if ((main->setting.flag & fss_read_main_flag_object_e) && main->setting.flag & fss_read_main_flag_content_e) {
+      f_print_dynamic_raw(f_fss_extended_list_close_s, print->to);
+      f_print_dynamic_raw(f_fss_extended_list_close_end_s, print->to);
+    }
 
     return F_none;
   }
index a8f323467dfccaf285353f22e8638edcddf696ea..0ac1caec99c27e680e98aaccdacfe068554ae019 100644 (file)
@@ -64,7 +64,7 @@ extern "C" {
  *     Errors (with error bit) from: fll_program_parameter_process_context().
  *     Errors (with error bit) from: fll_program_parameter_process_verbosity().
  *
- *     Errors (with error bit) from: fss_read_setting_load_depth(). @todo fss_read_depths_resize() is to be relocated to "callback".
+ *     Errors (with error bit) from: fss_read_setting_load_depth().
  *     Errors (with error bit) from: fss_read_signal_check()
  * @param callback
  *   (optional) Designate a function to call after performing the initial processing, but before printing help.
@@ -77,7 +77,7 @@ extern "C" {
  * @see fll_program_parameter_process_context()
  * @see fll_program_parameter_process_verbosity()
  *
- * @see fss_read_setting_load_depth() @todo fss_read_depths_resize() is to be relocated to "callback".
+ * @see fss_read_setting_load_depth()
  * @see fss_read_signal_check()
  */
 #ifndef _di_fss_read_setting_load_
index bb55a99bafe6d27d8c0cfc902078cec7ca384ed7..b04ccc3ca29aa6f08eeeb43339f14b2a63a7d9b5 100644 (file)
@@ -20,63 +20,67 @@ extern "C" {
  * Flags passed to the main function or program.
  *
  * fss_read_main_flag_*_e:
- *   - none:             No flags set.
- *   - at:               The object at the given position is being selected (Think of this as select a row for some Object).
- *   - columns:          The total columns found and selected is printed instead of the Content.
- *   - content:          The Content is to be printed.
- *   - content_multiple: Designate that multiple Content is allowed for an Object for this standard rather than a single Content per Object.
- *   - copyright:        Print copyright.
- *   - delimit:          How delimits are to be handled is designated.
- *   - depth:            The depth is specified at least once.
- *   - depth_multiple:   Designate that multiple depths are allowed within Content rather than being single depth Content.
- *   - empty:            Empty Content will be printed (Objects that have no Content will have their empty Content printed).
- *   - help:             Print help.
- *   - line:             A specific Content at a given line is to be selected (Think of this as select a row for some Content).
- *   - line_single:      Designate that only a single line for Content is allowed for an Object for this standard rather than allowing multiple lines per Content per Object.
- *   - name:             A specific Object name has been requested.
- *   - object:           The Object is to be printed.
- *   - object_as_line:   The Object is counted as its own line for the purpose of -l/--line or any other similar behavior.
- *   - original:         Enable original printing, where the quotes are printed and no delimits are applied.
- *   - pipe:             Print using the special pipe format.
- *   - print_first:      When set, print new line to message output on program begin after loading settings.
- *   - print_last:       When set, print new line to message output on program end.
- *   - quote_content:    Designate that the standard supports quotes on Content.
- *   - quote_object:     Designate that the standard supports quotes on Objects.
- *   - select:           A specific Content at a given position is to be selected (Think of this as select a column for some Content).
- *   - total:            The total lines found and selected is printed instead of the Content.
- *   - trim:             Empty space before and after Objects and Content will not be printed (They will be trimmed).
- *   - trim_object:      Empty space before and after Objects (but not Content) will not be printed (They will be trimmed).
- *   - version:          Print version.
+ *   - none:              No flags set.
+ *   - at:                The object at the given position is being selected (Think of this as select a row for some Object).
+ *   - columns:           The total columns found and selected is printed instead of the Content.
+ *   - content:           The Content is to be printed.
+ *   - content_has_close: The Content has a closing character which needs to be counted and handled when processing both Object and Content, but is otherwise not processed or printed.
+ *   - content_multiple:  Designate that multiple Content is allowed for an Object for this standard rather than a single Content per Object.
+ *   - copyright:         Print copyright.
+ *   - delimit:           How delimits are to be handled is designated.
+ *   - depth:             The depth is specified at least once.
+ *   - depth_multiple:    Designate that multiple depths are allowed within Content rather than being single depth Content.
+ *   - empty:             Empty Content will be printed (Objects that have no Content will have their empty Content printed).
+ *   - help:              Print help.
+ *   - line:              A specific Content at a given line is to be selected (Think of this as select a row for some Content).
+ *   - line_single:       Designate that only a single line for Content is allowed for an Object for this standard rather than allowing multiple lines per Content per Object.
+ *   - name:              A specific Object name has been requested.
+ *   - object:            The Object is to be printed.
+ *   - object_as_line:    The Object is counted as its own line for the purpose of -l/--line or any other similar behavior.
+ *   - object_trim:       Empty space before an after Objects are ignored while processing without affecting printing behavior.
+ *   - original:          Enable original printing, where the quotes are printed and no delimits are applied.
+ *   - pipe:              Print using the special pipe format.
+ *   - print_first:       When set, print new line to message output on program begin after loading settings.
+ *   - print_last:        When set, print new line to message output on program end.
+ *   - quote_content:     Designate that the standard supports quotes on Content.
+ *   - quote_object:      Designate that the standard supports quotes on Objects.
+ *   - select:            A specific Content at a given position is to be selected (Think of this as select a column for some Content).
+ *   - total:             The total lines found and selected is printed instead of the Content.
+ *   - trim:              Empty space before and after Objects and Content will not be printed (They will be trimmed).
+ *   - trim_object:       Empty space before and after Objects (but not Content) will not be printed (They will be trimmed).
+ *   - version:           Print version.
  */
 #ifndef _di_fss_read_main_flag_e_
   enum {
-    fss_read_main_flag_none_e             = 0x0,
-    fss_read_main_flag_at_e               = 0x1,
-    fss_read_main_flag_columns_e          = 0x2,
-    fss_read_main_flag_content_e          = 0x4,
-    fss_read_main_flag_content_multiple_e = 0x8,
-    fss_read_main_flag_copyright_e        = 0x10,
-    fss_read_main_flag_delimit_e          = 0x20,
-    fss_read_main_flag_depth_e            = 0x40,
-    fss_read_main_flag_depth_multiple_e   = 0x80,
-    fss_read_main_flag_empty_e            = 0x100,
-    fss_read_main_flag_help_e             = 0x200,
-    fss_read_main_flag_line_e             = 0x400,
-    fss_read_main_flag_line_single_e      = 0x800,
-    fss_read_main_flag_name_e             = 0x1000,
-    fss_read_main_flag_object_e           = 0x2000,
-    fss_read_main_flag_object_as_line_e   = 0x4000,
-    fss_read_main_flag_original_e         = 0x8000,
-    fss_read_main_flag_pipe_e             = 0x10000,
-    fss_read_main_flag_print_first_e      = 0x20000,
-    fss_read_main_flag_print_last_e       = 0x40000,
-    fss_read_main_flag_quote_content_e    = 0x80000,
-    fss_read_main_flag_quote_object_e     = 0x100000,
-    fss_read_main_flag_select_e           = 0x200000,
-    fss_read_main_flag_total_e            = 0x400000,
-    fss_read_main_flag_trim_e             = 0x800000,
-    fss_read_main_flag_trim_object_e      = 0x1000000,
-    fss_read_main_flag_version_e          = 0x2000000,
+    fss_read_main_flag_none_e              = 0x0,
+    fss_read_main_flag_at_e                = 0x1,
+    fss_read_main_flag_columns_e           = 0x2,
+    fss_read_main_flag_content_e           = 0x4,
+    fss_read_main_flag_content_has_close_e = 0x8,
+    fss_read_main_flag_content_multiple_e  = 0x10,
+    fss_read_main_flag_copyright_e         = 0x20,
+    fss_read_main_flag_delimit_e           = 0x40,
+    fss_read_main_flag_depth_e             = 0x80,
+    fss_read_main_flag_depth_multiple_e    = 0x100,
+    fss_read_main_flag_empty_e             = 0x200,
+    fss_read_main_flag_help_e              = 0x400,
+    fss_read_main_flag_line_e              = 0x800,
+    fss_read_main_flag_line_single_e       = 0x1000,
+    fss_read_main_flag_name_e              = 0x2000,
+    fss_read_main_flag_object_e            = 0x4000,
+    fss_read_main_flag_object_as_line_e    = 0x8000,
+    fss_read_main_flag_object_trim_e       = 0x10000,
+    fss_read_main_flag_original_e          = 0x20000,
+    fss_read_main_flag_pipe_e              = 0x40000,
+    fss_read_main_flag_print_first_e       = 0x80000,
+    fss_read_main_flag_print_last_e        = 0x100000,
+    fss_read_main_flag_quote_content_e     = 0x200000,
+    fss_read_main_flag_quote_object_e      = 0x400000,
+    fss_read_main_flag_select_e            = 0x800000,
+    fss_read_main_flag_total_e             = 0x1000000,
+    fss_read_main_flag_trim_e              = 0x2000000,
+    fss_read_main_flag_trim_object_e       = 0x4000000,
+    fss_read_main_flag_version_e           = 0x8000000,
   }; // enum
 #endif // _di_fss_read_main_flag_e_
 
index 2b7053e7cccaa1fe692f80629f61f08fbcf4c36e..9f9a1bf2c11f0c2a67af1214a68a615d52b6be30 100644 (file)
@@ -134,9 +134,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
           main->setting.standard = fss_read_basic_standard_s;
 
           // Remove flags not supported for this standard.
+          main->setting.flag -= main->setting.flag & fss_read_main_flag_content_has_close_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_object_as_line_e;
+          main->setting.flag -= main->setting.flag & fss_read_main_flag_object_trim_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_trim_object_e;
 
           main->setting.flag |= fss_read_main_flag_line_single_e;
@@ -158,8 +160,10 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
           main->setting.standard = fss_read_extended_standard_s;
 
           // Remove flags not supported for this standard.
+          main->setting.flag -= main->setting.flag & fss_read_main_flag_content_has_close_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_object_as_line_e;
+          main->setting.flag -= main->setting.flag & fss_read_main_flag_object_trim_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_trim_object_e;
 
           main->setting.flag |= fss_read_main_flag_line_single_e | fss_read_main_flag_content_multiple_e;
@@ -181,13 +185,14 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
           main->setting.standard = fss_read_basic_list_standard_s;
 
           // Remove flags not supported for this standard.
-          main->setting.flag -= main->setting.flag & fss_read_main_flag_line_single_e;
+          main->setting.flag -= main->setting.flag & fss_read_main_flag_content_has_close_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e;
+          main->setting.flag -= main->setting.flag & fss_read_main_flag_line_single_e;
           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_object_as_line_e;
+          main->setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e;
 
           main->callback.process_help = &fss_read_basic_list_process_help;
           main->callback.process_load = &fss_read_basic_list_process_load;
@@ -211,7 +216,8 @@ 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_object_as_line_e;
+          main->setting.flag |= fss_read_main_flag_content_has_close_e;
+          main->setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e;
 
           main->callback.process_help = &fss_read_extended_list_process_help;
           main->callback.process_load = &fss_read_extended_list_process_load;
@@ -219,7 +225,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
           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;
+          main->callback.print_set_end = &fss_read_extended_list_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 ||
@@ -229,12 +235,14 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
           main->setting.standard = fss_read_embedded_list_standard_s;
 
           // Remove flags not supported for this standard.
+          main->setting.flag -= main->setting.flag & fss_read_main_flag_content_has_close_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_line_single_e;
           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_content_multiple_e | fss_read_main_flag_depth_multiple_e;
-          main->setting.flag |= fss_read_main_flag_object_as_line_e;
+          main->setting.flag |= fss_read_main_flag_content_has_close_e | fss_read_main_flag_content_multiple_e;
+          main->setting.flag |= fss_read_main_flag_depth_multiple_e;
+          main->setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e;
 
           main->callback.process_help = &fss_read_embedded_list_process_help;
           main->callback.process_load = &fss_read_embedded_list_process_load;
@@ -242,7 +250,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
           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;
+          main->callback.print_set_end = &fss_read_embedded_list_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 ||
@@ -252,13 +260,14 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
           main->setting.standard = fss_read_payload_standard_s;
 
           // Remove flags not supported for this standard.
-          main->setting.flag -= main->setting.flag & fss_read_main_flag_line_single_e;
+          main->setting.flag -= main->setting.flag & fss_read_main_flag_content_has_close_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e;
           main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e;
+          main->setting.flag -= main->setting.flag & fss_read_main_flag_line_single_e;
           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_object_as_line_e;
+          main->setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e;
 
           main->callback.process_help = &fss_read_payload_process_help;
           main->callback.process_load = &fss_read_payload_process_load;
@@ -266,7 +275,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) {
 
           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;
+          main->callback.print_set_end = &fss_read_print_set_end_no_eol;
         }
         else {
           if (main->setting.flag & fss_read_main_flag_help_e) {
index a25f72e9627dc5ea5c3d7c1931f43f294b2b86fa..b699b45e96b1a166b6af7b70241cc14d76992200 100644 (file)
@@ -65,7 +65,12 @@ extern "C" {
       memset(names, F_true, sizeof(bool) * main->setting.objects.used);
     }
 
-    if (main->setting.flag & fss_read_main_flag_at_e) {
+    if (main->setting.flag & fss_read_main_flag_total_e) {
+      if (main->callback.process_total) {
+        main->callback.process_total(main, names);
+      }
+    }
+    else 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);
       }
@@ -75,11 +80,6 @@ extern "C" {
         main->callback.process_columns(main, names);
       }
     }
-    else if (main->setting.flag & fss_read_main_flag_total_e) {
-      if (main->callback.process_total) {
-        main->callback.process_total(main, names);
-      }
-    }
     else {
       f_array_length_t i = 0;
 
@@ -134,10 +134,6 @@ extern "C" {
     // If the standard only has one line per Content, then any line value greater than 0 equates to no line to print.
     if ((main->setting.flag & fss_read_main_flag_line_e) && (main->setting.flag & fss_read_main_flag_line_single_e)) {
       if (main->setting.line) {
-        if (main->setting.flag & fss_read_main_flag_total_e) {
-          fss_read_print_number(&main->program.output, 0);
-        }
-
         main->setting.state.status = F_none;
 
         return;
@@ -158,34 +154,7 @@ extern "C" {
           // 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;
 
-          if (main->setting.flag & fss_read_main_flag_total_e) {
-            f_array_length_t total = 0;
-            f_array_length_t j = 0;
-            f_array_length_t k = 0;
-            f_array_length_t l = 0;
-
-            for (; 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 (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 if (main->callback.process_at_line) {
+          if (main->callback.process_at_line) {
             f_array_length_t line = 0;
 
             main->callback.process_at_line(void_main, i, delimits_object, delimits_content, &line);
@@ -194,49 +163,6 @@ extern "C" {
         else if (main->setting.flag & fss_read_main_flag_columns_e) {
           fss_read_print_number(&main->program.output, main->setting.contents.array[i].used);
         }
-        else if (main->setting.flag & fss_read_main_flag_total_e) {
-          if (main->setting.flag & fss_read_main_flag_line_single_e) {
-            fss_read_print_number(&main->program.output, main->setting.contents.array[i].used ? 1 : 0);
-          }
-          else {
-            f_array_length_t total = 0;
-            f_string_range_t range = f_string_range_t_initialize;
-            f_array_length_t j = 0;
-            f_array_length_t k = 0;
-            f_array_length_t l = 0;
-
-            for (; j < main->setting.contents.array[i].used; ++j) {
-
-              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;
-                  }
-                }
-
-                if (main->setting.buffer.string[k] == f_string_eol_s.string[0]) ++total;
-              } // for
-            } // for
-
-            // If there are no newline characters but there is data, then this represents a single line.
-            if (main->setting.contents.array[i].used && !total) {
-              total = 1;
-            }
-
-            fss_read_print_number(&main->program.output, total);
-          }
-        }
         else if (main->callback.print_at) {
           main->callback.print_at(&main->program.output, i, delimits_object, delimits_content);
         }
@@ -274,12 +200,14 @@ extern "C" {
           main->callback.print_object(&main->program.output, at, delimits_object);
         }
 
-        if (main->callback.print_object_end) { // @todo need to handle object end only if content is not being printed or object end is not white space.
+        if (main->callback.print_object_end) {
           main->callback.print_object_end(&main->program.output);
         }
 
         if (!(main->setting.flag & fss_read_main_flag_content_e)) {
-          f_print_dynamic_raw(f_string_eol_s, main->program.output.to);
+          if (!(main->setting.flag & fss_read_main_flag_object_as_line_e)) {
+            f_print_dynamic_raw(f_string_eol_s, main->program.output.to);
+          }
 
           main->setting.state.status = F_success;
 
@@ -358,7 +286,7 @@ extern "C" {
               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;
+                j = main->setting.comments.array[k++].stop + 1;
 
                 if (j > main->setting.range.stop) break;
               }
@@ -384,8 +312,7 @@ extern "C" {
           } // for
 
           // If Content does not end with a newline, it still must be treated as the last line.
-          if (*line == line_original) {
-          //if (main->setting.buffer.string[main->setting.range.stop] != f_string_eol_s.string[0]) {
+          if ((main->setting.flag & fss_read_main_flag_line_single_e) && *line == line_original) {
             ++(*line);
 
             if (*line == main->setting.line) {
@@ -401,6 +328,22 @@ extern "C" {
           }
         } // for
       }
+
+      // @fixme The fll_fss_*_read functions do not have a store of the set closing ranges but should.
+      //        Simulate the ending by printing, but the original range should ideally be used (add new features to accomplish this).
+      if ((main->setting.flag & fss_read_main_flag_object_e) && (main->setting.flag & fss_read_main_flag_content_has_close_e)) {
+        if (*line == main->setting.line) {
+          if (main->callback.print_set_end) {
+            main->callback.print_set_end(&main->program.output);
+          }
+
+          main->setting.state.status = F_success;
+
+          return;
+        }
+
+        ++(*line);
+      }
     }
 
     main->setting.state.status = F_none;
@@ -466,7 +409,7 @@ extern "C" {
 
       memset(names, F_false, sizeof(bool) * main->setting.objects.used);
 
-      if (main->setting.flag & (fss_read_main_flag_trim_e | fss_read_main_flag_trim_object_e)) {
+      if (main->setting.flag & (fss_read_main_flag_trim_e | fss_read_main_flag_trim_object_e | fss_read_main_flag_object_trim_e)) {
         for (i = 0; i < main->setting.objects.used; ++i) {
 
           if (fss_read_signal_check(main)) return;
@@ -511,6 +454,10 @@ extern "C" {
         if (!names[i]) continue;
         if (fss_read_signal_check(main)) return;
 
+        if (main->setting.flag & fss_read_main_flag_at_e) {
+          if (main->setting.depths.array[0].value_at != i) continue;
+        }
+
         if (main->setting.select < main->setting.contents.array[i].used && main->setting.contents.array[i].array[main->setting.select].start <= main->setting.contents.array[i].array[main->setting.select].stop) {
           ++total;
         }
@@ -522,6 +469,10 @@ extern "C" {
         if (!names[i]) continue;
         if (fss_read_signal_check(main)) return;
 
+        if (main->setting.flag & fss_read_main_flag_at_e) {
+          if (main->setting.depths.array[0].value_at != i) continue;
+        }
+
         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;
         }
@@ -559,6 +510,10 @@ extern "C" {
       if (!names[at]) continue;
       if (fss_read_signal_check(main)) return;
 
+      if (main->setting.flag & fss_read_main_flag_at_e) {
+        if (main->setting.depths.array[0].value_at != at) continue;
+      }
+
       if (main->setting.flag & fss_read_main_flag_object_e) {
         ++total;
       }
@@ -592,11 +547,15 @@ extern "C" {
         } // for
 
         // If Content does not end with a newline, it still must be treated as the last line.
-        if (i) {
+        if ((main->setting.flag & fss_read_main_flag_line_single_e) && i) {
           j = main->setting.contents.array[at].array[i - 1].stop;
 
           if (main->setting.buffer.string[j] != f_string_eol_s.string[0]) ++total;
         }
+
+        if ((main->setting.flag & fss_read_main_flag_object_e) && (main->setting.flag & fss_read_main_flag_content_has_close_e)) {
+           ++total;
+        }
       }
     } // for
 
index 05f788248603a02f9a1dd7583c7676b3f91d5a5b..aa291342890325b6cea9c3053c930196e3ed5279 100644 (file)
@@ -17,7 +17,7 @@ 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_object_as_line_e;
+  data.setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e;
 
   data.setting.state.custom = (void *) &data;
   data.setting.standard = fss_read_payload_standard_s;
@@ -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_ignore = &fss_read_print_content_ignore;
+  data.callback.print_content_next = 0;
   data.callback.print_object = &fss_read_print_object;
   data.callback.print_object_end = &fss_read_payload_print_object_end;
-  data.callback.print_set_end = &fss_read_print_set_end;
+  data.callback.print_set_end = &fss_read_print_set_end_no_eol;
 
   f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize;
   data.program.parameters.array = parameters;