From ecfaaa75e134070da6c8d0bc6c2133b82b1d9462 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 5 Oct 2026 21:40:03 -0500 Subject: [PATCH] Progress: Get FSS embedded list content read test working. Include additional logic from 8d95e471986b3c6bddc323054af6da341e20246e where `F_okay_eos` and `F_okay_stop` are replaced with `F_content_found`. The recently added function `private_f_fss_skip_past_space_previous()` is incorrectly checking against `previous` when it should be checking against `range.start` for comining characters. --- level_0/f_fss/c/private-fss.c | 8 ++-- level_1/fl_fss/c/fss/embedded_list.c | 33 ++++----------- .../unit/c/test-fss-basic_list_content_read.c | 4 +- .../c/test-fss-embedded_list_content_read.c | 41 +++++++++++-------- .../c/test-fss-extended_list_content_read.c | 4 +- 5 files changed, 40 insertions(+), 50 deletions(-) diff --git a/level_0/f_fss/c/private-fss.c b/level_0/f_fss/c/private-fss.c index bc326fceb..aec1220d1 100644 --- a/level_0/f_fss/c/private-fss.c +++ b/level_0/f_fss/c/private-fss.c @@ -51,10 +51,10 @@ extern "C" { // Check that the first character is not a combining character or a joiner character. state->status = f_utf_is_combining_joiner( - buffer.string + *previous, - (range->stop - *previous) + 1 > buffer.used - *previous - ? buffer.used - *previous - : (range->stop - *previous) + 1 + buffer.string + range->start, + (range->stop - range->start) + 1 > buffer.used - range->start + ? buffer.used - range->start + : (range->stop - range->start) + 1 ); f_fss_fail_utf_to_false(state); diff --git a/level_1/fl_fss/c/fss/embedded_list.c b/level_1/fl_fss/c/fss/embedded_list.c index 0ebc91c09..ae2114981 100644 --- a/level_1/fl_fss/c/fss/embedded_list.c +++ b/level_1/fl_fss/c/fss/embedded_list.c @@ -332,7 +332,7 @@ extern "C" { flag_fl &= ~___fl_flag_has_graph_first___; - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { + if (state->status == F_okay_eol) { if (++depth >= cache->objects->size) { state->status = f_memory_array_resize(depth + 2, sizeof(f_range_t), (void **) &cache->objects->array, &cache->objects->used, &cache->objects->size); } @@ -384,21 +384,10 @@ extern "C" { // No valid object close found, seek until EOL. f_fss_seek_to_eol(buffer, range, state); if (F_status_is_error(state->status)) break; - - if (flag_fl & ___fl_flag_has_delimit_comment___) { - 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; - - delimits->array[delimits->used++] = comment_delimit; - } - - newline_last = range->start; - line_start = newline_last + 1; - flag_fl |= ___fl_flag_has_graph_first___; } } else if (buffer.string[range->start] == f_fss_embedded_list_close_s.string[0] && (flag_fl & ___fl_flag_has_graph_first___)) { - close_location = range->start; + close_location = previous = range->start++; f_fss_skip_past_space_previous(buffer, range, state, &previous); @@ -415,7 +404,7 @@ extern "C" { if (F_status_is_error(state->status)) break; if (range->start > range->stop || range->start >= buffer.used) break; - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { + if (state->status == F_okay_eol) { if (depth >= found->used) { state->status = f_memory_array_resize(depth + 2, sizeof(f_fss_nest_t), (void **) &found->depth, &found->used, &found->size); } @@ -478,7 +467,10 @@ extern "C" { line_start = newline_last + 1; flag_fl |= ___fl_flag_has_graph_first___; - if (!depth) { + if (depth) { + --depth; + } + else { state->status = f_utf_buffer_increment(buffer, range, 1); if (F_status_is_error(state->status)) { @@ -488,19 +480,10 @@ extern "C" { return; } - if (range->start >= buffer.used) { - state->status = F_okay_eos; - } else if (range->start > range->stop) { - state->status = F_okay_stop; - } - else { - state->status = F_fss_found_content; - } + state->status = F_fss_found_content; return; } - - --depth; } else { diff --git a/level_1/fl_fss/tests/unit/c/test-fss-basic_list_content_read.c b/level_1/fl_fss/tests/unit/c/test-fss-basic_list_content_read.c index f9dc447ad..183f6f296 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss-basic_list_content_read.c +++ b/level_1/fl_fss/tests/unit/c/test-fss-basic_list_content_read.c @@ -442,7 +442,7 @@ void test__fl_fss_basic_list_content_read__works_using_combining(void **void_sta printf("[ -------> ] --- [04] Failure with getline() for matches, with set %lu, result is negative.\n", set); } - assert_true(result >= 0); + assert_return_code(result, 0); matches = atoi(line_matches); @@ -510,7 +510,7 @@ void test__fl_fss_basic_list_content_read__works_using_combining(void **void_sta printf("[ -------> ] --- [10] Failure with getline() for counts, with set %lu, result is negative.\n", set); } - assert_true(result >= 0); + assert_return_code(result, 0); counts = atoi(line_counts); diff --git a/level_1/fl_fss/tests/unit/c/test-fss-embedded_list_content_read.c b/level_1/fl_fss/tests/unit/c/test-fss-embedded_list_content_read.c index 1a9d39b05..d5a6a1a64 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss-embedded_list_content_read.c +++ b/level_1/fl_fss/tests/unit/c/test-fss-embedded_list_content_read.c @@ -379,10 +379,9 @@ void test__fl_fss_embedded_list_content_read__works_using_combining(void **void_ f_range_t range = f_range_t_initialize; f_range_t found_object = f_range_t_initialize; - f_ranges_t found_content = f_ranges_t_initialize; f_ranges_t comments = f_ranges_t_initialize; - f_fss_nest_t found = f_fss_nest_t_initialize; + f_fss_nest_t found_content = f_fss_nest_t_initialize; f_state_t state = f_state_t_initialize; f_status_t status_object = F_okay; f_uint8s_t quotes = f_uint8s_t_initialize; @@ -464,7 +463,7 @@ void test__fl_fss_embedded_list_content_read__works_using_combining(void **void_ printf("[ -------> ] --- [04] Failure with getline() for matches, with set %lu, result is negative.\n", set); } - assert_true(result >= 0); + assert_return_code(result, 0); matches = atoi(line_matches); @@ -532,11 +531,11 @@ void test__fl_fss_embedded_list_content_read__works_using_combining(void **void_ printf("[ -------> ] --- [10] Failure with getline() for counts, with set %lu, result is negative.\n", set); } - assert_true(result >= 0); + assert_return_code(result, 0); counts = atoi(line_counts); - fl_fss_embedded_list_content_read(set_strings, &range, &found, &delimits, &comments, &state); + fl_fss_embedded_list_content_read(set_strings, &range, &found_content, &delimits, &comments, &state); if (!(state.status == F_fss_found_content || state.status == F_data_not)) { printf("[ -------> ] --- [11] Failure with fl_fss_embedded_list_content_read(), with set %lu, status=%u, expected %u, or %u.\n", set, state.status, F_fss_found_content, F_data_not); @@ -545,17 +544,27 @@ void test__fl_fss_embedded_list_content_read__works_using_combining(void **void_ assert_true(state.status == F_fss_found_content || state.status == F_data_not); if (state.status == F_fss_found_content) { - if (!found_content.used) { - printf("[ -------> ] --- [12] Failure with fl_fss_embedded_list_content_read(), with set %lu, expected found_content.used (%lu) <> 0.\n", set, found_content.used); + if (!(found_content.used && found_content.depth[0].used && found_content.depth[0].array[0].content.used)) { + printf( + "[ -------> ] --- [12] Failure with fl_fss_embedded_list_content_read(), with set %lu, expected found_content.used (%lu) <> 0 or found_content.depth.used (%lu) <> 0 or found_content.depth[0].array[0].content.used (%lu) <> 0 <> 0.\n", + set, + found_content.used, + found_content.used + ? found_content.depth[0].used + : 0, + found_content.used && found_content.depth[0].used + ? found_content.depth[0].array[0].content.used + : 0 + ); } - assert_true(found_content.used); + assert_true(found_content.used && found_content.depth[0].used && found_content.depth[0].array[0].content.used); - if (found_content.used != (f_number_unsigned_t) counts) { - printf("[ -------> ] --- [13] Failure with fl_fss_embedded_list_content_read(), with set %lu, expected found_content.used (%lu) == %lu, found = '%s', expected = '%s'.\n", set, found_content.used, (f_number_unsigned_t) counts, set_result.string ? set_result.string : "", set_contents[set].string ? set_contents[set].string : ""); + if (found_content.depth[0].used != (f_number_unsigned_t) counts) { + printf("[ -------> ] --- [13] Failure with fl_fss_embedded_list_content_read(), with set %lu, expected found_content.depth[0].used (%lu) == %lu, found = '%s', expected = '%s'.\n", set, found_content.depth[0].used, (f_number_unsigned_t) counts, set_result.string ? set_result.string : "", set_contents[set].string ? set_contents[set].string : ""); } - assert_true(found_content.used == (f_number_unsigned_t) counts); + assert_true(found_content.depth[0].used == (f_number_unsigned_t) counts); state.status = F_none; @@ -568,7 +577,7 @@ void test__fl_fss_embedded_list_content_read__works_using_combining(void **void_ assert_int_equal(state.status, F_okay); { - const f_status_t status = data__extract_from_source(set_delimit, found_content.array[0], &set_result); + const f_status_t status = data__extract_from_source(set_delimit, found_content.depth[0].array[0].content.array[0], &set_result); if (F_status_is_error(status)) { printf("[ -------> ] --- [15] Failure with data__extract_from_source() for extract set contents, with set %lu, status=%u has error bit set.\n", set, status); @@ -594,7 +603,6 @@ void test__fl_fss_embedded_list_content_read__works_using_combining(void **void_ if (comments.array) free(comments.array); if (delimits.array) free(delimits.array); - if (found_content.array) free(found_content.array); if (quotes.array) free(quotes.array); if (line_counts) free(line_counts); @@ -602,7 +610,7 @@ void test__fl_fss_embedded_list_content_read__works_using_combining(void **void_ if (line_object) free(line_object); if (set_result.string) free(set_result.string); - f_fss_nest_delete(&found); + f_fss_nest_delete(&found_content); comments.array = 0; comments.used = 0; @@ -610,7 +618,7 @@ void test__fl_fss_embedded_list_content_read__works_using_combining(void **void_ delimits.array = 0; delimits.used = 0; delimits.size = 0; - found_content.array = 0; + found_content.depth = 0; found_content.used = 0; found_content.size = 0; line_counts = 0; @@ -644,10 +652,9 @@ void test__fl_fss_embedded_list_content_read__works_using_combining(void **void_ if (comments.array) free(comments.array); if (delimits.array) free(delimits.array); - if (found_content.array) free(found_content.array); if (quotes.array) free(quotes.array); - f_fss_nest_delete(&found); + f_fss_nest_delete(&found_content); } } diff --git a/level_1/fl_fss/tests/unit/c/test-fss-extended_list_content_read.c b/level_1/fl_fss/tests/unit/c/test-fss-extended_list_content_read.c index 8b26865d2..5b20014ff 100644 --- a/level_1/fl_fss/tests/unit/c/test-fss-extended_list_content_read.c +++ b/level_1/fl_fss/tests/unit/c/test-fss-extended_list_content_read.c @@ -574,7 +574,7 @@ void test__fl_fss_extended_list_content_read__works_using_combining(void **void_ printf("[ -------> ] --- [04] Failure with getline() for matches, with set %lu, result is negative.\n", set); } - assert_true(result >= 0); + assert_return_code(result, 0); matches = atoi(line_matches); @@ -642,7 +642,7 @@ void test__fl_fss_extended_list_content_read__works_using_combining(void **void_ printf("[ -------> ] --- [10] Failure with getline() for counts, with set %lu, result is negative.\n", set); } - assert_true(result >= 0); + assert_return_code(result, 0); counts = atoi(line_counts); -- 2.52.0