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.
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
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
// 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>
--- /dev/null
+/**
+ * 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
#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)
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
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;
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);
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;
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++) {
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);
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);
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) {
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);
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;
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++;
#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++) {
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_
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) {
* 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).
* 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_
/**
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;
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;
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;
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) {
}
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;
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++;
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;
}
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;
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;
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);
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).
// 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;
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;
}
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) {
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) {
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;
}
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;
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;
}
} // 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.
}
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) {
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)
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;
}
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);
* 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).
* 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_
/**
}
#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) { \
#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_
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_
* 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
#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);
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;
}
* (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.
* 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_
/**
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;
#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;
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;
}
* (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).
* 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_
/**
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;
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]);
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);
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);
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]);
#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;
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.
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;
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);
}
}
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);
}
}
}
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++) {
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;
} // 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;
}
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]);
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;
}
#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) {
* 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.
* @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_
/**
#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
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;
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);
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);
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]);
#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;
{
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.
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.
}
#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) {
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) {
}
#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
* 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()
* 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_
/**
#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
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