From 206fa18a134e0fb311a637e011acc21148de7dbe Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 26 Aug 2024 23:22:59 -0500 Subject: [PATCH] Progress: Continue working on getting FSS Embedded Read working and tweak allocations. The extended list needs a separate parameter and make the `line_start` match the `newline_last` at the start of the function. Record `newline_last` and `line_start` whenever possible once a new line is found. Use the variable `comment_start` to make the purpose more clear. The `closes` array should be initialized before calling `fl_fss_extended_list_content_read()`. Make sure the `closes` array value is reset when the Content is not found. Make sure the `closes` array used length is incremented. The FSS Read functions now handle printing the close strings. I am now considering adding an `open` variable. Doing this would then merit moving most things into the `f_fss_item_t`. Tweak some of the allocations in other FSS functions for allocations that need explicit sizes (`f_memory_array_increase_by()`). --- level_1/fl_fss/c/fss/basic.c | 2 +- level_1/fl_fss/c/fss/basic_list.c | 6 ++-- level_1/fl_fss/c/fss/embedded_list.c | 14 ++++---- level_1/fl_fss/c/fss/extended.c | 6 ++-- level_1/fl_fss/c/fss/extended_list.c | 43 ++++++++++++----------- level_2/fll_fss/c/fss/embedded_list.c | 2 +- level_2/fll_fss/c/fss/extended_list.c | 12 ++++++- level_3/fss_read/c/embedded_list/print.c | 10 ++++-- level_3/fss_read/c/embedded_list/print.h | 4 ++- level_3/fss_read/c/embedded_list/process_normal.c | 7 +++- level_3/fss_read/c/extended_list/print.c | 10 ++++-- level_3/fss_read/c/extended_list/print.h | 4 ++- level_3/fss_read/c/main/common/type.h | 6 ++-- level_3/fss_read/c/main/print/data.c | 10 +++--- level_3/fss_read/c/main/print/data.h | 8 +++-- level_3/fss_read/c/main/process_normal.c | 12 +++---- 16 files changed, 95 insertions(+), 61 deletions(-) diff --git a/level_1/fl_fss/c/fss/basic.c b/level_1/fl_fss/c/fss/basic.c index 5d6e287..bac8890 100644 --- a/level_1/fl_fss/c/fss/basic.c +++ b/level_1/fl_fss/c/fss/basic.c @@ -209,7 +209,7 @@ extern "C" { // Objects cannot be empty, so write a quote empty string. { - const f_status_t status = f_memory_array_increase_by(state->step_small + 2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + const f_status_t status = f_memory_array_increase_by(2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(status)) { destination->used = destination_used; diff --git a/level_1/fl_fss/c/fss/basic_list.c b/level_1/fl_fss/c/fss/basic_list.c index 24b00fc..5c0fcf8 100644 --- a/level_1/fl_fss/c/fss/basic_list.c +++ b/level_1/fl_fss/c/fss/basic_list.c @@ -340,7 +340,7 @@ extern "C" { } // Ensure that there is room for a slash delimit and possibly the end of content character. - state->status = f_memory_array_increase_by(state->step_small + 3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + state->status = f_memory_array_increase_by(3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) return; const f_number_unsigned_t destination_used = destination->used; @@ -451,7 +451,7 @@ extern "C" { if (content.string[range->start] == f_fss_eol_s.string[0] || range->start >= content.used || range->start > range->stop) { // Increase by slash and basic list open and possible newline. - state->status = f_memory_array_increase_by(state->step_small + 3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + state->status = f_memory_array_increase_by(3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; destination->string[destination->used++] = f_fss_slash_s.string[0]; @@ -893,7 +893,7 @@ extern "C" { if (state->status == F_okay_stop || state->status == F_okay_eos) { if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { { - const f_status_t status = f_memory_array_increase_by(state->step_small + 2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + const f_status_t status = f_memory_array_increase_by(2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(status)) { state->status = status; diff --git a/level_1/fl_fss/c/fss/embedded_list.c b/level_1/fl_fss/c/fss/embedded_list.c index e001f6e..668f1d6 100644 --- a/level_1/fl_fss/c/fss/embedded_list.c +++ b/level_1/fl_fss/c/fss/embedded_list.c @@ -776,7 +776,7 @@ extern "C" { if (range->start > range->stop || range->start >= content.used) { if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { - const f_status_t status = f_memory_array_increase_by(state->step_small + 2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + const f_status_t status = f_memory_array_increase_by(2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(status)) { state->status = status; @@ -888,7 +888,7 @@ extern "C" { } // Increase by character at "start" and possible newline. - state->status = f_memory_array_increase_by(state->step_small + 2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + state->status = f_memory_array_increase_by(2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; destination->string[destination->used++] = content.string[start]; @@ -949,7 +949,7 @@ extern "C" { } // Increase by slash and extended list open and possible newline. - state->status = f_memory_array_increase_by(state->step_small + 3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + state->status = f_memory_array_increase_by(3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; destination->string[destination->used++] = f_fss_slash_s.string[0]; @@ -1022,7 +1022,7 @@ extern "C" { } if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { - state->status = f_memory_array_increase_by(state->step_small + 3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + state->status = f_memory_array_increase_by(3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) return; if (!ends_on_eol) { @@ -1427,7 +1427,7 @@ extern "C" { if (state->status == F_data_not_stop || state->status == F_data_not_eos) { if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { { - const f_status_t status = f_memory_array_increase_by(state->step_small + 2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + const f_status_t status = f_memory_array_increase_by(2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(status)) { state->status = status; @@ -1447,7 +1447,7 @@ extern "C" { } // Ensure that there is room for a slash delimit, the object open character, and the end of line character. - state->status = f_memory_array_increase_by(state->step_small + 4, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + state->status = f_memory_array_increase_by(4, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) return; const f_number_unsigned_t destination_used = destination->used; @@ -1625,7 +1625,7 @@ extern "C" { } if (complete != f_fss_complete_trim_e) { - state->status = f_memory_array_increase_by(state->step_small + 3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + state->status = f_memory_array_increase_by(3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) { destination->used = destination_used; diff --git a/level_1/fl_fss/c/fss/extended.c b/level_1/fl_fss/c/fss/extended.c index 69d20dc..e723471 100644 --- a/level_1/fl_fss/c/fss/extended.c +++ b/level_1/fl_fss/c/fss/extended.c @@ -174,7 +174,7 @@ extern "C" { if (state->status == F_data_not_stop || state->status == F_data_not_eos) { // Content that is empty must be represented by a quote empty string. - status = f_memory_array_increase_by(state->step_small + 4, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + status = f_memory_array_increase_by(4, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(status)) { state->status = status; @@ -198,7 +198,7 @@ extern "C" { } // Ensure that there is room, including the slash delimit and possibly the end of content characters. - status = f_memory_array_increase_by(state->step_small + 2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + status = f_memory_array_increase_by(2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(status)) { state->status = status; @@ -272,7 +272,7 @@ void fl_fss_extended_object_write(const f_string_static_t object, const uint8_t if (state->status == F_data_not_stop || state->status == F_data_not_eos) { // Objects cannot be empty, so write a quote empty string. - status = f_memory_array_increase_by(state->step_small + 2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + status = f_memory_array_increase_by(2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(status)) { destination->used = destination_used; diff --git a/level_1/fl_fss/c/fss/extended_list.c b/level_1/fl_fss/c/fss/extended_list.c index 58fb27d..4ae9540 100644 --- a/level_1/fl_fss/c/fss/extended_list.c +++ b/level_1/fl_fss/c/fss/extended_list.c @@ -45,10 +45,11 @@ extern "C" { found->array[found->used].start = range->start; + f_number_unsigned_t line_start = range->start; f_number_unsigned_t newline_last = range->start; f_number_unsigned_t slash_first = 0; f_number_unsigned_t slash_count = 0; - f_number_unsigned_t line_start = 0; + f_number_unsigned_t comment_start = 0; // Identify where the content ends. while (range->start <= range->stop && range->start < buffer.used) { @@ -117,6 +118,9 @@ extern "C" { if (range->start > range->stop || range->start >= buffer.used) break; if (buffer.string[range->start] == f_fss_eol_s.string[0]) { + newline_last = range->start; + line_start = range->start + 1; + state->status = f_memory_array_increase(state->step_small, sizeof(f_number_unsigned_t), (void **) &delimits->array, &delimits->used, &delimits->size); if (F_status_is_error(state->status)) break; @@ -161,7 +165,6 @@ extern "C" { } // while if (F_status_is_error(state->status)) break; - if (range->start > range->stop || range->start >= buffer.used) break; // Found a valid content close, set stop point to last newline. @@ -193,26 +196,24 @@ extern "C" { if (buffer.string[range->start] == f_fss_comment_s.string[0]) { // The newline_last is initialized to the range->start, which may not actually be a new line. - line_start = (buffer.string[newline_last] == f_string_eol_s.string[0]) ? newline_last + 1 : newline_last; + comment_start = (buffer.string[newline_last] == f_string_eol_s.string[0]) ? newline_last + 1 : newline_last; f_fss_seek_to_eol(buffer, range, state); if (F_status_is_error(state->status)) break; - state->status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &comments->array, &comments->used, &comments->size); - if (F_status_is_error(state->status)) break; - if (range->start > range->stop || range->start >= buffer.used) { --range->start; } else { newline_last = range->start; + line_start = newline_last + 1; } - comments->array[comments->used].start = line_start; - comments->array[comments->used++].stop = range->start++; + state->status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &comments->array, &comments->used, &comments->size); + if (F_status_is_error(state->status)) break; - // The newline_last is initialized to the range->start, which may not actually be a new line. - line_start = (buffer.string[newline_last] == f_string_eol_s.string[0]) ? newline_last + 1 : newline_last; + comments->array[comments->used].start = comment_start; + comments->array[comments->used++].stop = range->start++; continue; } @@ -259,7 +260,7 @@ extern "C" { if (range->start > range->stop || range->start >= content.used) { if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { { - const f_status_t status = f_memory_array_increase_by(state->step_small + 2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + const f_status_t status = f_memory_array_increase_by(2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(status)) { state->status = status; @@ -276,7 +277,7 @@ extern "C" { } // Ensure that there is room for a slash delimit and possibly the end of content characters. - state->status = f_memory_array_increase_by(state->step_small + 4, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + state->status = f_memory_array_increase_by(4, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) return; const f_number_unsigned_t destination_used = destination->used; @@ -303,7 +304,7 @@ extern "C" { slash_count = 1; if (do_prepend) { - state->status = f_memory_array_increase_by(state->step_small + prepend->used, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + state->status = f_memory_array_increase_by(prepend->used, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; state->status = f_string_dynamic_append(*prepend, destination); @@ -354,7 +355,7 @@ extern "C" { // Do nothing. } else if (content.string[range->start] == f_fss_eol_s.string[0] || range->start >= content.used || range->start > range->stop) { - state->status = f_memory_array_increase_by(state->step_small + 2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + state->status = f_memory_array_increase_by(2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; destination->string[destination->used++] = f_fss_slash_s.string[0]; @@ -373,7 +374,7 @@ extern "C" { } // Increase by character at "start" and possible newline. - state->status = f_memory_array_increase_by(state->step_small + 2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + state->status = f_memory_array_increase_by(2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; destination->string[destination->used++] = content.string[start]; @@ -434,7 +435,7 @@ extern "C" { } // Increase by slash and extended list close. - state->status = f_memory_array_increase_by(state->step_small + 2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + state->status = f_memory_array_increase_by(2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) break; destination->string[destination->used++] = f_fss_slash_s.string[0]; @@ -507,7 +508,7 @@ extern "C" { } if (complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_end_e) { - state->status = f_memory_array_increase_by(state->step_small + 3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + state->status = f_memory_array_increase_by(3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) { destination->used = destination_used; @@ -622,7 +623,7 @@ extern "C" { f_number_unsigned_t slash_first = 0; f_number_unsigned_t slash_count = 0; - bool graph_first = F_true; + uint8_t graph_first = F_true; // Identify where the object ends. while (range->start <= range->stop && range->start < buffer.used && buffer.string[range->start] != f_fss_eol_s.string[0]) { @@ -923,7 +924,7 @@ extern "C" { if (state->status == F_data_not_stop || state->status == F_data_not_eos) { if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { { - const f_status_t status = f_memory_array_increase_by(state->step_small + 2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + const f_status_t status = f_memory_array_increase_by(2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(status)) { state->status = status; @@ -943,7 +944,7 @@ extern "C" { } // Ensure that there is room for a slash delimit, the object open character, and the end of line character. - state->status = f_memory_array_increase_by(state->step_small + 4, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + state->status = f_memory_array_increase_by(4, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) return; const f_number_unsigned_t destination_used = destination->used; @@ -1122,7 +1123,7 @@ extern "C" { } if (complete != f_fss_complete_trim_e) { - state->status = f_memory_array_increase_by(state->step_small + 3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); + state->status = f_memory_array_increase_by(3, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) { destination->used = destination_used; diff --git a/level_2/fll_fss/c/fss/embedded_list.c b/level_2/fll_fss/c/fss/embedded_list.c index f795fe4..947f5b9 100644 --- a/level_2/fll_fss/c/fss/embedded_list.c +++ b/level_2/fll_fss/c/fss/embedded_list.c @@ -18,7 +18,7 @@ extern "C" { f_number_unsigned_t initial_used = 0; - bool found_data = F_false; + uint8_t found_data = F_false; if (!nest->used) { state->status = f_memory_array_increase(state->step_small, sizeof(f_fss_nest_t), (void **) &nest->depth, &nest->used, &nest->size); diff --git a/level_2/fll_fss/c/fss/extended_list.c b/level_2/fll_fss/c/fss/extended_list.c index 5ef33a9..7edd7b3 100644 --- a/level_2/fll_fss/c/fss/extended_list.c +++ b/level_2/fll_fss/c/fss/extended_list.c @@ -19,7 +19,7 @@ extern "C" { f_status_t status = F_okay; f_number_unsigned_t initial_used = objects->used; - bool found_data = F_false; + uint8_t found_data = F_false; do { state->status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &objects->array, &objects->used, &objects->size); @@ -59,6 +59,8 @@ extern "C" { if (state->status == F_fss_found_object) { found_data = F_true; contents->array[contents->used].used = 0; + closes->array[closes->used].start = 1; + closes->array[closes->used].stop = 0; fl_fss_extended_list_content_read(buffer, range, &contents->array[contents->used], &closes->array[closes->used], contents_delimits ? contents_delimits : objects_delimits, comments, state); if (F_status_is_error(state->status)) return; @@ -74,6 +76,10 @@ extern "C" { ++contents->array[contents->used++].used; ++objects->used; + // The Content end is not found so make sure the closes designates that the close is not found. + closes->array[closes->used].start = 1; + closes->array[closes->used++].stop = 0; + return; } @@ -103,6 +109,8 @@ extern "C" { } contents->array[contents->used].used = 0; + closes->array[closes->used].start = 1; + closes->array[closes->used].stop = 0; } if (range->start >= range->stop || range->start >= buffer.used) { @@ -111,6 +119,7 @@ extern "C" { if (state->status == F_fss_found_object || state->status == F_fss_found_content || state->status == F_fss_found_content_not || state->status == F_fss_found_object_content_not) { ++objects->used; ++contents->used; + ++closes->used; } state->status = (range->start >= buffer.used) ? F_okay_eos : F_okay_stop; @@ -120,6 +129,7 @@ extern "C" { ++objects->used; ++contents->used; + ++closes->used; } while (range->start < F_string_t_size_d); diff --git a/level_3/fss_read/c/embedded_list/print.c b/level_3/fss_read/c/embedded_list/print.c index dc5e6aa..cec5896 100644 --- a/level_3/fss_read/c/embedded_list/print.c +++ b/level_3/fss_read/c/embedded_list/print.c @@ -58,7 +58,7 @@ extern "C" { #endif // _di_fss_read_embedded_list_print_object_end_empty_ #ifndef _di_fss_read_embedded_list_print_set_end_ - f_status_t fss_read_embedded_list_print_set_end(fl_print_t * const print) { + f_status_t fss_read_embedded_list_print_set_end(fl_print_t * const print, const f_number_unsigned_t close) { if (!print || !print->custom) return F_status_set_error(F_output_not); @@ -67,7 +67,13 @@ extern "C" { if ((main->setting.flag & fss_read_main_flag_object_d) && (main->setting.flag & fss_read_main_flag_content_d)) { f_file_stream_lock(print->to); - f_print_dynamic_raw(f_fss_embedded_list_close_s, print->to); + if (close < main->setting.closes.used) { + f_print_dynamic_partial(main->setting.buffer, main->setting.closes.array[close], print->to); + } + else { + f_print_dynamic_raw(f_fss_embedded_list_close_s, print->to); + } + f_print_dynamic_raw(f_fss_embedded_list_close_end_s, print->to); f_file_stream_unlock(print->to); diff --git a/level_3/fss_read/c/embedded_list/print.h b/level_3/fss_read/c/embedded_list/print.h index 406e0d2..8b5a415 100644 --- a/level_3/fss_read/c/embedded_list/print.h +++ b/level_3/fss_read/c/embedded_list/print.h @@ -100,6 +100,8 @@ extern "C" { * The print.custom is expected to be of type fss_read_main_t. * * This does not alter print.custom.setting.state.status. + * @param close + * The position within the close array representing the range within the buffer for the close string. * * @return * F_okay on success. @@ -108,7 +110,7 @@ extern "C" { * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_read_embedded_list_print_set_end_ - extern f_status_t fss_read_embedded_list_print_set_end(fl_print_t * const print); + extern f_status_t fss_read_embedded_list_print_set_end(fl_print_t * const print, const f_number_unsigned_t close); #endif // _di_fss_read_embedded_list_print_set_end_ /** diff --git a/level_3/fss_read/c/embedded_list/process_normal.c b/level_3/fss_read/c/embedded_list/process_normal.c index 34f8e89..15ee639 100644 --- a/level_3/fss_read/c/embedded_list/process_normal.c +++ b/level_3/fss_read/c/embedded_list/process_normal.c @@ -122,7 +122,7 @@ extern "C" { return; } - if ((main->setting.flag & fss_read_main_flag_depth_d) && main->setting.nest.used > 1) { + if ((main->setting.flag & fss_read_main_flag_depth_d) && depth && main->setting.nest.used > 1) { f_number_unsigned_t i = 0; // @todo make an array of depths based on size. @@ -143,12 +143,16 @@ extern "C" { main->setting.state.status = f_memory_array_resize(main->setting.nest.depth[depth].used, sizeof(f_range_t), (void **) &main->setting.objects.array, &main->setting.objects.used, &main->setting.objects.size); if (F_status_is_error(main->setting.state.status)) return; + main->setting.state.status = f_memory_array_resize(main->setting.nest.depth[depth].used, sizeof(f_range_t), (void **) &main->setting.closes.array, &main->setting.closes.used, &main->setting.closes.size); + if (F_status_is_error(main->setting.state.status)) return; + main->setting.state.status = f_memory_array_resize(main->setting.nest.depth[depth].used, sizeof(f_ranges_t), (void **) &main->setting.contents.array, &main->setting.contents.used, &main->setting.contents.size); if (F_status_is_error(main->setting.state.status)) return; for (; main->setting.objects.used < main->setting.nest.depth[depth].used; ++main->setting.objects.used) { main->setting.objects.array[main->setting.objects.used] = main->setting.nest.depth[depth].array[main->setting.objects.used].object; + main->setting.closes.array[main->setting.objects.used] = main->setting.nest.depth[depth].array[main->setting.objects.used].close; // Use a static array for the inner Content that points to the depth, and so ensure the size is 0 to designate this is not dynamically allocated here. if (main->setting.nest.depth[depth].array[main->setting.objects.used].content.used) { @@ -163,6 +167,7 @@ extern "C" { } } // for + main->setting.closes.used = main->setting.objects.used; main->setting.contents.used = main->setting.objects.used; fss_read_ensure_quotes_length(main); diff --git a/level_3/fss_read/c/extended_list/print.c b/level_3/fss_read/c/extended_list/print.c index 82c3a87..eeaf18b 100644 --- a/level_3/fss_read/c/extended_list/print.c +++ b/level_3/fss_read/c/extended_list/print.c @@ -58,7 +58,7 @@ extern "C" { #endif // _di_fss_read_extended_list_print_object_end_content_ #ifndef _di_fss_read_extended_list_print_set_end_ - f_status_t fss_read_extended_list_print_set_end(fl_print_t * const print) { + f_status_t fss_read_extended_list_print_set_end(fl_print_t * const print, const f_number_unsigned_t close) { if (!print || !print->custom) return F_status_set_error(F_output_not); @@ -67,7 +67,13 @@ extern "C" { if ((main->setting.flag & fss_read_main_flag_object_d) && main->setting.flag & fss_read_main_flag_content_d) { f_file_stream_lock(print->to); - f_print_dynamic_raw(f_fss_extended_list_close_s, print->to); + if (close < main->setting.closes.used) { + f_print_dynamic_partial(main->setting.buffer, main->setting.closes.array[close], print->to); + } + else { + f_print_dynamic_raw(f_fss_extended_list_close_s, print->to); + } + f_print_dynamic_raw(f_fss_extended_list_close_end_s, print->to); f_file_stream_unlock(print->to); diff --git a/level_3/fss_read/c/extended_list/print.h b/level_3/fss_read/c/extended_list/print.h index bcc5a09..59d896c 100644 --- a/level_3/fss_read/c/extended_list/print.h +++ b/level_3/fss_read/c/extended_list/print.h @@ -101,6 +101,8 @@ extern "C" { * The print.custom is expected to be of type fss_read_main_t. * * This does not alter print.custom.setting.state.status. + * @param close + * The position within the close array representing the range within the buffer for the close string. * * @return * F_okay on success. @@ -109,7 +111,7 @@ extern "C" { * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_read_extended_list_print_set_end_ - extern f_status_t fss_read_extended_list_print_set_end(fl_print_t * const print); + extern f_status_t fss_read_extended_list_print_set_end(fl_print_t * const print, const f_number_unsigned_t close); #endif // _di_fss_read_extended_list_print_set_end_ /** diff --git a/level_3/fss_read/c/main/common/type.h b/level_3/fss_read/c/main/common/type.h index 1511b4c..02a908f 100644 --- a/level_3/fss_read/c/main/common/type.h +++ b/level_3/fss_read/c/main/common/type.h @@ -118,19 +118,17 @@ extern "C" { * The FSS Read cache. * * objects: An Objects array used by the fll_fss_embedded_list_read() function. - * closes: An Object closes array used by the fll_fss_embedded_list_read() function. * positions: A positions array used by the fll_fss_embedded_list_read() function. * slashes: A slashes array used by the fll_fss_embedded_list_read() function. */ #ifndef _di_fss_read_cache_t_ typedef struct { f_ranges_t objects; - f_ranges_t closes; f_number_unsigneds_t positions; f_number_unsigneds_t slashes; } fss_read_cache_t; - #define fss_read_cache_t_initialize { f_ranges_t_initialize, f_ranges_t_initialize, f_number_unsigneds_t_initialize, f_number_unsigneds_t_initialize } + #define fss_read_cache_t_initialize { f_ranges_t_initialize, f_number_unsigneds_t_initialize, f_number_unsigneds_t_initialize } #endif // _di_fss_read_cache_t_ /** @@ -179,7 +177,7 @@ extern "C" { f_status_t (*print_content_next)(fl_print_t * const print); f_status_t (*print_object_end)(fl_print_t * const print); f_status_t (*print_object_end_empty)(fl_print_t * const print); - f_status_t (*print_set_end)(fl_print_t * const print); + f_status_t (*print_set_end)(fl_print_t * const print, const f_number_unsigned_t close); f_status_t (*print_set_end_empty)(fl_print_t * const print); } fss_read_callback_t; diff --git a/level_3/fss_read/c/main/print/data.c b/level_3/fss_read/c/main/print/data.c index 2356756..e0d6e92 100644 --- a/level_3/fss_read/c/main/print/data.c +++ b/level_3/fss_read/c/main/print/data.c @@ -136,7 +136,7 @@ extern "C" { if ((print_state & 0x1) || !(print_state & 0x10)) { if (main->callback.print_set_end) { - main->callback.print_set_end(&main->program.output); + main->callback.print_set_end(&main->program.output, at); } } } @@ -148,7 +148,7 @@ extern "C" { } if (main->callback.print_set_end) { - main->callback.print_set_end(&main->program.output); + main->callback.print_set_end(&main->program.output, at); } } } @@ -158,7 +158,7 @@ extern "C" { } if (main->callback.print_set_end) { - main->callback.print_set_end(&main->program.output); + main->callback.print_set_end(&main->program.output, at); } } @@ -326,7 +326,7 @@ extern "C" { #endif // _di_fss_read_print_quote_ #ifndef _di_fss_read_print_set_end_ - f_status_t fss_read_print_set_end(fl_print_t * const print) { + f_status_t fss_read_print_set_end(fl_print_t * const print, const f_number_unsigned_t close) { if (!print || !print->custom) return F_status_set_error(F_output_not); @@ -337,7 +337,7 @@ extern "C" { #endif // _di_fss_read_print_set_end_ #ifndef _di_fss_read_print_set_end_no_eol_ - f_status_t fss_read_print_set_end_no_eol(fl_print_t * const print) { + f_status_t fss_read_print_set_end_no_eol(fl_print_t * const print, const f_number_unsigned_t close) { if (!print || !print->custom) return F_status_set_error(F_output_not); diff --git a/level_3/fss_read/c/main/print/data.h b/level_3/fss_read/c/main/print/data.h index 35ee330..9c00285 100644 --- a/level_3/fss_read/c/main/print/data.h +++ b/level_3/fss_read/c/main/print/data.h @@ -265,6 +265,8 @@ extern "C" { * The print.custom is expected to be of type fss_read_main_t. * * This does not alter print.custom.setting.state.status. + * @param close + * The position within the close array representing the range within the buffer for the close string. * * @return * F_okay on success. @@ -273,7 +275,7 @@ extern "C" { * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_read_print_set_end_ - extern f_status_t fss_read_print_set_end(fl_print_t * const print); + extern f_status_t fss_read_print_set_end(fl_print_t * const print, const f_number_unsigned_t close); #endif // _di_fss_read_print_set_end_ /** @@ -289,6 +291,8 @@ extern "C" { * The print.custom is expected to be of type fss_read_main_t. * * This does not alter print.custom.setting.state.status. + * @param close + * The position within the close array representing the range within the buffer for the close string. * * @return * F_okay on success. @@ -297,7 +301,7 @@ extern "C" { * F_output_not (with error bit) if a parameter is NULL. */ #ifndef _di_fss_read_print_set_end_no_eol_ - extern f_status_t fss_read_print_set_end_no_eol(fl_print_t * const print); + extern f_status_t fss_read_print_set_end_no_eol(fl_print_t * const print, const f_number_unsigned_t close); #endif // _di_fss_read_print_set_end_no_eol_ #ifdef __cplusplus diff --git a/level_3/fss_read/c/main/process_normal.c b/level_3/fss_read/c/main/process_normal.c index 5972fa6..7999ea0 100644 --- a/level_3/fss_read/c/main/process_normal.c +++ b/level_3/fss_read/c/main/process_normal.c @@ -210,7 +210,7 @@ extern "C" { if (!(main->setting.flag & fss_read_main_flag_object_as_line_d)) { if (main->callback.print_set_end) { - main->callback.print_set_end(&main->program.output); + main->callback.print_set_end(&main->program.output, at); } } @@ -240,7 +240,7 @@ extern "C" { if (!(main->setting.flag & fss_read_main_flag_object_as_line_d)) { if (*line == main->setting.line) { if (main->callback.print_set_end) { - main->callback.print_set_end(&main->program.output); + main->callback.print_set_end(&main->program.output, at); } main->setting.state.status = F_success; @@ -254,7 +254,7 @@ extern "C" { else if (main->setting.flag & fss_read_main_flag_empty_d) { if (*line == main->setting.line) { if (main->callback.print_set_end) { - main->callback.print_set_end(&main->program.output); + main->callback.print_set_end(&main->program.output, at); } main->setting.state.status = F_success; @@ -269,7 +269,7 @@ extern "C" { if (main->setting.flag & fss_read_main_flag_empty_d) { if (*line == main->setting.line) { if (main->callback.print_set_end) { - main->callback.print_set_end(&main->program.output); + main->callback.print_set_end(&main->program.output, at); } main->setting.state.status = F_success; @@ -322,7 +322,7 @@ extern "C" { } if (main->callback.print_set_end) { - main->callback.print_set_end(&main->program.output); + main->callback.print_set_end(&main->program.output, at); } main->setting.state.status = F_success; @@ -389,7 +389,7 @@ extern "C" { if ((main->setting.flag & fss_read_main_flag_object_d) && (main->setting.flag & fss_read_main_flag_content_has_close_d)) { if (*line == main->setting.line) { if (main->callback.print_set_end) { - main->callback.print_set_end(&main->program.output); + main->callback.print_set_end(&main->program.output, at); } main->setting.state.status = F_success; -- 1.8.3.1