From: Kevin Day Date: Thu, 2 Jan 2025 04:28:35 +0000 (-0600) Subject: Progress: Continue fixing iki_read (and eki_read) for runtime tests. X-Git-Tag: 0.7.0~5 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=61b0a1d7c50f0440ae3b7d57de0ab93d4f7d8752;p=fll Progress: Continue fixing iki_read (and eki_read) for runtime tests. Minor changes that I started working on before vacation. I forgot to write the notes and make a commit. I appear to have changed some of the name parameter handling. There is a clear bug where I mistakingly used the wrong array for a range check in a loop. Use the state status rather than a custom status for managing the status. Some of the print parameters are using the output.to directly rather than the print variable passed to the function. Correct some of the function documentation. there are still 165 test failures that I need to review. --- diff --git a/level_3/iki_read/c/iki/process.c b/level_3/iki_read/c/iki/process.c index 27e2adf..429278b 100644 --- a/level_3/iki_read/c/iki/process.c +++ b/level_3/iki_read/c/iki/process.c @@ -213,11 +213,11 @@ extern "C" { f_number_unsigned_t matches = 0; uint8_t matched = 0x0; // 0x0 = unmatched, 0x1 = matched. - for (i = 0; i < data->vocabulary.used; ++i) { - - if (iki_read_signal_check(main)) return; + // Only the last name parameter is valid for use. + if (main->setting.names.used) { + j = main->setting.names.used - 1; - for (j = 0; j < main->setting.names.used; ++j) { + for (i = 0; i < data->vocabulary.used; ++i) { if (iki_read_signal_check(main)) return; @@ -261,7 +261,7 @@ extern "C" { } } } // for - } // for + } if (main->setting.flag & iki_read_main_flag_line_d) { if (main->setting.flag & iki_read_main_flag_total_d) { @@ -278,10 +278,6 @@ extern "C" { else { iki_read_print_data_total(&main->program.output, matches); } - - main->setting.state.status = matched ? F_okay : F_data_not; - - return; } main->setting.state.status = matched ? F_okay : F_data_not; diff --git a/level_3/iki_read/c/main/print/data.c b/level_3/iki_read/c/main/print/data.c index 4d9c99a..4931f88 100644 --- a/level_3/iki_read/c/main/print/data.c +++ b/level_3/iki_read/c/main/print/data.c @@ -11,23 +11,30 @@ extern "C" { iki_read_main_t * const main = (iki_read_main_t *) print->custom; - if (F_status_is_error(main->setting.state.status) || !main->cache.expand.used) return; + if (F_status_is_error(main->setting.state.status)) return; + + if (!main->cache.expand.used) { + main->setting.state.status = F_data_not; + + return; + } f_number_unsigned_t i = 0; f_range_t range = macro_f_range_t_initialize_2(main->cache.expand.used); - f_status_t status; for (f_number_unsigned_t first = 0; range.start <= range.stop && range.start < main->cache.expand.used; ) { - status = f_string_dynamic_seek_line(main->cache.expand, &range); - if (F_status_is_error(status)) return; + if (iki_read_signal_check(main)) return; + + main->setting.state.status = f_string_dynamic_seek_line(main->cache.expand, &range); + if (F_status_is_error(main->setting.state.status)) return; - if (status == F_okay) { + if (main->setting.state.status == F_okay) { if (i == main->setting.line) { range.stop = range.start; range.start = first; - f_print_dynamic_partial(main->cache.expand, range, main->program.output.to); + f_print_dynamic_partial(main->cache.expand, range, print->to); break; } @@ -41,13 +48,15 @@ extern "C" { range.stop = range.start; range.start = first; - f_print_dynamic_partial(main->cache.expand, range, main->program.output.to); - f_print_dynamic(f_string_eol_s, main->program.output.to); + f_print_dynamic_partial(main->cache.expand, range, print->to); + f_print_dynamic(f_string_eol_s, print->to); } break; } } // for + + main->setting.state.status = F_okay; } #endif // _di_iki_read_print_data_line_ @@ -110,7 +119,7 @@ extern "C" { for (f_number_unsigned_t i = 0; i < main->setting.map_wrapss.array[index].used; ++i) { if (array[i] < main->setting.wrap.used && main->setting.wrap.array[array[i]].c.used) { - f_print_dynamic(main->setting.wrap.array[array[i]].c, main->program.output.to); + f_print_dynamic(main->setting.wrap.array[array[i]].c, print->to); } } // for } @@ -130,7 +139,7 @@ extern "C" { for (f_number_unsigned_t i = 0; i < main->setting.map_wrapss.array[index].used; ++i) { if (array[i] < main->setting.wrap.used && main->setting.wrap.array[array[i]].b.used) { - f_print_dynamic(main->setting.wrap.array[array[i]].b, main->program.output.to); + f_print_dynamic(main->setting.wrap.array[array[i]].b, print->to); } } // for } diff --git a/level_3/iki_read/c/main/print/data.h b/level_3/iki_read/c/main/print/data.h index 106b5d4..3fa064b 100644 --- a/level_3/iki_read/c/main/print/data.h +++ b/level_3/iki_read/c/main/print/data.h @@ -25,7 +25,14 @@ extern "C" { * @param print * The output structure to print to. * - * This does not alter print.custom.setting.state.status. + * This alters print.custom.setting.state.status: + * F_okay on success. + * F_data_not on success, but total is 0 or line is out of range. + * + * Error (with error bit set) from f_string_dynamic_seek_line(). + * Error (with error bit set) from iki_read_signal_check(). + * + * Error (with error bit) if status already has an error before start of function. */ #ifndef _di_iki_read_print_data_line_ extern void iki_read_print_data_line(fl_print_t * const print); @@ -65,7 +72,17 @@ extern "C" { * @param print * The output structure to print to. * - * This does not alter print.custom.setting.state.status. + * This alters print.custom.setting.state.status: + * F_okay on success. + * F_data_not on success, but total is 0 or line is out of range. + * + * Error (with error bit set) from f_string_dynamic_seek_line(). + * Error (with error bit set) from iki_read_signal_check(). + * + * Error (with error bit) if status already has an error before start of function. + * + * @see f_string_dynamic_seek_line() + * @see iki_read_signal_check() */ #ifndef _di_iki_read_print_data_line_total_expand_ extern void iki_read_print_data_total_expand(fl_print_t * const print);