From: Kevin Day Date: Thu, 12 Dec 2024 04:35:34 +0000 (-0600) Subject: Progress: Continue fixing iki_read (and eki_read). X-Git-Tag: 0.7.0~9 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=0a78ba71a7fb1d0a0720129fa46bfd9f985d95a1;p=fll Progress: Continue fixing iki_read (and eki_read). There is overlap between how `--at` and `--line` work when not using `--whole`. Do not treat using both as an error. Instead, just have `--at` be the higher priority and then perform `--line`. This results in a `--line` that can only potentially print something if it has a value of 0. This is only the case for `--object`. Both the `--content` and the `--literal` may potentially have multiple lines. I removed the existing `--line` logic. I will rewrite the logic for determining the number of lines when printing the `--literal` or the `--content`. There will also need to be another file that haas multiple iki lines. I was adding the line break behavior to break out of the loop when the line matches. Much of that, but not all of that, has been removed until I come back to write the new logic. The runtime tests are not yet updated. --- diff --git a/level_3/iki_read/c/eki/process.c b/level_3/iki_read/c/eki/process.c index 35075d0..8791166 100644 --- a/level_3/iki_read/c/eki/process.c +++ b/level_3/iki_read/c/eki/process.c @@ -29,12 +29,21 @@ extern "C" { return; } + // When --at and --line are specified, the only value for --line that will print anything is 0 when using --object. + if ((main->setting.flag & iki_read_main_flag_at_d) && (main->setting.flag & iki_read_main_flag_line_d)) { + if ((main->setting.flag & iki_read_main_flag_object_d) && main->setting.line) { + main->setting.state.status = F_data_not; + + return; + } + } + f_number_unsigned_t i = 0; if (main->setting.flag & iki_read_main_flag_name_d) { f_number_unsigned_t j = 0; f_number_unsigned_t matches = 0; - uint8_t unmatched = F_true; + uint8_t unmatched = 0x1; // 0x1 = unmatched, 0x2 = line break. if (!(main->setting.flag & iki_read_main_flag_total_d)) { f_file_stream_lock(main->program.output.to); @@ -50,12 +59,6 @@ extern "C" { return; } - // The variable parts, when not using --wrap, each is represented on its own line. - if (main->setting.flag & iki_read_main_flag_line_d) { - if (i < main->setting.line) continue; - if (i > main->setting.line) break; - } - for (j = 0; j < main->setting.names.used; ++j) { if (iki_read_signal_check(main)) { @@ -67,7 +70,7 @@ extern "C" { } if (f_compare_dynamic_partial_string(main->setting.names.array[j].string, main->cache.buffer, main->setting.names.array[j].used, data->vocabularys.array[i].array[0]) == F_equal_to) { - unmatched = F_false; + unmatched &= ~0x1; if (main->setting.flag & iki_read_main_flag_at_d) { if (matches < main->setting.at) { @@ -93,6 +96,8 @@ extern "C" { } } } // for + + if (unmatched & 0x2) break; } // for if ((main->setting.flag & iki_read_main_flag_total_d)) { @@ -113,7 +118,7 @@ extern "C" { f_file_stream_unlock(main->program.output.to); } - main->setting.state.status = unmatched ? F_data_not : F_okay; + main->setting.state.status = (unmatched & 0x1) ? F_data_not : F_okay; } else { if (data->variable.used) { diff --git a/level_3/iki_read/c/iki/process.c b/level_3/iki_read/c/iki/process.c index db2f993..d0fdecb 100644 --- a/level_3/iki_read/c/iki/process.c +++ b/level_3/iki_read/c/iki/process.c @@ -29,12 +29,21 @@ extern "C" { return; } + // When --at and --line are specified, the only value for --line that will print anything is 0 when using --object. + if ((main->setting.flag & iki_read_main_flag_at_d) && (main->setting.flag & iki_read_main_flag_line_d)) { + if ((main->setting.flag & iki_read_main_flag_object_d) && main->setting.line) { + main->setting.state.status = F_data_not; + + return; + } + } + f_number_unsigned_t i = 0; if (main->setting.flag & iki_read_main_flag_name_d) { f_number_unsigned_t j = 0; f_number_unsigned_t matches = 0; - uint8_t unmatched = F_true; + uint8_t unmatched = 0x1; // 0x1 = unmatched, 0x2 = line break. if (!(main->setting.flag & iki_read_main_flag_total_d)) { f_file_stream_lock(main->program.output.to); @@ -50,12 +59,6 @@ extern "C" { return; } - // The variable parts, when not using --wrap, each is represented on its own line. - if (main->setting.flag & iki_read_main_flag_line_d) { - if (i < main->setting.line) continue; - if (i > main->setting.line) break; - } - for (j = 0; j < main->setting.names.used; ++j) { if (iki_read_signal_check(main)) { @@ -67,7 +70,7 @@ extern "C" { } if (f_compare_dynamic_partial_string(main->setting.names.array[j].string, main->cache.buffer, main->setting.names.array[j].used, data->vocabulary.array[i]) == F_equal_to) { - unmatched = F_false; + unmatched &= ~0x1; if (main->setting.flag & iki_read_main_flag_at_d) { if (matches < main->setting.at) { @@ -93,6 +96,8 @@ extern "C" { } } } // for + + if (unmatched & 0x2) break; } // for if (main->setting.flag & iki_read_main_flag_total_d) { @@ -113,7 +118,7 @@ extern "C" { f_file_stream_unlock(main->program.output.to); } - main->setting.state.status = unmatched ? F_data_not : F_okay; + main->setting.state.status = (unmatched & 0x1) ? F_data_not : F_okay; } else { if (data->variable.used) {