From 8d95e471986b3c6bddc323054af6da341e20246e Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 23 Sep 2026 20:49:20 -0500 Subject: [PATCH] Progress: Finish basic list content read changes. I discovered that copying the file with the combining character at the start of the line (U+0301) causes a space to be added. This is problematic and cost me some time. I have to then manually recreate the file and use my `utf8` program to regenerate the correct test data: ```sh utf8 -cB U+0301 >> test.txt ``` Fix some issues with the basic list content read code. The start should be set to `begin` and not `0`. Finish adding the combining and joiner code. Consistently apply the `newline_last`. The content can be found but when it ends of EOS or stop, then it is returning the EOS or stop status codes (`F_okay_eos` and `F_okay_stop`) without setting the found structure. The code calling this should just need to check for `F_content_found`, so change the behavior to do this and set the found position when returning EOS or stop at the end. The start of the function should return EOS or stop as usual. I suspect this problem is likely also in the extended read and other such code. Consistently break out of the loop so the exit handling code gets properly called before returning on error. --- level_1/fl_fss/c/fss/basic_list.c | 158 +++++++++++------- .../contents/basic_list-combining_read-1.txt | 2 +- .../counts/basic_list-combining_read.txt | 2 +- .../strings/basic_list-combining_read.txt | 2 +- .../unit/c/test-fss-basic_list_content_read.c | 4 +- 5 files changed, 98 insertions(+), 70 deletions(-) diff --git a/level_1/fl_fss/c/fss/basic_list.c b/level_1/fl_fss/c/fss/basic_list.c index ba5b46d24..a6477ca81 100644 --- a/level_1/fl_fss/c/fss/basic_list.c +++ b/level_1/fl_fss/c/fss/basic_list.c @@ -49,10 +49,11 @@ extern "C" { const f_number_unsigned_t begin = range->start; found->array[found->used].start = range->start; - f_number_unsigned_t newline_last = range->start; + f_number_unsigned_t newline_last = begin; + f_number_unsigned_t previous = 0; f_number_unsigned_t slash_first = 0; f_number_unsigned_t slash_count = 0; - f_number_unsigned_t start = 0; + f_number_unsigned_t start = begin; f_number_unsigned_t comment_delimit = 0; uint8_t flag_fl = ___fl_flag_has_graph_first___; @@ -104,13 +105,13 @@ extern "C" { break; } - if (F_status_is_error(state->status)) return; + if (F_status_is_error(state->status)) break; if (buffer.string[range->start] != f_fss_slash_s.string[0]) break; ++slash_count; - } // while + } // for - if (F_status_is_error(state->status)) return; + if (F_status_is_error(state->status)) break; if (range->start > range->stop || range->start >= buffer.used) break; if (!(flag_fl & ___fl_flag_do_escape___)) continue; @@ -126,14 +127,17 @@ extern "C" { slash_count = 0; f_fss_skip_past_combining_joiner(buffer, range, state); + if (F_status_is_error(state->status)) break; continue; } - if (F_status_is_error(state->status) || state->status == F_data_not) return; + if (state->status == F_data_not) return; + if (F_status_is_error(state->status)) break; if (range->start > range->stop || range->start >= buffer.used) break; if (state->status == F_okay_eol) { + newline_last = start; start = range->start; range->start = slash_first; @@ -179,13 +183,22 @@ extern "C" { slash_count = 0; } } - - // TODO: Resume here. else if ((flag_fl & ___fl_flag_has_graph_first___) && buffer.string[range->start] == f_fss_comment_s.string[0]) { - // TODO: check combining/joiner. - flag_fl &= ___fl_flag_has_delimit_comment___; - comment_delimit = slash_first; ++range->start; + + if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { + flag_fl &= ~___fl_flag_has_graph_first_do_escape___; + slash_count = 0; + + f_fss_skip_past_combining_joiner(buffer, range, state); + if (F_status_is_error(state->status)) break; + } + else { + if (F_status_is_error(state->status)) break; + + flag_fl &= ___fl_flag_has_delimit_comment___; + comment_delimit = slash_first; + } } continue; @@ -195,71 +208,92 @@ extern "C" { ++range->start; flag_fl &= ~___fl_flag_has_delimit_comment_graph_first___; - // TODO: check combining/joiner. - - while (range->start <= range->stop && range->start < buffer.used) { // TODO: replace with seek to eol? + if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { + flag_fl &= ~___fl_flag_has_graph_first_do_escape___; + slash_count = 0; - if (state->interrupt) { - state->interrupt((void *) state, 0); - if (F_status_set_fine(state->status) == F_interrupt) break; - } + f_fss_skip_past_combining_joiner(buffer, range, state); + if (F_status_is_error(state->status)) break; - if (buffer.string[range->start] == f_fss_eol_s.string[0]) break; - if (f_fss_is_space(buffer, *range, state) == F_false) break; + continue; + } - state->status = f_utf_buffer_increment(buffer, range, 1); - if (F_status_is_error(state->status)) break; - } // while + if (F_status_is_error_not(state->status)) { + f_fss_skip_past_space(buffer, range, state); + } if (F_status_is_error(state->status)) break; if (range->start > range->stop || range->start >= buffer.used) break; // Found a valid object, set stop point to last newline. - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - if (newline_last == found->array[found->used].start && buffer.string[found->array[found->used].start] != f_fss_eol_s.string[0]) { - range->start = newline_last; - state->status = F_fss_found_content_not; + if (state->status == F_okay_eol) { + previous = range->start; + range->start = start; - return; - } + if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { + range->start = previous; - range->start = newline_last + 1; - found->array[found->used++].stop = newline_last; - state->status = F_fss_found_content; + 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; - return; - } + delimits->array[delimits->used++] = comment_delimit; + } + + newline_last = range->start; + start = ++range->start; + flag_fl |= ___fl_flag_has_graph_first___; + } + else { + range->start = previous; - if (buffer.string[range->start] == f_fss_eol_s.string[0]) { - 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; - } + if (newline_last == found->array[found->used].start) { + found->array[found->used++].stop = range->start++; + } + else { + range->start = newline_last + 1; + found->array[found->used++].stop = newline_last; + } - newline_last = range->start; - flag_fl |= ___fl_flag_has_graph_first___; + state->status = F_fss_found_content; + + return; + } } continue; } if ((flag_fl & ___fl_flag_has_graph_first___) && buffer.string[range->start] == f_fss_comment_s.string[0]) { - // TODO: check combining/joiner. + previous = range->start++; - // The newline_last is initialized to the range->start, which may not actually be a new line. - if (buffer.string[newline_last] == f_string_eol_s.string[0]) { - start = newline_last + 1; - } - else { - start = newline_last; + if (f_fss_is_combining_joiner(buffer, *range, state) == F_true) { + flag_fl &= ~___fl_flag_has_graph_first_do_escape___; + slash_count = 0; + + f_fss_skip_past_combining_joiner(buffer, range, state); + if (F_status_is_error(state->status)) break; + + continue; } - 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); + range->start = previous; + + // The newline_last is initialized to the range->start, which may not actually be a new line. + 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_not(state->status)) { + 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) { @@ -294,22 +328,16 @@ extern "C" { return; } - if (range->start >= buffer.used) { - found->array[found->used].stop = buffer.used - 1; - state->status = F_okay_eos; - - return; - } - - if (range->start > range->stop) { - found->array[found->used].stop = range->stop; - state->status = F_okay_stop; - - return; - } - if (range->start > begin) { - found->array[found->used++].stop = range->start - 1; + if (range->start >= buffer.used) { + found->array[found->used++].stop = buffer.used - 1; + } + else if (range->start > range->stop) { + found->array[found->used++].stop = range->stop; + } + else { + found->array[found->used++].stop = range->start - 1; + } } else { found->array[found->used].start = 1; diff --git a/level_1/fl_fss/data/tests/contents/basic_list-combining_read-1.txt b/level_1/fl_fss/data/tests/contents/basic_list-combining_read-1.txt index 177a9a6f7..65adf4f41 100644 --- a/level_1/fl_fss/data/tests/contents/basic_list-combining_read-1.txt +++ b/level_1/fl_fss/data/tests/contents/basic_list-combining_read-1.txt @@ -1,3 +1,3 @@ +́: is_second and content 2. - ́: does not have ́ content 3. diff --git a/level_1/fl_fss/data/tests/counts/basic_list-combining_read.txt b/level_1/fl_fss/data/tests/counts/basic_list-combining_read.txt index 9f145d81c..627e1097c 100644 --- a/level_1/fl_fss/data/tests/counts/basic_list-combining_read.txt +++ b/level_1/fl_fss/data/tests/counts/basic_list-combining_read.txt @@ -1,5 +1,5 @@ 1 -3 +1 1 1 1 diff --git a/level_1/fl_fss/data/tests/strings/basic_list-combining_read.txt b/level_1/fl_fss/data/tests/strings/basic_list-combining_read.txt index 5b9125828..38c40624a 100644 --- a/level_1/fl_fss/data/tests/strings/basic_list-combining_read.txt +++ b/level_1/fl_fss/data/tests/strings/basic_list-combining_read.txt @@ -1,8 +1,8 @@ first valid.: content 1. is_second and does not have embedded new line.: +́: is_second and content 2. - ́: does not have ́ content 3. fourth ͜no_space: has ͜no_space content 4. 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 ea84bad35..76cbf1f03 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 @@ -527,7 +527,7 @@ void test__fl_fss_basic_list_content_read__works_using_combining(void **void_sta fl_fss_basic_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_basic_list_content_read(), with set %lu, status=%u, expected %u or %u.\n", set, state.status, F_fss_found_content, F_data_not); + printf("[ -------> ] --- [11] Failure with fl_fss_basic_list_content_read(), with set %lu, status=%u, expected %u, or %u.\n", set, state.status, F_fss_found_content, F_data_not); } assert_true(state.status == F_fss_found_content || state.status == F_data_not); @@ -540,7 +540,7 @@ void test__fl_fss_basic_list_content_read__works_using_combining(void **void_sta assert_true(found_content.used); if (found_content.used != (f_number_unsigned_t) counts) { - printf("[ -------> ] --- [13] Failure with fl_fss_basic_list_content_read(), with set %lu, expected found_content.used (%lu) == %lu.\n", set, found_content.used, (f_number_unsigned_t) counts); + printf("[ -------> ] --- [13] Failure with fl_fss_basic_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 : ""); } assert_true(found_content.used == (f_number_unsigned_t) counts); -- 2.52.0