]> Kevux Git Server - fll/commitdiff
Update: Better handle comments in FSS and fix problems.
authorKevin Day <thekevinday@gmail.com>
Mon, 26 Oct 2020 00:18:41 +0000 (19:18 -0500)
committerKevin Day <thekevinday@gmail.com>
Mon, 26 Oct 2020 04:11:44 +0000 (23:11 -0500)
Comments may exist inside of an FSS Basic List and FSS Extended List.
Handle the comments.

The FSS Basic List Read and FSS Extended List read both need to print the ignore character around content in pipe mode.
The FSS Extended List needs to specifically not do this for individual nested objects.

Fix problems in the FSS Basic List read content handling when an object is found such that content is empty.
Clean up some of the code, doing some basic code simplification.
The FSS Basic List Read should always return a range and should not exclusively end always at an EOL.

Fix a case where not enough memory is allocated for delimits in FSS Basic List.

Add missing/incomplete parameter checks.

25 files changed:
build/level_0/settings
build/monolithic/settings
level_0/f_fss/c/fss.h
level_0/f_fss/c/fss_comment.h [new file with mode: 0644]
level_0/f_fss/c/fss_delimit.h
level_0/f_fss/data/build/settings
level_1/fl_fss/c/fss_basic.c
level_1/fl_fss/c/fss_basic_list.c
level_1/fl_fss/c/fss_basic_list.h
level_1/fl_fss/c/fss_extended.c
level_1/fl_fss/c/fss_extended_list.c
level_1/fl_fss/c/fss_extended_list.h
level_1/fl_fss/c/fss_macro.h
level_1/fl_fss/c/fss_status.h
level_2/fll_fss/c/fss_basic_list.c
level_2/fll_fss/c/fss_basic_list.h
level_2/fll_fss/c/fss_extended.c
level_2/fll_fss/c/fss_extended_list.c
level_2/fll_fss/c/fss_extended_list.h
level_3/fss_basic_list_read/c/fss_basic_list_read.c
level_3/fss_basic_list_read/c/private-fss_basic_list_read.c
level_3/fss_basic_list_read/c/private-fss_basic_list_read.h
level_3/fss_extended_list_read/c/fss_extended_list_read.c
level_3/fss_extended_list_read/c/private-fss_extended_list_read.c
level_3/fss_extended_list_read/c/private-fss_extended_list_read.h

index 770c3fc73ed227807b095112f31973544bb8778b..ee482052e7b1e930a2cf01c04c60733d8e8b0707 100644 (file)
@@ -22,7 +22,7 @@ build_libraries -lc
 build_libraries-level
 build_sources_library account.c console.c conversion.c directory.c private-directory.c environment.c private-environment.c file.c private-file.c fss.c iki.c private-iki.c memory.c path.c private-path.c pipe.c print.c private-print.c serialize.c private-serialize.c signal.c socket.c utf.c private-utf.c
 build_sources_program
-build_sources_headers account.h account-common.h color.h console.h console-common.h conversion.h conversion-common.h directory.h directory_type.h directory-common.h environment.h environment-common.h file.h file-common.h fss.h fss-common.h fss_delimit.h fss_named.h fss_nest.h fss_quote.h fss_set.h iki.h iki-common.h memory.h memory_structure.h path.h path-common.h pipe.h print.h serialize.h serialize-common.h signal.h signal-common.h socket.h socket-common.h status.h status_array.h string.h string-common.h string_dynamic.h string_map.h string_quantity.h string_range.h type.h type_array.h utf.h utf-common.h
+build_sources_headers account.h account-common.h color.h console.h console-common.h conversion.h conversion-common.h directory.h directory_type.h directory-common.h environment.h environment-common.h file.h file-common.h fss.h fss-common.h fss_comment.h fss_delimit.h fss_named.h fss_nest.h fss_quote.h fss_set.h iki.h iki-common.h memory.h memory_structure.h path.h path-common.h pipe.h print.h serialize.h serialize-common.h signal.h signal-common.h socket.h socket-common.h status.h status_array.h string.h string-common.h string_dynamic.h string_map.h string_quantity.h string_range.h type.h type_array.h utf.h utf-common.h
 build_sources_script
 build_sources_setting
 build_script yes
index 152db4933cb228500887b3f49e47bef1a2ecd6f0..2e3203ab8b43b3ea93913dba29686216ad71b159 100644 (file)
@@ -22,7 +22,7 @@ build_libraries -lc
 build_libraries-monolithic
 build_sources_library level_0/account.c level_0/console.c level_0/conversion.c level_0/directory.c level_0/private-directory.c level_0/environment.c level_0/private-environment.c level_0/file.c level_0/private-file.c level_0/fss.c level_0/iki.c level_0/private-iki.c level_0/memory.c level_0/path.c level_0/private-path.c level_0/pipe.c level_0/print.c level_0/private-print.c level_0/serialize.c level_0/private-serialize.c level_0/signal.c level_0/socket.c level_0/utf.c level_0/private-utf.c level_1/color.c level_1/console.c level_1/conversion.c level_1/directory.c level_1/private-directory.c level_1/environment.c level_1/private-fss.c level_1/fss_basic.c level_1/fss_basic_list.c level_1/fss_extended.c level_1/fss_extended_list.c level_1/iki.c level_1/print.c level_1/private-print.c level_1/status.c level_1/string.c level_1/private-string.c level_1/utf.c level_1/private-utf.c level_1/utf_file.c level_1/private-utf_file.c level_2/error.c level_2/private-error.c level_2/execute.c level_2/private-execute.c level_2/file.c level_2/private-file.c level_2/fss.c level_2/private-fss.c level_2/fss_basic.c level_2/fss_basic_list.c level_2/fss_extended.c level_2/fss_extended_list.c level_2/fss_status.c level_2/iki.c level_2/private-iki.c level_2/path.c level_2/program.c level_2/status.c
 build_sources_program
-build_sources_headers level_0/account.h level_0/account-common.h level_0/color.h level_0/console.h level_0/console-common.h level_0/conversion.h level_0/conversion-common.h level_0/directory.h level_0/directory_type.h level_0/directory-common.h level_0/environment.h level_0/environment-common.h level_0/file.h level_0/file-common.h level_0/fss.h level_0/fss-common.h level_0/fss_delimit.h level_0/fss_named.h level_0/fss_nest.h level_0/fss_quote.h level_0/fss_set.h level_0/iki.h level_0/iki-common.h level_0/memory.h level_0/memory_structure.h level_0/path.h level_0/path-common.h level_0/pipe.h level_0/print.h level_0/serialize.h level_0/serialize-common.h level_0/signal.h level_0/signal-common.h level_0/socket.h level_0/socket-common.h level_0/status.h level_0/status_array.h level_0/string.h level_0/string-common.h level_0/string_dynamic.h level_0/string_map.h level_0/string_quantity.h level_0/string_range.h level_0/type.h level_0/type_array.h level_0/utf.h level_0/utf-common.h level_1/color.h level_1/console.h level_1/conversion.h level_1/directory.h level_1/environment.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_macro.h level_1/fss_status.h level_1/iki.h level_1/print.h level_1/status.h level_1/string.h level_1/utf.h level_1/utf_file.h level_2/error.h level_2/error-common.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/iki.h level_2/path.h level_2/program.h level_2/status.h
+build_sources_headers level_0/account.h level_0/account-common.h level_0/color.h level_0/console.h level_0/console-common.h level_0/conversion.h level_0/conversion-common.h level_0/directory.h level_0/directory_type.h level_0/directory-common.h level_0/environment.h level_0/environment-common.h level_0/file.h level_0/file-common.h level_0/fss.h level_0/fss-common.h level_0/fss_comment.h level_0/fss_delimit.h level_0/fss_named.h level_0/fss_nest.h level_0/fss_quote.h level_0/fss_set.h level_0/iki.h level_0/iki-common.h level_0/memory.h level_0/memory_structure.h level_0/path.h level_0/path-common.h level_0/pipe.h level_0/print.h level_0/serialize.h level_0/serialize-common.h level_0/signal.h level_0/signal-common.h level_0/socket.h level_0/socket-common.h level_0/status.h level_0/status_array.h level_0/string.h level_0/string-common.h level_0/string_dynamic.h level_0/string_map.h level_0/string_quantity.h level_0/string_range.h level_0/type.h level_0/type_array.h level_0/utf.h level_0/utf-common.h level_1/color.h level_1/console.h level_1/conversion.h level_1/directory.h level_1/environment.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_macro.h level_1/fss_status.h level_1/iki.h level_1/print.h level_1/status.h level_1/string.h level_1/utf.h level_1/utf_file.h level_2/error.h level_2/error-common.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/iki.h level_2/path.h level_2/program.h level_2/status.h
 build_sources_script
 build_sources_setting
 build_script yes
index 44e44c55caadace1067e53184204a0569e52d9fb..263a951b2e3da111f157ba4982fc72db3184a517 100644 (file)
@@ -25,6 +25,7 @@
 
 // fll-0 fss includes
 #include <level_0/fss-common.h>
+#include <level_0/fss_comment.h>
 #include <level_0/fss_delimit.h>
 #include <level_0/fss_quote.h>
 #include <level_0/fss_named.h>
diff --git a/level_0/f_fss/c/fss_comment.h b/level_0/f_fss/c/fss_comment.h
new file mode 100644 (file)
index 0000000..de6bd85
--- /dev/null
@@ -0,0 +1,82 @@
+/**
+ * FLL - Level 0
+ *
+ * Project: FSS
+ * API Version: 0.5
+ * Licenses: lgplv2.1
+ *
+ * Defines set data to be used for/by project fss.
+ *
+ * This is auto-included by fss.h and should not need to be explicitly included.
+ */
+#ifndef _F_fss_comment_h
+#define _F_fss_comment_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Designate an fss comment location.
+ */
+#ifndef _di_f_fss_comment_t_
+  typedef f_string_range_t f_fss_comment_t;
+#endif // _di_f_fss_comment_t_
+
+/**
+ * An array of f_fss_comment_t.
+ *
+ * array: the array of fss quote.
+ * size: total amount of allocated space.
+ * used: total number of allocated spaces used.
+ */
+#ifndef _di_f_fss_comments_t_
+  typedef f_string_ranges_t f_fss_comments_t;
+
+  #define f_fss_comments_t_initialize f_string_ranges_t_initialize
+
+  #define f_macro_fss_comments_t_clear(delimits) f_macro_string_ranges_t_clear(delimits)
+
+  #define f_macro_fss_comments_t_new(status, delimits, length) f_macro_string_ranges_t_new(status, delimits, length)
+
+  #define f_macro_fss_comments_t_delete(status, delimits)  f_macro_string_ranges_t_delete(status, delimits)
+  #define f_macro_fss_comments_t_destroy(status, delimits) f_macro_string_ranges_t_destroy(status, delimits)
+
+  #define f_macro_fss_comments_t_delete_simple(delimits)  f_macro_string_ranges_t_delete_simple(delimits)
+  #define f_macro_fss_comments_t_destroy_simple(delimits) f_macro_string_ranges_t_destroy_simple(delimits)
+
+  #define f_macro_fss_comments_t_resize(status, delimits, new_length) f_macro_string_ranges_t_resize(status, delimits, new_length)
+  #define f_macro_fss_comments_t_adjust(status, delimits, new_length) f_macro_string_ranges_t_adjust(status, delimits, new_length)
+#endif // _di_f_fss_comments_t_
+
+/**
+ * An array of f_fss_comments_t.
+ *
+ * array: the array of fss quotes.
+ * size: total amount of allocated space.
+ * used: total number of allocated spaces used.
+ */
+#ifndef _di_f_fss_commentss_t_
+  typedef f_string_rangess_t f_fss_commentss_t;
+
+  #define f_fss_commentss_t_initialize f_string_rangess_t_initialize
+
+  #define f_macro_fss_commentss_t_clear(quotess) f_macro_string_rangess_t_clear(quotess)
+
+  #define f_macro_fss_commentss_t_new(status, quotess, length) f_macro_string_rangess_t_new(status, quotess, length)
+
+  #define f_macro_fss_commentss_t_delete(status, quotess)  f_macro_string_rangess_t_delete(status, quotess)
+  #define f_macro_fss_commentss_t_destroy(status, quotess) f_macro_string_rangess_t_destroy(status, quotess)
+
+  #define f_macro_fss_commentss_t_delete_simple(quotess)  f_macro_string_rangess_t_delete_simple(quotess)
+  #define f_macro_fss_commentss_t_destroy_simple(quotess) f_macro_string_rangess_t_destroy_simple(quotess)
+
+  #define f_macro_fss_commentss_t_resize(status, quotess, new_length) f_macro_string_rangess_t_resize(status, quotess, new_length)
+  #define f_macro_fss_commentss_t_adjust(status, quotess, new_length) f_macro_string_rangess_t_adjust(status, quotess, new_length)
+#endif // _di_f_fss_commentss_t_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_fss_comment_h
index 2eda779e7794a554bcbce3fef079e6611d25f85b..3679f501f9977f02bd67e84f8b569c8592dd3458 100644 (file)
@@ -59,7 +59,7 @@ extern "C" {
 #ifndef _di_f_fss_delimitss_t_
   typedef f_string_lengthss_t f_fss_delimitss_t;
 
-  #define f_fss_delimitss_t_initialize f_f_string_lengthss_t_initialize
+  #define f_fss_delimitss_t_initialize f_string_lengthss_t_initialize
 
   #define f_macro_fss_delimitss_t_clear(quotess) f_macro_string_lengthss_t_clear(quotess)
 
index e06e7cd05d84f4bad8d7b754cead7a6e216ec5a7..112ec98626fe31d09d0dea74b5f757c46be2dfcb 100644 (file)
@@ -22,7 +22,7 @@ build_libraries -lc
 build_libraries-individual -lf_memory -lf_utf
 build_sources_library fss.c
 build_sources_program
-build_sources_headers fss.h fss-common.h fss_delimit.h fss_named.h fss_nest.h fss_quote.h fss_set.h
+build_sources_headers fss.h fss-common.h fss_comment.h fss_delimit.h fss_named.h fss_nest.h fss_quote.h fss_set.h
 build_sources_script
 build_sources_setting
 build_script yes
index f8bd34c3d1ac52a67fb63f124de96c7c6dee5658..63a456941034c17bcdfaffc3cc9edbfbb55fe23d 100644 (file)
@@ -11,6 +11,7 @@ extern "C" {
       if (!buffer) return F_status_set_error(F_parameter);
       if (!range) return F_status_set_error(F_parameter);
       if (!found) return F_status_set_error(F_parameter);
+      if (!delimits) return F_status_set_error(F_parameter);
     #endif // _di_level_1_parameter_checking_
 
     const f_array_length_t delimits_used = delimits->used;
@@ -32,6 +33,7 @@ extern "C" {
       if (!buffer) return F_status_set_error(F_parameter);
       if (!range) return F_status_set_error(F_parameter);
       if (!found) return F_status_set_error(F_parameter);
+      if (!delimits) return F_status_set_error(F_parameter);
     #endif // _di_level_1_parameter_checking_
 
     f_status_t status = f_fss_skip_past_space(*buffer, range);
index c331cbe8c21992a6f2e1ca829a4819be0ad82bfe..5156313b0b841060239aa199e9ee7b6823f0e9dd 100644 (file)
@@ -11,6 +11,7 @@ extern "C" {
       if (!buffer) return F_status_set_error(F_parameter);
       if (!range) return F_status_set_error(F_parameter);
       if (!found) return F_status_set_error(F_parameter);
+      if (!delimits) return F_status_set_error(F_parameter);
     #endif // _di_level_1_parameter_checking_
 
     const f_array_length_t delimits_used = delimits->used;
@@ -57,16 +58,18 @@ extern "C" {
       return FL_fss_found_object_not;
     }
 
-    f_string_length_t first_slash = 0;
+    f_string_length_t slash_first = 0;
     f_string_length_t slash_count = 0;
     f_string_length_t start = 0;
     f_string_length_t stop = 0;
 
+    bool graph_first = F_true;
+
     // identify where the object ends.
     while (range->start <= range->stop && range->start < buffer->used && buffer->string[range->start] != f_fss_eol) {
 
       if (buffer->string[range->start] == f_fss_delimit_slash) {
-        first_slash = range->start;
+        slash_first = range->start;
         slash_count = 1;
 
         for (range->start++; range->start <= range->stop && range->start < buffer->used; range->start++) {
@@ -83,6 +86,7 @@ extern "C" {
         fl_macro_fss_object_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop);
 
         if (buffer->string[range->start] == f_fss_basic_list_open) {
+          graph_first = F_false;
           stop = range->start - 1;
 
           status = f_utf_buffer_increment(*buffer, range, 1);
@@ -90,25 +94,15 @@ extern "C" {
 
           while (range->start <= range->stop && range->start < buffer->used) {
 
-            if (buffer->string[range->start] == f_fss_eol) {
-              break;
-            }
+            if (buffer->string[range->start] == f_fss_eol) break;
 
             status = f_fss_is_space(*buffer, *range);
-
-            if (F_status_is_error(status)) {
-              delimits->used = delimits_used;
-              return status;
-            }
+            if (F_status_is_error(status)) break;
 
             if (status == F_false) break;
 
             status = f_utf_buffer_increment(*buffer, range, 1);
-
-            if (F_status_is_error(status)) {
-              delimits->used = delimits_used;
-              return status;
-            }
+            if (F_status_is_error(status)) break;
           } // while
 
           fl_macro_fss_object_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop);
@@ -116,14 +110,10 @@ extern "C" {
           if (buffer->string[range->start] == f_fss_eol) {
             start = range->start;
 
-            range->start = first_slash;
+            range->start = slash_first;
 
             status = private_fl_fss_delimits_increase_by((slash_count / 2) + 1, delimits);
-
-            if (F_status_is_error(status)) {
-              delimits->used = delimits_used;
-              return status;
-            }
+            if (F_status_is_error(status)) break;
 
             if (slash_count % 2 == 0) {
               while (slash_count > 0) {
@@ -155,40 +145,40 @@ extern "C" {
             return FL_fss_found_object_not;
           }
         }
+        else if (graph_first && buffer->string[range->start] == f_fss_comment) {
+          graph_first = F_false;
+
+          // comments may only have whitespace before the '#', therefore only the first slash needs to be delimited.
+          status = private_fl_fss_delimits_increase(delimits);
+          if (F_status_is_error(status)) break;
+
+          delimits->array[delimits->used++] = slash_first;
+          range->start++;
+        }
+        else {
+          graph_first = F_false;
+        }
 
         continue;
       }
       else if (buffer->string[range->start] == f_fss_basic_list_open) {
+        graph_first = F_false;
         stop = range->start - 1;
 
         status = f_utf_buffer_increment(*buffer, range, 1);
-
-        if (F_status_is_error(status)) {
-          delimits->used = delimits_used;
-          return status;
-        }
+        if (F_status_is_error(status)) break;
 
         while (range->start <= range->stop && range->start < buffer->used) {
 
-          if (buffer->string[range->start] == f_fss_eol) {
-            break;
-          }
+          if (buffer->string[range->start] == f_fss_eol) break;
 
           status = f_fss_is_space(*buffer, *range);
-
-          if (F_status_is_error(status)) {
-            delimits->used = delimits_used;
-            return status;
-          }
+          if (F_status_is_error(status)) break;
 
           if (status == F_false) break;
 
           status = f_utf_buffer_increment(*buffer, range, 1);
-
-          if (F_status_is_error(status)) {
-            delimits->used = delimits_used;
-            return status;
-          }
+          if (F_status_is_error(status)) break;
         } // while
 
         fl_macro_fss_object_return_on_overflow_delimited((*buffer), (*range), (*found), F_none_eos, F_none_stop);
@@ -197,28 +187,25 @@ extern "C" {
           found->stop = stop;
 
           status = f_utf_buffer_increment(*buffer, range, 1);
-
-          if (F_status_is_error(status)) {
-            delimits->used = delimits_used;
-            return status;
-          }
+          if (F_status_is_error(status)) break;
 
           return FL_fss_found_object;
         }
 
         continue;
       }
+      else if (graph_first) {
+        status = f_fss_is_space(*buffer, *range);
+        if (F_status_is_error(status)) break;
 
-      status = f_utf_buffer_increment(*buffer, range, 1);
-
-      if (F_status_is_error(status)) {
-        delimits->used = delimits_used;
-        return status;
+        if (status == F_false) {
+          graph_first = F_false;
+        }
       }
-    } // while
 
-    // seek to the end of the line when no valid object is found.
-    status = f_fss_seek_to_eol(*buffer, range);
+      status = f_utf_buffer_increment(*buffer, range, 1);
+      if (F_status_is_error(status)) break;
+    } // while
 
     if (F_status_is_error(status)) {
       delimits->used = delimits_used;
@@ -233,6 +220,9 @@ extern "C" {
       return F_data_not_stop;
     }
 
+    // seek to the end of the line when no valid object is found.
+    status = f_fss_seek_to_eol(*buffer, range);
+
     // move the start position to after the EOL.
     range->start++;
 
@@ -241,49 +231,55 @@ extern "C" {
 #endif // _di_fl_fss_basic_list_object_read_
 
 #ifndef _di_fl_fss_basic_list_content_read_
-  f_return_status fl_fss_basic_list_content_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits) {
+  f_return_status fl_fss_basic_list_content_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments) {
     #ifndef _di_level_1_parameter_checking_
       if (!buffer) return F_status_set_error(F_parameter);
       if (!range) return F_status_set_error(F_parameter);
       if (!found) return F_status_set_error(F_parameter);
+      if (!delimits) return F_status_set_error(F_parameter);
+      if (!comments) return F_status_set_error(F_parameter);
     #endif // _di_level_1_parameter_checking_
 
     const f_array_length_t delimits_used = delimits->used;
+    const f_array_length_t comments_used = comments->used;
 
     f_status_t status = f_fss_skip_past_delimit(*buffer, range);
     if (F_status_is_error(status)) return status;
 
-    fl_macro_fss_content_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, F_none_eos, F_none_stop);
+    fl_macro_fss_content_with_comments_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, F_none_eos, F_none_stop);
 
     status = private_fl_fss_ranges_increase(found);
     if (F_status_is_error(status)) return status;
 
     found->array[found->used].start = range->start;
 
-    f_string_length_t last_newline = range->start;
-    f_string_length_t first_slash = 0;
+    f_string_length_t newline_last = range->start;
+    f_string_length_t slash_first = 0;
     f_string_length_t slash_count = 0;
     f_string_length_t start = 0;
+    f_string_length_t comment_delimit = 0;
 
-    bool found_newline = F_false;
+    uint8_t graph_first = 0x1; // 0x0 = false, 0x1 = true, 0x2 = false, but there is a delimited comment, comment_delimit is set.
 
     // identify where the content ends.
     while (range->start <= range->stop && range->start < buffer->used) {
 
       if (buffer->string[range->start] == f_fss_eol) {
-        found_newline = F_true;
-        last_newline = range->start;
-
-        status = f_utf_buffer_increment(*buffer, range, 1);
-        if (F_status_is_error(status)) return status;
+        if (graph_first == 0x2) {
+          status = private_fl_fss_delimits_increase(delimits);
+          if (F_status_is_error(status)) break;
 
-        fl_macro_fss_content_return_on_overflow_delimited((*buffer), (*range), (*found), F_none_eos, F_none_stop);
+          delimits->array[delimits->used++] = comment_delimit;
+        }
 
+        newline_last = range->start;
+        graph_first = 0x1;
+        range->start++;
         continue;
       }
 
       if (buffer->string[range->start] == f_fss_delimit_slash) {
-        first_slash = range->start;
+        slash_first = range->start;
         slash_count = 1;
 
         for (range->start++; range->start <= range->stop && range->start < buffer->used; range->start++) {
@@ -297,145 +293,173 @@ extern "C" {
           slash_count++;
         } // for
 
-        if (found_newline) {
-          fl_macro_fss_content_return_on_overflow_delimited((*buffer), (*range), (*found), F_none_eos, F_none_stop);
-        }
-        else {
-          fl_macro_fss_content_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop);
-        }
+        if (range->start > range->stop || range->start >= buffer->used) break;
 
         if (buffer->string[range->start] == f_fss_basic_list_open) {
-          status = f_utf_buffer_increment(*buffer, range, 1);
-          if (F_status_is_error(status)) return status;
+          graph_first = 0x0;
+          range->start++;
 
           while (range->start <= range->stop && range->start < buffer->used) {
 
-            if (buffer->string[range->start] == f_fss_eol) {
-              break;
-            }
+            if (buffer->string[range->start] == f_fss_eol) break;
 
             status = f_fss_is_space(*buffer, *range);
+            if (F_status_is_error(status)) break;
 
-            if (F_status_is_error(status)) return status;
             if (status == F_false) break;
 
             status = f_utf_buffer_increment(*buffer, range, 1);
-            if (F_status_is_error(status)) return status;
+            if (F_status_is_error(status)) break;
           } // while
 
-          if (found_newline) {
-            fl_macro_fss_content_return_on_overflow_delimited((*buffer), (*range), (*found), F_none_eos, F_none_stop);
-          }
-          else {
-            fl_macro_fss_content_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop);
-          }
+          if (range->start > range->stop || range->start >= buffer->used) break;
 
           if (buffer->string[range->start] == f_fss_eol) {
             start = range->start;
-
-            range->start = first_slash;
+            range->start = slash_first;
 
             if (slash_count % 2 == 0) {
-              if (found_newline) {
-                found->array[found->used].stop = last_newline;
-                range->start = last_newline + 1;
-                found->used++;
+              found->array[found->used++].stop = newline_last;
+              range->start = newline_last + 1;
 
-                return FL_fss_found_content;
-              }
-
-              return FL_fss_found_content_not;
+              return FL_fss_found_content;
             }
 
-            status = private_fl_fss_delimits_increase_by(slash_count / 2, delimits);
-
-            if (F_status_is_error(status)) {
-              delimits->used = delimits_used;
-              return status;
-            }
+            status = private_fl_fss_delimits_increase_by((slash_count / 2) + 1, delimits);
+            if (F_status_is_error(status)) break;
 
             while (slash_count > 0) {
 
               if (buffer->string[range->start] == f_fss_delimit_slash) {
                 if (slash_count % 2 == 1) {
-                  delimits->array[delimits->used] = range->start;
-                  delimits->used++;
+                  delimits->array[delimits->used++] = range->start;
                 }
 
                 slash_count--;
               }
 
               status = f_utf_buffer_increment(*buffer, range, 1);
-              if (F_status_is_error(status)) return status;
+              if (F_status_is_error(status)) break;
             } // while
 
-            found_newline = F_true;
+            if (F_status_is_error(status)) break;
+
+            if (graph_first == 0x2) {
+              status = private_fl_fss_delimits_increase(delimits);
+              if (F_status_is_error(status)) break;
+
+              delimits->array[delimits->used++] = comment_delimit;
+            }
+
+            graph_first = 0x1;
             range->start = start + 1;
           }
         }
+        else if (graph_first == 0x1 && buffer->string[range->start] == f_fss_comment) {
+          graph_first = 0x2;
+          comment_delimit = slash_first;
+          range->start++;
+        }
 
         continue;
       }
-      else if (buffer->string[range->start] == f_fss_basic_list_open) {
-        status = f_utf_buffer_increment(*buffer, range, 1);
-        if (F_status_is_error(status)) return status;
+
+      if (buffer->string[range->start] == f_fss_basic_list_open) {
+        range->start++;
+        graph_first = 0x0;
 
         while (range->start <= range->stop && range->start < buffer->used) {
 
-          if (buffer->string[range->start] == f_fss_eol) {
-            break;
-          }
+          if (buffer->string[range->start] == f_fss_eol) break;
 
           status = f_fss_is_space(*buffer, *range);
+          if (F_status_is_error(status)) break;
 
-          if (F_status_is_error(status)) return status;
           if (status == F_false) break;
 
           status = f_utf_buffer_increment(*buffer, range, 1);
-          if (F_status_is_error(status)) return status;
+          if (F_status_is_error(status)) break;
         } // while
 
-        if (found_newline) {
-          fl_macro_fss_content_return_on_overflow_delimited((*buffer), (*range), (*found), F_none_eos, F_none_stop);
-        }
-        else {
-          fl_macro_fss_content_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop);
-        }
+        if (F_status_is_error(status)) break;
 
+        if (range->start > range->stop || range->start >= buffer->used) break;
+
+        // found a valid object, set stop point to last newline.
         if (buffer->string[range->start] == f_fss_eol) {
-          if (found_newline) {
-            found->array[found->used++].stop = last_newline;
-            range->start = last_newline + 1;
 
-            return FL_fss_found_content;
+          if (newline_last == found->array[found->used].start && buffer->string[found->array[found->used].start] != f_fss_eol) {
+            range->start = newline_last;
+            return FL_fss_found_content_not;
+          }
+          else {
+            range->start = newline_last + 1;
+            found->array[found->used++].stop = newline_last;
           }
 
-          if (!found_newline) {
-            range->start = last_newline;
+          return FL_fss_found_content;
+        }
+
+        if (buffer->string[range->start] == f_fss_eol) {
+          if (graph_first == 0x2) {
+            status = private_fl_fss_delimits_increase(delimits);
+            if (F_status_is_error(status)) break;
+
+            delimits->array[delimits->used++] = comment_delimit;
           }
 
-          return FL_fss_found_content_not;
+          newline_last = range->start;
+          graph_first = 0x1;
         }
 
         continue;
       }
 
-      status = f_utf_buffer_increment(*buffer, range, 1);
-      if (F_status_is_error(status)) return status;
-    } // while
+      if (graph_first == 0x1 && buffer->string[range->start] == f_fss_comment) {
+        start = range->start;
+
+        status = f_fss_seek_to_eol(*buffer, range);
+        if (F_status_is_error(status)) break;
+
+        status = private_fl_fss_ranges_increase(comments);
+        if (F_status_is_error(status)) break;
+
+        if (range->start > range->stop || range->start >= buffer->used) {
+          range->start--;
+        }
+        else {
+          newline_last = range->start;
+        }
+
+        comments->array[comments->used].start = start;
+        comments->array[comments->used++].stop = range->start++;
+        continue;
+      }
 
-    if (found_newline) {
-      found->array[found->used++].stop = last_newline;
-      range->start = last_newline + 1;
+      if (graph_first == 0x1) {
+        status = f_fss_is_space(*buffer, *range);
+        if (F_status_is_error(status)) break;
+
+        if (status == F_false) {
+          graph_first = 0x0;
+        }
+      }
 
-      fl_macro_fss_content_return_on_overflow_delimited((*buffer), (*range), (*found), F_none_eos, F_none_stop);
+      status = f_utf_buffer_increment(*buffer, range, 1);
+      if (F_status_is_error(status)) break;
+    } // while
 
-      return FL_fss_found_content;
+    if (F_status_is_error(status)) {
+      delimits->used = delimits_used;
+      comments->used = comments_used;
+      return status;
     }
 
-    fl_macro_fss_content_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop);
+    found->array[found->used++].stop = range->start - 1;
 
-    return FL_fss_found_content_not;
+    fl_macro_fss_content_return_on_overflow_delimited((*buffer), (*range), (*found), F_none_eos, F_none_stop);
+
+    return FL_fss_found_content;
   }
 #endif // _di_fl_fss_basic_list_content_read_
 
@@ -820,7 +844,16 @@ extern "C" {
       status = private_fl_fss_destination_increase(destination);
       if (F_status_is_error(status)) return status;
 
-      destination->string[destination->used++] = f_fss_basic_list_close;
+      // check to see if a newline exists, at the end.
+      if (destination->used) {
+        for (i = destination->used - 1; i > 0; --i) {
+          if (destination->string[i] != f_fss_delimit_placeholder) break;
+        } // for
+      }
+
+      if (!destination->used || destination->string[i] != f_fss_eol) {
+        destination->string[destination->used++] = f_fss_basic_list_close;
+      }
     }
 
     if (range->start > range->stop) {
index fc6689f0586c54e0dffc5e2624d9bcf9d88ea2dd..7af77ec7b99df6c41379c15d19ef9ca258c2cea8 100644 (file)
@@ -94,6 +94,10 @@ extern "C" {
  *   A set of all locations where a valid content was found.
  * @param delimits
  *   A delimits array representing where delimits exist within the buffer.
+ * @param comments
+ *   An array of ranges representing where comments are found within any valid content.
+ *   This only stores comments found within valid content only.
+ *   The comment range will include the trailing newline.
  *
  * @return
  *   FL_fss_found_content on success and content was found (start location is at end of content).
@@ -119,7 +123,7 @@ extern "C" {
  *   Errors (with error bit) from: f_fss_skip_past_space().
  */
 #ifndef _di_fl_fss_basic_list_content_read_
-  extern f_return_status fl_fss_basic_list_content_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits);
+  extern f_return_status fl_fss_basic_list_content_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments);
 #endif // _di_fl_fss_basic_list_content_read_
 
 /**
index 01b2bcef41b3fcb882d58546043503c739b6b070..75ea13d908a1b58d4d91fe00d9cf4e695c05cc87 100644 (file)
@@ -11,6 +11,7 @@ extern "C" {
       if (!buffer) return F_status_set_error(F_parameter);
       if (!range) return F_status_set_error(F_parameter);
       if (!found) return F_status_set_error(F_parameter);
+      if (!delimits) return F_status_set_error(F_parameter);
     #endif // _di_level_1_parameter_checking_
 
     const f_array_length_t delimits_used = delimits->used;
@@ -37,6 +38,7 @@ extern "C" {
       if (!buffer) return F_status_set_error(F_parameter);
       if (!range) return F_status_set_error(F_parameter);
       if (!found) return F_status_set_error(F_parameter);
+      if (!delimits) return F_status_set_error(F_parameter);
     #endif // _di_level_1_parameter_checking_
 
     f_status_t status = F_none;
index 997693b827061e72e598ddc6153162825bfe9852..1892f9347fda283f915da3165375df1e49157310 100644 (file)
@@ -11,6 +11,7 @@ extern "C" {
       if (!buffer) return F_status_set_error(F_parameter);
       if (!range) return F_status_set_error(F_parameter);
       if (!found) return F_status_set_error(F_parameter);
+      if (!delimits) return F_status_set_error(F_parameter);
     #endif // _di_level_1_parameter_checking_
 
     const f_array_length_t delimits_used = delimits->used;
@@ -69,58 +70,62 @@ extern "C" {
       return FL_fss_found_object_not;
     }
 
+    f_string_length_t start = 0;
+    f_string_length_t stop = 0;
+    f_string_length_t slash_first = 0;
+    f_string_length_t slash_count = 0;
+
+    bool graph_first = F_true;
+
     // identify where the object ends.
     while (range->start <= range->stop && range->start < buffer->used && buffer->string[range->start] != f_fss_eol) {
 
       if (buffer->string[range->start] == f_fss_delimit_slash) {
-        f_string_length_t first_slash = range->start;
-        f_string_length_t slash_count = 1;
+        slash_first = range->start;
+        slash_count = 1;
 
         status = f_utf_buffer_increment(*buffer, range, 1);
-        if (F_status_is_error(status)) return status;
+        if (F_status_is_error(status)) break;
 
         while (range->start <= range->stop && range->start < buffer->used && (buffer->string[range->start] == f_fss_delimit_placeholder || buffer->string[range->start] == f_fss_delimit_slash)) {
-          if (buffer->string[range->start] == f_fss_delimit_slash) {
-            slash_count++;
-          }
+
+          if (buffer->string[range->start] == f_fss_delimit_slash) slash_count++;
 
           status = f_utf_buffer_increment(*buffer, range, 1);
-          if (F_status_is_error(status)) return status;
+          if (F_status_is_error(status)) break;
         } // while
 
+        if (F_status_is_error(status)) break;
+
         fl_macro_fss_object_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop);
 
         if (buffer->string[range->start] == f_fss_extended_list_open) {
-          f_string_length_t stop_point = range->start - 1;
-
-          status = f_utf_buffer_increment(*buffer, range, 1);
-          if (F_status_is_error(status)) return status;
+          graph_first = F_false;
+          stop = range->start - 1;
+          range->start++;
 
           while (range->start <= range->stop && range->start < buffer->used) {
 
-            if (buffer->string[range->start] == f_fss_eol || (status = f_fss_is_graph(*buffer, *range)) == F_true) {
-              break;
-            }
+            if (buffer->string[range->start] == f_fss_eol) {
+              status = f_fss_is_graph(*buffer, *range);
+              if (F_status_is_error(status)) break;
 
-            if (F_status_is_error(status)) return status;
+              if (status == F_true) break;
+            }
 
             status = f_utf_buffer_increment(*buffer, range, 1);
-            if (F_status_is_error(status)) return status;
+            if (F_status_is_error(status)) break;
           } // while
 
           fl_macro_fss_object_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop);
 
           if (buffer->string[range->start] == f_fss_eol) {
-            f_string_length_t start = range->start;
+            start = range->start;
 
-            range->start = first_slash;
+            range->start = slash_first;
 
             status = private_fl_fss_delimits_increase_by((slash_count / 2) + 1, delimits);
-
-            if (F_status_is_error(status)) {
-              delimits->used = delimits_used;
-              return status;
-            }
+            if (F_status_is_error(status)) break;
 
             if (slash_count % 2 == 0) {
               while (slash_count > 0) {
@@ -135,10 +140,12 @@ extern "C" {
                 }
 
                 status = f_utf_buffer_increment(*buffer, range, 1);
-                if (F_status_is_error(status)) return status;
+                if (F_status_is_error(status)) break;
               } // while
 
-              found->stop = stop_point;
+              if (F_status_is_error(status)) break;
+
+              found->stop = stop;
               range->start = start + 1;
 
               return FL_fss_found_object;
@@ -148,31 +155,48 @@ extern "C" {
             return FL_fss_found_object_not;
           }
         }
+        else if (graph_first && buffer->string[range->start] == f_fss_comment) {
+          graph_first = F_false;
+
+          // comments may only have whitespace before the '#', therefore only the first slash needs to be delimited.
+          status = private_fl_fss_delimits_increase(delimits);
+          if (F_status_is_error(status)) break;
+
+          delimits->array[delimits->used++] = slash_first;
+          range->start++;
+        }
+        else {
+          graph_first = F_false;
+        }
 
         continue;
       }
       else if (buffer->string[range->start] == f_fss_extended_list_open) {
-        f_string_length_t stop_point = range->start - 1;
+        graph_first = F_false;
+        stop = range->start - 1;
 
         status = f_utf_buffer_increment(*buffer, range, 1);
-        if (F_status_is_error(status)) return status;
+        if (F_status_is_error(status)) break;
 
         while (range->start <= range->stop && range->start < buffer->used) {
+
           if (buffer->string[range->start] == f_fss_eol) break;
 
           status = f_fss_is_space(*buffer, *range);
+          if (F_status_is_error(status)) break;
 
-          if (F_status_is_error(status)) return status;
           if (status == F_false) break;
 
           status = f_utf_buffer_increment(*buffer, range, 1);
-          if (F_status_is_error(status)) return status;
+          if (F_status_is_error(status)) break;
         } // while
 
+        if (F_status_is_error(status)) break;
+
         fl_macro_fss_object_return_on_overflow_delimited((*buffer), (*range), (*found), F_none_eos, F_none_stop);
 
         if (buffer->string[range->start] == f_fss_eol) {
-          found->stop = stop_point;
+          found->stop = stop;
 
           // move the start position to after the EOL.
           range->start++;
@@ -182,33 +206,56 @@ extern "C" {
 
         continue;
       }
+      else if (graph_first) {
+        status = f_fss_is_space(*buffer, *range);
+        if (F_status_is_error(status)) break;
+
+        if (status == F_false) {
+          graph_first = F_false;
+        }
+      }
 
       status = f_utf_buffer_increment(*buffer, range, 1);
-      if (F_status_is_error(status)) return status;
+      if (F_status_is_error(status)) break;
     } // while
 
+    if (F_status_is_error(status)) {
+      delimits->used = delimits_used;
+      return status;
+    }
+
     // seek to the end of the line when no valid object is found.
     while (range->start <= range->stop && range->start < buffer->used && buffer->string[range->start] != f_fss_eol) {
 
       status = f_utf_buffer_increment(*buffer, range, 1);
-      if (F_status_is_error(status)) return status;
+
+      if (F_status_is_error(status)) {
+        delimits->used = delimits_used;
+        return status;
+      }
     } // while
 
     fl_macro_fss_object_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, F_data_not_eos, F_data_not_stop);
 
     status = f_utf_buffer_increment(*buffer, range, 1);
-    if (F_status_is_error(status)) return status;
+
+    if (F_status_is_error(status)) {
+      delimits->used = delimits_used;
+      return status;
+    }
 
     return FL_fss_found_object_not;
   }
 #endif // _di_fl_fss_extended_list_object_read_
 
 #ifndef _di_fl_fss_extended_list_content_read_
-  f_return_status fl_fss_extended_list_content_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_nest_t *found, f_fss_delimits_t *delimits) {
+  f_return_status fl_fss_extended_list_content_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_nest_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments) {
     #ifndef _di_level_1_parameter_checking_
       if (!buffer) return F_status_set_error(F_parameter);
       if (!range) return F_status_set_error(F_parameter);
       if (!found) return F_status_set_error(F_parameter);
+      if (!delimits) return F_status_set_error(F_parameter);
+      if (!comments) return F_status_set_error(F_parameter);
     #endif // _di_level_1_parameter_checking_
 
     const f_array_length_t found_used = found->used;
@@ -239,13 +286,15 @@ extern "C" {
     }
 
     const f_array_length_t delimits_used = delimits->used;
+    const f_array_length_t comments_used = comments->used;
 
     f_array_length_t depth = 0;
     f_array_length_t position = 0;
 
     f_string_length_t position_previous = range->start;
     f_string_length_t line_start = range->start;
-    f_string_length_t last_newline = range->start;
+    f_string_length_t newline_last = range->start;
+    f_string_length_t comment_delimit = 0;
 
     f_string_length_t slash_first = 0;
     f_string_length_t slash_last = 0;
@@ -255,6 +304,8 @@ extern "C" {
 
     bool is_open = F_false;
 
+    uint8_t graph_first = 0x0; // 0x0 = false, 0x1 = true, 0x2 = false, but there is a delimited comment, comment_delimit is set.
+
     // initialize depth 1 start position.
     // positions_start.used is used as a max depth (such that positions_start.used == max depth + 1).
     positions_start.array[0] = range->start;
@@ -263,12 +314,19 @@ extern "C" {
     while (range->start <= range->stop && range->start < buffer->used) {
 
       if (buffer->string[range->start] == f_fss_eol) {
-        last_newline = range->start;
-        position_previous = range->start;
-        range->start++;
+        if (graph_first == 0x2) {
+          status = private_fl_fss_delimits_increase(delimits);
+          if (F_status_is_error(status)) break;
+
+          delimits->array[delimits->used++] = comment_delimit;
+        }
+
+        newline_last = range->start;
+        position_previous = range->start++;
+        graph_first = 0x1;
 
         if (depth > 0) {
-          fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, positions_start, objects, F_unterminated_nest_eos, F_unterminated_nest_stop);
+          fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, F_unterminated_nest_eos, F_unterminated_nest_stop);
         }
         else {
           fl_macro_fss_nest_return_on_overflow_delimited((*buffer), (*range), (*found), positions_start, objects, F_none_eos, F_none_stop);
@@ -284,40 +342,28 @@ extern "C" {
         slash_count = 1;
 
         position_previous = range->start;
-        status = f_utf_buffer_increment(*buffer, range, 1);
-
-        if (F_status_is_error(status)) {
-          f_macro_string_lengths_t_delete_simple(positions_start);
-          f_macro_fss_objects_t_delete_simple(objects);
 
-          delimits->used = delimits_used;
-          return status;
-        }
+        status = f_utf_buffer_increment(*buffer, range, 1);
+        if (F_status_is_error(status)) break;
 
         while (range->start <= range->stop && range->start < buffer->used && (buffer->string[range->start] == f_fss_delimit_placeholder || buffer->string[range->start] == f_fss_delimit_slash)) {
           position_previous = range->start;
 
           if (buffer->string[range->start] == f_fss_delimit_slash) {
-            slash_last = range->start;
-            slash_count++;
+            slash_last = range->start++;
           }
 
           status = f_utf_buffer_increment(*buffer, range, 1);
-
-          if (F_status_is_error(status)) {
-            f_macro_string_lengths_t_delete_simple(positions_start);
-            f_macro_fss_objects_t_delete_simple(objects);
-
-            delimits->used = delimits_used;
-            return status;
-          }
+          if (F_status_is_error(status)) break;
         } // while
 
+        if (F_status_is_error(status)) break;
+
         if (depth > 0) {
-          fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, positions_start, objects, F_unterminated_nest_eos, F_unterminated_nest_stop);
+          fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, F_unterminated_nest_eos, F_unterminated_nest_stop);
         }
         else {
-          fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, positions_start, objects, F_data_not_eos, F_data_not_stop);
+          fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, F_data_not_eos, F_data_not_stop);
         }
 
         // All slashes for an open are delimited (because it could represent a slash in the object name).
@@ -326,65 +372,72 @@ extern "C" {
         // for example '}' = valid close, '\}' represents '}', '\\}' represents '\}', '\\\}' represents '\\}', '\\\\}' represents '\\\}', and so on..
         // When slash is odd and a (delimited) valid open/close is found, then save delimited positions and continue.
         if (buffer->string[range->start] == f_fss_eol) {
-          last_newline = range->start;
-          position_previous = range->start;
-          range->start++;
+          if (graph_first == 0x2) {
+            status = private_fl_fss_delimits_increase(delimits);
+            if (F_status_is_error(status)) break;
+
+            delimits->array[delimits->used++] = comment_delimit;
+          }
+
+          newline_last = range->start;
+          position_previous = range->start++;
           line_start = range->start;
+          graph_first = 0x1;
         }
         else if (buffer->string[range->start] == f_fss_extended_list_open || buffer->string[range->start] == f_fss_extended_list_close) {
           before_list_open = position_previous;
           is_open = F_false;
+          graph_first = 0x0;
 
           if (buffer->string[range->start] == f_fss_extended_list_open) {
             is_open = F_true;
           }
 
-          position_previous = range->start;
-          range->start++;
+          position_previous = range->start++;
 
           while (range->start <= range->stop && range->start < buffer->used) {
 
             if (buffer->string[range->start] == f_fss_eol) {
-              last_newline = range->start;
-              line_start = range->start + 1;
-              break;
-            }
+              if (graph_first == 0x2) {
+                status = private_fl_fss_delimits_increase(delimits);
+                if (F_status_is_error(status)) break;
+
+                delimits->array[delimits->used++] = comment_delimit;
+              }
 
-            if (buffer->string[range->start] != f_fss_delimit_placeholder && (status = f_fss_is_space(*buffer, *range)) == F_false) {
+              newline_last = range->start;
+              line_start = range->start + 1;
+              graph_first = 0x1;
               break;
             }
 
-            if (F_status_is_error(status)) {
-              f_macro_string_lengths_t_delete_simple(positions_start);
-              f_macro_fss_objects_t_delete_simple(objects);
+            if (buffer->string[range->start] != f_fss_delimit_placeholder) {
+              status = f_fss_is_space(*buffer, *range);
+              if (F_status_is_error(status)) break;
 
-              delimits->used = delimits_used;
-              return status;
+              if (status == F_false) break;
             }
 
             position_previous = range->start;
-            status = f_utf_buffer_increment(*buffer, range, 1);
-
-            if (F_status_is_error(status)) {
-              f_macro_string_lengths_t_delete_simple(positions_start);
-              f_macro_fss_objects_t_delete_simple(objects);
 
-              delimits->used = delimits_used;
-              return status;
-            }
+            status = f_utf_buffer_increment(*buffer, range, 1);
+            if (F_status_is_error(status)) break;
           } // while
 
+          if (F_status_is_error(status)) break;
+
           if (depth > 0) {
-            fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, positions_start, objects, F_unterminated_nest_eos, F_unterminated_nest_stop);
+            fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, F_unterminated_nest_eos, F_unterminated_nest_stop);
           }
           else {
-            fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, positions_start, objects, F_data_not_eos, F_data_not_stop);
+            fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, F_data_not_eos, F_data_not_stop);
           }
 
           // this is a valid object open/close that has been delimited, save the slash delimit positions.
           if (buffer->string[range->start] == f_fss_eol) {
-            last_newline = range->start;
+            newline_last = range->start;
             line_start = range->start + 1;
+            graph_first = 0x1;
 
             if (is_open) {
               bool is_object = F_false;
@@ -396,55 +449,39 @@ extern "C" {
               range->start = slash_first;
 
               status = private_fl_fss_delimits_increase_by((slash_count / 2) + 1, delimits);
-
-              if (F_status_is_error(status)) {
-                f_macro_string_lengths_t_delete_simple(positions_start);
-                f_macro_fss_objects_t_delete_simple(objects);
-
-                range->start = last_newline;
-                delimits->used = delimits_used;
-                return status;
-              }
+              if (F_status_is_error(status)) break;
 
               // apply slash delimits, only slashes and placeholders should be present.
               while (slash_count > 0) {
 
                 if (buffer->string[range->start] == f_fss_delimit_slash) {
                   if (slash_count % 2 == 1) {
-                    delimits->array[delimits->used] = range->start;
-                    delimits->used++;
+                    delimits->array[delimits->used++] = range->start;
                   }
 
                   slash_count--;
                 }
 
                 // Delimit slashes and placeholders are required to be in the ASCII range.
-                position_previous = range->start;
-                range->start++;
+                position_previous = range->start++;
               } // while
 
+              if (F_status_is_error(status)) break;
+
               // when slashes are even, the object is valid and needs to be processed.
               if (is_object) {
                 depth++;
 
                 if (depth > positions_start.size) {
                   f_macro_string_lengths_t_resize(status, positions_start, positions_start.size + f_fss_default_allocation_step);
-
-                  if (F_status_is_error(status)) {
-                    f_macro_string_lengths_t_delete_simple(positions_start);
-                    f_macro_fss_objects_t_delete_simple(objects);
-
-                    range->start = last_newline;
-                    delimits->used = delimits_used;
-                    return status;
-                  }
+                  if (F_status_is_error(status)) break;
                 }
 
                 if (positions_start.used < depth) {
                   positions_start.used = depth;
                 }
 
-                positions_start.array[depth] = last_newline + 1;
+                positions_start.array[depth] = newline_last + 1;
 
                 objects.array[depth].start = line_start;
                 objects.array[depth].stop = before_list_open;
@@ -452,77 +489,54 @@ extern "C" {
             }
             else {
               status = private_fl_fss_delimits_increase(delimits);
+              if (F_status_is_error(status)) break;
 
-              if (F_status_is_error(status)) {
-                f_macro_string_lengths_t_delete_simple(positions_start);
-                f_macro_fss_objects_t_delete_simple(objects);
-
-                range->start = last_newline;
-                delimits->used = delimits_used;
-                return status;
-              }
-
-              delimits->array[delimits->used] = slash_last;
-              delimits->used++;
+              delimits->array[delimits->used++] = slash_last;
             }
 
-            range->start = last_newline;
+            range->start = newline_last;
           }
         }
+        else if (graph_first == 0x1 && buffer->string[range->start] == f_fss_comment) {
+          graph_first = 0x2;
+          comment_delimit = slash_first;
+        }
+        else {
+          graph_first = 0x0;
+        }
       }
       else if (buffer->string[range->start] == f_fss_extended_list_open) {
+        graph_first = 0x0;
         before_list_open = position_previous;
-
         position_previous = range->start;
-        status = f_utf_buffer_increment(*buffer, range, 1);
-
-        if (F_status_is_error(status)) {
-          f_macro_string_lengths_t_delete_simple(positions_start);
-          f_macro_fss_objects_t_delete_simple(objects);
 
-          delimits->used = delimits_used;
-          return status;
-        }
+        status = f_utf_buffer_increment(*buffer, range, 1);
+        if (F_status_is_error(status)) break;
 
         while (range->start <= range->stop && range->start < buffer->used) {
 
-          if (buffer->string[range->start] == f_fss_eol) {
-            break;
-          }
+          if (buffer->string[range->start] == f_fss_eol) break;
 
           if (buffer->string[range->start] != f_fss_delimit_placeholder) {
             status = f_fss_is_space(*buffer, *range);
+            if (F_status_is_error(status)) break;
 
-            if (F_status_is_error(status)) {
-              f_macro_string_lengths_t_delete_simple(positions_start);
-              f_macro_fss_objects_t_delete_simple(objects);
-
-              delimits->used = delimits_used;
-              return status;
-            }
-
-            if (status == F_false) {
-              break;
-            }
+            if (status == F_false) break;
           }
 
           position_previous = range->start;
-          status = f_utf_buffer_increment(*buffer, range, 1);
 
-          if (F_status_is_error(status)) {
-            f_macro_string_lengths_t_delete_simple(positions_start);
-            f_macro_fss_objects_t_delete_simple(objects);
-
-            delimits->used = delimits_used;
-            return status;
-          }
+          status = f_utf_buffer_increment(*buffer, range, 1);
+          if (F_status_is_error(status)) break;
         } // while
 
+        if (F_status_is_error(status)) break;
+
         if (depth > 0) {
-          fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, positions_start, objects, F_unterminated_nest_eos, F_unterminated_nest_stop);
+          fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, F_unterminated_nest_eos, F_unterminated_nest_stop);
         }
         else {
-          fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, positions_start, objects, F_data_not_eos, F_data_not_stop);
+          fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, F_data_not_eos, F_data_not_stop);
         }
 
         if (buffer->string[range->start] == f_fss_eol) {
@@ -530,24 +544,10 @@ extern "C" {
 
           if (depth >= positions_start.size) {
             f_macro_string_lengths_t_resize(status, positions_start, positions_start.size + f_fss_default_allocation_step);
-
-            if (F_status_is_error(status)) {
-              f_macro_string_lengths_t_delete_simple(positions_start);
-              f_macro_fss_objects_t_delete_simple(objects);
-
-              delimits->used = delimits_used;
-              return status;
-            }
+            if (F_status_is_error(status)) break;
 
             f_macro_fss_objects_t_resize(status, objects, objects.size + f_fss_default_allocation_step);
-
-            if (F_status_is_error(status)) {
-              f_macro_string_lengths_t_delete_simple(positions_start);
-              f_macro_fss_objects_t_delete_simple(objects);
-
-              delimits->used = delimits_used;
-              return status;
-            }
+            if (F_status_is_error(status)) break;
           }
 
           if (positions_start.used <= depth) {
@@ -559,29 +559,38 @@ extern "C" {
           objects.array[depth].start = line_start;
           objects.array[depth].stop = before_list_open;
 
-          last_newline = range->start;
+          if (graph_first == 0x2) {
+            status = private_fl_fss_delimits_increase(delimits);
+            if (F_status_is_error(status)) break;
+
+            delimits->array[delimits->used++] = comment_delimit;
+          }
+
+          newline_last = range->start;
           line_start = range->start + 1;
+          graph_first = 0x1;
         }
         else {
 
           // No valid object close found, seek until EOL.
           status = f_fss_seek_to_eol(*buffer, range);
+          if (F_status_is_error(status)) break;
 
-          if (F_status_is_error(status)) {
-            f_macro_string_lengths_t_delete_simple(positions_start);
-            f_macro_fss_objects_t_delete_simple(objects);
+          if (graph_first == 0x2) {
+            status = private_fl_fss_delimits_increase(delimits);
+            if (F_status_is_error(status)) break;
 
-            delimits->used = delimits_used;
-            return status;
+            delimits->array[delimits->used++] = comment_delimit;
           }
 
-          last_newline = range->start;
+          newline_last = range->start;
           line_start = range->start + 1;
+          graph_first = 0x1;
 
           while (range->start <= range->stop && range->start < buffer->used) {
 
             if (buffer->string[range->start] == f_fss_eol) {
-              last_newline = range->start;
+              newline_last = range->start;
               line_start = range->start + 1;
               break;
             }
@@ -589,38 +598,28 @@ extern "C" {
             position_previous = range->start;
 
             status = f_utf_buffer_increment(*buffer, range, 1);
-
-            if (F_status_is_error(status)) {
-              f_macro_string_lengths_t_delete_simple(positions_start);
-              f_macro_fss_objects_t_delete_simple(objects);
-
-              delimits->used = delimits_used;
-              return status;
-            }
+            if (F_status_is_error(status)) break;
           } // while
 
+          if (F_status_is_error(status)) break;
+
           if (depth > 0) {
-            fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, positions_start, objects, F_unterminated_nest_eos, F_unterminated_nest_stop);
+            fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, F_unterminated_nest_eos, F_unterminated_nest_stop);
           }
           else {
-            fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, positions_start, objects, F_data_not_eos, F_data_not_stop);
+            fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, F_data_not_eos, F_data_not_stop);
           }
         }
       }
       else if (buffer->string[range->start] == f_fss_extended_list_close) {
+        graph_first = 0x0;
+
         while (range->start <= range->stop && range->start < buffer->used) {
 
           position_previous = range->start;
 
           status = f_utf_buffer_increment(*buffer, range, 1);
-
-          if (F_status_is_error(status)) {
-            f_macro_string_lengths_t_delete_simple(positions_start);
-            f_macro_fss_objects_t_delete_simple(objects);
-
-            delimits->used = delimits_used;
-            return status;
-          }
+          if (F_status_is_error(status)) break;
 
           if (buffer->string[range->start] == f_fss_eol) {
             break;
@@ -628,14 +627,7 @@ extern "C" {
 
           if (buffer->string[range->start] != f_fss_delimit_placeholder) {
             status = f_fss_is_space(*buffer, *range);
-
-            if (F_status_is_error(status)) {
-              f_macro_string_lengths_t_delete_simple(positions_start);
-              f_macro_fss_objects_t_delete_simple(objects);
-
-              delimits->used = delimits_used;
-              return status;
-            }
+            if (F_status_is_error(status)) break;
 
             if (status == F_false) {
               break;
@@ -643,48 +635,29 @@ extern "C" {
           }
         } // while
 
+        if (F_status_is_error(status)) break;
+
         if (depth > 0) {
-          fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, positions_start, objects, F_unterminated_nest_eos, F_unterminated_nest_stop);
+          fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, F_unterminated_nest_eos, F_unterminated_nest_stop);
         }
         else {
-          fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, positions_start, objects, F_data_not_eos, F_data_not_stop);
+          fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, F_data_not_eos, F_data_not_stop);
         }
 
         if (buffer->string[range->start] == f_fss_eol) {
           status = private_fl_fss_nest_increase(found);
-
-          if (F_status_is_error(status)) {
-            f_macro_string_lengths_t_delete_simple(positions_start);
-            f_macro_fss_objects_t_delete_simple(objects);
-
-            delimits->used = delimits_used;
-            return status;
-          }
+          if (F_status_is_error(status)) break;
 
           if (found->depth[depth].used == found->depth[depth].size) {
             f_macro_fss_items_t_resize(status, found->depth[depth], found->depth[depth].size + f_fss_default_allocation_step);
-
-            if (F_status_is_error(status)) {
-              f_macro_string_lengths_t_delete_simple(positions_start);
-              f_macro_fss_objects_t_delete_simple(objects);
-
-              delimits->used = delimits_used;
-              return status;
-            }
+            if (F_status_is_error(status)) break;
           }
 
           position = found->depth[depth].used;
 
           if (found->depth[depth].array[position].content.size != 1) {
             f_macro_fss_content_t_resize(status, found->depth[depth].array[position].content, 1);
-
-            if (F_status_is_error(status)) {
-              f_macro_string_lengths_t_delete_simple(positions_start);
-              f_macro_fss_objects_t_delete_simple(objects);
-
-              delimits->used = delimits_used;
-              return status;
-            }
+            if (F_status_is_error(status)) break;
           }
 
           // only assign object positions for nested objects.
@@ -694,7 +667,7 @@ extern "C" {
           }
 
           found->depth[depth].array[position].content.array[0].start = positions_start.array[depth];
-          found->depth[depth].array[position].content.array[0].stop = last_newline;
+          found->depth[depth].array[position].content.array[0].stop = newline_last;
           found->depth[depth].array[position].content.used = 1;
 
           if (position >= found->depth[depth].used) {
@@ -705,19 +678,20 @@ extern "C" {
             found->used = depth + 1;
           }
 
-          last_newline = range->start;
+          if (graph_first == 0x2) {
+            status = private_fl_fss_delimits_increase(delimits);
+            if (F_status_is_error(status)) break;
+
+            delimits->array[delimits->used++] = comment_delimit;
+          }
+
+          newline_last = range->start;
           line_start = range->start + 1;
+          graph_first = 0x1;
 
           if (!depth) {
             status = f_utf_buffer_increment(*buffer, range, 1);
-
-            if (F_status_is_error(status)) {
-              f_macro_string_lengths_t_delete_simple(positions_start);
-              f_macro_fss_objects_t_delete_simple(objects);
-
-              delimits->used = delimits_used;
-              return status;
-            }
+            if (F_status_is_error(status)) break;
 
             fl_macro_fss_nest_return_on_overflow_delimited((*buffer), (*range), (*found), positions_start, objects, F_none_eos, F_none_stop)
 
@@ -735,45 +709,78 @@ extern "C" {
           while (range->start <= range->stop && range->start < buffer->used) {
 
             if (buffer->string[range->start] == f_fss_eol) {
-              last_newline = range->start;
+              if (graph_first == 0x2) {
+                status = private_fl_fss_delimits_increase(delimits);
+                if (F_status_is_error(status)) break;
+
+                delimits->array[delimits->used++] = comment_delimit;
+              }
+
+              newline_last = range->start;
               line_start = range->start + 1;
+              graph_first = 0x1;
               break;
             }
 
             position_previous = range->start;
 
             status = f_utf_buffer_increment(*buffer, range, 1);
-
-            if (F_status_is_error(status)) {
-              f_macro_string_lengths_t_delete_simple(positions_start);
-              f_macro_fss_objects_t_delete_simple(objects);
-
-              delimits->used = delimits_used;
-              return status;
-            }
+            if (F_status_is_error(status)) break;
           } // while
 
+          if (F_status_is_error(status)) break;
+
           if (depth > 0) {
-            fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, positions_start, objects, F_unterminated_nest_eos, F_unterminated_nest_stop)
+            fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, F_unterminated_nest_eos, F_unterminated_nest_stop)
           }
           else {
-            fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, positions_start, objects, F_data_not_eos, F_data_not_stop)
+            fl_macro_fss_nest_return_on_overflow((*buffer), (*range), (*found), (*delimits), delimits_used, (*comments), comments_used, positions_start, objects, F_data_not_eos, F_data_not_stop)
           }
         }
       }
+      else if (graph_first == 0x1 && buffer->string[range->start] == f_fss_comment) {
+        position = range->start;
+
+        status = f_fss_seek_to_eol(*buffer, range);
+        if (F_status_is_error(status)) break;
+
+        status = private_fl_fss_ranges_increase(comments);
+        if (F_status_is_error(status)) break;
+
+        if (range->start > range->stop || range->start >= buffer->used) {
+          range->start--;
+        }
+        else {
+          if (graph_first == 0x2) {
+            status = private_fl_fss_delimits_increase(delimits);
+            if (F_status_is_error(status)) break;
+
+            delimits->array[delimits->used++] = comment_delimit;
+          }
+
+          newline_last = range->start;
+          graph_first = 0x1;
+        }
+
+        comments->array[comments->used].start = position;
+        comments->array[comments->used++].stop = range->start++;
+        continue;
+      }
       else if (buffer->string[range->start] != f_fss_eol) {
         position_previous = range->start;
 
-        status = f_utf_buffer_increment(*buffer, range, 1);
-
-        if (F_status_is_error(status)) {
-          f_macro_string_lengths_t_delete_simple(positions_start);
-          f_macro_fss_objects_t_delete_simple(objects);
+        if (graph_first == 0x1) {
+          status = f_fss_is_space(*buffer, *range);
+          if (F_status_is_error(status)) break;
 
-          delimits->used = delimits_used;
-          return status;
+          if (status == F_false) {
+            graph_first = 0x0;
+          }
         }
 
+        status = f_utf_buffer_increment(*buffer, range, 1);
+        if (F_status_is_error(status)) break;
+
         if (range->start >= buffer->used || range->start > range->stop) {
           break;
         }
@@ -784,19 +791,19 @@ extern "C" {
       position_previous = range->start;
 
       status = f_utf_buffer_increment(*buffer, range, 1);
-
-      if (F_status_is_error(status)) {
-        f_macro_string_lengths_t_delete_simple(positions_start);
-        f_macro_fss_objects_t_delete_simple(objects);
-
-        delimits->used = delimits_used;
-        return status;
-      }
+      if (F_status_is_error(status)) break;
     } // while
 
     f_macro_string_lengths_t_delete_simple(positions_start);
     f_macro_fss_objects_t_delete_simple(objects);
 
+    delimits->used = delimits_used;
+    comments->used = comments_used;
+
+    if (F_status_is_error(status)) {
+      return status;
+    }
+
     if (range->start > range->stop) {
       if (!depth) {
         return F_status_set_error(F_unterminated_stop);
index 084a3b08508978c62fd1d4c83ff2fccd918f467a..d64d668dcf649045377c7b4d6c8429056ec3ea1c 100644 (file)
@@ -98,6 +98,10 @@ extern "C" {
  *   A set of all locations where a valid content was found.
  * @param delimits
  *   A delimits array representing where delimits exist within the buffer.
+ * @param comments
+ *   An array of ranges representing where comments are found within any valid content.
+ *   This only stores comments found within valid content only.
+ *   The comment range will include the trailing newline.
  *
  * @return
  *   FL_fss_found_content on success and content was found (start location is at end of content).
@@ -122,7 +126,7 @@ extern "C" {
  *   Errors (with error bit) from: f_fss_skip_past_space().
  */
 #ifndef _di_fl_fss_extended_list_content_read_
-  extern f_return_status fl_fss_extended_list_content_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_nest_t *found, f_fss_delimits_t *delimits);
+  extern f_return_status fl_fss_extended_list_content_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_nest_t *found, f_fss_delimits_t *delimits, f_fss_comments_t *comments);
 #endif // _di_fl_fss_extended_list_content_read_
 
 /**
index be6b09485a4fa5b49f54a677aae9b8374069dec1..b4a37d51d875c9ceb6f8cbd5bfd7315446c70727 100644 (file)
@@ -54,6 +54,22 @@ extern "C" {
     }
 #endif // _di_fl_macro_fss_content_return_on_overflow_
 
+#ifndef _di_fl_macro_fss_content_with_comments_return_on_overflow_
+  #define fl_macro_fss_content_with_comments_return_on_overflow(buffer, range, found, delimits, delimits_used, comments, comments_used, eos_status, stop_status) \
+    if (range.start >= buffer.used) { \
+      delimits.used = delimits_used; \
+      comments.used = comments_used; \
+      found.array[found.used].stop = buffer.used - 1; \
+      return eos_status; \
+    } \
+    else if (range.start > range.stop) { \
+      delimits.used = delimits_used; \
+      comments.used = comments_used; \
+      found.array[found.used].stop = range.stop; \
+      return stop_status; \
+    }
+#endif // _di_fl_macro_fss_content_with_comments_return_on_overflow_
+
 #ifndef _di_fl_macro_fss_content_return_on_overflow_delimited_
   #define fl_macro_fss_content_return_on_overflow_delimited(buffer, range, found, eos_status, stop_status) \
     if (range.start >= buffer.used) { \
@@ -67,19 +83,19 @@ extern "C" {
 #endif // _di_fl_macro_fss_content_return_on_overflow_delimited_
 
 #ifndef _di_fl_macro_fss_nest_return_on_overflow_
-  #define fl_macro_fss_nest_return_on_overflow(buffer, range, found, delimits, delimits_used, positions, objects, eos_status, stop_status) \
+  #define fl_macro_fss_nest_return_on_overflow(buffer, range, found, delimits, delimits_used, comments, comments_used, positions, objects, eos_status, stop_status) \
     if (range.start >= buffer.used) { \
       delimits.used = delimits_used; \
+      comments.used = comments_used; \
       f_macro_string_lengths_t_delete_simple(positions); \
       f_macro_fss_objects_t_delete_simple(objects); \
-      \
       return eos_status; \
     } \
     else if (range.start > range.stop) { \
       delimits.used = delimits_used; \
+      comments.used = comments_used; \
       f_macro_string_lengths_t_delete_simple(positions); \
       f_macro_fss_objects_t_delete_simple(objects); \
-      \
       return stop_status; \
     }
 #endif // _di_fl_macro_fss_nest_return_on_overflow_
@@ -89,13 +105,11 @@ extern "C" {
     if (range.start >= buffer.used) { \
       f_macro_string_lengths_t_delete_simple(positions); \
       f_macro_fss_objects_t_delete_simple(objects); \
-      \
       return eos_status; \
     } \
     else if (range.start > range.stop) { \
       f_macro_string_lengths_t_delete_simple(positions); \
       f_macro_fss_objects_t_delete_simple(objects); \
-      \
       return stop_status; \
     }
 #endif // _di_fl_macro_fss_nest_return_on_overflow_delimited_
index 14fe54aa2a1df3bdfad26e3aac9313a556a55c44..2dde3eebe061d8cb10f70f5c2993f811f0c9d146 100644 (file)
@@ -8,6 +8,7 @@
  * Provides fss-specific status definitions.
  *
  * Warning: changing status codes will break abi, so recompile every file that includes and uses these error codes when this gets changed.
+ * @fixme this can be moved into level_0 because level_0/status is now a special case that can be included by other level_0 projects.
  */
 #ifndef _FL_fss_status_h
 #define _FL_fss_status_h
index d84d1c77678463e9de15781269420066756bd8fe..67966dcadbd13272b5d4d433055743b98461ebe4 100644 (file)
@@ -5,7 +5,7 @@ extern "C" {
 #endif
 
 #ifndef _di_fll_fss_basic_list_read_
-  f_return_status fll_fss_basic_list_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) {
+  f_return_status fll_fss_basic_list_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments) {
     #ifndef _di_level_2_parameter_checking_
       if (!buffer) return F_status_set_error(F_parameter);
       if (!range) return F_status_set_error(F_parameter);
@@ -65,11 +65,9 @@ extern "C" {
 
         if (status == FL_fss_found_object) {
           found_data = F_true;
-          status = fl_fss_basic_list_content_read(buffer, range, &contents->array[contents->used], contents_delimits ? contents_delimits : objects_delimits);
 
-          if (F_status_is_error(status)) {
-            return status;
-          }
+          status = fl_fss_basic_list_content_read(buffer, range, &contents->array[contents->used], contents_delimits ? contents_delimits : objects_delimits, comments);
+          if (F_status_is_error(status)) return status;
 
           break;
         }
index 1cd4cfafc65dd5a2cf3dde86bb37da6e588af5d6..4142638ebc24cf5a929216bc5d075a1cbecc0226 100644 (file)
@@ -46,6 +46,9 @@ extern "C" {
  *   (optional) An array of delimits for contents detected during processing.
  *   The caller is expected to decide if and when to process them.
  *   Set pointer address to 0 and all delimits will instead utilize objects_delimits.
+ * @param comments
+ *   An array of ranges representing where comments are found within any valid content.
+ *   This only stores comments found within valid content only.
  *
  * @return
  *   F_none on success.
@@ -64,7 +67,7 @@ extern "C" {
  *   Errors (with error bit) from: fl_fss_basic_list_object_read().
  */
 #ifndef _di_fll_fss_basic_list_read_
-  extern f_return_status fll_fss_basic_list_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits);
+  extern f_return_status fll_fss_basic_list_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments);
 #endif // _di_fll_fss_basic_list_read_
 
 /**
index 45d1969dd383d816f3b29ffae5b46f897a7e826f..b8dae82747ea0865d52fefcefb523cfd235a4b2a 100644 (file)
@@ -12,6 +12,7 @@ extern "C" {
       if (!objects) return F_status_set_error(F_parameter);
       if (!contents) return F_status_set_error(F_parameter);
       if (!objects_delimits) return F_status_set_error(F_parameter);
+      if (!contents_delimits) return F_status_set_error(F_parameter);
     #endif // _di_level_2_parameter_checking_
 
     f_status_t status = F_none;
index 64316f5d46b55ed1f9f83a6cd3ead0ee0f2f118a..852f9adc67324001ecd3b03f402e6806a16f0ad3 100644 (file)
@@ -5,12 +5,14 @@ extern "C" {
 #endif
 
 #ifndef _di_fll_fss_extended_list_read_
-  f_return_status fll_fss_extended_list_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_nest_t *nest, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) {
+  f_return_status fll_fss_extended_list_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_nest_t *nest, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments) {
     #ifndef _di_level_3_parameter_checking_
       if (!buffer) return F_status_set_error(F_parameter);
       if (!range) return F_status_set_error(F_parameter);
       if (!nest) return F_status_set_error(F_parameter);
       if (!objects_delimits) return F_status_set_error(F_parameter);
+      if (!contents_delimits) return F_status_set_error(F_parameter);
+      if (!comments) return F_status_set_error(F_parameter);
     #endif // _di_level_3_parameter_checking_
 
     f_status_t status = F_none;
@@ -63,7 +65,7 @@ extern "C" {
         if (status == FL_fss_found_object) {
           found_data = F_true;
 
-          status = fl_fss_extended_list_content_read(buffer, range, nest, contents_delimits ? contents_delimits : objects_delimits);
+          status = fl_fss_extended_list_content_read(buffer, range, nest, contents_delimits ? contents_delimits : objects_delimits, comments);
 
           break;
         }
index 5510a2227c44151962d68002b36232ec1fcfe401..253e9ec74726ad36f80f048dd42fb278e971bd5d 100644 (file)
@@ -43,6 +43,9 @@ extern "C" {
  *   (optional) An array of delimits for contents detected during processing.
  *   The caller is expected to decide if and when to process them.
  *   Set pointer address to 0 and all delimits will instead utilize objects_delimits.
+ * @param comments
+ *   An array of ranges representing where comments are found within any valid content.
+ *   This only stores comments found within valid content only.
  *
  * @return
  *   F_none on success (both valid object and valid content found with start location is at end of content).
@@ -68,7 +71,7 @@ extern "C" {
  *   Errors (with error bit) from: fl_fss_extended_list_object_read().
  */
 #ifndef _di_fll_fss_extended_list_read_
-  extern f_return_status fll_fss_extended_list_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_nest_t *nest, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits);
+  extern f_return_status fll_fss_extended_list_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_nest_t *nest, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments);
 #endif // _di_fll_fss_extended_list_read_
 
 /**
index b24b3c5626118249ca4ac515f9f0b65698c6efb1..d30f10fb418977e581c02c2e7c9c45215c4fe28e 100644 (file)
@@ -385,6 +385,7 @@ extern "C" {
       fss_basic_list_read_depths_t depths = fss_basic_list_read_depths_t_initialize;
 
       f_fss_delimits_t delimits = f_fss_delimits_t_initialize;
+      f_fss_comments_t comments = f_fss_comments_t_initialize;
 
       f_string_length_t original_size = data->quantity.total;
 
@@ -400,6 +401,7 @@ extern "C" {
       if (F_status_is_error_not(status) && depths.array[0].depth > 0) {
         macro_fss_basic_list_read_depths_t_delete_simple(depths);
         f_macro_fss_delimits_t_delete_simple(delimits);
+        f_macro_fss_comments_t_delete_simple(comments);
 
         if (data->parameters[fss_basic_list_read_parameter_total].result == f_console_result_found) {
           fprintf(data->output.stream, "0%c", f_string_eol[0]);
@@ -428,7 +430,7 @@ extern "C" {
           fll_error_file_print(data->error, F_status_set_fine(status), "f_file_read", F_true, "-", "read", fll_error_file_type_pipe);
         }
         else {
-          status = fss_basic_list_read_main_process_file(arguments, data, "-", depths, &delimits);
+          status = fss_basic_list_read_main_process_file(arguments, data, "-", depths, &delimits, &comments);
 
           if (F_status_is_error(status)) {
             fll_error_file_print(data->error, F_status_set_fine(status), "fss_basic_list_read_main_process_file", F_true, "-", "read", fll_error_file_type_pipe);
@@ -484,7 +486,7 @@ extern "C" {
             break;
           }
 
-          status = fss_basic_list_read_main_process_file(arguments, data, arguments.argv[data->remaining.array[i]], depths, &delimits);
+          status = fss_basic_list_read_main_process_file(arguments, data, arguments.argv[data->remaining.array[i]], depths, &delimits, &comments);
 
           if (F_status_is_error(status)) {
             fll_error_file_print(data->error, F_status_set_fine(status), "fss_basic_list_read_main_process_file", F_true, arguments.argv[data->remaining.array[i]], "read", fll_error_file_type_file);
@@ -506,6 +508,7 @@ extern "C" {
 
       macro_fss_basic_list_read_depths_t_delete_simple(depths);
       f_macro_fss_delimits_t_delete_simple(delimits);
+      f_macro_fss_comments_t_delete_simple(comments);
     }
     else {
       fl_color_print(data->error.to.stream, data->context.set.error, "%sYou failed to specify one or more files.%c", fll_error_print_error, f_string_eol[0]);
index 9105126a010d9c3315a510e9f3eb332a3bf7761f..b1ea0cbaac7009f93fa7c4d73492f299fbc213dc 100644 (file)
@@ -170,7 +170,7 @@ extern "C" {
 #endif // _di_fss_basic_list_read_main_preprocess_depth_
 
 #ifndef _di_fss_basic_list_read_main_process_file_
-  f_return_status fss_basic_list_read_main_process_file(const f_console_arguments_t arguments, fss_basic_list_read_data_t *data, const f_string_t filename, const fss_basic_list_read_depths_t depths, f_fss_delimits_t *delimits) {
+  f_return_status fss_basic_list_read_main_process_file(const f_console_arguments_t arguments, fss_basic_list_read_data_t *data, const f_string_t filename, const fss_basic_list_read_depths_t depths, f_fss_delimits_t *delimits, f_fss_comments_t *comments) {
     f_status_t status = F_none;
 
     const f_string_lengths_t except_none = f_string_lengths_t_initialize;
@@ -185,8 +185,9 @@ extern "C" {
       f_string_range_t input = f_macro_string_range_t_initialize(data->buffer.used);
 
       delimits->used = 0;
+      comments->used = 0;
 
-      status = fll_fss_basic_list_read(&data->buffer, &input, &data->objects, &data->contents, delimits, 0);
+      status = fll_fss_basic_list_read(&data->buffer, &input, &data->objects, &data->contents, delimits, 0, comments);
 
       if (F_status_is_error(status)) {
         // @todo: detect and replace fll_error_file_type_file with fll_error_file_type_pipe as appropriate.
@@ -212,6 +213,16 @@ extern "C" {
 
         return status;
       }
+
+      f_array_length_t i = 0;
+      f_array_length_t j = 0;
+
+      // comments are not to be part of the file, so remove them.
+      for (; i < comments->used; ++i) {
+        for (j = comments->array[i].start; j <= comments->array[i].stop; ++j) {
+          data->buffer.string[j] = f_fss_delimit_placeholder;
+        } // for
+      } // for
     }
 
     f_number_unsigned_t select = 0;
@@ -329,7 +340,9 @@ extern "C" {
 
               if (data->parameters[fss_basic_list_read_parameter_content].result == f_console_result_found) {
                 if (data->contents.array[i].used) {
+                  fss_basic_list_read_print_content_ignore(*data);
                   f_print_except_dynamic_partial(data->output.stream, data->buffer, data->contents.array[i].array[0], delimited ? *delimits : except_none);
+                  fss_basic_list_read_print_content_ignore(*data);
                 }
               }
 
@@ -354,7 +367,9 @@ extern "C" {
 
         if (data->parameters[fss_basic_list_read_parameter_content].result == f_console_result_found) {
           if (data->contents.array[i].used) {
+            fss_basic_list_read_print_content_ignore(*data);
             f_print_except_dynamic_partial(data->output.stream, data->buffer, data->contents.array[i].array[0], delimited ? *delimits : except_none);
+            fss_basic_list_read_print_content_ignore(*data);
           }
         }
 
@@ -374,6 +389,8 @@ extern "C" {
       }
 
       f_array_length_t at = 0;
+      f_array_length_t total = 0;
+      f_array_length_t line_current = 0;
 
       for (; i < data->objects.used; i++) {
 
@@ -384,7 +401,7 @@ extern "C" {
                 fprintf(data->output.stream, "0%c", f_string_eol[0]);
               }
               else {
-                f_array_length_t total = 1;
+                total = 1;
 
                 for (j = data->contents.array[i].array[0].start; j <= data->contents.array[i].array[0].stop; j++) {
                   if (!data->buffer.string[j]) continue;
@@ -422,7 +439,7 @@ extern "C" {
                   } // for
                 }
                 else {
-                  f_array_length_t line_current = 0;
+                  line_current = 0;
 
                   for (; i <= data->contents.array[i].array[0].stop; i++) {
                     if (!data->buffer.string[i]) continue;
@@ -455,11 +472,11 @@ extern "C" {
             }
 
             if (data->contents.array[i].used > 0) {
+              fss_basic_list_read_print_content_ignore(*data);
               f_print_except_dynamic_partial(data->output.stream, data->buffer, data->contents.array[i].array[0], delimited ? *delimits : except_none);
+              fss_basic_list_read_print_content_ignore(*data);
 
-              if (data->parameters[fss_basic_list_read_parameter_pipe].result == f_console_result_found) {
-                fprintf(data->output.stream, "%c", fss_basic_list_read_pipe_content_end);
-              }
+              fss_basic_list_read_print_set_end(*data);
             }
             else if (include_empty) {
               fprintf(data->output.stream, "%c", f_string_eol[0]);
@@ -570,11 +587,11 @@ extern "C" {
         continue;
       }
 
+      fss_basic_list_read_print_content_ignore(*data);
       f_print_except_dynamic_partial(data->output.stream, data->buffer, data->contents.array[i].array[0], delimited ? *delimits : except_none);
+      fss_basic_list_read_print_content_ignore(*data);
 
-      if (data->parameters[fss_basic_list_read_parameter_pipe].result == f_console_result_found) {
-        fprintf(data->output.stream, "%c", fss_basic_list_read_pipe_content_end);
-      }
+      fss_basic_list_read_print_set_end(*data);
     } // for
 
     return F_none;
@@ -607,6 +624,15 @@ extern "C" {
   }
 #endif // _di_fss_basic_list_read_print_content_end_
 
+#ifndef _di_fss_basic_list_read_print_content_ignore_
+  void fss_basic_list_read_print_content_ignore(const fss_basic_list_read_data_t data) {
+
+    if (data.parameters[fss_basic_list_read_parameter_pipe].result == f_console_result_found) {
+      fprintf(data.output.stream, "%c", fss_basic_list_read_pipe_content_ignore);
+    }
+  }
+#endif // _di_fss_basic_list_read_print_content_ignore_
+
 #ifndef _di_fss_basic_list_read_print_set_end_
   void fss_basic_list_read_print_set_end(const fss_basic_list_read_data_t data) {
 
index 610391c33264b68fdf2118941329ee65758d020d..c748a0263e2bcdae838c7e92ba453b7fc5900dd0 100644 (file)
@@ -191,6 +191,9 @@ extern "C" {
  *   The processed depth parameters.
  * @param delimits
  *   An array of delimits detected during processing.
+ * @param comments
+ *   An array of ranges representing where comments are found within any valid content.
+ *   This only stores comments found within valid content only.
  *
  * @return
  *   F_none on success.
@@ -200,7 +203,7 @@ extern "C" {
  * @see fss_basic_list_read_main_preprocess_depth()
  */
 #ifndef _di_fss_basic_list_read_main_process_file_
-  extern f_return_status fss_basic_list_read_main_process_file(const f_console_arguments_t arguments, fss_basic_list_read_data_t *data, const f_string_t file_name, const fss_basic_list_read_depths_t depths, f_fss_delimits_t *delimits) f_gcc_attribute_visibility_internal;
+  extern f_return_status fss_basic_list_read_main_process_file(const f_console_arguments_t arguments, fss_basic_list_read_data_t *data, const f_string_t file_name, const fss_basic_list_read_depths_t depths, f_fss_delimits_t *delimits, f_fss_comments_t *comments) f_gcc_attribute_visibility_internal;
 #endif // _di_fss_basic_list_read_main_process_file_
 
 /**
@@ -214,6 +217,18 @@ extern "C" {
 #endif // _di_fss_basic_list_read_print_object_end_
 
 /**
+ * Print the ignore character for content.
+ *
+ * This is only used in pipe output mode.
+ *
+ * @param data
+ *   The program specific data.
+ */
+#ifndef _di_fss_basic_list_read_print_content_ignore_
+  extern void fss_basic_list_read_print_content_ignore(const fss_basic_list_read_data_t data) f_gcc_attribute_visibility_internal;
+#endif // _di_fss_basic_list_read_print_content_ignore_
+
+/**
  * Print the end of an content.
  *
  * @param data
index 61abc159af2a4b37fe0ee9dbc64152bb0b36fffd..7b78ca616a62d57bcf3f7c52fa7b9ef490b9903a 100644 (file)
@@ -386,6 +386,7 @@ extern "C" {
 
       f_fss_delimits_t objects_delimits = f_fss_delimits_t_initialize;
       f_fss_delimits_t contents_delimits = f_fss_delimits_t_initialize;
+      f_fss_comments_t comments = f_fss_comments_t_initialize;
 
       f_string_length_t original_size = data->quantity.total;
 
@@ -416,7 +417,7 @@ extern "C" {
           fll_error_file_print(data->error, F_status_set_fine(status), "f_file_read", F_true, "-", "read", fll_error_file_type_pipe);
         }
         else {
-          status = fss_extended_list_read_main_process_file(arguments, data, "-", depths, &objects_delimits, &contents_delimits);
+          status = fss_extended_list_read_main_process_file(arguments, data, "-", depths, &objects_delimits, &contents_delimits, &comments);
 
           if (F_status_is_error(status)) {
             fll_error_file_print(data->error, F_status_set_fine(status), "fss_extended_list_read_main_process_file", F_true, "-", "read", fll_error_file_type_pipe);
@@ -470,7 +471,7 @@ extern "C" {
             break;
           }
 
-          status = fss_extended_list_read_main_process_file(arguments, data, arguments.argv[data->remaining.array[i]], depths, &objects_delimits, &contents_delimits);
+          status = fss_extended_list_read_main_process_file(arguments, data, arguments.argv[data->remaining.array[i]], depths, &objects_delimits, &contents_delimits, &comments);
 
           if (F_status_is_error(status)) {
             fll_error_file_print(data->error, F_status_set_fine(status), "fss_extended_list_read_main_process_file", F_true, arguments.argv[data->remaining.array[i]], "read", fll_error_file_type_file);
@@ -491,6 +492,7 @@ extern "C" {
       macro_fss_extended_list_read_depths_t_delete_simple(depths);
       f_macro_fss_delimits_t_delete_simple(objects_delimits);
       f_macro_fss_delimits_t_delete_simple(contents_delimits);
+      f_macro_fss_comments_t_delete_simple(comments);
     }
     else {
       fl_color_print(data->error.to.stream, data->context.set.error, "%sYou failed to specify one or more files.%c", fll_error_print_error, f_string_eol[0]);
index 04dc532d51f3a5dc9ff8a8b21e83046a6f81ad16..d6b443e9dcf3438e725c075512a68ef17e7b4aa2 100644 (file)
@@ -170,7 +170,7 @@ extern "C" {
 #endif // _di_fss_extended_list_read_main_preprocess_depth_
 
 #ifndef _di_fss_extended_list_read_main_process_file_
-  f_return_status fss_extended_list_read_main_process_file(const f_console_arguments_t arguments, fss_extended_list_read_data_t *data, const f_string_t filename, const fss_extended_list_read_depths_t depths, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) {
+  f_return_status fss_extended_list_read_main_process_file(const f_console_arguments_t arguments, fss_extended_list_read_data_t *data, const f_string_t filename, const fss_extended_list_read_depths_t depths, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments) {
     f_status_t status = F_none;
 
     {
@@ -178,8 +178,9 @@ extern "C" {
 
       objects_delimits->used = 0;
       contents_delimits->used = 0;
+      comments->used = 0;
 
-      status = fll_fss_extended_list_read(&data->buffer, &input, &data->nest, objects_delimits, contents_delimits);
+      status = fll_fss_extended_list_read(&data->buffer, &input, &data->nest, objects_delimits, contents_delimits, comments);
 
       if (F_status_is_error(status)) {
         // @todo: detect and replace fll_error_file_type_file with fll_error_file_type_pipe as appropriate.
@@ -203,6 +204,16 @@ extern "C" {
 
         return status;
       }
+
+      f_array_length_t i = 0;
+      f_array_length_t j = 0;
+
+      // comments are not to be part of the file, so remove them.
+      for (; i < comments->used; ++i) {
+        for (j = comments->array[i].start; j <= comments->array[i].stop; ++j) {
+          data->buffer.string[j] = f_fss_delimit_placeholder;
+        } // for
+      } // for
     }
 
     // Requested depths cannot be greater than contents depth.
@@ -591,6 +602,66 @@ extern "C" {
   }
 #endif // _di_fss_extended_list_read_main_process_for_depth_
 
+#ifndef _di_fss_extended_list_read_print_object_end_
+  void fss_extended_list_read_print_object_end(const fss_extended_list_read_data_t data) {
+
+    if (data.parameters[fss_extended_list_read_parameter_pipe].result == f_console_result_found) {
+      fprintf(data.output.stream, "%c", fss_extended_list_read_pipe_content_start);
+    }
+    else {
+      if (data.parameters[fss_extended_list_read_parameter_object].result == f_console_result_found && data.parameters[fss_extended_list_read_parameter_content].result == f_console_result_found) {
+        fprintf(data.output.stream, "%c%c", f_fss_extended_list_open, f_fss_extended_list_open_end);
+      }
+      else {
+        fprintf(data.output.stream, "%c", f_fss_eol);
+      }
+    }
+  }
+#endif // _di_fss_extended_list_read_print_object_end_
+
+#ifndef _di_fss_extended_list_read_print_content_end_
+  void fss_extended_list_read_print_content_end(const fss_extended_list_read_data_t data) {
+
+    if (data.parameters[fss_extended_list_read_parameter_pipe].result == f_console_result_found) {
+      fprintf(data.output.stream, "%c", fss_extended_list_read_pipe_content_start);
+    }
+    else {
+      if (data.parameters[fss_extended_list_read_parameter_object].result == f_console_result_found && data.parameters[fss_extended_list_read_parameter_content].result == f_console_result_found) {
+        fprintf(data.output.stream, "%c%c", f_fss_extended_list_close, f_fss_extended_list_close_end);
+      }
+      else {
+        fprintf(data.output.stream, "%c", f_fss_eol);
+      }
+    }
+  }
+#endif // _di_fss_extended_list_read_print_content_end_
+
+#ifndef _di_fss_extended_list_read_print_content_ignore_
+  void fss_extended_list_read_print_content_ignore(const fss_extended_list_read_data_t data) {
+
+    if (data.parameters[fss_extended_list_read_parameter_pipe].result == f_console_result_found) {
+      fprintf(data.output.stream, "%c", fss_extended_list_read_pipe_content_ignore);
+    }
+  }
+#endif // _di_fss_extended_list_read_print_content_ignore_
+
+#ifndef _di_fss_extended_list_read_print_set_end_
+  void fss_extended_list_read_print_set_end(const fss_extended_list_read_data_t data) {
+
+    if (data.parameters[fss_extended_list_read_parameter_pipe].result == f_console_result_found) {
+      fprintf(data.output.stream, "%c", fss_extended_list_read_pipe_content_end);
+    }
+    else {
+      if (data.parameters[fss_extended_list_read_parameter_object].result == f_console_result_found && data.parameters[fss_extended_list_read_parameter_content].result == f_console_result_found) {
+        fprintf(data.output.stream, "%c%c", f_fss_extended_list_close, f_fss_extended_list_close_end);
+      }
+      else {
+        fprintf(data.output.stream, "%c", f_fss_eol);
+      }
+    }
+  }
+#endif // _di_fss_extended_list_read_print_set_end_
+
 #ifndef _di_fss_extended_list_read_process_delimits_
   void fss_extended_list_read_process_delimits(const fss_extended_list_read_data_t data, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) {
 
@@ -682,6 +753,7 @@ extern "C" {
     for (i = 0; i < items->used; ++i) {
 
       for (j = 0; j < original_used; ++j) {
+
         for (k = 0; k < items->array[i].content.used; ++k) {
 
           if (original_delimits[j] >= items->array[i].content.array[k].start && original_delimits[j] <= items->array[i].content.array[k].stop) {
@@ -793,66 +865,6 @@ extern "C" {
   }
 #endif // _di_fss_extended_list_read_process_delimits_within_greater_
 
-#ifndef _di_fss_extended_list_read_print_object_end_
-  void fss_extended_list_read_print_object_end(const fss_extended_list_read_data_t data) {
-
-    if (data.parameters[fss_extended_list_read_parameter_pipe].result == f_console_result_found) {
-      fprintf(data.output.stream, "%c", fss_extended_list_read_pipe_content_start);
-    }
-    else {
-      if (data.parameters[fss_extended_list_read_parameter_content].result == f_console_result_found) {
-        fprintf(data.output.stream, "%c%c", f_fss_extended_list_open, f_fss_extended_list_open_end);
-      }
-      else {
-        fprintf(data.output.stream, "%c", f_fss_eol);
-      }
-    }
-  }
-#endif // _di_fss_extended_list_read_print_object_end_
-
-#ifndef _di_fss_extended_list_read_print_content_end_
-  void fss_extended_list_read_print_content_end(const fss_extended_list_read_data_t data) {
-
-    if (data.parameters[fss_extended_list_read_parameter_pipe].result == f_console_result_found) {
-      fprintf(data.output.stream, "%c", fss_extended_list_read_pipe_content_start);
-    }
-    else {
-      if (data.parameters[fss_extended_list_read_parameter_object].result == f_console_result_found) {
-        fprintf(data.output.stream, "%c%c", f_fss_extended_list_close, f_fss_extended_list_close_end);
-      }
-      else {
-        fprintf(data.output.stream, "%c", f_fss_eol);
-      }
-    }
-  }
-#endif // _di_fss_extended_list_read_print_content_end_
-
-#ifndef _di_fss_extended_list_read_print_content_ignore_
-  void fss_extended_list_read_print_content_ignore(const fss_extended_list_read_data_t data) {
-
-    if (data.parameters[fss_extended_list_read_parameter_pipe].result == f_console_result_found) {
-      fprintf(data.output.stream, "%c", fss_extended_list_read_pipe_content_ignore);
-    }
-  }
-#endif // _di_fss_extended_list_read_print_content_ignore_
-
-#ifndef _di_fss_extended_list_read_print_set_end_
-  void fss_extended_list_read_print_set_end(const fss_extended_list_read_data_t data) {
-
-    if (data.parameters[fss_extended_list_read_parameter_pipe].result == f_console_result_found) {
-      fprintf(data.output.stream, "%c", fss_extended_list_read_pipe_content_end);
-    }
-    else {
-      if (data.parameters[fss_extended_list_read_parameter_object].result == f_console_result_found) {
-        fprintf(data.output.stream, "%c%c", f_fss_extended_list_close, f_fss_extended_list_close_end);
-      }
-      else {
-        fprintf(data.output.stream, "%c", f_fss_eol);
-      }
-    }
-  }
-#endif // _di_fss_extended_list_read_print_set_end_
-
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 10e849378c54b534dff91f634fe6e93ec3028677..2384e81126eec431f8614aacd1b6fd432b1ec697 100644 (file)
@@ -193,6 +193,9 @@ extern "C" {
  *   An array of delimits detected during processing, for top-level objects.
  * @param contents_delimits
  *   An array of delimits detected during processing, for contents.
+ * @param comments
+ *   An array of ranges representing where comments are found within any valid content.
+ *   This only stores comments found within valid content only.
  *
  * @see fss_extended_list_read_main_preprocess_depth()
  * @see fss_extended_list_read_main_process_for_depth()
@@ -203,7 +206,7 @@ extern "C" {
  *   Status codes (with error bit) are returned on any problem.
  */
 #ifndef _di_fss_extended_list_read_main_process_file_
-  extern f_return_status fss_extended_list_read_main_process_file(const f_console_arguments_t arguments, fss_extended_list_read_data_t *data, const f_string_t file_name, const fss_extended_list_read_depths_t depths, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits) f_gcc_attribute_visibility_internal;
+  extern f_return_status fss_extended_list_read_main_process_file(const f_console_arguments_t arguments, fss_extended_list_read_data_t *data, const f_string_t file_name, const fss_extended_list_read_depths_t depths, f_fss_delimits_t *objects_delimits, f_fss_delimits_t *contents_delimits, f_fss_comments_t *comments) f_gcc_attribute_visibility_internal;
 #endif // _di_fss_extended_list_read_main_process_file_
 
 /**
@@ -239,6 +242,48 @@ extern "C" {
 #endif // _di_fss_extended_list_read_main_process_for_depth_
 
 /**
+ * Print the end of an content.
+ *
+ * @param data
+ *   The program specific data.
+ */
+#ifndef _di_fss_extended_list_read_print_content_end_
+  extern void fss_extended_list_read_print_content_end(const fss_extended_list_read_data_t data) f_gcc_attribute_visibility_internal;
+#endif // _di_fss_extended_list_read_print_content_end_
+
+/**
+ * Print the ignore character for content.
+ *
+ * This is only used in pipe output mode.
+ *
+ * @param data
+ *   The program specific data.
+ */
+#ifndef _di_fss_extended_list_read_print_content_ignore_
+  extern void fss_extended_list_read_print_content_ignore(const fss_extended_list_read_data_t data) f_gcc_attribute_visibility_internal;
+#endif // _di_fss_extended_list_read_print_content_ignore_
+
+/**
+ * Print the end of an object (which is essentially the start of a content).
+ *
+ * @param data
+ *   The program specific data.
+ */
+#ifndef _di_fss_extended_list_read_print_object_end_
+  extern void fss_extended_list_read_print_object_end(const fss_extended_list_read_data_t data) f_gcc_attribute_visibility_internal;
+#endif // _di_fss_extended_list_read_print_object_end_
+
+/**
+ * Print the end of an object/content set.
+ *
+ * @param data
+ *   The program specific data.
+ */
+#ifndef _di_fss_extended_list_read_print_set_end_
+  extern void fss_extended_list_read_print_set_end(const fss_extended_list_read_data_t data) f_gcc_attribute_visibility_internal;
+#endif // _di_fss_extended_list_read_print_set_end_
+
+/**
  * Rewrite the object and content delimit ranges to be within the given depth range.
  *
  * @param data
@@ -315,48 +360,6 @@ extern "C" {
   extern f_return_status fss_extended_list_read_process_delimits_within_greater(const fss_extended_list_read_data_t data, const f_string_length_t depth, const f_string_length_t location) f_gcc_attribute_visibility_internal;
 #endif // _di_fss_extended_list_read_process_delimits_within_greater_
 
-/**
- * Print the end of an object (which is essentially the start of a content).
- *
- * @param data
- *   The program specific data.
- */
-#ifndef _di_fss_extended_list_read_print_object_end_
-  extern void fss_extended_list_read_print_object_end(const fss_extended_list_read_data_t data) f_gcc_attribute_visibility_internal;
-#endif // _di_fss_extended_list_read_print_object_end_
-
-/**
- * Print the end of an content.
- *
- * @param data
- *   The program specific data.
- */
-#ifndef _di_fss_extended_list_read_print_content_end_
-  extern void fss_extended_list_read_print_content_end(const fss_extended_list_read_data_t data) f_gcc_attribute_visibility_internal;
-#endif // _di_fss_extended_list_read_print_content_end_
-
-/**
- * Print the ignore character for content.
- *
- * This is only used in pipe output mode.
- *
- * @param data
- *   The program specific data.
- */
-#ifndef _di_fss_extended_list_read_print_content_ignore_
-  extern void fss_extended_list_read_print_content_ignore(const fss_extended_list_read_data_t data) f_gcc_attribute_visibility_internal;
-#endif // _di_fss_extended_list_read_print_content_ignore_
-
-/**
- * Print the end of an object/content set.
- *
- * @param data
- *   The program specific data.
- */
-#ifndef _di_fss_extended_list_read_print_set_end_
-  extern void fss_extended_list_read_print_set_end(const fss_extended_list_read_data_t data) f_gcc_attribute_visibility_internal;
-#endif // _di_fss_extended_list_read_print_set_end_
-
 #ifdef __cplusplus
 } // extern "C"
 #endif