]> Kevux Git Server - fll/commitdiff
Bugfix: FSS Extended Read needs to properly handle --total when using --select and...
authorKevin Day <Kevin@kevux.org>
Tue, 13 Aug 2024 03:55:37 +0000 (22:55 -0500)
committerKevin Day <Kevin@kevux.org>
Tue, 13 Aug 2024 03:55:37 +0000 (22:55 -0500)
The use of --select 0 and --total should result in either 0 or 1.
The presence of --empty must also be taken into consideration.

level_3/fss_extended_read/c/private-read.c

index fc177850cc90c75198193502d0762fb2a5763217..fd9832551feb3ca007270f0a8657fc084dca3f05 100644 (file)
@@ -666,47 +666,101 @@ extern "C" {
   f_status_t fss_extended_read_process_total(fll_program_data_t * const main, fss_extended_read_data_t * const data, bool names[]) {
 
     f_array_length_t total = 0;
+    f_array_length_t i = 0;
 
-    // This standard only has one Content per line, however it has multiple Contents within that line.
-    if ((data->option & fss_extended_read_data_option_object_d) || (data->option & fss_extended_read_data_option_content_d) && (data->option & fss_extended_read_data_option_empty_d)) {
-      for (f_array_length_t i = 0; i < data->objects.used; ++i) {
+    if (data->option & fss_extended_read_data_option_select_d) {
+      for (; i < data->contents.used; ++i) {
 
         if (!names[i]) continue;
 
-        ++total;
+        if (!((++main->signal_check) % fss_extended_read_signal_check_d)) {
+          if (fll_program_standard_signal_received(main)) {
+            fss_extended_read_print_signal_received(main);
+
+            return F_status_set_error(F_interrupt);
+          }
+
+          main->signal_check = 0;
+        }
+
+        if (data->contents.array[i].used) {
+          if (data->select < data->contents.array[i].used) {
+            if ((data->option & fss_extended_read_data_option_empty_d) || data->contents.array[i].array[data->select].start <= data->contents.array[i].array[data->select].stop) {
+              ++total;
+            }
+          }
+        }
+        else if (!data->select && (data->option & fss_extended_read_data_option_empty_d)) {
+          ++total;
+        }
       } // for
     }
     else {
-      f_array_length_t i = 0;
-      f_array_length_t j = 0;
 
-      for (; i < data->contents.used; ++i) {
+      // This standard only has one Content per line, however it has multiple Contents within that line.
+      if ((data->option & fss_extended_read_data_option_object_d) || (data->option & fss_extended_read_data_option_content_d) && (data->option & fss_extended_read_data_option_empty_d)) {
+        for (; i < data->objects.used; ++i) {
 
-        if (!names[i]) continue;
-        if (!data->contents.array[i].used) continue;
+          if (!names[i]) continue;
 
-        if ((data->option & fss_extended_read_data_option_select_d) && data->contents.array[i].used <= data->select) {
-          continue;
-        }
+          if (!((++main->signal_check) % fss_extended_read_signal_check_d)) {
+            if (fll_program_standard_signal_received(main)) {
+              fss_extended_read_print_signal_received(main);
 
-        for (j = 0; j < data->contents.array[i].used; ++j) {
+              return F_status_set_error(F_interrupt);
+            }
 
-          if (data->contents.array[i].array[j].start <= data->contents.array[i].array[j].stop) {
-            if (data->option & fss_extended_read_data_option_select_d) {
-              if (j == data->select) {
-                ++total;
+            main->signal_check = 0;
+          }
 
-                break;
-              }
+          ++total;
+        } // for
+      }
+      else {
+        for (f_array_length_t j = 0; i < data->contents.used; ++i) {
+
+          if (!names[i]) continue;
+          if (!data->contents.array[i].used) continue;
+
+          if (!((++main->signal_check) % fss_extended_read_signal_check_d)) {
+            if (fll_program_standard_signal_received(main)) {
+              fss_extended_read_print_signal_received(main);
+
+              return F_status_set_error(F_interrupt);
             }
-            else {
-              ++total;
 
-              break;
+            main->signal_check = 0;
+          }
+
+          if (data->option & fss_extended_read_data_option_select_d) {
+            if (data->select < data->contents.array[i].used) {
+              if (data->contents.array[i].array[data->select].start <= data->contents.array[data->select].array[j].stop) {
+                ++total;
+              }
             }
           }
+          else {
+            for (j = 0; j < data->contents.array[i].used; ++j) {
+
+              if (!((++main->signal_check) % fss_extended_read_signal_check_d)) {
+                if (fll_program_standard_signal_received(main)) {
+                  fss_extended_read_print_signal_received(main);
+
+                  return F_status_set_error(F_interrupt);
+                }
+
+                main->signal_check = 0;
+              }
+
+              if (data->contents.array[i].array[j].start <= data->contents.array[i].array[j].stop) {
+                ++total;
+
+                break;
+              }
+            } // for
+          }
         } // for
-      } // for
+      }
     }
 
     flockfile(main->output.to.stream);