]> Kevux Git Server - fll/commitdiff
Bugfix: FSS Embedded Read is printing a single line with --line parameter with -...
authorKevin Day <Kevin@kevux.org>
Sun, 25 Aug 2024 16:36:39 +0000 (11:36 -0500)
committerKevin Day <Kevin@kevux.org>
Sun, 25 Aug 2024 16:36:39 +0000 (11:36 -0500)
The entire Content is being displayed when `--object` is used with `--line`.
The logic for printing the `--line` is entirely missing.
This adds the necessary logic to process the Object (and Content) when the `--line` is used.

Update the runtime tests accordingly.

31 files changed:
level_3/fss_embedded_list_read/c/private-read.c
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0000-basic-object-line-0.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0000-basic-object-line-1.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0000-basic-object-line-100.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0000-basic-object-line-5.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0000-basic-object-line-6.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0000-basic-object_and_content-line-0.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0000-basic-object_and_content-line-1.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0000-basic-object_and_content-line-100.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0000-basic-object_and_content-line-5.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0000-basic-object_and_content-line-6.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0001-empty_name_list-object-line-0.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0001-empty_name_list-object-line-1.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0001-empty_name_list-object-line-100.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0001-empty_name_list-object-line-5.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0001-empty_name_list-object-line-6.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0001-empty_name_list-object_and_content-line-0.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0001-empty_name_list-object_and_content-line-1.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0001-empty_name_list-object_and_content-line-100.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0001-empty_name_list-object_and_content-line-5.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0001-empty_name_list-object_and_content-line-6.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object-line-0.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object-line-1.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object-line-100.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object-line-5.expect
level_3/fss_embedded_list_read/tests/runtime/fss_0008/expect/test-0002-mixed-object-line-6.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

index 43b76bb..37f44ff 100644 (file)
@@ -553,6 +553,88 @@ extern "C" {
         print_object = &fl_print_trim_except_dynamic_partial;
       }
 
+      if (data->main->parameters.array[fss_embedded_list_read_parameter_line_e].result == f_console_result_additional_e) {
+        f_array_length_t line_current = 0;
+        uint8_t newline_missing = F_true;
+
+        flockfile(data->main->output.to.stream);
+
+        for (; i < items->used; ++i) {
+
+          if (skip[i]) continue;
+
+          // Handle Object begin.
+          if (line_current++ == line) {
+            print_object(data->buffer, items->array[i].object, *objects_delimits, data->main->output.to.stream);
+            fss_embedded_list_read_print_object_end(data);
+
+            break;
+          }
+
+          if (data->main->parameters.array[fss_embedded_list_read_parameter_content_e].result == f_console_result_found_e) {
+            if (items->array[i].content.used) {
+              j = items->array[i].content.array[0].start;
+
+              if (line_current != line) {
+                newline_missing = F_true;
+
+                for (; j <= items->array[i].content.array[0].stop; ++j) {
+
+                  if (data->buffer.string[j] == f_string_eol_s.string[0]) {
+                    if (++line_current == line) {
+                      ++j;
+                      newline_missing = F_false;
+
+                      break;
+                    }
+                  }
+                } // for
+              }
+
+              if (line_current == line) {
+
+                // If the matched line is after the stop, then this matches the end of Object line.
+                if (j > items->array[i].content.array[0].stop) {
+                  fss_embedded_list_read_print_set_end(data);
+                }
+                else {
+                  for (; j <= items->array[i].content.array[0].stop; ++j) {
+
+                    if (!data->buffer.string[j]) continue;
+
+                    if (data->buffer.string[j] == f_string_eol_s.string[0]) {
+                      f_print_dynamic_raw(f_string_eol_s, data->main->output.to.stream);
+
+                      break;
+                    }
+
+                    f_print_character(data->buffer.string[j], data->main->output.to.stream);
+                  } // for
+                }
+
+                break;
+              }
+
+              // The content always ends on a new line so if it is missing from the Content then treat the end of Content as a new line.
+              if (newline_missing) ++line_current;
+            }
+            else {
+
+              // Handle the Object end.
+              if (line_current++ == line) {
+                fss_embedded_list_read_print_set_end(data);
+
+                break;
+              }
+            }
+          }
+        } // for
+
+        funlockfile(data->main->output.to.stream);
+
+        return F_none;
+      }
+
       flockfile(data->main->output.to.stream);
 
       for (i = 0; i < items->used; ++i) {
index a3d6a83..fec5380 100644 (file)
@@ -1,37 +1 @@
 empty{
-}
-d{
-  b c
-}
-a{
-  e f
-  g h
-}
-привет{
-  мир
-}
-y {
-  z
-}
-"мир"{
-  quoted, "yep".
-}
-привет has space{
-  \"and so does this" "have space"
-}
-"This is quoted"{
-  But still a valid list.
-}
-AlsoGood{
-}
-hi     {
-  Check this.
-}
-привет has space   {
-  ...
-}
-a{
-  a second "a".
-}
-also_empty{
-}
index a3d6a83..5c34318 100644 (file)
@@ -1,37 +1 @@
-empty{
-}
-d{
-  b c
-}
-a{
-  e f
-  g h
-}
-привет{
-  мир
-}
-y {
-  z
-}
-"мир"{
-  quoted, "yep".
-}
-привет has space{
-  \"and so does this" "have space"
-}
-"This is quoted"{
-  But still a valid list.
-}
-AlsoGood{
-}
-hi     {
-  Check this.
-}
-привет has space   {
-  ...
-}
-a{
-  a second "a".
-}
-also_empty{
 }
index a3d6a83..e69de29 100644 (file)
@@ -1,37 +0,0 @@
-empty{
-}
-d{
-  b c
-}
-a{
-  e f
-  g h
-}
-привет{
-  мир
-}
-y {
-  z
-}
-"мир"{
-  quoted, "yep".
-}
-привет has space{
-  \"and so does this" "have space"
-}
-"This is quoted"{
-  But still a valid list.
-}
-AlsoGood{
-}
-hi     {
-  Check this.
-}
-привет has space   {
-  ...
-}
-a{
-  a second "a".
-}
-also_empty{
-}
index a3d6a83..85a90f6 100644 (file)
@@ -1,37 +1 @@
-empty{
-}
-d{
-  b c
-}
 a{
-  e f
-  g h
-}
-привет{
-  мир
-}
-y {
-  z
-}
-"мир"{
-  quoted, "yep".
-}
-привет has space{
-  \"and so does this" "have space"
-}
-"This is quoted"{
-  But still a valid list.
-}
-AlsoGood{
-}
-hi     {
-  Check this.
-}
-привет has space   {
-  ...
-}
-a{
-  a second "a".
-}
-also_empty{
-}
index a3d6a83..b19e23b 100644 (file)
@@ -1,37 +1 @@
-empty{
-}
-d{
-  b c
-}
-a{
   e f
-  g h
-}
-привет{
-  мир
-}
-y {
-  z
-}
-"мир"{
-  quoted, "yep".
-}
-привет has space{
-  \"and so does this" "have space"
-}
-"This is quoted"{
-  But still a valid list.
-}
-AlsoGood{
-}
-hi     {
-  Check this.
-}
-привет has space   {
-  ...
-}
-a{
-  a second "a".
-}
-also_empty{
-}
index 0a7c3b0..85a90f6 100644 (file)
@@ -1,33 +1 @@
 a{
-a b привет
-c d
- # not a comment
- \\# nor is this.
-\# even this is not.
-привет мир a 
-  
- # a valid list:
-   with content.
-}
-a{
-  another "A" list.
-}
-"мир"{
-  quoted, "yep".
-}
-привет has space{
-  But this is not a comment.
-}
-empty{
-}
-hi{
-  not a list\:
-  a b привет
-  c d
-  привет мир a 
-
-}
-has spaces {
-  yep.
-  fin  
-}
index 0a7c3b0..e50021b 100644 (file)
@@ -1,33 +1 @@
-a{
 a b привет
-c d
- # not a comment
- \\# nor is this.
-\# even this is not.
-привет мир a 
-  
- # a valid list:
-   with content.
-}
-a{
-  another "A" list.
-}
-"мир"{
-  quoted, "yep".
-}
-привет has space{
-  But this is not a comment.
-}
-empty{
-}
-hi{
-  not a list\:
-  a b привет
-  c d
-  привет мир a 
-
-}
-has spaces {
-  yep.
-  fin  
-}
index 0a7c3b0..e69de29 100644 (file)
@@ -1,33 +0,0 @@
-a{
-a b привет
-c d
- # not a comment
- \\# nor is this.
-\# even this is not.
-привет мир a 
-  
- # a valid list:
-   with content.
-}
-a{
-  another "A" list.
-}
-"мир"{
-  quoted, "yep".
-}
-привет has space{
-  But this is not a comment.
-}
-empty{
-}
-hi{
-  not a list\:
-  a b привет
-  c d
-  привет мир a 
-
-}
-has spaces {
-  yep.
-  fin  
-}
index 0a7c3b0..311f4e4 100644 (file)
@@ -1,33 +1 @@
-a{
-a b привет
-c d
- # not a comment
- \\# nor is this.
-\# even this is not.
-привет мир a 
-  
- # a valid list:
-   with content.
-}
-a{
-  another "A" list.
-}
-"мир"{
-  quoted, "yep".
-}
-привет has space{
-  But this is not a comment.
-}
-empty{
-}
-hi{
-  not a list\:
-  a b привет
-  c d
-  привет мир a 
-
-}
-has spaces {
-  yep.
-  fin  
-}
+\\# even this is not.
index 0a7c3b0..9c5d8ed 100644 (file)
@@ -1,33 +1 @@
-a{
-a b привет
-c d
- # not a comment
- \\# nor is this.
-\# even this is not.
 привет мир a 
-  
- # a valid list:
-   with content.
-}
-a{
-  another "A" list.
-}
-"мир"{
-  quoted, "yep".
-}
-привет has space{
-  But this is not a comment.
-}
-empty{
-}
-hi{
-  not a list\:
-  a b привет
-  c d
-  привет мир a 
-
-}
-has spaces {
-  yep.
-  fin  
-}