From 3555bcc1d99834e79a5c2d72d9c3efbc42c18419 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 30 Jan 2024 23:41:52 -0600 Subject: [PATCH] Bugfix: FSS Basic List and FSS Extended List print comment at the start of the Content. When the Content exists at the start of the Content, the comment character ('#') is printed when it should not be printed. This is a bug where the code initializes the newline_last at the range.start. The code logic then always expects the newline_last to represent an actual new line. This is not necessarily the case for when newline_last is pointing to the initial range.start position. Add a check when processing a comment to ensure that the newline_last is in fact a new line. --- level_1/fl_fss/c/fss/basic_list.c | 9 ++++++++- level_1/fl_fss/c/fss/extended_list.c | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/level_1/fl_fss/c/fss/basic_list.c b/level_1/fl_fss/c/fss/basic_list.c index e91b35e..17d4bee 100644 --- a/level_1/fl_fss/c/fss/basic_list.c +++ b/level_1/fl_fss/c/fss/basic_list.c @@ -231,7 +231,14 @@ extern "C" { } if (graph_first == 0x1 && buffer.string[range->start] == f_fss_comment_s.string[0]) { - start = newline_last + 1; + + // The newline_last is initialized to the range->start, which may not actually be a new line. + if (buffer.string[newline_last] == f_string_eol_s.string[0]) { + start = newline_last + 1; + } + else { + start = newline_last; + } status = f_fss_seek_to_eol(state, buffer, range); if (F_status_is_error(status)) break; diff --git a/level_1/fl_fss/c/fss/extended_list.c b/level_1/fl_fss/c/fss/extended_list.c index f3eb721..34f88b6 100644 --- a/level_1/fl_fss/c/fss/extended_list.c +++ b/level_1/fl_fss/c/fss/extended_list.c @@ -185,7 +185,14 @@ extern "C" { } if (buffer.string[range->start] == f_fss_comment_s.string[0]) { - start = newline_last + 1; + + // The newline_last is initialized to the range->start, which may not actually be a new line. + if (buffer.string[newline_last] == f_string_eol_s.string[0]) { + start = newline_last + 1; + } + else { + start = newline_last; + } status = f_fss_seek_to_eol(state, buffer, range); if (F_status_is_error(status)) break; -- 1.8.3.1