]> Kevux Git Server - fll/commitdiff
Progress: Continue working on getting FSS Embedded Read working.
authorKevin Day <Kevin@kevux.org>
Sat, 24 Aug 2024 03:18:33 +0000 (22:18 -0500)
committerKevin Day <Kevin@kevux.org>
Sat, 24 Aug 2024 03:18:33 +0000 (22:18 -0500)
I noticed that I forgot that I had intentionally set the size of the static array to 777 to try and trigger any problems.
I forgot about that and committed this in my previous progress commit.
This is now restored to a valid value.

This adds additional checks to the quotes and delimits arrays.
These are used in such a way that they much match the length of the Objects and Contents.
The current, incomplete, design with the FSS Embedded Read is copying over the Objects and Contents but has not yet properly set the delimits and quotes.
This exposes that there needs to be explicit checks between the loosely associated Objects and Contents with the delimits and quotes.

I noticed that the `--object` should always result in showing things even if the `--select` number is infinitely large but does not.
This is now fixed so that it always does this.
The runtime tests are updated as appropriate.

32 files changed:
level_3/fss_read/c/embedded_list/process_normal.c
level_3/fss_read/c/main/common/define.h
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-name-hi-select-0-total.expect
level_3/fss_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name--select-1-total.expect
level_3/fss_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-100-total.expect
level_3/fss_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-2-total.expect
level_3/fss_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-5-total.expect
level_3/fss_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-6-total.expect
level_3/fss_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-100-total.expect
level_3/fss_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-2-total.expect
level_3/fss_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-5-total.expect
level_3/fss_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-6-total.expect
level_3/fss_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-hi-select-0-total.expect
level_3/fss_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-hi-select-1-empty-total.expect
level_3/fss_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-hi-select-1-total.expect
level_3/fss_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-мир-select-1-total.expect
level_3/fss_read/tests/runtime/fss_0008/expect/test-0001-empty_name_list-content-columns-empty.expect
level_3/fss_read/tests/runtime/fss_0008/expect/test-0001-empty_name_list-content-name-a-columns.expect
level_3/fss_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name--select-1-total.expect
level_3/fss_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name-a-select-0-total.expect
level_3/fss_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name-a-select-1-total.expect
level_3/fss_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name-a-select-100-total.expect
level_3/fss_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name-a-select-2-total.expect
level_3/fss_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name-a-select-5-total.expect
level_3/fss_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name-a-select-6-total.expect
level_3/fss_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name-hi-select-1-empty-total.expect
level_3/fss_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name-hi-select-1-total.expect
level_3/fss_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name-payload-select-1-total.expect
level_3/fss_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name-мир-select-1-total.expect
level_3/fss_read/tests/runtime/fss_0008/expect/test-0002-mixed-content-name-привет_has_space-select-1-total.expect

index 398bd303a0bc8fd1eb401b77fc64ff65a61f9201..ecdf5452d4825bf91d94c58f5035504c79a8299d 100644 (file)
@@ -134,11 +134,11 @@ extern "C" {
       main->setting.objects.array[main->setting.objects.used] = main->setting.nest.depth[0].array[main->setting.objects.used].object;
 
       // Use a static array for the inner Content that points to the depth, and so ensure the size is 0 to designate this is not dynamically allocated here.
-      if (main->setting.nest.depth[0].array[main->setting.objects.used].content.size) {
+      if (main->setting.nest.depth[0].array[main->setting.objects.used].content.used) {
         main->setting.contents.array[main->setting.objects.used].array = main->setting.nest.depth[0].array[main->setting.objects.used].content.array;
         main->setting.contents.array[main->setting.objects.used].used = main->setting.nest.depth[0].array[main->setting.objects.used].content.used;
         main->setting.contents.array[main->setting.objects.used].size = 0;
-        main->setting.contents.array[main->setting.objects.used].used = 777;
+        main->setting.contents.array[main->setting.objects.used].used = main->setting.nest.depth[0].array[main->setting.objects.used].content.used;
       }
       else {
         main->setting.contents.array[main->setting.objects.used].array = 0;
index 4ed94e63b0c01d8161086a5a99b0c80bca6dc18e..8255b37abf0e794fb72f84ae20d56b80908ed36f 100644 (file)
@@ -78,6 +78,7 @@ extern "C" {
  *   - quote_content:          Designate that the standard supports quotes on Content.
  *   - quote_object:           Designate that the standard supports quotes on Objects.
  *   - select:                 A specific Content at a given position is to be selected (Think of this as select a column for some Content).
+ *   - select_content:         A helper flag representing select and content flag bits being set.
  *   - total:                  The total lines found and selected is printed instead of the Content.
  *   - trim:                   Empty space before and after Objects and Content will not be printed (They will be trimmed).
  *   - trim_object:            Empty space before and after Objects (but not Content) will not be printed (They will be trimmed).
@@ -113,6 +114,7 @@ extern "C" {
   #define fss_read_main_flag_quote_content_d          0x1000000
   #define fss_read_main_flag_quote_object_d           0x2000000
   #define fss_read_main_flag_select_d                 0x4000000
+  #define fss_read_main_flag_select_content_d         0x4000004
   #define fss_read_main_flag_total_d                  0x8000000
   #define fss_read_main_flag_trim_d                   0x10000000
   #define fss_read_main_flag_trim_object_d            0x20000000
index 4521b3e50a8179b95a6ba19749c3b9d146bcb332..235675634b99577680ef0ec02bf6c40fa7ec8ec2 100644 (file)
@@ -35,12 +35,26 @@ 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 (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) {
+              if (F_status_set_fine(
+                main->callback.print_object_end_content(
+                  &main->program.output,
+                  main->setting.contents.array[at].array[main->setting.select],
+                  (at < main->setting.quotes_content.used && 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 (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) {
+              if (F_status_set_fine(
+                main->callback.print_content(
+                  &main->program.output,
+                  main->setting.contents.array[at].array[main->setting.select],
+                  (at < main->setting.quotes_content.used && 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,11 +77,25 @@ extern "C" {
               print_state &= ~0x8;
 
               if (print_state & 0x1) {
-                if (F_status_set_fine(main->callback.print_object_end_content(&main->program.output, main->setting.contents.array[at].array[i], (at < main->setting.quotes_content.used && 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],
+                    (at < main->setting.quotes_content.used && 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 (F_status_set_fine(main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[i], (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content)) != F_output_not) {
+              else if (F_status_set_fine(
+                main->callback.print_content(
+                  &main->program.output,
+                  main->setting.contents.array[at].array[i],
+                  (at < main->setting.quotes_content.used && 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;
               }
 
@@ -80,14 +108,18 @@ extern "C" {
           for (; i < main->setting.contents.array[at].used; ++i) {
 
             if (fss_read_signal_check(main)) return F_status_set_error(F_interrupt);
+            if (main->setting.contents.array[at].array[i].start > main->setting.contents.array[at].array[i].stop) continue;
 
-            if (main->setting.contents.array[at].array[i].start <= main->setting.contents.array[at].array[i].stop) {
-              if (main->callback.print_content_next) {
-                main->callback.print_content_next(&main->program.output);
-              }
-
-              main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[i], (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content);
+            if (main->callback.print_content_next) {
+              main->callback.print_content_next(&main->program.output);
             }
+
+            main->callback.print_content(
+              &main->program.output,
+              main->setting.contents.array[at].array[i],
+              (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0,
+              delimits_content
+            );
           } // for
         }
       }
@@ -223,13 +255,13 @@ extern "C" {
 
     if (main->setting.flag & (fss_read_main_flag_trim_d | fss_read_main_flag_trim_object_d)) {
       if (main->setting.flag & fss_read_main_flag_original_d) {
-        if (main->setting.quotes_object.array[at]) {
+        if (at < main->setting.quotes_object.used && main->setting.quotes_object.array[at]) {
           fss_read_print_quote(&main->program.output, main->setting.quotes_object.array[at]);
         }
 
         fll_print_trim_dynamic_partial(main->setting.buffer, main->setting.objects.array[at], main->program.output.to);
 
-        if (main->setting.quotes_object.array[at]) {
+        if (at < main->setting.quotes_object.used && main->setting.quotes_object.array[at]) {
           fss_read_print_quote(&main->program.output, main->setting.quotes_object.array[at]);
         }
       }
@@ -239,13 +271,13 @@ extern "C" {
     }
     else {
       if (main->setting.flag & fss_read_main_flag_original_d) {
-        if (main->setting.quotes_object.array[at]) {
+        if (at < main->setting.quotes_object.used && main->setting.quotes_object.array[at]) {
           fss_read_print_quote(&main->program.output, main->setting.quotes_object.array[at]);
         }
 
         fll_print_dynamic_partial(main->setting.buffer, main->setting.objects.array[at], main->program.output.to);
 
-        if (main->setting.quotes_object.array[at]) {
+        if (at < main->setting.quotes_object.used && main->setting.quotes_object.array[at]) {
           fss_read_print_quote(&main->program.output, main->setting.quotes_object.array[at]);
         }
       }
index 22bfd550af7f112c9e35221402036071087ea433..4a36a89295f16ae43b06ae49de01fabe78a591f5 100644 (file)
@@ -295,14 +295,14 @@ extern "C" {
 
               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);
+                  printed = main->callback.print_object_end_content(&main->program.output, main->setting.contents.array[at].array[i], (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, 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);
+                  printed = main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[i], (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content);
 
                   if (F_status_set_fine(printed) != F_output_not) {
                     print_state |= 0x2;
@@ -364,10 +364,10 @@ extern "C" {
                 main->setting.range.stop = j;
 
                 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);
+                  main->callback.print_object_end_content(&main->program.output, main->setting.range, (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content);
                 }
                 else {
-                  main->callback.print_content(&main->program.output, main->setting.range, main->setting.quotes_content.array[at].array[i], delimits_content);
+                  main->callback.print_content(&main->program.output, main->setting.range, (at < main->setting.quotes_content.used && i < main->setting.quotes_content.array[at].used) ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content);
                 }
 
                 main->setting.state.status = F_success;
@@ -533,7 +533,7 @@ extern "C" {
     f_number_unsigned_t total = 0;
     f_number_unsigned_t i = 0;
 
-    if (main->setting.flag & fss_read_main_flag_select_d) {
+    if ((main->setting.flag & fss_read_main_flag_select_content_d) == fss_read_main_flag_select_content_d) {
       for (; i < main->setting.contents.used; ++i) {
 
         if (!names[i]) continue;
@@ -555,20 +555,38 @@ extern "C" {
         }
       } // for
     }
-    else {
-      for (; i < main->setting.objects.used; ++i) {
+    else if (main->setting.flag & fss_read_main_flag_at_d) {
+      for (f_number_unsigned_t at = 0; i < main->setting.objects.used; ++i) {
 
         if (!names[i]) continue;
         if (fss_read_signal_check(main)) return;
 
-        if (main->setting.flag & fss_read_main_flag_at_d) {
-          if (main->setting.depths.array[0].value_at != i) continue;
+        // @fixme all uses of "depths" may need to be changed so that standards that handle depth and those that don't select the currect structure at places like this.
+        if (at < main->setting.depths.array[0].value_at) {
+          ++at;
+
+          continue;
         }
 
         if (!(main->setting.flag & fss_read_main_flag_object_d) && (main->setting.flag & fss_read_main_flag_content_d)) {
           if (!(main->setting.contents.array[i].used || (main->setting.flag & fss_read_main_flag_empty_d))) continue;
         }
 
+        total = 1;
+
+        break;
+      } // for
+    }
+    else {
+      for (; i < main->setting.objects.used; ++i) {
+
+        if (!names[i]) continue;
+        if (fss_read_signal_check(main)) return;
+
+        if (!(main->setting.flag & fss_read_main_flag_object_d) && (main->setting.flag & fss_read_main_flag_content_d)) {
+          if (!(main->setting.contents.array[i].used || (main->setting.flag & fss_read_main_flag_empty_d))) continue;
+        }
+
         ++total;
       } // for
     }
@@ -592,67 +610,97 @@ extern "C" {
     fss_read_main_t * const main = (fss_read_main_t *) void_main;
 
     f_number_unsigned_t total = 0;
-    f_range_t range = f_range_t_initialize;
-    f_number_unsigned_t i = 0;
-    f_number_unsigned_t j = 0;
-    f_number_unsigned_t k = 0;
+    f_number_unsigned_t at = 0;
 
-    for (f_number_unsigned_t at = 0; at < main->setting.contents.used; ++at) {
+    if (main->setting.flag & fss_read_main_flag_content_d) {
+      f_number_unsigned_t i = 0;
+      f_number_unsigned_t j = 0;
+      f_number_unsigned_t k = 0;
 
-      if (!names[at]) continue;
-      if (fss_read_signal_check(main)) return;
+      f_range_t range = f_range_t_initialize;
 
-      if (main->setting.flag & fss_read_main_flag_at_d) {
-        if (main->setting.depths.array[0].value_at != at) continue;
-      }
+      for (; at < main->setting.contents.used; ++at) {
 
-      if (main->setting.flag & fss_read_main_flag_object_d) {
-        ++total;
-      }
+        if (!names[at]) continue;
+        if (fss_read_signal_check(main)) return;
 
-      if (main->setting.flag & fss_read_main_flag_content_d) {
-        if (!main->setting.contents.array[at].used) continue;
+        if (main->setting.flag & fss_read_main_flag_at_d) {
+          if (main->setting.depths.array[0].value_at != at) continue;
+        }
 
-        for (i = 0; i < main->setting.contents.array[at].used; ++i) {
+        if (main->setting.flag & fss_read_main_flag_object_d) {
+          if (!(main->setting.flag & fss_read_main_flag_content_d)) {
+            ++total;
 
-          if (fss_read_signal_check(main)) return;
+            continue;
+          }
 
-          range.start = main->setting.contents.array[at].array[i].start;
-          range.stop = main->setting.contents.array[at].array[i].stop;
+          if (main->setting.flag & fss_read_main_flag_object_as_line_d) {
+            ++total;
+          }
+        }
 
-          // This content has no data, do not even check "include empty" because it cannot be counted as a line.
-          if (range.start > range.stop) continue;
+        if (main->setting.flag & fss_read_main_flag_content_d) {
+          if (!main->setting.contents.array[at].used) continue;
 
-          for (j = range.start; j <= range.stop; ++j) {
+          for (i = 0; i < main->setting.contents.array[at].used; ++i) {
 
-            if (k < main->setting.comments.used) {
-              while (k < main->setting.comments.used && main->setting.comments.array[k].stop < j) ++k;
+            if (fss_read_signal_check(main)) return;
+
+            range.start = main->setting.contents.array[at].array[i].start;
+            range.stop = main->setting.contents.array[at].array[i].stop;
+
+            // This content has no data, and so do not even check "include empty" because it cannot be counted as a line.
+            if (range.start > range.stop) continue;
+
+            for (j = range.start; j <= range.stop; ++j) {
 
               if (k < main->setting.comments.used) {
-                if (j >= main->setting.comments.array[k].start && j <= main->setting.comments.array[k].stop) {
-                  j = main->setting.comments.array[k++].stop;
+                while (k < main->setting.comments.used && main->setting.comments.array[k].stop < j) ++k;
 
-                  continue;
+                if (k < main->setting.comments.used) {
+                  if (j >= main->setting.comments.array[k].start && j <= main->setting.comments.array[k].stop) {
+                    j = main->setting.comments.array[k++].stop;
+
+                    continue;
+                  }
                 }
               }
-            }
 
-            if (main->setting.buffer.string[j] == f_string_eol_s.string[0]) ++total;
+              if (main->setting.buffer.string[j] == f_string_eol_s.string[0]) ++total;
+            } // for
           } // for
-        } // for
 
-        // If Content does not end with a newline, it still must be treated as the last line.
-        if ((main->setting.flag & fss_read_main_flag_line_single_d) && i) {
-          j = main->setting.contents.array[at].array[i - 1].stop;
+          // Treat Content as the last line even if it does not end with a new line.
+          if ((main->setting.flag & fss_read_main_flag_line_single_d) && i) {
+            j = main->setting.contents.array[at].array[i - 1].stop;
+
+            if (main->setting.buffer.string[j] != f_string_eol_s.string[0]) ++total;
+          }
 
-          if (main->setting.buffer.string[j] != f_string_eol_s.string[0]) ++total;
+          if ((main->setting.flag & fss_read_main_flag_object_d) && (main->setting.flag & fss_read_main_flag_content_has_close_d)) {
+            ++total;
+          }
         }
+      } // for
+    }
+    else {
+      for (; at < main->setting.objects.used; ++at) {
+
+        if (!names[at]) continue;
+        if (fss_read_signal_check(main)) return;
 
-        if ((main->setting.flag & fss_read_main_flag_object_d) && (main->setting.flag & fss_read_main_flag_content_has_close_d)) {
-           ++total;
+        if (main->setting.flag & fss_read_main_flag_at_d) {
+          if (main->setting.depths.array[0].value_at != at) continue;
         }
-      }
-    } // for
+
+        if (!(main->setting.flag & fss_read_main_flag_object_d) && (main->setting.flag & fss_read_main_flag_content_d)) {
+          if (!(main->setting.contents.array[at].used || (main->setting.flag & fss_read_main_flag_empty_d))) continue;
+        }
+
+        ++total;
+      } // for
+    }
 
     fss_read_print_number(
       &main->program.output,