]> Kevux Git Server - fll/commitdiff
Update: FSS Read tests, clean up syntax, and add additional range check.
authorKevin Day <Kevin@kevux.org>
Sat, 5 Oct 2024 02:54:05 +0000 (21:54 -0500)
committerKevin Day <Kevin@kevux.org>
Sat, 5 Oct 2024 02:54:05 +0000 (21:54 -0500)
Make sure the `at` is within range in the `contents` array.

Add missing NULL characters in the "payload" section of the runtime test expect files.

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

index e529707f9725cc21dbcf56fea3ce617863ebc63c..c74e92421614fddb5547d50bd3648aeb4c09a9d3 100644 (file)
@@ -317,26 +317,24 @@ extern "C" {
                 }
               }
             }
-            else if (main->setting.flag & fss_read_main_flag_content_d) {
+            else if ((main->setting.flag & fss_read_main_flag_content_d) && (main->setting.feature & fss_read_feature_flag_object_as_line_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) {
+              if (at < main->setting.contents.used && 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;
+                // Skip past the new line and the Object opener.
+                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;
-                    }
+                  if (main->setting.open_object.used) {
+                    --before.stop;
+                  }
 
-                    before.start = before.stop;
+                  before.start = before.stop;
 
-                    while (before.start && main->setting.buffer.string[before.start] != f_string_eol_s.string[0]) --before.start;
+                  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 (main->setting.buffer.string[before.start] == f_string_eol_s.string[0]) ++before.start;
                 }
               }
             }
index a611209e6c1444155dbdd134b4ece592f846700a..bd8dd2b4c45588681f097f72d8a37c2583f4aa22 100644 (file)
Binary files a/level_3/fss_read/tests/runtime/fss_000e/expect/test-0003-object_space-object_and_content-original.expect and b/level_3/fss_read/tests/runtime/fss_000e/expect/test-0003-object_space-object_and_content-original.expect differ
index 1f0fb4cdd2c57f3718b4e4457203f14f0afd00bd..a611209e6c1444155dbdd134b4ece592f846700a 100644 (file)
Binary files a/level_3/fss_read/tests/runtime/fss_000e/expect/test-0003-object_space-object_and_content-select-0-original.expect and b/level_3/fss_read/tests/runtime/fss_000e/expect/test-0003-object_space-object_and_content-select-0-original.expect differ