From: Kevin Day Date: Sat, 24 Aug 2024 03:09:39 +0000 (-0500) Subject: Update: Always count any --select when using --object for FSS Read programs. X-Git-Tag: 0.6.12~26 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=e174a37a548573d9e3ef3b79341429c5a7ec5c80;p=fll Update: Always count any --select when using --object for FSS Read programs. Working on the 0.7 FSS Read programs resulted in me noticing an oversight regarding the `--select` with the `--object`. The `--object` will always result in showing things even if the `--select` number is infinitely large. This is a back port of those changes. I decided to also copy over a lot of the FSS Read code for this from 0.7. Doing this should help make maintaining both the 0.6 nd 0.7 easier. I still have work for the FSS Embedded Read program in the 0.7 branch and so I decided to withhold any 0.6 changes for FSS Embedded Read until I finish my changes in 0.7. This updates the relevant runtime tests. --- diff --git a/level_3/fss_basic_list_read/c/private-common.h b/level_3/fss_basic_list_read/c/private-common.h index cfe5c07..7e1e2b9 100644 --- a/level_3/fss_basic_list_read/c/private-common.h +++ b/level_3/fss_basic_list_read/c/private-common.h @@ -137,17 +137,18 @@ extern "C" { * The data structure for FSS Basic Read. * * fss_basic_list_read_data_option_*: - * - at: The object at the given position is being selected (Think of this as select a row for some Object). - * - columns: The total columns found and selected is printed instead of the Content. - * - content: The Content is to be printed. - * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). - * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). - * - name: A specific Object name has been requested. - * - object: The Object is to be printed. - * - original: Enable original printing, where the quotes are printed and no delimits are applied. - * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). - * - total: The total lines found and selected is printed instead of the Content. - * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). + * - at: The object at the given position is being selected (Think of this as select a row for some Object). + * - columns: The total columns found and selected is printed instead of the Content. + * - content: The Content is to be printed. + * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). + * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). + * - name: A specific Object name has been requested. + * - object: The Object is to be printed. + * - original: Enable original printing, where the quotes are printed and no delimits are applied. + * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). + * - select_content: A helper flag representing select and content flag bits being set. + * - total: The total lines found and selected is printed instead of the Content. + * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). * * argv: The argument structure in the progam data parameters for simplifying syntax. * options: Bitwise flags representing parameters. @@ -164,17 +165,18 @@ extern "C" { * delimits_content: The positions within the buffer representing Content character delimits. */ #ifndef _di_fss_basic_list_read_data_t_ - #define fss_basic_list_read_data_option_at_d 0x1 - #define fss_basic_list_read_data_option_columns_d 0x2 - #define fss_basic_list_read_data_option_content_d 0x4 - #define fss_basic_list_read_data_option_empty_d 0x8 - #define fss_basic_list_read_data_option_line_d 0x10 - #define fss_basic_list_read_data_option_name_d 0x20 - #define fss_basic_list_read_data_option_object_d 0x40 - #define fss_basic_list_read_data_option_original_d 0x80 - #define fss_basic_list_read_data_option_select_d 0x100 - #define fss_basic_list_read_data_option_total_d 0x200 - #define fss_basic_list_read_data_option_trim_d 0x400 + #define fss_basic_list_read_data_option_at_d 0x1 + #define fss_basic_list_read_data_option_columns_d 0x2 + #define fss_basic_list_read_data_option_content_d 0x4 + #define fss_basic_list_read_data_option_empty_d 0x8 + #define fss_basic_list_read_data_option_line_d 0x10 + #define fss_basic_list_read_data_option_name_d 0x20 + #define fss_basic_list_read_data_option_object_d 0x40 + #define fss_basic_list_read_data_option_original_d 0x80 + #define fss_basic_list_read_data_option_select_d 0x100 + #define fss_basic_list_read_data_option_select_content_d 0x104 + #define fss_basic_list_read_data_option_total_d 0x200 + #define fss_basic_list_read_data_option_trim_d 0x400 typedef struct { uint16_t option; 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 d063132..21a99e8 100644 --- a/level_3/fss_basic_list_read/c/private-read.c +++ b/level_3/fss_basic_list_read/c/private-read.c @@ -271,7 +271,7 @@ extern "C" { #endif // _di_fss_basic_list_read_load_ #ifndef _di_fss_basic_list_read_load_number_ - f_status_t fss_basic_list_read_load_number(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { + f_status_t fss_basic_list_read_load_number(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_array_length_t *number) { if (main->parameters.array[parameter].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; @@ -541,7 +541,7 @@ extern "C" { } } // for - // If Content does not end with a newline, it still must be treated as the last line. + // Treat Content as the last line even if it does not end with a new line. if (data->buffer.string[range.stop] != f_string_eol_s.string[0]) { ++(*line); @@ -738,65 +738,106 @@ extern "C" { f_status_t fss_basic_list_read_process_total(fll_program_data_t * const main, fss_basic_list_read_data_t * const data, bool names[]) { f_array_length_t total = 0; - f_string_range_t range = f_string_range_t_initialize; - f_array_length_t i = 0; - f_array_length_t j = 0; + f_array_length_t at = 0; - for (f_array_length_t at = 0; at < data->contents.used; ++at) { + if (data->option & fss_basic_list_read_data_option_content_d) { + f_array_length_t i = 0; + f_array_length_t j = 0; + f_array_length_t k = 0; - if (!names[at]) continue; + f_string_range_t range = f_string_range_t_initialize; - if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { - if (fll_program_standard_signal_received(main)) { - fss_basic_list_read_print_signal_received(main); + for (; at < data->contents.used; ++at) { - return F_status_set_error(F_interrupt); - } + if (!names[at]) continue; - main->signal_check = 0; - } + if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_read_print_signal_received(main); - if (data->option & fss_basic_list_read_data_option_object_d) { - ++total; - } + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; + } + + if (data->option & fss_basic_list_read_data_option_at_d) { + if (data->depths.array[0].value_at != at) continue; + } - // 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; + if (data->option & fss_basic_list_read_data_option_object_d) { + ++total; - range.start = data->contents.array[at].array[0].start; - range.stop = data->contents.array[at].array[0].stop; + if (!(data->option & fss_basic_list_read_data_option_content_d)) continue; + } - // 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 (data->option & fss_basic_list_read_data_option_content_d) { + if (!data->contents.array[at].used) continue; - for (i = range.start; i <= range.stop; ++i) { + for (i = 0; i < data->contents.array[at].used; ++i) { - if (j < data->comments.used) { - while (j < data->comments.used && data->comments.array[j].stop < i) ++j; + if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_read_print_signal_received(main); - if (j < data->comments.used && i >= data->comments.array[j].start && i <= data->comments.array[j].stop) { - i = data->comments.array[j++].stop; + return F_status_set_error(F_interrupt); + } - continue; + main->signal_check = 0; } - } - if (data->buffer.string[i] == f_string_eol_s.string[0]) { - range.start = i + 1; + range.start = data->contents.array[at].array[i].start; + range.stop = data->contents.array[at].array[i].stop; - if (i <= range.stop) { - ++total; - } + // 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; + + for (j = range.start; j <= range.stop; ++j) { + + if (k < data->comments.used) { + while (k < data->comments.used && data->comments.array[k].stop < j) ++k; + + if (k < data->comments.used) { + if (j >= data->comments.array[k].start && j <= data->comments.array[k].stop) { + j = data->comments.array[k++].stop; + + continue; + } + } + } + + if (data->buffer.string[j] == f_string_eol_s.string[0]) ++total; + } // for + } // for + } + } // for + } + else { + for (; at < data->objects.used; ++at) { + + if (!names[at]) continue; + + if (!((++main->signal_check) % fss_basic_list_read_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_list_read_print_signal_received(main); + + return F_status_set_error(F_interrupt); } - } // 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]) { - ++total; + main->signal_check = 0; } - } - } // for + + if (data->option & fss_basic_list_read_data_option_at_d) { + if (data->depths.array[0].value_at != at) continue; + } + + if (!(data->option & fss_basic_list_read_data_option_object_d) && (data->option & fss_basic_list_read_data_option_content_d)) { + if (!(data->contents.array[at].used || (data->option & fss_basic_list_read_data_option_empty_d))) continue; + } + + ++total; + } // for + } flockfile(main->output.to.stream); diff --git a/level_3/fss_basic_read/c/private-common.h b/level_3/fss_basic_read/c/private-common.h index 225f6ef..ee21122 100644 --- a/level_3/fss_basic_read/c/private-common.h +++ b/level_3/fss_basic_read/c/private-common.h @@ -137,43 +137,45 @@ extern "C" { * The data structure for FSS Basic Read. * * fss_basic_read_data_option_*: - * - at: The object at the given position is being selected (Think of this as select a row for some Object). - * - columns: The total columns found and selected is printed instead of the Content. - * - content: The Content is to be printed. - * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). - * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). - * - name: A specific Object name has been requested. - * - object: The Object is to be printed. - * - original: Enable original printing, where the quotes are printed and no delimits are applied. - * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). - * - total: The total lines found and selected is printed instead of the Content. - * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). + * - at: The object at the given position is being selected (Think of this as select a row for some Object). + * - columns: The total columns found and selected is printed instead of the Content. + * - content: The Content is to be printed. + * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). + * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). + * - name: A specific Object name has been requested. + * - object: The Object is to be printed. + * - original: Enable original printing, where the quotes are printed and no delimits are applied. + * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). + * - select_content: A helper flag representing select and content flag bits being set. + * - total: The total lines found and selected is printed instead of the Content. + * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). * - * argv: The argument structure in the progam data parameters for simplifying syntax. - * options: Bitwise flags representing parameters. - * delimit_mode: The delimit mode. - * delimit_depth: The delimit depth. - * select: The Content to select (column number). - * line: The Content to select (row number). - * files: A statically allocated array of files for designating where in the buffer a file is represented. - * depths: The array of parameters for each given depth. - * buffer: The buffer containing all loaded files (and STDIN pipe). - * objects: The positions within the buffer representing Objects. - * contents: The positions within the buffer representing Contents. - * delimits: The positions within the buffer representing character delimits. + * argv: The argument structure in the progam data parameters for simplifying syntax. + * options: Bitwise flags representing parameters. + * delimit_mode: The delimit mode. + * delimit_depth: The delimit depth. + * select: The Content to select (column number). + * line: The Content to select (row number). + * files: A statically allocated array of files for designating where in the buffer a file is represented. + * depths: The array of parameters for each given depth. + * buffer: The buffer containing all loaded files (and STDIN pipe). + * objects: The positions within the buffer representing Objects. + * contents: The positions within the buffer representing Contents. + * delimits: The positions within the buffer representing character delimits. */ #ifndef _di_fss_basic_read_data_t_ - #define fss_basic_read_data_option_at_d 0x1 - #define fss_basic_read_data_option_columns_d 0x2 - #define fss_basic_read_data_option_content_d 0x4 - #define fss_basic_read_data_option_empty_d 0x8 - #define fss_basic_read_data_option_line_d 0x10 - #define fss_basic_read_data_option_name_d 0x20 - #define fss_basic_read_data_option_object_d 0x40 - #define fss_basic_read_data_option_original_d 0x80 - #define fss_basic_read_data_option_select_d 0x100 - #define fss_basic_read_data_option_total_d 0x200 - #define fss_basic_read_data_option_trim_d 0x400 + #define fss_basic_read_data_option_at_d 0x1 + #define fss_basic_read_data_option_columns_d 0x2 + #define fss_basic_read_data_option_content_d 0x4 + #define fss_basic_read_data_option_empty_d 0x8 + #define fss_basic_read_data_option_line_d 0x10 + #define fss_basic_read_data_option_name_d 0x20 + #define fss_basic_read_data_option_object_d 0x40 + #define fss_basic_read_data_option_original_d 0x80 + #define fss_basic_read_data_option_select_d 0x100 + #define fss_basic_read_data_option_select_content_d 0x104 + #define fss_basic_read_data_option_total_d 0x200 + #define fss_basic_read_data_option_trim_d 0x400 typedef struct { uint16_t option; diff --git a/level_3/fss_basic_read/c/private-read.c b/level_3/fss_basic_read/c/private-read.c index 6f3830f..a9cf4f9 100644 --- a/level_3/fss_basic_read/c/private-read.c +++ b/level_3/fss_basic_read/c/private-read.c @@ -256,7 +256,7 @@ extern "C" { #endif // _di_fss_basic_read_load_ #ifndef _di_fss_basic_read_load_number_ - f_status_t fss_basic_read_load_number(fll_program_data_t * const main, fss_basic_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { + f_status_t fss_basic_read_load_number(fll_program_data_t * const main, fss_basic_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_array_length_t *number) { if (main->parameters.array[parameter].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; @@ -636,27 +636,62 @@ extern "C" { f_array_length_t total = 0; f_array_length_t i = 0; - if (data->option & fss_basic_read_data_option_select_d) { - if (!data->select) { - for (; i < data->contents.used; ++i) { + if ((data->option & fss_basic_read_data_option_select_content_d) == fss_basic_read_data_option_select_content_d) { + for (; i < data->contents.used; ++i) { - if (!names[i]) continue; + if (!names[i]) continue; - if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { - if (fll_program_standard_signal_received(main)) { - fss_basic_read_print_signal_received(main); + if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_read_print_signal_received(main); - return F_status_set_error(F_interrupt); - } + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; + } - main->signal_check = 0; + if (data->contents.array[i].used) { + if (data->select < data->contents.array[i].used) { + if ((data->option & fss_basic_read_data_option_empty_d) || data->contents.array[i].array[data->select].start <= data->contents.array[i].array[data->select].stop) { + ++total; + } } + } + else if (!data->select && (data->option & fss_basic_read_data_option_empty_d)) { + ++total; + } + } // for + } + else if (data->option & fss_basic_read_data_option_at_d) { + for (f_array_length_t at = 0; i < data->objects.used; ++i) { - if ((data->option & fss_basic_read_data_option_empty_d) || data->contents.array[i].used && data->contents.array[i].array[0].start <= data->contents.array[i].array[0].stop) { - ++total; + if (!names[i]) continue; + + if (!((++main->signal_check) % fss_basic_read_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_basic_read_print_signal_received(main); + + return F_status_set_error(F_interrupt); } - } // for - } + + main->signal_check = 0; + } + + if (at < data->depths.array[0].value_at) { + ++at; + + continue; + } + + if (!(data->option & fss_basic_read_data_option_object_d) && (data->option & fss_basic_read_data_option_content_d)) { + if (!(data->contents.array[i].used || (data->option & fss_basic_read_data_option_empty_d))) continue; + } + + total = 1; + + break; + } // for } else { for (; i < data->objects.used; ++i) { @@ -673,10 +708,8 @@ extern "C" { main->signal_check = 0; } - if (!(data->option & fss_basic_read_data_option_object_d) && data->option & fss_basic_read_data_option_content_d) { - if (!(data->contents.array[i].used || (data->option & fss_basic_read_data_option_empty_d))) { - continue; - } + if (!(data->option & fss_basic_read_data_option_object_d) && (data->option & fss_basic_read_data_option_content_d)) { + if (!(data->contents.array[i].used || (data->option & fss_basic_read_data_option_empty_d))) continue; } ++total; diff --git a/level_3/fss_basic_read/tests/runtime/fss_0000/expect/test-0001-unicode-object-name-hi-select-0-total.expect b/level_3/fss_basic_read/tests/runtime/fss_0000/expect/test-0001-unicode-object-name-hi-select-0-total.expect index 573541a..d00491f 100644 --- a/level_3/fss_basic_read/tests/runtime/fss_0000/expect/test-0001-unicode-object-name-hi-select-0-total.expect +++ b/level_3/fss_basic_read/tests/runtime/fss_0000/expect/test-0001-unicode-object-name-hi-select-0-total.expect @@ -1 +1 @@ -0 +1 diff --git a/level_3/fss_extended_list_read/c/private-common.h b/level_3/fss_extended_list_read/c/private-common.h index 205e1cf..dbcf096 100644 --- a/level_3/fss_extended_list_read/c/private-common.h +++ b/level_3/fss_extended_list_read/c/private-common.h @@ -138,17 +138,18 @@ extern "C" { * The data structure for FSS Basic Read. * * fss_extended_list_read_data_option_*: - * - at: The object at the given position is being selected (Think of this as select a row for some Object). - * - columns: The total columns found and selected is printed instead of the Content. - * - content: The Content is to be printed. - * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). - * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). - * - name: A specific Object name has been requested. - * - object: The Object is to be printed. - * - original: Enable original printing, where the quotes are printed and no delimits are applied. - * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). - * - total: The total lines found and selected is printed instead of the Content. - * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). + * - at: The object at the given position is being selected (Think of this as select a row for some Object). + * - columns: The total columns found and selected is printed instead of the Content. + * - content: The Content is to be printed. + * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). + * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). + * - name: A specific Object name has been requested. + * - object: The Object is to be printed. + * - original: Enable original printing, where the quotes are printed and no delimits are applied. + * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). + * - select_content: A helper flag representing select and content flag bits being set. + * - total: The total lines found and selected is printed instead of the Content. + * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). * * argv: The argument structure in the progam data parameters for simplifying syntax. * options: Bitwise flags representing parameters. @@ -165,17 +166,18 @@ extern "C" { * delimits_content: The positions within the buffer representing Content character delimits. */ #ifndef _di_fss_extended_list_read_data_t_ - #define fss_extended_list_read_data_option_at_d 0x1 - #define fss_extended_list_read_data_option_columns_d 0x2 - #define fss_extended_list_read_data_option_content_d 0x4 - #define fss_extended_list_read_data_option_empty_d 0x8 - #define fss_extended_list_read_data_option_line_d 0x10 - #define fss_extended_list_read_data_option_name_d 0x20 - #define fss_extended_list_read_data_option_object_d 0x40 - #define fss_extended_list_read_data_option_original_d 0x80 - #define fss_extended_list_read_data_option_select_d 0x100 - #define fss_extended_list_read_data_option_total_d 0x200 - #define fss_extended_list_read_data_option_trim_d 0x400 + #define fss_extended_list_read_data_option_at_d 0x1 + #define fss_extended_list_read_data_option_columns_d 0x2 + #define fss_extended_list_read_data_option_content_d 0x4 + #define fss_extended_list_read_data_option_empty_d 0x8 + #define fss_extended_list_read_data_option_line_d 0x10 + #define fss_extended_list_read_data_option_name_d 0x20 + #define fss_extended_list_read_data_option_object_d 0x40 + #define fss_extended_list_read_data_option_original_d 0x80 + #define fss_extended_list_read_data_option_select_d 0x100 + #define fss_extended_list_read_data_option_select_content_d 0x104 + #define fss_extended_list_read_data_option_total_d 0x200 + #define fss_extended_list_read_data_option_trim_d 0x400 typedef struct { uint16_t option; 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 6669e95..a694142 100644 --- a/level_3/fss_extended_list_read/c/private-read.c +++ b/level_3/fss_extended_list_read/c/private-read.c @@ -272,7 +272,7 @@ extern "C" { #endif // _di_fss_extended_list_read_load_ #ifndef _di_fss_extended_list_read_load_number_ - f_status_t fss_extended_list_read_load_number(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { + f_status_t fss_extended_list_read_load_number(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_array_length_t *number) { if (main->parameters.array[parameter].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; @@ -547,7 +547,7 @@ extern "C" { } } // for - // If Content does not end with a newline, it still must be treated as the last line. + // Treat Content as the last line even if it does not end with a new line. if (data->buffer.string[range.stop] != f_string_eol_s.string[0]) { ++(*line); @@ -752,61 +752,110 @@ extern "C" { f_status_t fss_extended_list_read_process_total(fll_program_data_t * const main, fss_extended_list_read_data_t * const data, bool names[]) { f_array_length_t total = 0; - f_string_range_t range = f_string_range_t_initialize; - f_array_length_t i = 0; - f_array_length_t j = 0; + f_array_length_t at = 0; - for (f_array_length_t at = 0; at < data->contents.used; ++at) { + if (data->option & fss_extended_list_read_data_option_content_d) { + f_array_length_t i = 0; + f_array_length_t j = 0; + f_array_length_t k = 0; - if (!names[at]) continue; + f_string_range_t range = f_string_range_t_initialize; - if (data->option & fss_extended_list_read_data_option_object_d) { - ++total; + for (; at < data->contents.used; ++at) { - // Include the closing brace in the total count. - if (data->option & fss_extended_list_read_data_option_content_d) { - ++total; + if (!names[at]) continue; + + if (!((++main->signal_check) % fss_extended_list_read_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_list_read_print_signal_received(main); + + return F_status_set_error(F_interrupt); + } + + main->signal_check = 0; } - } - // There is only a single Content column for this standard. - if (data->option & fss_extended_list_read_data_option_content_d) { + if (data->option & fss_extended_list_read_data_option_at_d) { + if (data->depths.array[0].value_at != at) continue; + } - if (!data->contents.array[at].used) continue; + if (data->option & fss_extended_list_read_data_option_object_d) { + ++total; - range.start = data->contents.array[at].array[0].start; - range.stop = data->contents.array[at].array[0].stop; + if (!(data->option & fss_extended_list_read_data_option_content_d)) continue; + } - // 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 (data->option & fss_extended_list_read_data_option_content_d) { + if (!data->contents.array[at].used) continue; - for (i = range.start; i <= range.stop; ++i) { + for (i = 0; i < data->contents.array[at].used; ++i) { - if (j < data->comments.used) { - while (j < data->comments.used && data->comments.array[j].stop < i) ++j; + if (!((++main->signal_check) % fss_extended_list_read_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_list_read_print_signal_received(main); - if (j < data->comments.used && i >= data->comments.array[j].start && i <= data->comments.array[j].stop) { - i = data->comments.array[j++].stop; + return F_status_set_error(F_interrupt); + } - continue; + main->signal_check = 0; } + + range.start = data->contents.array[at].array[i].start; + range.stop = data->contents.array[at].array[i].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; + + for (j = range.start; j <= range.stop; ++j) { + + if (k < data->comments.used) { + while (k < data->comments.used && data->comments.array[k].stop < j) ++k; + + if (k < data->comments.used) { + if (j >= data->comments.array[k].start && j <= data->comments.array[k].stop) { + j = data->comments.array[k++].stop; + + continue; + } + } + } + + if (data->buffer.string[j] == f_string_eol_s.string[0]) ++total; + } // for + } // for + + if (data->option & fss_extended_list_read_data_option_object_d) { + ++total; } + } + } // for + } + else { + for (; at < data->objects.used; ++at) { - if (data->buffer.string[i] == f_string_eol_s.string[0]) { - range.start = i + 1; + if (!names[at]) continue; - if (i <= range.stop) { - ++total; - } + if (!((++main->signal_check) % fss_extended_list_read_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_list_read_print_signal_received(main); + + return F_status_set_error(F_interrupt); } - } // 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]) { - ++total; + main->signal_check = 0; } - } - } // for + + if (data->option & fss_extended_list_read_data_option_at_d) { + if (data->depths.array[0].value_at != at) continue; + } + + if (!(data->option & fss_extended_list_read_data_option_object_d) && (data->option & fss_extended_list_read_data_option_content_d)) { + if (!(data->contents.array[at].used || (data->option & fss_extended_list_read_data_option_empty_d))) continue; + } + + ++total; + } // for + } flockfile(main->output.to.stream); diff --git a/level_3/fss_extended_read/c/private-common.h b/level_3/fss_extended_read/c/private-common.h index bb70958..8474a12 100644 --- a/level_3/fss_extended_read/c/private-common.h +++ b/level_3/fss_extended_read/c/private-common.h @@ -137,17 +137,18 @@ extern "C" { * The data structure for FSS Basic Read. * * fss_extended_read_data_option_*: - * - at: The object at the given position is being selected (Think of this as select a row for some Object). - * - columns: The total columns found and selected is printed instead of the Content. - * - content: The Content is to be printed. - * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). - * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). - * - name: A specific Object name has been requested. - * - object: The Object is to be printed. - * - original: Enable original printing, where the quotes are printed and no delimits are applied. - * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). - * - total: The total lines found and selected is printed instead of the Content. - * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). + * - at: The object at the given position is being selected (Think of this as select a row for some Object). + * - columns: The total columns found and selected is printed instead of the Content. + * - content: The Content is to be printed. + * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). + * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). + * - name: A specific Object name has been requested. + * - object: The Object is to be printed. + * - original: Enable original printing, where the quotes are printed and no delimits are applied. + * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). + * - select_content: A helper flag representing select and content flag bits being set. + * - total: The total lines found and selected is printed instead of the Content. + * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). * * argv: The argument structure in the progam data parameters for simplifying syntax. * options: Bitwise flags representing parameters. @@ -164,17 +165,18 @@ extern "C" { * delimits_content: The positions within the buffer representing Content character delimits. */ #ifndef _di_fss_extended_read_data_t_ - #define fss_extended_read_data_option_at_d 0x1 - #define fss_extended_read_data_option_columns_d 0x2 - #define fss_extended_read_data_option_content_d 0x4 - #define fss_extended_read_data_option_empty_d 0x8 - #define fss_extended_read_data_option_line_d 0x10 - #define fss_extended_read_data_option_name_d 0x20 - #define fss_extended_read_data_option_object_d 0x40 - #define fss_extended_read_data_option_original_d 0x80 - #define fss_extended_read_data_option_select_d 0x100 - #define fss_extended_read_data_option_total_d 0x200 - #define fss_extended_read_data_option_trim_d 0x400 + #define fss_extended_read_data_option_at_d 0x1 + #define fss_extended_read_data_option_columns_d 0x2 + #define fss_extended_read_data_option_content_d 0x4 + #define fss_extended_read_data_option_empty_d 0x8 + #define fss_extended_read_data_option_line_d 0x10 + #define fss_extended_read_data_option_name_d 0x20 + #define fss_extended_read_data_option_object_d 0x40 + #define fss_extended_read_data_option_original_d 0x80 + #define fss_extended_read_data_option_select_d 0x100 + #define fss_extended_read_data_option_select_content_d 0x104 + #define fss_extended_read_data_option_total_d 0x200 + #define fss_extended_read_data_option_trim_d 0x400 typedef struct { uint16_t option; diff --git a/level_3/fss_extended_read/c/private-read.c b/level_3/fss_extended_read/c/private-read.c index fd98325..12883ea 100644 --- a/level_3/fss_extended_read/c/private-read.c +++ b/level_3/fss_extended_read/c/private-read.c @@ -278,7 +278,7 @@ extern "C" { #endif // _di_fss_extended_read_load_ #ifndef _di_fss_extended_read_load_number_ - f_status_t fss_extended_read_load_number(fll_program_data_t * const main, fss_extended_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { + f_status_t fss_extended_read_load_number(fll_program_data_t * const main, fss_extended_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_array_length_t *number) { if (main->parameters.array[parameter].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; @@ -668,7 +668,7 @@ extern "C" { f_array_length_t total = 0; f_array_length_t i = 0; - if (data->option & fss_extended_read_data_option_select_d) { + if ((data->option & fss_extended_read_data_option_select_content_d) == fss_extended_read_data_option_select_content_d) { for (; i < data->contents.used; ++i) { if (!names[i]) continue; @@ -695,72 +695,57 @@ extern "C" { } } // for } - else { - - // This standard only has one Content per line, however it has multiple Contents within that line. - if ((data->option & fss_extended_read_data_option_object_d) || (data->option & fss_extended_read_data_option_content_d) && (data->option & fss_extended_read_data_option_empty_d)) { - for (; i < data->objects.used; ++i) { - - if (!names[i]) continue; + else if (data->option & fss_extended_read_data_option_at_d) { + for (f_array_length_t at = 0; i < data->objects.used; ++i) { - if (!((++main->signal_check) % fss_extended_read_signal_check_d)) { - if (fll_program_standard_signal_received(main)) { - fss_extended_read_print_signal_received(main); + if (!names[i]) continue; - return F_status_set_error(F_interrupt); - } + if (!((++main->signal_check) % fss_extended_read_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_read_print_signal_received(main); - main->signal_check = 0; + return F_status_set_error(F_interrupt); } - ++total; - } // for - } - else { - for (f_array_length_t j = 0; i < data->contents.used; ++i) { + main->signal_check = 0; + } - if (!names[i]) continue; - if (!data->contents.array[i].used) continue; + if (at < data->depths.array[0].value_at) { + ++at; - if (!((++main->signal_check) % fss_extended_read_signal_check_d)) { - if (fll_program_standard_signal_received(main)) { - fss_extended_read_print_signal_received(main); + continue; + } - return F_status_set_error(F_interrupt); - } + if (!(data->option & fss_extended_read_data_option_object_d) && (data->option & fss_extended_read_data_option_content_d)) { + if (!(data->contents.array[i].used || (data->option & fss_extended_read_data_option_empty_d))) continue; + } - main->signal_check = 0; - } + total = 1; - if (data->option & fss_extended_read_data_option_select_d) { - if (data->select < data->contents.array[i].used) { - if (data->contents.array[i].array[data->select].start <= data->contents.array[data->select].array[j].stop) { - ++total; - } - } - } - else { - for (j = 0; j < data->contents.array[i].used; ++j) { + break; + } // for + } + else { + for (; i < data->objects.used; ++i) { + + if (!names[i]) continue; - if (!((++main->signal_check) % fss_extended_read_signal_check_d)) { - if (fll_program_standard_signal_received(main)) { - fss_extended_read_print_signal_received(main); + if (!((++main->signal_check) % fss_extended_read_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_extended_read_print_signal_received(main); - return F_status_set_error(F_interrupt); - } + return F_status_set_error(F_interrupt); + } - main->signal_check = 0; - } + main->signal_check = 0; + } - if (data->contents.array[i].array[j].start <= data->contents.array[i].array[j].stop) { - ++total; + if (!(data->option & fss_extended_read_data_option_object_d) && (data->option & fss_extended_read_data_option_content_d)) { + if (!(data->contents.array[i].used || (data->option & fss_extended_read_data_option_empty_d))) continue; + } - break; - } - } // for - } - } // for - } + ++total; + } // for } flockfile(main->output.to.stream); diff --git a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name--select-1-total.expect b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name--select-1-total.expect index d00491f..0cfbf08 100644 --- a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name--select-1-total.expect +++ b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name--select-1-total.expect @@ -1 +1 @@ -1 +2 diff --git a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-100-total.expect b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-100-total.expect index 573541a..00750ed 100644 --- a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-100-total.expect +++ b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-100-total.expect @@ -1 +1 @@ -0 +3 diff --git a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-2-total.expect b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-2-total.expect index 0cfbf08..00750ed 100644 --- a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-2-total.expect +++ b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-2-total.expect @@ -1 +1 @@ -2 +3 diff --git a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-5-total.expect b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-5-total.expect index 573541a..00750ed 100644 --- a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-5-total.expect +++ b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-5-total.expect @@ -1 +1 @@ -0 +3 diff --git a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-6-total.expect b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-6-total.expect index 573541a..00750ed 100644 --- a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-6-total.expect +++ b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0000-quotes_and_escapes-object-name-a-select-6-total.expect @@ -1 +1 @@ -0 +3 diff --git a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-100-total.expect b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-100-total.expect index 573541a..b8626c4 100644 --- a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-100-total.expect +++ b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-100-total.expect @@ -1 +1 @@ -0 +4 diff --git a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-2-total.expect b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-2-total.expect index 00750ed..b8626c4 100644 --- a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-2-total.expect +++ b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-2-total.expect @@ -1 +1 @@ -3 +4 diff --git a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-5-total.expect b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-5-total.expect index d00491f..b8626c4 100644 --- a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-5-total.expect +++ b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-5-total.expect @@ -1 +1 @@ -1 +4 diff --git a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-6-total.expect b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-6-total.expect index 573541a..b8626c4 100644 --- a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-6-total.expect +++ b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-a-select-6-total.expect @@ -1 +1 @@ -0 +4 diff --git a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-hi-select-0-total.expect b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-hi-select-0-total.expect index 573541a..d00491f 100644 --- a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-hi-select-0-total.expect +++ b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-hi-select-0-total.expect @@ -1 +1 @@ -0 +1 diff --git a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-hi-select-1-empty-total.expect b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-hi-select-1-empty-total.expect index 573541a..d00491f 100644 --- a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-hi-select-1-empty-total.expect +++ b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-hi-select-1-empty-total.expect @@ -1 +1 @@ -0 +1 diff --git a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-hi-select-1-total.expect b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-hi-select-1-total.expect index 573541a..d00491f 100644 --- a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-hi-select-1-total.expect +++ b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-hi-select-1-total.expect @@ -1 +1 @@ -0 +1 diff --git "a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-\320\274\320\270\321\200-select-1-total.expect" "b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-\320\274\320\270\321\200-select-1-total.expect" index 573541a..d00491f 100644 --- "a/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-\320\274\320\270\321\200-select-1-total.expect" +++ "b/level_3/fss_extended_read/tests/runtime/fss_0001/expect/test-0001-unicode-object-name-\320\274\320\270\321\200-select-1-total.expect" @@ -1 +1 @@ -0 +1 diff --git a/level_3/fss_payload_read/c/private-common.h b/level_3/fss_payload_read/c/private-common.h index 27df608..816bf12 100644 --- a/level_3/fss_payload_read/c/private-common.h +++ b/level_3/fss_payload_read/c/private-common.h @@ -137,18 +137,19 @@ extern "C" { * The data structure for FSS Basic Read. * * fss_payload_read_data_option_*: - * - at: The object at the given position is being selected (Think of this as select a row for some Object). - * - columns: The total columns found and selected is printed instead of the Content. - * - content: The Content is to be printed. - * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). - * - extended: Based on the depth, the extended list is to be processed. - * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). - * - name: A specific Object name has been requested. - * - object: The Object is to be printed. - * - original: Enable original printing, where the quotes are printed and no delimits are applied. - * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). - * - total: The total lines found and selected is printed instead of the Content. - * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). + * - at: The object at the given position is being selected (Think of this as select a row for some Object). + * - columns: The total columns found and selected is printed instead of the Content. + * - content: The Content is to be printed. + * - empty: Empty Content will be printed (Objects that have no Content will have their empty Content printed). + * - extended: Based on the depth, the extended list is to be processed. + * - line: A specific Content at a given line is to be selected (Think of this as select a row for some Content). + * - name: A specific Object name has been requested. + * - object: The Object is to be printed. + * - original: Enable original printing, where the quotes are printed and no delimits are applied. + * - select: A specific Content at a given position is to be selected (Think of this as select a column for some Content). + * - select_content: A helper flag representing select and content flag bits being set. + * - total: The total lines found and selected is printed instead of the Content. + * - trim: Empty space before and after Objects and Content will not be printed (They will be trimmed). * * argv: The argument structure in the progam data parameters for simplifying syntax. * options: Bitwise flags representing parameters. @@ -169,18 +170,19 @@ extern "C" { * delimits_content_header: The positions within the buffer representing header Content character delimits. */ #ifndef _di_fss_payload_read_data_t_ - #define fss_payload_read_data_option_at_d 0x1 - #define fss_payload_read_data_option_columns_d 0x2 - #define fss_payload_read_data_option_content_d 0x4 - #define fss_payload_read_data_option_empty_d 0x8 - #define fss_payload_read_data_option_extended_d 0x10 - #define fss_payload_read_data_option_line_d 0x20 - #define fss_payload_read_data_option_name_d 0x40 - #define fss_payload_read_data_option_object_d 0x80 - #define fss_payload_read_data_option_original_d 0x100 - #define fss_payload_read_data_option_select_d 0x200 - #define fss_payload_read_data_option_total_d 0x400 - #define fss_payload_read_data_option_trim_d 0x800 + #define fss_payload_read_data_option_at_d 0x1 + #define fss_payload_read_data_option_columns_d 0x2 + #define fss_payload_read_data_option_content_d 0x4 + #define fss_payload_read_data_option_empty_d 0x8 + #define fss_payload_read_data_option_extended_d 0x10 + #define fss_payload_read_data_option_line_d 0x20 + #define fss_payload_read_data_option_name_d 0x40 + #define fss_payload_read_data_option_object_d 0x80 + #define fss_payload_read_data_option_original_d 0x100 + #define fss_payload_read_data_option_select_d 0x200 + #define fss_payload_read_data_option_select_content_d 0x204 + #define fss_payload_read_data_option_total_d 0x400 + #define fss_payload_read_data_option_trim_d 0x800 typedef struct { uint16_t option; diff --git a/level_3/fss_payload_read/c/private-read.c b/level_3/fss_payload_read/c/private-read.c index 7926f09..f47027b 100644 --- a/level_3/fss_payload_read/c/private-read.c +++ b/level_3/fss_payload_read/c/private-read.c @@ -305,7 +305,7 @@ extern "C" { #endif // _di_fss_payload_read_load_ #ifndef _di_fss_payload_read_load_number_ - f_status_t fss_payload_read_load_number(fll_program_data_t * const main, fss_payload_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_number_unsigned_t *number) { + f_status_t fss_payload_read_load_number(fll_program_data_t * const main, fss_payload_read_data_t * const data, const f_array_length_t parameter, const f_string_static_t name, f_array_length_t *number) { if (main->parameters.array[parameter].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[parameter].values.array[main->parameters.array[parameter].values.used - 1]; @@ -769,7 +769,7 @@ extern "C" { } } // for - // If Content does not end with a newline, it still must be treated as the last line. + // Treat Content as the last line even if it does not end with a new line. if (data->buffer.string[range.stop] != f_string_eol_s.string[0]) { ++(*line); @@ -1084,66 +1084,170 @@ extern "C" { f_status_t fss_payload_read_process_total(fll_program_data_t * const main, fss_payload_read_data_t * const data, bool names[]) { f_array_length_t total = 0; - f_string_range_t range = f_string_range_t_initialize; - f_array_length_t i = 0; - f_array_length_t j = 0; + f_array_length_t at = 0; - for (f_array_length_t at = 0; at < data->contents.used; ++at) { + if (data->option & fss_payload_read_data_option_content_d) { + f_array_length_t i = 0; + f_array_length_t j = 0; + f_array_length_t k = 0; - if (!names[at]) continue; + f_string_range_t range = f_string_range_t_initialize; - if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { - if (fll_program_standard_signal_received(main)) { - fss_payload_read_print_signal_received(main); + for (; at < data->contents.used; ++at) { - return F_status_set_error(F_interrupt); - } + if (!names[at]) continue; - main->signal_check = 0; - } + if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_read_print_signal_received(main); - if (data->option & fss_payload_read_data_option_object_d) { - ++total; - } + return F_status_set_error(F_interrupt); + } - // 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; + main->signal_check = 0; + } + + if (data->option & fss_payload_read_data_option_at_d) { + if (data->depths.array[0].value_at != at) continue; + } - range.start = data->contents.array[at].array[0].start; - range.stop = data->contents.array[at].array[0].stop; + if (data->option & fss_payload_read_data_option_object_d) { + ++total; + + if (!(data->option & fss_payload_read_data_option_content_d)) continue; + } - // 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 (data->option & fss_payload_read_data_option_content_d) { + if (!data->contents.array[at].used) continue; - for (i = range.start; i <= range.stop; ++i) { + for (i = 0; i < data->contents.array[at].used; ++i) { - if (j < data->comments.used) { - while (j < data->comments.used && data->comments.array[j].stop < i) ++j; + if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_read_print_signal_received(main); - if (j < data->comments.used && i >= data->comments.array[j].start && i <= data->comments.array[j].stop) { - i = data->comments.array[j++].stop; + return F_status_set_error(F_interrupt); + } - continue; + main->signal_check = 0; } + + range.start = data->contents.array[at].array[i].start; + range.stop = data->contents.array[at].array[i].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; + + for (j = range.start; j <= range.stop; ++j) { + + if (k < data->comments.used) { + while (k < data->comments.used && data->comments.array[k].stop < j) ++k; + + if (k < data->comments.used) { + if (j >= data->comments.array[k].start && j <= data->comments.array[k].stop) { + j = data->comments.array[k++].stop; + + continue; + } + } + } + + if (data->buffer.string[j] == f_string_eol_s.string[0]) ++total; + } // for + } // for + } + } // for + } + else { + for (; at < data->objects.used; ++at) { + + if (!names[at]) continue; + + if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_read_print_signal_received(main); + + return F_status_set_error(F_interrupt); } - if (data->buffer.string[i] == f_string_eol_s.string[0]) { - range.start = i + 1; + main->signal_check = 0; + } - if (i <= range.stop) { - ++total; - } + if (data->option & fss_payload_read_data_option_at_d) { + if (data->depths.array[0].value_at != at) continue; + } + + if (!(data->option & fss_payload_read_data_option_object_d) && (data->option & fss_payload_read_data_option_content_d)) { + if (!(data->contents.array[at].used || (data->option & fss_payload_read_data_option_empty_d))) continue; + } + + ++total; + } // for + } +/* + f_array_length_t total = 0; + f_string_range_t range = f_string_range_t_initialize; + f_array_length_t i = 0; + f_array_length_t j = 0; + + if ((data->option & fss_payload_read_data_option_select_content_d) == fss_payload_read_data_option_select_content_d) { + for (f_array_length_t at = 0; at < data->contents.used; ++at) { + + if (!names[at]) continue; + + if (!((++main->signal_check) % fss_payload_read_signal_check_d)) { + if (fll_program_standard_signal_received(main)) { + fss_payload_read_print_signal_received(main); + + return F_status_set_error(F_interrupt); } - } // 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]) { + main->signal_check = 0; + } + + if (data->option & fss_payload_read_data_option_object_d) { ++total; } - } - } // for + // 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; + + for (i = range.start; i <= range.stop; ++i) { + + if (j < data->comments.used) { + while (j < data->comments.used && data->comments.array[j].stop < i) ++j; + + if (j < data->comments.used && i >= data->comments.array[j].start && i <= data->comments.array[j].stop) { + i = data->comments.array[j++].stop; + + continue; + } + } + + if (data->buffer.string[i] == f_string_eol_s.string[0]) { + range.start = i + 1; + + if (i <= range.stop) { + ++total; + } + } + } // for + + // Treat Content as the last line even if it does not end with a new line. + if (data->buffer.string[range.stop] != f_string_eol_s.string[0]) { + ++total; + } + } + } // for + } +*/ flockfile(main->output.to.stream); if (data->option & fss_payload_read_data_option_line_d) {