]> 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 12d62d71e069b4df5dbef1c327fa400e812f56ed..1a92f7a3eb978655559f88b8edf35bb813847ebf 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 2c4d6c5c118c24f7b35d72e0fefc8d0653edd0aa..ad5dc860970136f42f3e0414c018742481ce020d 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 5000067a7c41217e8ea44a2be1227c122dc825bc..3574e7e1ad8c5e7ec6aac2905dd951780cbef515 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 90a9d23cdc545c44b21e0cf0f0bd644a363f735b..b8b0705f043fc9a018d69e38c615ee6bc0e882b7 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 d2bb5f2eea2719c34150c33b5dee63854147cba3..778fe2c3198c1e550b932ce27b3b496e6106422c 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 c4dc9a074d87930e6525d96d6ee8cd8678422767..e89385de1fa5312e2bc75905d010aa72d3e27e1f 100644 (file)
@@ -12,7 +12,7 @@
     \# Valid Object {
       with content.
     }
-{
+   {
 Has no Object name (only white space) and is oddly spaced.
    }
 мир      {
index 9b7d07923e63308a4703bb8412dff93cc564228b..99f66dfdb1f453f1bb6ea807180ad0aa0f62339f 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 44d70fde712c0a31cbb08ca188425f3613602864..5cf6b18d90c9eeb74d5dee45285840225fde5f04 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 9b5fa1c3e0f542cc28fa07265a88bb7a3ea7e594..ec420f019529865506abbd412a4d3dd9b55cd7de 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 a611209e6c1444155dbdd134b4ece592f846700a..bd8dd2b4c45588681f097f72d8a37c2583f4aa22 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 1f0fb4cdd2c57f3718b4e4457203f14f0afd00bd..bd8dd2b4c45588681f097f72d8a37c2583f4aa22 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 96efc0333c064d67680555f714b79b0cd0041b62..e62f883b7f5483200117059115eba3a382786658 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 &&