From: Kevin Day Date: Wed, 21 Oct 2020 23:30:45 +0000 (-0500) Subject: Bugfix: actually finish implementing delimit changes. X-Git-Tag: 0.5.1~23 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=0021b7e0b872d5c51a557ee5426bb56b74c6311d;p=fll Bugfix: actually finish implementing delimit changes. It seems that I forgot to check the other programs and update them to work with the new delimit handling behavior in the appropriate FSS processing functions. --- diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index 4d1f06a..d4f7782 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -1309,15 +1309,25 @@ extern "C" { } else if (F_status_is_error_not(*status)) { f_string_range_t range = f_macro_string_range_t_initialize(buffer.used); + f_fss_delimits_t delimits = f_fss_delimits_t_initialize; - *status = fll_fss_extended_read(&buffer, &range, &objects, &contents, 0, 0); + *status = fll_fss_extended_read(&buffer, &range, &objects, &contents, 0, 0, &delimits); if (F_status_is_error(*status)) { fake_print_error_fss(data, F_status_set_fine(*status), "fll_fss_extended_read", data.file_data_build_settings.string, range, F_true); } else { - fake_build_load_setting_process(data, setting_file.used ? path_file : data.file_data_build_settings.string, buffer, objects, contents, setting, status); + *status = fl_fss_apply_delimit(delimits, &buffer); + + if (F_status_is_error(*status)) { + fll_error_print(data.error, F_status_set_fine(*status), "fl_fss_apply_delimit", F_true); + } + else { + fake_build_load_setting_process(data, setting_file.used ? path_file : data.file_data_build_settings.string, buffer, objects, contents, setting, status); + } } + + f_macro_fss_delimits_t_delete_simple(delimits); } f_macro_string_dynamic_t_delete_simple(buffer); diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index b5b0f8b..1777c03 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -203,12 +203,25 @@ extern "C" { { f_string_range_t range = f_macro_string_range_t_initialize(data_make->buffer.used); + f_fss_delimits_t delimits = f_fss_delimits_t_initialize; - *status = fll_fss_basic_list_read(&data_make->buffer, &range, &list_objects, &list_contents); + *status = fll_fss_basic_list_read(&data_make->buffer, &range, &list_objects, &list_contents, &delimits); if (F_status_is_error(*status)) { fake_print_error_fss(data, *status, "fll_fss_basic_list_read", data.file_data_build_fakefile.string, range, F_true); + f_macro_fss_delimits_t_delete_simple(delimits); + f_macro_fss_objects_t_delete_simple(list_objects); + f_macro_fss_contents_t_delete_simple(list_contents); + return; + } + + *status = fl_fss_apply_delimit(delimits, &data_make->buffer); + + if (F_status_is_error(*status)) { + fll_error_print(data.error, F_status_set_fine(*status), "fl_fss_apply_delimit", F_true); + + f_macro_fss_delimits_t_delete_simple(delimits); f_macro_fss_objects_t_delete_simple(list_objects); f_macro_fss_contents_t_delete_simple(list_contents); return; @@ -240,6 +253,7 @@ extern "C" { { f_string_range_t content_range = f_string_range_t_initialize; + f_fss_delimits_t delimits = f_fss_delimits_t_initialize; for (f_array_length_t i = 0; i < list_objects.used; i++) { @@ -249,18 +263,26 @@ extern "C" { } if (fl_string_dynamic_partial_compare(name_settings, data_make->buffer, name_settings_range, list_objects.array[i]) == F_equal_to) { + if (!missing_settings) { fake_print_warning_settings_object_multiple(data, data.file_data_build_fakefile.string, "list", name_settings.string); continue; } + delimits.used = 0; content_range = list_contents.array[i].array[0]; - *status = fll_fss_extended_read(&data_make->buffer, &content_range, &settings.objects, &settings.contents, 0, 0); + *status = fll_fss_extended_read(&data_make->buffer, &content_range, &settings.objects, &settings.contents, 0, 0, &delimits); if (F_status_is_error(*status)) { fake_print_error_fss(data, F_status_set_fine(*status), "fll_fss_extended_read", data.file_data_build_fakefile.string, content_range, F_true); + break; + } + + *status = fl_fss_apply_delimit(delimits, &data_make->buffer); + if (F_status_is_error(*status)) { + fll_error_print(data.error, F_status_set_fine(*status), "fl_fss_apply_delimit", F_true); break; } @@ -279,18 +301,27 @@ extern "C" { data_make->fakefile.array[data_make->fakefile.used].name = list_objects.array[i]; + delimits.used = 0; content_range = list_contents.array[i].array[0]; - *status = fll_fss_extended_read(&data_make->buffer, &content_range, &data_make->fakefile.array[data_make->fakefile.used].objects, &data_make->fakefile.array[data_make->fakefile.used].contents, 0, &data_make->fakefile.array[data_make->fakefile.used].quotess); + *status = fll_fss_extended_read(&data_make->buffer, &content_range, &data_make->fakefile.array[data_make->fakefile.used].objects, &data_make->fakefile.array[data_make->fakefile.used].contents, 0, &data_make->fakefile.array[data_make->fakefile.used].quotess, &delimits); if (F_status_is_error(*status)) { fake_print_error_fss(data, F_status_set_fine(*status), "fll_fss_extended_read", data.file_data_build_fakefile.string, content_range, F_true); + break; + } + + *status = fl_fss_apply_delimit(delimits, &data_make->buffer); + if (F_status_is_error(*status)) { + fll_error_print(data.error, F_status_set_fine(*status), "fl_fss_apply_delimit", F_true); break; } data_make->fakefile.used++; } // for + + f_macro_fss_delimits_t_delete_simple(delimits); } f_macro_fss_objects_t_delete_simple(list_objects); diff --git a/level_3/firewall/c/private-firewall.c b/level_3/firewall/c/private-firewall.c index 338c40b..2883d7d 100644 --- a/level_3/firewall/c/private-firewall.c +++ b/level_3/firewall/c/private-firewall.c @@ -646,12 +646,12 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con status = F_status_set_error(status); } else { - { - f_string_range_t input = f_string_range_t_initialize; + f_fss_delimits_t delimits = f_fss_delimits_t_initialize; - input.stop = local_buffer.used - 1; + { + f_string_range_t input = f_macro_string_range_t_initialize(local_buffer.used); - status = fll_fss_basic_read(&local_buffer, &input, &basic_objects, &basic_contents, 0); + status = fll_fss_basic_read(&local_buffer, &input, &basic_objects, &basic_contents, 0, &delimits); } if (F_status_set_error(status)) { @@ -672,7 +672,16 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con status = F_status_set_error(status); } - else { + + if (F_status_is_error_not(status)) { + status = fl_fss_apply_delimit(delimits, &local_buffer); + + if (F_status_is_error(status)) { + fll_error_print(data.error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true); + } + } + + if (F_status_is_error_not(status)) { f_string_length_t buffer_counter = 0; f_string_length_t ip_length = 0; f_string_dynamic_t ip_list_action = f_string_dynamic_t_initialize; @@ -787,6 +796,8 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con arguments.used--; } } + + f_macro_fss_delimits_t_delete_simple(delimits); } } @@ -1316,9 +1327,8 @@ f_return_status firewall_default_lock(const firewall_data_t data) { f_return_status firewall_buffer_rules(const f_string_t filename, const bool optional, firewall_local_data_t *local, firewall_data_t *data) { f_file_t file = f_file_t_initialize; - f_status_t status = F_none; - status = f_file_open(filename, 0, &file); + f_status_t status = f_file_open(filename, 0, &file); if (F_status_is_error(status)) { status = F_status_set_fine(status); @@ -1382,12 +1392,13 @@ f_return_status firewall_buffer_rules(const f_string_t filename, const bool opti return status; } - else { - f_string_range_t input = f_string_range_t_initialize; - input.stop = local->buffer.used - 1; + f_fss_delimits_t delimits = f_fss_delimits_t_initialize; + + { + f_string_range_t input = f_macro_string_range_t_initialize(local->buffer.used); - status = fll_fss_basic_list_read(&local->buffer, &input, &local->chain_objects, &local->chain_contents); + status = fll_fss_basic_list_read(&local->buffer, &input, &local->chain_objects, &local->chain_contents, &delimits); } if (F_status_is_error(status)) { @@ -1405,17 +1416,34 @@ f_return_status firewall_buffer_rules(const f_string_t filename, const bool opti else { fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.%c", fll_error_print_error, status, filename, f_string_eol[0]); } + } + else { + status = fl_fss_apply_delimit(delimits, &local->buffer); - return status; + if (F_status_is_error(status)) { + fll_error_print(data->error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true); + } } + f_macro_fss_delimits_t_delete_simple(delimits); + return status; } f_return_status firewall_process_rules(f_string_range_t *range, firewall_local_data_t *local, firewall_data_t *data) { - f_status_t status = F_none; + f_fss_delimits_t delimits = f_fss_delimits_t_initialize; + + f_status_t status = fll_fss_extended_read(&local->buffer, range, &local->rule_objects, &local->rule_contents, 0, 0, &delimits); + + if (F_status_is_error_not(status)) { + status = fl_fss_apply_delimit(delimits, &local->buffer); + + if (F_status_is_error(status)) { + fll_error_print(data->error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true); + } + } - status = fll_fss_extended_read(&local->buffer, range, &local->rule_objects, &local->rule_contents, 0, 0); + f_macro_fss_delimits_t_delete_simple(delimits); if (F_status_is_error_not(status)) { status = firewall_perform_commands(*local, *data); diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c index b490854..fb6b115 100644 --- a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c @@ -174,10 +174,7 @@ extern "C" { f_status_t status = F_none; { - f_string_range_t input = f_string_range_t_initialize; - - input.start = 0; - input.stop = data->buffer.used - 1; + f_string_range_t input = f_macro_string_range_t_initialize(data->buffer.used); delimits->used = 0; diff --git a/level_3/fss_basic_read/c/private-fss_basic_read.c b/level_3/fss_basic_read/c/private-fss_basic_read.c index 3a9ac07..e7a08b4 100644 --- a/level_3/fss_basic_read/c/private-fss_basic_read.c +++ b/level_3/fss_basic_read/c/private-fss_basic_read.c @@ -174,10 +174,7 @@ extern "C" { f_status_t status = F_none; { - f_string_range_t input = f_string_range_t_initialize; - - input.start = 0; - input.stop = data->buffer.used - 1; + f_string_range_t input = f_macro_string_range_t_initialize(data->buffer.used); delimits->used = 0; diff --git a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c index 1e2c3c0..a91fa91 100644 --- a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c @@ -174,10 +174,7 @@ extern "C" { f_status_t status = F_none; { - f_string_range_t input = f_string_range_t_initialize; - - input.start = 0; - input.stop = data->buffer.used - 1; + f_string_range_t input = f_macro_string_range_t_initialize(data->buffer.used); delimits->used = 0; diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.c b/level_3/fss_extended_read/c/private-fss_extended_read.c index d333dea..8116cf7 100644 --- a/level_3/fss_extended_read/c/private-fss_extended_read.c +++ b/level_3/fss_extended_read/c/private-fss_extended_read.c @@ -174,10 +174,7 @@ extern "C" { f_status_t status = F_none; { - f_string_range_t input = f_string_range_t_initialize; - - input.start = 0; - input.stop = data->buffer.used - 1; + f_string_range_t input = f_macro_string_range_t_initialize(data->buffer.used); delimits->used = 0; diff --git a/level_3/init/c/private-init.c b/level_3/init/c/private-init.c index eea8c53..738c77a 100644 --- a/level_3/init/c/private-init.c +++ b/level_3/init/c/private-init.c @@ -65,12 +65,14 @@ } return F_status_set_error(status); - } else { - f_string_range_t input = f_string_range_t_initialize; + } + + f_fss_delimits_t delimits = f_fss_delimits_t_initialize; - input.stop = buffer->used - 1; + { + f_string_range_t input = f_macro_string_range_t_initialize(buffer->used); - status = fll_fss_basic_list_read(buffer, &input, objects, contents); + status = fll_fss_basic_list_read(buffer, &input, objects, contents, &delimits); } if (F_status_is_error(status)) { @@ -86,8 +88,19 @@ fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.%c", fll_error_print_error, status, filename, f_string_eol[0]); } + f_macro_fss_delimits_t_delete_simple(delimits); + return F_status_set_error(status); } + else { + *status = fl_fss_apply_delimit(delimits, &buffer); + + if (F_status_is_error(*status)) { + fll_error_print(data.error, F_status_set_fine(*status), "fl_fss_apply_delimit", F_true); + } + } + + f_macro_fss_delimits_t_delete_simple(delimits); return status; } @@ -96,27 +109,28 @@ #ifndef _di_init_rules_process_main_ f_return_status init_rules_process_main(const init_data_t data, const f_string_t filename, f_string_dynamic_t *buffer, f_fss_objects_t *objects, f_fss_contents_t *contents) { f_status_t status = F_none; + f_fss_delimits_t delimits = f_fss_delimits_t_initialize; // @todo: resume replacing code below. - status = fll_fss_extended_read(&buffer, input, &local->rule_objects, &local->rule_contents, 0, 0); + status = fll_fss_extended_read(&buffer, input, &local->rule_objects, &local->rule_contents, 0, 0, &delimits); + + if (F_status_is_error_not(*status)) { + status = fl_fss_apply_delimit(delimits, &buffer); + } + + f_macro_fss_delimits_t_delete_simple(delimits); if (F_status_is_error_not(status)) { //status = init_perform_commands(*local, *data); // @fixme if (F_status_is_error(status)) { - status = F_status_set_fine(status); - - if (status == F_memory_allocation || status == F_memory_reallocation) { + if (F_status_set_fine(status) == F_memory_allocation || F_status_set_fine(status) == F_memory_reallocation) { fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.", fll_error_print_error); - } else if (status == F_failure) { + } else if (F_status_set_fine(status) == F_failure) { // the error message has already been displayed. } else { fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling firewall_perform_commands().", fll_error_print_error, status); } - - f_macro_fss_objects_t_delete_simple(local->rule_objects); - f_macro_fss_contents_t_delete_simple(local->rule_contents); - return F_status_set_error(status); } } @@ -486,6 +500,7 @@ f_fss_objects_t objects = f_fss_objects_t_initialize; f_fss_contents_t contents = f_fss_contents_t_initialize; f_string_length_t position = 0; + f_fss_delimits_t delimits = f_fss_delimits_t_initialize; // load the main file into memory. status = init_rule_buffer(&data, init_rule_core_file, &buffer, &objects, &contents); @@ -506,14 +521,20 @@ f_macro_string_dynamic_t_delete(buffer); f_macro_fss_objects_t_delete(objects); f_macro_fss_contents_t_delete(contents); + f_macro_fss_delimits_t_delete_simple(delimits); return status; } while (position < objects.used) { location.start = objects.array[position].start; location.stop = objects.array[position].stop; + delimits.used = 0; - status = fll_fss_extended_read(&buffer, &location, &objects, &contents, 0, 0); + status = fll_fss_extended_read(&buffer, &location, &objects, &contents, 0, 0, &delimits); + + if (F_status_is_error_not(*status)) { + status = fl_fss_apply_delimit(delimits, &buffer); + } position++; } // while @@ -521,7 +542,13 @@ // @fixme: resume here, below is just notes and copy&pasted code as examples/reminders. /* - status = fll_fss_extended_read(&buffer, &location, &objects, &contents, 0, 0); + delimits.used = 0; + + status = fll_fss_extended_read(&buffer, &location, &objects, &contents, 0, 0, &delimits); + + if (F_status_is_error_not(status)) { + status = fl_fss_apply_delimit(delimits, &buffer); + } if (F_status_is_error(status_process)) { if (status == F_memory_allocation || status == F_memory_reallocation) { @@ -533,6 +560,8 @@ // @todo: init_delete_data((*data)); // @todo: init_delete_stack_memory(&stack_memory); + f_macro_fss_delimits_t_delete_simple(delimits); + return status_process; } */ @@ -540,8 +569,17 @@ /* f_status_t status = F_none; + delimits.used = 0; - status = fll_fss_extended_read(buffer, location, objects, contents, 0, 0); + status = fll_fss_extended_read(buffer, location, objects, contents, 0, 0, &delimits); + + if (F_status_is_error_not(status)) { + status = fl_fss_apply_delimit(delimits, &buffer); + } + + if (F_status_is_error(*status)) { + fll_error_print(data.error, F_status_set_fine(*status), "fl_fss_apply_delimit", F_true); + } if (F_status_is_error_not(status)) { // @todo: process objects and contents. @@ -560,6 +598,7 @@ f_macro_fss_objects_t_delete_simple((*rule_objects)); f_macro_fss_contents_t_delete_simple((*rule_contents)); + f_macro_fss_delimits_t_delete_simple(delimits); return F_status_set_error(status); } } @@ -576,6 +615,7 @@ f_macro_fss_contents_t_delete_simple((*rule_contents)); */ /* + f_macro_fss_delimits_t_delete_simple(delimits); f_macro_string_dynamic_t_delete(buffer); f_macro_fss_objects_t_delete(objects); f_macro_fss_contents_t_delete(contents);