]> Kevux Git Server - fll/commitdiff
Bugfix: Empty Objects are preserving leading white space when in original mode and...
authorKevin Day <Kevin@kevux.org>
Sat, 5 Oct 2024 03:01:27 +0000 (22:01 -0500)
committerKevin Day <Kevin@kevux.org>
Sat, 5 Oct 2024 03:01:27 +0000 (22:01 -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.

Update the runtime tests for all of the FSS Read programs.
Some of the tests were missing or were incorrect such that this bug slipped by without detection.
The FSS Payload Read tests now have the (missing) NULL characters added to them.

16 files changed:
level_3/fss_basic_list_read/c/private-print.c
level_3/fss_basic_list_read/tests/runtime/fss_0002/expect/test-0003-object_space-object_and_content-original.expect
level_3/fss_basic_list_read/tests/runtime/fss_0002/expect/test-0003-object_space-object_and_content-select-0-original.expect
level_3/fss_basic_list_read/tests/runtime/script/generate.sh
level_3/fss_basic_read/tests/runtime/script/generate.sh
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0003-object_space-object_and_content-select-0-original.expect
level_3/fss_embedded_list_read/tests/runtime/script/generate.sh
level_3/fss_extended_list_read/c/private-print.c
level_3/fss_extended_list_read/tests/runtime/fss_0003/expect/test-0003-object_space-object_and_content-original.expect
level_3/fss_extended_list_read/tests/runtime/fss_0003/expect/test-0003-object_space-object_and_content-select-0-original.expect
level_3/fss_extended_list_read/tests/runtime/script/generate.sh
level_3/fss_extended_read/tests/runtime/script/generate.sh
level_3/fss_payload_read/c/private-print.c
level_3/fss_payload_read/tests/runtime/fss_000e/expect/test-0003-object_space-object_and_content-original.expect
level_3/fss_payload_read/tests/runtime/fss_000e/expect/test-0003-object_space-object_and_content-select-0-original.expect
level_3/fss_payload_read/tests/runtime/script/generate.sh

index 12d62d7..1a92f7a 100644 (file)
@@ -72,6 +72,27 @@ extern "C" {
               }
             }
           }
+          else if (data->option & fss_basic_list_read_data_option_content_d) {
+
+            // An empty Object might still have white space.
+            if (at < data->contents.used && data->contents.array[at].used && data->contents.array[at].array[0].start <= data->contents.array[at].array[0].stop) {
+
+              // Skip past the new line and the Object opener.
+              if (data->contents.array[at].array[0].start && data->contents.array[at].array[0].start - 1) {
+                before.stop = data->contents.array[at].array[0].start - 2;
+
+                if (f_fss_basic_list_open_s.used) {
+                  --before.stop;
+                }
+
+                before.start = before.stop;
+
+                while (before.start && data->buffer.string[before.start] != f_string_eol_s.string[0]) --before.start;
+
+                if (data->buffer.string[before.start] == f_string_eol_s.string[0]) ++before.start;
+              }
+            }
+          }
         }
 
         if (before.start <= before.stop) {
index 2c4d6c5..ad5dc86 100644 (file)
@@ -242,6 +242,11 @@ generate_operate_0002() {
   fss_basic_list_read +n -ocs 5 ${file_source} > ${test_current}object_and_content-select-5.expect &&
   fss_basic_list_read +n -ocs 6 ${file_source} > ${test_current}object_and_content-select-6.expect &&
   fss_basic_list_read +n -ocs 100 ${file_source} > ${test_current}object_and_content-select-100.expect &&
+  fss_basic_list_read +n -ocsO 0 ${file_source} > ${test_current}object_and_content-select-0-original.expect &&
+  fss_basic_list_read +n -ocsO 1 ${file_source} > ${test_current}object_and_content-select-1-original.expect &&
+  fss_basic_list_read +n -ocsO 5 ${file_source} > ${test_current}object_and_content-select-5-original.expect &&
+  fss_basic_list_read +n -ocsO 6 ${file_source} > ${test_current}object_and_content-select-6-original.expect &&
+  fss_basic_list_read +n -ocsO 100 ${file_source} > ${test_current}object_and_content-select-100-original.expect &&
   fss_basic_list_read +n -ocC ${file_source} > ${test_current}object_and_content-columns.expect &&
   fss_basic_list_read +n -ocCe ${file_source} > ${test_current}object_and_content-columns-empty.expect &&
   fss_basic_list_read +n -oca 0 ${file_source} > ${test_current}object_and_content-at-0.expect &&
@@ -487,6 +492,11 @@ generate_operate_test_standard() {
   fss_basic_list_read +n -ocs 5 ${file_source} > ${test_current}object_and_content-select-5.expect &&
   fss_basic_list_read +n -ocs 6 ${file_source} > ${test_current}object_and_content-select-6.expect &&
   fss_basic_list_read +n -ocs 100 ${file_source} > ${test_current}object_and_content-select-100.expect &&
+  fss_basic_list_read +n -ocsO 0 ${file_source} > ${test_current}object_and_content-select-0-original.expect &&
+  fss_basic_list_read +n -ocsO 1 ${file_source} > ${test_current}object_and_content-select-1-original.expect &&
+  fss_basic_list_read +n -ocsO 5 ${file_source} > ${test_current}object_and_content-select-5-original.expect &&
+  fss_basic_list_read +n -ocsO 6 ${file_source} > ${test_current}object_and_content-select-6-original.expect &&
+  fss_basic_list_read +n -ocsO 100 ${file_source} > ${test_current}object_and_content-select-100-original.expect &&
   fss_basic_list_read +n -ocC ${file_source} > ${test_current}object_and_content-columns.expect &&
   fss_basic_list_read +n -ocCe ${file_source} > ${test_current}object_and_content-columns-empty.expect &&
   fss_basic_list_read +n -oca 0 ${file_source} > ${test_current}object_and_content-at-0.expect &&
index 5000067..3574e7e 100644 (file)
@@ -242,6 +242,11 @@ generate_operate_0000() {
   fss_basic_read +n -ocs 5 ${file_source} > ${test_current}object_and_content-select-5.expect &&
   fss_basic_read +n -ocs 6 ${file_source} > ${test_current}object_and_content-select-6.expect &&
   fss_basic_read +n -ocs 100 ${file_source} > ${test_current}object_and_content-select-100.expect &&
+  fss_basic_read +n -ocsO 0 ${file_source} > ${test_current}object_and_content-select-0-original.expect &&
+  fss_basic_read +n -ocsO 1 ${file_source} > ${test_current}object_and_content-select-1-original.expect &&
+  fss_basic_read +n -ocsO 5 ${file_source} > ${test_current}object_and_content-select-5-original.expect &&
+  fss_basic_read +n -ocsO 6 ${file_source} > ${test_current}object_and_content-select-6-original.expect &&
+  fss_basic_read +n -ocsO 100 ${file_source} > ${test_current}object_and_content-select-100-original.expect &&
   fss_basic_read +n -ocC ${file_source} > ${test_current}object_and_content-columns.expect &&
   fss_basic_read +n -ocCe ${file_source} > ${test_current}object_and_content-columns-empty.expect &&
   fss_basic_read +n -oca 0 ${file_source} > ${test_current}object_and_content-at-0.expect &&
@@ -487,6 +492,11 @@ generate_operate_test_standard() {
   fss_basic_read +n -ocs 5 ${file_source} > ${test_current}object_and_content-select-5.expect &&
   fss_basic_read +n -ocs 6 ${file_source} > ${test_current}object_and_content-select-6.expect &&
   fss_basic_read +n -ocs 100 ${file_source} > ${test_current}object_and_content-select-100.expect &&
+  fss_basic_read +n -ocsO 0 ${file_source} > ${test_current}object_and_content-select-0-original.expect &&
+  fss_basic_read +n -ocsO 1 ${file_source} > ${test_current}object_and_content-select-1-original.expect &&
+  fss_basic_read +n -ocsO 5 ${file_source} > ${test_current}object_and_content-select-5-original.expect &&
+  fss_basic_read +n -ocsO 6 ${file_source} > ${test_current}object_and_content-select-6-original.expect &&
+  fss_basic_read +n -ocsO 100 ${file_source} > ${test_current}object_and_content-select-100-original.expect &&
   fss_basic_read +n -ocC ${file_source} > ${test_current}object_and_content-columns.expect &&
   fss_basic_read +n -ocCe ${file_source} > ${test_current}object_and_content-columns-empty.expect &&
   fss_basic_read +n -oca 0 ${file_source} > ${test_current}object_and_content-at-0.expect &&
index 90a9d23..b8b0705 100644 (file)
@@ -242,6 +242,11 @@ generate_operate_0008() {
   fss_embedded_list_read +n -ocs 5 ${file_source} > ${test_current}object_and_content-select-5.expect &&
   fss_embedded_list_read +n -ocs 6 ${file_source} > ${test_current}object_and_content-select-6.expect &&
   fss_embedded_list_read +n -ocs 100 ${file_source} > ${test_current}object_and_content-select-100.expect &&
+  fss_embedded_list_read +n -ocsO 0 ${file_source} > ${test_current}object_and_content-select-0-original.expect &&
+  fss_embedded_list_read +n -ocsO 1 ${file_source} > ${test_current}object_and_content-select-1-original.expect &&
+  fss_embedded_list_read +n -ocsO 5 ${file_source} > ${test_current}object_and_content-select-5-original.expect &&
+  fss_embedded_list_read +n -ocsO 6 ${file_source} > ${test_current}object_and_content-select-6-original.expect &&
+  fss_embedded_list_read +n -ocsO 100 ${file_source} > ${test_current}object_and_content-select-100-original.expect &&
   fss_embedded_list_read +n -ocC ${file_source} > ${test_current}object_and_content-columns.expect &&
   fss_embedded_list_read +n -ocCe ${file_source} > ${test_current}object_and_content-columns-empty.expect &&
   fss_embedded_list_read +n -oca 0 ${file_source} > ${test_current}object_and_content-at-0.expect &&
@@ -487,6 +492,11 @@ generate_operate_test_standard() {
   fss_embedded_list_read +n -ocs 5 ${file_source} > ${test_current}object_and_content-select-5.expect &&
   fss_embedded_list_read +n -ocs 6 ${file_source} > ${test_current}object_and_content-select-6.expect &&
   fss_embedded_list_read +n -ocs 100 ${file_source} > ${test_current}object_and_content-select-100.expect &&
+  fss_embedded_list_read +n -ocsO 0 ${file_source} > ${test_current}object_and_content-select-0-original.expect &&
+  fss_embedded_list_read +n -ocsO 1 ${file_source} > ${test_current}object_and_content-select-1-original.expect &&
+  fss_embedded_list_read +n -ocsO 5 ${file_source} > ${test_current}object_and_content-select-5-original.expect &&
+  fss_embedded_list_read +n -ocsO 6 ${file_source} > ${test_current}object_and_content-select-6-original.expect &&
+  fss_embedded_list_read +n -ocsO 100 ${file_source} > ${test_current}object_and_content-select-100-original.expect &&
   fss_embedded_list_read +n -ocC ${file_source} > ${test_current}object_and_content-columns.expect &&
   fss_embedded_list_read +n -ocCe ${file_source} > ${test_current}object_and_content-columns-empty.expect &&
   fss_embedded_list_read +n -oca 0 ${file_source} > ${test_current}object_and_content-at-0.expect &&
index d2bb5f2..778fe2c 100644 (file)
@@ -108,11 +108,13 @@ extern "C" {
 
     if (at >= data->objects.used) return;
 
-    if ((data->option & fss_extended_list_read_data_option_content_d) && (!(data->option & fss_extended_list_read_data_option_original_d) || (data->option & fss_extended_list_read_data_option_trim_d))) {
-      const f_string_range_t before = fss_extended_list_read_print_at_determine_begin(main, data, at);
+    if ((data->option & fss_extended_list_read_data_option_content_d)) {
+      if (!(data->option & fss_extended_list_read_data_option_original_d) || (data->option & fss_extended_list_read_data_option_trim_d)) {
+        const f_string_range_t before = fss_extended_list_read_print_at_determine_begin(main, data, at);
 
-      if (before.start <= before.stop) {
-        f_print_except_dynamic_partial(data->buffer, before, delimits_object, main->output.to.stream);
+        if (before.start <= before.stop) {
+          f_print_except_dynamic_partial(data->buffer, before, delimits_object, main->output.to.stream);
+        }
       }
     }
 
@@ -148,6 +150,27 @@ extern "C" {
               }
             }
           }
+          else if (data->option & fss_extended_list_read_data_option_content_d) {
+
+            // An empty Object might still have white space.
+            if (at < data->contents.used && data->contents.array[at].used && data->contents.array[at].array[0].start <= data->contents.array[at].array[0].stop) {
+
+              // Skip past the new line and the Object opener.
+              if (data->contents.array[at].array[0].start && data->contents.array[at].array[0].start - 1) {
+                before.stop = data->contents.array[at].array[0].start - 2;
+
+                if (f_fss_extended_list_open_s.used) {
+                  --before.stop;
+                }
+
+                before.start = before.stop;
+
+                while (before.start && data->buffer.string[before.start] != f_string_eol_s.string[0]) --before.start;
+
+                if (data->buffer.string[before.start] == f_string_eol_s.string[0]) ++before.start;
+              }
+            }
+          }
         }
 
         if (before.start <= before.stop) {
index 9b7d079..99f66df 100644 (file)
@@ -242,6 +242,11 @@ generate_operate_0003() {
   fss_extended_list_read +n -ocs 5 ${file_source} > ${test_current}object_and_content-select-5.expect &&
   fss_extended_list_read +n -ocs 6 ${file_source} > ${test_current}object_and_content-select-6.expect &&
   fss_extended_list_read +n -ocs 100 ${file_source} > ${test_current}object_and_content-select-100.expect &&
+  fss_extended_list_read +n -ocsO 0 ${file_source} > ${test_current}object_and_content-select-0-original.expect &&
+  fss_extended_list_read +n -ocsO 1 ${file_source} > ${test_current}object_and_content-select-1-original.expect &&
+  fss_extended_list_read +n -ocsO 5 ${file_source} > ${test_current}object_and_content-select-5-original.expect &&
+  fss_extended_list_read +n -ocsO 6 ${file_source} > ${test_current}object_and_content-select-6-original.expect &&
+  fss_extended_list_read +n -ocsO 100 ${file_source} > ${test_current}object_and_content-select-100-original.expect &&
   fss_extended_list_read +n -ocC ${file_source} > ${test_current}object_and_content-columns.expect &&
   fss_extended_list_read +n -ocCe ${file_source} > ${test_current}object_and_content-columns-empty.expect &&
   fss_extended_list_read +n -oca 0 ${file_source} > ${test_current}object_and_content-at-0.expect &&
@@ -487,6 +492,11 @@ generate_operate_test_standard() {
   fss_extended_list_read +n -ocs 5 ${file_source} > ${test_current}object_and_content-select-5.expect &&
   fss_extended_list_read +n -ocs 6 ${file_source} > ${test_current}object_and_content-select-6.expect &&
   fss_extended_list_read +n -ocs 100 ${file_source} > ${test_current}object_and_content-select-100.expect &&
+  fss_extended_list_read +n -ocsO 0 ${file_source} > ${test_current}object_and_content-select-0-original.expect &&
+  fss_extended_list_read +n -ocsO 1 ${file_source} > ${test_current}object_and_content-select-1-original.expect &&
+  fss_extended_list_read +n -ocsO 5 ${file_source} > ${test_current}object_and_content-select-5-original.expect &&
+  fss_extended_list_read +n -ocsO 6 ${file_source} > ${test_current}object_and_content-select-6-original.expect &&
+  fss_extended_list_read +n -ocsO 100 ${file_source} > ${test_current}object_and_content-select-100-original.expect &&
   fss_extended_list_read +n -ocC ${file_source} > ${test_current}object_and_content-columns.expect &&
   fss_extended_list_read +n -ocCe ${file_source} > ${test_current}object_and_content-columns-empty.expect &&
   fss_extended_list_read +n -oca 0 ${file_source} > ${test_current}object_and_content-at-0.expect &&
index 44d70fd..5cf6b18 100644 (file)
@@ -242,6 +242,11 @@ generate_operate_0001() {
   fss_extended_read +n -ocs 5 ${file_source} > ${test_current}object_and_content-select-5.expect &&
   fss_extended_read +n -ocs 6 ${file_source} > ${test_current}object_and_content-select-6.expect &&
   fss_extended_read +n -ocs 100 ${file_source} > ${test_current}object_and_content-select-100.expect &&
+  fss_extended_read +n -ocsO 0 ${file_source} > ${test_current}object_and_content-select-0-original.expect &&
+  fss_extended_read +n -ocsO 1 ${file_source} > ${test_current}object_and_content-select-1-original.expect &&
+  fss_extended_read +n -ocsO 5 ${file_source} > ${test_current}object_and_content-select-5-original.expect &&
+  fss_extended_read +n -ocsO 6 ${file_source} > ${test_current}object_and_content-select-6-original.expect &&
+  fss_extended_read +n -ocsO 100 ${file_source} > ${test_current}object_and_content-select-100-original.expect &&
   fss_extended_read +n -ocC ${file_source} > ${test_current}object_and_content-columns.expect &&
   fss_extended_read +n -ocCe ${file_source} > ${test_current}object_and_content-columns-empty.expect &&
   fss_extended_read +n -oca 0 ${file_source} > ${test_current}object_and_content-at-0.expect &&
@@ -487,6 +492,11 @@ generate_operate_test_standard() {
   fss_extended_read +n -ocs 5 ${file_source} > ${test_current}object_and_content-select-5.expect &&
   fss_extended_read +n -ocs 6 ${file_source} > ${test_current}object_and_content-select-6.expect &&
   fss_extended_read +n -ocs 100 ${file_source} > ${test_current}object_and_content-select-100.expect &&
+  fss_extended_read +n -ocsO 0 ${file_source} > ${test_current}object_and_content-select-0-original.expect &&
+  fss_extended_read +n -ocsO 1 ${file_source} > ${test_current}object_and_content-select-1-original.expect &&
+  fss_extended_read +n -ocsO 5 ${file_source} > ${test_current}object_and_content-select-5-original.expect &&
+  fss_extended_read +n -ocsO 6 ${file_source} > ${test_current}object_and_content-select-6-original.expect &&
+  fss_extended_read +n -ocsO 100 ${file_source} > ${test_current}object_and_content-select-100-original.expect &&
   fss_extended_read +n -ocC ${file_source} > ${test_current}object_and_content-columns.expect &&
   fss_extended_read +n -ocCe ${file_source} > ${test_current}object_and_content-columns-empty.expect &&
   fss_extended_read +n -oca 0 ${file_source} > ${test_current}object_and_content-at-0.expect &&
index 9b5fa1c..ec420f0 100644 (file)
@@ -232,6 +232,27 @@ extern "C" {
               }
             }
           }
+          else if (data->option & fss_payload_read_data_option_content_d) {
+
+            // An empty Object might still have white space.
+            if (at < data->contents.used && data->contents.array[at].used && data->contents.array[at].array[0].start <= data->contents.array[at].array[0].stop) {
+
+              // Skip past the new line and the Object opener.
+              if (data->contents.array[at].array[0].start && data->contents.array[at].array[0].start - 1) {
+                before.stop = data->contents.array[at].array[0].start - 2;
+
+                if (f_fss_payload_list_open_s.used) {
+                  --before.stop;
+                }
+
+                before.start = before.stop;
+
+                while (before.start && data->buffer.string[before.start] != f_string_eol_s.string[0]) --before.start;
+
+                if (data->buffer.string[before.start] == f_string_eol_s.string[0]) ++before.start;
+              }
+            }
+          }
         }
 
         if (before.start <= before.stop) {
index a611209..bd8dd2b 100644 (file)
Binary files a/level_3/fss_payload_read/tests/runtime/fss_000e/expect/test-0003-object_space-object_and_content-original.expect and b/level_3/fss_payload_read/tests/runtime/fss_000e/expect/test-0003-object_space-object_and_content-original.expect differ
index 1f0fb4c..bd8dd2b 100644 (file)
Binary files a/level_3/fss_payload_read/tests/runtime/fss_000e/expect/test-0003-object_space-object_and_content-select-0-original.expect and b/level_3/fss_payload_read/tests/runtime/fss_000e/expect/test-0003-object_space-object_and_content-select-0-original.expect differ
index 96efc03..e62f883 100644 (file)
@@ -487,6 +487,12 @@ generate_operate_test_standard() {
   fss_payload_read +n -ocs 5 ${file_source} > ${test_current}object_and_content-select-5.expect &&
   fss_payload_read +n -ocs 6 ${file_source} > ${test_current}object_and_content-select-6.expect &&
   fss_payload_read +n -ocs 100 ${file_source} > ${test_current}object_and_content-select-100.expect &&
+  fss_payload_read +n -ocsO 0 ${file_source} > ${test_current}object_and_content-select-0-original.expect &&
+  fss_payload_read +n -ocsO 1 ${file_source} > ${test_current}object_and_content-select-1-original.expect &&
+  fss_payload_read +n -ocsO 5 ${file_source} > ${test_current}object_and_content-select-5-original.expect &&
+  fss_payload_read +n -ocsO 6 ${file_source} > ${test_current}object_and_content-select-6-original.expect &&
+  fss_payload_read +n -ocsO 100 ${file_source} > ${test_current}object_and_content-select-100-original.expect &&
+
   fss_payload_read +n -ocC ${file_source} > ${test_current}object_and_content-columns.expect &&
   fss_payload_read +n -ocCe ${file_source} > ${test_current}object_and_content-columns-empty.expect &&
   fss_payload_read +n -oca 0 ${file_source} > ${test_current}object_and_content-at-0.expect &&