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.
}
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;
+ }
f_fss_seek_to_eol(buffer, range, state);
if (F_status_is_error(state->status)) break;
}
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;
+ }
f_fss_seek_to_eol(buffer, range, state);
if (F_status_is_error(state->status)) break;