]> Kevux Git Server - fll/commitdiff
Bugfix: FSS Basic Read needs to properly handle --total when using --select and also...
authorKevin Day <Kevin@kevux.org>
Tue, 13 Aug 2024 03:33:51 +0000 (22:33 -0500)
committerKevin Day <Kevin@kevux.org>
Tue, 13 Aug 2024 03:33:51 +0000 (22:33 -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_basic_read/c/private-read.c

index 613f03b598acb15da6d703c1d0263a4c2d5ec8cb..6f3830f7501b5ce0e0517a72ea9d6ac21812873e 100644 (file)
@@ -634,29 +634,54 @@ extern "C" {
   f_status_t fss_basic_read_process_total(fll_program_data_t * const main, fss_basic_read_data_t * const data, bool names[]) {
 
     f_array_length_t total = 0;
+    f_array_length_t i = 0;
 
-    for (f_array_length_t i = 0; i < data->objects.used; ++i) {
+    if (data->option & fss_basic_read_data_option_select_d) {
+      if (!data->select) {
+        for (; i < data->contents.used; ++i) {
 
-      if (!names[i]) continue;
+          if (!names[i]) continue;
 
-      if (!((++main->signal_check) % fss_basic_read_signal_check_d)) {
-        if (fll_program_standard_signal_received(main)) {
-          fss_basic_read_print_signal_received(main);
+          if (!((++main->signal_check) % fss_basic_read_signal_check_d)) {
+            if (fll_program_standard_signal_received(main)) {
+              fss_basic_read_print_signal_received(main);
 
-          return F_status_set_error(F_interrupt);
-        }
+              return F_status_set_error(F_interrupt);
+            }
 
-        main->signal_check = 0;
+            main->signal_check = 0;
+          }
+
+          if ((data->option & fss_basic_read_data_option_empty_d) || data->contents.array[i].used && data->contents.array[i].array[0].start <= data->contents.array[i].array[0].stop) {
+            ++total;
+          }
+        } // for
       }
+    }
+    else {
+      for (; i < data->objects.used; ++i) {
 
-      if (!(data->option & fss_basic_read_data_option_object_d) && data->option & fss_basic_read_data_option_content_d) {
-        if (!(data->contents.array[i].used || (data->option & fss_basic_read_data_option_empty_d))) {
-          continue;
+        if (!names[i]) continue;
+
+        if (!((++main->signal_check) % fss_basic_read_signal_check_d)) {
+          if (fll_program_standard_signal_received(main)) {
+            fss_basic_read_print_signal_received(main);
+
+            return F_status_set_error(F_interrupt);
+          }
+
+          main->signal_check = 0;
         }
-      }
 
-      ++total;
-    } // for
+        if (!(data->option & fss_basic_read_data_option_object_d) && data->option & fss_basic_read_data_option_content_d) {
+          if (!(data->contents.array[i].used || (data->option & fss_basic_read_data_option_empty_d))) {
+            continue;
+          }
+        }
+
+        ++total;
+      } // for
+    }
 
     flockfile(main->output.to.stream);