From: Kevin Day Date: Wed, 31 May 2023 03:00:02 +0000 (-0500) Subject: Bugfix: Quotes in FSS read functions are not being properly handled. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=e793c5a5b9f3c3c636e55e0b52df1a11590827cb;p=fll Bugfix: Quotes in FSS read functions are not being properly handled. At some point in time the intended behavior changed from using the literal quote character to an enumeration representing the quote character on FSS read calls. This transition is incomplete and broken. Finish the transition, passing the enumeration representation rather than the literal character. Remove an unnecessary initialization on the quote because the private function being called also initializes the variable. Relocate the f_uint8s_increase() call to be after changing the error status to ensure that the quotes array is properly incremented. Update the documentation comments to better clarify this behavior in regards to the enumeration. --- diff --git a/level_1/fl_fss/c/fss/basic.h b/level_1/fl_fss/c/fss/basic.h index f1a45ab..05a7274 100644 --- a/level_1/fl_fss/c/fss/basic.h +++ b/level_1/fl_fss/c/fss/basic.h @@ -151,7 +151,7 @@ extern "C" { * @param found * A location where a valid object was found. * @param quote - * This will store the quote character to use (if value is 0, then there is not quote). + * This will store the quote type representing the character to use (from the f_fss_quote_type_*_e). * Set pointer address to 0 to not use. * @param delimits * A delimits array representing where delimits exist within the buffer. diff --git a/level_1/fl_fss/c/fss/extended.c b/level_1/fl_fss/c/fss/extended.c index c8dd351..684e1a2 100644 --- a/level_1/fl_fss/c/fss/extended.c +++ b/level_1/fl_fss/c/fss/extended.c @@ -52,22 +52,20 @@ extern "C" { f_string_range_t content_partial = f_string_range_t_initialize; - quote = 0; - private_fl_fss_basic_read(buffer, F_false, range, &content_partial, "e, delimits, state); if (state->status == F_fss_found_object || F_status_set_fine(state->status) == F_fss_found_object_content_not) { status = f_string_ranges_increase(state->step_small, found); - if (F_status_is_error_not(status) && quotes) { - status = f_uint8s_increase(state->step_small, quotes); - } - // The private function sets the error bit on unterminated quoted Object. if (state->status == F_status_set_error(F_fss_found_object_content_not)) { state->status = F_fss_found_object_content_not; } + if (F_status_is_error_not(status) && quotes) { + status = f_uint8s_increase(state->step_small, quotes); + } + if (F_status_is_error(status)) { delimits->used = delimits_used; state->status = status; @@ -82,20 +80,7 @@ extern "C" { found->array[found->used++] = content_partial; if (quotes) { - if (quote == f_fss_quote_type_double_e) { - quotes->array[quotes->used] = f_fss_quote_double_s.string[0]; - } - else if (quote == f_fss_quote_type_single_e) { - quotes->array[quotes->used] = f_fss_quote_single_s.string[0]; - } - else if (quote == f_fss_quote_type_backtick_e) { - quotes->array[quotes->used] = f_fss_quote_backtick_s.string[0]; - } - else { - quotes->array[quotes->used] = 0; - } - - quotes->used = found->used; + quotes->array[quotes->used++] = quote; } content_found = 1; @@ -133,6 +118,10 @@ extern "C" { else if (F_status_is_error(state->status)) { delimits->used = delimits_used; + if (quotes) { + quotes->used = quotes_used; + } + return; } } // while diff --git a/level_1/fl_fss/c/fss/extended.h b/level_1/fl_fss/c/fss/extended.h index d974c48..e0c6f98 100644 --- a/level_1/fl_fss/c/fss/extended.h +++ b/level_1/fl_fss/c/fss/extended.h @@ -44,7 +44,7 @@ extern "C" { * @param found * A set of all locations where a valid content was found. * @param quotes - * An array of quotes designating whether or not content is quoted and what quote is in use. + * This will store the quote type representing the character to use (from the f_fss_quote_type_*_e). * Set pointer address to 0 to not use. * @param delimits * A delimits array representing where delimits exist within the buffer. @@ -178,7 +178,7 @@ extern "C" { * @param found * A location where a valid object was found. * @param quote - * This will store the quote character to use (if value is 0, then there is not quote). + * This will store the quote type representing the character to use (from the f_fss_quote_type_*_e). * Set pointer address to 0 to not use. * @param delimits * A delimits array representing where delimits exist within the buffer. diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index 728272a..0eadde7 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -180,7 +180,7 @@ extern "C" { f_char_t quote_found = 0; if (quote) { - *quote = 0; + *quote = f_fss_quote_type_none_e; } // Identify where the object begins. @@ -365,11 +365,17 @@ extern "C" { if (state->status == F_true) { if (quote) { - if (quote_found == f_fss_quote_single_s.string[0] || quote_found == f_fss_quote_double_s.string[0] || quote_found == f_fss_quote_backtick_s.string[0]) { - *quote = quote_found; + if (quote_found == f_fss_quote_double_s.string[0]) { + *quote = f_fss_quote_type_double_e; + } + else if (quote_found == f_fss_quote_single_s.string[0]) { + *quote = f_fss_quote_type_single_e; + } + else if (quote_found == f_fss_quote_backtick_s.string[0]) { + *quote = f_fss_quote_type_backtick_e; } else { - *quote = 0; + *quote = f_fss_quote_type_none_e; } } @@ -532,8 +538,14 @@ extern "C" { if (state->status == F_true) { if (quote) { - if (quote_found == f_fss_quote_single_s.string[0] || quote_found == f_fss_quote_double_s.string[0] || quote_found == f_fss_quote_backtick_s.string[0]) { - *quote = quote_found; + if (quote_found == f_fss_quote_double_s.string[0]) { + *quote = f_fss_quote_type_double_e; + } + else if (quote_found == f_fss_quote_single_s.string[0]) { + *quote = f_fss_quote_type_single_e; + } + else if (quote_found == f_fss_quote_backtick_s.string[0]) { + *quote = f_fss_quote_type_backtick_e; } else { *quote = f_fss_quote_type_none_e; diff --git a/level_1/fl_fss/c/private-fss.h b/level_1/fl_fss/c/private-fss.h index b880dc7..0cc4990 100644 --- a/level_1/fl_fss/c/private-fss.h +++ b/level_1/fl_fss/c/private-fss.h @@ -103,7 +103,7 @@ extern "C" { * @param found * A set of all locations where a valid object was found. * @param quote - * This will store the quote character to use (if value is 0, then there is not quote). + * This will store the quote type representing the character to use (from the f_fss_quote_type_*_e). * Set pointer address to 0 to not use. * @param delimits * An array of delimits detected during processing.