]> Kevux Git Server - fll/commitdiff
Bugfix: Performance is slow due to process signal checks.
authorKevin Day <thekevinday@gmail.com>
Thu, 9 Dec 2021 05:21:57 +0000 (23:21 -0600)
committerKevin Day <thekevinday@gmail.com>
Thu, 9 Dec 2021 05:21:57 +0000 (23:21 -0600)
The cost of the system call for checking if a signal is received is more expensive than I have previously imagined.
I also was not sure where I should handle the signals and I arbitrarily put them inside loops.

Reduce the number of checks.
Reduce the number of the system call to check the process signal using modulus math.

The performance difference is most notable when using the byte_dump program.

This focuses on solving the immediate performance bug.
I still have not done any extensive performance investigations and I expect this to still have significant room for improvement.

41 files changed:
level_3/byte_dump/c/byte_dump.h
level_3/byte_dump/c/private-byte_dump.c
level_3/fake/c/fake.c
level_3/fake/c/fake.h
level_3/fake/c/private-build.c
level_3/fake/c/private-fake.c
level_3/fake/c/private-make.c
level_3/fake/c/private-skeleton.c
level_3/firewall/c/firewall.h
level_3/firewall/c/private-firewall.c
level_3/fss_basic_list_read/c/fss_basic_list_read.h
level_3/fss_basic_list_write/c/fss_basic_list_write.h
level_3/fss_basic_read/c/fss_basic_read.h
level_3/fss_basic_write/c/fss_basic_write.h
level_3/fss_embedded_list_read/c/fss_embedded_list_read.h
level_3/fss_embedded_list_write/c/fss_embedded_list_write.h
level_3/fss_extended_list_read/c/fss_extended_list_read.h
level_3/fss_extended_list_write/c/fss_extended_list_write.h
level_3/fss_extended_read/c/fss_extended_read.c
level_3/fss_extended_read/c/fss_extended_read.h
level_3/fss_extended_read/c/private-fss_extended_read.c
level_3/fss_extended_write/c/fss_extended_write.c
level_3/fss_extended_write/c/fss_extended_write.h
level_3/fss_extended_write/c/private-fss_extended_write.c
level_3/fss_identify/c/fss_identify.c
level_3/fss_identify/c/fss_identify.h
level_3/fss_identify/c/private-fss_identify.c
level_3/fss_status_code/c/fss_status_code.c
level_3/fss_status_code/c/fss_status_code.h
level_3/iki_read/c/iki_read.c
level_3/iki_read/c/iki_read.h
level_3/iki_read/c/private-iki_read.c
level_3/iki_write/c/iki_write.c
level_3/iki_write/c/iki_write.h
level_3/status_code/c/status_code.c
level_3/status_code/c/status_code.h
level_3/utf8/c/private-utf8.c
level_3/utf8/c/private-utf8_binary.c
level_3/utf8/c/private-utf8_codepoint.c
level_3/utf8/c/utf8.c
level_3/utf8/c/utf8.h

index 0e43e6fbfbc1077f415e24c8845277293e5d818c..a22b3726f74995107d36adfad55d78bd3a9096ea 100644 (file)
@@ -95,6 +95,8 @@ extern "C" {
 
   #define byte_dump_option_wide_d 0x1
 
+  #define byte_dump_signal_check_d 10000
+
   #define byte_dump_sequence_acknowledge_s               "␆"
   #define byte_dump_sequence_acknowledge_negative_s      "␕"
   #define byte_dump_sequence_backspace_s                 "␈"
index e31e9061004e09ca127232e7ec26219abb5a70d9..955b25a9c858936829f51b538337e0fe136abf7b 100644 (file)
@@ -57,10 +57,14 @@ extern "C" {
     memset(&invalid, 0, sizeof(char) * main->width);
 
     if (byte_get >= 0) {
-      for (;;) {
+      for (uint16_t signal_check = 0; ; ) {
 
-        if (byte_dump_signal_received(main)) {
-          return F_status_set_error(F_interrupt);
+        if (!((++signal_check) % byte_dump_signal_check_d)) {
+          if (byte_dump_signal_received(main)) {
+            return F_status_set_error(F_interrupt);
+          }
+
+          signal_check = 0;
         }
 
         byte_get = getc(file.stream);
index e4cb8ae4a0ffe47856463e51e7de824f446a2e6e..a38749a59eeea23b92ca7537b604fc0af44763d5 100644 (file)
@@ -336,7 +336,7 @@ extern "C" {
         if (status == F_child) {
           break;
         }
-        else if (F_status_set_fine(status) == F_interrupt || fake_signal_received(main)) {
+        else if (F_status_set_fine(status) == F_interrupt || !(i % fake_signal_check_short_d) && fake_signal_received(main)) {
           status = F_status_set_error(F_interrupt);
           break;
         }
index ccca3e90d29de3ccd710227b0f3ca5a465880ee0..0b2d1a5724d23dbd5c955c66e132b04cef689289 100644 (file)
@@ -240,6 +240,10 @@ extern "C" {
     fake_operation_skeleton,
   };
 
+  #define fake_signal_check_d 10000
+  #define fake_signal_check_tiny_d  4
+  #define fake_signal_check_short_d 16
+
   #define fake_operations_total_d    4
   #define fake_operations_initialize { 0, 0, 0, 0 }
 
@@ -396,6 +400,7 @@ extern "C" {
     f_signal_t signal;
 
     uint8_t operation;
+    uint16_t signal_check;
 
     mode_t umask;
     int child;
@@ -468,6 +473,7 @@ extern "C" {
       0, \
       0, \
       0, \
+      0, \
       f_string_dynamics_t_initialize, \
       f_string_dynamic_t_initialize, \
       f_string_dynamics_t_initialize, \
index d1b22e05d1c011dee008288246b15b4aa8bb00cf..48cd201648506df29c25baff050c3ca3b70a5a15 100644 (file)
@@ -328,6 +328,11 @@ extern "C" {
 
     for (f_array_length_t i = 0; i < files.used; ++i) {
 
+      if (!(i % fake_signal_check_short_d) && fake_signal_received(main)) {
+        *status = F_status_set_error(F_interrupt);
+        break;
+      }
+
       if (!files.array[i].used) continue;
 
       path_source.used = source.used;
@@ -346,11 +351,6 @@ extern "C" {
         break;
       }
 
-      if (fake_signal_received(main)) {
-        *status = F_status_set_error(F_interrupt);
-        break;
-      }
-
       *status = f_directory_is(path_source.string);
 
       if (*status == F_true) {
@@ -461,11 +461,6 @@ extern "C" {
           break;
         }
 
-        if (fake_signal_received(main)) {
-          *status = F_status_set_error(F_interrupt);
-          break;
-        }
-
         *status = f_file_copy(path_source.string, destination_file.string, mode, F_file_default_read_size_d, F_false);
 
         if (F_status_is_error(*status)) {
@@ -550,12 +545,6 @@ extern "C" {
 
       if (!directorys[i]->used) continue;
 
-      if (fake_signal_received(main)) {
-        *status = F_status_set_error(F_interrupt);
-
-        return;
-      }
-
       // @todo implement this in a common function and use across project for creating parent directories.
       for (f_array_length_t j = 0; j < directorys[i]->used; ++j) {
 
@@ -788,48 +777,40 @@ extern "C" {
 
     int return_code = 0;
 
-    if (fake_signal_received(main)) {
-      *status = F_status_set_error(F_interrupt);
-
-      macro_f_string_dynamic_t_delete_simple(path);
-      macro_f_string_dynamics_t_delete_simple(arguments);
-    }
-    else {
-      // child processes should receive all signals, without blocking.
-      f_signal_how_t signals = f_signal_how_t_initialize;
-      f_signal_set_empty(&signals.block);
-      f_signal_set_fill(&signals.block_not);
+    // Child processes should receive all signals, without blocking.
+    f_signal_how_t signals = f_signal_how_t_initialize;
+    f_signal_set_empty(&signals.block);
+    f_signal_set_fill(&signals.block_not);
 
-      fl_execute_parameter_t parameter = macro_fl_execute_parameter_t_initialize(FL_execute_parameter_option_path_d, 0, &data_build.environment, &signals, 0);
+    fl_execute_parameter_t parameter = macro_fl_execute_parameter_t_initialize(FL_execute_parameter_option_path_d, 0, &data_build.environment, &signals, 0);
 
-      *status = fll_execute_program(path.string, arguments, &parameter, 0, (void *) &return_code);
+    *status = fll_execute_program(path.string, arguments, &parameter, 0, (void *) &return_code);
 
-      macro_f_string_dynamics_t_delete_simple(arguments);
+    macro_f_string_dynamics_t_delete_simple(arguments);
 
-      if (fake_signal_received(main)) {
-        *status = F_status_set_error(F_interrupt);
-      }
-      else if (*status != F_child) {
-        if (F_status_is_error(*status)) {
-          if (F_status_set_fine(*status) == F_failure) {
-            if (main->error.verbosity != f_console_verbosity_quiet) {
-              flockfile(main->error.to.stream);
+    if (fake_signal_received(main)) {
+      *status = F_status_set_error(F_interrupt);
+    }
+    else if (*status != F_child) {
+      if (F_status_is_error(*status)) {
+        if (F_status_set_fine(*status) == F_failure) {
+          if (main->error.verbosity != f_console_verbosity_quiet) {
+            flockfile(main->error.to.stream);
 
-              fl_print_format("%c%[%SFailed to execute script: '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context);
-              fl_print_format("%[%Q%]", main->error.to.stream, main->error.notable, path, main->error.notable);
-              fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]);
+            fl_print_format("%c%[%SFailed to execute script: '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix, main->error.context);
+            fl_print_format("%[%Q%]", main->error.to.stream, main->error.notable, path, main->error.notable);
+            fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]);
 
-              funlockfile(main->error.to.stream);
-            }
-          }
-          else {
-            fll_error_print(main->error, F_status_set_fine(*status), "fll_execute_program", F_true);
+            funlockfile(main->error.to.stream);
           }
         }
         else {
-          fake_build_touch(main, file_stage, status);
+          fll_error_print(main->error, F_status_set_fine(*status), "fll_execute_program", F_true);
         }
       }
+      else {
+        fake_build_touch(main, file_stage, status);
+      }
     }
 
     macro_f_string_dynamic_t_delete_simple(path);
@@ -1242,12 +1223,6 @@ extern "C" {
 
       parameter_file_path[parameter_file_path_length] = 0;
 
-      if (fake_signal_received(main)) {
-        *status = F_status_set_error(F_interrupt);
-
-        return 0;
-      }
-
       *status = f_file_link(parameter_file_name_major, parameter_file_path);
 
       if (F_status_is_error_not(*status) && main->error.verbosity == f_console_verbosity_verbose) {
@@ -1277,12 +1252,6 @@ extern "C" {
 
       parameter_file_path[parameter_file_path_length] = 0;
 
-      if (fake_signal_received(main)) {
-        *status = F_status_set_error(F_interrupt);
-
-        return 0;
-      }
-
       *status = f_file_link(parameter_file_name_minor, parameter_file_path);
 
       if (F_status_is_error_not(*status) && main->error.verbosity == f_console_verbosity_verbose) {
@@ -1311,12 +1280,6 @@ extern "C" {
 
         parameter_file_path[parameter_file_path_length] = 0;
 
-        if (fake_signal_received(main)) {
-          *status = F_status_set_error(F_interrupt);
-
-          return 0;
-        }
-
         *status = f_file_link(parameter_file_name_micro, parameter_file_path);
 
         if (F_status_is_error_not(*status) && main->error.verbosity == f_console_verbosity_verbose) {
@@ -1345,12 +1308,6 @@ extern "C" {
 
           parameter_file_path[parameter_file_path_length] = 0;
 
-          if (fake_signal_received(main)) {
-            *status = F_status_set_error(F_interrupt);
-
-            return 0;
-          }
-
           *status = f_file_link(parameter_file_name_nano, parameter_file_path);
 
           if (F_status_is_error_not(*status) && main->error.verbosity == f_console_verbosity_verbose) {
@@ -1448,11 +1405,6 @@ extern "C" {
             break;
           }
 
-          if (fake_signal_received(main)) {
-            *status = F_status_set_error(F_interrupt);
-            break;
-          }
-
           *status = f_file_name_directory(sources[i]->array[j].string, sources[i]->array[j].used, &source_path);
 
           if (F_status_is_error(*status)) {
@@ -1629,10 +1581,7 @@ extern "C" {
         *status = fake_file_buffer(main, main->file_data_build_settings.string, &buffer);
       }
 
-      if (fake_signal_received(main)) {
-        *status = F_status_set_error(F_interrupt);
-      }
-      else if (F_status_is_error_not(*status)) {
+      if (F_status_is_error_not(*status)) {
         f_string_range_t range = macro_f_string_range_t_initialize(buffer.used);
         f_fss_delimits_t delimits = f_fss_delimits_t_initialize;
 
@@ -2171,7 +2120,7 @@ extern "C" {
         fll_error_print(main->error, F_status_set_fine(*status), function, F_true);
       }
     }
-    else if (!fake_signal_received(main)) {
+    else {
       const f_string_t settings_single_name[] = {
         fake_build_setting_name_build_compiler_s,
         fake_build_setting_name_build_indexer_s,
@@ -2919,10 +2868,6 @@ extern "C" {
         *status = F_status_set_error(F_failure);
       }
     }
-
-    if (fake_signal_received(main)) {
-      *status = F_status_set_error(F_interrupt);
-    }
   }
 #endif // _di_fake_build_load_setting_defaults_
 
@@ -2933,6 +2878,8 @@ extern "C" {
 
     if (fake_signal_received(main)) {
       *status = F_status_set_error(F_interrupt);
+
+      return;
     }
 
     const f_string_t names[] = {
@@ -3127,11 +3074,6 @@ extern "C" {
           break;
         }
 
-        if (fake_signal_received(main)) {
-          *status = F_status_set_error(F_interrupt);
-          break;
-        }
-
         *status = f_file_name_directory(sources[i]->array[j].string, sources[i]->array[j].used, &destination_path);
 
         if (F_status_is_error(*status)) {
@@ -3161,11 +3103,6 @@ extern "C" {
             break;
           }
 
-          if (fake_signal_received(main)) {
-            *status = F_status_set_error(F_interrupt);
-            break;
-          }
-
           *status = f_directory_exists(destination_path.string);
 
           if (*status == F_false) {
@@ -3675,15 +3612,15 @@ extern "C" {
 
     if (F_status_is_error(*status)) return;
 
-    f_mode_t mode = f_mode_t_initialize;
-
-    macro_f_mode_t_set_default_umask(mode, main->umask);
-
     if (fake_signal_received(main)) {
       *status = F_status_set_error(F_interrupt);
       return;
     }
 
+    f_mode_t mode = f_mode_t_initialize;
+
+    macro_f_mode_t_set_default_umask(mode, main->umask);
+
     *status = f_file_touch(file.string, mode.regular, F_false);
 
     if (F_status_is_error(*status)) {
index d50cdd80519ec39552a2802b2ab022b415ab0e73..e505fca18dbd296846859e46af0d5a6ce426fa44 100644 (file)
@@ -34,12 +34,6 @@ extern "C" {
       fflush(main->output.to.stream);
     }
 
-    if (fake_signal_received(main)) {
-      *status = F_status_set_error(F_interrupt);
-
-      return 0;
-    }
-
     int return_code = 0;
 
     if (program.used) {
@@ -960,8 +954,12 @@ extern "C" {
 
     fake_main_t *main = (fake_main_t *) state_ptr->custom;
 
-    if (fake_signal_received(main)) {
-      return F_status_set_error(F_interrupt);
+    if (!((++main->signal_check) % fake_signal_check_d)) {
+      if (fake_signal_received(main)) {
+        return F_status_set_error(F_interrupt);
+      }
+
+      main->signal_check = 0;
     }
 
     return F_interrupt_not;
@@ -983,8 +981,12 @@ extern "C" {
 
     fake_main_t *main = (fake_main_t *) state_ptr->custom;
 
-    if (fake_signal_received(main)) {
-      return F_status_set_error(F_interrupt);
+    if (!((++main->signal_check) % fake_signal_check_d)) {
+      if (fake_signal_received(main)) {
+        return F_status_set_error(F_interrupt);
+      }
+
+      main->signal_check = 0;
     }
 
     return F_interrupt_not;
@@ -1033,10 +1035,6 @@ extern "C" {
 
     for (uint8_t i = 0; i < 3; ++i) {
 
-      if (fake_signal_received(main)) {
-        return F_status_set_error(F_interrupt);
-      }
-
       if (parameters_value[i]->used) {
         memset(&directory_stat, 0, sizeof(struct stat));
 
index 478a084fe9a6f255ba673ea6d0ec8a16c9bfdb25..19774b3b8b2854f13cf2fc5de3a4cc7457e196f3 100644 (file)
@@ -286,7 +286,7 @@ extern "C" {
 
         for (f_array_length_t i = 0; i < list_objects.used; ++i) {
 
-          if (fake_signal_received(main)) {
+          if (!(i % fake_signal_check_short_d) && fake_signal_received(main)) {
             *status = F_status_set_error(F_interrupt);
             break;
           }
@@ -653,10 +653,6 @@ extern "C" {
         }
       }
 
-      if (fake_signal_received(main)) {
-        *status = F_status_set_error(F_interrupt);
-      }
-
       if (F_status_is_error_not(*status) && data_make->setting_make.load_build) {
         f_string_static_t stub = f_string_static_t_initialize;
 
@@ -697,14 +693,8 @@ extern "C" {
 
       f_string_map_multis_t define = f_string_map_multis_t_initialize;
 
-      if (fake_signal_received(main)) {
-        *status = F_status_set_error(F_interrupt);
-      }
-      else {
-
-        // load the fakefile "settings" as if they are build "settings".
-        fake_build_load_setting_process(main, F_false, main->file_data_build_fakefile.string, data_make->buffer, settings.objects, settings.contents, &data_make->setting_build, status);
-      }
+      // load the fakefile "settings" as if they are build "settings".
+      fake_build_load_setting_process(main, F_false, main->file_data_build_fakefile.string, data_make->buffer, settings.objects, settings.contents, &data_make->setting_build, status);
 
       if (F_status_is_error_not(*status) && settings.objects.used) {
         const f_string_t settings_name[] = {
@@ -766,11 +756,6 @@ extern "C" {
               break;
             }
 
-            if (fake_signal_received(main)) {
-              *status = F_status_set_error(F_interrupt);
-              break;
-            }
-
             *status = f_environment_set(define.array[i].name.string, combined.string, F_true);
 
             if (F_status_is_error(*status)) {
@@ -1129,12 +1114,6 @@ extern "C" {
       return status;
     }
 
-    if (fake_signal_received(main)) {
-      macro_fake_make_data_t_delete_simple(data_make);
-
-      return F_status_set_error(F_interrupt);
-    }
-
     status = f_path_current(F_true, &data_make.path.stack.array[0]);
 
     if (F_status_is_error(status)) {
@@ -2183,7 +2162,7 @@ extern "C" {
       operation = 0;
       operation_name = 0;
 
-      if (fake_signal_received(main)) {
+      if (!(i % fake_signal_check_short_d) && fake_signal_received(main)) {
         *status = F_status_set_error(F_interrupt);
         break;
       }
index 1a05d665979f5632c80111c53e9e06164cde4edf..bddc0ff4406f009b7688b03df42ac7a62897dd70 100644 (file)
@@ -45,10 +45,6 @@ extern "C" {
 
       for (uint8_t i = 0; i < 20; ++i) {
 
-        if (fake_signal_received(main)) {
-          return F_status_set_error(F_interrupt);
-        }
-
         status = fake_skeleton_operate_directory_create(main, *parameters_value[i]);
 
         if (F_status_is_error(status)) {
@@ -64,10 +60,6 @@ extern "C" {
     f_string_dynamic_t content = f_string_dynamic_t_initialize;
 
     if (F_status_is_error_not(status)) {
-      if (fake_signal_received(main)) {
-        status = F_status_set_error(F_interrupt);
-      }
-
       content.string = fake_make_skeleton_content_defines_s;
       content.used = fake_make_skeleton_content_defines_s_length;
       content.size = content.used;
@@ -78,10 +70,6 @@ extern "C" {
     }
 
     if (F_status_is_error_not(status)) {
-      if (fake_signal_received(main)) {
-        status = F_status_set_error(F_interrupt);
-      }
-
       content.string = fake_make_skeleton_content_dependencies_s;
       content.used = fake_make_skeleton_content_dependencies_s_length;
       content.size = content.used;
@@ -92,26 +80,14 @@ extern "C" {
     }
 
     if (F_status_is_error_not(status)) {
-      if (fake_signal_received(main)) {
-        status = F_status_set_error(F_interrupt);
-      }
-
       status = fake_skeleton_operate_file_create(main, file_data_build_process_post, F_true, content);
     }
 
     if (F_status_is_error_not(status)) {
-      if (fake_signal_received(main)) {
-        status = F_status_set_error(F_interrupt);
-      }
-
       status = fake_skeleton_operate_file_create(main, file_data_build_process_pre, F_true, content);
     }
 
     if (F_status_is_error_not(status)) {
-      if (fake_signal_received(main)) {
-        status = F_status_set_error(F_interrupt);
-      }
-
       content.string = fake_make_skeleton_content_settings_s;
       content.used = fake_make_skeleton_content_settings_s_length;
       content.size = content.used;
@@ -122,18 +98,10 @@ extern "C" {
     }
 
     if (F_status_is_error_not(status)) {
-      if (fake_signal_received(main)) {
-        status = F_status_set_error(F_interrupt);
-      }
-
       status = fake_skeleton_operate_file_create(main, main->file_documents_readme, F_false, content);
     }
 
     if (F_status_is_error_not(status)) {
-      if (fake_signal_received(main)) {
-        status = F_status_set_error(F_interrupt);
-      }
-
       content.string = fake_make_skeleton_content_fakefile_s;
       content.used = fake_make_skeleton_content_fakefile_s_length;
       content.size = content.used;
index 4e9a0f2035907cf15e23bbf2acca503e8a9dc5f8..0d6eaa425d315024018625cec0aba8542e9ce779 100644 (file)
@@ -93,6 +93,8 @@ extern "C" {
 #endif // _di_firewall_default_allocation_step_
 
 #ifndef _di_firewall_defines_
+  #define firewall_signal_check_d 10000
+
   #define firewall_tool_s            "tool"
   #define firewall_tool_iptables_s   "iptables"
   #define firewall_tool_ip6tables_s  "ip6tables"
index 7f94ce613c6495da956809958a84e36a5f47dcc4..49f0a44f7ece092960c994af557419e9f5d4936c 100644 (file)
@@ -61,18 +61,20 @@ f_status_t firewall_perform_commands(firewall_main_t * const main, const firewal
     chain = firewall_chain_custom_id;
   }
 
-  for (; i < local.rule_objects.used; ++i) {
+  for (uint16_t signal_check = 0; i < local.rule_objects.used; ++i) {
 
-    status = firewall_signal_received(main);
+    if (!((++signal_check) % firewall_signal_check_d)) {
+      if (firewall_signal_received(main)) {
+        macro_f_string_dynamic_t_delete_simple(ip_list);
+        macro_f_string_dynamic_t_delete_simple(argument);
+        macro_f_string_dynamics_t_delete_simple(arguments);
+        macro_f_string_dynamic_t_delete_simple(device);
+        macro_f_string_dynamic_t_delete_simple(protocol);
 
-    if (status) {
-      macro_f_string_dynamic_t_delete_simple(ip_list);
-      macro_f_string_dynamic_t_delete_simple(argument);
-      macro_f_string_dynamics_t_delete_simple(arguments);
-      macro_f_string_dynamic_t_delete_simple(device);
-      macro_f_string_dynamic_t_delete_simple(protocol);
+        return F_status_set_error(F_interrupt);
+      }
 
-      return F_status_set_error(F_interrupt);
+      signal_check = 0;
     }
 
     length  = macro_firewall_structure_size(local.rule_objects, i);
@@ -336,18 +338,6 @@ f_status_t firewall_perform_commands(firewall_main_t * const main, const firewal
 
     for (r = repeat; r > 0; --r) {
 
-      status = firewall_signal_received(main);
-
-      if (status) {
-        macro_f_string_dynamic_t_delete_simple(ip_list);
-        macro_f_string_dynamic_t_delete_simple(argument);
-        macro_f_string_dynamics_t_delete_simple(arguments);
-        macro_f_string_dynamic_t_delete_simple(device);
-        macro_f_string_dynamic_t_delete_simple(protocol);
-
-        return F_status_set_error(F_interrupt);
-      }
-
       // first add the program name
       f_string_dynamics_resize(0, &arguments);
 
@@ -939,17 +929,17 @@ f_status_t firewall_create_custom_chains(firewall_main_t * const main, firewall_
   reserved->has_stop = F_false;
   reserved->has_main = F_false;
 
-  while (i < local->chain_objects.used) {
+  for (uint16_t signal_check = 0; i < local->chain_objects.used; ) {
 
     new_chain = F_true;
     j = 0;
 
-    status = firewall_signal_received(main);
-
-    if (status) {
-      macro_f_string_dynamics_t_delete_simple(arguments);
+    if (!((++signal_check) % firewall_signal_check_d)) {
+      if (firewall_signal_received(main)) {
+        macro_f_string_dynamics_t_delete_simple(arguments);
 
-      return F_status_set_error(F_interrupt);
+        return F_status_set_error(F_interrupt);
+      }
     }
 
     // skip globally reserved chain name: main
index bc18a6b73c9b2cf1b4b4f85a390e43d9799ac094..b6085b08184b744515625a3a0ee5fa196a7b066c 100644 (file)
@@ -73,6 +73,8 @@ extern "C" {
 #endif // _di_fss_basic_list_read_program_name_
 
 #ifndef _di_fss_basic_list_read_defines_
+  #define fss_basic_list_read_signal_check_d 10000
+
   #define fss_basic_list_pipe_content_end_s    '\f'
   #define fss_basic_list_pipe_content_ignore_s '\v'
   #define fss_basic_list_pipe_content_start_s  '\b'
index abd468b886978f720fc461e260a18adc36b8b5d4..bde9c241a151e73c7f1c07a9216cf32c511bf40b 100644 (file)
@@ -67,6 +67,8 @@ extern "C" {
 #endif // _di_fss_basic_list_write_program_name_
 
 #ifndef _di_fss_basic_list_write_defines_
+  #define fss_basic_list_write_signal_check_d 10000
+
   #define fss_basic_list_write_pipe_content_end_s    '\f'
   #define fss_basic_list_write_pipe_content_ignore_s '\v'
   #define fss_basic_list_write_pipe_content_start_s  '\b'
index bdd18172a202816efde603206dd63878a9af1eef..0177668f1c15a1e3cfcba9c1fc155487179ba48d 100644 (file)
@@ -73,6 +73,8 @@ extern "C" {
 #endif // _di_fss_basic_read_program_name_
 
 #ifndef _di_fss_basic_read_defines_
+  #define fss_basic_read_signal_check_d 10000
+
   #define fss_basic_read_pipe_content_end_s    '\f'
   #define fss_basic_read_pipe_content_ignore_s '\v'
   #define fss_basic_read_pipe_content_start_s  '\b'
index 69781c09b5496f4ca262f99e810ea10d8e7667c9..6b3f81bb5fe1a13227f88bcf501742e45703c792 100644 (file)
@@ -68,6 +68,8 @@ extern "C" {
 #endif // _di_fss_basic_write_program_name_
 
 #ifndef _di_fss_basic_write_defines_
+  #define fss_basic_write_signal_check_d 10000
+
   #define fss_basic_write_pipe_content_end_s    '\f'
   #define fss_basic_write_pipe_content_ignore_s '\v'
   #define fss_basic_write_pipe_content_start_s  '\b'
index ea252ffc7d0537f60618f73ff6075a3c6f6bca1e..c6980467ccbf5e0e509019db81dc2009db16ffd7 100644 (file)
@@ -73,6 +73,8 @@ extern "C" {
 #endif // _di_fss_embedded_list_read_program_name_
 
 #ifndef _di_fss_embedded_list_read_defines_
+  #define fss_embedded_list_read_signal_check_d 10000
+
   #define fss_embedded_list_read_pipe_content_end_s    '\f'
   #define fss_embedded_list_read_pipe_content_ignore_s '\v'
   #define fss_embedded_list_read_pipe_content_start_s  '\b'
index e9136c03d25cee7a8674b5c341779db9e67bf022..8dd1015f57779630366be88e419be5ccfdc10a80 100644 (file)
@@ -68,6 +68,8 @@ extern "C" {
 #endif // _di_fss_embedded_list_write_program_name_
 
 #ifndef _di_fss_embedded_list_write_defines_
+  #define fss_embedded_list_write_signal_check_d 10000
+
   #define fss_embedded_list_write_pipe_content_end_s    '\f'
   #define fss_embedded_list_write_pipe_content_ignore_s '\v'
   #define fss_embedded_list_write_pipe_content_start_s  '\b'
index 174621e710a9243bd9b1a58c72a34c1c8b834537..20503c3f822a4d8d7e8fa47f3c32114bf94b748b 100644 (file)
@@ -73,6 +73,8 @@ extern "C" {
 #endif // _di_fss_extended_list_read_program_name_
 
 #ifndef _di_fss_extended_list_read_defines_
+  #define fss_extended_list_read_signal_check_d 10000
+
   #define fss_extended_list_read_pipe_content_end    '\f'
   #define fss_extended_list_read_pipe_content_ignore '\v'
   #define fss_extended_list_read_pipe_content_start  '\b'
index df0923bbfe98d3edfd5a8e71de91a962e7df7d47..f6d243d1c653968c3696dafd48442d0caa1122ec 100644 (file)
@@ -68,6 +68,8 @@ extern "C" {
 #endif // _di_fss_extended_list_write_program_name_
 
 #ifndef _di_fss_extended_list_write_defines_
+  #define fss_extended_list_write_signal_check_d 10000
+
   #define fss_extended_list_write_pipe_content_end_s    '\f'
   #define fss_extended_list_write_pipe_content_ignore_s '\v'
   #define fss_extended_list_write_pipe_content_start_s  '\b'
index ee1401102ae3defc405df55f489bcfcf7ba27334..d5ccd59df17f4843e0e8da88b0330c3bbfbad4d3 100644 (file)
@@ -346,15 +346,20 @@ extern "C" {
       if (F_status_is_error_not(status) && main->parameters[fss_extended_read_parameter_delimit].result == f_console_result_additional) {
         f_array_length_t location = 0;
         f_array_length_t length = 0;
+        uint16_t signal_check = 0;
 
         // Set the value to 0 to allow for detecting mode based on what is provided.
         data.delimit_mode = 0;
 
         for (f_array_length_t i = 0; i < main->parameters[fss_extended_read_parameter_delimit].values.used; ++i) {
 
-          if (fss_extended_read_signal_received(main)) {
-            status = F_status_set_error(F_signal);
-            break;
+          if (!((++signal_check) % fss_extended_read_signal_check_d)) {
+            if (fss_extended_read_signal_received(main)) {
+              status = F_status_set_error(F_signal);
+              break;
+            }
+
+            signal_check = 0;
           }
 
           location = main->parameters[fss_extended_read_parameter_delimit].values.array[i];
@@ -545,12 +550,17 @@ extern "C" {
       if (F_status_is_error_not(status) && main->remaining.used > 0) {
         f_file_t file = f_file_t_initialize;
         f_array_length_t size_file = 0;
+        uint16_t signal_check = 0;
 
         for (f_array_length_t i = 0; i < main->remaining.used; ++i) {
 
-          if (fss_extended_read_signal_received(main)) {
-            status = F_status_set_error(F_signal);
-            break;
+          if (!((++signal_check) % fss_extended_read_signal_check_d)) {
+            if (fss_extended_read_signal_received(main)) {
+              status = F_status_set_error(F_signal);
+              break;
+            }
+
+            signal_check = 0;
           }
 
           data.files.array[data.files.used].range.start = data.buffer.used;
index d29e42560ea844e46d881d38a53518c9eb48fb24..5e24b552e121828df7f3eec51fee7984fbe1006e 100644 (file)
@@ -73,6 +73,8 @@ extern "C" {
 #endif // _di_fss_extended_read_program_name_
 
 #ifndef _di_fss_extended_read_defines_
+  #define fss_extended_read_signal_check_d 10000
+
   #define fss_extended_read_pipe_content_end_s    '\f'
   #define fss_extended_read_pipe_content_ignore_s '\v'
   #define fss_extended_read_pipe_content_start_s  '\b'
index a8cce6cd5c366056109abe7944d40c9eb3e1a4b9..1cca898d470a8edc1a77a5d7e85d8501accb18fe 100644 (file)
@@ -86,11 +86,16 @@ extern "C" {
     f_array_length_t position_depth = 0;
     f_array_length_t position_at = 0;
     f_array_length_t position_name = 0;
+    uint16_t signal_check = 0;
 
     for (f_array_length_t i = 0; i < data->depths.used; ++i) {
 
-      if (fss_extended_read_signal_received(main)) {
-        return F_status_set_error(F_interrupt);
+      if (!((++signal_check) % fss_extended_read_signal_check_d)) {
+        if (fss_extended_read_signal_received(main)) {
+          return F_status_set_error(F_interrupt);
+        }
+
+        signal_check = 0;
       }
 
       data->depths.array[i].depth = 0;
@@ -175,8 +180,12 @@ extern "C" {
 
       for (f_array_length_t j = i + 1; j < data->depths.used; ++j) {
 
-        if (fss_extended_read_signal_received(main)) {
-          return F_status_set_error(F_interrupt);
+        if (!((++signal_check) % fss_extended_read_signal_check_d)) {
+          if (fss_extended_read_signal_received(main)) {
+            return F_status_set_error(F_interrupt);
+          }
+
+          signal_check = 0;
         }
 
         if (data->depths.array[i].depth == data->depths.array[j].depth) {
index 12f69d556791df070cb2d2d8701e800cddd559bb..dbc6a1e120ae1834c2da06a43b508f52313248d3 100644 (file)
@@ -446,12 +446,17 @@ extern "C" {
         if (main->parameters[fss_extended_write_parameter_partial].result == f_console_result_found) {
           if (main->parameters[fss_extended_write_parameter_object].result == f_console_result_additional) {
             contents.used = 0;
+            uint16_t signal_check = 0;
 
             for (f_array_length_t i = 0; i < main->parameters[fss_extended_write_parameter_object].values.used; ++i) {
 
-              if (fss_extended_write_signal_received(main)) {
-                status = F_status_set_error(F_interrupt);
-                break;
+              if (!((++signal_check) % fss_extended_write_signal_check_d)) {
+                if (fss_extended_write_signal_received(main)) {
+                  status = F_status_set_error(F_interrupt);
+                  break;
+                }
+
+                signal_check = 0;
               }
 
               object.string = arguments->argv[main->parameters[fss_extended_write_parameter_object].values.array[i]];
@@ -506,11 +511,15 @@ extern "C" {
           f_array_length_t object_next = 0;
           f_array_length_t content_current = 0;
 
-          for (; i < main->parameters[fss_extended_write_parameter_object].values.used; ++i) {
+          for (uint16_t signal_check = 0; i < main->parameters[fss_extended_write_parameter_object].values.used; ++i) {
 
-            if (fss_extended_write_signal_received(main)) {
-              status = F_status_set_error(F_interrupt);
-              break;
+            if (!((++signal_check) % fss_extended_write_signal_check_d)) {
+              if (fss_extended_write_signal_received(main)) {
+                status = F_status_set_error(F_interrupt);
+                break;
+              }
+
+              signal_check = 0;
             }
 
             object_current = main->parameters[fss_extended_write_parameter_object].locations.array[i];
index 20fc35ceacc95a7edea8876f5dde6cfd690040cf..3a711fc41c79614913186887be39545e65d4e477 100644 (file)
@@ -67,6 +67,8 @@ extern "C" {
 #endif // _di_fss_extended_write_program_name_
 
 #ifndef _di_fss_extended_write_defines_
+  #define fss_extended_write_signal_check_d 10000
+
   #define fss_extended_write_pipe_content_end_s    '\f'
   #define fss_extended_write_pipe_content_ignore_s '\v'
   #define fss_extended_write_pipe_content_start_s  '\b'
index 85dc7f16139231ff6c0d739a805d8f6ba26d7984..3f990fb06f7213db81840363c4f266885457ca07 100644 (file)
@@ -174,10 +174,14 @@ extern "C" {
     // 0x0 = start new object/content set, 0x1 = processing object, 0x2 = new individual content, 0x3 = processing content, 0x4 = end object/content set.
     uint8_t state = 0;
 
-    for (;;) {
+    for (uint16_t signal_check = 0; ; ) {
 
-      if (fss_extended_write_signal_received(main)) {
-        return F_status_set_error(F_interrupt);
+      if (!((++signal_check) % fss_extended_write_signal_check_d)) {
+        if (fss_extended_write_signal_received(main)) {
+          return F_status_set_error(F_interrupt);
+        }
+
+        signal_check = 0;
       }
 
       if (range.start > range.stop) {
index ba435911fef777ba4891b9c2d18f9fb969e3dab8..3e280977367527802f79f5d1542c6d05654686ff 100644 (file)
@@ -299,12 +299,17 @@ extern "C" {
     }
 
     if (F_status_is_error_not(status)) {
+      uint16_t signal_check = 0;
 
       for (f_array_length_t i = 0; i < main->remaining.used; ++i) {
 
-        if (fss_identify_signal_received(main)) {
-          status = F_status_set_error(F_interrupt);
-          break;
+        if (!((++signal_check) % fss_identify_signal_check_d)) {
+          if (fss_identify_signal_received(main)) {
+            status = F_status_set_error(F_interrupt);
+            break;
+          }
+
+          signal_check = 0;
         }
 
         if (main->parameters[fss_identify_parameter_line].result == f_console_result_additional) {
index 6d137f88ec2279f339fd8394d8efa9b1b98ae507..7c62085212f1c0305f75025696dca7b2fd5f6096 100644 (file)
@@ -71,6 +71,8 @@ extern "C" {
 #endif // _di_fss_identify_program_name_
 
 #ifndef _di_fss_identify_defines_
+  #define fss_identify_signal_check_d 10000
+
   #define fss_identify_short_content_s "c"
   #define fss_identify_short_line_s    "l"
   #define fss_identify_short_name_s    "n"
index 5e49cd0b669cf64dec9a01c1ce77b9d0ff013f1e..9ab83931f248aa798833df39e788da36c5fec23c 100644 (file)
@@ -10,6 +10,7 @@ extern "C" {
   f_status_t fss_identify_load_line(fss_identify_main_t * const main, const f_file_t file, const f_string_t name, f_string_static_t *buffer, f_string_range_t *range) {
 
     f_status_t status = F_none;
+    uint16_t signal_check = 0;
 
     buffer->used = 0;
 
@@ -17,9 +18,13 @@ extern "C" {
     range->stop = 0;
 
     do {
-      if (fss_identify_signal_received(main)) {
-        status = F_status_set_error(F_interrupt);
-        break;
+      if (!((++signal_check) % fss_identify_signal_check_d)) {
+        if (fss_identify_signal_received(main)) {
+          status = F_status_set_error(F_interrupt);
+          break;
+        }
+
+        signal_check = 0;
       }
 
       if (buffer->used + file.size_read > buffer->size) {
index 8f68a42c632ef59a835be6e445956cb4092f16de..5f710d6a02fc43785fb3cef2cd0707c49110ad40 100644 (file)
@@ -190,13 +190,19 @@ extern "C" {
       }
 
       if (main->remaining.used > 0) {
+        uint16_t signal_check = 0;
+
         flockfile(main->output.to.stream);
 
         for (f_array_length_t i = 0; i < main->remaining.used; ++i) {
 
-          if (fss_status_code_signal_received(main)) {
-            status = F_status_set_error(F_interrupt);
-            break;
+          if (!((++signal_check) % fss_status_code_signal_check_d)) {
+            if (fss_status_code_signal_received(main)) {
+              status = F_status_set_error(F_interrupt);
+              break;
+            }
+
+            signal_check = 0;
           }
 
           status2 = fss_status_code_process_check(main, arguments->argv[main->remaining.array[i]]);
@@ -215,13 +221,19 @@ extern "C" {
       }
 
       if (main->remaining.used > 0) {
+        uint16_t signal_check = 0;
+
         flockfile(main->output.to.stream);
 
         for (f_array_length_t i = 0; i < main->remaining.used; ++i) {
 
-          if (fss_status_code_signal_received(main)) {
-            status = F_status_set_error(F_interrupt);
-            break;
+          if (!((++signal_check) % fss_status_code_signal_check_d)) {
+            if (fss_status_code_signal_received(main)) {
+              status = F_status_set_error(F_interrupt);
+              break;
+            }
+
+            signal_check = 0;
           }
 
           status2 = fss_status_code_process_number(main, arguments->argv[main->remaining.array[i]]);
@@ -240,13 +252,19 @@ extern "C" {
       }
 
       if (main->remaining.used > 0) {
+        uint16_t signal_check = 0;
+
         flockfile(main->output.to.stream);
 
         for (f_array_length_t i = 0; i < main->remaining.used; ++i) {
 
-          if (fss_status_code_signal_received(main)) {
-            status = F_status_set_error(F_interrupt);
-            break;
+          if (!((++signal_check) % fss_status_code_signal_check_d)) {
+            if (fss_status_code_signal_received(main)) {
+              status = F_status_set_error(F_interrupt);
+              break;
+            }
+
+            signal_check = 0;
           }
 
           status2 = fss_status_code_process_normal(main, arguments->argv[main->remaining.array[i]]);
index 4d65fa2d8064911aa5c7ba1466d34b26c2676130..9cce55db8d5d5de2efa2248d079d924908ae0618 100644 (file)
@@ -68,6 +68,8 @@ extern "C" {
 #endif // _di_fss_status_code_program_name_
 
 #ifndef _di_fss_status_code_defines_
+  #define fss_status_code_signal_check_d 10000
+
   #define fss_status_code_short_is_fine_s    "f"
   #define fss_status_code_short_is_warning_s "w"
   #define fss_status_code_short_is_error_s   "e"
index 858f5c1f2454f3ef11a3cee78f796332d496204e..d3f9343b9cddb3b99053bc6bfd977845185ec41b 100644 (file)
@@ -437,11 +437,15 @@ extern "C" {
         f_array_length_t total = 0;
         f_file_t file = f_file_t_initialize;
 
-        for (; i < main->remaining.used; ++i) {
+        for (uint16_t signal_check = 0; i < main->remaining.used; ++i) {
 
-          if (iki_read_signal_received(main)) {
-            status = F_status_set_error(F_interrupt);
-            break;
+          if (!((++signal_check) % iki_read_signal_check_d)) {
+            if (iki_read_signal_received(main)) {
+              status = F_status_set_error(F_interrupt);
+              break;
+            }
+
+            signal_check = 0;
           }
 
           macro_f_file_t_reset(file);
index 6e74308ac4ba1346f7cffc282889e665ee85f9c6..53c69f2dd86a45406b6e23704d5492d3689e15db 100644 (file)
@@ -76,6 +76,8 @@ extern "C" {
 #endif // _di_iki_read_program_name_
 
 #ifndef _di_iki_read_defines_
+  #define iki_read_signal_check_d 10000
+
   enum {
     iki_read_mode_content = 1,
     iki_read_mode_literal,
index ad889f5d8156b26343725485cf1f229916e9ff42..276c98ae6763ad942a8737483730b3a07eaf1348 100644 (file)
@@ -487,12 +487,16 @@ extern "C" {
 
       range.start = 0;
 
-      for (; i < main->parameters[iki_read_parameter_name].values.used; ++i) {
+      for (uint16_t signal_check = 0; i < main->parameters[iki_read_parameter_name].values.used; ++i) {
 
-        if (iki_read_signal_received(main)) {
-          macro_f_string_dynamic_t_delete_simple(name);
+        if (!((++signal_check) % iki_read_signal_check_d)) {
+          if (iki_read_signal_received(main)) {
+            macro_f_string_dynamic_t_delete_simple(name);
+
+            return F_status_set_error(F_interrupt);
+          }
 
-          return F_status_set_error(F_interrupt);
+          signal_check = 0;
         }
 
         index = main->parameters[iki_read_parameter_name].values.array[i];
index fe3df0bb91e5fb79eff215bf42c4c008bceba707..a906ce037f031547be0eb39567b298b44a85c003 100644 (file)
@@ -293,14 +293,19 @@ extern "C" {
 
         f_array_length_t previous = 0;
         f_string_range_t range = f_string_range_t_initialize;
+        uint16_t signal_check = 0;
 
         range.start = 0;
 
         for (f_status_t status_pipe = F_none; ; ) {
 
-          if (iki_write_signal_received(main)) {
-            status = F_status_set_error(F_interrupt);
-            break;
+          if (!((++signal_check) % iki_write_signal_check_d)) {
+            if (iki_write_signal_received(main)) {
+              status = F_status_set_error(F_interrupt);
+              break;
+            }
+
+            signal_check = 0;
           }
 
           if (status_pipe != F_none_eof) {
@@ -413,12 +418,17 @@ extern "C" {
       if (F_status_is_error_not(status)) {
         f_string_static_t object = f_string_static_t_initialize;
         f_string_static_t content = f_string_static_t_initialize;
+        uint16_t signal_check = 0;
 
         for (f_array_length_t i = 0; i < main->parameters[iki_write_parameter_object].values.used; ++i) {
 
-          if (iki_write_signal_received(main)) {
-            status = F_status_set_error(F_interrupt);
-            break;
+          if (!((++signal_check) % iki_write_signal_check_d)) {
+            if (iki_write_signal_received(main)) {
+              status = F_status_set_error(F_interrupt);
+              break;
+            }
+
+            signal_check = 0;
           }
 
           object.string = arguments->argv[main->parameters[iki_write_parameter_object].values.array[i]];
index 6037759407fea9f554121a5c5944a838916e2cf2..4b7dd6511cdd51dfe7eb9a13e8e9a345d83da80a 100644 (file)
@@ -76,6 +76,8 @@ extern "C" {
 #endif // _di_iki_write_program_name_
 
 #ifndef _di_iki_write_defines_
+  #define iki_write_signal_check_d 10000
+
   #define iki_write_short_file_s    "f"
   #define iki_write_short_content_s "c"
   #define iki_write_short_double_s  "d"
index 577225ff460a377711dfb0c76995eea5a1397fbd..58ba6ad8cda0f2c26056fdc20773848aee876179 100644 (file)
@@ -197,13 +197,19 @@ extern "C" {
       }
 
       if (main->remaining.used > 0) {
+        uint16_t signal_check = 0;
+
         flockfile(main->output.to.stream);
 
         for (f_array_length_t i = 0; i < main->remaining.used; ++i) {
 
-          if (status_code_signal_received(main)) {
-            status = F_status_set_error(F_signal);
-            break;
+          if (!((++signal_check) % status_code_signal_check_d)) {
+            if (status_code_signal_received(main)) {
+              status = F_status_set_error(F_signal);
+              break;
+            }
+
+            signal_check = 0;
           }
 
           status2 = status_code_process_check(main, arguments->argv[main->remaining.array[i]]);
@@ -222,13 +228,19 @@ extern "C" {
       }
 
       if (main->remaining.used > 0) {
+        uint16_t signal_check = 0;
+
         flockfile(main->output.to.stream);
 
         for (f_array_length_t i = 0; i < main->remaining.used; ++i) {
 
-          if (status_code_signal_received(main)) {
-            status = F_status_set_error(F_signal);
-            break;
+          if (!((++signal_check) % status_code_signal_check_d)) {
+            if (status_code_signal_received(main)) {
+              status = F_status_set_error(F_signal);
+              break;
+            }
+
+            signal_check = 0;
           }
 
           status2 = status_code_process_number(main, arguments->argv[main->remaining.array[i]]);
@@ -247,13 +259,19 @@ extern "C" {
       }
 
       if (main->remaining.used > 0) {
+        uint16_t signal_check = 0;
+
         flockfile(main->output.to.stream);
 
         for (f_array_length_t i = 0; i < main->remaining.used; ++i) {
 
-          if (status_code_signal_received(main)) {
-            status = F_status_set_error(F_signal);
-            break;
+          if (!((++signal_check) % status_code_signal_check_d)) {
+            if (status_code_signal_received(main)) {
+              status = F_status_set_error(F_signal);
+              break;
+            }
+
+            signal_check = 0;
           }
 
           status2 = status_code_process_normal(main, arguments->argv[main->remaining.array[i]]);
index aebbb85f05f2eb022e3316a508651560eb0b2eb4..2c249e5716aa3f1735b5a3f036b87b5645c820ab 100644 (file)
@@ -67,6 +67,8 @@ extern "C" {
 #endif // _di_status_code_program_name_
 
 #ifndef _di_status_code_defines_
+  #define status_code_signal_check_d 10000
+
   #define status_code_short_is_fine_s    "f"
   #define status_code_short_is_warning_s "w"
   #define status_code_short_is_error_s   "e"
index 088944ad266adc070e941b8d73409056bfcabe22..70d99d668f7b356c2b2c17618dfdea184a1739c6 100644 (file)
@@ -36,20 +36,18 @@ extern "C" {
 
     flockfile(data->file.stream);
 
-    while (*character.string && F_status_is_error_not(status)) {
+    for (uint16_t signal_check = 0; *character.string && F_status_is_error_not(status); ) {
 
-      status = utf8_signal_received(data);
+      if (!((++signal_check) % utf8_signal_check_d)) {
+        if (utf8_signal_received(data)) {
+          utf8_print_signal_received(data, status);
 
-      if (status) {
-        utf8_print_signal_received(data, status);
-
-        status = F_status_set_error(F_signal);
-        break;
-      }
-      else {
-        status = F_none;
+          status = F_status_set_error(F_signal);
+          break;
+        }
       }
 
+      status = F_none;
       character.used = macro_f_utf_byte_width(*character.string);
 
       // Re-adjust used if buffer ended before the character is supposed to end.
@@ -97,7 +95,7 @@ extern "C" {
       if (status == F_utf) {
         valid = F_false;
       }
-    } // while
+    } // for
 
     if (F_status_is_error_not(status) && !(data->mode & utf8_mode_from_binary_d)) {
       if (mode_codepoint != utf8_codepoint_mode_ready && mode_codepoint != utf8_codepoint_mode_end && mode_codepoint != utf8_codepoint_mode_bad_end) {
index 4c43ebebdc50bc98378020d4abea0e090b113a7f..fc414ac261d166081354ab4c83102cd12b92607d 100644 (file)
@@ -65,6 +65,7 @@ extern "C" {
     bool valid = F_true;
     bool next = F_true;
     uint8_t mode_codepoint = utf8_codepoint_mode_ready;
+    uint16_t signal_check = 0;
 
     f_array_length_t i = 0;
     f_array_length_t j = 0;
@@ -79,18 +80,17 @@ extern "C" {
 
       for (i = 0; F_status_is_fine(status) && i < data->buffer.used; ) {
 
-        status = utf8_signal_received(data);
+        if (!((++signal_check) % utf8_signal_check_d)) {
+          if (utf8_signal_received(data)) {
+            utf8_print_signal_received(data, status);
 
-        if (status) {
-          utf8_print_signal_received(data, status);
-
-          status = F_status_set_error(F_signal);
-          break;
-        }
-        else {
-          status = F_none;
+            status = F_status_set_error(F_signal);
+            break;
+          }
         }
 
+        status = F_none;
+
         // Get the current width only when processing a new block.
         if (next) {
           character.used = macro_f_utf_byte_width(data->buffer.string[i]);
index 2af6c7d953449273e0741f66a11f2a4898eaefc7..6c8bd7c7c9958c4cd3b1a8b256d4272ef7c1d881 100644 (file)
@@ -189,6 +189,7 @@ extern "C" {
     f_status_t status = F_none;
     bool valid = F_true;
     bool next = F_true;
+    uint16_t signal_check = 0;
 
     f_array_length_t i = 0;
     f_array_length_t j = 0;
@@ -203,18 +204,17 @@ extern "C" {
 
       for (i = 0; F_status_is_fine(status) && i < data->buffer.used; ) {
 
-        status = utf8_signal_received(data);
+        if (!((++signal_check) % utf8_signal_check_d)) {
+          if (utf8_signal_received(data)) {
+            utf8_print_signal_received(data, status);
 
-        if (status) {
-          utf8_print_signal_received(data, status);
-
-          status = F_status_set_error(F_signal);
-          break;
-        }
-        else {
-          status = F_none;
+            status = F_status_set_error(F_signal);
+            break;
+          }
         }
 
+        status = F_none;
+
         // Get the current width only when processing a new block.
         if (next) {
           character.used = macro_f_utf_byte_width(data->buffer.string[i]);
index c602411e34f721ce0481ba8ebbae1eec4a0648c6..7c521e8cef92649b56dfdfd574b4ebabfb187979 100644 (file)
@@ -372,11 +372,15 @@ extern "C" {
 
         f_file_t file = macro_f_file_t_initialize(0, -1, F_file_flag_read_only_d, 32768, F_file_default_write_size_d);
 
-        for (; i < main->parameters[utf8_parameter_from_file].values.used && status != F_signal; ++i) {
+        for (uint16_t signal_check = 0; i < main->parameters[utf8_parameter_from_file].values.used && status != F_signal; ++i) {
 
-          if (utf8_signal_received(&data)) {
-            status = F_status_set_error(F_signal);
-            break;
+          if (!((++signal_check) % utf8_signal_check_d)) {
+            if (utf8_signal_received(&data)) {
+              status = F_status_set_error(F_signal);
+              break;
+            }
+
+            signal_check = 0;
           }
 
           index = main->parameters[utf8_parameter_from_file].values.array[i];
@@ -418,11 +422,15 @@ extern "C" {
         f_array_length_t i = 0;
         f_array_length_t index = 0;
 
-        for (; F_status_is_error_not(status) && i < main->remaining.used; ++i) {
+        for (uint16_t signal_check = 0; F_status_is_error_not(status) && i < main->remaining.used; ++i) {
 
-          if (utf8_signal_received(&data)) {
-            status = F_status_set_error(F_signal);
-            break;
+          if (!((++signal_check) % utf8_signal_check_d)) {
+            if (utf8_signal_received(&data)) {
+              status = F_status_set_error(F_signal);
+              break;
+            }
+
+            signal_check = 0;
           }
 
           index = main->remaining.array[i];
index 7339684f93fc027afab3611350096774318a9f1b..982903817e1d57b571f5a155b827f2ffd681640c 100644 (file)
@@ -87,6 +87,8 @@ extern "C" {
 #endif // _di_utf8_default_allocation_step_
 
 #ifndef _di_utf8_defines_
+  #define utf8_signal_check_d 10000
+
   #define utf8_string_from_s "from"
   #define utf8_string_to_s   "to"