From 3cdf124bf7a2b53085836892c72653f2437bf9d3 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 25 May 2022 20:00:40 -0500 Subject: [PATCH] Bugfix: The quotes are always being defined even when there are no quotes in the FSS read functions. Do not force either double or single quote by default. If there are no quotes, then they should be treated as unquoted. --- level_0/f_fss/c/fss/quote.h | 4 +++- level_1/fl_fss/c/fss/extended.c | 35 +++++++++++++++++++++++------------ level_1/fl_fss/c/fss/extended.h | 4 ++++ level_1/fl_fss/c/private-fss.c | 8 +++++++- level_2/fll_fss/c/fss/basic.c | 2 +- level_2/fll_fss/c/fss/basic_list.c | 2 +- level_2/fll_fss/c/fss/extended.c | 5 +++-- level_2/fll_fss/c/fss/extended_list.c | 2 +- level_2/fll_fss/c/fss/payload.c | 2 +- 9 files changed, 44 insertions(+), 20 deletions(-) diff --git a/level_0/f_fss/c/fss/quote.h b/level_0/f_fss/c/fss/quote.h index 1741b0a..3b58b6c 100644 --- a/level_0/f_fss/c/fss/quote.h +++ b/level_0/f_fss/c/fss/quote.h @@ -20,12 +20,14 @@ extern "C" { * Types for FSS quote. * * f_fss_quote_type_*: + * - none: Not a quote. * - single: Quote type is a single quote. * - double: Quote type is a double quote. */ #ifndef _di_f_fss_quote_type_ enum { - f_fss_quote_type_single_e = 1, + f_fss_quote_type_none_e = 0, + f_fss_quote_type_single_e, f_fss_quote_type_double_e, }; #endif // _di_f_fss_quote_type_ diff --git a/level_1/fl_fss/c/fss/extended.c b/level_1/fl_fss/c/fss/extended.c index d7458c1..32cfb79 100644 --- a/level_1/fl_fss/c/fss/extended.c +++ b/level_1/fl_fss/c/fss/extended.c @@ -35,38 +35,49 @@ extern "C" { } const f_array_length_t delimits_used = delimits->used; + const f_array_length_t quotes_used = quotes ? quotes->used : 0; uint8_t content_found = 0; - f_fss_quote_t quoted = 0; + f_fss_quote_t quoted = f_fss_quote_type_none_e; while (range->start <= range->stop && range->start < buffer.used) { f_string_range_t content_partial = f_string_range_t_initialize; - quoted = 0; + quoted = f_fss_quote_type_none_e; status = private_fl_fss_basic_read(buffer, F_false, state, range, &content_partial, "ed, delimits); if (status == F_fss_found_object || status == F_fss_found_object_content_not) { + status_allocate = f_string_ranges_increase(state.step_small, found); - if (found->used + 1 > found->size) { - status_allocate = f_string_ranges_increase(state.step_small, found); - - if (F_status_is_fine(status_allocate) && quotes) { - status_allocate = f_uint8s_resize(found->size, quotes); - } + if (F_status_is_error_not(status_allocate) && quotes) { + status_allocate = f_uint8s_increase(state.step_small, quotes); + } - if (F_status_is_error(status_allocate)) { - delimits->used = delimits_used; + if (F_status_is_error(status_allocate)) { + delimits->used = delimits_used; - return status_allocate; + if (quotes) { + quotes->used = quotes_used; } + + return status_allocate; } found->array[found->used++] = content_partial; if (quotes) { - quotes->array[quotes->used] = quoted == f_fss_quote_type_double_e ? f_string_ascii_quote_double_s.string[0] : f_string_ascii_quote_single_s.string[0]; + if (quoted == f_fss_quote_type_double_e) { + quotes->array[quotes->used] = f_string_ascii_quote_double_s.string[0]; + } + else if (quoted == f_fss_quote_type_double_e) { + quotes->array[quotes->used] = f_string_ascii_quote_single_s.string[0]; + } + else { + quotes->array[quotes->used] = 0; + } + quotes->used = found->used; } diff --git a/level_1/fl_fss/c/fss/extended.h b/level_1/fl_fss/c/fss/extended.h index 6fbfaec..256cf42 100644 --- a/level_1/fl_fss/c/fss/extended.h +++ b/level_1/fl_fss/c/fss/extended.h @@ -211,6 +211,8 @@ extern "C" { * Errors (with error bit) from: f_fss_is_zero_width(). * Errors (with error bit) from: f_fss_skip_past_delimit(). * Errors (with error bit) from: f_fss_skip_past_space(). + * Errors (with error bit) from: f_string_ranges_increase(). + * Errors (with error bit) from: f_uint8s_increase(). * Errors (with error bit) from: f_utf_buffer_increment(). * * @see f_array_lengths_increase() @@ -220,6 +222,8 @@ extern "C" { * @see f_fss_is_zero_width() * @see f_fss_skip_past_delimit() * @see f_fss_skip_past_space() + * @see f_string_ranges_increase() + * @see f_uint8s_increase() * @see f_utf_buffer_increment() * @see fl_fss_basic_object_read() * @see fl_fss_extended_object_read() diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index 1d87675..46a5597 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -181,7 +181,7 @@ extern "C" { f_char_t quote_found = 0; if (quoted) { - *quoted = 0; + *quoted = f_fss_quote_type_none_e; } // Identify where the object begins. @@ -414,6 +414,9 @@ extern "C" { else if (quote_found == f_fss_delimit_quote_double_s.string[0]) { *quoted = f_fss_quote_type_double_e; } + else { + *quoted = f_fss_quote_type_none_e; + } } range->start = first_slash; @@ -571,6 +574,9 @@ extern "C" { else if (quote_found == f_fss_delimit_quote_double_s.string[0]) { *quoted = f_fss_quote_type_double_e; } + else { + *quoted = f_fss_quote_type_none_e; + } } found->stop = range->start - 1; diff --git a/level_2/fll_fss/c/fss/basic.c b/level_2/fll_fss/c/fss/basic.c index 5cd6150..6bfd86b 100644 --- a/level_2/fll_fss/c/fss/basic.c +++ b/level_2/fll_fss/c/fss/basic.c @@ -52,7 +52,7 @@ extern "C" { status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]); if (F_status_is_error(status2)) return status2; - ++contents->used; + contents->array[contents->used++].used = 0; return F_fss_found_object_content_not; } diff --git a/level_2/fll_fss/c/fss/basic_list.c b/level_2/fll_fss/c/fss/basic_list.c index 9646a7d..ef953f6 100644 --- a/level_2/fll_fss/c/fss/basic_list.c +++ b/level_2/fll_fss/c/fss/basic_list.c @@ -37,7 +37,7 @@ extern "C" { status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]); if (F_status_is_error(status2)) return status2; - ++contents->used; + contents->array[contents->used++].used = 0; return F_fss_found_object_content_not; } diff --git a/level_2/fll_fss/c/fss/extended.c b/level_2/fll_fss/c/fss/extended.c index b156c02..6b0acd3 100644 --- a/level_2/fll_fss/c/fss/extended.c +++ b/level_2/fll_fss/c/fss/extended.c @@ -58,13 +58,13 @@ extern "C" { status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]); if (F_status_is_error(status2)) return status2; - ++contents->used; + contents->array[contents->used++].used = 0; if (contents_quoted) { status2 = f_uint8s_increase(state.step_small, &contents_quoted->array[contents_quoted->used]); if (F_status_is_error(status2)) return status2; - ++contents_quoted->used; + contents_quoted->array[contents_quoted->used++].used = 0; } return F_fss_found_object_content_not; @@ -95,6 +95,7 @@ extern "C" { if (F_status_is_error(status2)) return status2; quoted_content = &contents_quoted->array[contents_quoted->used]; + quoted_content->used = 0; } status = fl_fss_extended_content_read(buffer, state, range, &contents->array[contents->used], quoted_content, contents_delimits ? contents_delimits : objects_delimits); diff --git a/level_2/fll_fss/c/fss/extended_list.c b/level_2/fll_fss/c/fss/extended_list.c index 3c289b3..2fabc40 100644 --- a/level_2/fll_fss/c/fss/extended_list.c +++ b/level_2/fll_fss/c/fss/extended_list.c @@ -37,7 +37,7 @@ extern "C" { status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]); if (F_status_is_error(status2)) return status2; - ++contents->used; + contents->array[contents->used++].used = 0; return F_fss_found_object_content_not; } diff --git a/level_2/fll_fss/c/fss/payload.c b/level_2/fll_fss/c/fss/payload.c index a9b2081..1278be1 100644 --- a/level_2/fll_fss/c/fss/payload.c +++ b/level_2/fll_fss/c/fss/payload.c @@ -46,7 +46,7 @@ extern "C" { status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]); if (F_status_is_error(status2)) return status2; - ++contents->used; + contents->array[contents->used++].used = 0; return status; } -- 1.8.3.1