From 238c94dff31a97adbda8f31e002b4b242ea5d56c Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Fri, 4 Oct 2024 21:54:05 -0500 Subject: [PATCH] Update: FSS Read tests, clean up syntax, and add additional range check. 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 | 24 ++++++++++----------- ...object_space-object_and_content-original.expect | Bin 272 -> 275 bytes ...ace-object_and_content-select-0-original.expect | Bin 266 -> 272 bytes 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/level_3/fss_read/c/main/print/data.c b/level_3/fss_read/c/main/print/data.c index e529707..c74e924 100644 --- a/level_3/fss_read/c/main/print/data.c +++ b/level_3/fss_read/c/main/print/data.c @@ -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; } } } diff --git a/level_3/fss_read/tests/runtime/fss_000e/expect/test-0003-object_space-object_and_content-original.expect b/level_3/fss_read/tests/runtime/fss_000e/expect/test-0003-object_space-object_and_content-original.expect index a611209e6c1444155dbdd134b4ece592f846700a..bd8dd2b4c45588681f097f72d8a37c2583f4aa22 100644 GIT binary patch delta 13 UcmbQhG?{5a53_=T!o;2y03414NB{r; delta 9 QcmbQtG=XVC&&2)~01=e~=l}o! diff --git a/level_3/fss_read/tests/runtime/fss_000e/expect/test-0003-object_space-object_and_content-select-0-original.expect b/level_3/fss_read/tests/runtime/fss_000e/expect/test-0003-object_space-object_and_content-select-0-original.expect index 1f0fb4cdd2c57f3718b4e4457203f14f0afd00bd..a611209e6c1444155dbdd134b4ece592f846700a 100644 GIT binary patch delta 24 ecmeBTn!q&SzaRsb5d#C4F$0iD$