From f180e1c1522081c3bd071012b24688f53bedbde4 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 22 May 2024 20:02:51 -0500 Subject: [PATCH] Bugfix: A lone quote inside quotes should not be escaped for FSS Basic and Extended. The command and results: # fss_extended_write -oc "'" '"' -oc '"' "'" -oc ' `' "\` " -oc "'" "'" | fss_extended_read -oc ' \" \" ' ` ` ' ' Is incorrect. The correct results should be: # fss_extended_write -oc "'" '"' -oc '"' "'" -oc ' `' "\` " -oc "'" "'" | fss_extended_read -oc ' " " ' ` ` ' ' The problem is that in the case where the quote is already within a quoted string then it should not be escaped. This only applies for the quote that would not be a valid closing quote. --- level_1/fl_fss/c/private-fss.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index 9739cbd..afff42f 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -972,19 +972,25 @@ extern "C" { else if (object.string[range->start] == quote_char) { item_first = range->start++; - // The very first quote, must be escaped, when quoting is disabled. + status = f_fss_skip_past_delimit(state, object, range); + if (F_status_is_error(status)) return status; + + // The very first quote, must be escaped, but only when quoting is disabled or first quote is followed by white space. if (item_first == input_start) { - status = f_string_dynamic_increase(state.step_large, destination); - if (F_status_is_error(status)) break; + if (quote_is) { + status = f_fss_is_space(state, object, *range); + if (F_status_is_error(status)) break; + } - destination->string[used_start + 1] = f_fss_delimit_slash_s.string[0]; - } + if (!quote_is || quote_is && status == F_true) { + status = f_string_dynamic_increase(state.step_large, destination); + if (F_status_is_error(status)) break; - status = f_fss_skip_past_delimit(state, object, range); - if (F_status_is_error(status)) return status; + destination->string[used_start + 1] = f_fss_delimit_slash_s.string[0]; + } + } if (range->start > range->stop || range->start >= object.used) { - status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; -- 1.8.3.1