]> Kevux Git Server - fll/commitdiff
Progress: Finish basic list content read changes.
authorKevin Day <Kevin@kevux.org>
Thu, 24 Sep 2026 01:49:20 +0000 (20:49 -0500)
committerKevin Day <Kevin@kevux.org>
Thu, 24 Sep 2026 01:49:20 +0000 (20:49 -0500)
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
level_1/fl_fss/data/tests/contents/basic_list-combining_read-1.txt
level_1/fl_fss/data/tests/counts/basic_list-combining_read.txt
level_1/fl_fss/data/tests/strings/basic_list-combining_read.txt
level_1/fl_fss/tests/unit/c/test-fss-basic_list_content_read.c

index ba5b46d24b2dee3d9c9b492259513f6b7b98d726..a6477ca81973fcb567f92ac4d74a4d4ffd47e226 100644 (file)
@@ -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;
index 177a9a6f72dda7ec4591baf515c34e7161583e22..65adf4f413513aac53cf2c106713d1b38f892df1 100644 (file)
@@ -1,3 +1,3 @@
+́:
   is_second and content 2.
- ́:
   does not have ́ content 3.
index 5b912582803a65ae86d0f95c14ec137244581374..38c40624a3dfc202e69bb6d95c2b1b3eae5fc9d2 100644 (file)
@@ -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.
index ea84bad355cfc31c56180b209585ac5498bab6e7..76cbf1f03c974d58461cc4cdcc59967c4702bac4 100644 (file)
@@ -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);