From: Kevin Day Date: Sun, 28 May 2023 03:56:35 +0000 (-0500) Subject: Progress: Continue work on refactoring fss_*_read into fss_read. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=c5fc1ec00cc7cbf5bf3fd280320615754242edd3;p=fll Progress: Continue work on refactoring fss_*_read into fss_read. Get the programs into better working state. Now I need to next focus on ensuring that they work as expected. The payload and embedded list need special handling and are very much not implemented. --- diff --git a/level_3/fss_read/c/basic/fss_read.c b/level_3/fss_read/c/basic/fss_read.c index e29857a..b0cadec 100644 --- a/level_3/fss_read/c/basic/fss_read.c +++ b/level_3/fss_read/c/basic/fss_read.c @@ -63,6 +63,14 @@ extern "C" { } } + fss_read_ensure_quotes_length(main); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fss_read_ensure_quotes_length)); + + return; + } + main->setting.state.status = F_none; } #endif // _di_fss_read_basic_process_load_ diff --git a/level_3/fss_read/c/basic/fss_read.h b/level_3/fss_read/c/basic/fss_read.h index 3d89735..6b232c5 100644 --- a/level_3/fss_read/c/basic/fss_read.h +++ b/level_3/fss_read/c/basic/fss_read.h @@ -103,8 +103,11 @@ extern "C" { * * Errors (with error bit) from: fll_fss_basic_read() * + * Errors (with error bit) from: fss_read_ensure_quotes_length() + * * @see fll_fss_basic_read() * + * @see fss_read_ensure_quotes_length() * @see fss_read_file_identify() */ #ifndef _di_fss_read_basic_process_load_ diff --git a/level_3/fss_read/c/basic/main.c b/level_3/fss_read/c/basic/main.c index a46a8f7..21da79a 100644 --- a/level_3/fss_read/c/basic/main.c +++ b/level_3/fss_read/c/basic/main.c @@ -25,7 +25,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.process_help = &fss_read_basic_process_help; data.callback.process_last_line = &fss_read_process_last_line; - data.callback.process_load_depth = &fss_read_setting_load_depth; data.callback.process_normal = &fss_read_process_normal; data.callback.process_at = &fss_read_process_normal_at; diff --git a/level_3/fss_read/c/basic_list/fss_read.c b/level_3/fss_read/c/basic_list/fss_read.c index 36574dd..fbdc775 100644 --- a/level_3/fss_read/c/basic_list/fss_read.c +++ b/level_3/fss_read/c/basic_list/fss_read.c @@ -63,6 +63,14 @@ extern "C" { } } + fss_read_ensure_quotes_length(main); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fss_read_ensure_quotes_length)); + + return; + } + main->setting.state.status = F_none; } #endif // _di_fss_read_basic_list_process_load_ diff --git a/level_3/fss_read/c/basic_list/fss_read.h b/level_3/fss_read/c/basic_list/fss_read.h index 5ff936b..2b57474 100644 --- a/level_3/fss_read/c/basic_list/fss_read.h +++ b/level_3/fss_read/c/basic_list/fss_read.h @@ -103,8 +103,11 @@ extern "C" { * * Errors (with error bit) from: fll_fss_basic_list_read() * + * Errors (with error bit) from: fss_read_ensure_quotes_length() + * * @see fll_fss_basic_list_read() * + * @see fss_read_ensure_quotes_length() * @see fss_read_file_identify() */ #ifndef _di_fss_read_basic_list_process_load_ diff --git a/level_3/fss_read/c/basic_list/main.c b/level_3/fss_read/c/basic_list/main.c index d12db00..3004244 100644 --- a/level_3/fss_read/c/basic_list/main.c +++ b/level_3/fss_read/c/basic_list/main.c @@ -17,14 +17,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.custom = (void *) &data; data.program.warning.custom = (void *) &data; - data.setting.flag |= fss_read_main_flag_trim_object_e; - data.setting.state.custom = (void *) &data; data.setting.standard = fss_read_basic_list_standard_s; data.callback.process_help = &fss_read_basic_list_process_help; data.callback.process_last_line = &fss_read_process_last_line; - data.callback.process_load_depth = &fss_read_setting_load_depth; data.callback.process_normal = &fss_read_process_normal; data.callback.process_at = &fss_read_process_normal_at; diff --git a/level_3/fss_read/c/embedded_list/fss_read.c b/level_3/fss_read/c/embedded_list/fss_read.c index e6a1434..9cb2529 100644 --- a/level_3/fss_read/c/embedded_list/fss_read.c +++ b/level_3/fss_read/c/embedded_list/fss_read.c @@ -63,6 +63,14 @@ extern "C" { } } + fss_read_ensure_quotes_length(main); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fss_read_ensure_quotes_length)); + + return; + } + main->setting.state.status = F_none; } #endif // _di_fss_read_embedded_list_process_load_ diff --git a/level_3/fss_read/c/embedded_list/fss_read.h b/level_3/fss_read/c/embedded_list/fss_read.h index ea7b932..6b77918 100644 --- a/level_3/fss_read/c/embedded_list/fss_read.h +++ b/level_3/fss_read/c/embedded_list/fss_read.h @@ -103,8 +103,11 @@ extern "C" { * * Errors (with error bit) from: fll_fss_embedded_list_read() * + * Errors (with error bit) from: fss_read_ensure_quotes_length() + * * @see fll_fss_embedded_list_read() * + * @see fss_read_ensure_quotes_length() * @see fss_read_file_identify() */ #ifndef _di_fss_read_embedded_list_process_load_ diff --git a/level_3/fss_read/c/embedded_list/main.c b/level_3/fss_read/c/embedded_list/main.c index f07e183..0abcb9f 100644 --- a/level_3/fss_read/c/embedded_list/main.c +++ b/level_3/fss_read/c/embedded_list/main.c @@ -24,7 +24,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.process_help = &fss_read_embedded_list_process_help; data.callback.process_last_line = &fss_read_process_last_line; - data.callback.process_load_depth = &fss_read_setting_load_depth; data.callback.process_normal = &fss_read_process_normal; data.callback.process_at = &fss_read_process_normal_at; diff --git a/level_3/fss_read/c/extended/fss_read.c b/level_3/fss_read/c/extended/fss_read.c index d79b7bb..2dc5405 100644 --- a/level_3/fss_read/c/extended/fss_read.c +++ b/level_3/fss_read/c/extended/fss_read.c @@ -63,6 +63,14 @@ extern "C" { } } + fss_read_ensure_quotes_length(main); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fss_read_ensure_quotes_length)); + + return; + } + main->setting.state.status = F_none; } #endif // _di_fss_read_extended_process_load_ diff --git a/level_3/fss_read/c/extended/fss_read.h b/level_3/fss_read/c/extended/fss_read.h index 477f27b..db910e6 100644 --- a/level_3/fss_read/c/extended/fss_read.h +++ b/level_3/fss_read/c/extended/fss_read.h @@ -122,8 +122,11 @@ extern "C" { * * Errors (with error bit) from: fll_fss_extended_read() * + * Errors (with error bit) from: fss_read_ensure_quotes_length() + * * @see fll_fss_extended_read() * + * @see fss_read_ensure_quotes_length() * @see fss_read_file_identify() */ #ifndef _di_fss_read_extended_process_load_ diff --git a/level_3/fss_read/c/extended/main.c b/level_3/fss_read/c/extended/main.c index 0c78dd5..46410f5 100644 --- a/level_3/fss_read/c/extended/main.c +++ b/level_3/fss_read/c/extended/main.c @@ -25,7 +25,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.process_help = &fss_read_extended_process_help; data.callback.process_last_line = &fss_read_process_last_line; - data.callback.process_load_depth = &fss_read_setting_load_depth; data.callback.process_normal = &fss_read_process_normal; data.callback.process_at = &fss_read_process_normal_at; diff --git a/level_3/fss_read/c/extended/print.c b/level_3/fss_read/c/extended/print.c index 7f321e2..43b4c21 100644 --- a/level_3/fss_read/c/extended/print.c +++ b/level_3/fss_read/c/extended/print.c @@ -30,7 +30,7 @@ extern "C" { if ((main->setting.flag & fss_read_main_flag_content_e) && main->setting.contents.array[at].used) { if (main->callback.print_content) { - main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[0], main->setting.quotes_content.array[at].array[0], delimits_content); + main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[0], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[0] : 0, delimits_content); } } diff --git a/level_3/fss_read/c/extended_list/fss_read.c b/level_3/fss_read/c/extended_list/fss_read.c index d332ce5..6989420 100644 --- a/level_3/fss_read/c/extended_list/fss_read.c +++ b/level_3/fss_read/c/extended_list/fss_read.c @@ -63,6 +63,14 @@ extern "C" { } } + fss_read_ensure_quotes_length(main); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fss_read_ensure_quotes_length)); + + return; + } + main->setting.state.status = F_none; } #endif // _di_fss_read_extended_list_process_load_ diff --git a/level_3/fss_read/c/extended_list/fss_read.h b/level_3/fss_read/c/extended_list/fss_read.h index 0a3a4d8..ca8ed26 100644 --- a/level_3/fss_read/c/extended_list/fss_read.h +++ b/level_3/fss_read/c/extended_list/fss_read.h @@ -103,8 +103,11 @@ extern "C" { * * Errors (with error bit) from: fll_fss_extended_list_read() * + * Errors (with error bit) from: fss_read_ensure_quotes_length() + * * @see fll_fss_extended_list_read() * + * @see fss_read_ensure_quotes_length() * @see fss_read_file_identify() */ #ifndef _di_fss_read_extended_list_process_load_ diff --git a/level_3/fss_read/c/extended_list/main.c b/level_3/fss_read/c/extended_list/main.c index 3adffc5..555bfa3 100644 --- a/level_3/fss_read/c/extended_list/main.c +++ b/level_3/fss_read/c/extended_list/main.c @@ -17,14 +17,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.custom = (void *) &data; data.program.warning.custom = (void *) &data; - data.setting.flag |= fss_read_main_flag_trim_object_e; - data.setting.state.custom = (void *) &data; data.setting.standard = fss_read_extended_list_standard_s; data.callback.process_help = &fss_read_extended_list_process_help; data.callback.process_last_line = &fss_read_process_last_line; - data.callback.process_load_depth = &fss_read_setting_load_depth; data.callback.process_normal = &fss_read_process_normal; data.callback.process_at = &fss_read_process_normal_at; diff --git a/level_3/fss_read/c/main/common.c b/level_3/fss_read/c/main/common.c index 0ed95ce..79008c1 100644 --- a/level_3/fss_read/c/main/common.c +++ b/level_3/fss_read/c/main/common.c @@ -4,6 +4,23 @@ extern "C" { #endif +#ifndef _di_fss_read_ensure_quotes_length_ + void fss_read_ensure_quotes_length(fss_read_main_t * const main) { + + if (main->setting.quotes_object.size < main->setting.objects.used) { + main->setting.state.status = f_uint8s_increase_by(main->setting.objects.used - main->setting.quotes_object.size, &main->setting.quotes_object); + if (F_status_is_error(main->setting.state.status)) return; + } + + if (main->setting.quotes_content.size < main->setting.contents.used) { + main->setting.state.status = f_uint8ss_increase_by(main->setting.contents.used - main->setting.quotes_content.size, &main->setting.quotes_content); + if (F_status_is_error(main->setting.state.status)) return; + } + + main->setting.state.status = F_none; + } +#endif // _di_fss_read_ensure_quotes_length_ + #ifndef _di_fss_read_setting_load_ void fss_read_setting_load(const f_console_arguments_t arguments, fss_read_main_t * const main, void (*callback)(const f_console_arguments_t arguments, fss_read_main_t * const main)) { @@ -417,16 +434,10 @@ extern "C" { if (parameters->array[fss_read_parameter_content_e].result & f_console_result_found_e) { if (parameters->array[fss_read_parameter_object_e].result & f_console_result_found_e) { - if (parameters->array[fss_read_parameter_content_e].location < parameters->array[fss_read_parameter_object_e].location) { - main->setting.flag |= fss_read_main_flag_object_e; - } - else { - main->setting.flag |= fss_read_main_flag_content_e; - } - } - else { - main->setting.flag |= fss_read_main_flag_content_e; + main->setting.flag |= fss_read_main_flag_object_e; } + + main->setting.flag |= fss_read_main_flag_content_e; } else if (parameters->array[fss_read_parameter_object_e].result & f_console_result_found_e) { main->setting.flag |= fss_read_main_flag_object_e; @@ -516,12 +527,15 @@ extern "C" { main->setting.files.array[0].range.stop = main->setting.buffer.used - 1; if (main->callback.process_last_line) { - main->callback.process_last_line((void *) &main); + main->callback.process_last_line((void *) main); if (F_status_is_error(main->setting.state.status)) return; } + + ++main->setting.files.used; } else { main->setting.files.array[0].range.start = 1; + main->setting.files.array[0].range.stop = 0; } } @@ -529,20 +543,21 @@ extern "C" { off_t size_block = 0; off_t size_file = 0; off_t size_read = 0; + fss_read_file_t *file_data = 0; for (i = 0; i < parameters->remaining.used; ++i) { if (fss_read_signal_check(main)) return; index = parameters->remaining.array[i]; - - main->setting.files.array[main->setting.files.used].name = parameters->arguments.array[index]; - main->setting.files.array[main->setting.files.used].range.start = main->setting.buffer.used; + file_data = &main->setting.files.array[main->setting.files.used]; + file_data->name = parameters->arguments.array[index]; + file_data->range.start = main->setting.buffer.used; file.id = -1; file.stream = 0; - main->setting.state.status = f_file_stream_open(main->setting.files.array[main->setting.files.used].name, f_string_empty_s, &file); + main->setting.state.status = f_file_stream_open(file_data->name, f_string_empty_s, &file); if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { @@ -556,14 +571,14 @@ extern "C" { size_file = 0; - main->setting.state.status = f_file_size_by_id(file, &size_file); + main->setting.state.status = f_file_size(file_data->name, F_true, &size_file); if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_size_by_id), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_read_s, fll_error_file_type_file_e); + fll_error_file_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(f_file_size), fll_error_file_flag_fallback_e, parameters->arguments.array[index], f_file_operation_read_s, fll_error_file_type_file_e); break; } @@ -574,18 +589,15 @@ extern "C" { if (size_file > fss_read_allocation_block_max_d) { file.size_read = fss_read_allocation_block_read_large_d; size_block = fss_read_allocation_block_max_d; - - // Pre-allocate entire file buffer plus space for the terminating NULL. - f_string_dynamic_increase_by(size_file + (size_block - (size_file % size_block)) + 1, &main->setting.buffer); } else { file.size_read = fss_read_allocation_block_read_small_d; size_block = size_file; - - // Pre-allocate entire file buffer plus space for the terminating NULL. - f_string_dynamic_increase_by(size_file + 1, &main->setting.buffer); } + // Pre-allocate entire file buffer plus space for the terminating NULL. + f_string_dynamic_increase_by(size_file + 1, &main->setting.buffer); + if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); @@ -616,11 +628,11 @@ extern "C" { break; } - if (main->setting.buffer.used > main->setting.files.array[main->setting.files.used].range.start) { + if (main->setting.buffer.used > file_data->range.start) { main->setting.files.array[main->setting.files.used++].range.stop = main->setting.buffer.used - 1; if (main->callback.process_last_line) { - main->callback.process_last_line((void *) &main); + main->callback.process_last_line((void *) main); if (F_status_is_error(main->setting.state.status)) break; } } @@ -629,8 +641,8 @@ extern "C" { f_file_stream_close(&file); } else { - main->setting.files.array[main->setting.files.used].range.start = 1; - main->setting.files.array[main->setting.files.used].range.stop = 1; + file_data->range.start = 1; + file_data->range.stop = 0; } } // for @@ -653,9 +665,8 @@ extern "C" { i = parameters->array[fss_read_parameter_depth_e].values.used; } - // @fixme: much of the logic in this depths handling was static and is now dynamic, this needs to be reviewed and updated. - if (i + 1 > main->setting.depths.size) { - main->setting.state.status = fss_read_depths_resize(i + 1, &main->setting.depths); + if (i > main->setting.depths.size) { + main->setting.state.status = fss_read_depths_resize(i, &main->setting.depths); if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { @@ -673,24 +684,23 @@ extern "C" { f_array_length_t position_depth = 0; f_array_length_t position_at = 0; f_array_length_t position_name = 0; + fss_read_depth_t *current = 0; for (i = 0; i < main->setting.depths.used; ++i) { if (fss_read_signal_check(main)) return; - main->setting.depths.array[i].depth = 0; - main->setting.depths.array[i].index_at = 0; - main->setting.depths.array[i].index_name = 0; - main->setting.depths.array[i].value_at = 0; - main->setting.depths.array[i].value_name.used = 0; // @fixme this needs to be fully reset to 0. + current = &main->setting.depths.array[i]; + current->depth = 0; + current->index_at = 0; + current->index_name = 0; + current->value_at = 0; + current->value_name.used = 0; - if (!parameters->array[fss_read_parameter_depth_e].values.used) { - position_depth = 0; - } - else { + if (parameters->array[fss_read_parameter_depth_e].values.used) { position_depth = parameters->array[fss_read_parameter_depth_e].values.array[i]; - main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[position_depth], &main->setting.depths.array[i].depth); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[position_depth], ¤t->depth); if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { @@ -702,6 +712,9 @@ extern "C" { return; } } + else { + position_depth = 0; + } if (parameters->array[fss_read_parameter_at_e].result & f_console_result_value_e) { for (; position_at < parameters->array[fss_read_parameter_at_e].values.used; ++position_at) { @@ -714,16 +727,16 @@ extern "C" { break; } - main->setting.depths.array[i].index_at = parameters->array[fss_read_parameter_at_e].values.array[position_at]; + current->index_at = parameters->array[fss_read_parameter_at_e].values.array[position_at]; - main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[main->setting.depths.array[i].index_at], &main->setting.depths.array[i].value_at); + main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[current->index_at], ¤t->value_at); if (F_status_is_error(main->setting.state.status)) { if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fll_error_parameter_integer_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(fl_conversion_dynamic_to_unsigned_detect), F_true, fss_read_long_at_s, parameters->arguments.array[main->setting.depths.array[i].index_at]); + fll_error_parameter_integer_print(&main->program.error, F_status_set_fine(main->setting.state.status), macro_fss_read_f(fl_conversion_dynamic_to_unsigned_detect), F_true, fss_read_long_at_s, parameters->arguments.array[current->index_at]); return; } @@ -741,13 +754,13 @@ extern "C" { break; } - main->setting.depths.array[i].index_name = parameters->array[fss_read_parameter_name_e].values.array[position_name]; + current->index_name = parameters->array[fss_read_parameter_name_e].values.array[position_name]; if (parameters->array[fss_read_parameter_trim_e].result & f_console_result_found_e) { - main->setting.state.status = f_rip_dynamic(parameters->arguments.array[main->setting.depths.array[i].index_name], &main->setting.depths.array[i].value_name); + main->setting.state.status = f_rip_dynamic(parameters->arguments.array[current->index_name], ¤t->value_name); } else { - main->setting.state.status = f_string_dynamic_append(parameters->arguments.array[main->setting.depths.array[i].index_name], &main->setting.depths.array[i].value_name); + main->setting.state.status = f_string_dynamic_append(parameters->arguments.array[current->index_name], ¤t->value_name); } if (F_status_is_error(main->setting.state.status)) { @@ -771,37 +784,34 @@ extern "C" { if (fss_read_signal_check(main)) return; - if (main->setting.depths.array[i].depth == main->setting.depths.array[j].depth) { + current = &main->setting.depths.array[i]; + + if (current->depth == main->setting.depths.array[j].depth) { main->setting.state.status = F_status_set_error(F_parameter); if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fss_read_print_error_parameter_value_once_only_number(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_depth_s, main->setting.depths.array[i].depth); + fss_read_print_error_parameter_value_once_only_number(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_depth_s, current->depth); return; } - if (main->setting.depths.array[i].depth > main->setting.depths.array[j].depth) { + if (current->depth > main->setting.depths.array[j].depth) { main->setting.state.status = F_status_set_error(F_parameter); if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) { fll_print_dynamic_raw(f_string_eol_s, main->program.message.to); } - fss_read_print_error_parameter_value_before_value_number(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_depth_s, main->setting.depths.array[i].depth, main->setting.depths.array[j].depth); + fss_read_print_error_parameter_value_before_value_number(&main->program.error, f_console_symbol_long_normal_s, fss_read_long_depth_s, current->depth, main->setting.depths.array[j].depth); return; } } // for } // for - if (main->callback.process_load_depth) { - main->callback.process_load_depth(arguments, (void *) main, parameters); - if (F_status_is_error(main->setting.state.status)) return; - } - main->setting.state.status = F_none; } #endif // _di_fss_read_setting_load_depth_ diff --git a/level_3/fss_read/c/main/common.h b/level_3/fss_read/c/main/common.h index a4f96dc..6469691 100644 --- a/level_3/fss_read/c/main/common.h +++ b/level_3/fss_read/c/main/common.h @@ -17,6 +17,25 @@ extern "C" { #endif /** + * Make sure the array size of quotes_object and quotes_content matches the respective objects and contents. + * + * @param main + * The main program data. + * + * This alters main.setting.state.status: + * F_none on success. + * + * Errors (with error bit) from: f_uint8s_increase_by(). + * Errors (with error bit) from: f_uint8ss_increase_by(). + * + * @see f_uint8s_increase_by() + * @see f_uint8ss_increase_by() + */ +#ifndef _di_fss_read_ensure_quotes_length_ + extern void fss_read_ensure_quotes_length(fss_read_main_t * const main); +#endif // _di_fss_read_ensure_quotes_length_ + +/** * Perform the standard program setting load process. * * This prints error messages as appropriate. @@ -82,8 +101,6 @@ extern "C" { * Must not be NULL. * Must be of type fss_read_main_t. * - * This calls main.callback.process_load_depth() if not NULL. - * * This alters main.setting.state.status: * F_none on success. * diff --git a/level_3/fss_read/c/main/common/print.c b/level_3/fss_read/c/main/common/print.c index b773af0..eb112e3 100644 --- a/level_3/fss_read/c/main/common/print.c +++ b/level_3/fss_read/c/main/common/print.c @@ -8,7 +8,7 @@ extern "C" { const f_string_t fss_read_f_a[] = { "f_console_parameter_process", "f_file_read_block", - "f_file_size_by_id", + "f_file_size", "f_file_stream_open", "f_file_stream_read", "f_file_stream_read_block", @@ -52,6 +52,7 @@ extern "C" { "fll_program_parameter_process_context", "fll_program_parameter_process_verbosity", "fss_read_depths_resize", + "fss_read_ensure_quotes_length", "fss_read_files_resize", "fss_read_setting_load_depth", }; diff --git a/level_3/fss_read/c/main/common/print.h b/level_3/fss_read/c/main/common/print.h index d49f1cf..8a3da05 100644 --- a/level_3/fss_read/c/main/common/print.h +++ b/level_3/fss_read/c/main/common/print.h @@ -41,7 +41,7 @@ extern "C" { enum { fss_read_f_f_console_parameter_process_e, fss_read_f_f_file_read_block_e, - fss_read_f_f_file_size_by_id_e, + fss_read_f_f_file_size_e, fss_read_f_f_file_stream_open_e, fss_read_f_f_file_stream_read_e, fss_read_f_f_file_stream_read_block_e, @@ -85,6 +85,7 @@ extern "C" { fss_read_f_fll_program_parameter_process_context_e, fss_read_f_fll_program_parameter_process_verbosity_e, fss_read_f_fss_read_depths_resize_e, + fss_read_f_fss_read_ensure_quotes_length_e, fss_read_f_fss_read_files_resize_e, fss_read_f_fss_read_setting_load_depth_e, }; // enum diff --git a/level_3/fss_read/c/main/common/type.c b/level_3/fss_read/c/main/common/type.c index 5315e61..26162dd 100644 --- a/level_3/fss_read/c/main/common/type.c +++ b/level_3/fss_read/c/main/common/type.c @@ -19,13 +19,11 @@ extern "C" { if (!depths) return F_status_set_error(F_parameter); if (depths->used + length > F_array_length_t_size_d) return F_status_set_error(F_array_too_large); - f_status_t status = F_none; - for (f_array_length_t i = length; i < depths->size; ++i) { fss_read_depth_delete(&depths->array[i]); } // for - status = f_memory_resize(depths->size, length, sizeof(fss_read_file_t), (void **) & depths->array); + const f_status_t status = f_memory_resize(depths->size, length, sizeof(fss_read_depth_t), (void **) & depths->array); if (F_status_is_error(status)) return status; depths->size = length; diff --git a/level_3/fss_read/c/main/common/type.h b/level_3/fss_read/c/main/common/type.h index e239c4f..b759328 100644 --- a/level_3/fss_read/c/main/common/type.h +++ b/level_3/fss_read/c/main/common/type.h @@ -35,7 +35,7 @@ extern "C" { f_array_length_t index_name; f_number_unsigned_t value_at; - f_string_dynamic_t value_name; + f_string_dynamic_t value_name; } fss_read_depth_t; #define fss_read_depth_t_initialize \ @@ -119,17 +119,16 @@ extern "C" { /** * The FSS read callbacks. * - * process_help: Process help (generally printing help). - * process_last_line: Process printing last line if necessary when loading in a file (or pipe). - * process_load_depth: Process loading of the depth related parameters when loading the settings. - * process_normal: Process normally (data from parameters and files). + * process_help: Process help (generally printing help). + * process_last_line: Process printing last line if necessary when loading in a file (or pipe). + * process_normal: Process normally (data from parameters and files). * - * process_at: Process at parameter, usually called by the process_normal() callback. - * process_columns: Process columns parameter, usually called by the process_normal() callback. - * process_line: Process line parameter, usually called by the process_normal() callback. - * process_load: Process loading of FSS data from buffer (not to be confused with loading settings), usually called by the process_normal() callback. - * process_name: Process name parameter, usually called by the process_normal() callback. - * process_total: Process total parameter, usually called by the process_normal() callback. + * process_at: Process at parameter, usually called by the process_normal() callback. + * process_columns: Process columns parameter, usually called by the process_normal() callback. + * process_line: Process line parameter, usually called by the process_normal() callback. + * process_load: Process loading of FSS data from buffer (not to be confused with loading settings), usually called by the process_normal() callback. + * process_name: Process name parameter, usually called by the process_normal() callback. + * process_total: Process total parameter, usually called by the process_normal() callback. * * print_at: Print at the given location, usually called by the process_normal() callback. * print_object: Print the Object, usually called by the process_normal() callback. @@ -142,7 +141,6 @@ extern "C" { typedef struct { void (*process_help)(void * const main); void (*process_last_line)(void * const main); - void (*process_load_depth)(const f_console_arguments_t arguments, void * const main, f_console_parameters_t * const parameters); void (*process_normal)(void * const main); void (*process_at)(void * const main, const bool names[], const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content); diff --git a/level_3/fss_read/c/main/main.c b/level_3/fss_read/c/main/main.c index ff36084..25d0bbf 100644 --- a/level_3/fss_read/c/main/main.c +++ b/level_3/fss_read/c/main/main.c @@ -100,7 +100,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.process_help = &fss_read_main_process_help; main->callback.process_last_line = &fss_read_process_last_line; - main->callback.process_load_depth = &fss_read_setting_load_depth; main->callback.process_normal = &fss_read_process_normal; main->callback.process_at = &fss_read_process_normal_at; @@ -181,8 +180,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e; main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e; - main->setting.flag |= fss_read_main_flag_trim_object_e; - main->callback.process_help = &fss_read_basic_list_process_help; main->callback.process_load = &fss_read_basic_list_process_load; main->callback.print_set_end = &fss_read_print_set_end; @@ -203,8 +200,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e; main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e; - main->setting.flag |= fss_read_main_flag_trim_object_e; - main->callback.process_help = &fss_read_extended_list_process_help; main->callback.process_load = &fss_read_extended_list_process_load; main->callback.print_set_end = &fss_read_print_set_end; @@ -223,7 +218,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e; main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e; - main->setting.flag |= fss_read_main_flag_trim_object_e; main->setting.flag |= fss_read_main_flag_content_multiple_e | fss_read_main_flag_depth_multiple_e; main->callback.process_help = &fss_read_embedded_list_process_help; @@ -246,8 +240,6 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e; main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e; - main->setting.flag |= fss_read_main_flag_trim_object_e; - main->callback.process_help = &fss_read_payload_process_help; main->callback.process_load = &fss_read_payload_process_load; main->callback.print_set_end = &fss_read_print_set_end; diff --git a/level_3/fss_read/c/main/print/data.c b/level_3/fss_read/c/main/print/data.c index a7cd1b2..cf612bd 100644 --- a/level_3/fss_read/c/main/print/data.c +++ b/level_3/fss_read/c/main/print/data.c @@ -28,7 +28,7 @@ extern "C" { if ((main->setting.flag & fss_read_main_flag_content_e) && main->setting.contents.array[at].used) { if (main->callback.print_content) { - main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[0], main->setting.quotes_content.array[at].array[0], delimits_content); + main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[0], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[0] : 0, delimits_content); } } @@ -164,14 +164,16 @@ extern "C" { if (!print) return F_status_set_error(F_output_not); - fll_print_dynamic_raw( - type == f_fss_quote_type_single_e - ? f_fss_quote_single_s - : type == f_fss_quote_type_backtick_e - ? f_fss_quote_backtick_s - : f_fss_quote_double_s, - print->to - ); + if (type) { + fll_print_dynamic_raw( + type == f_fss_quote_type_single_e + ? f_fss_quote_single_s + : type == f_fss_quote_type_backtick_e + ? f_fss_quote_backtick_s + : f_fss_quote_double_s, + print->to + ); + } return F_none; } diff --git a/level_3/fss_read/c/payload/fss_read.c b/level_3/fss_read/c/payload/fss_read.c index 5a69c75..4331a30 100644 --- a/level_3/fss_read/c/payload/fss_read.c +++ b/level_3/fss_read/c/payload/fss_read.c @@ -63,6 +63,14 @@ extern "C" { } } + fss_read_ensure_quotes_length(main); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(fss_read_ensure_quotes_length)); + + return; + } + main->setting.state.status = F_none; } #endif // _di_fss_read_payload_process_load_ diff --git a/level_3/fss_read/c/payload/fss_read.h b/level_3/fss_read/c/payload/fss_read.h index 1d71748..b97f2a9 100644 --- a/level_3/fss_read/c/payload/fss_read.h +++ b/level_3/fss_read/c/payload/fss_read.h @@ -104,6 +104,9 @@ extern "C" { * * Errors (with error bit) from: fll_fss_payload_read() * + * Errors (with error bit) from: fss_read_ensure_quotes_length() + * + * @see fss_read_ensure_quotes_length() * @see fll_fss_payload_read() * * @see fss_read_file_identify() diff --git a/level_3/fss_read/c/payload/main.c b/level_3/fss_read/c/payload/main.c index 5ee4ae4..034df72 100644 --- a/level_3/fss_read/c/payload/main.c +++ b/level_3/fss_read/c/payload/main.c @@ -17,14 +17,11 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.program.output.custom = (void *) &data; data.program.warning.custom = (void *) &data; - data.setting.flag |= fss_read_main_flag_trim_object_e; - data.setting.state.custom = (void *) &data; data.setting.standard = fss_read_payload_standard_s; data.callback.process_help = &fss_read_payload_process_help; data.callback.process_last_line = &fss_read_process_last_line; - data.callback.process_load_depth = &fss_read_setting_load_depth; data.callback.process_normal = &fss_read_process_normal; data.callback.process_at = &fss_read_process_normal_at;