]> Kevux Git Server - fll/commitdiff
Bugfix: Invalid comment handling in FSS Embedded Read.
authorKevin Day <Kevin@kevux.org>
Sun, 25 Aug 2024 04:30:44 +0000 (23:30 -0500)
committerKevin Day <Kevin@kevux.org>
Sun, 25 Aug 2024 04:41:39 +0000 (23:41 -0500)
The comments are not being properly processed because graph_first is not and should be being set to 0x1 at start.
As a result, the first comment is not being treated as a comment.

Make sure to reset the `graph_first` and `line_start` after processing the comment.
The comment starts at the line and so use `line_start` rather than `newline_last + 1`.
Remove dead code where `graph_first == 0x2` is being checked inside a block that requires `graph_first` to be `0x1`.

Update code comments about `graph_first` in several of the fl_fss read sources.

Add additional check for buffer string range when processing comments.

Update the runtime tests as appropriate.

I also noticed that several of these runtime tests use `--line` but are showing multiple lines.
I will address this bug in a separate commit.

26 files changed:
level_1/fl_fss/c/fss/basic_list.c
level_1/fl_fss/c/fss/embedded_list.c
level_1/fl_fss/c/fss/extended_list.c
level_3/fss_embedded_list_read/c/private-read.c
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name-привет_has_space-select-0-total.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name-привет_has_space-select-0.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name-привет_has_space-total.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name-привет_has_space.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-original.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-select-0-original.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-select-0.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-total.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-trim.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-content.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object_and_content-line-0.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object_and_content-line-1.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object_and_content-line-100.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object_and_content-line-5.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object_and_content-line-6.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object_and_content-name-привет_has_space-select-0.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object_and_content-name-привет_has_space-total.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object_and_content-original.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object_and_content-select-0.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object_and_content-total.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object_and_content-trim.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object_and_content.expect

index 7ae97abe9e94c14effa95d3fc49942c0260b51d5..2f7504f2bdb0c76a69bdea11dced170e18a825f5 100644 (file)
@@ -35,7 +35,9 @@ extern "C" {
     f_array_length_t start = 0;
     f_array_length_t comment_delimit = 0;
 
-    uint8_t graph_first = 0x1; // 0x0 = false, 0x1 = true, 0x2 = false, but there is a delimited comment, comment_delimit is set.
+    // Designate that this is the first graph character.
+    // 0x0 = false, 0x1 = true, 0x2 = false, but there is a delimited comment, comment_delimit is set.
+    uint8_t graph_first = 0x1;
 
     // Identify where the content ends.
     while (range->start <= range->stop && range->start < buffer.used) {
index 261a36f42cf977b0a64157d9e0b9bbb0460d565f..8ea44794b29262b2ca1b99176f8ba76706659fdf 100644 (file)
@@ -69,8 +69,9 @@ extern "C" {
 
     bool is_open = F_false;
 
+    // Designate that this is the first graph character.
     // 0x0 = false, 0x1 = true, 0x2 = false, but there is a delimited comment, comment_delimit is set.
-    uint8_t graph_first = 0x0;
+    uint8_t graph_first = 0x1;
 
     // Initialize depth 1 start position.
     // Positions_start.used is used as a max depth (such that positions_start.used == max depth + 1).
@@ -598,7 +599,7 @@ extern "C" {
         }
       }
       else if (graph_first == 0x1 && buffer.string[range->start] == f_fss_comment_s.string[0]) {
-        position = newline_last + 1;
+        position = line_start;
 
         status = f_fss_seek_to_eol(state, buffer, range);
         if (F_status_is_error(status)) break;
@@ -610,19 +611,14 @@ extern "C" {
           --range->start;
         }
         else {
-          if (graph_first == 0x2) {
-            status = f_array_lengths_increase(state.step_small, delimits);
-            if (F_status_is_error(status)) break;
-
-            delimits->array[delimits->used++] = comment_delimit;
-          }
-
           newline_last = range->start;
-          graph_first = 0x1;
         }
 
+        graph_first = 0x1;
+
         comments->array[comments->used].start = position;
         comments->array[comments->used++].stop = range->start++;
+        line_start = range->start;
 
         continue;
       }
index 9a7ae4b7990c030c05926a2cdd5da2671fab4a24..875f10408be90abde876479fa6498f2a139ddd7d 100644 (file)
@@ -582,7 +582,8 @@ extern "C" {
     f_array_length_t slash_first = 0;
     f_array_length_t slash_count = 0;
 
-    bool graph_first = F_true;
+    // Designate that this is the first graph character.
+    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]) {
index 69cfb68fc0edd6cebccbd4c28da82419ebfedda9..43b76bb177c86eacda6bdc0baaf302f11b7ac1bd 100644 (file)
@@ -279,7 +279,10 @@ extern "C" {
       for (; i < comments->used; ++i) {
 
         for (j = comments->array[i].start; j <= comments->array[i].stop; ++j) {
-          data->buffer.string[j] = f_fss_delimit_placeholder_s.string[0];
+
+          if (j < data->buffer.used) {
+            data->buffer.string[j] = f_fss_delimit_placeholder_s.string[0];
+          }
         } // for
       } // for
     }
index 53d1e7a2e50a721a4900ce9b62f54491fcdf27f9..959ccee90a5b2749f7aa926f70a00b71e2db4662 100644 (file)
@@ -9,7 +9,6 @@ c d
    with content.
   another "A" list.
   quoted, "yep".
-  # has a comment
   But this is not a comment.
   not a list\:
   a b привет
index 53d1e7a2e50a721a4900ce9b62f54491fcdf27f9..959ccee90a5b2749f7aa926f70a00b71e2db4662 100644 (file)
@@ -9,7 +9,6 @@ c d
    with content.
   another "A" list.
   quoted, "yep".
-  # has a comment
   But this is not a comment.
   not a list\:
   a b привет
index bbd7eb3efa3deedb03b6d974549148f9acdf22e7..9c5c57b3d21d40fcb62af9a31e73130d75905e34 100644 (file)
@@ -9,7 +9,6 @@ c d
    with content.
   another "A" list.
   quoted, "yep".
-  # has a comment
   But this is not a comment.
   not a list\:
   a b привет
index bbd7eb3efa3deedb03b6d974549148f9acdf22e7..9c5c57b3d21d40fcb62af9a31e73130d75905e34 100644 (file)
@@ -9,7 +9,6 @@ c d
    with content.
   another "A" list.
   quoted, "yep".
-  # has a comment
   But this is not a comment.
   not a list\:
   a b привет
index bbd7eb3efa3deedb03b6d974549148f9acdf22e7..9c5c57b3d21d40fcb62af9a31e73130d75905e34 100644 (file)
@@ -9,7 +9,6 @@ c d
    with content.
   another "A" list.
   quoted, "yep".
-  # has a comment
   But this is not a comment.
   not a list\:
   a b привет