From: Kevin Day Date: Thu, 23 May 2024 01:02:51 +0000 (-0500) Subject: Bugfix: A lone quote inside quotes should not be escaped for FSS Basic and Extended. X-Git-Tag: 0.6.10~1 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=f180e1c1522081c3bd071012b24688f53bedbde4;p=fll 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. --- 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;