From bf60235e2e707bab6af2cfdc7df0b4f304349dfc Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 26 Feb 2022 19:33:59 -0600 Subject: [PATCH] Bugfix: A Rule's "define" settings are not being exported. The exporting of the define is never performed and needs to be. This is a quick implementation. I've added a TODO describing what I really want to do. The improved implementation is to be addressed after the FLL-0.5.8 release. --- level_3/controller/c/rule/private-rule.c | 45 ++++++++++++++++++++++++++++++-- level_3/controller/c/rule/private-rule.h | 4 +-- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/level_3/controller/c/rule/private-rule.c b/level_3/controller/c/rule/private-rule.c index d443400..a9de5c5 100644 --- a/level_3/controller/c/rule/private-rule.c +++ b/level_3/controller/c/rule/private-rule.c @@ -922,10 +922,10 @@ extern "C" { status = f_string_dynamic_append(source.script, &destination->script); if (F_status_is_error(status)) return status; - status = f_string_maps_append(source.define, &destination->define); + status = f_string_maps_append_all(source.define, &destination->define); if (F_status_is_error(status)) return status; - status = f_string_maps_append(source.parameter, &destination->parameter); + status = f_string_maps_append_all(source.parameter, &destination->parameter); if (F_status_is_error(status)) return status; status = f_string_dynamics_append(source.environment, &destination->environment); @@ -1131,6 +1131,47 @@ extern "C" { return status; } + // @todo Much of this loop really should be moved into the processing stage where define names that are not in the environment are not loaded (for better performance and resource utilization). + // When a "define" is in the "environment", add it to the exported environments (and overwrite any existing environment variable of the same name). + for (i = 0; i < process->rule.define.used; ++i) { + + for (j = 0; j < process->rule.environment.used; ++j) { + + if (fl_string_dynamic_compare(process->rule.define.array[i].name, process->rule.environment.array[j]) == F_equal_to) { + + for (k = 0; k < environment.used; ++k) { + + if (fl_string_dynamic_compare(process->rule.define.array[i].name, environment.array[k].name) == F_equal_to) { + + environment.array[k].value.used = 0; + + status = f_string_dynamic_append(process->rule.define.array[i].value, &environment.array[k].value); + + if (F_status_is_error(status)) { + controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true); + + return status; + } + + break; + } + } // for + + if (k == environment.used) { + status = f_string_maps_append(process->rule.define.array[i], &environment); + + if (F_status_is_error(status)) { + controller_print_error(global.thread, global.main->error, F_status_set_fine(status), "f_string_maps_append", F_true); + + return status; + } + } + + break; + } + } // for + } // for + for (i = 0; i < process->rule.items.used && controller_thread_is_enabled_process(process, global.thread); ++i) { if (process->rule.items.array[i].type == controller_rule_item_type_setting_e) continue; diff --git a/level_3/controller/c/rule/private-rule.h b/level_3/controller/c/rule/private-rule.h index b28834a..ced35c5 100644 --- a/level_3/controller/c/rule/private-rule.h +++ b/level_3/controller/c/rule/private-rule.h @@ -205,7 +205,7 @@ extern "C" { * Errors (with error bit) from: f_limit_sets_copy(). * Errors (with error bit) from: f_string_dynamic_append(). * Errors (with error bit) from: f_string_dynamics_append(). - * Errors (with error bit) from: f_string_maps_append(). + * Errors (with error bit) from: f_string_maps_append_all(). * Errors (with error bit) from: f_int32s_append(). * * @see f_capability_copy() @@ -213,7 +213,7 @@ extern "C" { * @see f_limit_sets_append() * @see f_string_dynamic_append() * @see f_string_dynamics_append() - * @see f_string_maps_append() + * @see f_string_maps_append_all() * @see f_int32s_append() */ #ifndef _di_controller_rule_copy_ -- 1.8.3.1