]> 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 43b76bb177c86eacda6bdc0baaf302f11b7ac1bd..37f44ffa07b491f169b343b09b495629632f4591 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 65b0a48c6425f622a732200ffd9e43a94511843a..c6cac69265af1e1684d2e3038f8fc90b84c87e9c 100644 (file)
@@ -1,13 +1 @@
 empty
-d
-a
-привет
-y 
-"мир"
-привет has space
-"This is quoted"
-AlsoGood
-hi     
-привет has space   
-a
-also_empty
index 65b0a48c6425f622a732200ffd9e43a94511843a..4bcfe98e640c8284511312660fb8709b0afa888e 100644 (file)
@@ -1,13 +1 @@
-empty
 d
-a
-привет
-y 
-"мир"
-привет has space
-"This is quoted"
-AlsoGood
-hi     
-привет has space   
-a
-also_empty
index 65b0a48c6425f622a732200ffd9e43a94511843a..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,13 +0,0 @@
-empty
-d
-a
-привет
-y 
-"мир"
-привет has space
-"This is quoted"
-AlsoGood
-hi     
-привет has space   
-a
-also_empty
index 65b0a48c6425f622a732200ffd9e43a94511843a..2057e0fc84fd3f1879cd95acf6fcd56a2c2d6990 100644 (file)
@@ -1,13 +1 @@
-empty
-d
-a
-привет
-y 
 "мир"
-привет has space
-"This is quoted"
-AlsoGood
-hi     
-привет has space   
-a
-also_empty
index 65b0a48c6425f622a732200ffd9e43a94511843a..9a900be18a57f65d342d2aa71d5c2c14cf81284c 100644 (file)
@@ -1,13 +1 @@
-empty
-d
-a
-привет
-y 
-"мир"
 привет has space
-"This is quoted"
-AlsoGood
-hi     
-привет has space   
-a
-also_empty
index a3d6a83895d0106cc7e163b51eb098074a41f8c7..fec53807c5792051ae3700b41a041aefee372170 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 a3d6a83895d0106cc7e163b51eb098074a41f8c7..5c34318c2147fb2285de5a1513f46168e33e6baf 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 a3d6a83895d0106cc7e163b51eb098074a41f8c7..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 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 a3d6a83895d0106cc7e163b51eb098074a41f8c7..85a90f60060215520429ea5a6e9cbe08ca6b2462 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 a3d6a83895d0106cc7e163b51eb098074a41f8c7..b19e23b2804b69a5ebf485a3df3e37a503f9a225 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 0a7c3b0cd76bd418f0aff3871b5f52b91a2f32a6..85a90f60060215520429ea5a6e9cbe08ca6b2462 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 0a7c3b0cd76bd418f0aff3871b5f52b91a2f32a6..e50021b658bf269f7c01e3e12849ee0b59bfdfa7 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 0a7c3b0cd76bd418f0aff3871b5f52b91a2f32a6..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 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 0a7c3b0cd76bd418f0aff3871b5f52b91a2f32a6..311f4e4f29a46a41a8b6173eb08312ea36aca3f3 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 0a7c3b0cd76bd418f0aff3871b5f52b91a2f32a6..9c5d8edc475bd18caf4901da7dc3bc58c901b69a 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  
-}