From 8c0da7bf799c37e6ceeb3d9c94d6622bbb0dd767 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Wed, 3 Jan 2024 17:25:37 -0600 Subject: [PATCH] Update: Optimize bitwise logic regarding removing bits. I intended to eventually do this and I finally got around to it. Change the logic to use "x &= ~y" rather than "x -= x & y" or "if (x | y) x -= y". In the case of "x -= x & y", the resulting object code is identical in my tests. However, the code is simpler to write with the "x &= ~y". The "if (x | y) x -= y" results in a lot more commands in the object. --- level_0/f_file/c/file.c | 138 +++++++-------------------- level_1/fl_conversion/c/private-conversion.c | 8 +- level_3/byte_dump/c/main/common.c | 20 ++-- level_3/control/c/main/common.c | 6 +- level_3/controller/c/common.c | 4 +- level_3/controller/c/controller.c | 8 +- level_3/controller/c/entry/private-entry.c | 32 ++----- level_3/controller/c/rule/private-rule.c | 8 +- level_3/fake/c/main/common.c | 12 +-- level_3/firewall/c/common.c | 4 +- level_3/fss_identify/c/main/common.c | 18 ++-- level_3/fss_read/c/main/common.c | 6 +- level_3/fss_read/c/main/main.c | 76 +++++++-------- level_3/fss_write/c/main/common.c | 10 +- level_3/fss_write/c/main/fss_write.c | 2 +- level_3/fss_write/c/main/main.c | 15 +-- level_3/fss_write/c/payload/fss_write.c | 2 +- level_3/iki_read/c/main/common.c | 6 +- level_3/iki_write/c/main/common.c | 6 +- level_3/status_code/c/main/common.c | 6 +- level_3/utf8/c/main/common.c | 30 +++--- 21 files changed, 154 insertions(+), 263 deletions(-) diff --git a/level_0/f_file/c/file.c b/level_0/f_file/c/file.c index 4380424..7d6a6ce 100644 --- a/level_0/f_file/c/file.c +++ b/level_0/f_file/c/file.c @@ -694,36 +694,24 @@ extern "C" { if (mode_change & F_file_mode_t_block_special_d) { if (change & F_file_mode_t_mask_bit_set_owner_d & F_file_mode_t_mask_how_subtract_d) { - if (*mode & F_file_mode_special_set_user_d) { - *mode -= F_file_mode_special_set_user_d; - } + *mode &= ~F_file_mode_special_set_user_d; } else if (change & F_file_mode_t_mask_bit_set_owner_d & F_file_mode_t_mask_how_add_d) { - if (!(*mode & F_file_mode_special_set_user_d)) { - *mode |= F_file_mode_special_set_user_d; - } + *mode |= F_file_mode_special_set_user_d; } if (change & F_file_mode_t_mask_bit_set_group_d & F_file_mode_t_mask_how_subtract_d) { - if (*mode & F_file_mode_special_set_group_d) { - *mode -= F_file_mode_special_set_group_d; - } + *mode &= ~F_file_mode_special_set_group_d; } else if (change & F_file_mode_t_mask_bit_set_group_d & F_file_mode_t_mask_how_add_d) { - if (!(*mode & F_file_mode_special_set_group_d)) { - *mode |= F_file_mode_special_set_group_d; - } + *mode |= F_file_mode_special_set_group_d; } if (change & F_file_mode_t_mask_bit_sticky_d & F_file_mode_t_mask_how_subtract_d) { - if (*mode & F_file_mode_special_sticky_d) { - *mode -= F_file_mode_special_sticky_d; - } + *mode &= ~F_file_mode_special_sticky_d; } else if (change & F_file_mode_t_mask_bit_sticky_d & F_file_mode_t_mask_how_add_d) { - if (!(*mode & F_file_mode_special_sticky_d)) { - *mode |= F_file_mode_special_sticky_d; - } + *mode |= F_file_mode_special_sticky_d; } } } @@ -753,39 +741,27 @@ extern "C" { if (mode_change & F_file_mode_t_block_owner_d) { if (change & F_file_mode_t_mask_bit_read_d & F_file_mode_t_mask_how_subtract_d) { - if (*mode & F_file_mode_owner_r_d) { - *mode -= F_file_mode_owner_r_d; - } + *mode &= ~F_file_mode_owner_r_d; } else if (change & F_file_mode_t_mask_bit_read_d & F_file_mode_t_mask_how_add_d) { - if (!(*mode & F_file_mode_owner_r_d)) { - *mode |= F_file_mode_owner_r_d; - } + *mode |= F_file_mode_owner_r_d; } if (change & F_file_mode_t_mask_bit_write_d & F_file_mode_t_mask_how_subtract_d) { - if (*mode & F_file_mode_owner_w_d) { - *mode -= F_file_mode_owner_w_d; - } + *mode &= ~F_file_mode_owner_w_d; } else if (change & F_file_mode_t_mask_bit_write_d & F_file_mode_t_mask_how_add_d) { - if (!(*mode & F_file_mode_owner_w_d)) { - *mode |= F_file_mode_owner_w_d; - } + *mode |= F_file_mode_owner_w_d; } if (change & F_file_mode_t_mask_bit_execute_d) { change &= F_file_mode_t_mask_bit_execute_d; if (change & F_file_mode_t_mask_how_subtract_d) { - if (*mode & F_file_mode_owner_x_d) { - *mode -= F_file_mode_owner_x_d; - } + *mode &= ~F_file_mode_owner_x_d; } else if (change & F_file_mode_t_mask_how_add_d) { - if (!(*mode & F_file_mode_owner_x_d)) { - *mode |= F_file_mode_owner_x_d; - } + *mode |= F_file_mode_owner_x_d; } } else if (change & F_file_mode_t_mask_bit_execute_only_d) { @@ -793,14 +769,10 @@ extern "C" { if (directory_is || (mode_file & F_file_mode_owner_x_d)) { if (change & F_file_mode_t_mask_how_subtract_d) { - if (*mode & F_file_mode_owner_x_d) { - *mode -= F_file_mode_owner_x_d; - } + *mode &= ~F_file_mode_owner_x_d; } else if (change & F_file_mode_t_mask_how_add_d) { - if (!(*mode & F_file_mode_owner_x_d)) { - *mode |= F_file_mode_owner_x_d; - } + *mode |= F_file_mode_owner_x_d; } } } @@ -832,39 +804,27 @@ extern "C" { if (mode_change & F_file_mode_t_block_group_d) { if (change & F_file_mode_t_mask_bit_read_d & F_file_mode_t_mask_how_subtract_d) { - if (*mode & F_file_mode_group_r_d) { - *mode -= F_file_mode_group_r_d; - } + *mode &= ~F_file_mode_group_r_d; } else if (change & F_file_mode_t_mask_bit_read_d & F_file_mode_t_mask_how_add_d) { - if (!(*mode & F_file_mode_group_r_d)) { - *mode |= F_file_mode_group_r_d; - } + *mode |= F_file_mode_group_r_d; } if (change & F_file_mode_t_mask_bit_write_d & F_file_mode_t_mask_how_subtract_d) { - if (*mode & F_file_mode_group_w_d) { - *mode -= F_file_mode_group_w_d; - } + *mode &= ~F_file_mode_group_w_d; } else if (change & F_file_mode_t_mask_bit_write_d & F_file_mode_t_mask_how_add_d) { - if (!(*mode & F_file_mode_group_w_d)) { - *mode |= F_file_mode_group_w_d; - } + *mode |= F_file_mode_group_w_d; } if (change & F_file_mode_t_mask_bit_execute_d) { change &= F_file_mode_t_mask_bit_execute_d; if (change & F_file_mode_t_mask_how_subtract_d) { - if (*mode & F_file_mode_group_x_d) { - *mode -= F_file_mode_group_x_d; - } + *mode &= ~F_file_mode_group_x_d; } else if (change & F_file_mode_t_mask_how_add_d) { - if (!(*mode & F_file_mode_group_x_d)) { - *mode |= F_file_mode_group_x_d; - } + *mode |= F_file_mode_group_x_d; } } else if (change & F_file_mode_t_mask_bit_execute_only_d) { @@ -872,14 +832,10 @@ extern "C" { if (directory_is || (mode_file & F_file_mode_group_x_d)) { if (change & F_file_mode_t_mask_how_subtract_d) { - if (*mode & F_file_mode_group_x_d) { - *mode -= F_file_mode_group_x_d; - } + *mode &= ~F_file_mode_group_x_d; } else if (change & F_file_mode_t_mask_how_add_d) { - if (!(*mode & F_file_mode_group_x_d)) { - *mode |= F_file_mode_group_x_d; - } + *mode |= F_file_mode_group_x_d; } } } @@ -911,39 +867,27 @@ extern "C" { if (mode_change & F_file_mode_t_block_world_d) { if (change & F_file_mode_t_mask_bit_read_d & F_file_mode_t_mask_how_subtract_d) { - if (*mode & F_file_mode_world_r_d) { - *mode -= F_file_mode_world_r_d; - } + *mode &= ~F_file_mode_world_r_d; } else if (change & F_file_mode_t_mask_bit_read_d & F_file_mode_t_mask_how_add_d) { - if (!(*mode & F_file_mode_world_r_d)) { - *mode |= F_file_mode_world_r_d; - } + *mode |= F_file_mode_world_r_d; } if (change & F_file_mode_t_mask_bit_write_d & F_file_mode_t_mask_how_subtract_d) { - if (*mode & F_file_mode_world_w_d) { - *mode -= F_file_mode_world_w_d; - } + *mode &= ~F_file_mode_world_w_d; } else if (change & F_file_mode_t_mask_bit_write_d & F_file_mode_t_mask_how_add_d) { - if (!(*mode & F_file_mode_world_w_d)) { - *mode |= F_file_mode_world_w_d; - } + *mode |= F_file_mode_world_w_d; } if (change & F_file_mode_t_mask_bit_execute_d) { change &= F_file_mode_t_mask_bit_execute_d; if (change & F_file_mode_t_mask_how_subtract_d) { - if (*mode & F_file_mode_world_x_d) { - *mode -= F_file_mode_world_x_d; - } + *mode &= ~F_file_mode_world_x_d; } else if (change & F_file_mode_t_mask_how_add_d) { - if (!(*mode & F_file_mode_world_x_d)) { - *mode |= F_file_mode_world_x_d; - } + *mode |= F_file_mode_world_x_d; } } else if (change & F_file_mode_t_mask_bit_execute_only_d) { @@ -951,14 +895,10 @@ extern "C" { if (directory_is || (mode_file & F_file_mode_world_x_d)) { if (change & F_file_mode_t_mask_how_subtract_d) { - if (*mode & F_file_mode_world_x_d) { - *mode -= F_file_mode_world_x_d; - } + *mode &= ~F_file_mode_world_x_d; } else if (change & F_file_mode_t_mask_how_add_d) { - if (!(*mode & F_file_mode_world_x_d)) { - *mode |= F_file_mode_world_x_d; - } + *mode |= F_file_mode_world_x_d; } } } @@ -1096,7 +1036,7 @@ extern "C" { // Clear by mask to prepare for replacement, which includes clearing the special block. mode_mask |= F_file_mode_t_block_special_d; - mode_result -= mode_result & mode_mask; + mode_result &= ~mode_mask; replace_result |= F_file_mode_t_replace_special_d; @@ -1167,7 +1107,7 @@ extern "C" { incomplete = F_false; if (how > 3) { - mode_result -= mode_result & mode_umask; + mode_result &= ~mode_umask; } on = 0; @@ -1190,7 +1130,7 @@ extern "C" { // Clear by mask to prepare for replacement, which includes clearing the special block. mode_mask |= F_file_mode_t_block_special_d; - mode_result -= mode_result & mode_mask; + mode_result &= ~mode_mask; replace_result |= F_file_mode_t_replace_special_d; @@ -1217,25 +1157,19 @@ extern "C" { if (how == 1 || how == 2 || how == 4 || how == 5) { incomplete = F_false; mode_result |= what & mode_mask & F_file_mode_t_mask_how_add_d; - - if (mode_result & what & mode_mask & F_file_mode_t_mask_how_subtract_d) { - mode_result -= mode_result & what & mode_mask & F_file_mode_t_mask_how_subtract_d; - } + mode_result &= ~F_file_mode_t_mask_how_subtract_d; } else if (how == 3 || how == 6) { incomplete = F_false; mode_result |= what & mode_mask & F_file_mode_t_mask_how_subtract_d; - - if (mode_result & what & mode_mask & F_file_mode_t_mask_how_add_d) { - mode_result -= mode_result & what & mode_mask & F_file_mode_t_mask_how_add_d; - } + mode_result &= ~F_file_mode_t_mask_how_add_d; } } } // for if (how > 3) { incomplete = F_false; - mode_result -= mode_result & mode_umask; + mode_result &= ~mode_umask; } if (!code.string[i]) break; diff --git a/level_1/fl_conversion/c/private-conversion.c b/level_1/fl_conversion/c/private-conversion.c index 29239b8..7148c70 100644 --- a/level_1/fl_conversion/c/private-conversion.c +++ b/level_1/fl_conversion/c/private-conversion.c @@ -435,8 +435,8 @@ extern "C" { if (vector == -1) { data.flag |= fl_conversion_data_flag_negative_e; } - else if (data.flag & fl_conversion_data_flag_negative_e) { - data.flag -= fl_conversion_data_flag_negative_e; + else { + data.flag &= ~fl_conversion_data_flag_negative_e; } if (mode == 10 || mode == 16 || mode == 12 || mode == 8) { @@ -578,9 +578,7 @@ extern "C" { fl_conversion_data_t data = macro_fl_conversion_data_t_initialize_1(mode, flag); - if (data.flag & fl_conversion_data_flag_negative_e) { - data.flag -= fl_conversion_data_flag_negative_e; - } + data.flag &= ~fl_conversion_data_flag_negative_e; if (mode == 10 || mode == 16 || mode == 12 || mode == 8) { status = private_fl_conversion_dynamic_to_base_unsigned(data, string + offset, length - offset, number); diff --git a/level_3/byte_dump/c/main/common.c b/level_3/byte_dump/c/main/common.c index ab1ab90..dc90428 100644 --- a/level_3/byte_dump/c/main/common.c +++ b/level_3/byte_dump/c/main/common.c @@ -17,14 +17,14 @@ extern "C" { // Identify and process first/last parameters. if (main->program.parameters.array[f_console_standard_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & byte_dump_main_flag_print_first_e; + main->setting.flag &= ~byte_dump_main_flag_print_first_e; } else { main->setting.flag |= byte_dump_main_flag_print_first_e; } if (main->program.parameters.array[f_console_standard_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & byte_dump_main_flag_print_last_e; + main->setting.flag &= ~byte_dump_main_flag_print_last_e; } else { main->setting.flag |= byte_dump_main_flag_print_last_e; @@ -154,9 +154,7 @@ extern "C" { } if (choices.array[choice] == byte_dump_parameter_narrow_e) { - if (main->setting.flag & byte_dump_main_flag_wide_e) { - main->setting.flag -= byte_dump_main_flag_wide_e; - } + main->setting.flag &= ~byte_dump_main_flag_wide_e; } else if (choices.array[choice] == byte_dump_parameter_wide_e) { main->setting.flag |= byte_dump_main_flag_wide_e; @@ -189,7 +187,7 @@ extern "C" { main->setting.flag |= byte_dump_main_flag_pipe_e; } else { - main->setting.flag -= main->setting.flag & byte_dump_main_flag_pipe_e; + main->setting.flag &= ~byte_dump_main_flag_pipe_e; } if (main->program.parameters.array[byte_dump_parameter_width_e].result & f_console_result_value_e) { @@ -284,7 +282,7 @@ extern "C" { return; } else { - main->setting.flag -= flags[i] & main->setting.flag; + main->setting.flag &= ~flags[i]; } } // for @@ -310,28 +308,28 @@ extern "C" { main->setting.flag |= byte_dump_main_flag_text_e; } else { - main->setting.flag -= byte_dump_main_flag_text_e & main->setting.flag; + main->setting.flag &= ~byte_dump_main_flag_text_e; } if (main->program.parameters.array[byte_dump_parameter_unicode_e].result & f_console_result_found_e) { main->setting.flag |= byte_dump_main_flag_unicode_e; } else { - main->setting.flag -= byte_dump_main_flag_unicode_e & main->setting.flag; + main->setting.flag &= ~byte_dump_main_flag_unicode_e; } if (main->program.parameters.array[byte_dump_parameter_placeholder_e].result & f_console_result_found_e) { main->setting.flag |= byte_dump_main_flag_placeholder_e; } else { - main->setting.flag -= byte_dump_main_flag_placeholder_e & main->setting.flag; + main->setting.flag &= ~byte_dump_main_flag_placeholder_e; } if (main->program.parameters.array[byte_dump_parameter_classic_e].result & f_console_result_found_e) { main->setting.flag |= byte_dump_main_flag_classic_e; } else { - main->setting.flag -= byte_dump_main_flag_classic_e & main->setting.flag; + main->setting.flag &= ~byte_dump_main_flag_classic_e; } if (main->program.parameters.remaining.used) { diff --git a/level_3/control/c/main/common.c b/level_3/control/c/main/common.c index db2c474..baf392a 100644 --- a/level_3/control/c/main/common.c +++ b/level_3/control/c/main/common.c @@ -17,14 +17,14 @@ extern "C" { // Identify and process first/last parameters. if (main->program.parameters.array[f_console_standard_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & control_main_flag_print_first_e; + main->setting.flag &= ~control_main_flag_print_first_e; } else { main->setting.flag |= control_main_flag_print_first_e; } if (main->program.parameters.array[f_console_standard_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & control_main_flag_print_last_e; + main->setting.flag &= ~control_main_flag_print_last_e; } else { main->setting.flag |= control_main_flag_print_last_e; @@ -94,7 +94,7 @@ extern "C" { main->setting.flag |= control_main_flag_pipe_e; } else { - main->setting.flag -= main->setting.flag & control_main_flag_pipe_e; + main->setting.flag &= ~control_main_flag_pipe_e; } // The settings path is statically allocated. diff --git a/level_3/controller/c/common.c b/level_3/controller/c/common.c index a9d714a..ea5d781 100644 --- a/level_3/controller/c/common.c +++ b/level_3/controller/c/common.c @@ -633,14 +633,14 @@ extern "C" { // Identify and process first/last parameters. if (main->program.parameters.array[f_console_standard_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & controller_main_flag_print_first_e; + main->setting.flag &= ~controller_main_flag_print_first_e; } else { main->setting.flag |= controller_main_flag_print_first_e; } if (main->program.parameters.array[f_console_standard_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & controller_main_flag_print_last_e; + main->setting.flag &= ~controller_main_flag_print_last_e; } else { main->setting.flag |= controller_main_flag_print_last_e; diff --git a/level_3/controller/c/controller.c b/level_3/controller/c/controller.c index e0c7633..2d66ea6 100644 --- a/level_3/controller/c/controller.c +++ b/level_3/controller/c/controller.c @@ -273,15 +273,13 @@ extern "C" { if (main->parameters.array[controller_parameter_interruptible_e].result & f_console_result_found_e) { setting.flag |= controller_setting_flag_interruptible_e; } - else if (setting.flag & controller_setting_flag_interruptible_e) { - setting.flag -= controller_setting_flag_interruptible_e; + else { + setting.flag &= ~controller_setting_flag_interruptible_e; } } else { if (main->parameters.array[controller_parameter_uninterruptible_e].result & f_console_result_found_e) { - if (setting.flag & controller_setting_flag_interruptible_e) { - setting.flag -= controller_setting_flag_interruptible_e; - } + setting.flag &= ~controller_setting_flag_interruptible_e; } else { setting.flag |= controller_setting_flag_interruptible_e; diff --git a/level_3/controller/c/entry/private-entry.c b/level_3/controller/c/entry/private-entry.c index fc3620d..289c0f5 100644 --- a/level_3/controller/c/entry/private-entry.c +++ b/level_3/controller/c/entry/private-entry.c @@ -526,9 +526,7 @@ extern "C" { if (action->status == F_okay) { if (action->parameters.used == 2) { - if (action->flag & controller_entry_action_flag_undefined_e) { - action->flag -= controller_entry_action_flag_undefined_e; - } + action->flag &= ~controller_entry_action_flag_undefined_e; status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, action->parameters.array[1], &action->number); @@ -1803,9 +1801,7 @@ extern "C" { for (k = 0; k < entry->items.used; ++k) { if (f_compare_dynamic(action->parameters.array[0], entry->items.array[k].name) == F_equal_to) { - if (missing & 0x1) { - missing -= 0x1; - } + missing &= ~0x1; break; } @@ -1962,9 +1958,7 @@ extern "C" { } } else { - if (global.setting->control.flag & controller_control_flag_readonly_e) { - global.setting->control.flag -= controller_control_flag_readonly_e; - } + global.setting->control.flag &= ~controller_control_flag_readonly_e; } cache->action.generic.used = 0; @@ -2236,10 +2230,7 @@ extern "C" { continue; } - if (entry->flag & controller_entry_flag_timeout_exit_no_e) { - entry->flag -= controller_entry_flag_timeout_exit_no_e; - } - + entry->flag &= ~controller_entry_flag_timeout_exit_no_e; time = &entry->timeout_exit; } else if (f_compare_dynamic_partial_string(controller_kill_s.string, cache->buffer_file, controller_kill_s.used, cache->content_actions.array[i].array[0]) == F_equal_to) { @@ -2249,10 +2240,7 @@ extern "C" { continue; } - if (entry->flag & controller_entry_flag_timeout_kill_no_e) { - entry->flag -= controller_entry_flag_timeout_kill_no_e; - } - + entry->flag &= ~controller_entry_flag_timeout_kill_no_e; time = &entry->timeout_kill; } else if (f_compare_dynamic_partial_string(controller_start_s.string, cache->buffer_file, controller_start_s.used, cache->content_actions.array[i].array[0]) == F_equal_to) { @@ -2262,10 +2250,7 @@ extern "C" { continue; } - if (entry->flag & controller_entry_flag_timeout_start_no_e) { - entry->flag -= controller_entry_flag_timeout_start_no_e; - } - + entry->flag &= ~controller_entry_flag_timeout_start_no_e; time = &entry->timeout_start; } else if (f_compare_dynamic_partial_string(controller_stop_s.string, cache->buffer_file, controller_stop_s.used, cache->content_actions.array[i].array[0]) == F_equal_to) { @@ -2275,10 +2260,7 @@ extern "C" { continue; } - if (entry->flag & controller_entry_flag_timeout_stop_no_e) { - entry->flag -= controller_entry_flag_timeout_stop_no_e; - } - + entry->flag &= ~controller_entry_flag_timeout_stop_no_e; time = &entry->timeout_stop; } else { diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index a0e2203..ca7a307 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -535,17 +535,13 @@ extern "C" { item->with |= controller_with_session_new_d; // The "session_new" and "session_same" are mutually exclusive. - if (item->with & controller_with_session_same_d) { - item->with -= controller_with_session_same_d; - } + item->with &= ~controller_with_session_same_d; } else if (f_compare_dynamic_partial_string(controller_session_same_s.string, cache->buffer_item, controller_session_same_s.used, cache->content_action.array[i]) == F_equal_to) { item->with |= controller_with_session_same_d; // The "session_new" and "session_same" are mutually exclusive. - if (item->with & controller_with_session_new_d) { - item->with -= controller_with_session_new_d; - } + item->with &= ~controller_with_session_new_d; } else { if (global.main->error.verbosity > f_console_verbosity_quiet_e) { diff --git a/level_3/fake/c/main/common.c b/level_3/fake/c/main/common.c index 702a564..4767ee1 100644 --- a/level_3/fake/c/main/common.c +++ b/level_3/fake/c/main/common.c @@ -27,14 +27,14 @@ extern "C" { // Identify and process first/last parameters. if (main->program.parameters.array[f_console_standard_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fake_main_flag_print_first_e; + main->setting.flag &= ~fake_main_flag_print_first_e; } else { main->setting.flag |= fake_main_flag_print_first_e; } if (main->program.parameters.array[f_console_standard_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fake_main_flag_print_last_e; + main->setting.flag &= ~fake_main_flag_print_last_e; } else { main->setting.flag |= fake_main_flag_print_last_e; @@ -99,7 +99,7 @@ extern "C" { main->setting.flag |= fake_main_flag_pipe_e; } else { - main->setting.flag -= main->setting.flag & fake_main_flag_pipe_e; + main->setting.flag &= ~fake_main_flag_pipe_e; } { @@ -129,7 +129,7 @@ extern "C" { if (main->program.parameters.array[enables[i]].result & f_console_result_found_e) { if (main->program.parameters.array[disables[i]].result & f_console_result_found_e) { if (main->program.parameters.array[enables[i]].location < main->program.parameters.array[disables[i]].location) { - main->setting.flag -= main->setting.flag & flags[i]; + main->setting.flag &= ~flags[i]; } else { main->setting.flag |= flags[i]; @@ -140,7 +140,7 @@ extern "C" { } } else if (main->program.parameters.array[disables[i]].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & flags[i]; + main->setting.flag &= ~flags[i]; } } // for } @@ -447,7 +447,7 @@ extern "C" { } else { main->setting.flag |= fake_main_flag_operation_make_e; - main->setting.flag -= main->setting.flag & fake_main_flag_operation_e; + main->setting.flag &= ~fake_main_flag_operation_e; main->setting.state.status = f_memory_array_increase_by(1, sizeof(uint8_t), (void **) &main->setting.operations.array, &main->setting.operations.used, &main->setting.operations.size); diff --git a/level_3/firewall/c/common.c b/level_3/firewall/c/common.c index 5956658..6b19cf7 100644 --- a/level_3/firewall/c/common.c +++ b/level_3/firewall/c/common.c @@ -123,14 +123,14 @@ extern "C" { // Identify and process first/last parameters. if (main->program.parameters.array[f_console_standard_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & firewall_main_flag_print_first_e; + main->setting.flag &= ~firewall_main_flag_print_first_e; } else { main->setting.flag |= firewall_main_flag_print_first_e; } if (main->program.parameters.array[f_console_standard_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & firewall_main_flag_print_last_e; + main->setting.flag &= ~firewall_main_flag_print_last_e; } else { main->setting.flag |= firewall_main_flag_print_last_e; diff --git a/level_3/fss_identify/c/main/common.c b/level_3/fss_identify/c/main/common.c index 714e443..d154a55 100644 --- a/level_3/fss_identify/c/main/common.c +++ b/level_3/fss_identify/c/main/common.c @@ -17,14 +17,14 @@ extern "C" { // Identify and process first/last parameters. if (main->program.parameters.array[f_console_standard_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fss_identify_main_flag_print_first_e; + main->setting.flag &= ~fss_identify_main_flag_print_first_e; } else { main->setting.flag |= fss_identify_main_flag_print_first_e; } if (main->program.parameters.array[f_console_standard_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fss_identify_main_flag_print_last_e; + main->setting.flag &= ~fss_identify_main_flag_print_last_e; } else { main->setting.flag |= fss_identify_main_flag_print_last_e; @@ -88,21 +88,21 @@ extern "C" { main->setting.flag |= fss_identify_main_flag_content_e; } else { - main->setting.flag -= main->setting.flag & fss_identify_main_flag_content_e; + main->setting.flag &= ~fss_identify_main_flag_content_e; } if (main->program.parameters.array[fss_identify_parameter_object_e].result & f_console_result_found_e) { main->setting.flag |= fss_identify_main_flag_object_e; } else { - main->setting.flag -= main->setting.flag & fss_identify_main_flag_object_e; + main->setting.flag &= ~fss_identify_main_flag_object_e; } if (main->program.parameters.array[fss_identify_parameter_total_e].result & f_console_result_found_e) { main->setting.flag |= fss_identify_main_flag_total_e; } else { - main->setting.flag -= main->setting.flag & fss_identify_main_flag_total_e; + main->setting.flag &= ~fss_identify_main_flag_total_e; } if (main->program.parameters.array[fss_identify_parameter_line_e].result & f_console_result_value_e) { @@ -139,7 +139,7 @@ extern "C" { return; } else { - main->setting.flag -= main->setting.flag & fss_identify_main_flag_line_e; + main->setting.flag &= ~fss_identify_main_flag_line_e; } if (main->program.parameters.array[fss_identify_parameter_name_e].result & f_console_result_value_e) { @@ -253,7 +253,7 @@ extern "C" { return; } else { - main->setting.flag -= main->setting.flag & fss_identify_parameter_name_e; + main->setting.flag &= ~fss_identify_parameter_name_e; } if (main->program.parameters.remaining.used) { @@ -286,14 +286,14 @@ extern "C" { main->setting.flag |= fss_identify_main_flag_file_from_e; } else { - main->setting.flag -= main->setting.flag & fss_identify_main_flag_file_from_e; + main->setting.flag &= ~fss_identify_main_flag_file_from_e; } if (main->program.pipe & fll_program_data_pipe_input_e) { main->setting.flag |= fss_identify_main_flag_pipe_e; } else { - main->setting.flag -= main->setting.flag & fss_identify_main_flag_pipe_e; + main->setting.flag &= ~fss_identify_main_flag_pipe_e; } if (!(main->setting.flag & fss_identify_main_flag_pipe_e | fss_identify_main_flag_file_from_e)) { diff --git a/level_3/fss_read/c/main/common.c b/level_3/fss_read/c/main/common.c index 403e51d..cd4862c 100644 --- a/level_3/fss_read/c/main/common.c +++ b/level_3/fss_read/c/main/common.c @@ -55,14 +55,14 @@ extern "C" { // Identify and process first/last parameters. if (parameters->array[f_console_standard_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fss_read_main_flag_print_first_e; + main->setting.flag &= ~fss_read_main_flag_print_first_e; } else { main->setting.flag |= fss_read_main_flag_print_first_e; } if (parameters->array[f_console_standard_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fss_read_main_flag_print_last_e; + main->setting.flag &= ~fss_read_main_flag_print_last_e; } else { main->setting.flag |= fss_read_main_flag_print_last_e; @@ -139,7 +139,7 @@ extern "C" { main->setting.flag |= fss_read_main_flag_pipe_e; } else { - main->setting.flag -= main->setting.flag & fss_read_main_flag_pipe_e; + main->setting.flag &= ~fss_read_main_flag_pipe_e; } { diff --git a/level_3/fss_read/c/main/main.c b/level_3/fss_read/c/main/main.c index 4ba12a5..0594054 100644 --- a/level_3/fss_read/c/main/main.c +++ b/level_3/fss_read/c/main/main.c @@ -113,12 +113,12 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { // Setup default standard (except for process_help): FSS-0000 (Basic). main->setting.standard = fss_read_basic_standard_s; - main->setting.flag -= main->setting.flag & fss_read_main_flag_content_has_close_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_object_as_line_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_object_trim_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_trim_object_e; + main->setting.flag &= ~fss_read_main_flag_content_has_close_e; + main->setting.flag &= ~fss_read_main_flag_content_multiple_e; + main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; + main->setting.flag &= ~fss_read_main_flag_object_as_line_e; + main->setting.flag &= ~fss_read_main_flag_object_trim_e; + main->setting.flag &= ~fss_read_main_flag_trim_object_e; main->setting.flag |= fss_read_main_flag_line_single_e; main->setting.flag |= fss_read_main_flag_quote_content_e | fss_read_main_flag_quote_object_e; @@ -150,12 +150,12 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_basic_standard_s; // Remove flags not supported for this standard. - main->setting.flag -= main->setting.flag & fss_read_main_flag_content_has_close_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_object_as_line_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_object_trim_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_trim_object_e; + main->setting.flag &= ~fss_read_main_flag_content_has_close_e; + main->setting.flag &= ~fss_read_main_flag_content_multiple_e; + main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; + main->setting.flag &= ~fss_read_main_flag_object_as_line_e; + main->setting.flag &= ~fss_read_main_flag_object_trim_e; + main->setting.flag &= ~fss_read_main_flag_trim_object_e; main->setting.flag |= fss_read_main_flag_line_single_e; main->setting.flag |= fss_read_main_flag_quote_content_e | fss_read_main_flag_quote_object_e; @@ -176,11 +176,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_extended_standard_s; // Remove flags not supported for this standard. - main->setting.flag -= main->setting.flag & fss_read_main_flag_content_has_close_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_object_as_line_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_object_trim_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_trim_object_e; + main->setting.flag &= ~fss_read_main_flag_content_has_close_e; + main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; + main->setting.flag &= ~fss_read_main_flag_object_as_line_e; + main->setting.flag &= ~fss_read_main_flag_object_trim_e; + main->setting.flag &= ~fss_read_main_flag_trim_object_e; main->setting.flag |= fss_read_main_flag_line_single_e | fss_read_main_flag_content_multiple_e; main->setting.flag |= fss_read_main_flag_quote_content_e | fss_read_main_flag_quote_object_e; @@ -201,12 +201,12 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_basic_list_standard_s; // Remove flags not supported for this standard. - main->setting.flag -= main->setting.flag & fss_read_main_flag_content_has_close_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_line_single_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e; + main->setting.flag &= ~fss_read_main_flag_content_has_close_e; + main->setting.flag &= ~fss_read_main_flag_content_multiple_e; + main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; + main->setting.flag &= ~fss_read_main_flag_line_single_e; + main->setting.flag &= ~fss_read_main_flag_quote_content_e; + main->setting.flag &= ~fss_read_main_flag_quote_object_e; main->setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e; @@ -226,11 +226,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_extended_list_standard_s; // Remove flags not supported for this standard. - main->setting.flag -= main->setting.flag & fss_read_main_flag_line_single_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e; + main->setting.flag &= ~fss_read_main_flag_line_single_e; + main->setting.flag &= ~fss_read_main_flag_content_multiple_e; + main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; + main->setting.flag &= ~fss_read_main_flag_quote_content_e; + main->setting.flag &= ~fss_read_main_flag_quote_object_e; main->setting.flag |= fss_read_main_flag_content_has_close_e; main->setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e; @@ -251,10 +251,10 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_embedded_list_standard_s; // Remove flags not supported for this standard. - main->setting.flag -= main->setting.flag & fss_read_main_flag_content_has_close_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_line_single_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e; + main->setting.flag &= ~fss_read_main_flag_content_has_close_e; + main->setting.flag &= ~fss_read_main_flag_line_single_e; + main->setting.flag &= ~fss_read_main_flag_quote_content_e; + main->setting.flag &= ~fss_read_main_flag_quote_object_e; main->setting.flag |= fss_read_main_flag_content_has_close_e | fss_read_main_flag_content_multiple_e; main->setting.flag |= fss_read_main_flag_depth_multiple_e; @@ -276,12 +276,12 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_read_payload_standard_s; // Remove flags not supported for this standard. - main->setting.flag -= main->setting.flag & fss_read_main_flag_content_has_close_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_line_single_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e; - main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e; + main->setting.flag &= ~fss_read_main_flag_content_has_close_e; + main->setting.flag &= ~fss_read_main_flag_content_multiple_e; + main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; + main->setting.flag &= ~fss_read_main_flag_line_single_e; + main->setting.flag &= ~fss_read_main_flag_quote_content_e; + main->setting.flag &= ~fss_read_main_flag_quote_object_e; main->setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e; diff --git a/level_3/fss_write/c/main/common.c b/level_3/fss_write/c/main/common.c index 6c47841..203c3b3 100644 --- a/level_3/fss_write/c/main/common.c +++ b/level_3/fss_write/c/main/common.c @@ -17,14 +17,14 @@ extern "C" { // Identify and process first/last parameters. if (main->program.parameters.array[f_console_standard_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fss_write_main_flag_print_first_e; + main->setting.flag &= ~fss_write_main_flag_print_first_e; } else { main->setting.flag |= fss_write_main_flag_print_first_e; } if (main->program.parameters.array[f_console_standard_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & fss_write_main_flag_print_last_e; + main->setting.flag &= ~fss_write_main_flag_print_last_e; } else { main->setting.flag |= fss_write_main_flag_print_last_e; @@ -84,7 +84,7 @@ extern "C" { main->setting.flag |= fss_write_main_flag_pipe_e; } else { - main->setting.flag -= main->setting.flag & fss_write_main_flag_pipe_e; + main->setting.flag &= ~fss_write_main_flag_pipe_e; } if (callback) { @@ -544,9 +544,7 @@ extern "C" { else { // There is no Object or Content, so remove ignores if set. - if (main->setting.flag & fss_write_main_flag_ignore_e) { - main->setting.flag -= fss_write_main_flag_ignore_e; - } + main->setting.flag &= ~fss_write_main_flag_ignore_e; } if (main->program.parameters.array[fss_write_parameter_partial_e].result & f_console_result_found_e) { diff --git a/level_3/fss_write/c/main/fss_write.c b/level_3/fss_write/c/main/fss_write.c index 6faa74a..24f322f 100644 --- a/level_3/fss_write/c/main/fss_write.c +++ b/level_3/fss_write/c/main/fss_write.c @@ -257,7 +257,7 @@ extern "C" { } // Reset the "has Content for Object" flag and associated contents array used length. - flag -= flag | 0x4; + flag &= ~0x4; main->setting.contents->used = 0; main->setting.state.status = f_memory_array_increase_by(main->setting.block.used, sizeof(f_char_t), (void **) &main->setting.object->string, &main->setting.object->used, &main->setting.object->size); diff --git a/level_3/fss_write/c/main/main.c b/level_3/fss_write/c/main/main.c index 1160b0f..ceeb28e 100644 --- a/level_3/fss_write/c/main/main.c +++ b/level_3/fss_write/c/main/main.c @@ -122,8 +122,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_write_basic_standard_s; // Remove flags not supported for this standard. - main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; - main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; + main->setting.flag &= ~(fss_write_main_flag_ignore_e | fss_write_main_flag_content_multiple_e); main->callback.process_content = &fss_write_basic_process_content; main->callback.process_help = &fss_write_basic_process_help; @@ -140,8 +139,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_write_extended_standard_s; // Remove flags not supported for this standard. - main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; - + main->setting.flag &= ~fss_write_main_flag_ignore_e; main->setting.flag |= fss_write_main_flag_content_multiple_e; main->callback.process_content = &fss_write_extended_process_content; @@ -159,8 +157,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_write_basic_list_standard_s; // Remove flags not supported for this standard. - main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; - main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; + main->setting.flag &= ~(fss_write_main_flag_ignore_e | fss_write_main_flag_content_multiple_e); main->callback.process_content = &fss_write_basic_list_process_content; main->callback.process_help = &fss_write_basic_list_process_help; @@ -177,8 +174,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_write_extended_list_standard_s; // Remove flags not supported for this standard. - main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; - + main->setting.flag &= ~fss_write_main_flag_content_multiple_e; main->setting.flag |= fss_write_main_flag_ignore_e; main->callback.process_content = &fss_write_extended_list_process_content; @@ -213,8 +209,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.standard = fss_write_payload_standard_s; // Remove flags not supported for this standard. - main->setting.flag -= main->setting.flag & fss_write_main_flag_ignore_e; - main->setting.flag -= main->setting.flag & fss_write_main_flag_content_multiple_e; + main->setting.flag &= ~(fss_write_main_flag_ignore_e | fss_write_main_flag_content_multiple_e); main->callback.process_content = 0; main->callback.process_help = &fss_write_payload_process_help; diff --git a/level_3/fss_write/c/payload/fss_write.c b/level_3/fss_write/c/payload/fss_write.c index 105bde9..4a4f907 100644 --- a/level_3/fss_write/c/payload/fss_write.c +++ b/level_3/fss_write/c/payload/fss_write.c @@ -129,7 +129,7 @@ extern "C" { } // Reset the "has Content for Object" flag and associated contents array used length. - flag -= flag | 0x4; + flag &= ~0x4; main->setting.contents->used = 0; main->setting.state.status = f_memory_array_increase_by(main->setting.block.used, sizeof(f_char_t), (void **) &main->setting.object->string, &main->setting.object->used, &main->setting.object->size); diff --git a/level_3/iki_read/c/main/common.c b/level_3/iki_read/c/main/common.c index b2b5355..4752e1e 100644 --- a/level_3/iki_read/c/main/common.c +++ b/level_3/iki_read/c/main/common.c @@ -17,14 +17,14 @@ extern "C" { // Identify and process first/last parameters. if (main->program.parameters.array[f_console_standard_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & iki_read_main_flag_print_first_e; + main->setting.flag &= ~iki_read_main_flag_print_first_e; } else { main->setting.flag |= iki_read_main_flag_print_first_e; } if (main->program.parameters.array[f_console_standard_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & iki_read_main_flag_print_last_e; + main->setting.flag &= ~iki_read_main_flag_print_last_e; } else { main->setting.flag |= iki_read_main_flag_print_last_e; @@ -86,7 +86,7 @@ extern "C" { main->setting.flag |= iki_read_main_flag_pipe_e; } else { - main->setting.flag -= main->setting.flag & iki_read_main_flag_pipe_e; + main->setting.flag &= ~iki_read_main_flag_pipe_e; } if (!(main->program.parameters.remaining.used || (main->program.pipe & fll_program_data_pipe_input_e))) { diff --git a/level_3/iki_write/c/main/common.c b/level_3/iki_write/c/main/common.c index 5595c72..e21e33d 100644 --- a/level_3/iki_write/c/main/common.c +++ b/level_3/iki_write/c/main/common.c @@ -17,14 +17,14 @@ extern "C" { // Identify and process first/last parameters. if (main->program.parameters.array[f_console_standard_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & iki_write_main_flag_print_first_e; + main->setting.flag &= ~iki_write_main_flag_print_first_e; } else { main->setting.flag |= iki_write_main_flag_print_first_e; } if (main->program.parameters.array[f_console_standard_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & iki_write_main_flag_print_last_e; + main->setting.flag &= ~iki_write_main_flag_print_last_e; } else { main->setting.flag |= iki_write_main_flag_print_last_e; @@ -90,7 +90,7 @@ extern "C" { main->setting.flag |= iki_write_main_flag_pipe_e; } else { - main->setting.flag -= main->setting.flag & iki_write_main_flag_pipe_e; + main->setting.flag &= ~iki_write_main_flag_pipe_e; } if (main->program.parameters.array[iki_write_parameter_file_e].result & f_console_result_value_e && main->program.parameters.array[iki_write_parameter_file_e].values.used) { diff --git a/level_3/status_code/c/main/common.c b/level_3/status_code/c/main/common.c index 35d7b54..9035839 100644 --- a/level_3/status_code/c/main/common.c +++ b/level_3/status_code/c/main/common.c @@ -17,14 +17,14 @@ extern "C" { // Identify and process first/last parameters. if (main->program.parameters.array[f_console_standard_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & status_code_main_flag_print_first_e; + main->setting.flag &= ~status_code_main_flag_print_first_e; } else { main->setting.flag |= status_code_main_flag_print_first_e; } if (main->program.parameters.array[f_console_standard_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & status_code_main_flag_print_last_e; + main->setting.flag &= ~status_code_main_flag_print_last_e; } else { main->setting.flag |= status_code_main_flag_print_last_e; @@ -86,7 +86,7 @@ extern "C" { main->setting.flag |= status_code_main_flag_pipe_e; } else { - main->setting.flag -= main->setting.flag & status_code_main_flag_pipe_e; + main->setting.flag &= ~status_code_main_flag_pipe_e; } if (main->program.parameters.array[status_code_parameter_error_e].result & f_console_result_found_e) { diff --git a/level_3/utf8/c/main/common.c b/level_3/utf8/c/main/common.c index 10f1a64..9a79b2a 100644 --- a/level_3/utf8/c/main/common.c +++ b/level_3/utf8/c/main/common.c @@ -17,14 +17,14 @@ extern "C" { // Identify and process first/last parameters. if (main->program.parameters.array[f_console_standard_parameter_line_first_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & utf8_main_flag_print_first_e; + main->setting.flag &= ~utf8_main_flag_print_first_e; } else { main->setting.flag |= utf8_main_flag_print_first_e; } if (main->program.parameters.array[f_console_standard_parameter_line_last_no_e].result & f_console_result_found_e) { - main->setting.flag -= main->setting.flag & utf8_main_flag_print_last_e; + main->setting.flag &= ~utf8_main_flag_print_last_e; } else { main->setting.flag |= utf8_main_flag_print_last_e; @@ -88,11 +88,11 @@ extern "C" { } if (choices.array[choice] == utf8_parameter_from_bytesequence_e) { - main->setting.mode -= main->setting.mode & utf8_mode_from_codepoint_e; + main->setting.mode &= ~utf8_mode_from_codepoint_e; main->setting.mode |= utf8_mode_from_bytesequence_e; } else if (choices.array[choice] == utf8_parameter_from_codepoint_e) { - main->setting.mode -= main->setting.mode & utf8_mode_from_bytesequence_e; + main->setting.mode &= ~utf8_mode_from_bytesequence_e; main->setting.mode |= utf8_mode_from_codepoint_e; } } @@ -117,22 +117,15 @@ extern "C" { } if (choices.array[choice] == utf8_parameter_to_bytesequence_e) { - main->setting.mode -= main->setting.mode & utf8_mode_to_codepoint_e; - main->setting.mode -= main->setting.mode & utf8_mode_to_combining_e; - main->setting.mode -= main->setting.mode & utf8_mode_to_width_e; - + main->setting.mode &= ~(utf8_mode_to_codepoint_e | utf8_mode_to_combining_e | utf8_mode_to_width_e); main->setting.mode |= utf8_mode_to_bytesequence_e; } else if (choices.array[choice] == utf8_parameter_to_codepoint_e) { - main->setting.mode -= main->setting.mode & utf8_mode_to_bytesequence_e; - main->setting.mode -= main->setting.mode & utf8_mode_to_combining_e; - main->setting.mode -= main->setting.mode & utf8_mode_to_width_e; - + main->setting.mode &= ~(utf8_mode_to_bytesequence_e | utf8_mode_to_combining_e | utf8_mode_to_width_e); main->setting.mode |= utf8_mode_to_codepoint_e; } else if (choices.array[choice] == utf8_parameter_to_combining_e) { - main->setting.mode -= main->setting.mode & utf8_mode_to_bytesequence_e; - main->setting.mode -= main->setting.mode & utf8_mode_to_codepoint_e; + main->setting.mode &= ~(utf8_mode_to_bytesequence_e | utf8_mode_to_codepoint_e); // --to_width may be specified with --to_combining. if (main->program.parameters.array[utf8_parameter_to_width_e].result & f_console_result_found_e) { @@ -142,8 +135,7 @@ extern "C" { main->setting.mode |= utf8_mode_to_combining_e; } else if (choices.array[choice] == utf8_parameter_to_width_e) { - main->setting.mode -= main->setting.mode & utf8_mode_to_bytesequence_e; - main->setting.mode -= main->setting.mode & utf8_mode_to_codepoint_e; + main->setting.mode &= ~(utf8_mode_to_bytesequence_e | utf8_mode_to_codepoint_e); // --to_width may be specified with --to_combining. if (main->program.parameters.array[utf8_parameter_to_combining_e].result & f_console_result_found_e) { @@ -177,7 +169,7 @@ extern "C" { main->setting.flag |= utf8_main_flag_pipe_e; } else { - main->setting.flag -= main->setting.flag & utf8_main_flag_pipe_e; + main->setting.flag &= ~utf8_main_flag_pipe_e; } if (main->program.parameters.array[utf8_parameter_to_file_e].result & f_console_result_value_e) { @@ -263,7 +255,7 @@ extern "C" { } else { main->program.output.to = main->program.message.to; - main->setting.flag -= main->setting.flag & utf8_main_flag_file_to_e; + main->setting.flag &= ~utf8_main_flag_file_to_e; } if (main->program.parameters.array[utf8_parameter_from_file_e].result & f_console_result_value_e) { @@ -343,7 +335,7 @@ extern "C" { return; } else { - main->setting.flag -= main->setting.flag & utf8_main_flag_file_from_e; + main->setting.flag &= ~utf8_main_flag_file_from_e; } if (main->program.parameters.remaining.used) { -- 1.8.3.1