From: Kevin Day Date: Thu, 20 May 2021 00:46:49 +0000 (-0500) Subject: Cleanup: Syntax and style. X-Git-Tag: 0.5.4~30 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=6021fd0b6ca5808cfb9606a7beb0e5230e150cb4;p=fll Cleanup: Syntax and style. Minor syntax and style cleanups. --- diff --git a/level_3/controller/c/controller.c b/level_3/controller/c/controller.c index e1b7cbc..0be7382 100644 --- a/level_3/controller/c/controller.c +++ b/level_3/controller/c/controller.c @@ -50,6 +50,7 @@ extern "C" { #ifndef _di_controller_main_ f_status_t controller_main(const f_console_arguments_t arguments, controller_main_t *main) { + f_status_t status = F_none; { @@ -394,7 +395,7 @@ extern "C" { #ifndef _di_controller_main_delete_ f_status_t controller_main_delete(controller_main_t *main) { - for (f_array_length_t i = 0; i < controller_total_parameters; i++) { + for (f_array_length_t i = 0; i < controller_total_parameters; ++i) { macro_f_array_lengths_t_delete_simple(main->parameters[i].locations); macro_f_array_lengths_t_delete_simple(main->parameters[i].locations_sub); macro_f_array_lengths_t_delete_simple(main->parameters[i].values); diff --git a/level_3/controller/c/private-common.c b/level_3/controller/c/private-common.c index 48b3f13..8f744e7 100644 --- a/level_3/controller/c/private-common.c +++ b/level_3/controller/c/private-common.c @@ -561,7 +561,7 @@ extern "C" { f_thread_unlock(&process->lock); if (count < controller_thread_wait_timeout_3_before) { - count++; + ++count; } } while (status == F_time && controller_thread_is_enabled_process(process, global.thread)); diff --git a/level_3/controller/c/private-controller.c b/level_3/controller/c/private-controller.c index aafdce7..69ef095 100644 --- a/level_3/controller/c/private-controller.c +++ b/level_3/controller/c/private-controller.c @@ -160,6 +160,7 @@ extern "C" { #ifndef _di_controller_file_pid_create_ f_status_t controller_file_pid_create(const pid_t pid, const f_string_static_t path) { + f_status_t status = F_none; // the file exists, do not attempt to overwrite. @@ -313,6 +314,7 @@ extern "C" { if (processs.array[i] && processs.array[i]->action == action && fl_string_dynamic_compare(alias, processs.array[i]->rule.alias) == F_equal_to) { if (at) *at = i; + return F_true; } } // for @@ -323,6 +325,7 @@ extern "C" { #ifndef _di_controller_get_id_user_ f_status_t controller_get_id_user(const f_string_static_t buffer, const f_string_range_t range, controller_cache_t *cache, uid_t *id) { + f_number_unsigned_t number = 0; f_status_t status = fl_conversion_string_to_number_unsigned(buffer.string, range, &number); @@ -364,6 +367,7 @@ extern "C" { #ifndef _di_controller_get_id_group_ f_status_t controller_get_id_group(const f_string_static_t buffer, const f_string_range_t range, controller_cache_t *cache, gid_t *id) { + f_number_unsigned_t number = 0; f_status_t status = fl_conversion_string_to_number_unsigned(buffer.string, range, &number); @@ -405,6 +409,7 @@ extern "C" { #ifndef _di_controller_perform_ready_ f_status_t controller_perform_ready(const bool is_entry, controller_global_t global, controller_cache_t *cache) { + f_status_t status = F_none; // only create pid file when not in validate mode. @@ -453,6 +458,7 @@ extern "C" { #ifndef _di_controller_preprocess_entry_ f_status_t controller_preprocess_entry(const bool is_entry, controller_global_t global, controller_cache_t *cache) { + f_status_t status = F_none; f_status_t status2 = F_none; @@ -1144,7 +1150,7 @@ extern "C" { } } else { - global->setting->rules.used++; + ++global->setting->rules.used; } f_thread_unlock(&global->thread->lock.rule); diff --git a/level_3/controller/c/private-entry.c b/level_3/controller/c/private-entry.c index b327594..4718480 100644 --- a/level_3/controller/c/private-entry.c +++ b/level_3/controller/c/private-entry.c @@ -201,16 +201,15 @@ extern "C" { cache->object_actions.used = cache->object_actions.size; while (cache->object_actions.used) { - cache->object_actions.used--; - cache->object_actions.array[cache->object_actions.used].start = 1; + + cache->object_actions.array[--cache->object_actions.used].start = 1; cache->object_actions.array[cache->object_actions.used].stop = 0; } // while cache->content_actions.used = cache->content_actions.size; while (cache->content_actions.used) { - cache->content_actions.used--; - cache->content_actions.array[cache->content_actions.used].used = 0; + cache->content_actions.array[--cache->content_actions.used].used = 0; } // while { @@ -443,7 +442,7 @@ extern "C" { break; } - action->parameters.used++; + ++action->parameters.used; } // for if (F_status_is_error_not(action->status)) { @@ -683,7 +682,7 @@ extern "C" { } } - actions->used++; + ++actions->used; } // for if (F_status_is_error(status_action)) { diff --git a/level_3/controller/c/private-rule.c b/level_3/controller/c/private-rule.c index 7d19c00..f65276d 100644 --- a/level_3/controller/c/private-rule.c +++ b/level_3/controller/c/private-rule.c @@ -291,7 +291,7 @@ extern "C" { } else { actions->array[actions->used].parameters.used = 1; - actions->used++; + ++actions->used; } } @@ -400,6 +400,7 @@ extern "C" { actions->array[actions->used].status = F_known_not; for (f_array_length_t i = 0; i < cache->content_action.used; ++i) { + status = f_string_dynamic_partial_mash_nulless(f_string_space_s, f_string_space_length, cache->buffer_item, cache->content_action.array[i], &actions->array[actions->used].parameters.array[0]); if (F_status_is_error(status)) break; } // for @@ -443,7 +444,7 @@ extern "C" { actions->array[actions->used].status = status; } - actions->used++; + ++actions->used; } } } @@ -3217,7 +3218,7 @@ extern "C" { status = controller_rule_item_read(is_normal, global, cache, &rule->items.array[rule->items.used]); if (F_status_is_error(status)) break; - rule->items.used++; + ++rule->items.used; } else { for_item = F_false; @@ -3238,6 +3239,7 @@ extern "C" { controller_rule_item_error_print(global.main->error, cache->action, for_item, global.thread); rule->status[0] = controller_status_simplify_error(F_status_set_fine(status)); + return rule->status[0]; } @@ -3702,7 +3704,7 @@ extern "C" { continue; } - setting_maps->used++; + ++setting_maps->used; continue; } @@ -3795,7 +3797,7 @@ extern "C" { break; } - rule->control_group.groups.used++; + ++rule->control_group.groups.used; } // for } @@ -4883,7 +4885,7 @@ extern "C" { continue; } - setting_values->used++; + ++setting_values->used; } // for continue; diff --git a/level_3/controller/c/private-thread.c b/level_3/controller/c/private-thread.c index 57a0d6c..143db65 100644 --- a/level_3/controller/c/private-thread.c +++ b/level_3/controller/c/private-thread.c @@ -64,7 +64,10 @@ extern "C" { f_array_length_t j = 0; for (; j < process->path_pids.used; ++j) { - if (process->path_pids.array[j].used && f_file_exists(process->path_pids.array[j].string) == F_true) break; + + if (process->path_pids.array[j].used && f_file_exists(process->path_pids.array[j].string) == F_true) { + break; + } } // for if (j < process->path_pids.used) { @@ -355,7 +358,6 @@ extern "C" { // A forked child process should deallocate memory on exit. // It seems that this function doesn't return to the calling thread for a forked child process, even with the "return 0;" below. // Deallocate as much as possible. - controller_main_t *main = (controller_main_t *) process->main_data; controller_setting_t *setting = (controller_setting_t *) process->main_setting; controller_thread_t *thread = (controller_thread_t *) process->main_thread; @@ -455,7 +457,9 @@ extern "C" { process = global->thread->processs.array[i]; // do not cancel exit processes, when not performing "execute" during exit. - if (process->type == controller_process_type_exit && global->thread->enabled != controller_thread_enabled_exit_execute) continue; + if (process->type == controller_process_type_exit && global->thread->enabled != controller_thread_enabled_exit_execute) { + continue; + } for (j = 0; j < process->childs.used; ++j) { @@ -597,7 +601,9 @@ extern "C" { #ifndef _di_controller_thread_process_exit_ void controller_thread_process_exit(controller_global_t *global) { - if (global->thread->enabled != controller_thread_enabled_exit) return; + if (global->thread->enabled != controller_thread_enabled_exit) { + return; + } if (global->setting->ready == controller_setting_ready_done) { @@ -797,7 +803,6 @@ extern "C" { // A forked child process should deallocate memory on exit. // It seems that this function doesn't return to the calling thread for a forked child process, even with the "return 0;" below. // Deallocate as much as possible. - controller_thread_delete_simple(entry->global->thread); controller_setting_delete_simple(entry->global->setting); controller_main_delete(entry->global->main); diff --git a/level_3/fake/c/fake.c b/level_3/fake/c/fake.c index 1c4bdea..dc07e9b 100644 --- a/level_3/fake/c/fake.c +++ b/level_3/fake/c/fake.c @@ -101,6 +101,7 @@ extern "C" { #ifndef _di_fake_main_ f_status_t fake_main(const f_console_arguments_t arguments, fake_main_t *main) { + f_status_t status = F_none; { @@ -179,18 +180,18 @@ extern "C" { f_array_length_t j = 0; f_array_length_t k = 0; - for (; i < main->parameters[fake_parameter_operation_build].locations.used; i++, locations_length++) { + for (; i < main->parameters[fake_parameter_operation_build].locations.used; ++i, ++locations_length) { operations[locations_length] = fake_operation_build; locations[locations_length] = main->parameters[fake_parameter_operation_build].locations.array[i]; } // for - for (i = 0; i < main->parameters[fake_parameter_operation_clean].locations.used; i++) { + for (i = 0; i < main->parameters[fake_parameter_operation_clean].locations.used; ++i) { - for (j = 0; j < locations_length; j++) { + for (j = 0; j < locations_length; ++j) { if (main->parameters[fake_parameter_operation_clean].locations.array[i] < locations[j]) { - for (k = locations_length; k > j; k--) { + for (k = locations_length; k > j; --k) { locations[k] = locations[k - 1]; operations[k] = operations[k - 1]; } // for @@ -201,15 +202,15 @@ extern "C" { locations[j] = main->parameters[fake_parameter_operation_clean].locations.array[i]; operations[j] = fake_operation_clean; - locations_length++; + ++locations_length; } // for - for (i = 0; i < main->parameters[fake_parameter_operation_make].locations.used; i++) { + for (i = 0; i < main->parameters[fake_parameter_operation_make].locations.used; ++i) { - for (j = 0; j < locations_length; j++) { + for (j = 0; j < locations_length; ++j) { if (main->parameters[fake_parameter_operation_make].locations.array[i] < locations[j]) { - for (k = locations_length; k > j; k--) { + for (k = locations_length; k > j; --k) { locations[k] = locations[k - 1]; operations[k] = operations[k - 1]; } // for @@ -220,15 +221,16 @@ extern "C" { locations[j] = main->parameters[fake_parameter_operation_make].locations.array[i]; operations[j] = fake_operation_make; - locations_length++; + ++locations_length; } // for - for (i = 0; i < main->parameters[fake_parameter_operation_skeleton].locations.used; i++) { + for (i = 0; i < main->parameters[fake_parameter_operation_skeleton].locations.used; ++i) { - for (j = 0; j < locations_length; j++) { + for (j = 0; j < locations_length; ++j) { if (main->parameters[fake_parameter_operation_skeleton].locations.array[i] < locations[j]) { - for (k = locations_length; k > j; k--) { + for (k = locations_length; k > j; --k) { + locations[k] = locations[k - 1]; operations[k] = operations[k - 1]; } // for @@ -239,7 +241,7 @@ extern "C" { locations[j] = main->parameters[fake_parameter_operation_skeleton].locations.array[i]; operations[j] = fake_operation_skeleton; - locations_length++; + ++locations_length; } // for } @@ -270,10 +272,12 @@ extern "C" { if (F_status_is_error(status)) { fake_main_delete(main); + return F_status_set_error(status); } - for (uint8_t i = 0; i < operations_length; i++) { + for (uint8_t i = 0; i < operations_length; ++i) { + main->operation = operations[i]; if (main->operation == fake_operation_build) { diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index ba6255f..5c666e4 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -11,6 +11,7 @@ extern "C" { #ifndef _di_fake_build_arguments_standard_add_ void fake_build_arguments_standard_add(const fake_main_t main, const fake_build_data_t data_build, const bool is_shared, const bool is_library, f_string_dynamics_t *arguments, f_status_t *status) { + if (F_status_is_error(*status)) return; f_array_length_t build_libraries_length = fake_build_parameter_library_link_path_length + main.path_build_libraries_shared.used; @@ -45,7 +46,8 @@ extern "C" { build_includes_length, }; - for (uint8_t i = 0; i < 2; i++) { + for (uint8_t i = 0; i < 2; ++i) { + *status = fll_execute_arguments_add(values[i], lengths[i], arguments); if (F_status_is_error(*status)) break; } // for @@ -94,34 +96,34 @@ extern "C" { } if (F_status_is_error_not(*status)) { - for (f_array_length_t i = 0; i < data_build.setting.build_libraries.used; i++) { + for (f_array_length_t i = 0; i < data_build.setting.build_libraries.used; ++i) { *status = fll_execute_arguments_add(data_build.setting.build_libraries.array[i].string, data_build.setting.build_libraries.array[i].used, arguments); if (F_status_is_error(*status)) break; } // for } - for (f_array_length_t i = 0; i < data_build.setting.flags_all.used && F_status_is_error_not(*status); i++) { + for (f_array_length_t i = 0; i < data_build.setting.flags_all.used && F_status_is_error_not(*status); ++i) { *status = fll_execute_arguments_add(data_build.setting.flags_all.array[i].string, data_build.setting.flags_all.array[i].used, arguments); if (F_status_is_error(*status)) break; } // for - for (f_array_length_t i = 0; i < data_build.setting.flags_shared.used && F_status_is_error_not(*status); i++) { + for (f_array_length_t i = 0; i < data_build.setting.flags_shared.used && F_status_is_error_not(*status); ++i) { *status = fll_execute_arguments_add(data_build.setting.flags_shared.array[i].string, data_build.setting.flags_shared.array[i].used, arguments); if (F_status_is_error(*status)) break; } // for if (is_library) { - for (f_array_length_t j = 0; j < data_build.setting.flags_library.used && F_status_is_error_not(*status); j++) { + for (f_array_length_t j = 0; j < data_build.setting.flags_library.used && F_status_is_error_not(*status); ++j) { *status = fll_execute_arguments_add(data_build.setting.flags_library.array[j].string, data_build.setting.flags_library.array[j].used, arguments); if (F_status_is_error(*status)) break; } // for } else { - for (f_array_length_t i = 0; i < data_build.setting.flags_program.used && F_status_is_error_not(*status); i++) { + for (f_array_length_t i = 0; i < data_build.setting.flags_program.used && F_status_is_error_not(*status); ++i) { *status = fll_execute_arguments_add(data_build.setting.flags_program.array[i].string, data_build.setting.flags_program.array[i].used, arguments); if (F_status_is_error(*status)) break; @@ -132,7 +134,7 @@ extern "C" { f_array_length_t length = 0; f_array_length_t i = 0; - for (; i < main.define.used && F_status_is_error_not(*status); i++) { + for (; i < main.define.used && F_status_is_error_not(*status); ++i) { *status = fll_execute_arguments_add(main.define.array[i].string, main.define.array[i].used, arguments); if (F_status_is_error(*status)) break; @@ -142,21 +144,21 @@ extern "C" { f_array_length_t length = 0; f_array_length_t i = 0; - for (; i < data_build.setting.defines_all.used && F_status_is_error_not(*status); i++) { + for (; i < data_build.setting.defines_all.used && F_status_is_error_not(*status); ++i) { *status = fll_execute_arguments_add(data_build.setting.defines_all.array[i].string, data_build.setting.defines_all.array[i].used, arguments); if (F_status_is_error(*status)) break; } // for if (is_shared) { - for (i = 0; i < data_build.setting.defines_shared.used && F_status_is_error_not(*status); i++) { + for (i = 0; i < data_build.setting.defines_shared.used && F_status_is_error_not(*status); ++i) { *status = fll_execute_arguments_add(data_build.setting.defines_shared.array[i].string, data_build.setting.defines_shared.array[i].used, arguments); if (F_status_is_error(*status)) break; } // for } else { - for (i = 0; i < data_build.setting.defines_static.used && F_status_is_error_not(*status); i++) { + for (i = 0; i < data_build.setting.defines_static.used && F_status_is_error_not(*status); ++i) { *status = fll_execute_arguments_add(data_build.setting.defines_static.array[i].string, data_build.setting.defines_static.array[i].used, arguments); if (F_status_is_error(*status)) break; @@ -168,10 +170,12 @@ extern "C" { #ifndef _di_fake_build_copy_ void fake_build_copy(const fake_main_t main, const f_mode_t mode, const f_string_t label, const f_string_static_t source, const f_string_static_t destination, const f_string_statics_t files, const f_string_static_t file_stage, const f_array_length_t preserve, f_status_t *status) { + if (F_status_is_error(*status) || f_file_exists(file_stage.string) == F_true || *status == F_child) return; if (fake_signal_received(main)) { *status = F_status_set_error(F_signal); + return; } @@ -206,7 +210,8 @@ extern "C" { recurse.failures = &failures; - for (f_array_length_t i = 0; i < files.used; i++) { + for (f_array_length_t i = 0; i < files.used; ++i) { + if (!files.array[i].used) continue; path_source.used = source.used; @@ -265,7 +270,7 @@ extern "C" { if (F_status_is_error(*status)) { if (main.error.verbosity == f_console_verbosity_verbose) { - for (f_array_length_t j = 0; j < failures.used; j++) { + for (f_array_length_t j = 0; j < failures.used; ++j) { fake_print_error_build_operation_file(main, F_status_set_fine(*status), "fl_directory_copy", "copy directory", "to", path_source.string, destination_directory.string, F_true); } // for @@ -382,6 +387,7 @@ extern "C" { #ifndef _di_fake_build_skeleton_ void fake_build_skeleton(const fake_main_t main, const fake_build_data_t data_build, const mode_t mode, const f_string_static_t file_stage, f_status_t *status) { + if (F_status_is_error(*status) || f_file_exists(file_stage.string) == F_true || *status == F_child) return; if (fake_signal_received(main)) { @@ -436,12 +442,13 @@ extern "C" { fprintf(main.output.stream, "%c", f_string_eol_s[0]); } - for (uint8_t i = 0; i < 15; i++) { + for (uint8_t i = 0; i < 15; ++i) { if (!directorys[i]->used) continue; if (fake_signal_received(main)) { *status = F_status_set_error(F_signal); + return; } @@ -494,11 +501,13 @@ extern "C" { #ifndef _di_fake_build_execute_process_script_ int fake_build_execute_process_script(const fake_main_t main, const fake_build_data_t data_build, const f_string_static_t process_script, const f_string_static_t file_stage, f_status_t *status) { + if (F_status_is_error(*status) || f_file_exists(file_stage.string) == F_true || *status == F_child) return main.child; if (!process_script.used) return 0; if (fake_signal_received(main)) { *status = F_status_set_error(F_signal); + return 0; } @@ -551,7 +560,7 @@ extern "C" { f_string_dynamic_t defines = f_string_dynamic_t_initialize; if (main.define.used) { - for (f_array_length_t i = 0; i < main.define.used; i++) { + for (f_array_length_t i = 0; i < main.define.used; ++i) { *status = f_string_dynamic_mash(f_string_space_s, 1, main.define.array[i], &defines); @@ -731,6 +740,7 @@ extern "C" { #ifndef _di_fake_build_get_file_name_without_extension_ f_status_t fake_build_get_file_name_without_extension(const fake_main_t main, const f_string_static_t path, f_string_dynamic_t *name) { + name->used = 0; if (!path.used) return F_none; @@ -739,12 +749,14 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "f_file_name_base", F_true); + return status; } f_array_length_t i = name->used; - for (; i > 0; i--) { + for (; i > 0; --i) { + if (name->string[i] == f_path_extension_separator[0]) { name->used = i; break; @@ -755,6 +767,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main.error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true); + return status; } @@ -776,6 +789,7 @@ extern "C" { #ifndef _di_fake_build_library_shared_ int fake_build_library_shared(const fake_main_t main, const fake_build_data_t data_build, const f_mode_t mode, const f_string_static_t file_stage, f_status_t *status) { + if (F_status_is_error(*status) || f_file_exists(file_stage.string) == F_true || *status == F_child) return main.child; if (!data_build.setting.build_sources_library.used) return 0; @@ -803,7 +817,7 @@ extern "C" { f_array_length_t source_length = 0; - for (f_array_length_t i = 0; i < data_build.setting.build_sources_library.used; i++) { + for (f_array_length_t i = 0; i < data_build.setting.build_sources_library.used; ++i) { source_length = path_sources->used + data_build.setting.build_sources_library.array[i].used; @@ -949,7 +963,8 @@ extern "C" { parameter_file_path_length, }; - for (uint8_t i = 0; i < 4; i++) { + for (uint8_t i = 0; i < 4; ++i) { + *status = fll_execute_arguments_add(values[i], lengths[i], &arguments); if (F_status_is_error(*status)) break; } // for @@ -1004,6 +1019,7 @@ extern "C" { if (fake_signal_received(main)) { *status = F_status_set_error(F_signal); + return 0; } @@ -1015,10 +1031,12 @@ extern "C" { else if (F_status_is_error(*status)) { if (F_status_set_fine(*status) == F_file_found) { fll_error_file_print(main.error, F_status_set_fine(*status), "f_file_link", F_true, parameter_file_path, "link", fll_error_file_type_file); + return 0; } fll_error_file_print(main.error, F_status_set_fine(*status), "f_file_link", F_true, parameter_file_name_micro, "link", fll_error_file_type_file); + return 0; } } @@ -1093,6 +1111,7 @@ extern "C" { #ifndef _di_fake_build_library_static_ int fake_build_library_static(const fake_main_t main, const fake_build_data_t data_build, const f_mode_t mode, const f_string_static_t file_stage, f_status_t *status) { + if (F_status_is_error(*status) || f_file_exists(file_stage.string) == F_true || *status == F_child) return main.child; if (!data_build.setting.build_sources_library.used) return 0; @@ -1136,7 +1155,8 @@ extern "C" { if (F_status_is_error_not(*status)) { f_array_length_t source_length = 0; - for (f_array_length_t i = 0; i < data_build.setting.build_sources_library.used; i++) { + for (f_array_length_t i = 0; i < data_build.setting.build_sources_library.used; ++i) { + source_path.used = 0; *status = fake_build_get_file_name_without_extension(main, data_build.setting.build_sources_library.array[i], &file_name); @@ -1230,6 +1250,7 @@ extern "C" { #ifndef _di_fake_build_load_environment_ void fake_build_load_environment(const fake_main_t main, const fake_build_data_t data_build, f_string_maps_t *environment, f_status_t *status) { + if (F_status_is_error(*status)) return; // reset the environment. @@ -1252,7 +1273,7 @@ extern "C" { f_path_present_working_length }; - for (uint8_t i = 0; i < 2; i++) { + for (uint8_t i = 0; i < 2; ++i) { *status = fl_environment_load_name(variables_name[i], variables_length[i], environment); @@ -1294,6 +1315,7 @@ extern "C" { #ifndef _di_fake_build_load_setting_ void fake_build_load_setting(const fake_main_t main, const f_string_static_t setting_file, fake_build_setting_t *setting, f_status_t *status) { + if (F_status_is_error(*status)) return; if (fake_signal_received(main)) { @@ -1368,7 +1390,7 @@ extern "C" { fake_build_setting_name_project_name, }; - for (uint8_t i = 0; i < 1; i++) { + for (uint8_t i = 0; i < 1; ++i) { if (!settings[i]->used) { fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); @@ -1385,6 +1407,7 @@ extern "C" { if (failed) { *status = F_status_set_error(F_failure); + return; } } @@ -1395,10 +1418,12 @@ extern "C" { #ifndef _di_fake_build_load_setting_process_ void fake_build_load_setting_process(const fake_main_t main, const f_string_t path_file, const f_string_static_t buffer, const f_fss_objects_t objects, const f_fss_contents_t contents, fake_build_setting_t *setting, f_status_t *status) { + if (F_status_is_error(*status) && buffer.used) return; if (fake_signal_received(main)) { *status = F_status_set_error(F_signal); + return; } @@ -1595,10 +1620,11 @@ extern "C" { modes = &main.mode; } - for (; i < modes->used; i++) { + for (; i < modes->used; ++i) { + found = F_false; - for (j = 0; j < setting->modes.used; j++) { + for (j = 0; j < setting->modes.used; ++j) { if (fl_string_dynamic_compare_trim(modes->array[i], setting->modes.array[j]) == F_equal_to) { found = F_true; @@ -1626,7 +1652,7 @@ extern "C" { memset(&settings_mode_names, 0, sizeof(f_string_t) * fake_build_setting_total); memset(&setting_mode_lengths, 0, sizeof(f_array_length_t) * fake_build_setting_total); - for (j = 0; j < fake_build_setting_total; j++) { + for (j = 0; j < fake_build_setting_total; ++j) { setting_mode_lengths[j] = settings_length[j] + 1 + modes->array[i].used; @@ -1652,7 +1678,7 @@ extern "C" { } } - for (j = 0; j < fake_build_setting_total; j++) { + for (j = 0; j < fake_build_setting_total; ++j) { macro_f_string_dynamic_t_delete_simple(settings_mode_name_dynamic[j]); } // for @@ -1664,18 +1690,21 @@ extern "C" { f_string_dynamic_t temporary[total_build_libraries]; for (i = 0; i < total_build_libraries; ++i) { + temporary[i].string = setting->build_libraries.array[i].string; temporary[i].used = setting->build_libraries.array[i].used; temporary[i].size = setting->build_libraries.array[i].size; } // for for (i = 0, j = total_build_libraries; j < setting->build_libraries.used; ++i, ++j) { + setting->build_libraries.array[i].string = setting->build_libraries.array[j].string; setting->build_libraries.array[i].used = setting->build_libraries.array[j].used; setting->build_libraries.array[i].size = setting->build_libraries.array[j].size; } // for for (i = setting->build_libraries.used - total_build_libraries, j = 0; j < total_build_libraries; ++i, ++j) { + setting->build_libraries.array[i].string = temporary[j].string; setting->build_libraries.array[i].used = temporary[j].used; setting->build_libraries.array[i].size = temporary[j].size; @@ -1881,7 +1910,8 @@ extern "C" { 5, }; - for (f_array_length_t i = 0; i < 27; i++) { + for (f_array_length_t i = 0; i < 27; ++i) { + if (!settings_single_source[i]->used) continue; if (settings_single_source[i]->used > 1) { @@ -1990,6 +2020,7 @@ extern "C" { } } else { + // replace any potential existing value. settings_single_destination[i]->used = 0; @@ -2048,10 +2079,12 @@ extern "C" { #ifndef _di_fake_build_load_setting_defaults_ void fake_build_load_setting_defaults(const fake_main_t main, fake_build_setting_t *setting, f_status_t *status) { + if (F_status_is_error(*status)) return; if (fake_signal_received(main)) { *status = F_status_set_error(F_signal); + return; } @@ -2074,7 +2107,8 @@ extern "C" { &setting->version_micro, }; - for (uint8_t i = 0; i < 3; i++) { + for (uint8_t i = 0; i < 3; ++i) { + if (destinations[i]->used) continue; *status = f_string_append_assure(sources[i], lengths[i], destinations[i]); @@ -2209,6 +2243,7 @@ extern "C" { #ifndef _di_fake_build_load_stage_ void fake_build_load_stage(const fake_main_t main, const f_string_static_t settings_file, fake_build_stage_t *stage, f_status_t *status) { + if (F_status_is_error(*status)) return; if (fake_signal_received(main)) { @@ -2276,10 +2311,11 @@ extern "C" { if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_file_name_base", F_true); + return; } - for (uint8_t i = 0; i < fake_build_stage_total; i++) { + for (uint8_t i = 0; i < fake_build_stage_total; ++i) { *status = f_string_dynamic_append_nulless(main.path_build_stage, values[i]); @@ -2346,6 +2382,7 @@ extern "C" { #ifndef _di_fake_build_objects_static_ int fake_build_objects_static(const fake_main_t main, const fake_build_data_t data_build, const f_mode_t mode, const f_string_static_t file_stage, f_status_t *status) { + if (F_status_is_error(*status) || f_file_exists(file_stage.string) == F_true || *status == F_child) return main.child; if (!data_build.setting.build_sources_library.used) return 0; @@ -2376,7 +2413,8 @@ extern "C" { path_sources = &data_build.setting.path_sources; } - for (f_array_length_t i = 0; i < data_build.setting.build_sources_library.used; i++) { + for (f_array_length_t i = 0; i < data_build.setting.build_sources_library.used; ++i) { + file_name.used = 0; destination_path.used = 0; @@ -2512,7 +2550,7 @@ extern "C" { destination_length, }; - for (uint8_t j = 0; j < 5; j++) { + for (uint8_t j = 0; j < 5; ++j) { *status = fll_execute_arguments_add(values[j], lengths[j], &arguments); if (F_status_is_error(*status)) break; @@ -2680,6 +2718,7 @@ extern "C" { #ifndef _di_fake_build_program_shared_ int fake_build_program_shared(const fake_main_t main, const fake_build_data_t data_build, const f_mode_t mode, const f_string_static_t file_stage, f_status_t *status) { + if (F_status_is_error(*status) || f_file_exists(file_stage.string) == F_true || *status == F_child) return main.child; if (!data_build.setting.build_sources_program.used) return 0; @@ -2707,7 +2746,8 @@ extern "C" { f_array_length_t source_length = 0; - for (f_array_length_t i = 0; i < data_build.setting.build_sources_program.used; i++) { + for (f_array_length_t i = 0; i < data_build.setting.build_sources_program.used; ++i) { + source_length = path_sources->used + data_build.setting.build_sources_program.array[i].used; char source[source_length + 1]; @@ -2740,7 +2780,8 @@ extern "C" { parameter_file_name_path_length, }; - for (uint8_t i = 0; i < 2; i++) { + for (uint8_t i = 0; i < 2; ++i) { + *status = fll_execute_arguments_add(values[i], lengths[i], &arguments); if (F_status_is_error(*status)) break; } // for @@ -2782,6 +2823,7 @@ extern "C" { #ifndef _di_fake_build_program_static_ int fake_build_program_static(const fake_main_t main, const fake_build_data_t data_build, const f_mode_t mode, const f_string_static_t file_stage, f_status_t *status) { + if (F_status_is_error(*status) || f_file_exists(file_stage.string) == F_true || *status == F_child) return main.child; if (!data_build.setting.build_sources_program.used) return 0; @@ -2809,7 +2851,8 @@ extern "C" { f_array_length_t source_length = 0; - for (f_array_length_t i = 0; i < data_build.setting.build_sources_program.used; i++) { + for (f_array_length_t i = 0; i < data_build.setting.build_sources_program.used; ++i) { + if (!data_build.setting.build_sources_program.array[i].used) continue; source_length = path_sources->used + data_build.setting.build_sources_program.array[i].used; @@ -2871,7 +2914,8 @@ extern "C" { parameter_file_name_path_length, }; - for (uint8_t i = 0; i < 4; i++) { + for (uint8_t i = 0; i < 4; ++i) { + *status = fll_execute_arguments_add(values[i], lengths[i], &arguments); if (F_status_is_error(*status)) break; } // for @@ -2900,6 +2944,7 @@ extern "C" { #ifndef _di_fake_build_touch_ void fake_build_touch(const fake_main_t main, const f_string_dynamic_t file, f_status_t *status) { + if (F_status_is_error(*status)) return; f_mode_t mode = f_mode_t_initialize; @@ -2908,6 +2953,7 @@ extern "C" { if (fake_signal_received(main)) { *status = F_status_set_error(F_signal); + return; } diff --git a/level_3/fake/c/private-clean.c b/level_3/fake/c/private-clean.c index c002ce9..ed6fa07 100644 --- a/level_3/fake/c/private-clean.c +++ b/level_3/fake/c/private-clean.c @@ -12,6 +12,7 @@ extern "C" { #ifndef _di_fake_clean_operate_ f_status_t fake_clean_operate(const fake_main_t main) { + f_status_t status = F_none; if (main.error.verbosity != f_console_verbosity_quiet) { @@ -42,6 +43,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_file_print(main.error, F_status_set_fine(status), "f_directory_remove", F_true, main.path_build.string, "remove", fll_error_file_type_directory); + return status; } @@ -51,11 +53,13 @@ extern "C" { #if !defined(_di_fake_clean_operate_) int fake_clean_remove_recursively_verbosely(const char *path, const struct stat *file_stat, int type, struct FTW *entity) { + if (!entity->level) return 0; const int result = remove(path); if (!result) { + // @todo in order to get this working, the recursive function that calls this needs to be rewritten with more flexibility or provide a higher-level equivalent function. printf("Removed '%s'.%c", path, f_string_eol_s[0]); } diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 254b994..3754c2a 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -11,12 +11,14 @@ extern "C" { #ifndef _di_fake_execute_ int fake_execute(const fake_main_t main, const f_string_maps_t environment, const f_string_static_t program, const f_string_statics_t arguments, f_status_t *status) { + if (F_status_is_error(*status)) return 1; if (main.error.verbosity == f_console_verbosity_verbose) { fprintf(main.output.stream, "%s", program.string); - for (f_array_length_t i = 0; i < arguments.used; i++) { + for (f_array_length_t i = 0; i < arguments.used; ++i) { + if (!arguments.array[i].used) continue; fprintf(main.output.stream, " %s", arguments.array[i].string); @@ -30,6 +32,7 @@ extern "C" { if (fake_signal_received(main)) { *status = F_status_set_error(F_signal); + return 0; } @@ -48,6 +51,7 @@ extern "C" { if (fake_signal_received(main)) { *status = F_status_set_error(F_signal); + return 0; } @@ -84,6 +88,7 @@ extern "C" { #ifndef _di_fake_file_buffer_ f_status_t fake_file_buffer(const fake_main_t main, const f_string_t path_file, f_string_dynamic_t *buffer) { + f_file_t file = f_file_t_initialize; f_string_t name_function = "f_file_exists"; f_status_t status = F_none; @@ -153,6 +158,7 @@ extern "C" { #ifndef _di_fake_path_generate_ f_status_t fake_path_generate(fake_main_t *main) { + f_status_t status = F_none; uint8_t i = 0; @@ -197,11 +203,13 @@ extern "C" { parameters_value_2, }; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; ++i) { + status = fake_path_generate_string_dynamic(main, *parameters_source[i], parameters_value[i], parameters_length[i]); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "fake_path_generate_string_dynamic", F_true); + return status; } } // for @@ -262,11 +270,13 @@ extern "C" { &main->path_sources_script, }; - for (i = 0; i < 15; i++) { + for (i = 0; i < 15; ++i) { + status = f_string_append_nulless(parameters_source[i], parameters_length[i], parameters_value[i]); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_append_nulless", F_true); + return status; } } // for @@ -317,11 +327,13 @@ extern "C" { parameters_value_3, }; - for (i = 0; i < 4; i++) { + for (i = 0; i < 4; ++i) { + status = fake_path_generate_string_dynamic(main, *parameters_source[i], parameters_value[i], parameters_length[i]); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "fake_path_generate_string_dynamic", F_true); + return status; } } // for @@ -379,11 +391,13 @@ extern "C" { &main->file_documents_readme, }; - for (i = 0; i < 11; i++) { + for (i = 0; i < 11; ++i) { + status = f_string_append_nulless(parameters_source[i], parameters_length[i], parameters_value[i]); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_append_nulless", F_true); + return status; } } // for @@ -397,11 +411,13 @@ extern "C" { &main->path_work_programs, }; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; ++i) { + status = f_string_dynamic_append_nulless(main->path_work, parameters_value[i]); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append_nulless", F_true); + return status; } } // for @@ -426,11 +442,13 @@ extern "C" { &main->path_work_programs, }; - for (i = 0; i < 3; i++) { + for (i = 0; i < 3; ++i) { + status = f_string_append_nulless(parameters_source[i], parameters_length[i], parameters_value[i]); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_append_nulless", F_true); + return status; } } // for @@ -464,11 +482,13 @@ extern "C" { parameters_value_1, }; - for (i = 0; i < 2; i++) { + for (i = 0; i < 2; ++i) { + status = fake_path_generate_string_dynamic(main, *parameters_source[i], parameters_value[i], parameters_length[i]); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "fake_path_generate_string_dynamic", F_true); + return status; } } // for @@ -502,11 +522,13 @@ extern "C" { &main->path_work_programs_static, }; - for (i = 0; i < 6; i++) { + for (i = 0; i < 6; ++i) { + status = f_string_append_nulless(parameters_source[i], parameters_length[i], parameters_value[i]); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_append_nulless", F_true); + return status; } } // for @@ -551,13 +573,15 @@ extern "C" { &main->file_documents_readme, }; - for (i = 0; i < 34; i++) { + for (i = 0; i < 34; ++i) { + if (!parameters_value[i]->used) continue; status = f_string_dynamic_terminate_after(parameters_value[i]); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_terminate_after", F_true); + return status; } } // for @@ -569,9 +593,11 @@ extern "C" { #ifndef _di_fake_path_generate_string_dynamic_ f_status_t fake_path_generate_string_dynamic(fake_main_t *main, const f_string_dynamic_t source, f_string_dynamic_t *destination[], const uint8_t length) { + f_status_t status = F_none; - for (uint8_t i = 0; i < length; i++) { + for (uint8_t i = 0; i < length; ++i) { + status = f_string_dynamic_append_nulless(source, destination[i]); if (F_status_is_error(status)) return status; } // for @@ -623,15 +649,17 @@ extern "C" { F_false, }; - for (uint8_t i = 0; i < 3; i++) { + for (uint8_t i = 0; i < 3; ++i) { if (main->parameters[parameters_id[i]].result == f_console_result_found) { fake_print_error_parameter_missing_value(*main, parameters_name[i]); + return F_status_set_error(F_parameter); } else if (main->parameters[parameters_id[i]].result == f_console_result_additional) { if (main->parameters[parameters_id[i]].locations.used > 1) { fake_print_error_parameter_too_many(*main, parameters_name[i]); + return F_status_set_error(F_parameter); } @@ -643,7 +671,8 @@ extern "C" { f_array_length_t j = 0; f_array_length_t width_max = 0; - for (j = 0; j < length; j++) { + for (j = 0; j < length; ++j) { + width_max = length - j; status = f_utf_is_word_dash_plus(arguments.argv[location] + j, width_max, F_false); @@ -710,6 +739,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "macro_f_string_dynamic_t_resize", F_true); + return status; } @@ -721,6 +751,7 @@ extern "C" { if (main->parameters[fake_parameter_define].result == f_console_result_found) { fake_print_error_parameter_missing_value(*main, fake_long_define); + return F_status_set_error(F_parameter); } @@ -760,7 +791,7 @@ extern "C" { &main->path_work, }; - for (uint8_t i = 0; i < 4; i++) { + for (uint8_t i = 0; i < 4; ++i) { if (main->parameters[parameters_id[i]].result == f_console_result_found) { fake_print_error_parameter_missing_value(*main, parameters_name[i]); @@ -823,9 +854,9 @@ extern "C" { f_array_length_t j = 0; f_array_length_t width_max = 0; - for (; i < main->define.used; i++) { + for (; i < main->define.used; ++i) { - for (j = 0; j < main->define.array[i].used; j++) { + for (j = 0; j < main->define.array[i].used; ++j) { width_max = main->define.array[i].used - j; @@ -880,9 +911,9 @@ extern "C" { f_array_length_t j = 0; f_array_length_t width_max = 0; - for (; i < main->mode.used; i++) { + for (; i < main->mode.used; ++i) { - for (j = 0; j < main->mode.array[i].used; j++) { + for (j = 0; j < main->mode.array[i].used; ++j) { width_max = main->mode.array[i].used - j; @@ -1042,7 +1073,7 @@ extern "C" { struct stat directory_stat; f_status_t status = F_none; - for (uint8_t i = 0; i < 3; i++) { + for (uint8_t i = 0; i < 3; ++i) { if (fake_signal_received(main)) { return F_status_set_error(F_signal); diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index 89369c5..e206107 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -46,6 +46,7 @@ extern "C" { #ifndef _di_fake_make_get_id_group_ f_status_t fake_make_get_id_group(const fake_main_t main, const fll_error_print_t error, const f_string_static_t buffer, gid_t *id) { + const f_string_range_t range = macro_f_string_range_t_initialize(buffer.used); f_number_unsigned_t number = 0; @@ -60,6 +61,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(error, F_status_set_fine(status), "f_account_id_group_by_name", F_true); + return F_status_set_error(status); } else if (status == F_exist_not) { @@ -95,8 +97,10 @@ extern "C" { #ifndef _di_fake_make_get_id_mode_ f_status_t fake_make_get_id_mode(const fake_main_t main, const fll_error_print_t error, const f_string_static_t buffer, f_file_mode_t *mode, uint8_t *replace) { + if (!buffer.used) { fll_error_print(error, F_parameter, "fake_make_get_id_mode", F_true); + return F_status_set_error(F_parameter); } @@ -124,6 +128,7 @@ extern "C" { #ifndef _di_fake_make_get_id_owner_ f_status_t fake_make_get_id_owner(const fake_main_t main, const fll_error_print_t error, const f_string_static_t buffer, uid_t *id) { + const f_string_range_t range = macro_f_string_range_t_initialize(buffer.used); f_number_unsigned_t number = 0; @@ -138,6 +143,7 @@ extern "C" { if (F_status_is_error(status)) { fll_error_print(error, status, "f_account_id_user_by_name", F_true); + return F_status_set_error(status); } else if (status == F_exist_not) { @@ -173,6 +179,7 @@ extern "C" { #ifndef _di_fake_make_load_fakefile_ void fake_make_load_fakefile(const fake_main_t main, fake_make_data_t *data_make, f_status_t *status) { + if (F_status_is_error(*status)) return; if (fake_signal_received(main)) { @@ -264,7 +271,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++) { + for (f_array_length_t i = 0; i < list_objects.used; ++i) { if (fake_signal_received(main)) { *status = F_status_set_error(F_signal); @@ -327,7 +334,7 @@ extern "C" { break; } - data_make->fakefile.used++; + ++data_make->fakefile.used; } // for macro_f_fss_delimits_t_delete_simple(delimits); @@ -405,7 +412,7 @@ extern "C" { bool unmatched_fail = F_true; bool unmatched_load = F_true; - for (f_array_length_t i = 0; i < settings.objects.used; i++) { + for (f_array_length_t i = 0; i < settings.objects.used; ++i) { if (fl_string_dynamic_partial_compare_string(fake_make_setting_compiler, data_make->buffer, fake_make_setting_compiler_length, settings.objects.array[i]) == F_equal_to) { if (range_compiler) { @@ -430,7 +437,7 @@ extern "C" { f_array_length_t j = 0; f_array_length_t k = 0; - for (; j < settings.contents.array[i].used; j++) { + for (; j < settings.contents.array[i].used; ++j) { *status = f_string_dynamic_partial_append_nulless(data_make->buffer, settings.contents.array[i].array[j], &name_define); @@ -447,7 +454,7 @@ extern "C" { } if (fake_make_operate_validate_define_name(name_define) == F_true) { - for (k = 0; k < data_make->setting_build.environment.used; k++) { + for (k = 0; k < data_make->setting_build.environment.used; ++k) { if (fl_string_dynamic_compare(name_define, data_make->setting_build.environment.array[k]) == F_equal_to) { break; } @@ -464,7 +471,7 @@ extern "C" { } // Include the terminating NULL when copying. - name_define.used++; + ++name_define.used; *status = f_string_dynamic_append(name_define, &data_make->setting_build.environment.array[data_make->setting_build.environment.used]); @@ -585,7 +592,7 @@ extern "C" { // each define replaces the previous define. data_make->setting_make.parameter.array[0].value.array[0].used = 0; - for (f_array_length_t j = 1; j < settings.contents.array[i].used; j++) { + for (f_array_length_t j = 1; j < settings.contents.array[i].used; ++j) { function_name = "f_string_dynamic_partial_append_nulless"; *status = f_string_dynamic_partial_append_nulless(data_make->buffer, settings.contents.array[i].array[j], &data_make->setting_make.parameter.array[0].value.array[0]); @@ -641,6 +648,7 @@ extern "C" { if (F_status_is_error(*status)) { macro_f_fss_set_t_delete_simple(settings); + return; } @@ -702,14 +710,14 @@ extern "C" { f_status_t status_validate = F_none; f_string_dynamic_t combined = f_string_dynamic_t_initialize; - for (f_array_length_t i = 0; i < define.used; i++) { + for (f_array_length_t i = 0; i < define.used; ++i) { status_validate = fake_make_operate_validate_define_name(define.array[i].name); if (status_validate) { combined.used = 0; - for (f_array_length_t j = 0; j < define.array[i].value.used; j++) { + for (f_array_length_t j = 0; j < define.array[i].value.used; ++j) { *status = f_string_dynamic_mash(f_string_space_s, 1, define.array[i].value.array[j], &combined); @@ -765,10 +773,12 @@ extern "C" { #ifndef _di_fake_make_load_parameters_ void fake_make_load_parameters(const fake_main_t main, fake_make_data_t *data_make, f_status_t *status) { + if (F_status_is_error(*status)) return; if (fake_signal_received(main)) { *status = F_status_set_error(F_signal); + return; } @@ -778,6 +788,7 @@ extern "C" { if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true); + return; } } @@ -821,10 +832,11 @@ extern "C" { if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_string_append", F_true); + return; } else { - data_make->parameter.color.used++; + ++data_make->parameter.color.used; } } @@ -834,6 +846,7 @@ extern "C" { if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true); + return; } } @@ -877,6 +890,7 @@ extern "C" { if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_string_append", F_true); + return; } else { @@ -908,9 +922,9 @@ extern "C" { uint8_t i = 0; f_array_length_t j = 0; - for (; i < 2; i ++) { + for (; i < 2; ++i) { - for (j = 0; j < source[i]->used; j++) { + for (j = 0; j < source[i]->used; ++j) { if (destination[i]->used >= destination[i]->size) { *status = f_string_dynamics_increase_by(f_memory_default_allocation_small, destination[i]); @@ -937,7 +951,7 @@ extern "C" { return; } else { - destination[i]->used++; + ++destination[i]->used; } if (destination[i]->used >= destination[i]->size) { @@ -956,7 +970,7 @@ extern "C" { return; } else { - destination[i]->used++; + ++destination[i]->used; } } // for } // for @@ -1003,13 +1017,14 @@ extern "C" { &data_make->parameter.settings, }; - for (uint8_t i = 0; i < 7; i ++) { + for (uint8_t i = 0; i < 7; ++i) { if (destination[i]->used >= destination[i]->size) { *status = f_string_dynamics_increase_by(f_memory_default_allocation_small, destination[i]); if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true); + return; } } @@ -1027,10 +1042,11 @@ extern "C" { if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_string_append", F_true); + return; } else { - destination[i]->used++; + ++destination[i]->used; } if (destination[i]->used >= destination[i]->size) { @@ -1038,6 +1054,7 @@ extern "C" { if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true); + return; } } @@ -1046,10 +1063,11 @@ extern "C" { if (F_status_is_error(*status)) { fll_error_print(main.error, F_status_set_fine(*status), "f_string_dynamic_append", F_true); + return; } else { - destination[i]->used++; + ++destination[i]->used; } } // for } @@ -1193,6 +1211,7 @@ extern "C" { if (F_status_is_error(*status) || *status == F_string_too_large) { fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_dynamics_increase_by", F_true); + return; } } @@ -1266,7 +1285,7 @@ extern "C" { &data_make->parameter.work, }; - for (; i < content.used; i++) { + for (; i < content.used; ++i) { if (content.array[i].start > content.array[i].stop) { continue; @@ -1305,7 +1324,7 @@ extern "C" { } } - for (j = 0, previous = iki_variable.array[0].start; j < iki_variable.used; j++) { + for (j = 0, previous = iki_variable.array[0].start; j < iki_variable.used; ++j) { parameter_is = F_false; define_is = F_false; @@ -1367,7 +1386,7 @@ extern "C" { unmatched = F_false; } else { - for (k = 0; k < 11; k++) { + for (k = 0; k < 11; ++k) { if (fl_string_dynamic_partial_compare_string(reserved_name[k], data_make->buffer, reserved_length[k], iki_content.array[j]) == F_equal_to) { if (arguments->used >= arguments->size) { @@ -1379,7 +1398,7 @@ extern "C" { } } - for (l = 0; l < reserved_value[k]->used; l++) { + for (l = 0; l < reserved_value[k]->used; ++l) { if (l > 0) { *status = f_string_append(f_string_space_s, 1, &arguments->array[arguments->used]); @@ -1400,7 +1419,7 @@ extern "C" { if (F_status_is_error_not(*status)) { unmatched = F_false; - arguments->used++; + ++arguments->used; } else { break; @@ -1410,7 +1429,7 @@ extern "C" { } if (unmatched && parameter->used) { - for (k = 0; k < parameter->used; k++) { + for (k = 0; k < parameter->used; ++k) { // check against iki variable list. *status = fl_string_dynamic_partial_compare_dynamic(parameter->array[k].name, data_make->buffer, iki_content.array[j]); @@ -1420,7 +1439,7 @@ extern "C" { if (parameter->array[k].value.used) { if (quotes.array[i]) { - for (l = 0; l < parameter->array[k].value.used; l++) { + for (l = 0; l < parameter->array[k].value.used; ++l) { if (l > 0) { *status = f_string_append(f_string_space_s, 1, &arguments->array[arguments->used]); @@ -1449,7 +1468,7 @@ extern "C" { } } - for (l = 0; l < parameter->array[k].value.used; l++) { + for (l = 0; l < parameter->array[k].value.used; ++l) { *status = f_string_dynamic_append_nulless(parameter->array[k].value.array[l], &arguments->array[arguments->used]); @@ -1465,7 +1484,7 @@ extern "C" { break; } - arguments->used++; + ++arguments->used; } // for } } @@ -1549,7 +1568,7 @@ extern "C" { break; } - arguments->used++; + ++arguments->used; } macro_f_iki_variable_t_delete_simple(iki_variable); @@ -1565,6 +1584,7 @@ extern "C" { #ifndef _di_fake_make_operate_expand_build_ f_status_t fake_make_operate_expand_build(const fake_main_t main, const f_fss_quote_t quoted, const f_string_range_t range_name, fake_make_data_t *data_make, f_string_dynamics_t *arguments) { + f_status_t status = F_none; f_string_dynamic_t value = f_string_dynamic_t_initialize; @@ -1586,7 +1606,7 @@ extern "C" { data_make->setting_build.version_target, }; - for (uint8_t i = 0; i < 2; i++) { + for (uint8_t i = 0; i < 2; ++i) { status = fl_string_dynamic_partial_compare_string(uint8_name[i], data_make->buffer, uint8_length[i], range_name); @@ -1630,7 +1650,7 @@ extern "C" { data_make->setting_build.search_static, }; - for (uint8_t i = 0; i < 7; i++) { + for (uint8_t i = 0; i < 7; ++i) { status = fl_string_dynamic_partial_compare_string(bool_name[i], data_make->buffer, bool_length[i], range_name); @@ -1710,7 +1730,7 @@ extern "C" { data_make->setting_build.version_minor, }; - for (uint8_t i = 0; i < 17; i++) { + for (uint8_t i = 0; i < 17; ++i) { status = fl_string_dynamic_partial_compare_string(dynamic_name[i], data_make->buffer, dynamic_length[i], range_name); @@ -1784,14 +1804,14 @@ extern "C" { data_make->setting_build.modes_default, }; - for (uint8_t i = 0; i < 17; i++) { + for (uint8_t i = 0; i < 17; ++i) { status = fl_string_dynamic_partial_compare_string(dynamics_name[i], data_make->buffer, dynamics_length[i], range_name); if (status == F_equal_to) { unmatched = F_false; - for (f_array_length_t j = 0; j < dynamics_value[i].used; j++) { + for (f_array_length_t j = 0; j < dynamics_value[i].used; ++j) { status = f_string_dynamic_mash(f_string_space_s, 1, dynamics_value[i].array[j], &value); @@ -1807,11 +1827,13 @@ extern "C" { if (F_status_is_error(status)) { macro_f_string_dynamic_t_delete_simple(value); + return status; } if (unmatched) { macro_f_string_dynamic_t_delete_simple(value); + return F_false; } @@ -1828,7 +1850,7 @@ extern "C" { status = f_string_dynamic_terminate_after(&arguments->array[arguments->used]); if (F_status_is_error_not(status)) { - arguments->used++; + ++arguments->used; } } } @@ -1846,6 +1868,7 @@ extern "C" { #ifndef _di_fake_make_operate_expand_environment_ f_status_t fake_make_operate_expand_environment(const fake_main_t main, const f_fss_quote_t quoted, const f_string_range_t range_name, fake_make_data_t *data_make, f_string_dynamics_t *arguments) { + f_status_t status = F_none; f_string_dynamic_t value = f_string_dynamic_t_initialize; @@ -1864,10 +1887,12 @@ extern "C" { if (F_status_is_error(status)) { macro_f_string_dynamic_t_delete_simple(value); + return status; } else if (status == F_exist_not) { macro_f_string_dynamic_t_delete_simple(value); + return F_false; } @@ -1902,6 +1927,7 @@ extern "C" { #ifndef _di_fake_make_operate_section_ int fake_make_operate_section(const f_array_length_t id_section, fake_main_t *main, fake_make_data_t *data_make, f_array_lengths_t *section_stack, f_status_t *status) { + if (F_status_is_error(*status) || *status == F_child) return main->child; if (fake_signal_received(*main)) { @@ -1926,8 +1952,7 @@ extern "C" { } } - section_stack->array[section_stack->used] = id_section; - section_stack->used++; + section_stack->array[section_stack->used++] = id_section; const f_fss_named_t *section = &data_make->fakefile.array[id_section]; @@ -1944,7 +1969,8 @@ extern "C" { } if (!section->objects.used) { - section_stack->used--; + --section_stack->used; + return 0; } @@ -2066,7 +2092,8 @@ extern "C" { memset(operations, 0, sizeof(uint8_t) * section->objects.used); memset(arguments, 0, sizeof(f_string_dynamics_t) * section->objects.used); - for (i = 0; i < section->objects.used; i++, *status = F_none) { + for (i = 0; i < section->objects.used; ++i, *status = F_none) { + operation = 0; operation_name = 0; @@ -2075,7 +2102,7 @@ extern "C" { break; } - for (j = 0; j < fake_make_operation_total; j++) { + for (j = 0; j < fake_make_operation_total; ++j) { if (fl_string_dynamic_partial_compare(operations_name[j], data_make->buffer, operations_range[j], section->objects.array[i]) == F_equal_to) { operation = operations_type[j]; @@ -2243,7 +2270,7 @@ extern "C" { } // for if (*status == F_status_set_error(F_signal)) { - for (i = 0; i < section->objects.used; i++) { + for (i = 0; i < section->objects.used; ++i) { macro_f_string_dynamics_t_delete_simple(arguments[i]); } // for @@ -2278,11 +2305,11 @@ extern "C" { *status = F_status_set_error(F_failure); } - for (i = 0; i < section->objects.used; i++) { + for (i = 0; i < section->objects.used; ++i) { macro_f_string_dynamics_t_delete_simple(arguments[i]); } // for - section_stack->used--; + --section_stack->used; return 0; } @@ -2290,6 +2317,7 @@ extern "C" { #ifndef _di_fake_make_operate_process_ int fake_make_operate_process(const f_string_range_t section_name, const uint8_t operation, const f_string_static_t operation_name, const f_string_dynamics_t arguments, const bool success, uint8_t *operation_if, fake_main_t *main, fake_make_data_t *data_make, f_array_lengths_t *section_stack, f_status_t *status) { + if (*status == F_child) return main->child; if (operation == fake_make_operation_type_index) { @@ -2336,6 +2364,7 @@ extern "C" { if (F_status_set_fine(*status) == F_signal) { *status = F_status_set_error(F_signal); + return 0; } @@ -2354,6 +2383,7 @@ extern "C" { if (F_status_set_fine(*status) == F_signal) { *status = F_status_set_error(F_signal); + return 0; } @@ -2388,6 +2418,7 @@ extern "C" { if (F_status_is_error(status_file)) { fll_error_file_print(data_make->error, F_status_set_fine(status_file), "f_directory_is", F_true, arguments.array[1].string, "identify", fll_error_file_type_directory); + *status = F_status_set_error(F_failure); return 0; } @@ -2397,7 +2428,7 @@ extern "C" { } } - for (f_array_length_t i = 0; i < total; i++) { + for (f_array_length_t i = 0; i < total; ++i) { destination_length = arguments.array[total].used; @@ -2502,7 +2533,8 @@ extern "C" { } } - for (f_array_length_t i = 0; i < total; i++) { + for (f_array_length_t i = 0; i < total; ++i) { + destination_length = arguments.array[total].used; if (existing) { @@ -2580,7 +2612,8 @@ extern "C" { const int recursion_max = operation == fake_make_operation_type_delete ? 0 : f_directory_descriptors_max; struct stat file_stat; - for (f_array_length_t i = 0; i < arguments.used; i++) { + for (f_array_length_t i = 0; i < arguments.used; ++i) { + memset(&file_stat, 0, sizeof(struct stat)); *status = f_file_stat(arguments.array[i].string, F_false, &file_stat); @@ -2749,7 +2782,7 @@ extern "C" { f_status_t status_file = F_none; - for (f_array_length_t i = 1; i < arguments.used; i++) { + for (f_array_length_t i = 1; i < arguments.used; ++i) { status_file = fake_make_assure_inside_project(*main, arguments.array[i], data_make); @@ -2788,7 +2821,7 @@ extern "C" { f_status_t status_file = F_none; - for (f_array_length_t i = 1; i < arguments.used; i++) { + for (f_array_length_t i = 1; i < arguments.used; ++i) { status_file = fake_make_assure_inside_project(*main, arguments.array[i], data_make); @@ -2853,7 +2886,7 @@ extern "C" { *operation_if = fake_make_operation_if_type_true_next; - for (f_array_length_t i = 2; i < arguments.used; i++, id_file = 0) { + for (f_array_length_t i = 2; i < arguments.used; ++i, id_file = 0) { *status = f_file_group_read(arguments.array[i].string, &id_file); if (F_status_is_error(*status)) { @@ -2904,7 +2937,7 @@ extern "C" { *operation_if = fake_make_operation_if_type_true_next; - for (f_array_length_t i = 3; i < arguments.used; i++, mode_file = 0) { + for (f_array_length_t i = 3; i < arguments.used; ++i, mode_file = 0) { *status = f_file_mode_read(arguments.array[i].string, &mode_file); @@ -2941,7 +2974,7 @@ extern "C" { *operation_if = fake_make_operation_if_type_true_next; - for (f_array_length_t i = 2; i < arguments.used; i++, id_file = 0) { + for (f_array_length_t i = 2; i < arguments.used; ++i, id_file = 0) { *status = f_file_owner_read(arguments.array[i].string, &id_file); @@ -2961,6 +2994,7 @@ extern "C" { } if (*operation_if == fake_make_operation_if_type_if_is) { + // block = 0x1 (0000 0001) link = 0x10 (0001 0000) // character = 0x2 (0000 0010) regular = 0x20 (0010 0000) // directory = 0x4 (0000 0100) socket = 0x40 (0100 0000) @@ -2971,9 +3005,10 @@ extern "C" { *status = F_none; - for (; i < arguments.used; i++) { + for (; i < arguments.used; ++i) { + if (fl_string_dynamic_compare_string(fake_make_operation_argument_if_is_for, arguments.array[i], fake_make_operation_argument_if_is_for_length) == F_equal_to) { - i++; + ++i; break; } @@ -3005,7 +3040,7 @@ extern "C" { *operation_if = fake_make_operation_if_type_true_next; - for (; i < arguments.used; i++, mode_file = 0) { + for (; i < arguments.used; ++i, mode_file = 0) { *status = f_file_mode_read(arguments.array[i].string, &mode_file); @@ -3049,7 +3084,7 @@ extern "C" { if (*operation_if == fake_make_operation_if_type_if_exists) { *operation_if = fake_make_operation_if_type_true_next; - for (f_array_length_t i = 1; i < arguments.used; i++) { + for (f_array_length_t i = 1; i < arguments.used; ++i) { *status = f_file_exists(arguments.array[i].string); @@ -3073,7 +3108,7 @@ extern "C" { if (fl_string_dynamic_compare_string(fake_make_operation_argument_environment, arguments.array[1], fake_make_operation_argument_environment_length) == F_equal_to) { *operation_if = fake_make_operation_if_type_true_next; - for (f_array_length_t i = 2; i < arguments.used; i++) { + for (f_array_length_t i = 2; i < arguments.used; ++i) { if (f_environment_exists(arguments.array[i].string) != F_true) { *operation_if = fake_make_operation_if_type_false_next; @@ -3094,9 +3129,9 @@ extern "C" { *operation_if = fake_make_operation_if_type_true_next; - for (; i < arguments.used; i++, missed = F_true) { + for (; i < arguments.used; ++i, missed = F_true) { - for (j = 0; j < data_make->setting_make.parameter.used; j++) { + for (j = 0; j < data_make->setting_make.parameter.used; ++j) { if (fl_string_dynamic_compare(arguments.array[i], data_make->setting_make.parameter.array[j].name) == F_equal_to) { missed = F_false; @@ -3117,7 +3152,7 @@ extern "C" { if (*operation_if == fake_make_operation_if_type_if_equal) { *operation_if = fake_make_operation_if_type_true_next; - for (f_array_length_t i = 2; i < arguments.used; i++) { + for (f_array_length_t i = 2; i < arguments.used; ++i) { if (fl_string_dynamic_compare(arguments.array[1], arguments.array[i]) == F_equal_to_not) { *operation_if = fake_make_operation_if_type_false_next; @@ -3134,9 +3169,9 @@ extern "C" { f_array_length_t i = 1; f_array_length_t j = 0; - for (; i < arguments.used; i++) { + for (; i < arguments.used; ++i) { - for (j = i + 1; j < arguments.used; j++) { + for (j = i + 1; j < arguments.used; ++j) { if (fl_string_dynamic_compare(arguments.array[i], arguments.array[j]) == F_equal_to) { *operation_if = fake_make_operation_if_type_false_next; @@ -3150,6 +3185,7 @@ extern "C" { } if (*operation_if == fake_make_operation_if_type_if_greater || *operation_if == fake_make_operation_if_type_if_greater_equal || *operation_if == fake_make_operation_if_type_if_less || *operation_if == fake_make_operation_if_type_if_less_equal) { + f_status_t status_number = F_none; f_string_range_t range = f_string_range_t_initialize; @@ -3185,7 +3221,7 @@ extern "C" { } if (F_status_is_error_not(status_number)) { - for (i = 2; i < arguments.used; i++, status_number = F_none, number_left = number_right, is_negative_left = is_negative_right) { + for (i = 2; i < arguments.used; ++i, status_number = F_none, number_left = number_right, is_negative_left = is_negative_right) { if (arguments.array[i].used) { range.start = 0; @@ -3324,7 +3360,7 @@ extern "C" { mode_t mode = 0; mode_t mode_file = 0; - for (f_array_length_t i = 1; i < arguments.used; i++) { + for (f_array_length_t i = 1; i < arguments.used; ++i) { mode = 0; *status = f_file_mode_read(arguments.array[i].string, &mode_file); @@ -3370,7 +3406,7 @@ extern "C" { mode_t mode = 0; mode_t mode_file = 0; - for (f_array_length_t i = 1; i < arguments.used; i++) { + for (f_array_length_t i = 1; i < arguments.used; ++i) { mode = 0; *status = f_file_mode_read(arguments.array[i].string, &mode_file); @@ -3437,7 +3473,7 @@ extern "C" { } } - for (f_array_length_t i = 0; i < total; i++) { + for (f_array_length_t i = 0; i < total; ++i) { destination_length = arguments.array[total].used; @@ -3470,7 +3506,7 @@ extern "C" { if (operation == fake_make_operation_type_operate) { f_array_length_t id_section = 0; - for (; id_section < data_make->fakefile.used; id_section++) { + for (; id_section < data_make->fakefile.used; ++id_section) { if (fl_string_dynamic_partial_compare_string(arguments.array[0].string, data_make->buffer, arguments.array[0].used, data_make->fakefile.array[id_section].name) == F_equal_to) { break; @@ -3502,7 +3538,7 @@ extern "C" { f_status_t status_file = F_none; - for (f_array_length_t i = 1; i < arguments.used; i++) { + for (f_array_length_t i = 1; i < arguments.used; ++i) { status_file = fake_make_assure_inside_project(*main, arguments.array[i], data_make); @@ -3542,7 +3578,7 @@ extern "C" { f_status_t status_file = F_none; - for (f_array_length_t i = 1; i < arguments.used; i++) { + for (f_array_length_t i = 1; i < arguments.used; ++i) { status_file = fake_make_assure_inside_project(*main, arguments.array[i], data_make); @@ -3604,7 +3640,8 @@ extern "C" { } if (operation == fake_make_operation_type_print) { - for (f_array_length_t i = 0; i < arguments.used; i++) { + for (f_array_length_t i = 0; i < arguments.used; ++i) { + f_print_dynamic(main->output.stream, arguments.array[i]); if (i + 1 < arguments.used) { @@ -3618,11 +3655,13 @@ extern "C" { if (operation == fake_make_operation_type_run) { *status = fake_make_operate_process_run(*main, arguments, F_false, data_make); + return 0; } if (operation == fake_make_operation_type_shell) { *status = fake_make_operate_process_run(*main, arguments, F_true, data_make); + return 0; } @@ -3631,6 +3670,7 @@ extern "C" { if (F_status_set_fine(*status) == F_signal) { *status = F_status_set_error(F_signal); + return 0; } @@ -3668,21 +3708,24 @@ extern "C" { if (F_status_set_fine(*status) == F_array_too_large) { fake_print_message_section_operation_path_stack_max(*main, data_make->error, F_array_too_large, "f_string_dynamics_increase_by", "path stack"); + return 0; } else if (F_status_is_error(*status)) { fll_error_print(data_make->error, F_status_set_fine(*status), "macro_f_string_dynamics_t_resize", F_true); + return 0; } } // copy the entire real path, including the trailing NULL. - data_make->path_cache.used++; + ++data_make->path_cache.used; f_string_dynamic_append(data_make->path_cache, &data_make->path.stack.array[data_make->path.stack.used]); if (F_status_is_error(*status)) { fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_dynamic_append_nulless", F_true); + return 0; } @@ -3690,6 +3733,7 @@ extern "C" { *status = fake_make_path_relative(*main, data_make->path.stack.array[data_make->path.stack.used], data_make); if (F_status_is_error(*status)) { + fll_error_print(data_make->error, F_status_set_fine(*status), "fake_make_path_relative", F_true); return 0; } @@ -3701,7 +3745,7 @@ extern "C" { fprintf(main->output.stream, "'.%c", f_string_eol_s[0]); } - data_make->path.stack.used++; + ++data_make->path.stack.used; } return 0; @@ -3713,6 +3757,7 @@ extern "C" { if (F_status_is_error(*status)) { fake_print_message_section_operation_path_stack_max(*main, data_make->error, F_status_set_fine(*status), "f_path_change", arguments.array[0].string); + return 0; } @@ -3721,7 +3766,7 @@ extern "C" { } // clear stack, except for the project root. - for (f_array_length_t i = 1; i < data_make->path.stack.used; i++) { + for (f_array_length_t i = 1; i < data_make->path.stack.used; ++i) { macro_f_string_dynamic_t_delete_simple(data_make->path.stack.array[i]); } // for @@ -3734,7 +3779,7 @@ extern "C" { macro_f_mode_t_set_default_umask(mode, main->umask); - for (f_array_length_t i = 1; i < arguments.used; i++) { + for (f_array_length_t i = 1; i < arguments.used; ++i) { if (fl_string_dynamic_compare_string(fake_make_operation_argument_file, arguments.array[0], fake_make_operation_argument_file_length) == F_equal_to) { *status = f_file_touch(arguments.array[i].string, mode.regular, F_false); @@ -3772,7 +3817,6 @@ extern "C" { f_color_print_code(main->output.stream, *main->context.set.notable.after); fprintf(main->output.stream, "'.%c", f_string_eol_s[0]); } - } // for } @@ -3790,7 +3834,8 @@ extern "C" { f_status_t status = F_none; // reset the environment. - for (f_array_length_t i = 0; i < data_make->environment.used; i++) { + for (f_array_length_t i = 0; i < data_make->environment.used; ++i) { + data_make->environment.array[i].name.used = 0; data_make->environment.array[i].value.used = 0; } // for @@ -3808,7 +3853,8 @@ extern "C" { if (main.error.verbosity == f_console_verbosity_verbose) { fprintf(main.output.stream, "%s", program.string); - for (f_array_length_t i = 0; i < arguments.used; i++) { + for (f_array_length_t i = 0; i < arguments.used; ++i) { + if (!arguments.array[i].used) continue; fprintf(main.output.stream, " %s", arguments.array[i].string); @@ -3857,6 +3903,7 @@ extern "C" { #ifndef _di_fake_make_operate_process_return_ void fake_make_operate_process_return(const fake_main_t main, const int return_code, fake_make_data_t *data_make, f_status_t *status) { + f_status_t status2 = F_none; data_make->setting_make.parameter.array[0].value.array[0].used = 0; @@ -3929,6 +3976,7 @@ extern "C" { #ifndef _di_fake_make_operate_process_run_ f_status_t fake_make_operate_process_run(const fake_main_t main, const f_string_statics_t arguments, const bool as_shell, fake_make_data_t *data_make) { + const f_string_static_t *program = &arguments.array[0]; f_status_t status = F_none; @@ -3942,7 +3990,7 @@ extern "C" { return status; } - for (f_array_length_t i = 0; i < args.size; i++) { + for (f_array_length_t i = 0; i < args.size; ++i) { status = f_string_dynamic_append(arguments.array[i + 1], &args.array[i]); @@ -3962,7 +4010,7 @@ extern "C" { return status; } - args.used++; + ++args.used; } // for } @@ -3975,6 +4023,7 @@ extern "C" { #ifndef _di_fake_make_operate_validate_ void fake_make_operate_validate(const fake_main_t main, const f_string_range_t section_name, const f_array_length_t operation, const f_string_static_t operation_name, const f_string_dynamics_t arguments, uint8_t *operation_if, fake_make_data_t *data_make, f_array_lengths_t *section_stack, f_status_t *status) { + if (F_status_is_error(*status)) return; if (operation == fake_make_operation_type_index || operation == fake_make_operation_type_run || operation == fake_make_operation_type_shell) { @@ -4115,7 +4164,7 @@ extern "C" { if (operation == fake_make_operation_type_clone) { if (arguments.used > 1) { - for (f_array_length_t i = 0; i < arguments.used; i++) { + for (f_array_length_t i = 0; i < arguments.used; ++i) { *status = fake_make_assure_inside_project(main, arguments.array[i], data_make); @@ -4128,7 +4177,7 @@ extern "C" { } } // for - for (f_array_length_t i = 0; i < arguments.used - 1; i++) { + for (f_array_length_t i = 0; i < arguments.used - 1; ++i) { if (f_file_exists(arguments.array[i].string) != F_true) { if (main.error.verbosity != f_console_verbosity_quiet && data_make->error.to.stream) { @@ -4220,7 +4269,7 @@ extern "C" { if (operation == fake_make_operation_type_copy) { if (arguments.used > 1) { - for (f_array_length_t i = 0; i < arguments.used; i++) { + for (f_array_length_t i = 0; i < arguments.used; ++i) { *status = fake_make_assure_inside_project(main, arguments.array[i], data_make); @@ -4233,7 +4282,7 @@ extern "C" { } } // for - for (f_array_length_t i = 0; i < arguments.used - 1; i++) { + for (f_array_length_t i = 0; i < arguments.used - 1; ++i) { if (f_file_exists(arguments.array[i].string) != F_true) { if (main.error.verbosity != f_console_verbosity_quiet && data_make->error.to.stream) { @@ -4302,7 +4351,7 @@ extern "C" { if (operation == fake_make_operation_type_delete || operation == fake_make_operation_type_deletes) { if (arguments.used) { - for (f_array_length_t i = 0; i < arguments.used; i++) { + for (f_array_length_t i = 0; i < arguments.used; ++i) { *status = fake_make_assure_inside_project(main, arguments.array[i], data_make); @@ -4482,7 +4531,7 @@ extern "C" { if (arguments.used > 1) { f_status_t status_file = F_none; - for (f_array_length_t i = 1; i < arguments.used; i++) { + for (f_array_length_t i = 1; i < arguments.used; ++i) { status_file = f_file_is(arguments.array[i].string, f_file_type_regular, F_false); @@ -4604,7 +4653,7 @@ extern "C" { f_array_length_t i = 0; - for (; i < 14; i++) { + for (; i < 14; ++i) { if (fl_string_dynamic_compare_string(if_type_strings[i], arguments.array[0], if_type_lengths[i]) == F_equal_to) { *operation_if = if_type_codes[i]; @@ -4836,7 +4885,7 @@ extern "C" { bool is_negative = F_false; // @fixme there needs to handle converting numbers with decimals (like 1.01), perhaps operate on them as strings or provide a special processor. - for (i = 1; i < arguments.used; i++, status_number = F_none) { + for (i = 1; i < arguments.used; ++i, status_number = F_none) { if (arguments.array[i].used) { range.start = 0; @@ -4941,7 +4990,7 @@ extern "C" { if (operation == fake_make_operation_type_move) { if (arguments.used > 1) { - for (f_array_length_t i = 0; i < arguments.used; i++) { + for (f_array_length_t i = 0; i < arguments.used; ++i) { *status = fake_make_assure_inside_project(main, arguments.array[i], data_make); @@ -4954,7 +5003,7 @@ extern "C" { } } // for - for (f_array_length_t i = 0; i < arguments.used - 1; i++) { + for (f_array_length_t i = 0; i < arguments.used - 1; ++i) { if (f_file_exists(arguments.array[i].string) != F_true) { if (main.error.verbosity != f_console_verbosity_quiet && data_make->error.to.stream) { @@ -5033,7 +5082,7 @@ extern "C" { else if (arguments.used == 1) { f_array_length_t id_section = 0; - for (; id_section < data_make->fakefile.used; id_section++) { + for (; id_section < data_make->fakefile.used; ++id_section) { if (fl_string_dynamic_partial_compare_string(arguments.array[0].string, data_make->buffer, arguments.array[0].used, data_make->fakefile.array[id_section].name) == F_equal_to) { break; @@ -5047,7 +5096,7 @@ extern "C" { f_color_print(data_make->error.to.stream, data_make->error.context, "' was found.%c", f_string_eol_s[0]); } else { - for (f_array_length_t i = 0; i < section_stack->used; i++) { + for (f_array_length_t i = 0; i < section_stack->used; ++i) { if (section_stack->array[i] == id_section) { fprintf(data_make->error.to.stream, "%c", f_string_eol_s[0]); @@ -5152,7 +5201,7 @@ extern "C" { } } - for (f_array_length_t i = 1; i < arguments.used; i++) { + for (f_array_length_t i = 1; i < arguments.used; ++i) { *status = fake_make_assure_inside_project(main, arguments.array[i], data_make); @@ -5183,13 +5232,14 @@ extern "C" { #ifndef _di_fake_make_operate_validate_define_name_ f_status_t fake_make_operate_validate_define_name(const f_string_static_t name) { + if (!name.used) return F_none; if (!(isalpha(name.string[0]) || name.string[0] == '_')) { return F_false; } - for (f_array_length_t i = 0; i < name.used; i++) { + for (f_array_length_t i = 0; i < name.used; ++i) { if (!(isalnum(name.string[i]) || name.string[i] == '_')) { return F_false; @@ -5202,6 +5252,7 @@ extern "C" { #ifndef _di_fake_make_path_relative_ f_status_t fake_make_path_relative(const fake_main_t main, const f_string_static_t path, fake_make_data_t *data_make) { + data_make->path_cache.used = 0; if (!path.used || path.used == data_make->path.stack.array[0].used) { diff --git a/level_3/fake/c/private-print.c b/level_3/fake/c/private-print.c index 8e77e91..f28173c 100644 --- a/level_3/fake/c/private-print.c +++ b/level_3/fake/c/private-print.c @@ -297,6 +297,7 @@ extern "C" { #ifndef _di_fake_print_error_parameter_missing_value_ void fake_print_error_parameter_missing_value(const fake_main_t main, const f_string_t parameter) { + if (main.error.verbosity == f_console_verbosity_quiet) return; fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); @@ -310,6 +311,7 @@ extern "C" { #ifndef _di_fake_print_error_parameter_too_many_ void fake_print_error_parameter_too_many(const fake_main_t main, const f_string_t parameter) { + if (main.error.verbosity == f_console_verbosity_quiet) return; fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); @@ -323,6 +325,7 @@ extern "C" { #ifndef _di_fake_print_message_section_operation_failed_ void fake_print_message_section_operation_failed(const fake_main_t main, const fll_error_print_t error, const f_string_static_t buffer, const f_string_range_t section_name, const f_string_range_t operation_name) { + if (main.error.verbosity == f_console_verbosity_quiet || !error.to.stream) return; f_array_length_t line = 1; @@ -350,6 +353,7 @@ extern "C" { #ifndef _di_fake_print_message_section_operation_path_outside_ void fake_print_message_section_operation_path_outside(const fake_main_t main, const fll_error_print_t error, const f_status_t status, const f_string_t function, const f_string_t path) { + if (main.error.verbosity == f_console_verbosity_quiet || !error.to.stream) return; if (F_status_set_fine(status) == F_false) { @@ -366,6 +370,7 @@ extern "C" { #ifndef _di_fake_print_message_section_operation_path_stack_max_ void fake_print_message_section_operation_path_stack_max(const fake_main_t main, fll_error_print_t error, const f_status_t status, const f_string_t function, const f_string_t path) { + if (main.error.verbosity == f_console_verbosity_quiet || !error.to.stream) return; if (status == F_array_too_large) { @@ -390,6 +395,7 @@ extern "C" { #ifndef _di_fake_print_message_section_operation_stack_max_ void fake_print_message_section_operation_stack_max(const fake_main_t main, fll_error_print_t error, const f_string_static_t buffer, const f_string_range_t section_name, const f_string_range_t operation_name, const f_array_length_t stack_max) { + if (main.error.verbosity == f_console_verbosity_quiet || !error.to.stream) return; f_array_length_t line = 1; @@ -419,6 +425,7 @@ extern "C" { #ifndef _di_fake_print_message_section_operation_unknown_ void fake_print_message_section_operation_unknown(const fake_main_t main, const fll_error_print_t error, const f_string_static_t buffer, const f_string_range_t section_name, const f_string_range_t operation_name) { + if (main.error.verbosity == f_console_verbosity_quiet || !error.to.stream) return; f_array_length_t line = 1; @@ -446,6 +453,7 @@ extern "C" { #ifndef _di_fake_print_warning_settings_content_empty_ void fake_print_warning_settings_content_empty(const fake_main_t main, const f_string_t path_file, const f_string_dynamic_t buffer, const f_string_range_t range_object, const f_string_t settings_name) { + if (main.error.verbosity == f_console_verbosity_quiet) return; fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); @@ -466,6 +474,7 @@ extern "C" { #ifndef _di_fake_print_warning_settings_content_invalid_ void fake_print_warning_settings_content_invalid(const fake_main_t main, const f_string_t path_file, const f_string_dynamic_t buffer, const f_string_range_t range_object, const f_string_range_t range_content, const f_string_t settings_name) { + if (main.error.verbosity == f_console_verbosity_quiet) return; fprintf(main.output.stream, "%c", f_string_eol_s[0]); @@ -492,6 +501,7 @@ extern "C" { #ifndef _di_fake_print_warning_settings_content_multiple_ void fake_print_warning_settings_content_multiple(const fake_main_t main, const f_string_t path_file, const f_string_t name_object) { + if (main.error.verbosity != f_console_verbosity_verbose) return; fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); @@ -507,6 +517,7 @@ extern "C" { #ifndef _di_fake_print_warning_settings_object_multiple_ void fake_print_warning_settings_object_multiple(const fake_main_t main, const f_string_t path_file, const f_string_t label, const f_string_t name_object) { + if (main.error.verbosity != f_console_verbosity_verbose) return; fprintf(main.error.to.stream, "%c", f_string_eol_s[0]); diff --git a/level_3/fake/c/private-skeleton.c b/level_3/fake/c/private-skeleton.c index ee3af32..0a8201f 100644 --- a/level_3/fake/c/private-skeleton.c +++ b/level_3/fake/c/private-skeleton.c @@ -159,6 +159,7 @@ extern "C" { #ifndef _di_fake_skeleton_operate_directory_create_ f_status_t fake_skeleton_operate_directory_create(const fake_main_t main, const f_string_dynamic_t path) { + f_status_t status = F_none; if (!path.used) return F_none; @@ -215,6 +216,7 @@ extern "C" { #ifndef _di_fake_skeleton_operate_file_create_ f_status_t fake_skeleton_operate_file_create(const fake_main_t main, const f_string_dynamic_t path, const bool executable, const f_string_static_t content) { + f_status_t status = F_none; if (!path.used) return F_none;