From 894034e87c43bd80e8a6626d97b0ca65abd032af Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 29 Mar 2022 20:17:09 -0500 Subject: [PATCH] Update: Use signal_check more consistently in programs. There are programs that do not use the fll_program_data_t structure. These now define the signal_check in their main. Such cases will go away as soon as they are converted into using fll_program_data_t. --- level_3/byte_dump/c/common.h | 4 +- level_3/byte_dump/c/private-byte_dump.c | 6 +-- level_3/firewall/c/common.h | 2 + level_3/firewall/c/private-firewall.c | 10 ++--- .../fss_basic_list_read/c/fss_basic_list_read.c | 10 ++--- level_3/fss_basic_list_read/c/private-read.c | 39 ++++++++---------- level_3/fss_basic_read/c/fss_basic_read.c | 20 ++++++--- level_3/fss_basic_read/c/private-read.c | 48 ++++++++++++++++------ level_3/fss_embedded_list_read/c/common.h | 2 + .../c/fss_embedded_list_read.c | 10 +++-- level_3/fss_embedded_list_read/c/private-read.c | 16 ++++++-- .../c/fss_extended_list_read.c | 20 ++++++--- level_3/fss_extended_list_read/c/private-read.c | 16 ++++++-- level_3/fss_extended_read/c/fss_extended_read.c | 11 +++-- level_3/fss_extended_read/c/private-read.c | 9 ++-- level_3/fss_extended_write/c/fss_extended_write.c | 12 +++--- level_3/fss_extended_write/c/private-write.c | 6 +-- level_3/fss_identify/c/fss_identify.c | 6 +-- level_3/fss_identify/c/private-identify.c | 5 +-- level_3/fss_payload_read/c/fss_payload_read.c | 10 ++--- level_3/fss_payload_read/c/private-read.c | 39 ++++++++---------- level_3/fss_status_code/c/fss_status_code.c | 18 +++----- level_3/iki_read/c/common.h | 2 + level_3/iki_read/c/iki_read.c | 5 +-- level_3/iki_read/c/private-read.c | 6 +-- level_3/iki_write/c/common.h | 4 +- level_3/iki_write/c/iki_write.c | 11 ++--- level_3/status_code/c/status_code.c | 18 +++----- level_3/utf8/c/private-utf8.c | 6 ++- level_3/utf8/c/private-utf8_binary.c | 5 ++- level_3/utf8/c/private-utf8_codepoint.c | 6 ++- level_3/utf8/c/utf8.c | 12 +++--- 32 files changed, 211 insertions(+), 183 deletions(-) diff --git a/level_3/byte_dump/c/common.h b/level_3/byte_dump/c/common.h index 931506a..d4a61b8 100644 --- a/level_3/byte_dump/c/common.h +++ b/level_3/byte_dump/c/common.h @@ -346,13 +346,12 @@ extern "C" { * warning: The output file for warning printing. * signal: The process signal management structure. * context: The color context. - * - * @todo */ #ifndef _di_byte_dump_main_t_ typedef struct { f_console_parameters_t parameters; + uint16_t signal_check; bool process_pipe; fl_print_t output; @@ -374,6 +373,7 @@ extern "C" { #define byte_dump_main_t_initialize \ { \ f_console_parameters_t_initialize, \ + 0, \ F_false, \ fl_print_t_initialize, \ macro_fl_print_t_initialize_error(), \ diff --git a/level_3/byte_dump/c/private-byte_dump.c b/level_3/byte_dump/c/private-byte_dump.c index 202d81e..ea3a29b 100644 --- a/level_3/byte_dump/c/private-byte_dump.c +++ b/level_3/byte_dump/c/private-byte_dump.c @@ -57,14 +57,14 @@ extern "C" { memset(&invalid, 0, sizeof(f_char_t) * main->width); if (byte_get >= 0) { - for (uint16_t signal_check = 0; ; ) { + for (;;) { - if (!((++signal_check) % byte_dump_signal_check_d)) { + if (!((++main->signal_check) % byte_dump_signal_check_d)) { if (byte_dump_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } byte_get = getc(file.stream); diff --git a/level_3/firewall/c/common.h b/level_3/firewall/c/common.h index 2d06eee..6d8a17d 100644 --- a/level_3/firewall/c/common.h +++ b/level_3/firewall/c/common.h @@ -419,6 +419,7 @@ extern "C" { typedef struct { f_console_parameters_t parameters; + uint16_t signal_check; bool process_pipe; int child; @@ -437,6 +438,7 @@ extern "C" { #define firewall_main_t_initialize \ { \ f_console_parameters_t_initialize, \ + 0, \ F_false, \ 0, \ fl_print_t_initialize, \ diff --git a/level_3/firewall/c/private-firewall.c b/level_3/firewall/c/private-firewall.c index 06361a9..a439b45 100644 --- a/level_3/firewall/c/private-firewall.c +++ b/level_3/firewall/c/private-firewall.c @@ -61,9 +61,9 @@ f_status_t firewall_perform_commands(firewall_main_t * const main, const firewal chain = firewall_chain_custom_id_e; } - for (uint16_t signal_check = 0; F_status_is_error_not(status) && i < local.rule_objects.used; ++i) { + for (; F_status_is_error_not(status) && i < local.rule_objects.used; ++i) { - if (!((++signal_check) % firewall_signal_check_d)) { + if (!((++main->signal_check) % firewall_signal_check_d)) { if (firewall_signal_received(main)) { f_string_dynamic_resize(0, &ip_list); f_string_dynamics_resize(0, &arguments); @@ -73,7 +73,7 @@ f_status_t firewall_perform_commands(firewall_main_t * const main, const firewal return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } length = macro_firewall_structure_size(local.rule_objects, i); @@ -816,12 +816,12 @@ f_status_t firewall_create_custom_chains(firewall_main_t * const main, firewall_ reserved->has_stop = F_false; reserved->has_main = F_false; - for (uint16_t signal_check = 0; i < local->chain_objects.used; ++i) { + for (; i < local->chain_objects.used; ++i) { new_chain = F_true; j = 0; - if (!((++signal_check) % firewall_signal_check_d)) { + if (!((++main->signal_check) % firewall_signal_check_d)) { if (firewall_signal_received(main)) break; } diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index 3bee387..520de04 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -353,21 +353,20 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters.array[fss_basic_list_read_parameter_delimit_e].result == f_console_result_additional_e) { f_array_length_t index = 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.array[fss_basic_list_read_parameter_delimit_e].values.used; ++i) { - if (!((++signal_check) % fss_basic_list_read_signal_check_d)) { + if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { if (fss_basic_list_read_signal_received(main)) { status = F_status_set_error(F_interrupt); break; } - signal_check = 0; + main->signal_check = 0; } index = main->parameters.array[fss_basic_list_read_parameter_delimit_e].values.array[i]; @@ -551,18 +550,17 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters.remaining.used) { 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->parameters.remaining.used; ++i) { - if (!((++signal_check) % fss_basic_list_read_signal_check_d)) { + if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { if (fss_basic_list_read_signal_received(main)) { status = F_status_set_error(F_interrupt); break; } - signal_check = 0; + main->signal_check = 0; } data.files.array[data.files.used].name = data.argv[main->parameters.remaining.array[i]]; diff --git a/level_3/fss_basic_list_read/c/private-read.c b/level_3/fss_basic_list_read/c/private-read.c index 8720f41..af5c725 100644 --- a/level_3/fss_basic_list_read/c/private-read.c +++ b/level_3/fss_basic_list_read/c/private-read.c @@ -83,16 +83,15 @@ 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 (!((++signal_check) % fss_basic_list_read_signal_check_d)) { + if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { if (fss_basic_list_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } data->depths.array[i].depth = 0; @@ -173,12 +172,12 @@ extern "C" { for (f_array_length_t j = i + 1; j < data->depths.used; ++j) { - if (!((++signal_check) % fss_basic_list_read_signal_check_d)) { + if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { if (fss_basic_list_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } if (data->depths.array[i].depth == data->depths.array[j].depth) { @@ -342,7 +341,6 @@ extern "C" { f_array_lengths_t except_none = f_array_lengths_t_initialize; f_array_lengths_t *delimits_object = fss_basic_list_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; f_array_lengths_t *delimits_content = fss_basic_list_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; - uint16_t signal_check = 0; if (data->option & fss_basic_list_read_data_option_raw_d) { delimits_object = &except_none; @@ -353,12 +351,12 @@ extern "C" { if (!names[i]) continue; - if (!((++signal_check) % fss_basic_list_read_signal_check_d)) { + if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { if (fss_basic_list_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } fss_basic_list_read_print_at(main, i, *delimits_object, *delimits_content, data); @@ -394,18 +392,17 @@ extern "C" { f_array_length_t at = 0; f_status_t status = F_none; - uint16_t signal_check = 0; for (f_array_length_t i = 0; i < data->objects.used; ++i) { if (!names[i]) continue; - if (!((++signal_check) % fss_basic_list_read_signal_check_d)) { + if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { if (fss_basic_list_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } if (at == data->depths.array[0].value_at) { @@ -493,7 +490,6 @@ extern "C" { f_string_range_t range = data->contents.array[at].array[0]; f_array_length_t i = 0; - uint16_t signal_check = 0; // This content has no data, do not even check "include empty" because it cannot be counted as a line. if (range.start > range.stop) { @@ -502,12 +498,12 @@ extern "C" { for (i = range.start; i <= range.stop; ++i) { - if (!((++signal_check) % fss_basic_list_read_signal_check_d)) { + if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { if (fss_basic_list_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } if (data->buffer.string[i] == f_string_eol_s.string[0]) { @@ -578,18 +574,17 @@ extern "C" { } f_array_length_t max = 0; - uint16_t signal_check = 0; for (f_array_length_t i = 0; i < data->contents.used; ++i) { if (!names[i]) continue; - if (!((++signal_check) % fss_basic_list_read_signal_check_d)) { + if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { if (fss_basic_list_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } if (data->contents.array[i].used > max) { @@ -617,18 +612,17 @@ extern "C" { f_array_length_t line = 0; f_status_t status = F_none; - uint16_t signal_check = 0; for (f_array_length_t i = 0; i < data->contents.used; ++i) { if (!names[i]) continue; - if (!((++signal_check) % fss_basic_list_read_signal_check_d)) { + if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { if (fss_basic_list_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } status = fss_basic_list_read_process_at_line(main, data, i, *delimits_object, *delimits_content, &line); @@ -733,18 +727,17 @@ extern "C" { f_array_length_t total = 0; f_string_range_t range = f_string_range_t_initialize; f_array_length_t i = 0; - uint16_t signal_check = 0; for (f_array_length_t at = 0; at < data->contents.used; ++at) { if (!names[at]) continue; - if (!((++signal_check) % fss_basic_list_read_signal_check_d)) { + if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { if (fss_basic_list_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } if (data->option & fss_basic_list_read_data_option_object_d) { diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index 654c9da..71acf22 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -359,10 +359,14 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.array[fss_basic_read_parameter_delimit_e].values.used; ++i) { - if (fss_basic_read_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { + if (fss_basic_read_signal_received(main)) { + status = F_status_set_error(F_interrupt); - break; + break; + } + + main->signal_check = 0; } index = main->parameters.array[fss_basic_read_parameter_delimit_e].values.array[i]; @@ -557,10 +561,14 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - if (fss_basic_read_signal_received(main)) { - status = F_status_set_error(F_signal); + if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { + if (fss_basic_read_signal_received(main)) { + status = F_status_set_error(F_signal); - break; + break; + } + + main->signal_check = 0; } data.files.array[data.files.used].range.start = data.buffer.used; diff --git a/level_3/fss_basic_read/c/private-read.c b/level_3/fss_basic_read/c/private-read.c index 3c033ca..325fbe0 100644 --- a/level_3/fss_basic_read/c/private-read.c +++ b/level_3/fss_basic_read/c/private-read.c @@ -63,8 +63,12 @@ extern "C" { for (f_array_length_t i = 0; i < data->depths.used; ++i) { - if (fss_basic_read_signal_received(main)) { - return F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { + if (fss_basic_read_signal_received(main)) { + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } data->depths.array[i].depth = 0; @@ -145,8 +149,12 @@ extern "C" { for (f_array_length_t j = i + 1; j < data->depths.used; ++j) { - if (fss_basic_read_signal_received(main)) { - return F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { + if (fss_basic_read_signal_received(main)) { + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } if (data->depths.array[i].depth == data->depths.array[j].depth) { @@ -358,8 +366,12 @@ extern "C" { if (!names[i]) continue; - if (fss_basic_read_signal_received(main)) { - return F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { + if (fss_basic_read_signal_received(main)) { + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } if (at == data->depths.array[0].value_at) { @@ -435,8 +447,12 @@ extern "C" { if (!names[at]) continue; - if (fss_basic_read_signal_received(main)) { - return F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { + if (fss_basic_read_signal_received(main)) { + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } if (data->contents.array[at].used > max) { @@ -462,8 +478,12 @@ extern "C" { if (!names[i]) continue; - if (fss_basic_read_signal_received(main)) { - return F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { + if (fss_basic_read_signal_received(main)) { + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } if (!(data->option & fss_basic_read_data_option_object_d) && (data->option & fss_basic_read_data_option_content_d)) { @@ -607,8 +627,12 @@ extern "C" { if (!names[i]) continue; - if (fss_basic_read_signal_received(main)) { - return F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { + if (fss_basic_read_signal_received(main)) { + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } if (!(data->option & fss_basic_read_data_option_object_d) && data->option & fss_basic_read_data_option_content_d) { diff --git a/level_3/fss_embedded_list_read/c/common.h b/level_3/fss_embedded_list_read/c/common.h index 4d533bc..1ce3935 100644 --- a/level_3/fss_embedded_list_read/c/common.h +++ b/level_3/fss_embedded_list_read/c/common.h @@ -285,6 +285,7 @@ extern "C" { typedef struct { f_console_parameters_t parameters; + uint16_t signal_check; f_array_lengths_t remaining; bool process_pipe; @@ -307,6 +308,7 @@ extern "C" { #define fss_embedded_list_read_main_t_initialize \ { \ f_console_parameters_t_initialize, \ + 0, \ f_array_lengths_t_initialize, \ F_false, \ fl_print_t_initialize, \ diff --git a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c index ad65cd9..9219ebc 100644 --- a/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c +++ b/level_3/fss_embedded_list_read/c/fss_embedded_list_read.c @@ -444,10 +444,14 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters.remaining.used > 0) { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - if (fss_embedded_list_read_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_embedded_list_read_signal_check_d)) { + if (fss_embedded_list_read_signal_received(main)) { + status = F_status_set_error(F_interrupt); - break; + break; + } + + main->signal_check = 0; } f_file_t file = f_file_t_initialize; diff --git a/level_3/fss_embedded_list_read/c/private-read.c b/level_3/fss_embedded_list_read/c/private-read.c index 15552db..0ca3263 100644 --- a/level_3/fss_embedded_list_read/c/private-read.c +++ b/level_3/fss_embedded_list_read/c/private-read.c @@ -129,8 +129,12 @@ extern "C" { for (i = 0; i < values_total; ++i) { - if (fss_embedded_list_read_signal_received(main)) { - return F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_embedded_list_read_signal_check_d)) { + if (fss_embedded_list_read_signal_received(main)) { + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } if (values_type[i] == fss_embedded_list_read_parameter_depth_e || values_type[i] == fss_embedded_list_read_parameter_at_e) { @@ -554,8 +558,12 @@ extern "C" { if (skip[i]) continue; - if (fss_embedded_list_read_signal_received(main)) { - return F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_embedded_list_read_signal_check_d)) { + if (fss_embedded_list_read_signal_received(main)) { + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } if (!items->array[i].content.used) { diff --git a/level_3/fss_extended_list_read/c/fss_extended_list_read.c b/level_3/fss_extended_list_read/c/fss_extended_list_read.c index fd33c88..ebb472c 100644 --- a/level_3/fss_extended_list_read/c/fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/fss_extended_list_read.c @@ -359,10 +359,14 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.array[fss_extended_list_read_parameter_delimit_e].values.used; ++i) { - if (fss_extended_list_read_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_extended_list_read_signal_check_d)) { + if (fss_extended_list_read_signal_received(main)) { + status = F_status_set_error(F_interrupt); - break; + break; + } + + main->signal_check = 0; } index = main->parameters.array[fss_extended_list_read_parameter_delimit_e].values.array[i]; @@ -557,10 +561,14 @@ extern "C" { for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - if (fss_extended_list_read_signal_received(main)) { - status = F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_extended_list_read_signal_check_d)) { + if (fss_extended_list_read_signal_received(main)) { + status = F_status_set_error(F_interrupt); - break; + break; + } + + main->signal_check = 0; } data.files.array[data.files.used].range.start = data.buffer.used; diff --git a/level_3/fss_extended_list_read/c/private-read.c b/level_3/fss_extended_list_read/c/private-read.c index 134d73b..72e338a 100644 --- a/level_3/fss_extended_list_read/c/private-read.c +++ b/level_3/fss_extended_list_read/c/private-read.c @@ -86,8 +86,12 @@ extern "C" { for (f_array_length_t i = 0; i < data->depths.used; ++i) { - if (fss_extended_list_read_signal_received(main)) { - return F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_extended_list_read_signal_check_d)) { + if (fss_extended_list_read_signal_received(main)) { + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } data->depths.array[i].depth = 0; @@ -168,8 +172,12 @@ extern "C" { for (f_array_length_t j = i + 1; j < data->depths.used; ++j) { - if (fss_extended_list_read_signal_received(main)) { - return F_status_set_error(F_interrupt); + if (!((++main->signal_check) % fss_extended_list_read_signal_check_d)) { + if (fss_extended_list_read_signal_received(main)) { + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } if (data->depths.array[i].depth == data->depths.array[j].depth) { diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index 36e9e55..e605f5e 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -351,21 +351,20 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters.array[fss_extended_read_parameter_delimit_e].result == f_console_result_additional_e) { f_array_length_t index = 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.array[fss_extended_read_parameter_delimit_e].values.used; ++i) { - if (!((++signal_check) % fss_extended_read_signal_check_d)) { + if (!((++main->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; + main->signal_check = 0; } index = main->parameters.array[fss_extended_read_parameter_delimit_e].values.array[i]; @@ -557,17 +556,17 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters.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->parameters.remaining.used; ++i) { - if (!((++signal_check) % fss_extended_read_signal_check_d)) { + if (!((++main->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; + main->signal_check = 0; } data.files.array[data.files.used].range.start = data.buffer.used; diff --git a/level_3/fss_extended_read/c/private-read.c b/level_3/fss_extended_read/c/private-read.c index d23d8d4..74f2604 100644 --- a/level_3/fss_extended_read/c/private-read.c +++ b/level_3/fss_extended_read/c/private-read.c @@ -87,16 +87,15 @@ 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 (!((++signal_check) % fss_extended_read_signal_check_d)) { + if (!((++main->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; + main->signal_check = 0; } data->depths.array[i].depth = 0; @@ -177,12 +176,12 @@ extern "C" { for (f_array_length_t j = i + 1; j < data->depths.used; ++j) { - if (!((++signal_check) % fss_extended_read_signal_check_d)) { + if (!((++main->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; + main->signal_check = 0; } if (data->depths.array[i].depth == data->depths.array[j].depth) { diff --git a/level_3/fss_extended_write/c/fss_extended_write.c b/level_3/fss_extended_write/c/fss_extended_write.c index fa2d301..9bdefb1 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -450,18 +450,16 @@ extern "C" { if (main->parameters.array[fss_extended_write_parameter_object_e].result == f_console_result_additional_e) { contents.used = 0; - uint16_t signal_check = 0; - for (f_array_length_t i = 0; i < main->parameters.array[fss_extended_write_parameter_object_e].values.used; ++i) { - if (!((++signal_check) % fss_extended_write_signal_check_d)) { + if (!((++main->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; + main->signal_check = 0; } status = fss_extended_write_process(main, output, quote, &argv[main->parameters.array[fss_extended_write_parameter_object_e].values.array[i]], 0, &buffer); @@ -497,16 +495,16 @@ extern "C" { f_array_length_t object_next = 0; f_array_length_t content_current = 0; - for (uint16_t signal_check = 0; i < main->parameters.array[fss_extended_write_parameter_object_e].values.used; ++i) { + for (; i < main->parameters.array[fss_extended_write_parameter_object_e].values.used; ++i) { - if (!((++signal_check) % fss_extended_write_signal_check_d)) { + if (!((++main->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; + main->signal_check = 0; } object_current = main->parameters.array[fss_extended_write_parameter_object_e].locations.array[i]; diff --git a/level_3/fss_extended_write/c/private-write.c b/level_3/fss_extended_write/c/private-write.c index c2c0708..90e211b 100644 --- a/level_3/fss_extended_write/c/private-write.c +++ b/level_3/fss_extended_write/c/private-write.c @@ -175,14 +175,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 (uint16_t signal_check = 0; ; ) { + for (;;) { - if (!((++signal_check) % fss_extended_write_signal_check_d)) { + if (!((++main->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; + main->signal_check = 0; } if (range.start > range.stop) { diff --git a/level_3/fss_identify/c/fss_identify.c b/level_3/fss_identify/c/fss_identify.c index 233a04c..e6a8211 100644 --- a/level_3/fss_identify/c/fss_identify.c +++ b/level_3/fss_identify/c/fss_identify.c @@ -300,18 +300,16 @@ extern "C" { } if (F_status_is_error_not(status)) { - uint16_t signal_check = 0; - for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - if (!((++signal_check) % fss_identify_signal_check_d)) { + if (!((++main->signal_check) % fss_identify_signal_check_d)) { if (fss_identify_signal_received(main)) { status = F_status_set_error(F_interrupt); break; } - signal_check = 0; + main->signal_check = 0; } if (main->parameters.array[fss_identify_parameter_line_e].result == f_console_result_additional_e) { diff --git a/level_3/fss_identify/c/private-identify.c b/level_3/fss_identify/c/private-identify.c index ed623ff..13d039b 100644 --- a/level_3/fss_identify/c/private-identify.c +++ b/level_3/fss_identify/c/private-identify.c @@ -11,7 +11,6 @@ extern "C" { f_status_t fss_identify_load_line(fll_program_data_t * const main, const f_file_t file, const f_string_static_t file_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; @@ -19,14 +18,14 @@ extern "C" { range->stop = 0; do { - if (!((++signal_check) % fss_identify_signal_check_d)) { + if (!((++main->signal_check) % fss_identify_signal_check_d)) { if (fss_identify_signal_received(main)) { status = F_status_set_error(F_interrupt); break; } - signal_check = 0; + main->signal_check = 0; } if (buffer->used + file.size_read > buffer->size) { diff --git a/level_3/fss_payload_read/c/fss_payload_read.c b/level_3/fss_payload_read/c/fss_payload_read.c index 5f9ac54..b04032a 100644 --- a/level_3/fss_payload_read/c/fss_payload_read.c +++ b/level_3/fss_payload_read/c/fss_payload_read.c @@ -371,21 +371,20 @@ extern "C" { if (F_status_is_error_not(status) && main->parameters.array[fss_payload_read_parameter_delimit_e].result == f_console_result_additional_e) { f_array_length_t index = 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.array[fss_payload_read_parameter_delimit_e].values.used; ++i) { - if (!((++signal_check) % fss_payload_read_signal_check_d)) { + if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { if (fss_payload_read_signal_received(main)) { status = F_status_set_error(F_interrupt); break; } - signal_check = 0; + main->signal_check = 0; } index = main->parameters.array[fss_payload_read_parameter_delimit_e].values.array[i]; @@ -591,18 +590,17 @@ extern "C" { f_file_t file = f_file_t_initialize; f_array_length_t size_file = 0; const f_array_length_t buffer_used = data.buffer.used; - uint16_t signal_check = 0; for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - if (!((++signal_check) % fss_payload_read_signal_check_d)) { + if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { if (fss_payload_read_signal_received(main)) { status = F_status_set_error(F_interrupt); break; } - signal_check = 0; + main->signal_check = 0; } data.files.array[data.files.used].range.start = data.buffer.used; diff --git a/level_3/fss_payload_read/c/private-read.c b/level_3/fss_payload_read/c/private-read.c index 7efc8a8..c862b02 100644 --- a/level_3/fss_payload_read/c/private-read.c +++ b/level_3/fss_payload_read/c/private-read.c @@ -83,16 +83,15 @@ 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 (!((++signal_check) % fss_payload_read_signal_check_d)) { + if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { if (fss_payload_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } data->depths.array[i].depth = 0; @@ -173,12 +172,12 @@ extern "C" { for (f_array_length_t j = i + 1; j < data->depths.used; ++j) { - if (!((++signal_check) % fss_payload_read_signal_check_d)) { + if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { if (fss_payload_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } if (data->depths.array[i].depth == data->depths.array[j].depth) { @@ -438,7 +437,6 @@ extern "C" { f_array_lengths_t except_none = f_array_lengths_t_initialize; f_array_lengths_t *delimits_object = fss_payload_read_delimit_object_is(data, 0) ? &data->delimits_object : &except_none; f_array_lengths_t *delimits_content = fss_payload_read_delimit_content_is(data, 0) ? &data->delimits_content : &except_none; - uint16_t signal_check = 0; bool is_payload = F_false; if (data->option & fss_payload_read_data_option_raw_d) { @@ -450,12 +448,12 @@ extern "C" { if (!names[i]) continue; - if (!((++signal_check) % fss_payload_read_signal_check_d)) { + if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { if (fss_payload_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } is_payload = fl_string_dynamic_partial_compare_string(f_fss_string_payload_s.string, data->buffer, f_fss_string_payload_s.used, data->objects.array[i]) == F_equal_to; @@ -493,19 +491,18 @@ extern "C" { f_array_length_t at = 0; f_status_t status = F_none; - uint16_t signal_check = 0; bool is_payload = F_false; for (f_array_length_t i = 0; i < data->objects.used; ++i) { if (!names[i]) continue; - if (!((++signal_check) % fss_payload_read_signal_check_d)) { + if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { if (fss_payload_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } if (at == data->depths.array[0].value_at) { @@ -690,7 +687,6 @@ extern "C" { f_string_range_t range = f_string_range_t_initialize; f_array_length_t i = 0; - uint16_t signal_check = 0; range.start = data->contents.array[at].array[0].start; range.stop = data->contents.array[at].array[0].stop; @@ -702,12 +698,12 @@ extern "C" { for (i = range.start; i <= range.stop; ++i) { - if (!((++signal_check) % fss_payload_read_signal_check_d)) { + if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { if (fss_payload_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } if (data->buffer.string[i] == f_string_eol_s.string[0]) { @@ -778,18 +774,17 @@ extern "C" { } f_array_length_t max = 0; - uint16_t signal_check = 0; for (f_array_length_t at = 0; at < data->contents.used; ++at) { if (!names[at]) continue; - if (!((++signal_check) % fss_payload_read_signal_check_d)) { + if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { if (fss_payload_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } if (data->contents.array[at].used > max) { @@ -847,18 +842,17 @@ extern "C" { f_array_length_t line = 0; f_status_t status = F_none; - uint16_t signal_check = 0; for (f_array_length_t i = 0; i < data->contents.used; ++i) { if (!names[i]) continue; - if (!((++signal_check) % fss_payload_read_signal_check_d)) { + if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { if (fss_payload_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } status = fss_payload_read_process_at_line(main, data, i, *delimits_object, *delimits_content, &line); @@ -1051,18 +1045,17 @@ extern "C" { f_array_length_t total = 0; f_string_range_t range = f_string_range_t_initialize; f_array_length_t i = 0; - uint16_t signal_check = 0; for (f_array_length_t at = 0; at < data->contents.used; ++at) { if (!names[at]) continue; - if (!((++signal_check) % fss_payload_read_signal_check_d)) { + if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { if (fss_payload_read_signal_received(main)) { return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } if (data->option & fss_payload_read_data_option_object_d) { diff --git a/level_3/fss_status_code/c/fss_status_code.c b/level_3/fss_status_code/c/fss_status_code.c index a4de8c9..adee528 100644 --- a/level_3/fss_status_code/c/fss_status_code.c +++ b/level_3/fss_status_code/c/fss_status_code.c @@ -201,20 +201,18 @@ extern "C" { } if (main->parameters.remaining.used > 0) { - uint16_t signal_check = 0; - flockfile(main->output.to.stream); for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - if (!((++signal_check) % fss_status_code_signal_check_d)) { + if (!((++main->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; + main->signal_check = 0; } status2 = fss_status_code_process_check(main, argv[main->parameters.remaining.array[i]]); @@ -233,20 +231,18 @@ extern "C" { } if (main->parameters.remaining.used > 0) { - uint16_t signal_check = 0; - flockfile(main->output.to.stream); for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - if (!((++signal_check) % fss_status_code_signal_check_d)) { + if (!((++main->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; + main->signal_check = 0; } status2 = fss_status_code_process_number(main, argv[main->parameters.remaining.array[i]]); @@ -265,20 +261,18 @@ extern "C" { } if (main->parameters.remaining.used > 0) { - uint16_t signal_check = 0; - flockfile(main->output.to.stream); for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - if (!((++signal_check) % fss_status_code_signal_check_d)) { + if (!((++main->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; + main->signal_check = 0; } status2 = fss_status_code_process_normal(main, argv[main->parameters.remaining.array[i]]); diff --git a/level_3/iki_read/c/common.h b/level_3/iki_read/c/common.h index b4e0a71..78ca2d5 100644 --- a/level_3/iki_read/c/common.h +++ b/level_3/iki_read/c/common.h @@ -251,6 +251,7 @@ extern "C" { typedef struct { f_console_parameters_t parameters; + uint16_t signal_check; bool process_pipe; fl_print_t output; @@ -274,6 +275,7 @@ extern "C" { #define iki_read_main_t_initialize \ { \ f_console_parameters_t_initialize, \ + 0, \ F_false, \ fl_print_t_initialize, \ macro_fl_print_t_initialize_error(), \ diff --git a/level_3/iki_read/c/iki_read.c b/level_3/iki_read/c/iki_read.c index 71c3b02..c3eafbe 100644 --- a/level_3/iki_read/c/iki_read.c +++ b/level_3/iki_read/c/iki_read.c @@ -434,19 +434,18 @@ extern "C" { } if (F_status_is_fine(status) && main->parameters.remaining.used > 0) { - uint16_t signal_check = 0; f_file_t file = f_file_t_initialize; for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - if (!((++signal_check) % iki_read_signal_check_d)) { + if (!((++main->signal_check) % iki_read_signal_check_d)) { if (iki_read_signal_received(main)) { status = F_status_set_error(F_interrupt); break; } - signal_check = 0; + main->signal_check = 0; } macro_f_file_t_reset(file); diff --git a/level_3/iki_read/c/private-read.c b/level_3/iki_read/c/private-read.c index 40874db..ff470a5 100644 --- a/level_3/iki_read/c/private-read.c +++ b/level_3/iki_read/c/private-read.c @@ -498,16 +498,16 @@ extern "C" { range.start = 0; - for (uint16_t signal_check = 0; i < main->parameters.array[iki_read_parameter_name_e].values.used; ++i) { + for (; i < main->parameters.array[iki_read_parameter_name_e].values.used; ++i) { - if (!((++signal_check) % iki_read_signal_check_d)) { + if (!((++main->signal_check) % iki_read_signal_check_d)) { if (iki_read_signal_received(main)) { f_string_dynamic_resize(0, &name); return F_status_set_error(F_interrupt); } - signal_check = 0; + main->signal_check = 0; } index = main->parameters.array[iki_read_parameter_name_e].values.array[i]; diff --git a/level_3/iki_write/c/common.h b/level_3/iki_write/c/common.h index f942d35..7d10eb1 100644 --- a/level_3/iki_write/c/common.h +++ b/level_3/iki_write/c/common.h @@ -155,13 +155,12 @@ extern "C" { * warning: The output file for warning printing. * signal: The process signal management structure. * context: The color context. - * - * @todo */ #ifndef _di_iki_write_main_t_ typedef struct { f_console_parameters_t parameters; + uint16_t signal_check; bool process_pipe; fl_print_t output; @@ -179,6 +178,7 @@ extern "C" { #define iki_write_main_t_initialize \ { \ f_console_parameters_t_initialize, \ + 0, \ F_false, \ fl_print_t_initialize, \ macro_fl_print_t_initialize_error(), \ diff --git a/level_3/iki_write/c/iki_write.c b/level_3/iki_write/c/iki_write.c index 334ec73..39e4719 100644 --- a/level_3/iki_write/c/iki_write.c +++ b/level_3/iki_write/c/iki_write.c @@ -295,20 +295,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 (!((++signal_check) % iki_write_signal_check_d)) { + if (!((++main->signal_check) % iki_write_signal_check_d)) { if (iki_write_signal_received(main)) { status = F_status_set_error(F_interrupt); break; } - signal_check = 0; + main->signal_check = 0; } if (status_pipe != F_none_eof) { @@ -426,17 +425,15 @@ extern "C" { } if (F_status_is_error_not(status)) { - uint16_t signal_check = 0; - for (f_array_length_t i = 0; i < main->parameters.array[iki_write_parameter_object_e].values.used; ++i) { - if (!((++signal_check) % iki_write_signal_check_d)) { + if (!((++main->signal_check) % iki_write_signal_check_d)) { if (iki_write_signal_received(main)) { status = F_status_set_error(F_interrupt); break; } - signal_check = 0; + main->signal_check = 0; } status = iki_write_process(main, file, argv[main->parameters.array[iki_write_parameter_object_e].values.array[i]], argv[main->parameters.array[iki_write_parameter_content_e].values.array[i]], &escaped); diff --git a/level_3/status_code/c/status_code.c b/level_3/status_code/c/status_code.c index a9643f2..2290242 100644 --- a/level_3/status_code/c/status_code.c +++ b/level_3/status_code/c/status_code.c @@ -201,20 +201,18 @@ extern "C" { } if (main->parameters.remaining.used > 0) { - uint16_t signal_check = 0; - flockfile(main->output.to.stream); for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - if (!((++signal_check) % status_code_signal_check_d)) { + if (!((++main->signal_check) % status_code_signal_check_d)) { if (status_code_signal_received(main)) { status = F_status_set_error(F_signal); break; } - signal_check = 0; + main->signal_check = 0; } status2 = status_code_process_check(main, argv[main->parameters.remaining.array[i]]); @@ -233,20 +231,18 @@ extern "C" { } if (main->parameters.remaining.used > 0) { - uint16_t signal_check = 0; - flockfile(main->output.to.stream); for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - if (!((++signal_check) % status_code_signal_check_d)) { + if (!((++main->signal_check) % status_code_signal_check_d)) { if (status_code_signal_received(main)) { status = F_status_set_error(F_signal); break; } - signal_check = 0; + main->signal_check = 0; } status2 = status_code_process_number(main, argv[main->parameters.remaining.array[i]]); @@ -265,20 +261,18 @@ extern "C" { } if (main->parameters.remaining.used > 0) { - uint16_t signal_check = 0; - flockfile(main->output.to.stream); for (f_array_length_t i = 0; i < main->parameters.remaining.used; ++i) { - if (!((++signal_check) % status_code_signal_check_d)) { + if (!((++main->signal_check) % status_code_signal_check_d)) { if (status_code_signal_received(main)) { status = F_status_set_error(F_signal); break; } - signal_check = 0; + main->signal_check = 0; } status2 = status_code_process_normal(main, argv[main->parameters.remaining.array[i]]); diff --git a/level_3/utf8/c/private-utf8.c b/level_3/utf8/c/private-utf8.c index 2f58847..ec32490 100644 --- a/level_3/utf8/c/private-utf8.c +++ b/level_3/utf8/c/private-utf8.c @@ -36,9 +36,9 @@ extern "C" { flockfile(data->file.stream); - for (uint16_t signal_check = 0; text.string[0] && F_status_is_error_not(status); ) { + for (; text.string[0] && F_status_is_error_not(status); ) { - if (!((++signal_check) % utf8_signal_check_d)) { + if (!((++data->main->signal_check) % utf8_signal_check_d)) { if (utf8_signal_received(data)) { utf8_print_signal_received(data, status); @@ -46,6 +46,8 @@ extern "C" { break; } + + data->main->signal_check = 0; } status = F_none; diff --git a/level_3/utf8/c/private-utf8_binary.c b/level_3/utf8/c/private-utf8_binary.c index b78c777..5c1d94d 100644 --- a/level_3/utf8/c/private-utf8_binary.c +++ b/level_3/utf8/c/private-utf8_binary.c @@ -68,7 +68,6 @@ extern "C" { bool valid = F_true; bool next = F_true; uint8_t mode_codepoint = utf8_codepoint_mode_ready_e; - uint16_t signal_check = 0; f_array_length_t i = 0; f_array_length_t j = 0; @@ -83,7 +82,7 @@ extern "C" { for (i = 0; F_status_is_fine(status) && i < data->buffer.used; ) { - if (!((++signal_check) % utf8_signal_check_d)) { + if (!((++data->main->signal_check) % utf8_signal_check_d)) { if (utf8_signal_received(data)) { utf8_print_signal_received(data, status); @@ -91,6 +90,8 @@ extern "C" { break; } + + data->main->signal_check = 0; } status = F_none; diff --git a/level_3/utf8/c/private-utf8_codepoint.c b/level_3/utf8/c/private-utf8_codepoint.c index fa391ea..64f5201 100644 --- a/level_3/utf8/c/private-utf8_codepoint.c +++ b/level_3/utf8/c/private-utf8_codepoint.c @@ -204,7 +204,6 @@ extern "C" { bool valid = F_true; bool next = F_true; uint8_t mode_codepoint = utf8_codepoint_mode_ready_e; - uint16_t signal_check = 0; f_array_length_t i = 0; f_array_length_t j = 0; @@ -219,13 +218,16 @@ extern "C" { for (i = 0; F_status_is_fine(status) && i < data->buffer.used; ) { - if (!((++signal_check) % utf8_signal_check_d)) { + if (!((++data->main->signal_check) % utf8_signal_check_d)) { if (utf8_signal_received(data)) { utf8_print_signal_received(data, status); status = F_signal; + break; } + + data->main->signal_check = 0; } status = F_none; diff --git a/level_3/utf8/c/utf8.c b/level_3/utf8/c/utf8.c index 4799c04..5a36fbd 100644 --- a/level_3/utf8/c/utf8.c +++ b/level_3/utf8/c/utf8.c @@ -406,16 +406,16 @@ 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 (uint16_t signal_check = 0; i < main->parameters.array[utf8_parameter_from_file_e].values.used && status != F_signal; ++i) { + for (; i < main->parameters.array[utf8_parameter_from_file_e].values.used && status != F_signal; ++i) { - if (!((++signal_check) % utf8_signal_check_d)) { + if (!((++main->signal_check) % utf8_signal_check_d)) { if (utf8_signal_received(&data)) { status = F_status_set_error(F_signal); break; } - signal_check = 0; + main->signal_check = 0; } index = main->parameters.array[utf8_parameter_from_file_e].values.array[i]; @@ -454,18 +454,16 @@ extern "C" { } if (F_status_is_error_not(status) && status != F_signal && main->parameters.remaining.used) { - uint16_t signal_check = 0; - for (f_array_length_t i = 0; F_status_is_error_not(status) && i < main->parameters.remaining.used; ++i) { - if (!((++signal_check) % utf8_signal_check_d)) { + if (!((++main->signal_check) % utf8_signal_check_d)) { if (utf8_signal_received(&data)) { status = F_status_set_error(F_signal); break; } - signal_check = 0; + main->signal_check = 0; } utf8_print_section_header_parameter(&data, main->parameters.remaining.array[i]); -- 1.8.3.1