From d94d5337c44d7b2d6f3ed183e8d2c94b4bdad1f6 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 14 Jul 2022 23:27:43 -0500 Subject: [PATCH] Bugfix: Single quotes are not being properly detected in FSS Extended Read functions. A copy and paste mistake where f_fss_quote_type_double_e when instead f_fss_quote_type_single_e should be used resulted in the quote being set to NULL. Also do some code clean up. --- level_1/fl_fss/c/fss/basic.c | 30 +++++-------------- level_1/fl_fss/c/fss/basic_list.c | 54 +++++++++-------------------------- level_1/fl_fss/c/fss/embedded_list.c | 52 ++++++++++----------------------- level_1/fl_fss/c/fss/extended.c | 19 ++++-------- level_1/fl_fss/c/fss/extended_list.c | 36 ++++++----------------- level_2/fll_fss/c/fss/basic.c | 37 ++++++++++-------------- level_2/fll_fss/c/fss/basic_list.c | 23 +++++---------- level_2/fll_fss/c/fss/embedded_list.c | 49 ++++++++++++------------------- level_2/fll_fss/c/fss/extended.c | 41 ++++++++++++-------------- level_2/fll_fss/c/fss/extended_list.c | 37 ++++++++++-------------- level_2/fll_fss/c/fss/payload.c | 33 ++++++++------------- 11 files changed, 134 insertions(+), 277 deletions(-) diff --git a/level_1/fl_fss/c/fss/basic.c b/level_1/fl_fss/c/fss/basic.c index cbc41e3..d081b3d 100644 --- a/level_1/fl_fss/c/fss/basic.c +++ b/level_1/fl_fss/c/fss/basic.c @@ -23,13 +23,8 @@ extern "C" { return F_fss_found_content_not; } - if (status == F_none_eos) { - return F_data_not_eos; - } - - if (status == F_none_stop) { - return F_data_not_stop; - } + if (status == F_none_eos) return F_data_not_eos; + if (status == F_none_stop) return F_data_not_stop; status = f_string_ranges_increase(state.step_small, found); if (F_status_is_error(status)) return status; @@ -51,16 +46,11 @@ extern "C" { status = f_fss_skip_past_delimit(state, buffer, range); if (F_status_is_error(status)) break; - if (status == F_none_eos || status == F_none_stop) { - return status; - } - + if (status == F_none_eos || status == F_none_stop) return status; if (buffer.string[range->start] == f_fss_basic_close_s.string[0]) break; } // for - if (F_status_is_error(status)) { - return status; - } + if (F_status_is_error(status)) return status; found->array[found->used++].stop = range->start - 1; @@ -93,9 +83,7 @@ extern "C" { destination->string[destination->used++] = f_fss_basic_close_s.string[0]; } - if (range->start > range->stop) { - return F_data_not_stop; - } + if (range->start > range->stop) return F_data_not_stop; return F_data_not_eos; } @@ -111,9 +99,7 @@ extern "C" { if (state.interrupt) { status = state.interrupt((void *) &state, 0); - if (F_status_set_fine(status) == F_interrupt) { - return F_status_set_error(F_interrupt); - } + if (F_status_set_fine(status) == F_interrupt) return F_status_set_error(F_interrupt); } if (content.string[range->start] == f_fss_eol_s.string[0]) { @@ -131,9 +117,7 @@ extern "C" { destination->string[destination->used++] = f_fss_basic_close_s.string[0]; } - if (range->start > range->stop) { - return F_none_stop; - } + if (range->start > range->stop) return F_none_stop; return F_none_eos; } diff --git a/level_1/fl_fss/c/fss/basic_list.c b/level_1/fl_fss/c/fss/basic_list.c index 6bca029..ff31dd3 100644 --- a/level_1/fl_fss/c/fss/basic_list.c +++ b/level_1/fl_fss/c/fss/basic_list.c @@ -307,9 +307,7 @@ extern "C" { destination->string[destination->used++] = f_fss_basic_list_close_s.string[0]; } - if (status == F_none_stop) { - return F_data_not_stop; - } + if (status == F_none_stop) return F_data_not_stop; return F_data_not_eos; } @@ -516,13 +514,8 @@ extern "C" { } } - if (range->start > range->stop) { - return F_none_stop; - } - - if (range->start >= content.used) { - return F_none_eos; - } + if (range->start > range->stop) return F_none_stop; + if (range->start >= content.used) return F_none_eos; return F_none; } @@ -549,13 +542,8 @@ extern "C" { return F_fss_found_object_not; } - if (status == F_none_eos) { - return F_data_not_eos; - } - - if (status == F_none_stop) { - return F_data_not_stop; - } + if (status == F_none_eos) return F_data_not_eos; + if (status == F_none_stop) return F_data_not_stop; // Begin the search. found->start = range->start; @@ -566,13 +554,8 @@ extern "C" { status = f_fss_seek_to_eol(state, buffer, range); if (F_status_is_error(status)) return status; - if (status == F_none_eos) { - return F_data_not_eos; - } - - if (status == F_none_stop) { - return F_data_not_stop; - } + if (status == F_none_eos) return F_data_not_eos; + if (status == F_none_stop) return F_data_not_stop; // Move the start position to after the EOL. ++range->start; @@ -730,6 +713,7 @@ extern "C" { if (F_status_set_fine(status) == F_interrupt) { status = F_status_set_error(F_interrupt); + break; } } @@ -777,13 +761,8 @@ extern "C" { return status; } - if (status == F_none_eos) { - return F_data_not_eos; - } - - if (status == F_none_stop) { - return F_data_not_stop; - } + if (status == F_none_eos) return F_data_not_eos; + if (status == F_none_stop) return F_data_not_stop; // seek to the end of the line when no valid object is found. status = f_fss_seek_to_eol(state, buffer, range); @@ -816,9 +795,7 @@ extern "C" { } } - if (status == F_none_stop) { - return F_data_not_stop; - } + if (status == F_none_stop) return F_data_not_stop; return F_data_not_eos; } @@ -1006,13 +983,8 @@ extern "C" { } } - if (range->start > range->stop) { - return F_none_stop; - } - - if (range->start >= object.used) { - return F_none_eos; - } + if (range->start > range->stop) return F_none_stop; + if (range->start >= object.used) return F_none_eos; return F_none; } diff --git a/level_1/fl_fss/c/fss/embedded_list.c b/level_1/fl_fss/c/fss/embedded_list.c index c2fbbf4..ba0230b 100644 --- a/level_1/fl_fss/c/fss/embedded_list.c +++ b/level_1/fl_fss/c/fss/embedded_list.c @@ -655,21 +655,15 @@ extern "C" { delimits->used = delimits_used; comments->used = comments_used; - if (F_status_is_error(status)) { - return status; - } + if (F_status_is_error(status)) return status; if (range->start > range->stop) { - if (!depth) { - return F_status_set_error(F_end_not_stop); - } + if (!depth) return F_status_set_error(F_end_not_stop); return F_status_set_error(F_end_not_nest_stop); } - if (!depth) { - return F_status_set_error(F_end_not_eos); - } + if (!depth) return F_status_set_error(F_end_not_eos); return F_status_set_error(F_end_not_nest_eos); } @@ -814,6 +808,7 @@ extern "C" { } range->start = start + 1; + continue; } } @@ -854,6 +849,7 @@ extern "C" { destination->string[destination->used++] = content.string[start]; range->start = start + 1; + continue; } } @@ -878,6 +874,7 @@ extern "C" { destination->string[destination->used++] = content.string[start]; range->start = start + 1; + continue; } else if (content.string[range->start] == f_fss_comment_s.string[0] && !has_graph) { @@ -926,6 +923,7 @@ extern "C" { if (F_status_is_error(status)) { destination->used = used_start; + return status; } @@ -941,13 +939,8 @@ extern "C" { destination->string[destination->used++] = f_fss_embedded_list_close_end_s.string[0]; } - if (range->start > range->stop) { - return F_none_stop; - } - - if (range->start >= content.used) { - return F_none_eos; - } + if (range->start > range->stop) return F_none_stop; + if (range->start >= content.used) return F_none_eos; return F_none; } @@ -974,13 +967,8 @@ extern "C" { return F_fss_found_object_not; } - if (status == F_none_eos) { - return F_data_not_eos; - } - - if (status == F_none_stop) { - return F_data_not_stop; - } + if (status == F_none_eos) return F_data_not_eos; + if (status == F_none_stop) return F_data_not_stop; // Return found nothing if this line only contains white space and delimit placeholders. if (buffer.string[range->start] == f_fss_eol_s.string[0]) { @@ -1004,13 +992,8 @@ extern "C" { return status; } - if (status == F_none_eos) { - return F_data_not_eos; - } - - if (status == F_none_stop) { - return F_data_not_stop; - } + if (status == F_none_eos) return F_data_not_eos; + if (status == F_none_stop) return F_data_not_stop; // Move the start position to after the EOL. ++range->start; @@ -1485,13 +1468,8 @@ extern "C" { } } - if (range->start > range->stop) { - return F_none_stop; - } - - if (range->start >= object.used) { - return F_none_eos; - } + if (range->start > range->stop) return F_none_stop; + if (range->start >= object.used) return F_none_eos; return F_none; } diff --git a/level_1/fl_fss/c/fss/extended.c b/level_1/fl_fss/c/fss/extended.c index 32cfb79..48be121 100644 --- a/level_1/fl_fss/c/fss/extended.c +++ b/level_1/fl_fss/c/fss/extended.c @@ -26,13 +26,8 @@ extern "C" { return F_fss_found_content_not; } - if (status == F_none_eos) { - return F_data_not_eos; - } - - if (status == F_none_stop) { - return F_data_not_stop; - } + if (status == F_none_eos) return F_data_not_eos; + if (status == F_none_stop) return F_data_not_stop; const f_array_length_t delimits_used = delimits->used; const f_array_length_t quotes_used = quotes ? quotes->used : 0; @@ -71,7 +66,7 @@ extern "C" { 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) { + else if (quoted == f_fss_quote_type_single_e) { quotes->array[quotes->used] = f_string_ascii_quote_single_s.string[0]; } else { @@ -121,9 +116,7 @@ extern "C" { } // while if (content_found) { - if (content_found == 2) { - return status; - } + if (content_found == 2) return status; return F_fss_found_content; } @@ -160,9 +153,7 @@ extern "C" { destination->string[destination->used++] = f_fss_extended_close_s.string[0]; } - if (status == F_data_not_stop) { - return F_none_stop; - } + if (status == F_data_not_stop) return F_none_stop; return F_none_eos; } diff --git a/level_1/fl_fss/c/fss/extended_list.c b/level_1/fl_fss/c/fss/extended_list.c index 76875d3..9e30b75 100644 --- a/level_1/fl_fss/c/fss/extended_list.c +++ b/level_1/fl_fss/c/fss/extended_list.c @@ -489,13 +489,8 @@ extern "C" { destination->string[destination->used++] = f_fss_extended_list_close_end_s.string[0]; } - if (range->start > range->stop) { - return F_none_stop; - } - - if (range->start >= content.used) { - return F_none_eos; - } + if (range->start > range->stop) return F_none_stop; + if (range->start >= content.used) return F_none_eos; return F_none; } @@ -522,13 +517,8 @@ extern "C" { return F_fss_found_object_not; } - if (status == F_none_eos) { - return F_data_not_eos; - } - - if (status == F_none_stop) { - return F_data_not_stop; - } + if (status == F_none_eos) return F_data_not_eos; + if (status == F_none_stop) return F_data_not_stop; // Return found nothing if this line only contains white space and delimit placeholders. if (buffer.string[range->start] == f_fss_eol_s.string[0]) { @@ -552,13 +542,8 @@ extern "C" { return status; } - if (status == F_none_eos) { - return F_data_not_eos; - } - - if (status == F_none_stop) { - return F_data_not_stop; - } + if (status == F_none_eos) return F_data_not_eos; + if (status == F_none_stop) return F_data_not_stop; // Move the start position to after the EOL. ++range->start; @@ -1033,13 +1018,8 @@ extern "C" { } } - if (range->start > range->stop) { - return F_none_stop; - } - - if (range->start >= object.used) { - return F_none_eos; - } + if (range->start > range->stop) return F_none_stop; + if (range->start >= object.used) return F_none_eos; return F_none; } diff --git a/level_2/fll_fss/c/fss/basic.c b/level_2/fll_fss/c/fss/basic.c index 6bfd86b..ef2a7f5 100644 --- a/level_2/fll_fss/c/fss/basic.c +++ b/level_2/fll_fss/c/fss/basic.c @@ -28,6 +28,8 @@ extern "C" { status = f_string_rangess_increase(state.step_small, contents); if (F_status_is_error(status)) return status; + contents->array[contents->used].used = 0; + if (objects_quoted) { status = f_uint8s_increase(state.step_small, objects_quoted); if (F_status_is_error(status)) return status; @@ -58,19 +60,14 @@ extern "C" { } if (found_data) { - if (range->start >= buffer.used) { - return F_none_eos; - } + if (range->start >= buffer.used) return F_none_eos; return F_none_stop; } - else { - if (range->start >= buffer.used) { - return F_data_not_eos; - } - return F_data_not_stop; - } + if (range->start >= buffer.used) return F_data_not_eos; + + return F_data_not_stop; } if (status == F_fss_found_object) { @@ -104,26 +101,24 @@ extern "C" { return status; } - else if (status == F_data_not_eos || status == F_data_not_stop) { + + if (status == F_data_not_eos || status == F_data_not_stop) { // If at least some valid object was found, then return F_none equivelents. if (objects->used > initial_used) { - if (status == F_data_not_eos) { - return F_none_eos; - } - - if (status == F_data_not_stop) { - return F_none_stop; - } + if (status == F_data_not_eos) return F_none_eos; + if (status == F_data_not_stop) return F_none_stop; } return status; } - else if (status != F_fss_found_object && status != F_fss_found_content && status != F_fss_found_content_not && status != F_fss_found_object_content_not) { + + if (status != F_fss_found_object && status != F_fss_found_content && status != F_fss_found_content_not && status != F_fss_found_object_content_not) { return status; } + // When content is found, the range->start is incremented, if content is found at range->stop, then range->start will be > range.stop. - else if (range->start >= range->stop || range->start >= buffer.used) { + if (range->start >= range->stop || range->start >= buffer.used) { if (status == F_fss_found_object || status == F_fss_found_content || status == F_fss_found_content_not || status == F_fss_found_object_content_not) { ++objects->used; ++contents->used; @@ -133,9 +128,7 @@ extern "C" { } } - if (range->start >= buffer.used) { - return F_none_eos; - } + if (range->start >= buffer.used) return F_none_eos; return F_none_stop; } diff --git a/level_2/fll_fss/c/fss/basic_list.c b/level_2/fll_fss/c/fss/basic_list.c index ef953f6..05871f0 100644 --- a/level_2/fll_fss/c/fss/basic_list.c +++ b/level_2/fll_fss/c/fss/basic_list.c @@ -26,6 +26,8 @@ extern "C" { status = f_string_rangess_increase(state.step_small, contents); if (F_status_is_error(status)) return status; + contents->array[contents->used].used = 0; + do { status = fl_fss_basic_list_object_read(buffer, state, range, &objects->array[objects->used], objects_delimits); if (F_status_is_error(status)) return status; @@ -43,16 +45,12 @@ extern "C" { } if (found_data) { - if (range->start >= buffer.used) { - return F_none_eos; - } + if (range->start >= buffer.used) return F_none_eos; return F_none_stop; } - if (range->start >= buffer.used) { - return F_data_not_eos; - } + if (range->start >= buffer.used) return F_data_not_eos; return F_data_not_stop; } @@ -90,13 +88,8 @@ extern "C" { // If at least some valid object was found, then return F_none equivalents. if (objects->used > initial_used) { - if (status == F_data_not_eos) { - return F_none_eos; - } - - if (status == F_data_not_stop) { - return F_none_stop; - } + if (status == F_data_not_eos) return F_none_eos; + if (status == F_data_not_stop) return F_none_stop; } return status; @@ -114,9 +107,7 @@ extern "C" { ++contents->used; } - if (range->start >= buffer.used) { - return F_none_eos; - } + if (range->start >= buffer.used) return F_none_eos; return F_none_stop; } diff --git a/level_2/fll_fss/c/fss/embedded_list.c b/level_2/fll_fss/c/fss/embedded_list.c index 968527c..3b9e70b 100644 --- a/level_2/fll_fss/c/fss/embedded_list.c +++ b/level_2/fll_fss/c/fss/embedded_list.c @@ -31,6 +31,8 @@ extern "C" { status = f_fss_items_resize(state.step_small, &nest->depth[0]); if (F_status_is_error(status)) return status; + nest->depth[nest->used].used = 0; + status = fl_fss_embedded_list_object_read(buffer, state, range, &nest->depth[0].array[nest->depth[0].used].object, objects_delimits); if (F_status_is_error(status)) return status; @@ -42,19 +44,14 @@ extern "C" { } if (found_data) { - if (range->start >= buffer.used) { - return F_none_eos; - } + if (range->start >= buffer.used) return F_none_eos; return F_none_stop; } - else { - if (range->start >= buffer.used) { - return F_data_not_eos; - } - return F_data_not_stop; - } + if (range->start >= buffer.used) return F_data_not_eos; + + return F_data_not_stop; } if (status == F_fss_found_object) { @@ -76,45 +73,37 @@ extern "C" { if (status == F_none_eos || status == F_none_stop) { return status; } - else if (status == F_data_not_eos || status == F_data_not_stop) { + + if (status == F_data_not_eos || status == F_data_not_stop) { // If at least some valid object was found, then return F_none equivalents. if (nest->depth[0].used > initial_used) { - if (status == F_data_not_eos) { - return F_none_eos; - } - - if (status == F_data_not_stop) { - return F_none_stop; - } + if (status == F_data_not_eos) return F_none_eos; + if (status == F_data_not_stop) return F_none_stop; } return status; } - else if (status == F_end_not_eos || status == F_end_not_stop || status == F_end_not_nest_eos || status == F_end_not_nest_stop) { + + if (status == F_end_not_eos || status == F_end_not_stop || status == F_end_not_nest_eos || status == F_end_not_nest_stop) { // If at least some valid object was found, then return F_none equivalents. if (nest->depth[0].used > initial_used) { - if (status == F_data_not_eos) { - return F_none_eos; - } - - if (status == F_data_not_stop) { - return F_none_stop; - } + if (status == F_data_not_eos) return F_none_eos; + if (status == F_data_not_stop) return F_none_stop; } return status; } - else if (status != F_fss_found_object && status != F_fss_found_content && status != F_fss_found_content_not && status != F_fss_found_object_content_not) { + + if (status != F_fss_found_object && status != F_fss_found_content && status != F_fss_found_content_not && status != F_fss_found_object_content_not) { return status; } - else if (range->start >= range->stop || range->start >= buffer.used) { + + if (range->start >= range->stop || range->start >= buffer.used) { // When content is found, the range->start is incremented, if content is found at range->stop, then range->start will be > range.stop. - if (range->start >= buffer.used) { - return F_none_eos; - } + if (range->start >= buffer.used) return F_none_eos; return F_none_stop; } diff --git a/level_2/fll_fss/c/fss/extended.c b/level_2/fll_fss/c/fss/extended.c index 6b0acd3..dd34548 100644 --- a/level_2/fll_fss/c/fss/extended.c +++ b/level_2/fll_fss/c/fss/extended.c @@ -29,6 +29,8 @@ extern "C" { status = f_string_rangess_increase(state.step_small, contents); if (F_status_is_error(status)) return status; + contents->array[contents->used].used = 0; + if (objects_quoted) { status = f_uint8s_increase(state.step_small, objects_quoted); if (F_status_is_error(status)) return status; @@ -37,6 +39,8 @@ extern "C" { if (contents_quoted) { status = f_uint8ss_increase(state.step_small, contents_quoted); if (F_status_is_error(status)) return status; + + contents_quoted->array[contents_quoted->used].used = 0; } do { @@ -71,16 +75,12 @@ extern "C" { } if (found_data) { - if (range->start >= buffer.used) { - return F_none_eos; - } + if (range->start >= buffer.used) return F_none_eos; return F_none_stop; } - if (range->start >= buffer.used) { - return F_data_not_eos; - } + if (range->start >= buffer.used) return F_data_not_eos; return F_data_not_stop; } @@ -103,7 +103,8 @@ extern "C" { break; } - else if (status == F_fss_found_object_content_not) { + + if (status == F_fss_found_object_content_not) { found_data = F_true; break; @@ -127,25 +128,23 @@ extern "C" { return status; } - else if (status == F_data_not_eos || status == F_data_not_stop || status == F_end_not_group_eos || status == F_end_not_group_stop) { + + if (status == F_data_not_eos || status == F_data_not_stop || status == F_end_not_group_eos || status == F_end_not_group_stop) { // If at least some valid object was found, then return F_none equivelents. if (objects->used > initial_used) { - if (status == F_data_not_eos) { - return F_none_eos; - } - - if (status == F_data_not_stop) { - return F_none_stop; - } + if (status == F_data_not_eos) return F_none_eos; + if (status == F_data_not_stop) return F_none_stop; } return status; } - else if (status != F_fss_found_object && status != F_fss_found_content && status != F_fss_found_content_not && status != F_fss_found_object_content_not && status != F_end_not_group) { + + if (status != F_fss_found_object && status != F_fss_found_content && status != F_fss_found_content_not && status != F_fss_found_object_content_not && status != F_end_not_group) { return status; } - else if (range->start >= range->stop || range->start >= buffer.used) { + + if (range->start >= range->stop || range->start >= buffer.used) { // When content is found, the range->start is incremented, if content is found at range->stop, then range->start will be > range.stop. if (status == F_fss_found_object || status == F_fss_found_content || status == F_fss_found_content_not || status == F_fss_found_object_content_not || status == F_end_not_group) { @@ -162,16 +161,12 @@ extern "C" { } if (range->start >= buffer.used) { - if (status == F_end_not_group) { - return F_end_not_group_eos; - } + if (status == F_end_not_group) return F_end_not_group_eos; return F_none_eos; } - if (status == F_end_not_group) { - return F_end_not_group_stop; - } + if (status == F_end_not_group) return F_end_not_group_stop; return F_none_stop; } diff --git a/level_2/fll_fss/c/fss/extended_list.c b/level_2/fll_fss/c/fss/extended_list.c index 2fabc40..cd810f6 100644 --- a/level_2/fll_fss/c/fss/extended_list.c +++ b/level_2/fll_fss/c/fss/extended_list.c @@ -26,6 +26,8 @@ extern "C" { status = f_string_rangess_increase(state.step_small, contents); if (F_status_is_error(status)) return status; + contents->array[contents->used].used = 0; + do { status = fl_fss_extended_list_object_read(buffer, state, range, &objects->array[objects->used], objects_delimits); if (F_status_is_error(status)) return status; @@ -43,19 +45,14 @@ extern "C" { } if (found_data) { - if (range->start >= buffer.used) { - return F_none_eos; - } + if (range->start >= buffer.used) return F_none_eos; return F_none_stop; } - else { - if (range->start >= buffer.used) { - return F_data_not_eos; - } - return F_data_not_stop; - } + if (range->start >= buffer.used) return F_data_not_eos; + + return F_data_not_stop; } if (status == F_fss_found_object) { @@ -85,25 +82,23 @@ extern "C" { return status; } - else if (status == F_data_not_eos || status == F_data_not_stop) { + + if (status == F_data_not_eos || status == F_data_not_stop) { // If at least some valid object was found, then return F_none equivalents. if (objects->used > initial_used) { - if (status == F_data_not_eos) { - return F_none_eos; - } - - if (status == F_data_not_stop) { - return F_none_stop; - } + if (status == F_data_not_eos) return F_none_eos; + if (status == F_data_not_stop) return F_none_stop; } return status; } - else if (status != F_fss_found_object && status != F_fss_found_content && status != F_fss_found_content_not && status != F_fss_found_object_content_not) { + + if (status != F_fss_found_object && status != F_fss_found_content && status != F_fss_found_content_not && status != F_fss_found_object_content_not) { return status; } - else if (range->start >= range->stop || range->start >= buffer.used) { + + if (range->start >= range->stop || range->start >= buffer.used) { // When content is found, the range->start is incremented, if content is found at range->stop, then range->start will be > range.stop. if (status == F_fss_found_object || status == F_fss_found_content || status == F_fss_found_content_not || status == F_fss_found_object_content_not) { @@ -111,9 +106,7 @@ extern "C" { ++contents->used; } - if (range->start >= buffer.used) { - return F_none_eos; - } + if (range->start >= buffer.used) return F_none_eos; return F_none_stop; } diff --git a/level_2/fll_fss/c/fss/payload.c b/level_2/fll_fss/c/fss/payload.c index 1278be1..6b058ab 100644 --- a/level_2/fll_fss/c/fss/payload.c +++ b/level_2/fll_fss/c/fss/payload.c @@ -26,6 +26,8 @@ extern "C" { status = f_string_rangess_increase(state.step_small, contents); if (F_status_is_error(status)) return status; + contents->array[contents->used].used = 0; + do { status = fl_fss_basic_list_object_read(buffer, state, range, &objects->array[objects->used], objects_delimits); if (F_status_is_error(status)) return status; @@ -35,9 +37,9 @@ extern "C" { if (fl_string_dynamic_partial_compare_string(f_fss_string_payload_s.string, buffer, f_fss_string_payload_s.used, objects->array[objects->used]) == F_equal_to) { status = F_fss_found_object_content_not; } - else { - // Returning without a "payload" is an error. + // Returning without a "payload" is an error. + else { status = F_status_set_error(F_fss_found_object_content_not); } @@ -53,16 +55,12 @@ extern "C" { // Returning without a "payload" is an error. if (found_data) { - if (range->start >= buffer.used) { - return F_status_set_error(F_none_eos); - } + if (range->start >= buffer.used) return F_status_set_error(F_none_eos); return F_status_set_error(F_none_stop); } - if (range->start >= buffer.used) { - return F_status_set_error(F_data_not_eos); - } + if (range->start >= buffer.used) return F_status_set_error(F_data_not_eos); return F_status_set_error(F_data_not_stop); } @@ -107,6 +105,8 @@ extern "C" { status2 = f_string_ranges_increase(state.step_small, &contents->array[contents->used]); if (F_status_is_error(status2)) return status2; + contents->array[contents->used].used = 0; + if (fl_string_dynamic_partial_compare_string(f_fss_string_payload_s.string, buffer, f_fss_string_payload_s.used, objects->array[objects->used]) == F_equal_to) { ++objects->used; @@ -137,13 +137,8 @@ extern "C" { if (objects->used > initial_used) { // Returning without a "payload" is an error. - if (status == F_data_not_eos) { - return F_status_set_error(F_none_eos); - } - - if (status == F_data_not_stop) { - return F_status_set_error(F_none_stop); - } + if (status == F_data_not_eos) return F_status_set_error(F_none_eos); + if (status == F_data_not_stop) return F_status_set_error(F_none_stop); } return F_status_set_error(status); @@ -162,9 +157,7 @@ extern "C" { } // Returning without a "payload" is an error. - if (range->start >= buffer.used) { - return F_status_set_error(F_none_eos); - } + if (range->start >= buffer.used) return F_status_set_error(F_none_eos); return F_status_set_error(F_none_stop); } @@ -206,9 +199,7 @@ extern "C" { if (state.interrupt) { status = state.interrupt((void *) &state, 0); - if (F_status_set_fine(status) == F_interrupt) { - return F_status_set_error(F_interrupt); - } + if (F_status_set_fine(status) == F_interrupt) return F_status_set_error(F_interrupt); } memcpy(destination->string + destination->used + i, content.string + i, sizeof(f_char_t) * F_fss_default_block_size_normal_d); -- 1.8.3.1