While not enthusiastic about this, I believe that I need to report the quote used to the caller.
Make this an optional parameter.
This took some significant consideration.
Not all standards utilize quotes and I also do not want to make FSS object and content types more complex than ranges.
Using a separate variable, while a bit more tedious in having to maintain consistency, is an acceptable approach.
FSS-0000 objects, FSS-0001 objects, and FSS-0001 contents all use the same logic for identifying their types.
Reduce code by using the same function.
Because FSS-0001 contents is an array of contents, move delimit processing outside of the private function.
Replace (used + 1 > size) checks with (used == size) checks to increase performance by avoiding arithmetic operations.
Replace (used <= 0) checks with (used == 0) checks to remove unnecessary checks.
Replace (used != 0) checks with (used) checks to avoid extra processor work.
When incrementing and decrementing buffer, do not report used as an error, instead just return F_data_not.
Shorten pre_allocate_size to size_allocate.
Stop setting F_unterminated_group_stop and F_unterminated_group_eos as warnings.
This was not done consistently.
Rename buffer to destination for FSS write functions.
At some point in the past I was wanting to use while loops more exclusively.
After some some significant time and consideration, I have decided to abandon that idea.
Use for loops where they make more sense over while loops.
Continue work in Featureless Make.
build_libraries-level
build_sources_library console.c conversion.c directory.c private-directory.c environment.c private-environment.c file.c private-file.c fss.c iki.c memory.c path.c pipe.c print.c serialize.c private-serialize.c socket.c utf.c private-utf.c
build_sources_program
-build_sources_headers color.h console.h conversion.h directory.h directory_type.h environment.h file.h fss.h fss-common.h fss-named.h fss-nest.h fss-set.h iki.h iki-common.h memory.h memory-structure.h path.h pipe.h print.h serialize.h socket.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 color.h console.h conversion.h directory.h directory_type.h environment.h file.h fss.h fss-common.h fss-named.h fss-nest.h fss-quoted.h fss-set.h iki.h iki-common.h memory.h memory-structure.h path.h pipe.h print.h serialize.h socket.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/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/memory.c level_0/path.c level_0/pipe.c level_0/print.c level_0/serialize.c level_0/private-serialize.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/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/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/execute.c level_2/private-execute.c level_2/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/program.c level_2/status.c
build_sources_program
-build_sources_headers level_0/color.h level_0/console.h level_0/conversion.h level_0/directory.h level_0/directory_type.h level_0/environment.h level_0/file.h level_0/fss.h level_0/fss-common.h level_0/fss-named.h level_0/fss-nest.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/pipe.h level_0/print.h level_0/serialize.h level_0/socket.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/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/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/program.h level_2/status.h
+build_sources_headers level_0/color.h level_0/console.h level_0/conversion.h level_0/directory.h level_0/directory_type.h level_0/environment.h level_0/file.h level_0/fss.h level_0/fss-common.h level_0/fss-named.h level_0/fss-nest.h level_0/fss-quoted.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/pipe.h level_0/print.h level_0/serialize.h level_0/socket.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/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/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/program.h level_2/status.h
build_sources_script
build_sources_setting
build_script yes
Consider implementing a specification for accessibility characters using non-printing characters as a code word followed by another UTF-8 character to represent its code.
Followed by a UTF-8 character s done to ensure type safety.
This is likely to be limited to programs/terminals that accept it as to avoid printing extra noise.
-A simpler compatible version might be made that only utilies non-printing characters.
+A simpler compatible version might be made that only utilizes non-printing characters.
+
+Improve the FSS write functions as follows:
+- allow specifying both object and content at the same time, such as "fss_basic_write -o 'my object' -c 'my content'".
+ - This adds a new parameter -c/--content.
+ - This removes the parameter -s/--string.
+ - Both -o/--object and -c/--content will require a parameter (set an empty sting for an empty value).
+ - There can be only one -o/--object, but there can be multiple -c/--content (for fss-0000 (basic), multiple content would be appended together).
+- allow for designating how the pipe shall be handled, -O/--pipe_object or -C/--pipe_content (pipe data can exclusively only be an object or content but not both).
+- look into supporting NULL separation for providing the possibility of having the piped data contain both object and content such that a single null separates the object from the content.
+ - if the data starts with a null then it is content. ("\0My Content" = content only, "my object" = object only, "my object\0My content" = object and content.
+ - if implemented, would be designated by the -p/--pipe parameter.
+ - might not be possible as pipe might naturally terminate on NULL (investigate this).
+- Add -d/--double and -s/--single parameters to designate that this is to be quoted and then using single quotes or double quotes.
+ - consider adding -D/--double_if and -S/--single_if for only adding single or double quotes if quoting is required.
if (needs_additional.used > 0) {
i = needs_additional.array[0];
- if (parameters.parameter[i].additional.used >= parameters.parameter[i].additional.size) {
+ if (parameters.parameter[i].additional.used == parameters.parameter[i].additional.size) {
f_macro_string_lengths_resize(status, parameters.parameter[i].additional, parameters.parameter[i].additional.size + f_console_default_allocation_step);
if (F_status_is_error(status)) {
continue;
}
- if (parameters.parameter[i].locations.used >= parameters.parameter[i].locations.size) {
+ if (parameters.parameter[i].locations.used == parameters.parameter[i].locations.size) {
f_macro_string_lengths_resize(status, parameters.parameter[i].locations, parameters.parameter[i].locations.size + f_console_default_allocation_step);
if (F_status_is_error(status)) {
if (strncmp(arguments.argv[location], parameters.parameter[i].symbol_other, string_length + 1) != 0) continue;
- if (parameters.parameter[i].locations.used >= parameters.parameter[i].locations.size) {
+ if (parameters.parameter[i].locations.used == parameters.parameter[i].locations.size) {
f_macro_string_lengths_resize(status, parameters.parameter[i].locations, parameters.parameter[i].locations.size + f_console_default_allocation_step);
if (F_status_is_error(status)) {
if (!found) {
// populate list of remaining parameters.parameter not associated with anything.
- if (remaining->used >= remaining->size) {
+ if (remaining->used == remaining->size) {
f_macro_memory_structure_macro_increment(status, (*remaining), 1, f_console_default_allocation_step, f_macro_string_lengths_resize, F_buffer_too_large);
if (F_status_is_error(status)) {
f_macro_string_lengths_delete_simple(needs_additional);
continue;
}
- if (names->used >= names->size) {
+ if (names->used == names->size) {
f_macro_memory_structure_macro_increment(status, (*names), 1, f_directory_default_allocation_step, f_macro_string_dynamics_resize, F_buffer_too_large);
if (F_status_is_error(status)) break;
}
* FSS-specific delimiters.
*/
#ifndef _di_f_fss_delimiters_
- #define f_fss_delimit_slash '\\'
- #define f_fss_delimit_single_quote '\''
- #define f_fss_delimit_double_quote '"'
#define f_fss_delimit_placeholder f_string_placeholder[0]
+ #define f_fss_delimit_quote_single '\''
+ #define f_fss_delimit_quote_double '"'
+ #define f_fss_delimit_slash '\\'
#endif //_di_f_fss_delimiters_
/**
--- /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_quoted_h
+#define _F_fss_quoted_h
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Types for FSS quoted.
+ */
+#ifndef _di_f_fss_quoted_type_
+ enum {
+ f_fss_quoted_type_single = 1,
+ f_fss_quoted_type_double,
+ };
+#endif // _di_f_fss_quoted_type_
+
+/**
+ * Designate an fss quoted.
+ */
+#ifndef _di_f_fss_quoted_
+ typedef uint8_t f_fss_quoted;
+#endif // _di_f_fss_quoted_
+
+/**
+ * An array of f_fss_quoted.
+ *
+ * array: the array of fss quoted.
+ * size: total amount of allocated space.
+ * used: total number of allocated spaces used.
+ */
+#ifndef _di_f_fss_quoteds_
+ typedef struct {
+ f_fss_quoted *array;
+
+ f_array_length size;
+ f_array_length used;
+ } f_fss_quoteds;
+
+ #define f_fss_quoteds_initialize {0, 0, 0}
+
+ #define f_macro_fss_quoteds_clear(quoteds) f_macro_memory_structure_clear(quoteds)
+
+ #define f_macro_fss_quoteds_new(status, quoteds, length) f_macro_memory_structure_new(status, quoteds, f_fss_quoted, length)
+
+ #define f_macro_fss_quoteds_delete(status, quoteds) f_macro_memory_structure_delete(status, quoteds, f_fss_quoted)
+ #define f_macro_fss_quoteds_destroy(status, quoteds) f_macro_memory_structure_destroy(status, quoteds, f_fss_quoted)
+
+ #define f_macro_fss_quoteds_delete_simple(quoteds) f_macro_memory_structure_delete_simple(quoteds, f_fss_quoted)
+ #define f_macro_fss_quoteds_destroy_simple(quoteds) f_macro_memory_structure_destroy_simple(quoteds, f_fss_quoted)
+
+ #define f_macro_fss_quoteds_resize(status, quoteds, new_length) f_macro_memory_structure_resize(status, quoteds, f_fss_quoted, new_length)
+ #define f_macro_fss_quoteds_adjust(status, quoteds, new_length) f_macro_memory_structure_adjust(status, quoteds, f_fss_quoted, new_length)
+#endif // _di_f_fss_quoteds_
+
+/**
+ * An array of f_fss_quoteds.
+ *
+ * array: the array of fss quoteds.
+ * size: total amount of allocated space.
+ * used: total number of allocated spaces used.
+ */
+#ifndef _di_f_fss_quotedss_
+ typedef struct {
+ f_fss_quoteds *array;
+
+ f_array_length size;
+ f_array_length used;
+ } f_fss_quotedss;
+
+ #define f_fss_quotedss_initialize {0, 0, 0}
+
+ #define f_macro_fss_quotedss_clear(quotedss) f_macro_memory_structures_clear(quotedss)
+
+ #define f_macro_fss_quotedss_new(status, quotedss, length) f_macro_memory_structures_new(status, quotedss, f_fss_quoteds, length)
+
+ #define f_macro_fss_quotedss_delete(status, quotedss) f_macro_memory_structures_delete(status, quotedss, f_fss_quoted, f_fss_quoteds)
+ #define f_macro_fss_quotedss_destroy(status, quotedss) f_macro_memory_structures_destroy(status, quotedss, f_fss_quoted, f_fss_quoteds)
+
+ #define f_macro_fss_quotedss_delete_simple(quotedss) f_macro_memory_structures_delete_simple(quotedss, f_fss_quoted, f_fss_quoteds)
+ #define f_macro_fss_quotedss_destroy_simple(quotedss) f_macro_memory_structures_destroy_simple(quotedss, f_fss_quoted, f_fss_quoteds)
+
+ #define f_macro_fss_quotedss_resize(status, quotedss, new_length) f_macro_memory_structures_resize(status, quotedss, f_fss_quoted, f_fss_quoteds, new_length, f_array_length)
+ #define f_macro_fss_quotedss_adjust(status, quotedss, new_length) f_macro_memory_structures_adjust(status, quotedss, f_fss_quoted, f_fss_quoteds, new_length, f_array_length)
+#endif // _di_f_fss_quotedss_
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // _F_fss_quoted_h
#ifndef _di_f_fss_count_lines_
f_return_status f_fss_count_lines(const f_string_static buffer, const f_string_length before, f_string_length *line) {
#ifndef _di_level_0_parameter_checking_
- if (buffer.used <= 0) return F_status_set_error(F_parameter);
+ if (buffer.used == 0) return F_status_set_error(F_parameter);
if (before >= buffer.used) return F_status_set_error(F_parameter);
if (line == 0) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
#ifndef _di_f_fss_count_lines_range_
f_return_status f_fss_count_lines_range(const f_string_static buffer, const f_string_range range, const f_string_length before, f_string_length *line) {
#ifndef _di_level_0_parameter_checking_
- if (buffer.used <= 0) return F_status_set_error(F_parameter);
+ if (buffer.used == 0) return F_status_set_error(F_parameter);
if (range.start > range.stop) return F_status_set_error(F_parameter);
if (range.start >= buffer.used) return F_status_set_error(F_parameter);
if (before >= buffer.used) return F_status_set_error(F_parameter);
#ifndef _di_f_fss_is_graph_
f_return_status f_fss_is_graph(const f_string_static buffer, const f_string_range range) {
#ifndef _di_level_0_parameter_checking_
- if (buffer.used <= 0) return F_status_set_error(F_parameter);
+ if (buffer.used == 0) return F_status_set_error(F_parameter);
if (range.start < 0) return F_status_set_error(F_parameter);
if (range.stop < range.start) return F_status_set_error(F_parameter);
if (range.start >= buffer.used) return F_status_set_error(F_parameter);
#ifndef _di_f_fss_is_space_
f_return_status f_fss_is_space(const f_string_static buffer, const f_string_range range) {
#ifndef _di_level_0_parameter_checking_
- if (buffer.used <= 0) return F_status_set_error(F_parameter);
+ if (buffer.used == 0) return F_status_set_error(F_parameter);
if (range.start < 0) return F_status_set_error(F_parameter);
if (range.stop < range.start) return F_status_set_error(F_parameter);
if (range.start >= buffer.used) return F_status_set_error(F_parameter);
width_max = buffer.used - range.start;
}
- // Handle (ASCII) zero-width spaces and control characters (isspace() or iscntrl() might consider some of these spaces).
status = f_utf_is_zero_width(buffer.string + range.start, width_max);
if (status != F_false) {
#ifndef _di_f_fss_is_zero_width_
f_return_status f_fss_is_zero_width(const f_string_static buffer, const f_string_range range) {
#ifndef _di_level_0_parameter_checking_
- if (buffer.used <= 0) return F_status_set_error(F_parameter);
+ if (buffer.used == 0) return F_status_set_error(F_parameter);
if (range.start < 0) return F_status_set_error(F_parameter);
if (range.stop < range.start) return F_status_set_error(F_parameter);
if (range.start >= buffer.used) return F_status_set_error(F_parameter);
#ifndef _di_f_fss_skip_past_space_
f_return_status f_fss_skip_past_space(const f_string_static buffer, f_string_range *range) {
#ifndef _di_level_0_parameter_checking_
- if (buffer.used <= 0) return F_status_set_error(F_parameter);
+ if (buffer.used == 0) return F_status_set_error(F_parameter);
if (range == 0) return F_status_set_error(F_parameter);
- if (range->stop < range->start) return F_status_set_error(F_parameter);
+ if (range->start > range->stop) return F_status_set_error(F_parameter);
if (range->start >= buffer.used) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
#ifndef _di_f_fss_skip_past_non_graph_
f_return_status f_fss_skip_past_non_graph(const f_string_static buffer, f_string_range *range) {
#ifndef _di_level_0_parameter_checking_
- if (buffer.used <= 0) return F_status_set_error(F_parameter);
+ if (buffer.used == 0) return F_status_set_error(F_parameter);
if (range == 0) return F_status_set_error(F_parameter);
- if (range->stop < range->start) return F_status_set_error(F_parameter);
+ if (range->start > range->stop) return F_status_set_error(F_parameter);
if (range->start >= buffer.used) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
#include <level_0/fss-common.h>
#include <level_0/fss-named.h>
#include <level_0/fss-nest.h>
+#include <level_0/fss-quoted.h>
#include <level_0/fss-set.h>
#ifdef __cplusplus
build_libraries-individual -lf_utf -lf_memory
build_sources_library fss.c
build_sources_program
-build_sources_headers fss.h fss-common.h fss-named.h fss-nest.h fss-set.h
+build_sources_headers fss.h fss-common.h fss-named.h fss-nest.h fss-quoted.h fss-set.h
build_sources_script
build_sources_setting
build_script yes
#ifndef _di_f_macro_iki_allocate_delimits_if_necessary_
#define f_macro_iki_allocate_delimits_if_necessary(status, delimits) \
status = F_none; \
- if (delimits.used + 1 > delimits.size) { \
+ if (delimits.used == delimits.size) { \
if (delimits.used + f_iki_default_allocation_step > f_string_length_size) { \
- if (delimits.used + 1 > f_string_length_size) { \
+ if (delimits.used == f_string_length_size) { \
status = F_status_set_error(F_string_too_large); \
} \
else { \
#ifndef _di_f_macro_iki_allocate_ranges_if_necessary_
#define f_macro_iki_allocate_ranges_if_necessary(status, ranges) \
status = F_none; \
- if (ranges.used + 1 > ranges.size) { \
+ if (ranges.used == ranges.size) { \
if (ranges.used + f_iki_default_allocation_step > f_string_length_size) { \
- if (ranges.used + 1 > f_string_length_size) { \
+ if (ranges.used == f_string_length_size) { \
status = F_status_set_error(F_string_too_large); \
} \
else { \
f_return_status f_iki_read(f_string_static *buffer, f_string_range *range, f_iki_variable *variable, f_iki_vocabulary *vocabulary, f_iki_content *content) {
#ifndef _di_level_0_parameter_checking_
if (buffer == 0) return F_status_set_error(F_parameter);
+ if (buffer->used == 0) return F_status_set_error(F_parameter);
if (range == 0) return F_status_set_error(F_parameter);
if (variable == 0) return F_status_set_error(F_parameter);
if (vocabulary == 0) return F_status_set_error(F_parameter);
if (content == 0) return F_status_set_error(F_parameter);
- if (buffer->used == 0) return F_status_set_error(F_parameter);
if (range->start > range->stop) return F_status_set_error(F_parameter);
if (range->start >= buffer->used) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
#ifndef _di_f_print_string_dynamic_
f_return_status f_print_string_dynamic(FILE *output, const f_string_static buffer) {
#ifndef _di_level_0_parameter_checking_
- if (buffer.used <= 0) return F_status_set_error(F_parameter);
+ if (buffer.used == 0) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
register f_string_length i = 0;
#ifndef _di_level_0_parameter_checking_
if (range.start < 0) return F_status_set_error(F_parameter);
if (range.start > range.stop) return F_status_set_error(F_parameter);
- if (buffer.used <= 0) return F_status_set_error(F_parameter);
+ if (buffer.used == 0) return F_status_set_error(F_parameter);
if (range.start >= buffer.used) return F_status_set_error(F_parameter);
if (range.stop >= buffer.used) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
#define f_macro_statusss_delete_simple(statusss) f_macro_memory_structures_delete_simple(statusss, f_status, f_statuss)
#define f_macro_statusss_destroy_simple(statusss) f_macro_memory_structures_destroy_simple(statusss, f_status, f_statuss)
- #define f_macro_statusss_resize(status, statusss, new_length) f_macro_memory_structures_resize(status, statusss, f_status, f_statuss, new_length)
- #define f_macro_statusss_adjust(status, statusss, new_length) f_macro_memory_structures_adjust(status, statusss, f_status, f_statuss, new_length)
+ #define f_macro_statusss_resize(status, statusss, new_length) f_macro_memory_structures_resize(status, statusss, f_status, f_statuss, new_length, f_array_length)
+ #define f_macro_statusss_adjust(status, statusss, new_length) f_macro_memory_structures_adjust(status, statusss, f_status, f_statuss, new_length, f_array_length)
#endif // _di_f_statuss_
#ifdef __cplusplus
#ifndef _di_f_utf_buffer_decrement_
f_return_status f_utf_buffer_decrement(const f_string_static buffer, f_string_range *range, const f_string_length step) {
#ifndef _di_level_0_parameter_checking_
- if (buffer.used == 0) return F_status_set_error(F_parameter);
if (range == 0) return F_status_set_error(F_parameter);
if (range->start > range->stop) return F_status_set_error(F_parameter);
if (range->start >= buffer.used) return F_status_set_error(F_parameter);
if (step < 1) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
+ if (buffer.used == 0) return F_data_not;
+
f_string_length i = 0;
unsigned short width = 0;
#ifndef _di_f_utf_buffer_increment_
f_return_status f_utf_buffer_increment(const f_string_static buffer, f_string_range *range, const f_string_length step) {
#ifndef _di_level_0_parameter_checking_
- if (buffer.used == 0) return F_status_set_error(F_parameter);
if (range == 0) return F_status_set_error(F_parameter);
if (range->start > range->stop) return F_status_set_error(F_parameter);
if (range->start >= buffer.used) return F_status_set_error(F_parameter);
if (step < 1) return F_status_set_error(F_parameter);
#endif // _di_level_0_parameter_checking_
+ if (buffer.used == 0) return F_data_not;
+
f_string_length i = 0;
unsigned short width = 0;
* F_none on success.
* F_none_stop if the stop range is reached before all steps are completed.
* F_none_eos if the end of buffer is reached before all steps are completed.
+ * F_data_not if buffer is empty.
* F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
* F_parameter (with error bit) if a parameter is invalid.
*/
* F_none on success.
* F_none_stop if the stop range is reached before all steps are completed.
* F_none_eos if the end of buffer is reached before all steps are completed.
+ * F_data_not if buffer is empty.
* F_incomplete_utf_stop (with error bit) if the stop range is reached before the complete UTF-8 character can be processed.
* F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
* F_parameter (with error bit) if a parameter is invalid.
if (string == 0) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- if (start_color.used != 0) {
+ if (start_color.used) {
f_status status = f_print_string_dynamic(file, start_color);
if (F_status_is_error(status)) return status;
}
va_end(ap);
- if (end_color.used != 0) {
+ if (end_color.used) {
f_status status = f_print_string_dynamic(file, end_color);
if (F_status_is_error(status)) return status;
if (string == 0) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- if (start_color.used != 0) {
+ if (start_color.used) {
f_status status = f_print_string_dynamic(file, start_color);
if (F_status_is_error(status)) return status;
va_end(ap);
- if (end_color.used != 0) {
+ if (end_color.used) {
f_status status = f_print_string_dynamic(file, end_color);
if (F_status_is_error(status)) return status;
}
if (string == 0) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- if (start_color.used != 0) {
+ if (start_color.used) {
f_status status = f_print_string_dynamic(file, start_color);
if (F_status_is_error(status)) return status;
}
va_end(ap);
- if (end_color.used != 0) {
+ if (end_color.used) {
f_status status = f_print_string_dynamic(file, end_color);
if (F_status_is_error(status)) return status;
}
if (string == 0) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- if (start_color.used != 0) {
+ if (start_color.used) {
f_status status = f_print_string_dynamic(file, start_color);
if (F_status_is_error(status)) return status;
va_end(ap);
- if (end_color.used != 0) {
+ if (end_color.used) {
f_status status = f_print_string_dynamic(file, end_color);
if (F_status_is_error(status)) return status;
}
#ifndef _di_fl_color_print_code_
f_return_status fl_color_print_code(FILE *file, const f_string_static color) {
- if (color.used != 0) {
+ if (color.used) {
f_status status = f_print_string_dynamic(file, color);
if (F_status_is_error(status)) return status;
}
names = &listing->unknown;
}
- if (names->used >= names->size) {
+ if (names->used == names->size) {
f_macro_string_dynamics_resize(status, (*names), names->size + f_directory_default_allocation_step);
if (F_status_is_error(status)) break;
}
if (F_status_is_error(status)) break;
if (names->array[names->used].used > 0 && names->array[names->used].string[names->array[names->used].used - 1] != 0) {
- if (names->array[names->used].used + 1 > f_string_length_size) {
+ if (names->array[names->used].used == f_string_length_size) {
status = F_status_set_error(F_string_too_large);
break;
}
#endif
#ifndef _di_fl_fss_basic_object_read_
- f_return_status fl_fss_basic_object_read(f_string_dynamic *buffer, f_string_range *range, f_fss_object *found) {
+ f_return_status fl_fss_basic_object_read(f_string_dynamic *buffer, f_string_range *range, f_fss_object *found, f_fss_quoted *quoted) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return F_status_set_error(F_parameter);
+ if (buffer->used == 0) return F_status_set_error(F_parameter);
if (range == 0) return F_status_set_error(F_parameter);
if (found == 0) return F_status_set_error(F_parameter);
- if (range->stop < range->start) return F_status_set_error(F_parameter);
- if (buffer->used == 0) return F_status_set_error(F_parameter);
+ if (range->start > range->stop) return F_status_set_error(F_parameter);
if (range->start >= buffer->used) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- return private_fl_fss_basic_object_read(F_true, buffer, range, found);
+ f_status status = F_none;
+ f_string_lengths delimits = f_string_lengths_initialize;
+
+ status = private_fl_fss_basic_object_read(buffer, range, found, quoted, &delimits);
+ if (F_status_is_error(status)) {
+ f_macro_string_lengths_delete_simple(delimits);
+ return status;
+ }
+
+ if (status == FL_fss_found_object_not || status == F_data_not || status == F_data_not_eos || status == F_data_not_stop) {
+ f_macro_string_lengths_delete_simple(delimits);
+ return status;
+ }
+
+ fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
+
+ return status;
}
#endif // _di_fl_fss_basic_object_read_
f_return_status fl_fss_basic_content_read(f_string_dynamic *buffer, f_string_range *range, f_fss_content *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return F_status_set_error(F_parameter);
+ if (buffer->used == 0) return F_status_set_error(F_parameter);
if (range == 0) return F_status_set_error(F_parameter);
if (found == 0) return F_status_set_error(F_parameter);
- if (range->stop < range->start) return F_status_set_error(F_parameter);
- if (buffer->used == 0) return F_status_set_error(F_parameter);
+ if (range->start > range->stop) return F_status_set_error(F_parameter);
if (range->start >= buffer->used) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
// search for valid content.
for (;;) {
fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*range));
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*range), (*found), delimits, F_none_eos, F_none_stop)
+ fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*range), (*found), delimits, F_none_eos, F_none_stop);
if (buffer->string[range->start] == f_fss_basic_close) break;
#endif // _di_fl_fss_basic_content_read_
#ifndef _di_fl_fss_basic_object_write_
- f_return_status fl_fss_basic_object_write(f_string_dynamic *buffer, const f_string_static object, f_string_range *range) {
+ f_return_status fl_fss_basic_object_write(const f_string_static object, const f_fss_quoted quoted, f_string_range *range, f_string_dynamic *destination) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == 0) return F_status_set_error(F_parameter);
+ if (destination == 0) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- f_status status = F_none;
- bool quoted = F_false;
-
- f_string_range buffer_position = f_string_range_initialize;
- f_string_length start_position = f_string_initialize;
- f_string_length pre_allocate_size = 0;
-
- fl_macro_fss_skip_past_delimit_placeholders(object, (*range));
-
- if (range->start > range->stop) return F_data_not_stop;
- else if (range->start >= object.used) return F_data_not_eos;
-
- start_position = range->start;
-
- // add an additional 3 to ensure that there is room for the start and stop quotes or a slash delimit and the object open character.
- pre_allocate_size = buffer->used + (range->stop - range->start) + 3 + f_fss_default_allocation_step_string;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size);
- if (F_status_is_error(status)) return status;
- }
-
- buffer_position.start = buffer->used;
- buffer_position.stop = buffer->used;
-
- if (object.string[range->start] == f_fss_delimit_slash) {
- while (range->start <= range->stop && range->start < object.used) {
- if (object.string[range->start] == f_fss_delimit_placeholder) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- continue;
- }
- else if (object.string[range->start] != f_fss_delimit_slash) {
- break;
- }
-
- buffer->string[buffer_position.stop] = object.string[range->start];
- buffer_position.stop++;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
- } // while
-
- if (object.string[range->start] == f_fss_delimit_single_quote || object.string[range->start] == f_fss_delimit_double_quote) {
- pre_allocate_size++;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
- if (F_status_is_error(status)) return status;
- }
-
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer->string[buffer_position.stop + 1] = object.string[range->start];
- buffer_position.stop += 2;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
- }
- }
- else if (object.string[range->start] == f_fss_delimit_single_quote || object.string[range->start] == f_fss_delimit_double_quote) {
- pre_allocate_size++;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
-
- if (F_status_is_error(status)) return status;
- }
-
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer->string[buffer_position.stop + 1] = object.string[range->start];
- buffer_position.stop += 2;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
- }
- else if (object.string[range->start] == f_fss_comment) {
- quoted = F_true;
- }
-
- while (range->start <= range->stop && range->start < object.used) {
- if (object.string[range->start] == f_fss_delimit_placeholder) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- continue;
- }
- else if (object.string[range->start] == f_string_eol[0]) {
- if (quoted) {
- buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
- buffer_position.stop++;
- }
-
- buffer->string[buffer_position.stop] = f_fss_basic_open;
- buffer->used = buffer_position.stop + 1;
-
- return F_none_eol;
- }
- else if ((status = f_fss_is_space(*buffer, *range)) == F_true || quoted) {
- pre_allocate_size++;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
- if (F_status_is_error(status)) return status;
- }
-
- // restart the loop searching for f_fss_delimit_double_quote.
- range->start = start_position;
- buffer_position.stop = buffer_position.start;
-
- buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
- buffer_position.stop++;
-
- while (range->start <= range->stop && range->start < object.used) {
- if (object.string[range->start] == f_fss_delimit_placeholder) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- continue;
- }
- else if (object.string[range->start] == f_fss_delimit_double_quote) {
- pre_allocate_size++;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
- if (F_status_is_error(status)) return status;
- }
-
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer_position.stop++;
- }
- else if (object.string[range->start] == f_fss_delimit_slash) {
- f_string_length slash_count = 0;
-
- for (;;) {
- buffer->string[buffer_position.stop] = object.string[range->start];
- buffer_position.stop++;
- slash_count++;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- fl_macro_fss_skip_past_delimit_placeholders(object, (*range));
-
- if (range->start > range->stop || range->start >= object.used) {
- break;
- }
-
- if (object.string[range->start] == f_fss_delimit_double_quote) {
- pre_allocate_size += slash_count;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
- if (F_status_is_error(status)) return status;
- }
-
- break;
- }
- else if (object.string[range->start] != f_fss_delimit_slash) {
- slash_count = 0;
- break;
- }
- } // for
-
- while (slash_count > 0) {
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer_position.stop++;
- slash_count--;
- } // while
-
- continue;
- }
- else if (object.string[range->start] == f_string_eol[0]) {
- buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
- buffer_position.stop++;
-
- buffer->string[buffer_position.stop] = f_fss_basic_open;
- buffer->used = buffer_position.stop + 1;
-
- return F_none_eol;
- }
-
- buffer->string[buffer_position.stop] = object.string[range->start];
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- buffer_position.stop++;
- } // while
-
- buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
- buffer->string[buffer_position.stop + 1] = f_fss_basic_open;
- buffer->used = buffer_position.stop + 2;
- break;
- }
- else if (F_status_is_error(status)) {
- return status;
- }
-
- buffer->string[buffer_position.stop] = object.string[range->start];
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- buffer_position.stop++;
- } // while
-
- if (buffer->used < buffer_position.stop) {
- buffer->string[buffer_position.stop] = f_fss_basic_open;
- buffer->used = buffer_position.stop + 1;
- }
-
- if (range->start > range->stop) return F_none_stop;
- else if (range->start >= object.used) return F_none_eos;
-
- return F_none;
+ return private_fl_fss_basic_object_write(object, quoted, range, destination);
}
#endif // _di_fl_fss_basic_object_write_
#ifndef _di_fl_fss_basic_content_write_
- f_return_status fl_fss_basic_content_write(f_string_dynamic *buffer, const f_string_static content, f_string_range *range) {
+ f_return_status fl_fss_basic_content_write(const f_string_static content, f_string_range *range, f_string_dynamic *destination) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == 0) return F_status_set_error(F_parameter);
+ if (destination == 0) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = F_none;
- f_string_range input_position = f_string_range_initialize;
- f_string_range buffer_position = f_string_range_initialize;
- f_string_length pre_allocate_size = 0;
-
- fl_macro_fss_skip_past_delimit_placeholders(content, (*range))
+ fl_macro_fss_skip_past_delimit_placeholders(content, (*range));
if (range->start > range->stop) return F_data_not_stop;
else if (range->start >= content.used) return F_data_not_eos;
- // add an additional 1 to ensure that there is room for the terminating newline.
- pre_allocate_size = buffer->used + (content.used) + 1 + f_fss_default_allocation_step_string;
+ f_string_range input_position = f_string_range_initialize;
+ f_string_range buffer_position = f_string_range_initialize;
+
+ // ensure that there is room for the terminating newline.
+ f_string_length size_allocate = destination->used + content.used + 1 + f_fss_default_allocation_step_string;
- buffer_position.start = buffer->used;
- buffer_position.stop = buffer->used;
+ buffer_position.start = destination->used;
+ buffer_position.stop = destination->used;
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size);
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate);
if (F_status_is_error(status)) return status;
}
while (range->start <= range->stop && range->start < content.used) {
if (content.string[range->start] == f_string_eol[0]) {
- buffer->string[buffer_position.stop] = f_string_eol[0];
- buffer->used = buffer_position.stop + 1;
+ destination->string[buffer_position.stop] = f_string_eol[0];
+ destination->used = buffer_position.stop + 1;
return F_none_eos;
}
if (content.string[range->start] != f_fss_delimit_placeholder) {
- buffer->string[buffer_position.stop] = content.string[range->start];
+ destination->string[buffer_position.stop] = content.string[range->start];
buffer_position.stop++;
}
- status = f_utf_buffer_increment(*buffer, range, 1);
+ status = f_utf_buffer_increment(content, range, 1);
if (F_status_is_error(status)) return status;
} // while
- buffer->string[buffer_position.stop] = f_string_eol[0];
- buffer->used = buffer_position.stop + 1;
+ destination->string[buffer_position.stop] = f_string_eol[0];
+ destination->used = buffer_position.stop + 1;
if (range->start > range->stop) return F_none_stop;
else if (range->start >= content.used) return F_none_eos;
* A start location past the stop location or buffer used means that the entire range was processed.
* @param found
* A set of all locations where a valid object was found.
+ * @param quoted
+ * This will store whether or not this object is quoted and what quote is in use.
+ * Set pointer address to 0 to not use.
*
* @return
* FL_fss_found_object on success and object was found (start location is at end of object).
* F_none_stop on success after reaching stopping point (a valid object is not yet confirmed).
* F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found).
* F_data_not_stop no data found after reaching stopping point (essentially only comments are found).
- * F_unterminated_group_eos (with warning bit) if EOS was reached before the a group termination was reached.
- * F_unterminated_group_stop (with warning bit) if stop point was reached before the a group termination was reached.
+ * F_unterminated_group_eos if EOS was reached before the a group termination was reached.
+ * F_unterminated_group_stop if stop point was reached before the a group termination was reached.
+ * F_buffer_too_large (with error bit) if a buffer is too large.
* F_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
* F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
* F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
* Errors from (with error bit): f_fss_skip_past_space().
*/
#ifndef _di_fl_fss_basic_object_read_
- extern f_return_status fl_fss_basic_object_read(f_string_dynamic *buffer, f_string_range *range, f_fss_object *found);
+ extern f_return_status fl_fss_basic_object_read(f_string_dynamic *buffer, f_string_range *range, f_fss_object *found, f_fss_quoted *quoted);
#endif // _di_fl_fss_basic_object_read_
/**
* F_none_stop on success after reaching stopping point (a valid object is not yet confirmed).
* F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found).
* F_data_not_stop no data found after reaching stopping point (essentially only comments are found).
- * F_unterminated_group_eos (with warning bit) if EOS was reached before the a group termination was reached.
- * F_unterminated_group_stop (with warning bit) if stop point was reached before the a group termination was reached.
+ * F_unterminated_group_eos if EOS was reached before the a group termination was reached.
+ * F_unterminated_group_stop if stop point was reached before the a group termination was reached.
+ * F_buffer_too_large (with error bit) if a buffer is too large.
* F_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
* F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
* F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
*
* @param object
* The string to write as (does not stop at NULLS, they are ignored and not written).
+ * @param quoted
+ * If 0, then double quotes are auto-inserted, when required.
+ * Otherwise, this is the type of quote to wrap the object in when writing.
* @param range
* The start/stop location within the object string to write as an object.
- * @param buffer
+ * @param destination
* The buffer where the object is written to.
- * This will be auto-incremented and must not be a static string.
*
* @return
* F_none on success.
* Errors from (with error bit): f_utf_buffer_increment().
*/
#ifndef _di_fl_fss_basic_object_write_
- extern f_return_status fl_fss_basic_object_write(f_string_dynamic *buffer, const f_string_static object, f_string_range *range);
+ extern f_return_status fl_fss_basic_object_write(const f_string_static object, const f_fss_quoted quoted, f_string_range *range, f_string_dynamic *destination);
#endif // _di_fl_fss_basic_object_write_
/**
* The string to write as (does not stop at NULLS, they are ignored and not written).
* @param range
* The start/stop location within the content string to write as an content.
- * @param buffer
+ * @param destination
* The buffer where the content is written to.
- * This will be auto-incremented and must not be a static string.
- *
* @return
* F_none on success.
* F_none_eos on success after reaching the end of the buffer.
* Errors from (with error bit): f_utf_buffer_increment().
*/
#ifndef _di_fl_fss_basic_content_write_
- extern f_return_status fl_fss_basic_content_write(f_string_dynamic *buffer, const f_string_static content, f_string_range *range);
+ extern f_return_status fl_fss_basic_content_write(const f_string_static content, f_string_range *range, f_string_dynamic *destination);
#endif // _di_fl_fss_basic_content_write_
#ifdef __cplusplus
f_return_status fl_fss_basic_list_object_read(f_string_dynamic *buffer, f_string_range *range, f_fss_object *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return F_status_set_error(F_parameter);
+ if (buffer->used == 0) return F_status_set_error(F_parameter);
if (range == 0) return F_status_set_error(F_parameter);
if (found == 0) return F_status_set_error(F_parameter);
- if (range->stop < range->start) return F_status_set_error(F_parameter);
- if (buffer->used == 0) return F_status_set_error(F_parameter);
+ if (range->start > range->stop) return F_status_set_error(F_parameter);
if (range->start >= buffer->used) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
f_return_status fl_fss_basic_list_content_read(f_string_dynamic *buffer, f_string_range *range, f_fss_content *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return F_status_set_error(F_parameter);
+ if (buffer->used == 0) return F_status_set_error(F_parameter);
if (range == 0) return F_status_set_error(F_parameter);
if (found == 0) return F_status_set_error(F_parameter);
- if (range->stop < range->start) return F_status_set_error(F_parameter);
- if (buffer->used == 0) return F_status_set_error(F_parameter);
+ if (range->start > range->stop) return F_status_set_error(F_parameter);
if (range->start >= buffer->used) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
#endif // _di_fl_fss_basic_list_content_read_
#ifndef _di_fl_fss_basic_list_object_write_
- f_return_status fl_fss_basic_list_object_write(const f_string_static object, f_string_range *range, f_string_dynamic *buffer) {
+ f_return_status fl_fss_basic_list_object_write(const f_string_static object, f_string_range *range, f_string_dynamic *destination) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == 0) return F_status_set_error(F_parameter);
+ if (destination == 0) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = F_none;
f_string_range buffer_position = f_string_range_initialize;
f_string_length start_position = f_string_initialize;
- f_string_length pre_allocate_size = 0;
+ f_string_length size_allocate = 0;
f_string_length start_buffer = 0;
fl_macro_fss_skip_past_delimit_placeholders(object, (*range))
start_position = range->start;
// add an additional 2 to ensure that there is room for the slash delimit and the object open character.
- pre_allocate_size = buffer->used + (range->stop - range->start) + 2 + f_fss_default_allocation_step_string;
+ size_allocate = destination->used + (range->stop - range->start) + 2 + f_fss_default_allocation_step_string;
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size);
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate);
if (F_status_is_error(status)) return status;
}
- buffer_position.start = buffer->used;
- buffer_position.stop = buffer->used;
+ buffer_position.start = destination->used;
+ buffer_position.stop = destination->used;
while (range->start <= range->stop && range->start < object.used) {
if (object.string[range->start] == f_fss_comment) {
}
if (object.string[range->start] != f_fss_delimit_placeholder) {
- buffer->string[buffer_position.stop] = object.string[range->start];
+ destination->string[buffer_position.stop] = object.string[range->start];
buffer_position.stop++;
}
if (object.string[range->start] == f_fss_delimit_slash) {
f_string_length slash_count = 1;
- buffer->string[buffer_position.stop] = object.string[range->start];
+ destination->string[buffer_position.stop] = object.string[range->start];
buffer_position.stop++;
status = f_utf_buffer_increment(object, range, 1);
break;
}
- buffer->string[buffer_position.stop] = object.string[range->start];
+ destination->string[buffer_position.stop] = object.string[range->start];
buffer_position.stop++;
status = f_utf_buffer_increment(object, range, 1);
} // while
if (range->start > range->stop || range->start >= object.used) {
- pre_allocate_size += slash_count;
+ size_allocate += slash_count;
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string);
if (F_status_is_error(status)) return status;
}
while (slash_count > 0) {
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
+ destination->string[buffer_position.stop] = f_fss_delimit_slash;
buffer_position.stop++;
slash_count--;
} // while
}
if (object.string[range->start] != f_fss_delimit_placeholder) {
- buffer->string[buffer_position.stop] = object.string[range->start];
+ destination->string[buffer_position.stop] = object.string[range->start];
buffer_position.stop++;
}
if (F_status_is_error(status)) return status;
} // while
- buffer->string[buffer_position.stop] = f_fss_basic_list_open;
- buffer->string[buffer_position.stop + 1] = f_string_eol[0];
- buffer->used = buffer_position.stop + 2;
+ destination->string[buffer_position.stop] = f_fss_basic_list_open;
+ destination->string[buffer_position.stop + 1] = f_string_eol[0];
+ destination->used = buffer_position.stop + 2;
if (range->start > range->stop) return F_none_stop;
else if (range->start >= object.used) return F_none_eos;
#endif // _di_fl_fss_basic_list_object_write_
#ifndef _di_fl_fss_basic_list_content_write_
- f_return_status fl_fss_basic_list_content_write(const f_string_static content, f_string_range *range, f_string_dynamic *buffer) {
+ f_return_status fl_fss_basic_list_content_write(const f_string_static content, f_string_range *range, f_string_dynamic *destination) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == 0) return F_status_set_error(F_parameter);
+ if (destination == 0) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = F_none;
f_string_range buffer_position = f_string_range_initialize;
f_string_length start_position = f_string_initialize;
- f_string_length pre_allocate_size = 0;
+ f_string_length size_allocate = 0;
fl_macro_fss_skip_past_delimit_placeholders(content, (*range))
start_position = range->start;
// add an additional 2 to ensure that there is room for the slash delimit and the content open character.
- pre_allocate_size = buffer->used + (range->stop - range->start) + 2 + f_fss_default_allocation_step_string;
+ size_allocate = destination->used + (range->stop - range->start) + 2 + f_fss_default_allocation_step_string;
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size);
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate);
if (F_status_is_error(status)) return status;
}
- buffer_position.start = buffer->used;
- buffer_position.stop = buffer->used;
+ buffer_position.start = destination->used;
+ buffer_position.stop = destination->used;
while (range->start <= range->stop && range->start < content.used) {
if (content.string[range->start] == f_fss_delimit_slash && !is_comment) {
f_string_length slash_count = 1;
- buffer->string[buffer_position.stop] = content.string[range->start];
+ destination->string[buffer_position.stop] = content.string[range->start];
buffer_position.stop++;
has_graph = F_true;
break;
}
- buffer->string[buffer_position.stop] = content.string[range->start];
+ destination->string[buffer_position.stop] = content.string[range->start];
buffer_position.stop++;
status = f_utf_buffer_increment(content, range, 1);
} // while
if (content.string[range->start] == f_string_eol[0] || range->start >= content.used || range->start > range->stop) {
- pre_allocate_size += slash_count + 1;
+ size_allocate += slash_count + 1;
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string);
if (F_status_is_error(status)) return status;
}
while (slash_count > 0) {
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
+ destination->string[buffer_position.stop] = f_fss_delimit_slash;
buffer_position.stop++;
slash_count--;
} // while
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
+ destination->string[buffer_position.stop] = f_fss_delimit_slash;
buffer_position.stop++;
has_graph = F_false;
is_comment = F_false;
}
- buffer->string[buffer_position.stop] = f_fss_basic_list_open;
+ destination->string[buffer_position.stop] = f_fss_basic_list_open;
buffer_position.stop++;
range->start = start + 1;
continue;
} // while
if (content.string[range->start] == f_string_eol[0] || range->start >= content.used || range->start > range->stop) {
- pre_allocate_size++;
+ size_allocate++;
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string);
if (F_status_is_error(status)) return status;
}
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
+ destination->string[buffer_position.stop] = f_fss_delimit_slash;
buffer_position.stop++;
has_graph = F_false;
is_comment = F_false;
}
- buffer->string[buffer_position.stop] = f_fss_basic_list_open;
+ destination->string[buffer_position.stop] = f_fss_basic_list_open;
buffer_position.stop++;
range->start = start + 1;
continue;
}
if (content.string[range->start] != f_fss_delimit_placeholder) {
- buffer->string[buffer_position.stop] = content.string[range->start];
+ destination->string[buffer_position.stop] = content.string[range->start];
buffer_position.stop++;
}
if (F_status_is_error(status)) return status;
} // while
- buffer->string[buffer_position.stop] = f_string_eol[0];
- buffer->used = buffer_position.stop + 1;
+ destination->string[buffer_position.stop] = f_string_eol[0];
+ destination->used = buffer_position.stop + 1;
if (range->start > range->stop) return F_none_stop;
else if (range->start >= content.used) return F_none_eos;
* F_none_stop on success after reaching stopping point (a valid object is not yet confirmed).
* F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found).
* F_data_not_stop no data found after reaching stopping point (essentially only comments are found).
- * F_unterminated_group_eos (with warning bit) if EOS was reached before the a group termination was reached.
- * F_unterminated_group_stop (with warning bit) if stop point was reached before the a group termination was reached.
+ * F_unterminated_group_eos if EOS was reached before the a group termination was reached.
+ * F_unterminated_group_stop if stop point was reached before the a group termination was reached.
+ * F_buffer_too_large (with error bit) if a buffer is too large.
* F_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
* F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
* F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
* F_none_stop on success after reaching stopping point (a valid object is not yet confirmed).
* F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found).
* F_data_not_stop no data found after reaching stopping point (essentially only comments are found).
- * F_unterminated_group_eos (with warning bit) if EOS was reached before the a group termination was reached.
- * F_unterminated_group_stop (with warning bit) if stop point was reached before the a group termination was reached.
+ * F_unterminated_group_eos if EOS was reached before the a group termination was reached.
+ * F_unterminated_group_stop if stop point was reached before the a group termination was reached.
+ * F_buffer_too_large (with error bit) if a buffer is too large.
* F_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
* F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
* F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
* The string to write as (does not stop at NULLS, they are ignored and not written).
* @param range
* The start/stop location within the object string to write as an object.
- * @param buffer
+ * @param destination
* The buffer where the object is written to.
- * This will be auto-incremented and must not be a static string.
*
* @return
* F_none on success.
* Errors from (with error bit): f_utf_buffer_increment().
*/
#ifndef _di_fl_fss_basic_list_object_write_
- extern f_return_status fl_fss_basic_list_object_write(const f_string_static object, f_string_range *range, f_string_dynamic *buffer);
+ extern f_return_status fl_fss_basic_list_object_write(const f_string_static object, f_string_range *range, f_string_dynamic *destination);
#endif // _di_fl_fss_basic_list_object_write_
/**
* The string to write as (does not stop at NULLS, they are ignored and not written).
* @param range
* The start/stop location within the content string to write as an content.
- * @param buffer
+ * @param destination
* The buffer where the content is written to.
- * This will be auto-incremented and must not be a static string.
*
* @return
* F_none on success.
* Errors from (with error bit): f_utf_buffer_increment().
*/
#ifndef _di_fl_fss_basic_list_content_write_
- extern f_return_status fl_fss_basic_list_content_write(const f_string_static content, f_string_range *range, f_string_dynamic *buffer);
+ extern f_return_status fl_fss_basic_list_content_write(const f_string_static content, f_string_range *range, f_string_dynamic *destination);
#endif // _di_fl_fss_basic_list_content_write_
#ifdef __cplusplus
#endif
#ifndef _di_fl_fss_extended_object_read_
- f_return_status fl_fss_extended_object_read(f_string_dynamic *buffer, f_string_range *range, f_fss_object *found) {
+ f_return_status fl_fss_extended_object_read(f_string_dynamic *buffer, f_string_range *range, f_fss_object *found, f_fss_quoted *quoted) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return F_status_set_error(F_parameter);
+ if (buffer->used == 0) return F_status_set_error(F_parameter);
if (range == 0) return F_status_set_error(F_parameter);
if (found == 0) return F_status_set_error(F_parameter);
- if (range->stop < range->start) return F_status_set_error(F_parameter);
- if (buffer->used == 0) return F_status_set_error(F_parameter);
+ if (range->start > range->stop) return F_status_set_error(F_parameter);
if (range->start >= buffer->used) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- return private_fl_fss_basic_object_read(F_false, buffer, range, found);
+ f_status status = F_none;
+ f_string_lengths delimits = f_string_lengths_initialize;
+
+ status = private_fl_fss_basic_object_read(buffer, range, found, quoted, &delimits);
+ if (F_status_is_error(status)) {
+ f_macro_string_lengths_delete_simple(delimits);
+ return status;
+ }
+
+ if (status == FL_fss_found_object_not || status == F_data_not || status == F_data_not_eos || status == F_data_not_stop) {
+ f_macro_string_lengths_delete_simple(delimits);
+ return status;
+ }
+
+ fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
+
+ return status;
}
#endif // _di_fl_fss_extended_object_read_
#ifndef _di_fl_fss_extended_content_read_
- f_return_status fl_fss_extended_content_read(f_string_dynamic *buffer, f_string_range *range, f_fss_content *found) {
+ f_return_status fl_fss_extended_content_read(f_string_dynamic *buffer, f_string_range *range, f_fss_content *found, f_fss_quoteds *quoteds) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return F_status_set_error(F_parameter);
if (buffer->used == 0) return F_status_set_error(F_parameter);
if (range == 0) return F_status_set_error(F_parameter);
if (found == 0) return F_status_set_error(F_parameter);
- if (range->stop < range->start) return F_status_set_error(F_parameter);
+ if (range->start > range->stop) return F_status_set_error(F_parameter);
if (range->start >= buffer->used) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = F_none;
- // delimits must only be applied once a valid object is found.
- f_string_lengths delimits = f_string_lengths_initialize;
-
status = f_fss_skip_past_space(*buffer, range);
if (F_status_is_error(status)) return status;
return F_data_not_stop;
}
- bool has_delimit = F_false;
- int8_t quoted = 0;
-
- bool continue_main_loop = F_false;
+ f_string_lengths delimits = f_string_lengths_initialize;
- f_string_length location = 0;
- f_array_length already_used = found->used;
+ uint8_t content_found = 0;
while (range->start <= range->stop && range->start < buffer->used) {
- quoted = 0;
+ f_string_range content_partial = f_string_range_initialize;
+ f_fss_quoted quoted = 0;
- if (found->used >= found->size) {
- f_macro_fss_content_resize(status, (*found), found->size + f_fss_default_allocation_step);
+ status = private_fl_fss_basic_object_read(buffer, range, &content_partial, "ed, &delimits);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
- }
-
- // begin the search.
- found->array[found->used].start = range->start;
- found->array[found->used].stop = 0;
-
- // identify where the content begins.
- if (buffer->string[range->start] == f_fss_delimit_slash) {
- f_string_length last_slash = range->start;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
-
- while (range->start <= range->stop && range->start < buffer->used) {
- if (buffer->string[range->start] == f_fss_delimit_placeholder) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
+ if (status == FL_fss_found_object || status == FL_fss_found_object_content_not) {
+ if (found->used == found->size) {
+ if (found->used + f_fss_default_allocation_step > found->size) {
+ if (found->used == f_array_length_size) {
f_macro_string_lengths_delete_simple(delimits);
- return status;
+ return F_status_set_error(F_buffer_too_large);
}
-
- continue;
- }
-
- status = f_fss_is_space(*buffer, *range);
-
- if (status == F_true) {
- found->array[found->used].stop = range->start - 1;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
-
- found->used++;
-
- if (buffer->string[range->start] == f_fss_extended_close) {
- fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
-
- return FL_fss_found_content;
+ else {
+ f_macro_fss_content_resize(status, (*found), found->size + f_fss_default_allocation_step);
}
-
- continue_main_loop = F_true;
- break;
- }
- else if (F_status_is_error(status)) {
- return status;
}
- else if (buffer->string[range->start] != f_fss_delimit_slash) {
- break;
+ else {
+ f_macro_fss_content_resize(status, (*found), found->size + f_fss_default_allocation_step);
}
- last_slash = range->start;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
if (F_status_is_error(status)) return status;
- } // while
- if (continue_main_loop) {
- continue_main_loop = F_false;
- continue;
- }
-
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*range), (*found), delimits, F_none_eos, F_none_stop)
-
- if (buffer->string[range->start] == f_fss_delimit_single_quote || buffer->string[range->start] == f_fss_delimit_double_quote) {
- if (delimits.used >= delimits.size) {
- f_macro_string_lengths_resize(status, delimits, delimits.size + f_fss_default_allocation_step);
-
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ if (quoteds) {
+ f_macro_fss_quoteds_resize(status, (*quoteds), found->size);
}
-
- delimits.array[delimits.used] = last_slash;
- delimits.used++;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
- }
- }
- else if (buffer->string[range->start] == f_fss_delimit_single_quote || buffer->string[range->start] == f_fss_delimit_double_quote) {
- quoted = buffer->string[range->start];
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
}
- found->array[found->used].start = range->start;
- }
-
- // identify where the content ends.
- if (quoted == 0) {
- status = F_none;
-
- for (;;) {
- status = f_fss_is_space(*buffer, *range);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
-
- if (status == F_true) break;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
-
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*range), (*found), delimits, F_none_eos, F_none_stop)
- } // for
-
- found->array[found->used].stop = range->start - 1;
+ found->array[found->used] = content_partial;
found->used++;
- if (buffer->string[range->start] == f_fss_extended_close) {
- fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
-
- range->start++;
- return FL_fss_found_content;
+ if (quoteds) {
+ quoteds->array[quoteds->used] = quoted;
+ quoteds->used = found->used;
}
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ content_found = 1;
- continue;
+ if (status == FL_fss_found_object_content_not) break;
}
- else {
- while (range->start <= range->stop && range->start < buffer->used) {
-
- if (buffer->string[range->start] == f_fss_delimit_slash) {
- f_string_length first_slash = range->start;
- f_string_length slash_count = 1;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
-
- while (range->start <= range->stop && range->start < buffer->used) {
- if (buffer->string[range->start] == f_fss_delimit_placeholder) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
-
- continue;
- }
- else if (buffer->string[range->start] != f_fss_delimit_slash) {
- break;
- }
-
- slash_count++;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
- } // while
-
- fl_macro_fss_content_return_on_overflow((*buffer), (*range), (*found), delimits, F_unterminated_group_eos, F_unterminated_group_stop)
-
- if (buffer->string[range->start] == quoted) {
- location = range->start;
- range->start = first_slash;
-
- // check to see if there is a whitespace, EOS, or EOL after the quote, if not, then this is not a closing quote and delimits do not apply.
- {
- f_string_length location = range->start;
-
- if (range->start + 1 <= range->stop && range->start + 1 < buffer->used) {
- range->start++;
-
- fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*range));
-
- if (range->start <= range->stop && range->start < buffer->used) {
- status = f_fss_is_space(*buffer, *range);
- if (F_status_is_error(status)) {
- return status;
- }
- }
- else {
- // EOS or EOL was reached, so it is a valid closing quote.
- // (for EOL, this is always TRUE, for EOS this could be false but there is no way to know this, so assume TRUE (@todo maybe none on stop?).
- status = F_true;
- }
- }
- else {
- // EOS or EOL was reached, so it is a valid closing quote.
- // (for EOL, this is always TRUE, for EOS this could be false but there is no way to know this, so assume TRUE (@todo maybe none on stop?).
- status = F_true;
- }
-
- range->start = location;
- }
-
- if (status == F_true) {
- if (slash_count % 2 == 0) {
- if (delimits.used + (slash_count / 2) >= delimits.size) {
- f_macro_string_lengths_resize(status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step);
-
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
- }
-
- 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++;
- }
-
- slash_count--;
- }
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
- } // while
-
- range->start = location + 1;
-
- fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*range));
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*range), (*found), delimits, F_none_eos, F_none_stop)
-
- status = f_fss_is_graph(*buffer, *range);
-
- if (status == F_true) {
- while (range->start < buffer->used && range->start <= range->stop && buffer->string[range->start] != f_string_eol[0]) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
- } // while
-
- fl_macro_fss_content_return_on_overflow((*buffer), (*range), (*found), delimits, F_unterminated_group_eos, F_unterminated_group_stop)
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
-
- return F_unterminated_group;
- }
- else if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
- else if (buffer->string[range->start] == f_fss_extended_close) {
- fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
-
- found->array[found->used].stop = location - 1;
-
- range->start++;
- found->used++;
- return FL_fss_found_content;
- }
-
- found->array[found->used].stop = location - 1;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
-
- found->used++;
- continue;
- }
- else {
- if (delimits.used + (slash_count / 2) >= delimits.size) {
- f_macro_string_lengths_resize(status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step);
-
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
- }
-
- 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++;
- }
-
- slash_count--;
- }
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
- } // while
-
- range->start = location;
- }
- }
- }
- }
- else if (buffer->string[range->start] == quoted) {
- // check to see if there is a whitespace, EOS, or EOL after the quote, if not, then this is not a closing quote.
- {
- f_string_length location = range->start;
-
- status = F_false;
-
- if (range->start + 1 <= range->stop && range->start + 1 < buffer->used) {
- range->start++;
-
- fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*range));
-
- if (range->start <= range->stop && range->start < buffer->used) {
- status = f_fss_is_space(*buffer, *range);
- if (F_status_is_error(status)) {
- return status;
- }
- }
- else {
- // EOS or EOL was reached, so it is a valid closing quote.
- // (for EOL, this is always TRUE, for EOS this could be false but there is no way to know this, so assume TRUE (@todo maybe none on stop?).
- status = F_true;
- }
- }
- else {
- // EOS or EOL was reached, so it is a valid closing quote.
- // (for EOL, this is always TRUE, for EOS this could be false but there is no way to know this, so assume TRUE (@todo maybe none on stop?).
- status = F_true;
- }
-
- range->start = location;
- }
-
- if (status == F_true) {
- found->array[found->used].stop = range->start - 1;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
-
- while (range->start <= range->stop && range->start < buffer->used) {
-
- if (buffer->string[range->start] == f_fss_extended_close) {
- fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
-
- range->start++;
- found->used++;
- return FL_fss_found_content;
- }
-
- status = f_fss_is_space(*buffer, *range);
-
- if (status == F_true) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
-
- found->used++;
- continue_main_loop = F_true;
- break;
- }
- else if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
- else if (buffer->string[range->start] != f_fss_delimit_placeholder) {
-
- while (range->start < buffer->used && range->start <= range->stop) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
-
- fl_macro_fss_content_return_on_overflow((*buffer), (*range), (*found), delimits, F_unterminated_group_eos, F_unterminated_group_stop)
-
- if (buffer->string[range->start] == f_string_eol[0]) break;
- } // while
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
-
- return F_unterminated_group;
- }
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
-
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*range), (*found), delimits, F_none_eos, F_none_stop)
- } // while
-
- if (continue_main_loop) break;
-
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*range), (*found), delimits, F_none_eos, F_none_stop)
- }
- }
- else if (buffer->string[range->start] == f_fss_extended_close) {
-
- if (found->used == already_used) {
- range->start++;
- return FL_fss_found_content_not;
- }
- else {
- fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
-
- found->array[found->used].stop = range->start - 1;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
-
- found->used++;
-
- return FL_fss_found_content;
- }
- }
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
- } // while
-
- fl_macro_fss_content_return_on_overflow((*buffer), (*range), (*found), delimits, F_unterminated_group_eos, F_unterminated_group_stop)
+ else if (status == FL_fss_found_object_not) {
+ break;
}
+ else if (status == F_data_not_eos) {
+ if (content_found) {
+ status = F_none_eos;
+ }
- if (continue_main_loop) {
- continue_main_loop = F_false;
- continue;
+ content_found = 2;
+ break;
}
+ else if (status == F_data_not_stop) {
+ if (content_found) {
+ status = F_none_stop;
+ }
- break;
- } // while
-
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*range), (*found), delimits, F_none_eos, F_none_stop)
-
- // seek to the end of the line when no valid content is found
- while (range->start < buffer->used && range->start <= range->stop && buffer->string[range->start] != f_string_eol[0]) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
+ content_found = 2;
+ break;
+ }
+ else if (status == F_unterminated_group_eos || status == F_unterminated_group_eos) {
+ if (content_found) {
+ content_found = 2;
+ }
+ break;
+ }
+ else if (F_status_is_error(status)) {
f_macro_string_lengths_delete_simple(delimits);
return status;
}
} // while
- fl_macro_fss_content_delimited_return_on_overflow((*buffer), (*range), (*found), delimits, F_none_eos, F_none_stop)
+ if (content_found) {
+ fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
- if (found->used == already_used) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
+ if (content_found == 2) {
return status;
}
- return FL_fss_found_content_not;
+ return FL_fss_found_content;
}
- fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
-
- return FL_fss_found_content;
+ return FL_fss_found_content_not;
}
#endif // _di_fl_fss_extended_content_read_
#ifndef _di_fl_fss_extended_object_write_
- f_return_status fl_fss_extended_object_write(const f_string_static object, f_string_range *range, f_string_dynamic *buffer) {
+f_return_status fl_fss_extended_object_write(const f_string_static object, const f_fss_quoted quoted, f_string_range *range, f_string_dynamic *destination) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == 0) return F_status_set_error(F_parameter);
+ if (destination == 0) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- f_status status = F_none;
- bool quoted = F_false;
-
- f_string_range buffer_position = f_string_range_initialize;
- f_string_length start_position = f_string_initialize;
- f_string_length pre_allocate_size = 0;
-
- fl_macro_fss_skip_past_delimit_placeholders(object, (*range))
-
- if (range->start > range->stop) return F_data_not_stop;
- else if (range->start >= object.used) return F_data_not_eos;
-
- start_position = range->start;
-
- // add an additional 3 to ensure that there is room for the start and stop quotes or a slash delimit and the object open character.
- pre_allocate_size = buffer->used + (range->stop - range->start) + 3 + f_fss_default_allocation_step_string;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size);
- if (F_status_is_error(status)) return status;
- }
-
- buffer_position.start = buffer->used;
- buffer_position.stop = buffer->used;
-
- if (object.string[range->start] == f_fss_delimit_slash) {
- while (range->start <= range->stop && range->start < object.used) {
- if (object.string[range->start] == f_fss_delimit_placeholder) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- continue;
- } else if (object.string[range->start] != f_fss_delimit_slash) {
- break;
- }
-
- buffer->string[buffer_position.stop] = object.string[range->start];
- buffer_position.stop++;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
- } // while
-
- if (object.string[range->start] == f_fss_delimit_single_quote || object.string[range->start] == f_fss_delimit_double_quote) {
- pre_allocate_size++;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
-
- if (F_status_is_error(status)) return status;
- }
-
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer->string[buffer_position.stop + 1] = object.string[range->start];
- buffer_position.stop += 2;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
- }
- }
- else if (object.string[range->start] == f_fss_delimit_single_quote || object.string[range->start] == f_fss_delimit_double_quote) {
- pre_allocate_size++;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
- if (F_status_is_error(status)) return status;
- }
-
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer->string[buffer_position.stop + 1] = object.string[range->start];
- buffer_position.stop += 2;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
- }
- else if (object.string[range->start] == f_fss_comment) {
- quoted = F_true;
- }
-
- while (range->start <= range->stop && range->start < object.used) {
- if (object.string[range->start] == f_fss_delimit_placeholder) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- continue;
- }
- else if (object.string[range->start] == f_string_eol[0]) {
- if (quoted) {
- buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
- buffer_position.stop++;
- }
-
- buffer->string[buffer_position.stop] = f_fss_basic_open;
- buffer->used = buffer_position.stop + 1;
-
- return F_none_eol;
- }
- else if ((status = f_fss_is_space(*buffer, *range)) == F_true || quoted) {
- f_string_length first_space = range->start;
-
- if (!quoted) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- while (range->start <= range->stop && range->start < object.used && isspace(object.string[range->start])) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
- } // while
-
- if (range->start > range->stop || range->start >= object.used) {
- buffer->string[first_space] = f_fss_extended_open;
- buffer->used = buffer_position.stop + 1;
- break;
- }
- }
-
- pre_allocate_size++;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
-
- if (F_status_is_error(status)) return status;
- }
-
- // restart the loop searching for f_fss_delimit_double_quote.
- range->start = start_position;
- buffer_position.stop = buffer_position.start;
-
- buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
- buffer_position.stop++;
-
- while (range->start <= range->stop && range->start < object.used) {
- if (object.string[range->start] == f_fss_delimit_placeholder) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- continue;
- }
- else if (object.string[range->start] == f_fss_delimit_double_quote) {
- pre_allocate_size++;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
-
- if (F_status_is_error(status)) return status;
- }
-
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer_position.stop++;
- }
- else if (object.string[range->start] == f_fss_delimit_slash) {
- f_string_length slash_count = 0;
-
- for (;;) {
- buffer->string[buffer_position.stop] = object.string[range->start];
- buffer_position.stop++;
- slash_count++;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- fl_macro_fss_skip_past_delimit_placeholders(object, (*range));
-
- if (range->start > range->stop || range->start >= object.used) {
- break;
- }
-
- if (object.string[range->start] == f_fss_delimit_double_quote) {
- pre_allocate_size += slash_count;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
- if (F_status_is_error(status)) return status;
- }
-
- break;
- }
- else if (object.string[range->start] != f_fss_delimit_slash) {
- slash_count = 0;
- break;
- }
- } // for
-
- while (slash_count > 0) {
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer_position.stop++;
- slash_count--;
- } // while
-
- continue;
- }
- else if (object.string[range->start] == f_string_eol[0]) {
- buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
- buffer_position.stop++;
-
- buffer->string[buffer_position.stop] = f_fss_basic_open;
- buffer->used = buffer_position.stop + 1;
-
- return F_none_eol;
- }
-
- buffer->string[buffer_position.stop] = object.string[range->start];
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- buffer_position.stop++;
- } // while
-
- buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
- buffer->string[buffer_position.stop + 1] = f_fss_extended_open;
- buffer->used = buffer_position.stop + 2;
- break;
- }
- else if (F_status_is_error(status)) {
- return status;
- }
-
- buffer->string[buffer_position.stop] = object.string[range->start];
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- buffer_position.stop++;
- } // while
-
- if (buffer->used < buffer_position.stop) {
- buffer->string[buffer_position.stop] = f_fss_extended_open;
- buffer->used = buffer_position.stop + 1;
- }
-
- if (range->start > range->stop) return F_none_stop;
- else if (range->start >= object.used) return F_none_eos;
-
- return F_none;
+ return private_fl_fss_basic_object_write(object, quoted, range, destination);
}
#endif // _di_fl_fss_extended_object_write_
#ifndef _di_fl_fss_extended_content_write_
- f_return_status fl_fss_extended_content_write(const f_string_static content, f_string_range *range, f_string_dynamic *buffer) {
+ f_return_status fl_fss_extended_content_write(const f_string_static content, const f_fss_quoted quoted, f_string_range *range, f_string_dynamic *destination) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == 0) return F_status_set_error(F_parameter);
+ if (destination == 0) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
- f_status status = F_none;
- int8_t quoted = 0;
-
- f_string_range buffer_position = f_string_range_initialize;
- f_string_length start_position = 0;
- f_string_length pre_allocate_size = 0;
-
- fl_macro_fss_skip_past_delimit_placeholders(content, (*range))
-
- if (range->start > range->stop) return F_data_not_stop;
- else if (range->start >= content.used) return F_data_not_eos;
-
- // add an additional 1 to ensure that there is room for the terminating newline.
- pre_allocate_size = buffer->used + (content.used) + 1 + f_fss_default_allocation_step_string;
-
- buffer_position.start = buffer->used;
- buffer_position.stop = buffer->used;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size);
- if (F_status_is_error(status)) return status;
- }
-
- start_position = range->start;
-
- // if this first slash is followed by a quote, then that quote must be delimited.
- if (content.string[range->start] == f_fss_delimit_slash) {
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer_position.stop++;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- while (range->start <= range->stop && range->start < content.used) {
- if (content.string[range->start] == f_fss_delimit_placeholder) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- continue;
- }
-
- if (content.string[range->start] != f_fss_delimit_slash) {
- break;
- }
-
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer_position.stop++;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
- } // while
-
- if (range->start > range->stop) {
- buffer->string[buffer_position.stop] = ' ';
- buffer->used = buffer_position.stop + 1;
- return F_none_stop;
- }
- else if (range->start >= content.used) {
- buffer->string[buffer_position.stop] = ' ';
- buffer->used = buffer_position.stop + 1;
- return F_none_eos;
- }
-
- if (content.string[range->start] == f_fss_delimit_single_quote || content.string[range->start] == f_fss_delimit_double_quote) {
- pre_allocate_size++;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
- if (F_status_is_error(status)) return status;
- }
-
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer->string[buffer_position.stop + 1] = content.string[range->start];
- buffer_position.stop += 2;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
- }
- }
- else if (content.string[range->start] == f_fss_delimit_single_quote || content.string[range->start] == f_fss_delimit_double_quote) {
- pre_allocate_size++;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
- if (F_status_is_error(status)) return status;
- }
-
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer->string[buffer_position.stop + 1] = content.string[range->start];
- buffer_position.stop += 2;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
- }
-
- while (range->start <= range->stop && range->start < content.used) {
- if (content.string[range->start] == f_string_eol[0]) {
- buffer->string[buffer_position.stop] = ' ';
- buffer->used = buffer_position.stop + 1;
- return F_none_eol;
- }
-
- if (content.string[range->start] != f_fss_delimit_placeholder && (status = f_fss_is_space(*buffer, *range)) == F_true) {
- quoted = f_fss_delimit_double_quote;
-
- pre_allocate_size += 2;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
- if (F_status_is_error(status)) return status;
- }
-
- range->start = start_position;
- buffer_position.stop = buffer_position.start;
- buffer->string[buffer_position.stop] = f_fss_delimit_double_quote;
- buffer_position.stop++;
- break;
- }
- else if (F_status_is_error(status)) {
- return status;
- }
-
- buffer->string[buffer_position.stop] = content.string[range->start];
- buffer_position.stop++;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
- } // while
-
- if (quoted != 0) {
- while (range->start <= range->stop && range->start < content.used) {
- if (content.string[range->start] == f_fss_delimit_slash) {
- f_string_length slash_count = 1;
-
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer_position.stop++;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- while (range->start <= range->stop && range->start < content.used) {
- if (content.string[range->start] == f_fss_delimit_placeholder) {
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
-
- continue;
- }
-
- if (content.string[range->start] != f_fss_delimit_slash) {
- break;
- }
-
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer_position.stop++;
- slash_count++;
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
- } // while
-
- if (content.string[range->start] == quoted || range->start > range->stop || range->start >= content.used) {
- pre_allocate_size += slash_count + 1;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
- if (F_status_is_error(status)) return status;
- }
-
- while (slash_count > 0) {
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer_position.stop++;
- slash_count--;
- } // while
-
- if (range->start > range->stop || range->start >= content.used) {
- break;
- }
-
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer->string[buffer_position.stop + 1] = quoted;
- buffer_position.stop += 2;
- }
- else {
- buffer->string[buffer_position.stop] = content.string[range->start];
- buffer_position.stop++;
- }
- }
- else if (content.string[range->start] == quoted) {
- pre_allocate_size++;
-
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
- if (F_status_is_error(status)) return status;
- }
-
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
- buffer->string[buffer_position.stop + 1] = quoted;
- buffer_position.stop += 2;
- }
- else if (content.string[range->start] == f_string_eol[0]) {
- buffer->string[buffer_position.stop] = quoted;
- buffer->string[buffer_position.stop + 1] = ' ';
- buffer->used = buffer_position.stop + 2;
- return F_none_eol;
- }
- else if (content.string[range->start] != f_fss_delimit_placeholder) {
- buffer->string[buffer_position.stop] = content.string[range->start];
- buffer_position.stop++;
- }
-
- status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) return status;
- } // while
-
- buffer->string[buffer_position.stop] = quoted;
- buffer_position.stop++;
- }
-
- buffer->string[buffer_position.stop] = ' ';
- buffer->used = buffer_position.stop + 1;
-
- if (range->start > range->stop) return F_none_stop;
- else if (range->start >= content.used) return F_none_eos;
-
- return F_none;
+ // this operates exactly like an object, syntax-wise, so just use the object write.
+ return private_fl_fss_basic_object_write(content, quoted, range, destination);
}
#endif // _di_fl_fss_extended_content_write_
* A start location past the stop location or buffer used means that the entire range was processed.
* @param found
* A set of all locations where a valid object was found.
+ * @param quoted
+ * This will store whether or not this object is quoted and what quote is in use.
+ * Set pointer address to 0 to not use.
*
* @return
* FL_fss_found_object on success and object was found (start location is at end of object).
* F_none_stop on success after reaching stopping point (a valid object is not yet confirmed).
* F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found).
* F_data_not_stop no data found after reaching stopping point (essentially only comments are found).
- * F_unterminated_group_eos (with warning bit) if EOS was reached before the a group termination was reached.
- * F_unterminated_group_stop (with warning bit) if stop point was reached before the a group termination was reached.
+ * F_unterminated_group_eos if EOS was reached before the a group termination was reached.
+ * F_unterminated_group_stop if stop point was reached before the a group termination was reached.
+ * F_buffer_too_large (with error bit) if a buffer is too large.
* F_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
* F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
* F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
* Errors from (with error bit): f_fss_skip_past_space().
*/
#ifndef _di_fl_fss_extended_object_read_
- extern f_return_status fl_fss_extended_object_read(f_string_dynamic *buffer, f_string_range *range, f_fss_object *found);
+ extern f_return_status fl_fss_extended_object_read(f_string_dynamic *buffer, f_string_range *range, f_fss_object *found, f_fss_quoted *quoted);
#endif // _di_fl_fss_extended_object_read_
/**
* A start location past the stop location or buffer used means that the entire range was processed.
* @param found
* A set of all locations where a valid content was found.
+ * @param quoteds
+ * An array of quotes designating whether or not content is quoted and what quote is in use.
+ * Set pointer address to 0 to not use.
*
* @return
* FL_fss_found_content on success and content was found (start location is at end of content).
* F_none_stop on success after reaching stopping point (a valid object is not yet confirmed).
* F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found).
* F_data_not_stop no data found after reaching stopping point (essentially only comments are found).
- * F_unterminated_group_eos (with warning bit) if EOS was reached before the a group termination was reached.
- * F_unterminated_group_stop (with warning bit) if stop point was reached before the a group termination was reached.
+ * F_unterminated_group_eos if EOS was reached before the a group termination was reached.
+ * F_unterminated_group_stop if stop point was reached before the a group termination was reached.
+ * F_buffer_too_large (with error bit) if a buffer is too large.
* F_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
* F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
* F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
* Errors from (with error bit): f_fss_skip_past_space().
*/
#ifndef _di_fl_fss_extended_content_read_
- extern f_return_status fl_fss_extended_content_read(f_string_dynamic *buffer, f_string_range *range, f_fss_content *found);
+ extern f_return_status fl_fss_extended_content_read(f_string_dynamic *buffer, f_string_range *range, f_fss_content *found, f_fss_quoteds *quoteds);
#endif // _di_fl_fss_extended_content_read_
/**
*
* @param object
* The string to write as (does not stop at NULLS, they are ignored and not written).
+ * @param quoted
+ * If 0, then double quotes are auto-inserted, when required.
+ * Otherwise, this is the type of quote to wrap the object in when writing.
* @param range
* The start/stop location within the object string to write as an object.
- * @param buffer
+ * @param destination
* The buffer where the object is written to.
- * This will be auto-incremented and must not be a static string.
*
* @return
* F_none on success.
* Errors from (with error bit): f_utf_buffer_increment().
*/
#ifndef _di_fl_fss_extended_object_write_
- extern f_return_status fl_fss_extended_object_write(const f_string_static object, f_string_range *range, f_string_dynamic *buffer);
+ extern f_return_status fl_fss_extended_object_write(const f_string_static object, const f_fss_quoted quoted, f_string_range *range, f_string_dynamic *destination);
#endif // _di_fl_fss_extended_object_write_
/**
*
* @param content
* The string to write as (does not stop at NULLS, they are ignored and not written).
+ * @param quoted
+ * If 0, then double quotes are auto-inserted, when required.
+ * Otherwise, this is the type of quote to wrap the object in when writing.
* @param range
* The start/stop location within the content string to write as an content.
- * @param buffer
+ * @param destination
* The buffer where the content is written to.
- * This will be auto-incremented and must not be a static string.
*
* @return
* F_none on success.
* Errors from (with error bit): f_utf_buffer_increment().
*/
#ifndef _di_fl_fss_extended_content_write_
- extern f_return_status fl_fss_extended_content_write(const f_string_static content, f_string_range *range, f_string_dynamic *buffer);
+ extern f_return_status fl_fss_extended_content_write(const f_string_static content, const f_fss_quoted quoted, f_string_range *range, f_string_dynamic *destination);
#endif // _di_fl_fss_extended_content_write_
#ifdef __cplusplus
f_return_status fl_fss_extended_list_object_read(f_string_dynamic *buffer, f_string_range *range, f_fss_object *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return F_status_set_error(F_parameter);
+ if (buffer->used == 0) return F_status_set_error(F_parameter);
if (range == 0) return F_status_set_error(F_parameter);
if (found == 0) return F_status_set_error(F_parameter);
- if (range->stop < range->start) return F_status_set_error(F_parameter);
- if (buffer->used == 0) return F_status_set_error(F_parameter);
+ if (range->start > range->stop) return F_status_set_error(F_parameter);
if (range->start >= buffer->used) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
f_return_status fl_fss_extended_list_content_read(f_string_dynamic *buffer, f_string_range *range, f_fss_nest *found) {
#ifndef _di_level_1_parameter_checking_
if (buffer == 0) return F_status_set_error(F_parameter);
+ if (buffer->used == 0) return F_status_set_error(F_parameter);
if (range == 0) return F_status_set_error(F_parameter);
if (found == 0) return F_status_set_error(F_parameter);
- if (range->stop < range->start) return F_status_set_error(F_parameter);
- if (buffer->used == 0) return F_status_set_error(F_parameter);
+ if (range->start > range->stop) return F_status_set_error(F_parameter);
if (range->start >= buffer->used) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
}
}
- if (found->depth[depth].used >= found->depth[depth].size) {
+ if (found->depth[depth].used == found->depth[depth].size) {
f_macro_fss_items_resize(status, found->depth[depth], found->depth[depth].size + f_fss_default_allocation_step);
if (F_status_is_error(status)) {
#endif // _di_fl_fss_extended_list_content_read_
#ifndef _di_fl_fss_extended_list_object_write_
- f_return_status fl_fss_extended_list_object_write(const f_string_static object, f_string_range *range, f_string_dynamic *buffer) {
+ f_return_status fl_fss_extended_list_object_write(const f_string_static object, f_string_range *range, f_string_dynamic *destination) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == 0) return F_status_set_error(F_parameter);
+ if (destination == 0) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
f_status status = F_none;
f_string_range buffer_position = f_string_range_initialize;
f_string_length start_position = f_string_initialize;
- f_string_length pre_allocate_size = 0;
+ f_string_length size_allocate = 0;
f_string_length start_buffer = 0;
fl_macro_fss_skip_past_delimit_placeholders(object, (*range))
start_position = range->start;
// add an additional 2 to ensure that there is room for the slash delimit and the object open character.
- pre_allocate_size = buffer->used + (range->stop - range->start) + 2 + f_fss_default_allocation_step_string;
+ size_allocate = destination->used + (range->stop - range->start) + 2 + f_fss_default_allocation_step_string;
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size);
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate);
if (F_status_is_error(status)) return status;
}
- buffer_position.start = buffer->used;
- buffer_position.stop = buffer->used;
+ buffer_position.start = destination->used;
+ buffer_position.stop = destination->used;
while (range->start <= range->stop && range->start < object.used) {
if (object.string[range->start] == f_fss_comment) {
}
if (object.string[range->start] != f_fss_delimit_placeholder) {
- buffer->string[buffer_position.stop] = object.string[range->start];
+ destination->string[buffer_position.stop] = object.string[range->start];
buffer_position.stop++;
}
if (object.string[range->start] == f_fss_delimit_slash) {
f_string_length slash_count = 1;
- buffer->string[buffer_position.stop] = object.string[range->start];
+ destination->string[buffer_position.stop] = object.string[range->start];
buffer_position.stop++;
status = f_utf_buffer_increment(object, range, 1);
break;
}
- buffer->string[buffer_position.stop] = object.string[range->start];
+ destination->string[buffer_position.stop] = object.string[range->start];
buffer_position.stop++;
status = f_utf_buffer_increment(object, range, 1);
} // while
if (range->start > range->stop || range->start >= object.used) {
- pre_allocate_size += slash_count;
+ size_allocate += slash_count;
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string);
if (F_status_is_error(status)) return status;
}
while (slash_count > 0) {
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
+ destination->string[buffer_position.stop] = f_fss_delimit_slash;
buffer_position.stop++;
slash_count--;
} // while
}
if (object.string[range->start] != f_fss_delimit_placeholder) {
- buffer->string[buffer_position.stop] = object.string[range->start];
+ destination->string[buffer_position.stop] = object.string[range->start];
buffer_position.stop++;
}
if (F_status_is_error(status)) return status;
} // while
- buffer->string[buffer_position.stop] = f_fss_extended_list_open;
- buffer->string[buffer_position.stop + 1] = f_string_eol[0];
- buffer->used = buffer_position.stop + 2;
+ destination->string[buffer_position.stop] = f_fss_extended_list_open;
+ destination->string[buffer_position.stop + 1] = f_string_eol[0];
+ destination->used = buffer_position.stop + 2;
if (range->start > range->stop) return F_none_stop;
else if (range->start >= object.used) return F_none_eos;
#endif // _di_fl_fss_extended_list_object_write_
#ifndef _di_fl_fss_extended_list_content_write_
- f_return_status fl_fss_extended_list_content_write(const f_string_static content, f_string_range *range, f_string_dynamic *buffer) {
+ f_return_status fl_fss_extended_list_content_write(const f_string_static content, f_string_range *range, f_string_dynamic *destination) {
#ifndef _di_level_1_parameter_checking_
- if (buffer == 0) return F_status_set_error(F_parameter);
+ if (destination == 0) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
// @todo
f_string_range buffer_position = f_string_range_initialize;
f_string_length start_position = f_string_initialize;
- f_string_length pre_allocate_size = 0;
+ f_string_length size_allocate = 0;
fl_macro_fss_skip_past_delimit_placeholders(content, (*range))
start_position = range->start;
// add an additional 2 to ensure that there is room for the slash delimit and the content open character.
- pre_allocate_size = buffer->used + (range->stop - range->start) + 2 + f_fss_default_allocation_step_string;
+ size_allocate = destination->used + (range->stop - range->start) + 2 + f_fss_default_allocation_step_string;
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size);
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate);
if (F_status_is_error(status)) return status;
}
- buffer_position.start = buffer->used;
- buffer_position.stop = buffer->used;
+ buffer_position.start = destination->used;
+ buffer_position.stop = destination->used;
while (range->start <= range->stop && range->start < content.used) {
if (content.string[range->start] == f_fss_delimit_slash && !is_comment) {
f_string_length slash_count = 1;
- buffer->string[buffer_position.stop] = content.string[range->start];
+ destination->string[buffer_position.stop] = content.string[range->start];
buffer_position.stop++;
has_graph = F_true;
break;
}
- buffer->string[buffer_position.stop] = content.string[range->start];
+ destination->string[buffer_position.stop] = content.string[range->start];
buffer_position.stop++;
status = f_utf_buffer_increment(content, range, 1);
} // while
if (content.string[range->start] == f_string_eol[0] || range->start >= content.used || range->start > range->stop) {
- pre_allocate_size += slash_count + 1;
+ size_allocate += slash_count + 1;
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string);
if (F_status_is_error(status)) return status;
}
while (slash_count > 0) {
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
+ destination->string[buffer_position.stop] = f_fss_delimit_slash;
buffer_position.stop++;
slash_count--;
} // while
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
+ destination->string[buffer_position.stop] = f_fss_delimit_slash;
buffer_position.stop++;
has_graph = F_false;
is_comment = F_false;
}
- buffer->string[buffer_position.stop] = f_fss_extended_list_open;
+ destination->string[buffer_position.stop] = f_fss_extended_list_open;
buffer_position.stop++;
range->start = start + 1;
continue;
} // while
if (content.string[range->start] == f_string_eol[0] || range->start >= content.used || range->start > range->stop) {
- pre_allocate_size++;
+ size_allocate++;
- if (pre_allocate_size > buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), pre_allocate_size + f_fss_default_allocation_step_string);
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string);
if (F_status_is_error(status)) return status;
}
- buffer->string[buffer_position.stop] = f_fss_delimit_slash;
+ destination->string[buffer_position.stop] = f_fss_delimit_slash;
buffer_position.stop++;
has_graph = F_false;
is_comment = F_false;
}
- buffer->string[buffer_position.stop] = f_fss_extended_list_open;
+ destination->string[buffer_position.stop] = f_fss_extended_list_open;
buffer_position.stop++;
range->start = start + 1;
continue;
}
if (content.string[range->start] != f_fss_delimit_placeholder) {
- buffer->string[buffer_position.stop] = content.string[range->start];
+ destination->string[buffer_position.stop] = content.string[range->start];
buffer_position.stop++;
}
if (F_status_is_error(status)) return status;
} // while
- buffer->string[buffer_position.stop] = f_string_eol[0];
- buffer->used = buffer_position.stop + 1;
+ destination->string[buffer_position.stop] = f_string_eol[0];
+ destination->used = buffer_position.stop + 1;
if (range->start > range->stop) return F_none_stop;
else if (range->start >= content.used) return F_none_eos;
* F_none_stop on success after reaching stopping point (a valid object is not yet confirmed).
* F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found).
* F_data_not_stop no data found after reaching stopping point (essentially only comments are found).
- * F_unterminated_group_eos (with warning bit) if EOS was reached before the a group termination was reached.
- * F_unterminated_group_stop (with warning bit) if stop point was reached before the a group termination was reached.
+ * F_unterminated_group_eos if EOS was reached before the a group termination was reached.
+ * F_unterminated_group_stop if stop point was reached before the a group termination was reached.
+ * F_buffer_too_large (with error bit) if a buffer is too large.
* F_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
* F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
* F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
* F_none_stop on success after reaching stopping point (a valid object is not yet confirmed).
* F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found).
* F_data_not_stop no data found after reaching stopping point (essentially only comments are found).
- * F_unterminated_group_eos (with warning bit) if EOS was reached before the a group termination was reached.
- * F_unterminated_group_stop (with warning bit) if stop point was reached before the a group termination was reached.
+ * F_unterminated_group_eos if EOS was reached before the a group termination was reached.
+ * F_unterminated_group_stop if stop point was reached before the a group termination was reached.
+ * F_buffer_too_large (with error bit) if a buffer is too large.
* F_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
* F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
* F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
* The string to write as (does not stop at NULLS, they are ignored and not written).
* @param range
* The start/stop location within the object string to write as an object.
- * @param buffer
+ * @param destination
* The buffer where the object is written to.
- * This will be auto-incremented and must not be a static string.
*
* @return
* F_none on success.
* Errors from (with error bit): f_utf_buffer_increment().
*/
#ifndef _di_fl_fss_extended_list_object_write_
- extern f_return_status fl_fss_extended_list_object_write(const f_string_static object, f_string_range *range, f_string_dynamic *buffer);
+ extern f_return_status fl_fss_extended_list_object_write(const f_string_static object, f_string_range *range, f_string_dynamic *destination);
#endif // _di_fl_fss_extended_list_object_write_
/**
* The string to write as (does not stop at NULLS, they are ignored and not written).
* @param range
* The start/stop location within the content string to write as an content.
- * @param buffer
+ * @param destination
* The buffer where the content is written to.
- * This will be auto-incremented and must not be a static string.
*
* @return
* F_none on success.
* Errors from (with error bit): f_utf_buffer_increment().
*/
#ifndef _di_fl_fss_extended_list_content_write_
- extern f_return_status fl_fss_extended_list_content_write(const f_string_static content, f_string_range *range, f_string_dynamic *buffer);
+ extern f_return_status fl_fss_extended_list_content_write(const f_string_static content, f_string_range *range, f_string_dynamic *destination);
#endif // _di_fl_fss_extended_list_content_write_
#ifdef __cplusplus
// TODO: check if character to be replaced is UTF and apply placeholder to entire width.
#ifndef _di_fl_macro_fss_apply_delimit_placeholders_
#define fl_macro_fss_apply_delimit_placeholders(buffer, delimits) \
- { \
- f_status macro_allocation_status = F_none; \
- \
- f_array_length i = 0; \
- \
- while (i < delimits.used) { \
+ for (f_array_length i = 0; i < delimits.used; i++) { \
buffer.string[delimits.array[i]] = f_fss_delimit_placeholder; \
- i++; \
} \
\
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
- }
+ f_macro_string_lengths_delete_simple(delimits);
#endif // _di_fl_macro_fss_apply_delimit_placeholders_
#ifndef _di_fl_macro_fss_skip_past_delimit_placeholders_
- #define fl_macro_fss_skip_past_delimit_placeholders(buffer, location) \
- while (buffer.string[location.start] == f_fss_delimit_placeholder) { \
- location.start++;\
+ #define fl_macro_fss_skip_past_delimit_placeholders(buffer, range) \
+ while (buffer.string[range.start] == f_fss_delimit_placeholder) { \
+ range.start++;\
\
- if (location.start >= buffer.used) break; \
- if (location.start > location.stop) break; \
+ if (range.start >= buffer.used) break; \
+ if (range.start > range.stop) break; \
} // while
#endif // _di_fl_macro_fss_skip_past_delimit_placeholders_
#ifndef _di_fl_macro_fss_object_return_on_overflow_
- #define fl_macro_fss_object_return_on_overflow(buffer, location, found, delimits, eos_status, stop_status) \
- if (location.start >= buffer.used) { \
- f_status macro_allocation_status = F_none; \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ #define fl_macro_fss_object_return_on_overflow(buffer, range, found, delimits, eos_status, stop_status) \
+ if (range.start >= buffer.used) { \
+ f_macro_string_lengths_delete_simple(delimits); \
\
found.stop = buffer.used - 1; \
return eos_status; \
} \
- else if (location.start > location.stop) { \
- f_status macro_allocation_status = F_none; \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ else if (range.start > range.stop) { \
+ f_macro_string_lengths_delete_simple(delimits); \
\
- found.stop = location.stop; \
+ found.stop = range.stop; \
return stop_status; \
}
#endif // _di_fl_macro_fss_object_return_on_overflow_
#ifndef _di_fl_macro_fss_object_delimited_return_on_overflow_
- #define fl_macro_fss_object_delimited_return_on_overflow(buffer, location, found, delimits, eos_status, stop_status) \
- if (location.start >= buffer.used) { \
- f_status macro_allocation_status = F_none; \
- f_array_length i = 0; \
- \
- while (i < delimits.used) { \
+ #define fl_macro_fss_object_delimited_return_on_overflow(buffer, range, found, delimits, eos_status, stop_status) \
+ if (range.start >= buffer.used) { \
+ for (f_array_length i = 0; i < delimits.used; i++) { \
buffer.string[delimits.array[i]] = f_fss_delimit_placeholder; \
- i++; \
} \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ f_macro_string_lengths_delete_simple(delimits); \
\
found.stop = buffer.used - 1; \
return eos_status; \
} \
- else if (location.start > location.stop) { \
- f_status macro_allocation_status = F_none; \
- f_array_length i = 0; \
- \
- while (i < delimits.used) { \
+ else if (range.start > range.stop) { \
+ for (f_array_length i = 0; i < delimits.used; i++) { \
buffer.string[delimits.array[i]] = f_fss_delimit_placeholder; \
i++; \
} \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ f_macro_string_lengths_delete_simple(delimits); \
\
- found.stop = location.stop; \
+ found.stop = range.stop; \
return stop_status; \
}
#endif // _di_fl_macro_fss_object_delimited_return_on_overflow_
#ifndef _di_fl_macro_fss_content_return_on_overflow_
- #define fl_macro_fss_content_return_on_overflow(buffer, location, found, delimits, eos_status, stop_status) \
- if (location.start >= buffer.used) { \
- f_status macro_allocation_status = F_none; \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ #define fl_macro_fss_content_return_on_overflow(buffer, range, found, delimits, eos_status, stop_status) \
+ if (range.start >= buffer.used) { \
+ f_macro_string_lengths_delete_simple(delimits); \
\
found.array[found.used].stop = buffer.used - 1; \
return eos_status; \
} \
- else if (location.start > location.stop) { \
- f_status macro_allocation_status = F_none; \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ else if (range.start > range.stop) { \
+ f_macro_string_lengths_delete_simple(delimits); \
\
- found.array[found.used].stop = location.stop; \
+ found.array[found.used].stop = range.stop; \
return stop_status; \
}
#endif // _di_fl_macro_fss_content_return_on_overflow_
#ifndef _di_fl_macro_fss_content_delimited_return_on_overflow_
- #define fl_macro_fss_content_delimited_return_on_overflow(buffer, location, found, delimits, eos_status, stop_status) \
- if (location.start >= buffer.used) { \
- f_status macro_allocation_status = F_none; \
- f_array_length i = 0; \
- \
- while (i < delimits.used) { \
+ #define fl_macro_fss_content_delimited_return_on_overflow(buffer, range, found, delimits, eos_status, stop_status) \
+ if (range.start >= buffer.used) { \
+ for (f_array_length i = 0; i < delimits.used; i++) { \
buffer.string[delimits.array[i]] = f_fss_delimit_placeholder; \
- i++; \
} \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ f_macro_string_lengths_delete_simple(delimits); \
\
found.array[found.used].stop = buffer.used - 1; \
return eos_status; \
} \
- else if (location.start > location.stop) { \
- f_status macro_allocation_status = F_none; \
- f_array_length i = 0; \
- \
- while (i < delimits.used) { \
+ else if (range.start > range.stop) { \
+ for (f_array_length i = 0; i < delimits.used; i++) { \
buffer.string[delimits.array[i]] = f_fss_delimit_placeholder; \
- i++; \
} \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ f_macro_string_lengths_delete_simple(delimits); \
\
- found.array[found.used].stop = location.stop; \
+ found.array[found.used].stop = range.stop; \
return stop_status; \
}
#endif // _di_fl_macro_fss_content_delimited_return_on_overflow_
#ifndef _di_fl_macro_fss_allocate_content_if_necessary_
#define fl_macro_fss_allocate_content_if_necessary(content, delimits) \
- if (content.used >= content.size) { \
+ if (content.used == content.size) { \
f_status status = F_none; \
\
f_macro_fss_content_resize(status, content, content.size + f_fss_default_allocation_step); \
if (F_status_is_error(status)) { \
- f_status macro_allocation_status = F_none; \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ f_macro_string_lengths_delete_simple(delimits); \
\
return status; \
} \
#endif // _di_fl_macro_fss_allocate_content_if_necessary_
#ifndef _di_fl_macro_fss_nest_return_on_overflow_
- #define fl_macro_fss_nest_return_on_overflow(buffer, location, found, delimits, positions, objects, eos_status, stop_status) \
- if (location.start >= buffer.used) { \
- f_status macro_allocation_status = F_none; \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
- f_macro_string_lengths_delete(macro_allocation_status, positions); \
- f_macro_fss_objects_delete(macro_allocation_status, objects); \
+ #define fl_macro_fss_nest_return_on_overflow(buffer, range, found, delimits, positions, objects, eos_status, stop_status) \
+ if (range.start >= buffer.used) { \
+ f_macro_string_lengths_delete_simple(delimits); \
+ f_macro_string_lengths_delete_simple(positions); \
+ f_macro_fss_objects_delete_simple(objects); \
\
- /* @todo: found.array[found.used].stop = buffer.used - 1; */ \
return eos_status; \
} \
- else if (location.start > location.stop) { \
- f_status macro_allocation_status = F_none; \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
- f_macro_string_lengths_delete(macro_allocation_status, positions); \
- f_macro_fss_objects_delete(macro_allocation_status, objects); \
+ else if (range.start > range.stop) { \
+ f_macro_string_lengths_delete_simple(delimits); \
+ f_macro_string_lengths_delete_simple(positions); \
+ f_macro_fss_objects_delete_simple(objects); \
\
- /* @todo: found.array[found.used].stop = location.stop; */ \
return stop_status; \
}
#endif // _di_fl_macro_fss_nest_return_on_overflow_
#ifndef _di_fl_macro_fss_nest_delimited_return_on_overflow_
- #define fl_macro_fss_nest_delimited_return_on_overflow(buffer, location, found, delimits, positions, objects, eos_status, stop_status) \
- if (location.start >= buffer.used) { \
- f_status macro_allocation_status = F_none; \
- f_array_length i = 0; \
- \
- while (i < delimits.used) { \
+ #define fl_macro_fss_nest_delimited_return_on_overflow(buffer, range, found, delimits, positions, objects, eos_status, stop_status) \
+ if (range.start >= buffer.used) { \
+ for (f_array_length i = 0; i < delimits.used; i++) { \
buffer.string[delimits.array[i]] = f_fss_delimit_placeholder; \
- i++; \
} \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
- f_macro_string_lengths_delete(macro_allocation_status, positions); \
- f_macro_fss_objects_delete(macro_allocation_status, objects); \
+ f_macro_string_lengths_delete_simple(delimits); \
+ f_macro_string_lengths_delete_simple(positions); \
+ f_macro_fss_objects_delete_simple(objects); \
\
return eos_status; \
} \
- else if (location.start > location.stop) { \
- f_status macro_allocation_status = F_none; \
- f_array_length i = 0; \
- \
- while (i < delimits.used) { \
+ else if (range.start > range.stop) { \
+ for (f_array_length i = 0; i < delimits.used; i++) { \
buffer.string[delimits.array[i]] = f_fss_delimit_placeholder; \
- i++; \
} \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
- f_macro_string_lengths_delete(macro_allocation_status, positions); \
- f_macro_fss_objects_delete(macro_allocation_status, objects); \
+ f_macro_string_lengths_delete_simple(delimits); \
+ f_macro_string_lengths_delete_simple(positions); \
+ f_macro_fss_objects_delete_simple(objects); \
\
return stop_status; \
}
- // @todo: found.array[found.used].stop = location.stop;
#endif // _di_fl_macro_fss_nest_delimited_return_on_overflow_
#ifndef _di_fl_macro_fss_object_seek_till_newline_
- #define fl_macro_fss_object_seek_till_newline(buffer, location, delimits, eos_status, stop_status) \
- while (buffer.string[location.start] != f_string_eol[0]) { \
- location.start++; \
- if (location.start >= buffer.used) { \
- f_status macro_allocation_status = F_none; \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ #define fl_macro_fss_object_seek_till_newline(buffer, range, delimits, eos_status, stop_status) \
+ while (buffer.string[range.start] != f_string_eol[0]) { \
+ range.start++; \
+ if (range.start >= buffer.used) { \
+ f_macro_string_lengths_delete_simple(delimits); \
\
return eos_status; \
} \
- if (location.start > location.stop) { \
- f_status macro_allocation_status = F_none; \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ if (range.start > range.stop) { \
+ f_macro_string_lengths_delete_simple(delimits); \
\
return stop_status; \
} \
#endif // _di_fl_macro_fss_object_seek_till_newline_
#ifndef _di_fl_macro_fss_object_delimited_seek_till_newline_
- #define fl_macro_fss_object_delimited_seek_till_newline(buffer, location, delimits, eos_status, stop_status) \
- while (buffer.string[location.start] != f_string_eol[0]) { \
- location.start++; \
- if (location.start >= buffer.used) { \
- f_status macro_allocation_status = F_none; \
- f_array_length i = 0; \
- \
- while (i < delimits.used) { \
+ #define fl_macro_fss_object_delimited_seek_till_newline(buffer, range, delimits, eos_status, stop_status) \
+ while (buffer.string[range.start] != f_string_eol[0]) { \
+ range.start++; \
+ if (range.start >= buffer.used) { \
+ for (f_array_length i = 0; i < delimits.used; i++) { \
buffer.string[delimits.array[i]] = f_fss_delimit_placeholder; \
- i++; \
} \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ f_macro_string_lengths_delete_simple(delimits); \
\
return eos_status; \
} \
- if (location.start > location.stop) { \
- f_status macro_allocation_status = F_none; \
- f_array_length i = 0; \
- \
- while (i < delimits.used) { \
+ if (range.start > range.stop) { \
+ for (f_array_length i = 0; i < delimits.used; i++) { \
buffer.string[delimits.array[i]] = f_fss_delimit_placeholder; \
- i++; \
} \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ f_macro_string_lengths_delete_simple(delimits); \
\
return stop_status; \
} \
#endif // _di_fl_macro_fss_object_delimited_seek_till_newline_
#ifndef _di_fl_macro_fss_content_seek_till_newline_
- #define fl_macro_fss_content_seek_till_newline(buffer, location, found, delimits, eos_status, stop_status) \
- while (buffer.string[location.start] != f_string_eol[0]) { \
- location.start++; \
- if (location.start >= buffer.used) { \
- f_status macro_allocation_status = F_none; \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ #define fl_macro_fss_content_seek_till_newline(buffer, range, found, delimits, eos_status, stop_status) \
+ while (buffer.string[range.start] != f_string_eol[0]) { \
+ range.start++; \
+ if (range.start >= buffer.used) { \
+ f_macro_string_lengths_delete_simple(delimits); \
\
- found.array[found.used].stop = location.stop; \
+ found.array[found.used].stop = range.stop; \
return eos_status; \
} \
- if (location.start > location.stop) { \
- f_status macro_allocation_status = F_none; \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ if (range.start > range.stop) { \
+ f_macro_string_lengths_delete_simple(delimits); \
\
- found.array[found.used].stop = location.stop; \
+ found.array[found.used].stop = range.stop; \
return stop_status; \
} \
} // while
#endif // _di_fl_macro_fss_content_seek_till_newline_
#ifndef _di_fl_macro_fss_content_delimited_seek_till_newline_
- #define fl_macro_fss_content_delimited_seek_till_newline(buffer, location, found, delimits, eos_status, stop_status) \
- while (buffer.string[location.start] != f_string_eol[0]) { \
- location.start++; \
- if (location.start >= buffer.used) { \
- f_status macro_allocation_status = F_none; \
- f_array_length i = 0; \
- \
- while (i < delimits.used) { \
+ #define fl_macro_fss_content_delimited_seek_till_newline(buffer, range, found, delimits, eos_status, stop_status) \
+ while (buffer.string[range.start] != f_string_eol[0]) { \
+ range.start++; \
+ if (range.start >= buffer.used) { \
+ for (f_array_length i = 0; i < delimits.used; i++) { \
buffer.string[delimits.array[i]] = f_fss_delimit_placeholder; \
- i++; \
} \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ f_macro_string_lengths_delete_simple(delimits); \
\
- found.array[found.used].stop = location.stop; \
+ found.array[found.used].stop = range.stop; \
return eos_status; \
} \
- if (location.start > location.stop) { \
- f_status macro_allocation_status = F_none; \
- f_array_length i = 0; \
- \
- while (i < delimits.used) { \
+ if (range.start > range.stop) { \
+ for (f_array_length i = 0; i < delimits.used; i++) { \
buffer.string[delimits.array[i]] = f_fss_delimit_placeholder; \
- i++; \
} \
- f_macro_string_lengths_delete(macro_allocation_status, delimits); \
+ f_macro_string_lengths_delete_simple(delimits); \
\
- found.array[found.used].stop = location.stop; \
+ found.array[found.used].stop = range.stop; \
return stop_status; \
} \
} // while
extern "C" {
#endif
-#if !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_)
- f_return_status private_fl_fss_basic_object_read(const bool is_basic, f_string_dynamic *buffer, f_string_range *range, f_fss_object *found) {
+#if !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_) || !defined(_di_fl_fss_extended_content_read_)
+ f_return_status private_fl_fss_basic_object_read(f_string_dynamic *buffer, f_string_range *range, f_fss_object *found, f_fss_quoted *quoted, f_string_lengths *delimits) {
f_status status = F_none;
- // delimits must only be applied once a valid object is found.
- f_string_lengths delimits = f_string_lengths_initialize;
-
status = f_fss_skip_past_space(*buffer, range);
if (F_status_is_error(status)) return status;
return F_data_not_stop;
}
- // when handling delimits, the only time they should be applied is when a valid object would exist.
- // however, the delimits will appear before a valid object, so remember their positions and only apply them after a would be valid object is confirmed.
- bool has_delimit = F_false;
-
// begin the search.
found->start = range->start;
// ignore all comment lines.
if (buffer->string[range->start] == f_fss_comment) {
- fl_macro_fss_object_seek_till_newline((*buffer), (*range), delimits, F_data_not_eos, F_data_not_stop);
+ while (buffer->string[range->start] != f_string_eol[0]) {
+ range->start++;
+
+ if (range->start >= buffer->used) return F_data_not_eos;
+ if (range->start > range->stop) return F_data_not_stop;
+ } // while
status = f_utf_buffer_increment(*buffer, range, 1);
if (F_status_is_error(status)) return status;
return FL_fss_found_object_not;
}
- // handle quote support.
- int8_t quoted = 0;
+ // delimits must only be applied once a valid object is found->
+ const f_string_length delimit_initial = delimits->used;
+
+ // handle quoted support.
+ int8_t quote = 0;
+
+ if (quoted) {
+ *quoted = 0;
+ }
// identify where the object begins.
if (buffer->string[range->start] == f_fss_delimit_slash) {
}
} // while
- fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*range), (*found), delimits, F_none_eos, F_none_stop);
+ if (range->start >= buffer->used) {
+ found->stop = buffer->used - 1;
+ return F_none_eos;
+ }
+ else if (range->start > range->stop) {
+ found->stop = range->stop;
+ return F_none_stop;
+ }
- if (buffer->string[range->start] == f_fss_delimit_single_quote || buffer->string[range->start] == f_fss_delimit_double_quote) {
+ if (buffer->string[range->start] == f_fss_delimit_quote_single || buffer->string[range->start] == f_fss_delimit_quote_double) {
- // only the first slash before a quote needs to be escaped (or not) as once there is a slash before a quote, this cannot ever be a quoted object.
+ // only the first slash before a quoted needs to be escaped (or not) as once there is a slash before a quoted, this cannot ever be a quote object.
// this simplifies the number of slashes needed.
- if (delimits.used + 1 > delimits.size) {
- f_macro_string_lengths_resize(status, delimits, delimits.size + 1);
- if (F_status_is_error(status)) return status;
+ if (delimits->used == delimits->size) {
+ if (delimits->size + f_fss_default_allocation_step > f_array_length_size) {
+ if (delimits->size + 1 > f_array_length_size) {
+ return F_status_set_error(F_buffer_too_large);
+ }
+
+ f_macro_string_lengths_resize(status, (*delimits), delimits->size + 1);
+ if (F_status_is_error(status)) return status;
+ }
+ else {
+ f_macro_string_lengths_resize(status, (*delimits), delimits->size + f_fss_default_allocation_step);
+ if (F_status_is_error(status)) return status;
+ }
}
- delimits.array[delimits.used] = first_slash;
- delimits.used++;
+ delimits->array[delimits->used] = first_slash;
+ delimits->used++;
status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ if (F_status_is_error(status)) return status;
}
}
- else if (buffer->string[range->start] == f_fss_delimit_single_quote || buffer->string[range->start] == f_fss_delimit_double_quote) {
- quoted = buffer->string[range->start];
+ else if (buffer->string[range->start] == f_fss_delimit_quote_single || buffer->string[range->start] == f_fss_delimit_quote_double) {
+ quote = buffer->string[range->start];
status = f_utf_buffer_increment(*buffer, range, 1);
if (F_status_is_error(status)) return status;
}
// identify where the object ends.
- if (quoted == 0) {
+ if (quote == 0) {
status = F_none;
while (range->start <= range->stop && range->start < buffer->used) {
status = f_fss_is_space(*buffer, *range);
-
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ 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)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ if (F_status_is_error(status)) return status;
} // while
found->stop = range->start - 1;
- fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
-
if (buffer->string[range->start] == f_string_eol[0]) {
range->start++;
return FL_fss_found_object_content_not;
}
status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ if (F_status_is_error(status)) return status;
return FL_fss_found_object;
}
else {
-
while (range->start <= range->stop && range->start < buffer->used) {
if (buffer->string[range->start] == f_fss_delimit_slash) {
f_string_length slash_count = 1;
status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ if (F_status_is_error(status)) return status;
while (range->start <= range->stop && range->start < buffer->used) {
if (buffer->string[range->start] == f_fss_delimit_placeholder) {
status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ if (F_status_is_error(status)) return status;
continue;
}
slash_count++;
status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ if (F_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*range), (*found), delimits, F_status_set_warning(F_unterminated_group_eos), F_status_set_warning(F_unterminated_group_stop));
+ if (range->start >= buffer->used) {
+ found->stop = buffer->used - 1;
+ delimits->used = delimit_initial;
+ return F_unterminated_group_eos;
+ }
+ else if (range->start > range->stop) {
+ found->stop = range->stop;
+ delimits->used = delimit_initial;
+ return F_unterminated_group_stop;
+ }
- if (buffer->string[range->start] == quoted) {
+ if (buffer->string[range->start] == quote) {
f_string_length location = range->start;
- // check to see if there is a whitespace, EOS, or EOL after the quote, if not, then this is not a closing quote and delimits do not apply.
+ // check to see if there is a whitespace, EOS, or EOL after the quoted, if not, then this is not a closing quoted and delimits do not apply.
if (range->start + 1 <= range->stop && range->start + 1 < buffer->used) {
range->start++;
if (range->start <= range->stop && range->start < buffer->used) {
status = f_fss_is_space(*buffer, *range);
- if (F_status_is_error(status)) {
- return status;
- }
+ if (F_status_is_error(status)) return status;
}
else {
- // EOS or EOL was reached, so it is a valid closing quote.
+ // EOS or EOL was reached, so it is a valid closing quoted.
// (for EOL, this is always TRUE, for EOS this could be false but there is no way to know this, so assume TRUE (@todo maybe none on stop?).
status = F_true;
}
}
else {
- // EOS or EOL was reached, so it is a valid closing quote.
+ // EOS or EOL was reached, so it is a valid closing quoted.
// (for EOL, this is always TRUE, for EOS this could be false but there is no way to know this, so assume TRUE (@todo maybe none on stop?).
status = F_true;
}
if (status == F_true) {
+ if (quoted) {
+ if (quote == f_fss_delimit_quote_single) {
+ *quoted = f_fss_quoted_type_single;
+ }
+ else if (quote == f_fss_delimit_quote_double) {
+ *quoted = f_fss_quoted_type_double;
+ }
+ }
+
range->start = first_slash;
if (slash_count % 2 == 0) {
- if (delimits.used + (slash_count / 2) >= delimits.size) {
- f_macro_string_lengths_resize(status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step);
-
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
+ if (delimits->used + (slash_count / 2) >= delimits->size) {
+ if (delimits->used + (slash_count / 2) >= f_array_length_size) {
+ return F_status_set_error(F_buffer_too_large);
}
+
+ f_macro_string_lengths_resize(status, (*delimits), delimits->size + (slash_count / 2));
+ if (F_status_is_error(status)) return status;
}
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;
+ delimits->used++;
}
slash_count--;
}
status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ if (F_status_is_error(status)) return status;
} // while
range->start = location + 1;
- fl_macro_fss_skip_past_delimit_placeholders((*buffer), (*range));
- fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*range), (*found), delimits, F_none_eos, F_none_stop);
+ while (buffer->string[range->start] == f_fss_delimit_placeholder) {
+ range->start++;
+
+ if (range->start >= buffer->used) return F_none_eos;
+ if (range->start > range->stop) return F_none_stop;
+ } // while
if ((status = f_fss_is_graph(*buffer, *range)) == F_true) {
while (range->start < buffer->used && range->start <= range->stop && buffer->string[range->start] != f_string_eol[0]) {
status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ if (F_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*range), (*found), delimits, F_data_not_eos, F_data_not_stop);
-
- f_macro_string_lengths_delete_simple(delimits);
+ if (range->start >= buffer->used) {
+ found->stop = buffer->used - 1;
+ return F_data_not_eos;
+ }
+ else if (range->start > range->stop) {
+ found->stop = range->stop;
+ return F_data_not_stop;
+ }
status = f_utf_buffer_increment(*buffer, range, 1);
if (F_status_is_error(status)) return status;
return FL_fss_found_object_not;
}
else if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
return status;
}
else if (buffer->string[range->start] == f_string_eol[0]) {
- fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
-
found->stop = location - 1;
range->start++;
return FL_fss_found_object_content_not;
}
- fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
-
found->stop = location - 1;
status = f_utf_buffer_increment(*buffer, range, 1);
return FL_fss_found_object;
}
else {
- if (delimits.used + (slash_count / 2) >= delimits.size) {
- f_macro_string_lengths_resize(status, delimits, delimits.size + (slash_count / 2) + f_fss_default_allocation_step);
-
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
+ if (delimits->used + (slash_count / 2) >= delimits->size) {
+ if (delimits->used + (slash_count / 2) >= f_array_length_size) {
+ return F_status_set_error(F_buffer_too_large);
}
+
+ f_macro_string_lengths_resize(status, (*delimits), delimits->size + (slash_count / 2) + 1);
+ if (F_status_is_error(status)) return status;
}
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;
+ delimits->used++;
}
slash_count--;
}
status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ if (F_status_is_error(status)) return status;
} // while
range->start = location;
}
}
}
- else if (buffer->string[range->start] == quoted) {
- // check to see if there is a whitespace, EOS, or EOL after the quote, if not, then this is not a closing quote.
+ else if (buffer->string[range->start] == quote) {
+ // check to see if there is a whitespace, EOS, or EOL after the quoted, if not, then this is not a closing quoted.
{
f_string_length location = range->start;
if (range->start <= range->stop && range->start < buffer->used) {
status = f_fss_is_space(*buffer, *range);
- if (F_status_is_error(status)) {
- return status;
- }
+ if (F_status_is_error(status)) return status;
}
else {
- // EOS or EOL was reached, so it is a valid closing quote.
+ // EOS or EOL was reached, so it is a valid closing quoted.
// (for EOL, this is always TRUE, for EOS this could be false but there is no way to know this, so assume TRUE (@todo maybe none on stop?).
status = F_true;
}
}
else {
- // EOS or EOL was reached, so it is a valid closing quote.
- // (for EOL, this is always TRUE, for EOS this could be false but there is no way to know this, so assume TRUE (@todo maybe none on stop?).
+ // EOS or EOL was reached, so it is a valid closing quoted.
+ // (for EOL, this is always TRUE, for EOS this could be false but there is no way to know this, so assume TRUE (@todo maybe none on stop?).
status = F_true;
}
}
if (status == F_true) {
+ if (quoted) {
+ if (quote == f_fss_delimit_quote_single) {
+ *quoted = f_fss_quoted_type_single;
+ }
+ else if (quote == f_fss_delimit_quote_double) {
+ *quoted = f_fss_quoted_type_double;
+ }
+ }
+
found->stop = range->start - 1;
status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ if (F_status_is_error(status)) return status;
while (range->start <= range->stop && range->start < buffer->used) {
if (buffer->string[range->start] == f_string_eol[0]) {
- fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
-
range->start++;
return FL_fss_found_object_content_not;
}
else if ((status = f_fss_is_space(*buffer, *range)) == F_true) {
- fl_macro_fss_apply_delimit_placeholders((*buffer), delimits);
-
status = f_utf_buffer_increment(*buffer, range, 1);
if (F_status_is_error(status)) return status;
return FL_fss_found_object;
}
else if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
return status;
}
else if (buffer->string[range->start] != f_fss_delimit_placeholder) {
while (range->start < buffer->used && range->start <= range->stop && buffer->string[range->start] != f_string_eol[0]) {
status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ if (F_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*range), (*found), delimits, F_data_not_eos, F_data_not_stop);
-
- f_macro_string_lengths_delete_simple(delimits);
+ if (range->start >= buffer->used) {
+ found->stop = buffer->used - 1;
+ return F_data_not_eos;
+ }
+ else if (range->start > range->stop) {
+ found->stop = range->stop;
+ return 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)) return status;
} // while
- fl_macro_fss_object_delimited_return_on_overflow((*buffer), (*range), (*found), delimits, F_none_eos, F_none_stop);
+ if (range->start >= buffer->used) {
+ found->stop = buffer->used - 1;
+ return F_none_eos;
+ }
+ else if (range->start > range->stop) {
+ found->stop = range->stop;
+ return F_none_stop;
+ }
}
}
else if (buffer->string[range->start] == f_string_eol[0]) {
- f_macro_string_lengths_delete_simple(delimits);
-
range->start++;
return FL_fss_found_object_not;
}
status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ if (F_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*range), (*found), delimits, F_status_set_warning(F_unterminated_group_eos), F_status_set_warning(F_unterminated_group_stop));
+ if (range->start >= buffer->used) {
+ found->stop = buffer->used - 1;
+ delimits->used = delimit_initial;
+ return F_unterminated_group_eos;
+ }
+ else if (range->start > range->stop) {
+ found->stop = range->stop;
+ delimits->used = delimit_initial;
+ return F_unterminated_group_stop;
+ }
}
- // seek to the end of the line when no valid object is found
+ // seek to the end of the line when no valid object is found->
while (range->start < buffer->used && range->start <= range->stop && buffer->string[range->start] != f_string_eol[0]) {
status = f_utf_buffer_increment(*buffer, range, 1);
- if (F_status_is_error(status)) {
- f_macro_string_lengths_delete_simple(delimits);
- return status;
- }
+ if (F_status_is_error(status)) return status;
} // while
- fl_macro_fss_object_return_on_overflow((*buffer), (*range), (*found), delimits, F_data_not_eos, F_data_not_stop);
-
- f_macro_string_lengths_delete_simple(delimits);
+ if (range->start >= buffer->used) {
+ found->stop = buffer->used - 1;
+ return F_data_not_eos;
+ }
+ else if (range->start > range->stop) {
+ found->stop = range->stop;
+ return F_data_not_stop;
+ }
status = f_utf_buffer_increment(*buffer, range, 1);
if (F_status_is_error(status)) return status;
}
#endif // !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_)
+#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_)
+ f_return_status private_fl_fss_basic_object_write(const f_string_static object, const f_fss_quoted quoted, f_string_range *range, f_string_dynamic *destination) {
+ f_status status = F_none;
+
+ fl_macro_fss_skip_past_delimit_placeholders(object, (*range));
+
+ if (range->start > range->stop) return F_data_not_stop;
+ else if (range->start >= object.used) return F_data_not_eos;
+
+ // ensure that there is room for the start and stop quotes or a slash delimit and the object open character.
+ f_string_length size_allocate = destination->used + (range->stop - range->start) + 3 + f_fss_default_allocation_step_string;
+
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate);
+ if (F_status_is_error(status)) return status;
+ }
+
+ const f_string_length position_start = range->start;
+
+ f_string_range destination_position = f_string_range_initialize;
+
+ destination_position.start = destination->used;
+ destination_position.stop = destination->used;
+
+ bool quote = quoted ? F_true : F_false;
+
+ if (quote) {
+ if (quoted == f_fss_quoted_type_single) {
+ destination->string[destination_position.start] = f_fss_delimit_quote_single;
+ }
+ else {
+ destination->string[destination_position.start] = f_fss_delimit_quote_double;
+ }
+
+ destination_position.stop++;
+ }
+
+ // @todo: if the string starts with a single or double quoted, it needs to be escaped, but if quotes are detected later on, be sure to re-evaluate escaping.
+
+ if (object.string[range->start] == f_fss_delimit_slash) {
+ while (range->start <= range->stop && range->start < object.used) {
+ if (object.string[range->start] == f_fss_delimit_placeholder) {
+ status = f_utf_buffer_increment(object, range, 1);
+ if (F_status_is_error(status)) return status;
+
+ continue;
+ }
+ else if (object.string[range->start] != f_fss_delimit_slash) {
+ break;
+ }
+
+ destination->string[destination_position.stop] = object.string[range->start];
+ destination_position.stop++;
+
+ status = f_utf_buffer_increment(object, range, 1);
+ if (F_status_is_error(status)) return status;
+ } // while
+
+ if (range->start <= range->stop && range->start < object.used) {
+ if ((quoted == f_fss_quoted_type_single && object.string[range->start] == f_fss_delimit_quote_single) || (quoted == f_fss_quoted_type_double && object.string[range->start] == f_fss_delimit_quote_double)) {
+ size_allocate++;
+
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string);
+ if (F_status_is_error(status)) return status;
+ }
+
+ destination->string[destination_position.stop] = f_fss_delimit_slash;
+ destination->string[destination_position.stop + 1] = object.string[range->start];
+ destination_position.stop += 2;
+
+ status = f_utf_buffer_increment(object, range, 1);
+ if (F_status_is_error(status)) return status;
+ }
+ }
+ }
+ else if ((quoted == f_fss_quoted_type_single && object.string[range->start] == f_fss_delimit_quote_single) || (quoted == f_fss_quoted_type_double && object.string[range->start] == f_fss_delimit_quote_double)) {
+ size_allocate++;
+
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string);
+
+ if (F_status_is_error(status)) return status;
+ }
+
+ destination->string[destination_position.stop] = f_fss_delimit_slash;
+ destination->string[destination_position.stop + 1] = object.string[range->start];
+ destination_position.stop += 2;
+
+ status = f_utf_buffer_increment(object, range, 1);
+ if (F_status_is_error(status)) return status;
+ }
+
+ while (range->start <= range->stop && range->start < object.used) {
+ if (object.string[range->start] == f_fss_delimit_placeholder) {
+ status = f_utf_buffer_increment(object, range, 1);
+ if (F_status_is_error(status)) return status;
+
+ continue;
+ }
+
+ if (object.string[range->start] == f_string_eol[0]) {
+ if (quote) {
+ destination->string[destination_position.stop] = destination->string[destination_position.start];
+ destination_position.stop++;
+ }
+
+ destination->string[destination_position.stop] = f_fss_basic_open;
+ destination->used = destination_position.stop + 1;
+
+ return F_none_eol;
+ }
+
+ if (quote) {
+ if (object.string[range->start] == f_fss_delimit_slash) {
+ f_string_range next = *range;
+ f_string_length slashes = 1;
+
+ bool must_delimit = F_false;
+
+ while (next.start <= next.stop && next.start < object.used) {
+ if (object.string[next.start] == f_fss_delimit_placeholder) {
+ status = f_utf_buffer_increment(object, &next, 1);
+ if (F_status_is_error(status)) return status;
+
+ continue;
+ }
+ else if (object.string[next.start] != f_fss_delimit_slash) {
+ break;
+ }
+
+ slashes++;
+
+ status = f_utf_buffer_increment(object, &next, 1);
+ if (F_status_is_error(status)) return status;
+ } // while
+
+ if (next.start <= next.stop && next.start < object.used) {
+ // identify if quoted exists and could be considered a valid closing quoted.
+ if (object.string[next.start] == destination->string[destination_position.start]) {
+ fl_macro_fss_skip_past_delimit_placeholders(object, next);
+
+ if (next.start <= next.stop && next.start < object.used) {
+ status = f_fss_is_space(*destination, next);
+
+ if (status == F_true) {
+ must_delimit = F_true;
+ }
+ else if (F_status_is_error(status)) {
+ return status;
+ }
+ }
+ else {
+ must_delimit = F_true;
+ }
+ }
+ }
+ else {
+ // ensure that the slashes before the closing quoted to not delimit the closing quoted.
+ must_delimit = F_true;
+ }
+
+ if (must_delimit) {
+ for (f_string_length i = 0; i < slashes; i++) {
+ destination->string[destination_position.stop] = f_fss_delimit_slash;
+ destination_position.stop++;
+ } // for
+
+ if (slashes % 2) {
+ size_allocate++;
+
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string);
+ if (F_status_is_error(status)) return status;
+ }
+
+ destination->string[destination_position.stop] = f_fss_delimit_slash;
+ destination_position.stop++;
+ }
+ }
+ }
+ else if (object.string[range->start] == destination->string[destination_position.start]) {
+ f_string_range next = *range;
+ bool must_delimit = F_false;
+
+ status = f_utf_buffer_increment(object, &next, 1);
+ if (F_status_is_error(status)) return status;
+
+ fl_macro_fss_skip_past_delimit_placeholders(object, next);
+
+ if (next.start > range->stop || next.start >= object.used) {
+ must_delimit = F_true;
+ }
+ else {
+ status = f_fss_is_space(object, next);
+
+ if (status == F_true) {
+ must_delimit = F_true;
+ }
+ else if (F_status_is_error(status)) {
+ return status;
+ }
+ }
+
+ if (must_delimit) {
+ size_allocate++;
+
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string);
+ if (F_status_is_error(status)) return status;
+ }
+
+ destination->string[destination_position.stop] = f_fss_delimit_slash;
+ destination_position.stop++;
+ }
+ }
+ }
+ else {
+ status = f_fss_is_space(object, *range);
+
+ if (status == F_true) {
+ size_allocate++;
+
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string);
+ if (F_status_is_error(status)) return status;
+ }
+
+ // restart the loop then search for delimit slash or quoted and escape as appropriate.
+ range->start = position_start;
+ destination_position.stop = destination_position.start;
+
+ destination->string[destination_position.stop] = f_fss_delimit_quote_double;
+ destination_position.stop++;
+
+ quote = F_true;
+
+ if (object.string[range->start] == f_fss_delimit_slash) {
+ while (range->start <= range->stop && range->start < object.used) {
+ if (object.string[range->start] == f_fss_delimit_placeholder) {
+ status = f_utf_buffer_increment(object, range, 1);
+ if (F_status_is_error(status)) return status;
+
+ continue;
+ }
+ else if (object.string[range->start] != f_fss_delimit_slash) {
+ break;
+ }
+
+ destination->string[destination_position.stop] = object.string[range->start];
+ destination_position.stop++;
+
+ status = f_utf_buffer_increment(object, range, 1);
+ if (F_status_is_error(status)) return status;
+ } // while
+
+ if (range->start > range->stop || range->start >= object.used) break;
+
+ if (object.string[range->start] == f_fss_delimit_quote_double) {
+ size_allocate++;
+
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string);
+ if (F_status_is_error(status)) return status;
+ }
+
+ destination->string[destination_position.stop] = f_fss_delimit_slash;
+ destination_position.stop++;
+ }
+ }
+ else if (object.string[range->start] == f_fss_delimit_quote_double) {
+ size_allocate++;
+
+ if (size_allocate > destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string);
+ if (F_status_is_error(status)) return status;
+ }
+
+ destination->string[destination_position.stop] = f_fss_delimit_slash;
+ destination_position.stop++;
+ }
+ }
+ else if (F_status_is_error(status)) {
+ return status;
+ }
+ }
+
+ destination->string[destination_position.stop] = object.string[range->start];
+
+ status = f_utf_buffer_increment(object, range, 1);
+ if (F_status_is_error(status)) return status;
+
+ destination_position.stop++;
+ } // while
+
+ if (quote) {
+ destination->string[destination_position.stop] = destination->string[destination_position.start];
+ destination_position.stop++;
+ }
+
+ destination->string[destination_position.stop] = f_fss_basic_open;
+ destination->used = destination_position.stop + 1;
+
+ if (range->start > range->stop) return F_none_stop;
+ else if (range->start >= object.used) return F_none_eos;
+
+ return F_none;
+ }
+#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_)
+
#ifdef __cplusplus
} // extern "C"
#endif
*
* Intended to be shared to each of the different implementation variations.
*
- * @param is_basic
- * Set to TRUE if this is a basic read.
- * Set to FALSE if this is an extended read.
* @param buffer
* The buffer to read from.
* This will be updated with delimit placeholders as it is being processed.
* A start location past the stop location or buffer used means that the entire range was processed.
* @param found
* A set of all locations where a valid object was found.
+ * @param quoted
+ * This will store whether or not this object is quoted and what quote is in use.
+ * Set pointer address to 0 to not use.
+ * @param delimits
+ * An array of delimits detected during processing.
+ * The caller is expected to decide if and when to process them.
*
* @return
* FL_fss_found_object on success and object was found (start location is at end of object).
* F_none_stop on success after reaching stopping point (a valid object is not yet confirmed).
* F_data_not_eos no objects found after reaching the end of the buffer (essentially only comments are found).
* F_data_not_stop no data found after reaching stopping point (essentially only comments are found).
- * F_unterminated_group_eos (with warning bit) if EOS was reached before the a group termination was reached.
- * F_unterminated_group_stop (with warning bit) if stop point was reached before the a group termination was reached.
+ * F_unterminated_group_eos if EOS was reached before the a group termination was reached.
+ * F_unterminated_group_stop if stop point was reached before the a group termination was reached.
+ * F_buffer_too_large (with error bit) if a buffer is too large.
* F_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
* F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed.
* F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed.
* @see fl_fss_basic_object_read()
* @see fl_fss_extended_object_read()
*/
-#if !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_)
- extern f_return_status private_fl_fss_basic_object_read(const bool is_basic, f_string_dynamic *buffer, f_string_range *range, f_fss_object *found) f_gcc_attribute_visibility_internal;
-#endif // !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_)
+#if !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_) || !defined(_di_fl_fss_extended_content_read_)
+ extern f_return_status private_fl_fss_basic_object_read(f_string_dynamic *buffer, f_string_range *range, f_fss_object *found, f_fss_quoted *quoted, f_string_lengths *delimits) f_gcc_attribute_visibility_internal;
+#endif // !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_) || !defined(_di_fl_fss_extended_content_read_)
+
+/**
+ * Private implementation of fl_fss_basic_object_write().
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param object
+ * The string to write as (does not stop at NULLS, they are ignored and not written).
+ * @param quoted
+ * If 0, then double quotes are auto-inserted, if needed.
+ * Otherwise, this is the type of quote to wrap the object in when writing.
+ * @param range
+ * The start/stop location within the object string to write as an object.
+ * @param destination
+ * The buffer where the object is written to.
+ *
+ * @return
+ * F_none on success.
+ * F_none_eos on success after reaching the end of the buffer.
+ * F_data_not_stop no data to write due start location being greater than stop location.
+ * F_data_not_eos no data to write due start location being greater than or equal to buffer size.
+ * F_none_stop on success after reaching stopping point .
+ * F_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete.
+ * F_memory_reallocation (with error bit) on reallocation error.
+ * F_parameter (with error bit) if a parameter is invalid.
+ * F_utf (with error bit) is returned on failure to read/process a UTF-8 character.
+ *
+ * Errors from (with error bit): f_utf_buffer_increment().
+ *
+ * @see fl_fss_basic_object_write()
+ * @see fl_fss_extended_object_write()
+ */
+#if !defined(fl_fss_basic_object_write) || !defined(fl_fss_extended_object_write)
+ extern f_return_status private_fl_fss_basic_object_write(const f_string_static object, const f_fss_quoted quoted, f_string_range *range, f_string_dynamic *destination) f_gcc_attribute_visibility_internal;
+#endif // !defined(fl_fss_basic_object_write) || !defined(fl_fss_extended_object_write)
#ifdef __cplusplus
} // extern "C"
#ifndef _di_fl_print_trim_string_dynamic_
f_return_status fl_print_trim_string_dynamic(FILE *output, const f_string_static buffer) {
#ifndef _di_level_1_parameter_checking_
- if (buffer.used <= 0) return F_status_set_error(F_parameter);
+ if (buffer.used == 0) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
register f_string_length i = 0;
#ifndef _di_level_1_parameter_checking_
if (range.start < 0) return F_status_set_error(F_parameter);
if (range.stop < range.start) return F_status_set_error(F_parameter);
- if (buffer.used <= 0) return F_status_set_error(F_parameter);
+ if (buffer.used == 0) return F_status_set_error(F_parameter);
if (range.start >= buffer.used) return F_status_set_error(F_parameter);
if (range.stop >= buffer.used) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
#ifndef _di_fl_print_trim_utf_string_dynamic_
f_return_status fl_print_trim_utf_string_dynamic(FILE *output, const f_utf_string_static buffer) {
#ifndef _di_level_1_parameter_checking_
- if (buffer.used <= 0) return F_status_set_error(F_parameter);
+ if (buffer.used == 0) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
register f_utf_string_length i = 0;
#ifndef _di_level_1_parameter_checking_
if (range.start < 0) return F_status_set_error(F_parameter);
if (range.stop < range.start) return F_status_set_error(F_parameter);
- if (buffer.used <= 0) return F_status_set_error(F_parameter);
+ if (buffer.used == 0) return F_status_set_error(F_parameter);
if (range.start >= buffer.used) return F_status_set_error(F_parameter);
if (range.stop >= buffer.used) return F_status_set_error(F_parameter);
#endif // _di_level_1_parameter_checking_
if (destination->used && destination->string[destination->used - 1] == 0) return F_none;
- if (destination->used + 1 > f_string_length_size) return F_status_set_error(F_string_too_large);
+ if (destination->used == f_string_length_size) return F_status_set_error(F_string_too_large);
const f_string_length total = destination->used + 1;
} // for
}
- if (destination->used + 1 > f_string_length_size) return F_status_set_error(F_string_too_large);
+ if (destination->used == f_string_length_size) return F_status_set_error(F_string_too_large);
const f_string_length total = destination->used + 1;
return F_none;
}
- if (destination->used + 1 > f_utf_string_length_size) {
+ if (destination->used == f_utf_string_length_size) {
return F_status_set_error(F_string_too_large);
}
} // for
}
- if (destination->used + 1 > f_utf_string_length_size) {
+ if (destination->used == f_utf_string_length_size) {
return F_status_set_error(F_string_too_large);
}
buffer_write[used] = f_macro_utf_character_to_char_1(string[*written + i]);
if (width > 1) {
- if (used + 1 > write_size) {
+ if (used == write_size) {
width_written = 1;
used += 1;
break;
f_return_status private_fll_execute_arguments_add(const f_string source, const f_string_length length, f_string_dynamics *arguments) {
f_status status = F_none;
- if (arguments->used >= arguments->size) {
+ if (arguments->used == arguments->size) {
if (arguments->size + f_memory_default_allocation_step > f_array_length_size) {
if (arguments->size + 1 > f_array_length_size) return F_buffer_too_large;
f_macro_string_dynamics_resize(status, (*arguments), arguments->size + 1);
f_return_status fll_fss_identify(const f_string_static buffer, f_fss_header *header) {
#ifndef _di_level_2_parameter_checking_
if (header == 0) return F_status_set_error(F_parameter);
- if (buffer.used <= 0) return F_status_set_error(F_parameter);
+ if (buffer.used == 0) return F_status_set_error(F_parameter);
#endif // _di_level_2_parameter_checking_
return private_fll_fss_identify(buffer, header);
f_status status = F_none;
f_string_length length_object = 0;
+ f_string_dynamics *value = 0;
+ f_fss_content *content = 0;
f_array_length i = 0;
f_array_length j = 0;
if (F_status_is_error(status)) return status;
if (status == F_equal_to_not) continue;
+value = values[j];
+content = &contents.array[i];
if (values[j]->used + contents.array[i].used > values[j]->size) {
if (values[j]->used + contents.array[i].used > f_array_length_size) {
return F_status_set_error(F_buffer_too_large);
}
- f_macro_string_dynamics_resize(status, (*values[j]), values[j]->used + contents.array[i].used);
+ //f_macro_string_dynamics_resize(status, (*values[j]), (values[j]->used + contents.array[i].used));
+ //f_macro_string_dynamics_resize(status, (*value), (value->used + content->used));
+ f_macro_string_dynamics_resize(status, (*value), (values[j]->used + content->used));
+
+/*
+ status = F_none;
+ if ((values[j]->used + contents.array[i].used) < values[j]->size) {
+ f_array_length xxx = values[j]->size - (values[j]->used + contents.array[i].used);
+ for (; xxx < values[j]->size; xxx++) {
+ f_macro_string_dynamic_delete(status, values[j]->array[i]);
+ if (status != F_none) break;
+ }
+ }
+ if (status == F_none) status = f_memory_resize((void **) & values[j]->array, sizeof(f_string_dynamic), values[j]->size, (values[j]->used + contents.array[i].used));
+ if (status == F_none) {
+ if ((values[j]->used + contents.array[i].used) > values[j]->size) {
+ f_array_length xxx = values[j]->size;
+ for (; xxx < (values[j]->used + contents.array[i].used); xxx++) {
+ memset(&values[j]->array[i], 0, sizeof(f_string_dynamic));
+ }
+ }
+ values[j]->size = (values[j]->used + contents.array[i].used);
+ if (values[j]->used > values[j]->size) values[j]->used = (values[j]->used + contents.array[i].used);
+ }
+*/
+
if (F_status_is_error(status)) return status;
}
continue;
}
- if (values[j]->used + 1 > values[j]->size) {
+ if (values[j]->used == values[j]->size) {
if (values[j]->used + f_fss_default_allocation_step > f_array_length_size) {
- if (values[j]->used + 1 > f_array_length_size) {
+ if (values[j]->used == f_array_length_size) {
f_macro_string_dynamic_delete_simple(name);
return F_status_set_error(F_buffer_too_large);
}
if (F_status_is_error(status)) return status;
if (status == F_equal_to_not) continue;
- if (values[j]->used + 1 > values[j]->size) {
+ if (values[j]->used == values[j]->size) {
if (values[j]->used + f_fss_default_allocation_step > f_array_length_size) {
- if (values[j]->used + 1 > f_array_length_size) {
+ if (values[j]->used == f_array_length_size) {
return F_status_set_error(F_buffer_too_large);
}
if (F_status_is_error(status)) return status;
if (status == F_equal_to_not) continue;
- if (values[j]->used + 1 > values[j]->size) {
+ if (values[j]->used == values[j]->size) {
if (values[j]->used + f_fss_default_allocation_step > f_array_length_size) {
- if (values[j]->used + 1 > f_array_length_size) {
+ if (values[j]->used == f_array_length_size) {
return F_status_set_error(F_buffer_too_large);
}
map_multi = &values[j]->array[k];
}
else {
- if (values[j]->used + 1 > values[j]->size) {
+ if (values[j]->used == values[j]->size) {
if (values[j]->used + f_fss_default_allocation_step > f_array_length_size) {
- if (values[j]->used + 1 > f_array_length_size) {
+ if (values[j]->used == f_array_length_size) {
return F_status_set_error(F_buffer_too_large);
}
if (contents.array[i].used == 1) continue;
}
- if (map_multi->value.used + 1 > map_multi->value.size) {
- if (map_multi->value.used + 1 > f_array_length_size) {
+ if (map_multi->value.used == map_multi->value.size) {
+ if (map_multi->value.used == f_array_length_size) {
return F_status_set_error(F_buffer_too_large);
}
map = &values[j]->array[k];
}
else {
- if (values[j]->used + 1 > values[j]->size) {
+ if (values[j]->used == values[j]->size) {
if (values[j]->used + f_fss_default_allocation_step > f_array_length_size) {
- if (values[j]->used + 1 > f_array_length_size) {
+ if (values[j]->used == f_array_length_size) {
f_macro_string_dynamic_delete_simple(name);
return F_status_set_error(F_buffer_too_large);
}
if (F_status_is_error(status)) return status;
if (status == F_equal_to_not) continue;
- if (values[j]->used + 1 > values[j]->size) {
+ if (values[j]->used == values[j]->size) {
if (values[j]->used + f_fss_default_allocation_step > f_array_length_size) {
- if (values[j]->used + 1 > f_array_length_size) {
+ if (values[j]->used == f_array_length_size) {
return F_status_set_error(F_buffer_too_large);
}
#endif
#ifndef _di_fll_fss_basic_read_
- f_return_status fll_fss_basic_read(f_string_dynamic *buffer, f_string_range *range, f_fss_objects *objects, f_fss_contents *contents) {
+ f_return_status fll_fss_basic_read(f_string_dynamic *buffer, f_string_range *range, f_fss_objects *objects, f_fss_contents *contents, f_fss_quoteds *quoted_objects) {
#ifndef _di_level_2_parameter_checking_
if (buffer == 0) return F_status_set_error(F_parameter);
if (range == 0) return F_status_set_error(F_parameter);
f_status status = F_none;
f_status status2 = F_none;
f_string_length initial_used = objects->used;
+
bool found_data = F_false;
+ f_fss_quoted *quoted_object = 0;
+
do {
- if (objects->used >= objects->size) {
+ if (objects->used == objects->size) {
f_macro_fss_objects_resize(status2, (*objects), objects->used + f_fss_default_allocation_step);
if (F_status_is_error(status2)) return status2;
f_macro_fss_contents_resize(status2, (*contents), contents->used + f_fss_default_allocation_step);
if (F_status_is_error(status2)) return status2;
+
+ if (quoted_objects) {
+ f_macro_fss_quoteds_resize(status2, (*quoted_objects), quoted_objects->used + f_fss_default_allocation_step);
+ if (F_status_is_error(status2)) return status2;
+ }
}
do {
- status = fl_fss_basic_object_read(buffer, range, &objects->array[objects->used]);
- if (F_status_is_error(status)) return status;
+ if (quoted_objects) {
+ quoted_object = "ed_objects->array[quoted_objects->used];
+ }
+
+ status = fl_fss_basic_object_read(buffer, range, &objects->array[objects->used], quoted_object);
+
+ if (F_status_is_error(status)) {
+ return status;
+ }
if (range->start >= range->stop || range->start >= buffer->used) {
if (status == FL_fss_found_object || status == FL_fss_found_object_content_not) {
objects->used++;
- if (contents->array[contents->used].used >= contents->array[contents->used].size) {
+ if (quoted_objects) {
+ quoted_objects->used++;
+ }
+
+ if (contents->array[contents->used].used == contents->array[contents->used].size) {
f_macro_fss_content_resize(status2, contents->array[contents->used], contents->array[contents->used].size + f_fss_default_allocation_step);
if (F_status_is_error(status2)) return status2;
}
else if (status == FL_fss_found_object_content_not) {
found_data = F_true;
- if (contents->array[contents->used].used >= contents->array[contents->used].size) {
+ if (contents->array[contents->used].used == contents->array[contents->used].size) {
f_macro_fss_content_resize(status2, contents->array[contents->used], contents->array[contents->used].size + f_fss_default_allocation_step);
if (F_status_is_error(status2)) return status2;
}
contents->array[contents->used].used++;
objects->used++;
contents->used++;
+
+ if (quoted_objects) {
+ quoted_objects->used++;
+ }
+
return status;
}
else if (status == F_data_not_eos || status == F_data_not_stop) {
if (status == FL_fss_found_object || status == FL_fss_found_content || status == FL_fss_found_content_not || status == FL_fss_found_object_content_not) {
objects->used++;
contents->used++;
+
+ if (quoted_objects) {
+ quoted_objects->used++;
+ }
}
if (range->start >= buffer->used) {
objects->used++;
contents->used++;
+
+ if (quoted_objects) {
+ quoted_objects->used++;
+ }
} while (range->start < f_string_length_size);
return F_status_is_error(F_number_overflow);
#endif // _di_fll_fss_basic_read_
#ifndef _di_fll_fss_basic_write_
- f_return_status fll_fss_basic_write(const f_string_static object, const f_string_statics contents, f_string_dynamic *buffer) {
+ f_return_status fll_fss_basic_write(const f_string_static object, const f_string_statics contents, f_string_dynamic *destination) {
#ifndef _di_level_2_parameter_checking_
- if (buffer == 0) return F_status_set_error(F_parameter);
+ if (destination == 0) return F_status_set_error(F_parameter);
if (contents.used > contents.size) return F_status_set_error(F_parameter);
#endif // _di_level_2_parameter_checking_
f_status status = 0;
f_array_length current = 0;
- f_string_range range = f_string_range_initialize;
-
- range.start = 0;
- range.stop = object.used - 1;
+ f_string_range range = f_macro_string_range_initialize(object.used);
- status = fl_fss_basic_object_write(buffer, object, &range);
+ status = fl_fss_basic_object_write(object, 0, &range, destination);
if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
return status;
if (contents.used > 0) {
range.start = 0;
range.stop = contents.array[0].used - 1;
- status = fl_fss_basic_content_write(buffer, contents.array[0], &range);
+ status = fl_fss_basic_content_write(contents.array[0], &range, destination);
if (F_status_is_error(status)) {
return status;
}
}
else {
- if (buffer->used >= buffer->size) {
- f_macro_string_dynamic_resize(status, (*buffer), buffer->size + f_fss_default_allocation_step_string);
+ if (destination->used == destination->size) {
+ f_macro_string_dynamic_resize(status, (*destination), destination->size + f_fss_default_allocation_step_string);
if (F_status_is_error(status)) return status;
}
- buffer->string[buffer->used] = f_string_eol[0];
- buffer->used++;
+ destination->string[destination->used] = f_string_eol[0];
+ destination->used++;
}
}
* This will be populated with all valid objects found.
* @param contents
* This will be populated with all valid contents found.
+ * @param quoted_objects
+ * An array of all objects discovered with quotes and the quote discovered.
+ * Set pointer address to 0 to disable.
*
* @return
* F_none on success.
* F_utf (with error bit) is returned on failure to read/process a UTF-8 character.
*/
#ifndef _di_fll_fss_basic_read_
- extern f_return_status fll_fss_basic_read(f_string_dynamic *buffer, f_string_range *range, f_fss_objects *objects, f_fss_contents *contents);
+ extern f_return_status fll_fss_basic_read(f_string_dynamic *buffer, f_string_range *range, f_fss_objects *objects, f_fss_contents *contents, f_fss_quoteds *quoted_objects);
#endif // _di_fll_fss_basic_read_
/**
bool found_data = F_false;
do {
- if (objects->used >= objects->size) {
+ if (objects->used == objects->size) {
f_macro_fss_objects_resize(status2, (*objects), objects->used + f_fss_default_allocation_step);
if (F_status_is_error(status)) {
if (status == FL_fss_found_object || status == FL_fss_found_object_content_not) {
objects->used++;
- if (contents->array[contents->used].used >= contents->array[contents->used].size) {
+ if (contents->array[contents->used].used == contents->array[contents->used].size) {
f_macro_fss_content_resize(status2, contents->array[contents->used], contents->array[contents->used].size + f_fss_default_allocation_step);
if (F_status_is_error(status2)) return status2;
}
else if (status == FL_fss_found_object_content_not) {
found_data = F_true;
- if (contents->array[contents->used].used >= contents->array[contents->used].size) {
+ if (contents->array[contents->used].used == contents->array[contents->used].size) {
f_macro_fss_content_resize(status2, contents->array[contents->used], contents->array[contents->used].size + f_fss_default_allocation_step);
if (F_status_is_error(status2)) return status2;
}
}
}
else {
- if (buffer->used >= buffer->size) {
+ if (buffer->used == buffer->size) {
f_macro_string_dynamic_resize(status, (*buffer), buffer->size + f_fss_default_allocation_step_string);
if (F_status_is_error(status)) return status;
}
#endif
#ifndef _di_fll_fss_extended_read_
- f_return_status fll_fss_extended_read(f_string_dynamic *buffer, f_string_range *range, f_fss_objects *objects, f_fss_contents *contents) {
+ f_return_status fll_fss_extended_read(f_string_dynamic *buffer, f_string_range *range, f_fss_objects *objects, f_fss_contents *contents, f_fss_quoteds *quoted_objects, f_fss_quotedss *quoted_contents) {
#ifndef _di_level_2_parameter_checking_
if (buffer == 0) return F_status_set_error(F_parameter);
if (range == 0) return F_status_set_error(F_parameter);
f_status status = F_none;
f_status status2 = F_none;
f_string_length initial_used = objects->used;
+
bool found_data = F_false;
+ f_fss_quoted *quoted_object = 0;
+ f_fss_quoteds *quoted_content = 0;
+
do {
- if (objects->used >= objects->size) {
+ if (objects->used == objects->size) {
f_macro_fss_objects_resize(status2, (*objects), objects->used + f_fss_default_allocation_step);
if (F_status_is_error(status2)) return status2;
f_macro_fss_contents_resize(status2, (*contents), contents->used + f_fss_default_allocation_step);
if (F_status_is_error(status2)) return status2;
+
+ if (quoted_objects) {
+ f_macro_fss_quoteds_resize(status2, (*quoted_objects), quoted_objects->used + f_fss_default_allocation_step);
+ if (F_status_is_error(status2)) return status2;
+ }
+
+ if (quoted_contents) {
+ f_macro_fss_quotedss_resize(status2, (*quoted_contents), quoted_contents->used + f_fss_default_allocation_step);
+ if (F_status_is_error(status2)) return status2;
+ }
}
do {
- status = fl_fss_extended_object_read(buffer, range, &objects->array[objects->used]);
- if (F_status_is_error(status)) return status;
+ if (quoted_objects) {
+ quoted_object = "ed_objects->array[quoted_objects->used];
+ }
+
+ status = fl_fss_extended_object_read(buffer, range, &objects->array[objects->used], quoted_object);
+
+ if (F_status_is_error(status)) {
+ return status;
+ }
if (range->start >= range->stop || range->start >= buffer->used) {
if (status == FL_fss_found_object || status == FL_fss_found_object_content_not) {
objects->used++;
+ if (quoted_objects) {
+ quoted_objects->used++;
+ }
+
if (contents->array[contents->used].used == contents->array[contents->used].size) {
f_macro_fss_content_resize(status2, contents->array[contents->used], contents->array[contents->used].size + f_fss_default_allocation_step);
if (F_status_is_error(status2)) return status2;
contents->used++;
+ if (quoted_contents) {
+ quoted_contents->used++;
+ }
+
return FL_fss_found_object_content_not;
}
if (status == FL_fss_found_object) {
found_data = F_true;
- status = fl_fss_extended_content_read(buffer, range, &contents->array[contents->used]);
- if (F_status_is_error(status)) return status;
+ if (quoted_contents) {
+ quoted_content = "ed_contents->array[quoted_contents->used];
+ }
+
+ status = fl_fss_extended_content_read(buffer, range, &contents->array[contents->used], quoted_content);
+
+ if (F_status_is_error(status)) {
+ return status;
+ }
break;
}
if (status == F_none_eos || status == F_none_stop) {
contents->array[contents->used].used++;
+
objects->used++;
contents->used++;
+
+ if (quoted_objects) {
+ quoted_objects->used++;
+ }
+
+ if (quoted_contents) {
+ quoted_contents->array[quoted_contents->used].used++;
+ quoted_contents->used++;
+ }
+
return status;
}
else if (status == F_data_not_eos || status == F_data_not_stop || status == F_unterminated_group_eos || status == F_unterminated_group_stop) {
if (status == FL_fss_found_object || status == FL_fss_found_content || status == FL_fss_found_content_not || status == FL_fss_found_object_content_not || status == F_unterminated_group) {
objects->used++;
contents->used++;
+
+ if (quoted_objects) {
+ quoted_objects->used++;
+ }
+
+ if (quoted_contents) {
+ quoted_contents->used++;
+ }
}
if (range->start >= buffer->used) {
objects->used++;
contents->used++;
+
+ if (quoted_objects) {
+ quoted_objects->used++;
+ }
+
+ if (quoted_contents) {
+ quoted_contents->used++;
+ }
} while (range->start < f_string_length_size);
return F_status_is_error(F_number_overflow);
f_status status = 0;
f_array_length current = 0;
- f_string_range range = f_string_range_initialize;
-
- range.start = 0;
- range.stop = object.used - 1;
+ f_string_range range = f_macro_string_range_initialize(object.used);
- status = fl_fss_extended_object_write(object, &range, buffer);
+ status = fl_fss_extended_object_write(object, 0, &range, buffer);
if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
return status;
while (current < contents.used) {
range.start = 0;
range.stop = contents.array[current].used - 1;
- status = fl_fss_extended_content_write(contents.array[current], &range, buffer);
+ status = fl_fss_extended_content_write(contents.array[current], 0, &range, buffer);
if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
return status;
* This will be populated with all valid objects found.
* @param contents
* This will be populated with all valid contents found.
+ * @param quoted_objects
+ * An array of all objects discovered with quotes and the quote discovered.
+ * Set pointer address to 0 to disable.
+ * @param quoted_contents
+ * An array of all contents discovered with quotes and the quote discovered.
+ * Set pointer address to 0 to disable.
*
* @return
* F_none on success.
* F_number_overflow (with error bit) if the maximimum buffer size is reached.
*/
#ifndef _di_fll_fss_extended_read_
- extern f_return_status fll_fss_extended_read(f_string_dynamic *buffer, f_string_range *range, f_fss_objects *objects, f_fss_contents *contents);
+ extern f_return_status fll_fss_extended_read(f_string_dynamic *buffer, f_string_range *range, f_fss_objects *objects, f_fss_contents *contents, f_fss_quoteds *quoted_objects, f_fss_quotedss *quoted_contents);
#endif // _di_fll_fss_extended_read_
/**
do {
do {
- if (nest->depth[0].used >= nest->depth[0].size) {
+ if (nest->depth[0].used == nest->depth[0].size) {
f_macro_fss_items_resize(status2, nest->depth[0], nest->depth[0].used + f_fss_default_allocation_step);
if (F_status_is_error(status)) return status;
}
}
}
else {
- if (buffer->used >= buffer->size) {
+ if (buffer->used == buffer->size) {
f_macro_string_dynamic_resize(status, (*buffer), buffer->size + f_fss_default_allocation_step_string);
if (F_status_is_error(status)) return status;
}
status = F_none;
}
else {
- if (destination->used >= destination->size) {
+ if (destination->used == destination->size) {
f_macro_string_dynamics_resize(status, (*destination), destination->size + f_console_default_allocation_step);
if (F_status_is_error(status)) return status;
}
}
}
- if (environment->names.used + 1 > environment->names.size) {
+ if (environment->names.used == environment->names.size) {
f_macro_string_dynamics_resize(*status, environment->names, environment->names.size + f_memory_default_allocation_step);
if (F_status_is_not_error(*status)) {
f_string_range range = f_macro_string_range_initialize(buffer.used);
- *status = fll_fss_extended_read(&buffer, &range, &objects, &contents);
+ *status = fll_fss_extended_read(&buffer, &range, &objects, &contents, 0, 0);
if (F_status_is_error(*status)) {
fake_print_error_fss(data.context, data.verbosity, *status, "fll_fss_extended_read", data.file_data_build_settings.string, range, F_true);
}
continue;
}
+ f_fss_quotedss quoted_contents = f_fss_quotedss_initialize;
+
content_range = list_contents.array[i].array[0];
- *status = fll_fss_extended_read(&data_make->buffer, &content_range, &settings.objects, &settings.contents);
+ *status = fll_fss_extended_read(&data_make->buffer, &content_range, &settings.objects, &settings.contents, 0, "ed_contents);
if (F_status_is_error(*status)) {
fake_print_error_fss(data.context, data.verbosity, *status, "fll_fss_extended_read", data.file_data_build_fakefile.string, content_range, F_true);
+ f_macro_fss_quotedss_delete_simple(quoted_contents);
f_macro_fss_set_delete_simple(settings);
f_macro_fss_objects_delete_simple(list_objects);
f_macro_fss_contents_delete_simple(list_contents);
return;
}
+ if (quoted_contents.used) {
+ // @todo
+ }
+
+ f_macro_fss_quotedss_delete_simple(quoted_contents);
+
missing_settings = F_false;
continue;
}
content_range = list_contents.array[i].array[0];
- *status = fll_fss_extended_read(&data_make->buffer, &content_range, &data_make->fakefile.array[data_make->fakefile.used].objects, &data_make->fakefile.array[data_make->fakefile.used].contents);
+ *status = fll_fss_extended_read(&data_make->buffer, &content_range, &data_make->fakefile.array[data_make->fakefile.used].objects, &data_make->fakefile.array[data_make->fakefile.used].contents, 0, 0);
if (F_status_is_error(*status)) {
fake_print_error_fss(data.context, data.verbosity, *status, "fll_fss_extended_read", data.file_data_build_fakefile.string, content_range, F_true);
break;
}
- if (arguments->used + 1 > arguments->size) {
+ if (arguments->used == arguments->size) {
if (arguments->used + f_memory_default_allocation_step <= F_buffer_too_large) {
f_macro_string_dynamics_resize((*status), (*arguments), arguments->used + f_memory_default_allocation_step);
}
*status = fl_string_dynamic_partial_compare_dynamic(map_multis->array[k].name, data_make->buffer, iki_content.array[j]);
if (*status == F_equal_to) {
- for (l = 0; l < map_multis->array[k].value.used; l++) {
- if (l > 0) {
- *status = fl_string_append(" ", 1, &arguments->array[arguments->used]);
+ if (map_multis->array[k].value.used) {
+ for (l = 0; l < map_multis->array[k].value.used; l++) {
+ if (l > 0) {
+ *status = fl_string_append(" ", 1, &arguments->array[arguments->used]);
+ if (F_status_is_error(*status)) {
+ fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_append", F_true);
+ break;
+ }
+ }
+
+ *status = fl_string_dynamic_append_nulless(map_multis->array[k].value.array[l], &arguments->array[arguments->used]);
if (F_status_is_error(*status)) {
- fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_append", F_true);
+ fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_dynamic_append_nulless", F_true);
break;
}
- }
-
- *status = fl_string_dynamic_append_nulless(map_multis->array[k].value.array[l], &arguments->array[arguments->used]);
- if (F_status_is_error(*status)) {
- fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_dynamic_append_nulless", F_true);
- break;
- }
- } // for
+ } // for
+ }
break;
}
*status = F_status_set_error(F_invalid);
}
else if (operation == fake_make_operation_type_operate) {
- if (section_stack->used + 1 > fake_make_section_stack_max) {
+ if (section_stack->used == fake_make_section_stack_max) {
fake_print_error_fakefile_section_operation_stack_max(data.context, data.verbosity, data_make->buffer, section->name, section->objects.array[i], fake_make_section_stack_max);
*status = F_status_set_error(F_recurse);
} // for
if (F_status_is_fine(*status) && has_error) {
- *status = F_status_set_error(F_failure);
+ *status = F_none;
}
if (F_status_is_error(*status)) {
-# fss-0005 iki-0001
-# @todo consider creating iki-0002 to support both "parameter" and "define" as opposed to "var" as documented below.
+# fss-0005 iki-0002
settings:
load_build yes
# from this, adding 'parameter:"verbose"' in main would be replaced with '+v' if and when the +V/++verbose parameter is passed to fake otherwise it is removed.
# gcc parameter:"verbose" would become gcc +v
parameter verbose +v
+ parameter verbose4 +v and then " some"
main:
- print This is a line.
+ print This is a line "(define = 'define:"example"') parameter:"verbose4"."
invalid
+ print This works? 'parameter\:"verbose" parameter:"verbose2' parameter:'verbose3' should_-+miss:"abc"
print This is another line. 'parameter\:"verbose" parameter:"verbose2\""' parameter:'verbose3\\'
another invalid
input.stop = local_buffer.used - 1;
- status = fll_fss_basic_read(&local_buffer, &input, &basic_objects, &basic_contents);
+ status = fll_fss_basic_read(&local_buffer, &input, &basic_objects, &basic_contents, 0);
}
if (F_status_set_error(status)) {
}
if (new_chain) {
- if (data->chains.used >= data->chains.size) {
+ if (data->chains.used == data->chains.size) {
f_macro_string_dynamics_resize(status, data->chains, data->chains.used + firewall_default_allocation_step);
if (F_status_is_error(status)) {
f_return_status firewall_process_rules(f_string_range *range, firewall_local_data *local, firewall_data *data) {
f_status status = F_none;
- status = fll_fss_extended_read(&local->buffer, range, &local->rule_objects, &local->rule_contents);
+ status = fll_fss_extended_read(&local->buffer, range, &local->rule_objects, &local->rule_contents, 0, 0);
if (F_status_is_not_error(status)) {
status = firewall_perform_commands(*local, *data);
// TODO: temporarily added, convert this to a function below.
// TODO: also report: fl_color_print_line(f_type_error, data.context.error, data.context.reset, "CRITICAL ERROR: Unable to allocate memory.");
#define firewall_macro_append_argument_to_arguments(status, arguments, argument) \
- if (arguments.used >= arguments.size) { \
+ if (arguments.used == arguments.size) { \
f_macro_string_dynamics_resize(status, arguments, arguments.used + firewall_default_allocation_step); \
\
if (F_status_is_error(status)) break; \
printf("%c", f_string_eol[0]);
- fll_program_print_help_option(context, fss_basic_list_write_short_object, fss_basic_list_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Write an object instead of content.");
- fll_program_print_help_option(context, fss_basic_list_write_short_file, fss_basic_list_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to.");
- fll_program_print_help_option(context, fss_basic_list_write_short_string, fss_basic_list_write_long_string, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a string to convert.");
+ fll_program_print_help_option(context, fss_basic_list_write_short_file, fss_basic_list_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to.");
+ fll_program_print_help_option(context, fss_basic_list_write_short_object, fss_basic_list_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Write an object instead of content.");
+ fll_program_print_help_option(context, fss_basic_list_write_short_partial, fss_basic_list_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, "Do not output the final end of object or end of content character.");
+ fll_program_print_help_option(context, fss_basic_list_write_short_string, fss_basic_list_write_long_string, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a string to convert.");
fll_program_print_help_usage(context, fss_basic_list_write_name, "");
f_console_parameter_ids choices = { ids, 3 };
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
-
if (F_status_is_error(status)) {
fss_basic_list_write_delete_data(data);
return F_status_set_error(status);
f_string_range range = f_string_range_initialize;
if (data->process_pipe) {
- f_file file = f_file_initialize;
+ f_file file = f_file_initialize;
f_string_dynamic input = f_string_dynamic_initialize;
file.id = f_type_descriptor_input;
fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
}
+ f_macro_string_dynamic_delete_simple(buffer);
f_macro_string_dynamic_delete_simple(input);
fss_basic_list_write_delete_data(data);
return F_status_set_error(status);
}
- range.start = 0;
- range.stop = input.used - 1;
+ if (input.used) {
+ range.start = 0;
+ range.stop = input.used - 1;
- if (object) {
- status = fl_fss_basic_list_object_write(input, &range, &buffer);
+ if (object) {
+ status = fl_fss_basic_list_object_write(input, &range, &buffer);
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
- return F_status_set_error(status);
- }
- }
- else {
- status = fl_fss_basic_list_content_write(input, &range, &buffer);
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
+ f_macro_string_dynamic_delete_simple(buffer);
+ f_macro_string_dynamic_delete_simple(input);
+ fss_basic_list_write_delete_data(data);
+ return F_status_set_error(status);
+ }
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
- return F_status_set_error(status);
+ // this should remove both the closing newline and the colon.
+ if (data->parameters[fss_basic_list_write_parameter_partial].result == f_console_result_found) {
+ buffer.used -= 2;
+ }
+ }
+ else {
+ status = fl_fss_basic_list_content_write(input, &range, &buffer);
+
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
+ f_macro_string_dynamic_delete_simple(buffer);
+ f_macro_string_dynamic_delete_simple(input);
+ fss_basic_list_write_delete_data(data);
+ return F_status_set_error(status);
+ }
+
+ if (data->parameters[fss_basic_list_write_parameter_partial].result == f_console_result_found) {
+ buffer.used--;
+ }
}
}
input.string = arguments.argv[data->parameters[fss_basic_list_write_parameter_string].additional.array[0]];
input.used = strlen(input.string);
- range.start = 0;
- range.stop = input.used - 1;
+ if (input.used) {
+ range.start = 0;
+ range.stop = input.used - 1;
- if (object) {
- status = fl_fss_basic_list_object_write(input, &range, &buffer);
+ if (object) {
+ status = fl_fss_basic_list_object_write(input, &range, &buffer);
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
- return F_status_set_error(status);
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
+ f_macro_string_dynamic_delete_simple(buffer);
+ fss_basic_list_write_delete_data(data);
+ return F_status_set_error(status);
+ }
+
+ // this should remove both the closing newline and the colon.
+ if (data->parameters[fss_basic_list_write_parameter_partial].result == f_console_result_found) {
+ buffer.used -= 2;
+ }
}
- }
- else {
- status = fl_fss_basic_list_content_write(input, &range, &buffer);
+ else {
+ status = fl_fss_basic_list_content_write(input, &range, &buffer);
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
- return F_status_set_error(status);
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos || status == F_data_not_eol) {
+ f_macro_string_dynamic_delete_simple(buffer);
+ fss_basic_list_write_delete_data(data);
+ return F_status_set_error(status);
+ }
+
+ if (data->parameters[fss_basic_list_write_parameter_partial].result == f_console_result_found) {
+ buffer.used--;
+ }
}
}
fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
}
+ f_macro_string_dynamic_delete_simple(buffer);
fss_basic_list_write_delete_data(data);
return F_status_set_error(status);
}
fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()", status);
}
+ f_macro_string_dynamic_delete_simple(buffer);
fss_basic_list_write_delete_data(data);
return F_status_set_error(status);
}
else {
f_print_string_dynamic(f_type_output, buffer);
}
+
+ f_macro_string_dynamic_delete_simple(buffer);
}
fss_basic_list_write_delete_data(data);
#endif // _di_fss_basic_list_write_name_
#ifndef _di_fss_basic_list_write_defines_
- #define fss_basic_list_write_short_object "o"
- #define fss_basic_list_write_short_file "f"
- #define fss_basic_list_write_short_string "s"
+ #define fss_basic_list_write_short_object "o"
+ #define fss_basic_list_write_short_file "f"
+ #define fss_basic_list_write_short_string "s"
+ #define fss_basic_list_write_short_partial "p"
- #define fss_basic_list_write_long_object "object"
- #define fss_basic_list_write_long_file "file"
- #define fss_basic_list_write_long_string "string"
+ #define fss_basic_list_write_long_object "object"
+ #define fss_basic_list_write_long_file "file"
+ #define fss_basic_list_write_long_string "string"
+ #define fss_basic_list_write_long_partial "partial"
enum {
fss_basic_list_write_parameter_help,
fss_basic_list_write_parameter_no_color,
fss_basic_list_write_parameter_version,
- fss_basic_list_write_parameter_object,
fss_basic_list_write_parameter_file,
+ fss_basic_list_write_parameter_object,
+ fss_basic_list_write_parameter_partial,
fss_basic_list_write_parameter_string,
};
f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \
- f_console_parameter_initialize(fss_basic_list_write_short_object, fss_basic_list_write_long_object, 0, F_false, f_console_type_normal), \
f_console_parameter_initialize(fss_basic_list_write_short_file, fss_basic_list_write_long_file, 0, F_true, f_console_type_normal), \
+ f_console_parameter_initialize(fss_basic_list_write_short_object, fss_basic_list_write_long_object, 0, F_false, f_console_type_normal), \
+ f_console_parameter_initialize(fss_basic_list_write_short_partial, fss_basic_list_write_long_partial, 0, F_true, f_console_type_normal), \
f_console_parameter_initialize(fss_basic_list_write_short_string, fss_basic_list_write_long_string, 0, F_true, f_console_type_normal), \
}
- #define fss_basic_list_write_total_parameters 8
+ #define fss_basic_list_write_total_parameters 9
#endif // _di_fss_basic_list_write_defines_
#ifndef _di_fss_basic_list_write_data_
input.start = 0;
input.stop = data->buffer.used - 1;
- status = fll_fss_basic_read(&data->buffer, &input, &data->objects, &data->contents);
+ status = fll_fss_basic_read(&data->buffer, &input, &data->objects, &data->contents, 0);
if (F_status_is_error(status)) {
status = F_status_set_fine(status);
printf("%c", f_string_eol[0]);
- fll_program_print_help_option(context, fss_basic_write_short_object, fss_basic_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Write an object instead of content.");
- fll_program_print_help_option(context, fss_basic_write_short_file, fss_basic_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to.");
- fll_program_print_help_option(context, fss_basic_write_short_string, fss_basic_write_long_string, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a string to convert.");
+ fll_program_print_help_option(context, fss_basic_write_short_file, fss_basic_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to.");
+ fll_program_print_help_option(context, fss_basic_write_short_object, fss_basic_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Write an object instead of content.");
+ fll_program_print_help_option(context, fss_basic_write_short_partial, fss_basic_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, "Do not output the final end of object or end of content character.");
+ fll_program_print_help_option(context, fss_basic_write_short_string, fss_basic_write_long_string, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a string to convert.");
fll_program_print_help_usage(context, fss_basic_write_name, "");
f_console_parameter_id ids[3] = { fss_basic_write_parameter_no_color, fss_basic_write_parameter_light, fss_basic_write_parameter_dark };
f_console_parameter_ids choices = { ids, 3 };
- status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
-
+ status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
if (F_status_is_error(status)) {
fss_basic_write_delete_data(data);
- return F_status_set_error(status);
+ return status;
}
status = F_none;
return F_status_set_error(status);
}
- range.start = 0;
- range.stop = input.used - 1;
+ if (input.used) {
+ range.start = 0;
+ range.stop = input.used - 1;
- if (object) {
- status = fl_fss_basic_object_write(&buffer, input, &range);
+ if (object) {
+ status = fl_fss_basic_object_write(input, 0, &range, &buffer);
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- return F_status_set_error(status);
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_delete_simple(buffer);
+ f_macro_string_dynamic_delete_simple(input);
+ fss_basic_write_delete_data(data);
+ return F_status_set_error(status);
+ }
+ }
+ else {
+ status = fl_fss_basic_content_write(input, &range, &buffer);
+
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_delete_simple(buffer);
+ f_macro_string_dynamic_delete_simple(input);
+ fss_basic_write_delete_data(data);
+ return F_status_set_error(status);
+ }
}
- }
- else {
- status = fl_fss_basic_content_write(&buffer, input, &range);
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- return F_status_set_error(status);
+ if (data->parameters[fss_basic_write_parameter_partial].result == f_console_result_found) {
+ buffer.used--;
}
}
f_string_dynamic input = f_string_dynamic_initialize;
input.string = arguments.argv[data->parameters[fss_basic_write_parameter_string].additional.array[0]];
- input.used = strlen(input.string);
+ input.used = strnlen(input.string, f_console_length_size);
- range.start = 0;
- range.stop = input.used - 1;
+ if (input.used) {
+ range.start = 0;
+ range.stop = input.used - 1;
- if (object) {
- status = fl_fss_basic_object_write(&buffer, input, &range);
+ if (object) {
+ status = fl_fss_basic_object_write(input, 0, &range, &buffer);
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- return F_status_set_error(status);
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_delete_simple(buffer);
+ fss_basic_write_delete_data(data);
+ return F_status_set_error(status);
+ }
}
- }
- else {
- status = fl_fss_basic_content_write(&buffer, input, &range);
+ else {
+ status = fl_fss_basic_content_write(input, &range, &buffer);
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- return F_status_set_error(status);
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_delete_simple(buffer);
+ fss_basic_write_delete_data(data);
+ return F_status_set_error(status);
+ }
+ }
+
+ if (data->parameters[fss_basic_write_parameter_partial].result == f_console_result_found) {
+ buffer.used--;
}
}
fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
}
+ f_macro_string_dynamic_delete_simple(buffer);
fss_basic_write_delete_data(data);
return status;
}
fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()", status);
}
+ f_macro_string_dynamic_delete_simple(buffer);
fss_basic_write_delete_data(data);
return F_status_set_error(status);
}
else {
f_print_string_dynamic(f_type_output, buffer);
}
+
+ f_macro_string_dynamic_delete_simple(buffer);
}
fss_basic_write_delete_data(data);
#ifndef _di_fss_basic_write_delete_data_
f_return_status fss_basic_write_delete_data(fss_basic_write_data *data) {
f_status status = F_none;
- f_string_length i = 0;
- while (i < fss_basic_write_total_parameters) {
+ for (f_string_length i = 0; i < fss_basic_write_total_parameters; i++) {
f_macro_string_lengths_delete_simple(data->parameters[i].locations);
f_macro_string_lengths_delete_simple(data->parameters[i].additional);
- i++;
- } // while
+ } // for
f_macro_string_lengths_delete_simple(data->remaining);
fl_macro_color_context_delete_simple(data->context);
#endif // _di_fss_basic_write_name_
#ifndef _di_fss_basic_write_defines_
- #define fss_basic_write_short_object "o"
- #define fss_basic_write_short_file "f"
- #define fss_basic_write_short_string "s"
+ #define fss_basic_write_short_object "o"
+ #define fss_basic_write_short_file "f"
+ #define fss_basic_write_short_string "s"
+ #define fss_basic_write_short_partial "p"
- #define fss_basic_write_long_object "object"
- #define fss_basic_write_long_file "file"
- #define fss_basic_write_long_string "string"
+ #define fss_basic_write_long_object "object"
+ #define fss_basic_write_long_file "file"
+ #define fss_basic_write_long_string "string"
+ #define fss_basic_write_long_partial "partial"
enum {
fss_basic_write_parameter_help,
fss_basic_write_parameter_no_color,
fss_basic_write_parameter_version,
- fss_basic_write_parameter_object,
fss_basic_write_parameter_file,
+ fss_basic_write_parameter_object,
+ fss_basic_write_parameter_partial,
fss_basic_write_parameter_string,
};
f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \
- f_console_parameter_initialize(fss_basic_write_short_object, fss_basic_write_long_object, 0, F_false, f_console_type_normal), \
f_console_parameter_initialize(fss_basic_write_short_file, fss_basic_write_long_file, 0, F_true, f_console_type_normal), \
+ f_console_parameter_initialize(fss_basic_write_short_object, fss_basic_write_long_object, 0, F_false, f_console_type_normal), \
+ f_console_parameter_initialize(fss_basic_write_short_partial, fss_basic_write_long_partial, 0, F_true, f_console_type_normal), \
f_console_parameter_initialize(fss_basic_write_short_string, fss_basic_write_long_string, 0, F_true, f_console_type_normal), \
}
- #define fss_basic_write_total_parameters 8
+ #define fss_basic_write_total_parameters 9
#endif // _di_fss_basic_write_defines_
#ifndef _di_fss_basic_write_data_
input.start = 0;
input.stop = data->buffer.used - 1;
- status = fll_fss_extended_read(&data->buffer, &input, &data->objects, &data->contents);
+ status = fll_fss_extended_read(&data->buffer, &input, &data->objects, &data->contents, 0, 0);
if (F_status_is_error(status)) {
status = F_status_set_fine(status);
printf("%c", f_string_eol[0]);
- fll_program_print_help_option(context, fss_extended_write_short_object, fss_extended_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Write an object instead of content.");
- fll_program_print_help_option(context, fss_extended_write_short_file, fss_extended_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to.");
- fll_program_print_help_option(context, fss_extended_write_short_string, fss_extended_write_long_string, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a string to convert.");
- fll_program_print_help_option(context, fss_extended_write_short_partial, fss_extended_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, " For 'content', do not output the end of content character.");
+ fll_program_print_help_option(context, fss_extended_write_short_file, fss_extended_write_long_file, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a file to send output to.");
+ fll_program_print_help_option(context, fss_extended_write_short_object, fss_extended_write_long_object, f_console_symbol_short_enable, f_console_symbol_long_enable, " Write an object instead of content.");
+ fll_program_print_help_option(context, fss_extended_write_short_partial, fss_extended_write_long_partial, f_console_symbol_short_enable, f_console_symbol_long_enable, "Do not output the final end of object or end of content character.");
+ fll_program_print_help_option(context, fss_extended_write_short_string, fss_extended_write_long_string, f_console_symbol_short_enable, f_console_symbol_long_enable, " Specify a string to convert.");
fll_program_print_help_usage(context, fss_extended_write_name, "");
f_console_parameter_ids choices = { ids, 3 };
status = fll_program_parameter_process(arguments, parameters, choices, F_true, &data->remaining, &data->context);
-
if (F_status_is_error(status)) {
fss_extended_write_delete_data(data);
- return F_status_set_error(status);
+ return status;
}
status = F_none;
}
- if (F_status_is_error(status)) {
- status = F_status_set_fine(status);
-
- if (status == F_data_not) {
- fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ERROR: One of the parameters you passed requires an additional parameter that you did not pass.");
- // TODO: there is a way to identify which parameter is incorrect
- // to do this, one must look for any "has_additional" and then see if the "additional" location is set to 0
- // nothing can be 0 as that represents the program name, unless arguments.argv[] is improperly created
- }
- else if (status == F_memory_allocation || status == F_memory_reallocation) {
- fl_color_print_line(f_type_error, data->context.error, data->context.reset, "CRITICAL ERROR: Unable to allocate memory.");
- }
- else if (status == F_utf) {
- fl_color_print_line(f_type_error, data->context.error, data->context.reset, "ENCODING ERROR: Invalid UTF-8 character in parameter when calling f_console_parameter_process().");
- }
- else if (status == F_parameter) {
- fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: Invalid parameter when calling f_console_parameter_process().");
- }
- else {
- fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_console_parameter_process().", status);
- }
-
- fss_extended_write_delete_data(data);
- return F_status_set_error(status);
- }
-
if (data->parameters[fss_extended_write_parameter_help].result == f_console_result_found) {
fss_extended_write_print_help(data->context);
}
f_array_length counter = 0;
bool object = (data->parameters[fss_extended_write_parameter_object].result == f_console_result_found);
- f_string_dynamic buffer = f_string_dynamic_initialize;
+ f_string_dynamic buffer = f_string_dynamic_initialize;
f_string_range range = f_string_range_initialize;
if (data->process_pipe) {
return F_status_set_error(status);
}
- range.start = 0;
- range.stop = input.used - 1;
+ if (input.used) {
+ range.start = 0;
+ range.stop = input.used - 1;
- if (object) {
- status = fl_fss_extended_object_write(input, &range, &buffer);
+ if (object) {
+ status = fl_fss_extended_object_write(input, 0, &range, &buffer);
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- return F_status_set_error(status);
- }
- }
- else {
- status = fl_fss_extended_content_write(input, &range, &buffer);
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_delete_simple(buffer);
+ f_macro_string_dynamic_delete_simple(input);
+ fss_extended_write_delete_data(data);
+ return F_status_set_error(status);
+ }
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- return F_status_set_error(status);
+ if (data->parameters[fss_extended_write_parameter_partial].result == f_console_result_found) {
+ buffer.used--;
+ }
}
+ else {
+ status = fl_fss_extended_content_write(input, 0, &range, &buffer);
- if (data->parameters[fss_extended_write_parameter_partial].result == f_console_result_none) {
- if (buffer.used >= buffer.size) {
- f_macro_string_dynamic_resize(status, buffer, buffer.used + f_fss_default_allocation_step_string);
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_delete_simple(buffer);
+ f_macro_string_dynamic_delete_simple(input);
+ fss_extended_write_delete_data(data);
+ return F_status_set_error(status);
+ }
- if (F_status_is_error(status)) {
- return status;
- }
+ // remove the last whitespace separator before possibly appending the newline.
+ if (buffer.used) {
+ buffer.used--;
}
- buffer.string[buffer.used] = f_fss_extended_close;
- buffer.used++;
+ if (data->parameters[fss_extended_write_parameter_partial].result == f_console_result_none) {
+ if (buffer.used == buffer.size) {
+ f_macro_string_dynamic_resize(status, buffer, buffer.used + f_fss_default_allocation_step_string);
+
+ if (F_status_is_error(status)) {
+ f_macro_string_dynamic_delete_simple(buffer);
+ f_macro_string_dynamic_delete_simple(input);
+ fss_extended_write_delete_data(data);
+ return status;
+ }
+ }
+
+ buffer.string[buffer.used] = f_fss_extended_close;
+ buffer.used++;
+ }
}
}
f_macro_string_dynamic_delete_simple(input);
}
else if (data->parameters[fss_extended_write_parameter_string].result == f_console_result_additional) {
+ const f_console_parameter *parameter = &data->parameters[fss_extended_write_parameter_string];
f_string_dynamic input = f_string_dynamic_initialize;
if (object) {
- input.string = arguments.argv[data->parameters[fss_extended_write_parameter_string].additional.array[0]];
- input.used = strlen(input.string);
+ input.string = arguments.argv[parameter->additional.array[0]];
+ input.used = strnlen(input.string, f_console_length_size);
- range.start = 0;
- range.stop = input.used - 1;
+ if (input.used) {
+ range.start = 0;
+ range.stop = input.used - 1;
- status = fl_fss_extended_object_write(input, &range, &buffer);
+ status = fl_fss_extended_object_write(input, 0, &range, &buffer);
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_delete_simple(buffer);
+ fss_extended_write_delete_data(data);
+ return F_status_set_error(status);
+ }
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- return F_status_set_error(status);
+ if (data->parameters[fss_extended_write_parameter_partial].result == f_console_result_found) {
+ buffer.used--;
+ }
}
}
else {
- f_string_length i = 0;
+ for (f_string_length i = 0; i < parameter->additional.used; i++) {
+ input.string = arguments.argv[parameter->additional.array[i]];
+ input.used = strnlen(input.string, f_console_length_size);
- while (i < data->parameters[fss_extended_write_parameter_string].additional.used) {
- input.string = arguments.argv[data->parameters[fss_extended_write_parameter_string].additional.array[i]];
- input.used = strlen(input.string);
+ if (input.used) {
+ range.start = 0;
+ range.stop = input.used - 1;
- range.start = 0;
- range.stop = input.used - 1;
+ status = fl_fss_extended_content_write(input, 0, &range, &buffer);
- status = fl_fss_extended_content_write(input, &range, &buffer);
-
- if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
- return F_status_set_error(status);
+ if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) {
+ f_macro_string_dynamic_delete_simple(buffer);
+ fss_extended_write_delete_data(data);
+ return F_status_set_error(status);
+ }
}
+ } // for
- i++;
- } // while
+ // remove the last whitespace separator before possibly appending the newline.
+ if (buffer.used) {
+ buffer.used--;
+ }
if (data->parameters[fss_extended_write_parameter_partial].result == f_console_result_none) {
- if (buffer.used >= buffer.size) {
+ if (buffer.used == buffer.size) {
f_macro_string_dynamic_resize(status, buffer, buffer.used + f_fss_default_allocation_step_string);
if (F_status_is_error(status)) {
+ f_macro_string_dynamic_delete_simple(buffer);
+ fss_extended_write_delete_data(data);
return status;
}
}
fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_open()", status);
}
+ f_macro_string_dynamic_delete_simple(buffer);
fss_extended_write_delete_data(data);
return status;
}
fl_color_print_line(f_type_error, data->context.error, data->context.reset, "INTERNAL ERROR: An unhandled error (%u) has occurred while calling f_file_write()", status);
}
+ f_macro_string_dynamic_delete_simple(buffer);
fss_extended_write_delete_data(data);
return F_status_set_error(status);
}
else {
f_print_string_dynamic(f_type_output, buffer);
}
+
+ f_macro_string_dynamic_delete_simple(buffer);
}
fss_extended_write_delete_data(data);
#ifndef _di_fss_extended_write_delete_data_
f_return_status fss_extended_write_delete_data(fss_extended_write_data *data) {
f_status status = F_none;
- f_string_length i = 0;
- while (i < fss_extended_write_total_parameters) {
+ for (f_string_length i = 0; i < fss_extended_write_total_parameters; i++) {
f_macro_string_lengths_delete_simple(data->parameters[i].locations);
f_macro_string_lengths_delete_simple(data->parameters[i].additional);
- i++;
- } // while
+ } // for
f_macro_string_lengths_delete_simple(data->remaining);
fl_macro_color_context_delete_simple(data->context);
fss_extended_write_parameter_no_color,
fss_extended_write_parameter_version,
- fss_extended_write_parameter_object,
fss_extended_write_parameter_file,
- fss_extended_write_parameter_string,
+ fss_extended_write_parameter_object,
fss_extended_write_parameter_partial,
+ fss_extended_write_parameter_string,
};
#define f_console_parameter_initialize_fss_extended_write \
f_console_parameter_initialize(f_console_standard_short_dark, f_console_standard_long_dark, 0, F_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_no_color, f_console_standard_long_no_color, 0, F_false, f_console_type_inverse), \
f_console_parameter_initialize(f_console_standard_short_version, f_console_standard_long_version, 0, F_false, f_console_type_inverse), \
- f_console_parameter_initialize(fss_extended_write_short_object, fss_extended_write_long_object, 0, F_false, f_console_type_normal), \
f_console_parameter_initialize(fss_extended_write_short_file, fss_extended_write_long_file, 0, F_true, f_console_type_normal), \
- f_console_parameter_initialize(fss_extended_write_short_string, fss_extended_write_long_string, 0, F_true, f_console_type_normal), \
+ f_console_parameter_initialize(fss_extended_write_short_object, fss_extended_write_long_object, 0, F_false, f_console_type_normal), \
f_console_parameter_initialize(fss_extended_write_short_partial, fss_extended_write_long_partial, 0, F_false, f_console_type_normal), \
+ f_console_parameter_initialize(fss_extended_write_short_string, fss_extended_write_long_string, 0, F_true, f_console_type_normal), \
}
#define fss_extended_write_total_parameters 9
f_status status = F_none;
// @todo: resume replacing code below.
- status = fll_fss_extended_read(&buffer, input, &local->rule_objects, &local->rule_contents);
+ status = fll_fss_extended_read(&buffer, input, &local->rule_objects, &local->rule_contents, 0, 0);
if (F_status_is_not_error(status)) {
//status = init_perform_commands(*local, *data); // @fixme
location.start = objects.array[position].start;
location.stop = objects.array[position].stop;
- status = fll_fss_extended_read(&buffer, &location, &objects, &contents);
+ status = fll_fss_extended_read(&buffer, &location, &objects, &contents, 0, 0);
position++;
} // while
// @fixme: resume here, below is just notes and copy&pasted code as examples/reminders.
/*
- status = fll_fss_extended_read(&buffer, &location, &objects, &contents);
+ status = fll_fss_extended_read(&buffer, &location, &objects, &contents, 0, 0);
if (F_status_is_error(status_process)) {
if (status == F_memory_allocation || status == F_memory_reallocation) {
/*
f_status status = F_none;
- status = fll_fss_extended_read(buffer, location, objects, contents);
+ status = fll_fss_extended_read(buffer, location, objects, contents, 0, 0);
if (F_status_is_not_error(status)) {
// @todo: process objects and contents.