Fix issue where the `extern` prefix strings accidentally have `_length` in their names.
The entry and rule names should be without their prefixes.
Perform the prefix matching before pulling out the string.
Skip anything that doesn't match the correct prefix when using a loaded file.
Otherwise, operate normally.
This relocates the exit file loading to be at the start, right after loading the entry file.
It may be worth loading all of the rules specified in the entry and the exit at the start.
I added `@todo` and `@fixme` to represent these areas that I need to figure out how I want to handle.
#define _di_f_compare_dynamic_except_string_
#define _di_f_compare_dynamic_except_trim_
#define _di_f_compare_dynamic_except_trim_string_
-#define _di_f_compare_dynamic_partial_
+//#define _di_f_compare_dynamic_partial_
#define _di_f_compare_dynamic_partial_dynamic_
#define _di_f_compare_dynamic_partial_except_
#define _di_f_compare_dynamic_partial_except_dynamic_
extern const f_string_static_t controller_controlfile_s;
- extern const f_string_static_t controller_prefix_entry_s_length;
- extern const f_string_static_t controller_prefix_exit_s_length;
- extern const f_string_static_t controller_prefix_rule_s_length;
+ extern const f_string_static_t controller_prefix_entry_s;
+ extern const f_string_static_t controller_prefix_exit_s;
+ extern const f_string_static_t controller_prefix_rule_s;
#endif // !defined(_di_controller_controlfile_s_) && defined(_support_controller_controlfile_)
/**
// 0x1 = main found, 0x2 = found existing.
uint8_t code = 0;
+ #ifdef _support_controller_controlfile_
+ const f_string_static_t prefix = is_entry ? controller_prefix_entry_s : controller_prefix_exit_s;
+ const f_range_t prefix_range = macro_f_range_t_initialize_2(prefix.used);
+
+ f_range_t offset = f_range_t_initialize;
+ #endif // _support_controller_controlfile_
+
for (i = 0; i < main->thread.cache.object_items.used && controller_thread_enable_is_normal(&main->thread, is_entry); ++i) {
code &= ~0x2;
break;
}
- state.status = f_string_dynamic_partial_append(main->thread.cache.buffer_file, main->thread.cache.object_items.array[i], &main->thread.cache.action.name_item);
+ // Process the entry or exit items normally, but if pre-loaded (as with controlfile or initfile), then only process if the proper prefix is present.
+ offset = main->thread.cache.object_items.array[i];
+
+ if (main->setting.flag & controller_main_flag_loaded_d) {
+ if (f_compare_dynamic_partial(main->thread.cache.buffer_file, prefix, offset, prefix_range) != F_equal_to) continue;
+
+ // Determine the next range position, skipping past any NULL characters.
+ for (j = 0; offset.start <= offset.stop && j < prefix.used; ++offset.start) {
+
+ if (!main->thread.cache.buffer_file.string[offset.start]) continue;
+
+ ++j;
+ } // for
+ }
+
+ state.status = f_string_dynamic_partial_append(main->thread.cache.buffer_file, offset, &main->thread.cache.action.name_item);
if (F_status_is_error(state.status)) {
controller_print_error_entry(&main->program.error, is_entry, F_status_set_fine(state.status), F_status_debug_source_d, F_true, F_status_debug_source_d);
}
else {
state.status = controller_file_load(main, F_false, controller_exits_s, main->process.name_entry, controller_exit_s);
-
- // Immediately return on error whole loading the Exit.
- if (state.status == F_file_found_not) {
- entry->status = controller_status_simplify_error(F_file_found_not);
-
- return F_status_set_error(F_file_found_not);
- }
}
}
memcpy(cache_name_item, cache->action.name_item.string, sizeof(f_char_t) * cache->action.name_item.used);
memcpy(cache_name_file, cache->action.name_file.string, sizeof(f_char_t) * cache->action.name_file.used);
- status = controller_rule_read(main, cache, is_entry, alias_rule, entry, rule);
+ status = controller_rule_read(main, cache, is_entry, alias_rule, entry, rule); // @fixme this re-uses the buffer_file, which may be a problem for entry reading.
// Restore cache.
memcpy(cache->action.name_action.string, cache_name_action, sizeof(f_char_t) * cache_name_action_used);
controller_print_error_status(&main->program.error, F_status_debug_source_d, F_status_set_fine(state.status));
}
else {
- state.status = controller_file_load(main, F_true, controller_rules_s, rule->alias, controller_rule_s);
- }
+ if (!(main->setting.flag & controller_main_flag_loaded_d)) {
+ state.status = controller_file_load(main, F_true, controller_rules_s, rule->alias, controller_rule_s);
- if (F_status_is_error_not(state.status)) {
- rule->timestamp = cache->timestamp;
+ /* @todo, how should this be handled?
+ * Load the files at the start, so that this does not need to be loaded here?
+ f_range_t offset = f_range_t_initialize;
- if (cache->buffer_file.used) {
- f_range_t range = macro_f_range_t_initialize_2(cache->buffer_file.used);
+ offset = main->thread.cache.object_actions.array[i];
- fll_fss_basic_list_read(cache->buffer_file, &range, &cache->object_items, &cache->content_items, &cache->delimits, 0, &cache->comments, &state);
+ if (main->setting.flag & controller_main_flag_loaded_d) {
+ }*/
+ }
- if (F_status_is_error(state.status)) {
- controller_print_error_status(&main->program.error, F_status_debug_source_d, F_status_set_fine(state.status));
- }
- else {
- f_fss_apply_delimit(cache->delimits, &cache->buffer_file, &state);
+ if (F_status_is_error_not(state.status)) {
+ rule->timestamp = cache->timestamp;
+
+ if (cache->buffer_file.used) {
+ f_range_t range = macro_f_range_t_initialize_2(cache->buffer_file.used);
+
+ fll_fss_basic_list_read(cache->buffer_file, &range, &cache->object_items, &cache->content_items, &cache->delimits, 0, &cache->comments, &state);
if (F_status_is_error(state.status)) {
controller_print_error_status(&main->program.error, F_status_debug_source_d, F_status_set_fine(state.status));
}
+ else {
+ f_fss_apply_delimit(cache->delimits, &cache->buffer_file, &state);
+
+ if (F_status_is_error(state.status)) {
+ controller_print_error_status(&main->program.error, F_status_debug_source_d, F_status_set_fine(state.status));
+ }
+ }
}
}
}
*status = controller_entry_read(main, F_true);
+ // Also load the exit file on start.
+ if (F_status_is_error_not(*status) && F_status_set_fine(*status) != F_interrupt && *status != F_child) {
+ *status = controller_entry_read(main, F_false);
+ }
+
+ // @todo pre-load all rule files? find all rules in the entry files and exit files and then load them?
+
if (F_status_set_fine(*status) == F_interrupt) {
main->process.ready = controller_process_ready_abort_e;
}
main->process.ready = controller_process_ready_fail_e;
}
else if (*status != F_child) {
+
+ // Free up memory consumed by the buffered file.
+ f_memory_array_resize(0, sizeof(f_char_t), (void **) &main->thread.cache.buffer_file.string, &main->thread.cache.buffer_file.used, &main->thread.cache.buffer_file.size);
+
*status = controller_entry_preprocess(main, F_true);
if ((main->setting.flag & controller_main_flag_simulate_d) && (main->setting.flag & controller_main_flag_validate_d)) {
controller_t * const main = (controller_t *) argument;
f_status_t * const status = &main->thread.status;
- *status = controller_entry_read(main, F_false);
-
- if (F_status_set_fine(*status) == F_interrupt) {
- main->process.ready = controller_process_ready_abort_e;
- }
- else if (F_status_is_error(*status)) {
- main->process.ready = controller_process_ready_fail_e;
- }
- else if (*status == F_file_found_not) {
- main->process.ready = controller_process_ready_done_e;
- }
- else if (*status != F_child) {
- *status = controller_entry_preprocess(main, F_false);
+ // The exit file is loaded on start, so go straight into the pre-process.
+ *status = controller_entry_preprocess(main, F_false);
- if ((main->setting.flag & controller_main_flag_simulate_d) && (main->setting.flag & controller_main_flag_validate_d)) {
- controller_print_output_entry_setting_validate(&main->program.output, F_false);
- }
+ if ((main->setting.flag & controller_main_flag_simulate_d) && (main->setting.flag & controller_main_flag_validate_d)) {
+ controller_print_output_entry_setting_validate(&main->program.output, F_false);
}
if (F_status_is_error_not(*status) && *status != F_child && *status != F_file_found_not) {