From f479fbdb7eddbcfec61b39c4ebe575be42ae92b9 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 15 Jun 2023 19:33:20 -0500 Subject: [PATCH] Bugfix: The line and total need to support the closing brace. The closing brace is now being calculated when both --object and --content are specified. --- level_3/fss_basic_list_read/c/private-read.c | 9 +-- level_3/fss_extended_list_read/c/private-read.c | 80 +++++++++++++++---------- level_3/fss_payload_read/c/private-read.c | 13 +--- 3 files changed, 53 insertions(+), 49 deletions(-) diff --git a/level_3/fss_basic_list_read/c/private-read.c b/level_3/fss_basic_list_read/c/private-read.c index 74c80ac..cd06c1a 100644 --- a/level_3/fss_basic_list_read/c/private-read.c +++ b/level_3/fss_basic_list_read/c/private-read.c @@ -484,18 +484,14 @@ extern "C" { // There is only a single Content column for this standard. if (data->option & fss_basic_list_read_data_option_content_d) { - if (!data->contents.array[at].used) { - return F_none; - } + if (!data->contents.array[at].used) return F_none; f_string_range_t range = data->contents.array[at].array[0]; f_array_length_t i = 0; f_array_length_t j = 0; // This content has no data, do not even check "include empty" because it cannot be counted as a line. - if (range.start > range.stop) { - return F_none; - } + if (range.start > range.stop) return F_none; for (i = range.start; i <= range.stop; ++i) { @@ -766,7 +762,6 @@ extern "C" { // There is only a single Content column for this standard. if (data->option & fss_basic_list_read_data_option_content_d) { - if (!data->contents.array[at].used) continue; range.start = data->contents.array[at].array[0].start; diff --git a/level_3/fss_extended_list_read/c/private-read.c b/level_3/fss_extended_list_read/c/private-read.c index 808859f..9342805 100644 --- a/level_3/fss_extended_list_read/c/private-read.c +++ b/level_3/fss_extended_list_read/c/private-read.c @@ -474,7 +474,6 @@ extern "C" { f_status_t fss_extended_list_read_process_at_line(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t *line) { if (data->option & fss_extended_list_read_data_option_object_d) { - if (*line == data->line) { flockfile(main->output.to.stream); @@ -495,9 +494,7 @@ extern "C" { // There is only a single Content column for this standard. if (data->option & fss_extended_list_read_data_option_content_d) { - if (!data->contents.array[at].used) { - return F_none; - } + if (!data->contents.array[at].used) return F_none; f_string_range_t range = f_string_range_t_initialize; f_array_length_t i = 0; @@ -507,52 +504,72 @@ extern "C" { range.stop = data->contents.array[at].array[0].stop; // This content has no data, do not even check "include empty" because it cannot be counted as a line. - if (range.start > range.stop) { - return F_none; - } + if (range.start <= range.stop) { + for (i = range.start; i <= range.stop; ++i) { - for (i = range.start; i <= range.stop; ++i) { + if (j < data->comments.used) { + while (data->comments.array[j].stop < i) ++j; - if (j < data->comments.used) { - while (data->comments.array[j].stop < i) ++j; + if (i >= data->comments.array[j].start && i <= data->comments.array[j].stop) { + i = data->comments.array[j++].stop; - if (i >= data->comments.array[j].start && i <= data->comments.array[j].stop) { - i = data->comments.array[j++].stop; + continue; + } + } - continue; + if (data->buffer.string[i] == f_string_eol_s.string[0]) { + if (*line == data->line) { + range.stop = i; + + flockfile(main->output.to.stream); + + if (data->option & fss_extended_list_read_data_option_total_d) { + fss_extended_list_read_print_one(main); + } + else { + f_print_except_in_dynamic_partial(data->buffer, range, delimits_content, data->comments, main->output.to.stream); + } + + funlockfile(main->output.to.stream); + + return F_success; + } + + range.start = i + 1; + + if (i <= range.stop) { + ++(*line); + } } - } + } // for - if (data->buffer.string[i] == f_string_eol_s.string[0]) { - if (*line == data->line) { - range.stop = i; + // If Content does not end with a newline, it still must be treated as the last line. + if (data->buffer.string[range.stop] != f_string_eol_s.string[0]) { + ++(*line); + if (*line == data->line) { flockfile(main->output.to.stream); if (data->option & fss_extended_list_read_data_option_total_d) { fss_extended_list_read_print_one(main); } else { + range.stop = data->contents.array[at].array[0].stop; + f_print_except_in_dynamic_partial(data->buffer, range, delimits_content, data->comments, main->output.to.stream); + f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); } funlockfile(main->output.to.stream); return F_success; } - - range.start = i + 1; - - if (i <= range.stop) { - ++(*line); - } } - } // for - - // If Content does not end with a newline, it still must be treated as the last line. - if (data->buffer.string[range.stop] != f_string_eol_s.string[0]) { - ++(*line); + } + // @fixme The fll_fss_*_read functions do not have a store of the set closing ranges but should. + // Simulate the ending by printing, but the original range should ideally be used. + if (data->option & fss_extended_list_read_data_option_object_d) { if (*line == data->line) { flockfile(main->output.to.stream); @@ -560,16 +577,15 @@ extern "C" { fss_extended_list_read_print_one(main); } else { - range.stop = data->contents.array[at].array[0].stop; - - f_print_except_in_dynamic_partial(data->buffer, range, delimits_content, data->comments, main->output.to.stream); - f_print_dynamic_raw(f_string_eol_s, main->output.to.stream); + fss_extended_list_read_print_set_end(main, data); } funlockfile(main->output.to.stream); return F_success; } + + ++(*line); } } diff --git a/level_3/fss_payload_read/c/private-read.c b/level_3/fss_payload_read/c/private-read.c index 099f1ce..031a89a 100644 --- a/level_3/fss_payload_read/c/private-read.c +++ b/level_3/fss_payload_read/c/private-read.c @@ -709,9 +709,7 @@ extern "C" { // There is only a single Content column for this standard. if (data->option & fss_payload_read_data_option_content_d) { - if (!data->contents.array[at].used) { - return F_none; - } + if (!data->contents.array[at].used) return F_none; f_string_range_t range = f_string_range_t_initialize; f_array_length_t i = 0; @@ -721,9 +719,7 @@ extern "C" { range.stop = data->contents.array[at].array[0].stop; // This content has no data, do not even check "include empty" because it cannot be counted as a line. - if (range.start > range.stop) { - return F_none; - } + if (range.start > range.stop) return F_none; for (i = range.start; i <= range.stop; ++i) { @@ -1112,16 +1108,13 @@ extern "C" { // There is only a single Content column for this standard. if (data->option & fss_payload_read_data_option_content_d) { - if (!data->contents.array[at].used) continue; range.start = data->contents.array[at].array[0].start; range.stop = data->contents.array[at].array[0].stop; // This content has no data, do not even check "include empty" because it cannot be counted as a line. - if (range.start > range.stop) { - continue; - } + if (range.start > range.stop) continue; for (i = range.start; i <= range.stop; ++i) { -- 1.8.3.1