From 009e002cffc7d167a767c30c9346c26d14f88c7c Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 10 Dec 2022 21:57:21 -0600 Subject: [PATCH] Feature: Add support for "trim" in "complete" enumeration for FSS writing. There is now a "none" equivalent that performs a "trim". --- level_0/f_fss/c/fss/common.h | 2 ++ level_1/fl_fss/c/fss/basic.c | 18 ++++++++++-------- level_1/fl_fss/c/fss/basic_list.c | 22 ++++++++++++---------- level_1/fl_fss/c/fss/embedded_list.c | 28 +++++++++++++++------------- level_1/fl_fss/c/fss/extended.c | 18 ++++++++++-------- level_1/fl_fss/c/fss/extended_list.c | 28 +++++++++++++++------------- 6 files changed, 64 insertions(+), 52 deletions(-) diff --git a/level_0/f_fss/c/fss/common.h b/level_0/f_fss/c/fss/common.h index e96f749..7211392 100644 --- a/level_0/f_fss/c/fss/common.h +++ b/level_0/f_fss/c/fss/common.h @@ -188,6 +188,7 @@ extern "C" { * - next: Complete as if this is a piece of a set (such as FSS-0001, adding a separating space). * - partial: Complete, but do not add terminating EOL, where applicable. * - partial_trim: Complete, but do not add terminating EOL and remove any leading or trailing whitespace, where applicable. + * - trim: Only print the Object or Content, trimmed where applicable, without any closing or terminating characters. */ #ifndef _di_f_fss_complete_e_ enum { @@ -198,6 +199,7 @@ extern "C" { f_fss_complete_next_e, f_fss_complete_partial_e, f_fss_complete_partial_trim_e, + f_fss_complete_trim_e, }; // enum #endif // _di_f_fss_complete_e_ diff --git a/level_1/fl_fss/c/fss/basic.c b/level_1/fl_fss/c/fss/basic.c index 2765896..527e404 100644 --- a/level_1/fl_fss/c/fss/basic.c +++ b/level_1/fl_fss/c/fss/basic.c @@ -189,11 +189,11 @@ extern "C" { destination->string[destination->used++] = quote ? quote : f_fss_quote_double_s.string[0]; } - if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { + if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) { if (status == F_none_stop || status == F_none_eos || status == F_data_not_stop || status == F_data_not_eos) { f_status_t status2 = F_none; - if (complete == f_fss_complete_full_trim_e) { + if (complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) { status2 = private_fl_fss_basic_write_object_trim(quote ? quote : f_fss_quote_double_s.string[0], destination_used, state, destination); if (F_status_is_error(status2)) { @@ -203,15 +203,17 @@ extern "C" { } } - status2 = f_string_dynamic_increase(state.step_large, destination); + if (complete != f_fss_complete_trim_e) { + status2 = f_string_dynamic_increase(state.step_large, destination); - if (F_status_is_error(status2)) { - destination->used = destination_used; + if (F_status_is_error(status2)) { + destination->used = destination_used; - return status2; - } + return status2; + } - destination->string[destination->used++] = f_fss_basic_open_s.string[0]; + destination->string[destination->used++] = f_fss_basic_open_s.string[0]; + } } } diff --git a/level_1/fl_fss/c/fss/basic_list.c b/level_1/fl_fss/c/fss/basic_list.c index 89c4228..a1f40b1 100644 --- a/level_1/fl_fss/c/fss/basic_list.c +++ b/level_1/fl_fss/c/fss/basic_list.c @@ -968,8 +968,8 @@ extern "C" { return status; } - if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - if (complete == f_fss_complete_full_trim_e) { + if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) { + if (complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) { status = private_fl_fss_basic_list_write_object_trim(destination_used, state, destination); if (F_status_is_error(status)) { @@ -979,18 +979,20 @@ extern "C" { } } - status = f_string_dynamic_increase(state.step_small + 2, destination); + if (complete != f_fss_complete_trim_e) { + status = f_string_dynamic_increase(state.step_small + 2, destination); - if (F_status_is_error(status)) { - destination->used = destination_used; + if (F_status_is_error(status)) { + destination->used = destination_used; - return status; - } + return status; + } - destination->string[destination->used++] = f_fss_basic_list_open_s.string[0]; + destination->string[destination->used++] = f_fss_basic_list_open_s.string[0]; - if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - destination->string[destination->used++] = f_fss_basic_list_open_end_s.string[0]; + if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { + destination->string[destination->used++] = f_fss_basic_list_open_end_s.string[0]; + } } } diff --git a/level_1/fl_fss/c/fss/embedded_list.c b/level_1/fl_fss/c/fss/embedded_list.c index cae6261..eb69e16 100644 --- a/level_1/fl_fss/c/fss/embedded_list.c +++ b/level_1/fl_fss/c/fss/embedded_list.c @@ -1442,8 +1442,8 @@ extern "C" { return status; } - if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - if (complete == f_fss_complete_full_trim_e) { + if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) { + if (complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) { status = private_fl_fss_basic_list_write_object_trim(destination_used, state, destination); if (F_status_is_error(status)) { @@ -1456,22 +1456,24 @@ extern "C" { ends_on_space = F_true; } - status = f_string_dynamic_increase_by(state.step_small + 3, destination); + if (complete != f_fss_complete_trim_e) { + status = f_string_dynamic_increase_by(state.step_small + 3, destination); - if (F_status_is_error(status)) { - destination->used = destination_used; + if (F_status_is_error(status)) { + destination->used = destination_used; - return status; - } + return status; + } - if (!ends_on_space) { - destination->string[destination->used++] = f_fss_space_s.string[0]; - } + if (!ends_on_space) { + destination->string[destination->used++] = f_fss_space_s.string[0]; + } - destination->string[destination->used++] = f_fss_embedded_list_open_s.string[0]; + destination->string[destination->used++] = f_fss_embedded_list_open_s.string[0]; - if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - destination->string[destination->used++] = f_fss_embedded_list_open_end_s.string[0]; + if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { + destination->string[destination->used++] = f_fss_embedded_list_open_end_s.string[0]; + } } } diff --git a/level_1/fl_fss/c/fss/extended.c b/level_1/fl_fss/c/fss/extended.c index 4888206..77dc91f 100644 --- a/level_1/fl_fss/c/fss/extended.c +++ b/level_1/fl_fss/c/fss/extended.c @@ -243,11 +243,11 @@ f_status_t fl_fss_extended_object_write(const f_string_static_t object, const ui destination->string[destination->used++] = quote ? quote : f_fss_quote_double_s.string[0]; } - if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { + if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) { if (status == F_none_stop || status == F_none_eos || status == F_data_not_stop || status == F_data_not_eos) { f_status_t status2 = F_none; - if (complete == f_fss_complete_full_trim_e) { + if (complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) { status2 = private_fl_fss_basic_write_object_trim(quote ? quote : f_fss_quote_double_s.string[0], destination_used, state, destination); if (F_status_is_error(status2)) { @@ -257,15 +257,17 @@ f_status_t fl_fss_extended_object_write(const f_string_static_t object, const ui } } - status2 = f_string_dynamic_increase(state.step_large, destination); + if (complete != f_fss_complete_trim_e) { + status2 = f_string_dynamic_increase(state.step_large, destination); - if (F_status_is_error(status2)) { - destination->used = destination_used; + if (F_status_is_error(status2)) { + destination->used = destination_used; - return status2; - } + return status2; + } - destination->string[destination->used++] = f_fss_extended_open_s.string[0]; + destination->string[destination->used++] = f_fss_extended_open_s.string[0]; + } } } diff --git a/level_1/fl_fss/c/fss/extended_list.c b/level_1/fl_fss/c/fss/extended_list.c index 653dd05..32eead3 100644 --- a/level_1/fl_fss/c/fss/extended_list.c +++ b/level_1/fl_fss/c/fss/extended_list.c @@ -1003,8 +1003,8 @@ extern "C" { return status; } - if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - if (complete == f_fss_complete_full_trim_e) { + if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) { + if (complete == f_fss_complete_full_trim_e || complete == f_fss_complete_trim_e) { status = private_fl_fss_basic_list_write_object_trim(destination_used, state, destination); if (F_status_is_error(status)) { @@ -1017,22 +1017,24 @@ extern "C" { ends_on_space = F_true; } - status = f_string_dynamic_increase_by(state.step_small + 3, destination); + if (complete != f_fss_complete_trim_e) { + status = f_string_dynamic_increase_by(state.step_small + 3, destination); - if (F_status_is_error(status)) { - destination->used = destination_used; + if (F_status_is_error(status)) { + destination->used = destination_used; - return status; - } + return status; + } - if (!ends_on_space) { - destination->string[destination->used++] = f_fss_space_s.string[0]; - } + if (!ends_on_space) { + destination->string[destination->used++] = f_fss_space_s.string[0]; + } - destination->string[destination->used++] = f_fss_extended_list_open_s.string[0]; + destination->string[destination->used++] = f_fss_extended_list_open_s.string[0]; - if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { - destination->string[destination->used++] = f_fss_extended_list_open_end_s.string[0]; + if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { + destination->string[destination->used++] = f_fss_extended_list_open_end_s.string[0]; + } } } -- 1.8.3.1