From: Kevin Day Date: Thu, 14 Nov 2019 02:54:31 +0000 (-0600) Subject: Feature: add support for including empty content in fss_basic_read X-Git-Tag: 0.5.0~393 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=7eab988fc94fb16119cc9e9f6da8f1ef9593844d;p=fll Feature: add support for including empty content in fss_basic_read Empty content is an object that has no content. When there is no content for an object, no content is printed for that line and that line is not included in content totals or line selections. --- 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 102ec5b..f3cd548 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.c +++ b/level_3/fss_basic_read/c/fss_basic_read.c @@ -19,6 +19,7 @@ extern "C" { fll_program_print_help_option(data.context, fss_basic_read_short_at, fss_basic_read_long_at, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric index."); fll_program_print_help_option(data.context, fss_basic_read_short_depth, fss_basic_read_long_depth, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object at this numeric depth."); + fll_program_print_help_option(data.context, fss_basic_read_short_empty, fss_basic_read_long_empty, f_console_symbol_short_enable, f_console_symbol_long_enable, " Include empty content when processing."); fll_program_print_help_option(data.context, fss_basic_read_short_line, fss_basic_read_long_line, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print only the content at the given line."); fll_program_print_help_option(data.context, fss_basic_read_short_name, fss_basic_read_long_name, f_console_symbol_short_enable, f_console_symbol_long_enable, " Select object with this name."); fll_program_print_help_option(data.context, fss_basic_read_short_object, fss_basic_read_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Print the object instead of the content."); diff --git a/level_3/fss_basic_read/c/fss_basic_read.h b/level_3/fss_basic_read/c/fss_basic_read.h index 34bc25f..55e000a 100644 --- a/level_3/fss_basic_read/c/fss_basic_read.h +++ b/level_3/fss_basic_read/c/fss_basic_read.h @@ -58,6 +58,7 @@ extern "C" { #ifndef _di_fss_basic_read_defines_ #define fss_basic_read_short_at "a" #define fss_basic_read_short_depth "d" + #define fss_basic_read_short_empty "e" #define fss_basic_read_short_line "l" #define fss_basic_read_short_name "n" #define fss_basic_read_short_object "o" @@ -66,6 +67,7 @@ extern "C" { #define fss_basic_read_long_at "at" #define fss_basic_read_long_depth "depth" + #define fss_basic_read_long_empty "empty" #define fss_basic_read_long_line "line" #define fss_basic_read_long_name "name" #define fss_basic_read_long_object "object" @@ -81,6 +83,7 @@ extern "C" { fss_basic_read_parameter_at, fss_basic_read_parameter_depth, + fss_basic_read_parameter_empty, fss_basic_read_parameter_line, fss_basic_read_parameter_name, fss_basic_read_parameter_object, @@ -97,6 +100,7 @@ extern "C" { f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, f_false, f_console_type_inverse), \ f_console_parameter_initialize(fss_basic_read_short_at, fss_basic_read_long_at, 0, f_true, f_console_type_normal), \ f_console_parameter_initialize(fss_basic_read_short_depth, fss_basic_read_long_depth, 0, f_true, f_console_type_normal), \ + f_console_parameter_initialize(fss_basic_read_short_empty, fss_basic_read_long_empty, 0, f_false, f_console_type_normal), \ f_console_parameter_initialize(fss_basic_read_short_line, fss_basic_read_long_line, 0, f_true, f_console_type_normal), \ f_console_parameter_initialize(fss_basic_read_short_name, fss_basic_read_long_name, 0, f_true, f_console_type_normal), \ f_console_parameter_initialize(fss_basic_read_short_object, fss_basic_read_long_object, 0, f_false, f_console_type_normal), \ @@ -104,7 +108,7 @@ extern "C" { f_console_parameter_initialize(fss_basic_read_short_total, fss_basic_read_long_total, 0, f_false, f_console_type_normal), \ } - #define fss_basic_read_total_parameters 12 + #define fss_basic_read_total_parameters 13 #endif // _di_fss_basic_read_defines_ #ifndef _di_fss_basic_read_data_ 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 6045522..6e64bee 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 @@ -337,6 +337,12 @@ extern "C" { memset(names, 1, sizeof(bool) * data->objects.used); } + bool include_empty = 0; + + if (data->parameters[fss_basic_read_parameter_empty].result == f_console_result_found) { + include_empty = 1; + } + if (data->parameters[fss_basic_read_parameter_object].result == f_console_result_found) { if (data->parameters[fss_basic_read_parameter_total].result == f_console_result_found) { if (depths.array[0].index_at > 0) { @@ -426,7 +432,13 @@ extern "C" { f_string_length total = 0; for (f_string_length i = 0; i < data->objects.used; i++) { - if (names[i] == 0 || data->contents.array[i].used == 0) continue; + if (!names[i]) { + continue; + } + + if (data->contents.array[i].used == 0 && !include_empty) { + continue; + } total++; } // for @@ -439,7 +451,22 @@ extern "C" { f_string_length line_current = 0; for (f_string_length i = 0; i < data->contents.used; i++) { - if (names[i] == 0 || data->contents.array[i].used == 0) continue; + if (!names[i]) { + continue; + } + + if (data->contents.array[i].used == 0) { + if (include_empty) { + if (line_current == line) { + fprintf(f_standard_output, "%c", f_string_eol); + break; + } + + line_current++; + } + + continue; + } if (line_current == line) { f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]); @@ -455,7 +482,17 @@ extern "C" { } for (f_string_length i = 0; i < data->contents.used; i++) { - if (!names[i] || data->contents.array[i].used == 0) continue; + if (!names[i]) { + continue; + } + + if (data->contents.array[i].used == 0) { + if (include_empty) { + fprintf(f_standard_output, "%c", f_string_eol); + } + + continue; + } f_print_string_dynamic_partial(f_standard_output, data->buffer, data->contents.array[i].array[0]); fprintf(f_standard_output, "%c", f_string_eol);