]> Kevux Git Server - fll/commitdiff
Bugfix: Empty Objects are preserving leading white space when in original mode.
authorKevin Day <Kevin@kevux.org>
Thu, 3 Oct 2024 05:12:22 +0000 (00:12 -0500)
committerKevin Day <Kevin@kevux.org>
Thu, 3 Oct 2024 05:12:22 +0000 (00:12 -0500)
This (unfortunately) adds more logic to processing the case when `--original` is used and the Object is empty.

This makes me wonder if I have to implement the opener range.
I was not happy about adding the `close` for memory and space reasons.
Adding this would introduce more inefficiencies.

I may end up having to add support for processing different types of structures if I want to support the simple Object and Content without the `open` and `close` positions as well as with those positions.
The focus in this commit is only on fixing the printing and does not introduce any of the behavior that I described here.

level_3/fss_read/c/main/print/data.c
level_3/fss_read/tests/runtime/fss_0002/expect/test-0003-object_space-object_and_content-original.expect
level_3/fss_read/tests/runtime/fss_0002/expect/test-0003-object_space-object_and_content-select-0-original.expect
level_3/fss_read/tests/runtime/fss_0003/expect/test-0003-object_space-object_and_content-original.expect
level_3/fss_read/tests/runtime/fss_0003/expect/test-0003-object_space-object_and_content-select-0-original.expect
level_3/fss_read/tests/runtime/fss_0008/expect/test-0003-object_space-object_and_content-select-0-original.expect

index 16b042bdd2782974b43146fd2d6b79d268799730..e529707f9725cc21dbcf56fea3ce617863ebc63c 100644 (file)
@@ -254,17 +254,19 @@ extern "C" {
     if (at >= main->setting.objects.used) return F_output_not;
 
     // The current FSS standards that have a only spaces to the left of a close so simply print all to the left.
-    if ((main->setting.feature & fss_read_feature_flag_object_align_d) && (main->setting.flag & fss_read_main_flag_content_d) && (!(main->setting.flag & fss_read_main_flag_original_d) || (main->setting.flag & fss_read_main_flag_trim_d))) {
-      if (at < main->setting.closes.used && main->setting.closes.array[at].start <= main->setting.closes.array[at].stop) {
-        f_range_t before = f_range_t_initialize;
-
-        if (main->setting.closes.array[at].start) {
-          before.start = main->setting.closes.array[at].start;
-          before.stop = main->setting.closes.array[at].stop ? main->setting.closes.array[at].stop - 1 : 0;
-        }
+    if ((main->setting.feature & fss_read_feature_flag_object_align_d) && (main->setting.flag & fss_read_main_flag_content_d)) {
+      if (!(main->setting.flag & fss_read_main_flag_original_d) || (main->setting.flag & fss_read_main_flag_trim_d)) {
+        if (at < main->setting.closes.used && main->setting.closes.array[at].start <= main->setting.closes.array[at].stop) {
+          f_range_t before = f_range_t_initialize;
+
+          if (main->setting.closes.array[at].start) {
+            before.start = main->setting.closes.array[at].start;
+            before.stop = main->setting.closes.array[at].stop ? main->setting.closes.array[at].stop - 1 : 0;
+          }
 
-        if (before.start <= before.stop) {
-          fll_print_except_dynamic_partial(main->setting.buffer, before, delimits, main->program.output.to);
+          if (before.start <= before.stop) {
+            fll_print_except_dynamic_partial(main->setting.buffer, before, delimits, main->program.output.to);
+          }
         }
       }
     }
@@ -315,6 +317,29 @@ extern "C" {
                 }
               }
             }
+            else if (main->setting.flag & fss_read_main_flag_content_d) {
+
+              // An empty Object might still have white space.
+              if (main->setting.contents.array[at].used && main->setting.contents.array[at].array[0].start <= main->setting.contents.array[at].array[0].stop) {
+
+                // Skip past the new line and the object opener.
+                if (main->setting.feature & fss_read_feature_flag_object_as_line_d) {
+                  if (main->setting.contents.array[at].array[0].start && main->setting.contents.array[at].array[0].start - 1) {
+                    before.stop = main->setting.contents.array[at].array[0].start - 2;
+
+                    if (main->setting.open_object.used) {
+                      --before.stop;
+                    }
+
+                    before.start = before.stop;
+
+                    while (before.start && main->setting.buffer.string[before.start] != f_string_eol_s.string[0]) --before.start;
+
+                    if (main->setting.buffer.string[before.start] == f_string_eol_s.string[0]) ++before.start;
+                  }
+                }
+              }
+            }
 
             if (before.start <= before.stop) {
               fll_print_except_dynamic_partial(main->setting.buffer, before, delimits, main->program.output.to);
index 4276d1b4f6591c9b45b4f6b0c6c2e5a79dbd2734..46a6b63d05c85e92dad82f81133b7986446db465 100644 (file)
@@ -11,7 +11,7 @@
     \# Valid Object :
       with content.
 
-:
+   :
 Has no Object name (only white space) and is oddly spaced.
 
 мир      :
index c4dc9a074d87930e6525d96d6ee8cd8678422767..e89385de1fa5312e2bc75905d010aa72d3e27e1f 100644 (file)
@@ -12,7 +12,7 @@
     \# Valid Object {
       with content.
     }
-{
+   {
 Has no Object name (only white space) and is oddly spaced.
    }
 мир      {
index c4dc9a074d87930e6525d96d6ee8cd8678422767..e89385de1fa5312e2bc75905d010aa72d3e27e1f 100644 (file)
@@ -12,7 +12,7 @@
     \# Valid Object {
       with content.
     }
-{
+   {
 Has no Object name (only white space) and is oddly spaced.
    }
 мир      {