]> Kevux Git Server - fll/commitdiff
Feature: add support for including empty content in fss_basic_read
authorKevin Day <thekevinday@gmail.com>
Thu, 14 Nov 2019 02:54:31 +0000 (20:54 -0600)
committerKevin Day <thekevinday@gmail.com>
Thu, 14 Nov 2019 03:00:32 +0000 (21:00 -0600)
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.

level_3/fss_basic_read/c/fss_basic_read.c
level_3/fss_basic_read/c/fss_basic_read.h
level_3/fss_basic_read/c/private-fss_basic_read.c

index 102ec5b02ae91ff2943bd3c03d2339db50899cb2..f3cd548463bdca742d46deda813875a4ee79ea05 100644 (file)
@@ -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.");
index 34bc25f5d511ef6e6c6511a9e871416d4ac3b7e0..55e000a83e5e76cbb640563bcaeafcfdd53a14da 100644 (file)
@@ -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_
index 60455228c3f7dd5c061fa1afb7e963276426d62a..6e64bee9c8d5cde29758c2ef4f7a0b5d5a68e2bd 100644 (file)
@@ -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);