From: Kevin Day Date: Sat, 16 Nov 2019 20:50:58 +0000 (-0600) Subject: Update: --name and --at in combination should process '--at' relative to '--name' X-Git-Tag: 0.5.0~381 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=61bfe4b40506a8356d3b3279e57d69bab57d6010;p=fll Update: --name and --at in combination should process '--at' relative to '--name' This logic is already done with --line and other parameters. Doing this same thing with --name and --at makes the code/logic more consistent and reasonable. --- diff --git a/level_3/fss_basic_list_read/c/fss_basic_list_read.c b/level_3/fss_basic_list_read/c/fss_basic_list_read.c index fc41070..49c97ab 100644 --- a/level_3/fss_basic_list_read/c/fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/fss_basic_list_read.c @@ -79,6 +79,18 @@ extern "C" { printf("%c", f_string_eol); + printf(" When both "); + fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_list_read_long_at); + printf(" and "); + fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_list_read_long_name); + printf(" parameters are specified (at the same depth), the "); + fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_list_read_long_at); + printf(" parameter value will be treated as a position relative to the specified "); + fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_list_read_long_name); + printf(" parameter value.%c", f_string_eol); + + printf("%c", f_string_eol); + printf(" This program may support parameters, such as "); fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_list_read_long_depth); printf(" or "); diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c index 0ae20df..2d77d0a 100644 --- a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c @@ -391,10 +391,20 @@ extern "C" { } if (depths.array[0].index_at > 0) { - if (depths.array[0].value_at < data->objects.used && names[depths.array[0].value_at]) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[depths.array[0].value_at]); - fprintf(f_standard_output, "%c", f_string_eol); - } + f_array_length at = 0; + f_array_length i = 0; + + for (; i < data->objects.used; i++) { + if (names[i]) { + if (at == depths.array[0].value_at) { + f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[i]); + fprintf(f_standard_output, "%c", f_string_eol); + break; + } + + at++; + } + } // for return f_none; } @@ -410,84 +420,106 @@ extern "C" { } if (depths.array[0].index_at > 0) { - if (names[depths.array[0].value_at]) { - if (depths.array[0].value_at >= data->objects.used) { - if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) { - fprintf(f_standard_output, "0%c", f_string_eol); - } - - return f_none; + if (depths.array[0].value_at >= data->objects.used) { + if (names[depths.array[0].value_at] && data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) { + fprintf(f_standard_output, "0%c", f_string_eol); } - else if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) { - if (data->contents.array[depths.array[0].value_at].used == 0) { - fprintf(f_standard_output, "0%c", f_string_eol); - } - else { - fprintf(f_standard_output, "1%c", f_string_eol); - } - return f_none; - } + return f_none; + } - if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) { - if (data->contents.array[depths.array[0].value_at].used == 0) { - if (include_empty && line == 0) { - fprintf(f_standard_output, "%c", f_string_eol); + f_array_length at = 0; + f_array_length i = 0; + + for (; i < data->objects.used; i++) { + if (names[i]) { + if (at == depths.array[0].value_at) { + if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) { + if (data->contents.array[i].used == 0) { + fprintf(f_standard_output, "0%c", f_string_eol); + } + else { + f_string_length total = 1; + + for (f_string_length j = data->contents.array[i].array[0].start; j <= data->contents.array[i].array[0].stop; j++) { + if (data->buffer.string[j] == f_string_eos) continue; + + if (data->buffer.string[j] == f_string_eol) { + total++; + } + } // for + + fprintf(f_standard_output, "%llu%c", total, f_string_eol); + } + + return f_none; } - } - else { - f_string_length i = data->contents.array[depths.array[0].value_at].array[0].start; - if (line == 0) { - for (; i <= data->contents.array[depths.array[0].value_at].array[0].stop; i++) { - if (data->buffer.string[i] == f_string_eos) continue; - if (data->buffer.string[i] == f_string_eol) { + if (data->parameters[fss_basic_list_read_parameter_line].result == f_console_result_additional) { + if (data->contents.array[i].used == 0) { + if (include_empty && line == 0) { fprintf(f_standard_output, "%c", f_string_eol); - break; } + } + else { + f_string_length i = data->contents.array[i].array[0].start; + + if (line == 0) { + for (; i <= data->contents.array[i].array[0].stop; i++) { + if (data->buffer.string[i] == f_string_eos) continue; + if (data->buffer.string[i] == f_string_eol) { + fprintf(f_standard_output, "%c", f_string_eol); + break; + } + + fprintf(f_standard_output, "%c", data->buffer.string[i]); + } // for + } + else { + f_string_length line_current = 0; - fprintf(f_standard_output, "%c", data->buffer.string[i]); - } // for - } - else { - f_string_length line_current = 0; + for (; i <= data->contents.array[i].array[0].stop; i++) { + if (data->buffer.string[i] == f_string_eos) continue; + + if (data->buffer.string[i] == f_string_eol) { + line_current++; - for (; i <= data->contents.array[depths.array[0].value_at].array[0].stop; i++) { - if (data->buffer.string[i] == f_string_eos) continue; + if (line_current == line) { + i++; - if (data->buffer.string[i] == f_string_eol) { - line_current++; + for (; i <= data->contents.array[i].array[0].stop; i++) { + if (data->buffer.string[i] == f_string_eos) continue; + if (data->buffer.string[i] == f_string_eol) { + fprintf(f_standard_output, "%c", f_string_eol); + break; + } - if (line_current == line) { - i++; + fprintf(f_standard_output, "%c", data->buffer.string[i]); + } // for - for (; i <= data->contents.array[depths.array[0].value_at].array[0].stop; i++) { - if (data->buffer.string[i] == f_string_eos) continue; - if (data->buffer.string[i] == f_string_eol) { - fprintf(f_standard_output, "%c", f_string_eol); break; } + } + } // for + } + } - fprintf(f_standard_output, "%c", data->buffer.string[i]); - } // for + return f_none; + } - break; - } - } - } // for + if (data->contents.array[i].used > 0) { + f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]); + } + else if (include_empty) { + fprintf(f_standard_output, "%c", f_string_eol); } - } - return f_none; - } + break; + } - if (data->contents.array[depths.array[0].value_at].used > 0) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[0]); + at++; } - else if (include_empty) { - fprintf(f_standard_output, "%c", f_string_eol); - } - } + } // for return f_none; } @@ -496,15 +528,23 @@ extern "C" { f_string_length total = 0; for (f_string_length i = 0; i < data->objects.used; i++) { - if (!names[i]) { - continue; - } + if (!names[i]) continue; + + if (data->contents.array[i].used == 0) { + if (include_empty) { + total++; + } - if (data->contents.array[i].used == 0 && !include_empty) { continue; } - total++; + for (f_string_length j = data->contents.array[i].array[0].start; j <= data->contents.array[i].array[0].stop; j++) { + if (data->buffer.string[j] == f_string_eos) continue; + + if (data->buffer.string[j] == f_string_eol) { + total++; + } + } // for } // for fprintf(f_standard_output, "%llu%c", total, f_string_eol); diff --git a/level_3/fss_basic_read/c/fss_basic_read.c b/level_3/fss_basic_read/c/fss_basic_read.c index 5b88a7c..123b2a3 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -79,6 +79,18 @@ extern "C" { printf("%c", f_string_eol); + printf(" When both "); + fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_read_long_at); + printf(" and "); + fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_read_long_name); + printf(" parameters are specified (at the same depth), the "); + fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_read_long_at); + printf(" parameter value will be treated as a position relative to the specified "); + fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_read_long_name); + printf(" parameter value.%c", f_string_eol); + + printf("%c", f_string_eol); + printf(" This program may support parameters, such as "); fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_basic_read_long_depth); printf(" or "); diff --git a/level_3/fss_basic_read/c/private-fss_basic_read.c b/level_3/fss_basic_read/c/private-fss_basic_read.c index 4634314..69cb1fc 100644 --- a/level_3/fss_basic_read/c/private-fss_basic_read.c +++ b/level_3/fss_basic_read/c/private-fss_basic_read.c @@ -391,15 +391,25 @@ extern "C" { } if (depths.array[0].index_at > 0) { - if (depths.array[0].value_at < data->objects.used && names[depths.array[0].value_at]) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[depths.array[0].value_at]); - fprintf(f_standard_output, "%c", f_string_eol); - } + f_array_length at = 0; + f_array_length i = 0; + + for (; i < data->objects.used; i++) { + if (names[i]) { + if (at == depths.array[0].value_at) { + f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[i]); + fprintf(f_standard_output, "%c", f_string_eol); + break; + } + + at++; + } + } // for return f_none; } - for (f_string_length i = 0; i < data->objects.used; i++) { + for (f_array_length i = 0; i < data->objects.used; i++) { if (names[i] == 0) continue; f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[i]); @@ -410,47 +420,59 @@ extern "C" { } if (depths.array[0].index_at > 0) { - if (names[depths.array[0].value_at]) { - if (depths.array[0].value_at >= data->objects.used) { - if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { - fprintf(f_standard_output, "0%c", f_string_eol); - } - - return f_none; + if (depths.array[0].value_at >= data->objects.used) { + if (names[depths.array[0].value_at] && data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { + fprintf(f_standard_output, "0%c", f_string_eol); } - else if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { - if (data->contents.array[depths.array[0].value_at].used == 0) { - fprintf(f_standard_output, "0%c", f_string_eol); - } - else { - fprintf(f_standard_output, "1%c", f_string_eol); - } + return f_none; + } + + if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) { + if (line > 0) { return f_none; } + } - if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) { - if (line == 0) { - if (data->contents.array[depths.array[0].value_at].used > 0) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[0]); - fprintf(f_standard_output, "%c", f_string_eol); + f_array_length at = 0; + f_array_length i = 0; + + for (; i < data->objects.used; i++) { + if (names[i]) { + if (at == depths.array[0].value_at) { + if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { + if (data->contents.array[i].used == 0) { + fprintf(f_standard_output, "0%c", f_string_eol); + } + else { + fprintf(f_standard_output, "1%c", f_string_eol); + } } - else if (include_empty) { - fprintf(f_standard_output, "%c", f_string_eol); + else if (data->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) { + if (data->contents.array[i].used > 0) { + f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]); + fprintf(f_standard_output, "%c", f_string_eol); + } + else if (include_empty) { + fprintf(f_standard_output, "%c", f_string_eol); + } + } + else { + if (data->contents.array[i].used > 0) { + f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]); + fprintf(f_standard_output, "%c", f_string_eol); + } + else if (include_empty) { + fprintf(f_standard_output, "%c", f_string_eol); + } } - } - return f_none; - } + break; + } - if (data->contents.array[depths.array[0].value_at].used > 0) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[0]); - fprintf(f_standard_output, "%c", f_string_eol); + at++; } - else if (include_empty) { - fprintf(f_standard_output, "%c", f_string_eol); - } - } + } // for return f_none; } diff --git a/level_3/fss_extended_read/c/fss_extended_read.c b/level_3/fss_extended_read/c/fss_extended_read.c index 80ba61e..23b8684 100644 --- a/level_3/fss_extended_read/c/fss_extended_read.c +++ b/level_3/fss_extended_read/c/fss_extended_read.c @@ -79,6 +79,18 @@ extern "C" { printf("%c", f_string_eol); + printf(" When both "); + fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_extended_read_long_at); + printf(" and "); + fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_extended_read_long_name); + printf(" parameters are specified (at the same depth), the "); + fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_extended_read_long_at); + printf(" parameter value will be treated as a position relative to the specified "); + fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_extended_read_long_name); + printf(" parameter value.%c", f_string_eol); + + printf("%c", f_string_eol); + printf(" This program may support parameters, such as "); fl_color_print(f_standard_output, data.context.notable, data.context.reset, "--%s", fss_extended_read_long_depth); printf(" or "); diff --git a/level_3/fss_extended_read/c/private-fss_extended_read.c b/level_3/fss_extended_read/c/private-fss_extended_read.c index 4e4aa39..08cd760 100644 --- a/level_3/fss_extended_read/c/private-fss_extended_read.c +++ b/level_3/fss_extended_read/c/private-fss_extended_read.c @@ -386,10 +386,20 @@ extern "C" { } if (depths.array[0].index_at > 0) { - if (depths.array[0].value_at < data->objects.used && names[depths.array[0].value_at]) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[depths.array[0].value_at]); - fprintf(f_standard_output, "%c", f_string_eol); - } + f_array_length at = 0; + f_array_length i = 0; + + for (; i < data->objects.used; i++) { + if (names[i]) { + if (at == depths.array[0].value_at) { + f_print_string_dynamic_partial(f_standard_output, data->buffer, data->objects.array[i]); + fprintf(f_standard_output, "%c", f_string_eol); + break; + } + + at++; + } + } // for return f_none; } @@ -405,43 +415,80 @@ extern "C" { } if (depths.array[0].index_at > 0) { - if (names[depths.array[0].value_at]) { - if (depths.array[0].value_at >= data->objects.used) { - if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) { - fprintf(f_standard_output, "0%c", f_string_eol); - } - - return f_none; + if (depths.array[0].value_at >= data->objects.used) { + if (names[depths.array[0].value_at] && data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) { + fprintf(f_standard_output, "0%c", f_string_eol); } - else if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) { - if (data->contents.array[depths.array[0].value_at].used == 0) { - fprintf(f_standard_output, "0%c", f_string_eol); - } - else { - fprintf(f_standard_output, "1%c", f_string_eol); - } - return f_none; - } + return f_none; + } + + f_array_length at = 0; + f_array_length i = 0; + + for (; i < data->objects.used; i++) { + if (names[i]) { + if (at == depths.array[0].value_at) { + if (data->parameters[fss_extended_read_parameter_total].result == f_console_result_found) { + if (data->contents.array[i].used == 0) { + fprintf(f_standard_output, "0%c", f_string_eol); + } + else { + fprintf(f_standard_output, "1%c", f_string_eol); + } + + return f_none; + } + + if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) { + if (line == 0) { + if (data->contents.array[i].used > 0) { + f_string_length j = 0; + + if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { + if (select < data->contents.array[i].used) { + f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[select]); + fprintf(f_standard_output, "%c", f_string_eol); + } else if (include_empty) { + fprintf(f_standard_output, "%c", f_string_eol); + } + } + else { + for (j = 0; j < data->contents.array[i].used; j++) { + f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[j]); + + if (j + 1 < data->contents.array[i].used) { + printf(" "); + } + } // for - if (data->parameters[fss_extended_read_parameter_line].result == f_console_result_additional) { - if (line == 0) { - if (data->contents.array[depths.array[0].value_at].used > 0) { + fprintf(f_standard_output, "%c", f_string_eol); + } + } + else if (include_empty) { + fprintf(f_standard_output, "%c", f_string_eol); + } + } + + return f_none; + } + + if (data->contents.array[i].used > 0) { f_string_length j = 0; if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { - if (select < data->contents.array[depths.array[0].value_at].used) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[select]); + if (select < data->contents.array[i].used) { + f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[select]); fprintf(f_standard_output, "%c", f_string_eol); } else if (include_empty) { fprintf(f_standard_output, "%c", f_string_eol); } } else { - for (j = 0; j < data->contents.array[depths.array[0].value_at].used; j++) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[j]); + for (j = 0; j < data->contents.array[i].used; j++) { + f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[j]); - if (j + 1 < data->contents.array[depths.array[0].value_at].used) { + if (j + 1 < data->contents.array[i].used) { printf(" "); } } // for @@ -452,38 +499,13 @@ extern "C" { else if (include_empty) { fprintf(f_standard_output, "%c", f_string_eol); } - } - - return f_none; - } - - if (data->contents.array[depths.array[0].value_at].used > 0) { - f_string_length j = 0; - if (data->parameters[fss_extended_read_parameter_select].result == f_console_result_additional) { - if (select < data->contents.array[depths.array[0].value_at].used) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[select]); - fprintf(f_standard_output, "%c", f_string_eol); - } else if (include_empty) { - fprintf(f_standard_output, "%c", f_string_eol); - } + break; } - else { - for (j = 0; j < data->contents.array[depths.array[0].value_at].used; j++) { - f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[depths.array[0].value_at].array[j]); - - if (j + 1 < data->contents.array[depths.array[0].value_at].used) { - printf(" "); - } - } // for - fprintf(f_standard_output, "%c", f_string_eol); - } + at++; } - else if (include_empty) { - fprintf(f_standard_output, "%c", f_string_eol); - } - } + } // for return f_none; }