From 51a17ea967d871285514fe53a82342ae8ed637e0 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 14 May 2022 08:40:31 -0500 Subject: [PATCH] Bugfix: The FSS object write functions don't handle all newlines. There are several cases where the newline character in the object is not being properly treated as an error and returned. --- level_1/fl_fss/c/fss/basic_list.c | 6 ++++++ level_1/fl_fss/c/fss/embedded_list.c | 14 +++++++++++++- level_1/fl_fss/c/fss/extended_list.c | 14 +++++++++++++- level_1/fl_fss/c/private-fss.c | 31 ++++++++++++++++++++++++++++++- 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/level_1/fl_fss/c/fss/basic_list.c b/level_1/fl_fss/c/fss/basic_list.c index 9c8f202..a7ad6ac 100644 --- a/level_1/fl_fss/c/fss/basic_list.c +++ b/level_1/fl_fss/c/fss/basic_list.c @@ -636,6 +636,12 @@ extern "C" { if (F_status_is_error(status)) break; if (status == F_true) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); + + break; + } + width = macro_f_utf_byte_width(object.string[range->start]); status = f_string_dynamic_increase_by(width, destination); diff --git a/level_1/fl_fss/c/fss/embedded_list.c b/level_1/fl_fss/c/fss/embedded_list.c index 91b9721..cd99156 100644 --- a/level_1/fl_fss/c/fss/embedded_list.c +++ b/level_1/fl_fss/c/fss/embedded_list.c @@ -1054,6 +1054,12 @@ extern "C" { if (F_status_is_error(status)) break; if (status == F_true) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); + + break; + } + width = macro_f_utf_byte_width(object.string[range->start]); status = f_string_dynamic_increase_by(width, destination); @@ -1140,7 +1146,13 @@ extern "C" { status = f_fss_is_space(state, object, *range); if (F_status_is_error(status)) break; - ends_on_space = status == F_true; + if (ends_on_space = (status == F_true)) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); + + break; + } + } width = macro_f_utf_byte_width(object.string[range->start]); diff --git a/level_1/fl_fss/c/fss/extended_list.c b/level_1/fl_fss/c/fss/extended_list.c index 200752e..8da1241 100644 --- a/level_1/fl_fss/c/fss/extended_list.c +++ b/level_1/fl_fss/c/fss/extended_list.c @@ -601,6 +601,12 @@ extern "C" { if (F_status_is_error(status)) break; if (status == F_true) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); + + break; + } + width = macro_f_utf_byte_width(object.string[range->start]); status = f_string_dynamic_increase_by(width, destination); @@ -687,7 +693,13 @@ extern "C" { status = f_fss_is_space(state, object, *range); if (F_status_is_error(status)) break; - ends_on_space = status == F_true; + if (ends_on_space = (status == F_true)) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); + + break; + } + } width = macro_f_utf_byte_width(object.string[range->start]); diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index 976bc41..81d85e0 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -856,6 +856,10 @@ extern "C" { return F_data_not_stop; } + if (status == F_none_eol) { + return F_status_set_error(F_none_eol); + } + // Ensure that there is room for the potential start and stop quotes, a potential delimit at start, and the potential object open character. status = f_string_dynamic_increase_by(5, destination); if (F_status_is_error(status)) return status; @@ -985,6 +989,12 @@ extern "C" { if (F_status_is_error(status)) break; if (status == F_true) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); + + break; + } + quoted_is = F_true; status = f_string_dynamic_increase_by(item_total, destination); @@ -1047,6 +1057,12 @@ extern "C" { if (F_status_is_error(status)) break; if (status == F_true) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); + + break; + } + quoted_is = F_true; } @@ -1107,6 +1123,12 @@ extern "C" { if (F_status_is_error(status)) break; if (status == F_true) { + if (object.string[range->start] == f_fss_eol_s.string[0]) { + status = F_status_set_error(F_none_eol); + + break; + } + if (item_first != input_start) { status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; @@ -1205,7 +1227,14 @@ extern "C" { return status; } - if (status == F_false) { + if (status == F_true) { + if (object.string[i] == f_fss_eol_s.string[0]) { + destination->used = used_start; + + return F_status_set_error(F_none_eol); + } + } + else { destination->string[used_start + 1] = f_fss_delimit_placeholder_s.string[0]; } } -- 1.8.3.1