]> Kevux Git Server - fll/commitdiff
Update: FSS Read unit tests to handle trailing space when dealing with --line.
authorKevin Day <Kevin@kevux.org>
Tue, 20 Aug 2024 03:00:46 +0000 (22:00 -0500)
committerKevin Day <Kevin@kevux.org>
Tue, 20 Aug 2024 03:03:18 +0000 (22:03 -0500)
The tests now handle the `--line` parameter such that a trailing space is not printed.
The code is now updated to handle this behavior.

level_3/fss_read/c/main/print/data.c
level_3/fss_read/c/main/process_normal.c
level_3/fss_read/tests/runtime/fss_0000/expect/test-0001-unicode-object_and_content-line-6-original.expect
level_3/fss_read/tests/runtime/fss_0000/expect/test-0001-unicode-object_and_content-line-6.expect
level_3/fss_read/tests/runtime/fss_0001/expect/test-0001-unicode-object_and_content-line-6-original.expect
level_3/fss_read/tests/runtime/fss_0001/expect/test-0001-unicode-object_and_content-line-6.expect

index c9e2c84a70c03c8e9ef6ce84a10bdf85e5b8c69c..9476cfca21b6013af2d620593ae4ac709db9b2ae 100644 (file)
@@ -35,12 +35,12 @@ extern "C" {
         if (main->setting.select < main->setting.contents.array[at].used && main->setting.contents.array[at].array[main->setting.select].start <= main->setting.contents.array[at].array[main->setting.select].stop) {
           if (main->callback.print_content && main->callback.print_object_end_content) {
             if (print_state & 0x1) {
-              if (main->callback.print_object_end_content(&main->program.output, main->setting.contents.array[at].array[main->setting.select], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[main->setting.select] : 0, delimits_content) != F_output_not) {
+              if (F_status_set_fine(main->callback.print_object_end_content(&main->program.output, main->setting.contents.array[at].array[main->setting.select], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[main->setting.select] : 0, delimits_content)) != F_output_not) {
                 print_state |= 0x6;
               }
             }
             else {
-              if (main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[main->setting.select], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[main->setting.select] : 0, delimits_content) != F_output_not) {
+              if (F_status_set_fine(main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[main->setting.select], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[main->setting.select] : 0, delimits_content)) != F_output_not) {
                 print_state |= 0x2;
               }
             }
@@ -63,13 +63,12 @@ extern "C" {
               print_state &= ~0x8;
 
               if (print_state & 0x1) {
-                if (main->callback.print_object_end_content(&main->program.output, main->setting.contents.array[at].array[i], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content) != F_output_not) {
+                if (F_status_set_fine(main->callback.print_object_end_content(&main->program.output, main->setting.contents.array[at].array[i], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content)) != F_output_not) {
                   print_state |= 0x6;
                 }
               }
-              else {if (main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[i], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content) != F_output_not) {
-                  print_state |= 0x2;
-                }
+              else if (F_status_set_fine(main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[i], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content)) != F_output_not) {
+                print_state |= 0x2;
               }
 
               ++i;
index 157aa9e30d93949f7e6f6134cdfc36ebfe263918..22bfd550af7f112c9e35221402036071087ea433 100644 (file)
@@ -192,17 +192,22 @@ extern "C" {
 
     fss_read_main_t * const main = (fss_read_main_t *) void_main;
 
+    // 0x1 = object printed, 0x2 = content printed, 0x4 = object end printed, 0x8 = content is empty, 0x10 = select is out of range.
+    uint8_t print_state = 0x0;
+
     if (main->setting.flag & fss_read_main_flag_object_d) {
       if (*line == main->setting.line) {
         if (main->callback.print_object) {
-          main->callback.print_object(&main->program.output, at, delimits_object);
-        }
-
-        if (main->callback.print_object_end) {
-          main->callback.print_object_end(&main->program.output);
+          if (F_status_set_fine(main->callback.print_object(&main->program.output, at, delimits_object)) != F_output_not) {
+            print_state = 0x1;
+          }
         }
 
         if (!(main->setting.flag & fss_read_main_flag_content_d)) {
+          if (main->callback.print_object_end) {
+            main->callback.print_object_end(&main->program.output);
+          }
+
           if (!(main->setting.flag & fss_read_main_flag_object_as_line_d)) {
             if (main->callback.print_set_end) {
               main->callback.print_set_end(&main->program.output);
@@ -213,6 +218,12 @@ extern "C" {
 
           return;
         }
+
+        if (main->setting.flag & fss_read_main_flag_object_as_line_d && main->callback.print_object_end) {
+          if (F_status_set_fine(main->callback.print_object_end(&main->program.output)) != F_output_not) {
+            print_state = 0x4;
+          }
+        }
       }
 
       if ((main->setting.flag & fss_read_main_flag_object_as_line_d) || !(main->setting.flag & fss_read_main_flag_content_d)) {
@@ -279,16 +290,32 @@ extern "C" {
 
       if (main->setting.flag & fss_read_main_flag_line_single_d) {
         if (*line == main->setting.line) {
-          if (main->setting.contents.array[at].used) {
-            for (;;) {
+          if (main->setting.contents.array[at].used && main->callback.print_content && main->callback.print_object_end_content) {
+            for (f_status_t printed = F_okay; ; ) {
+
+              if (main->setting.contents.array[at].array[i].start <= main->setting.contents.array[at].array[i].stop) {
+                if ((print_state & 0x1) && !(print_state & 0x4)) {
+                  printed = main->callback.print_object_end_content(&main->program.output, main->setting.contents.array[at].array[i], main->setting.quotes_content.array[at].array[i], delimits_content);
+
+                  if (F_status_set_fine(printed) != F_output_not) {
+                    print_state |= 0x6;
+                  }
+                }
+                else {
+                  printed = main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[i], main->setting.quotes_content.array[at].array[i], delimits_content);
 
-              if (main->callback.print_content) {
-                main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[i], main->setting.quotes_content.array[at].array[i], delimits_content);
+                  if (F_status_set_fine(printed) != F_output_not) {
+                    print_state |= 0x2;
+                  }
+                }
+              }
+              else {
+                printed = F_output_not;
               }
 
               if (++i >= main->setting.contents.array[at].used) break;
 
-              if (main->callback.print_content_next) {
+              if (F_status_set_fine(printed) != F_output_not && main->callback.print_content_next) {
                 main->callback.print_content_next(&main->program.output);
               }
             } // for
@@ -305,7 +332,7 @@ extern "C" {
 
         ++(*line);
       }
-      else {
+      else if (main->callback.print_content && main->callback.print_object_end_content) {
         f_number_unsigned_t j = 0;
         f_number_unsigned_t k = 0;
 
@@ -336,7 +363,10 @@ extern "C" {
               if (*line == main->setting.line) {
                 main->setting.range.stop = j;
 
-                if (main->callback.print_content) {
+                if ((print_state & 0x1) && !(print_state & 0x4)) {
+                  main->callback.print_object_end_content(&main->program.output, main->setting.range, main->setting.quotes_content.array[at].array[i], delimits_content);
+                }
+                else {
                   main->callback.print_content(&main->program.output, main->setting.range, main->setting.quotes_content.array[at].array[i], delimits_content);
                 }