From: Kevin Day Date: Fri, 2 Oct 2020 04:40:23 +0000 (-0500) Subject: Progress: FSS development and other changes. X-Git-Tag: 0.5.1~48 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=4c1de5b5208fba7bdadda0ad91b710d295af391e;p=fll Progress: FSS development and other changes. Work on the FSS Basic and FSS Extended write functions, changing the design strategy. The FSS Extended Write program needs additional consideration for how to handle multiple content (which may entail changing the logic of FSS Basic Write accordingly as well). The Basic List and Extended List are currently not worked on but will be. Use "quote" instead of "quoted". After review, this makes more sense to me overall. Fixes of other observed issues, such as missing "_t" in some macros. Update the FSS documentation, focusing on the FSS Basic and possibly FSS Extended. --- diff --git a/build/level_0/settings b/build/level_0/settings index db34825..4725621 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -22,7 +22,7 @@ build_libraries -lc build_libraries-level build_sources_library account.c console.c conversion.c directory.c private-directory.c environment.c private-environment.c file.c private-file.c fss.c iki.c private-iki.c memory.c path.c private-path.c pipe.c print.c private-print.c serialize.c private-serialize.c signal.c socket.c utf.c private-utf.c build_sources_program -build_sources_headers account.h account-common.h color.h console.h console-common.h conversion.h conversion-common.h directory.h directory_type.h directory-common.h environment.h environment-common.h file.h file-common.h fss.h fss-common.h fss_named.h fss_nest.h fss_quoted.h fss_set.h iki.h iki-common.h memory.h memory_structure.h path.h path-common.h pipe.h print.h serialize.h serialize-common.h signal.h signal-common.h socket.h socket-common.h status.h status_array.h string.h string-common.h string_dynamic.h string_map.h string_quantity.h string_range.h type.h type_array.h utf.h utf-common.h +build_sources_headers account.h account-common.h color.h console.h console-common.h conversion.h conversion-common.h directory.h directory_type.h directory-common.h environment.h environment-common.h file.h file-common.h fss.h fss-common.h fss_named.h fss_nest.h fss_quote.h fss_set.h iki.h iki-common.h memory.h memory_structure.h path.h path-common.h pipe.h print.h serialize.h serialize-common.h signal.h signal-common.h socket.h socket-common.h status.h status_array.h string.h string-common.h string_dynamic.h string_map.h string_quantity.h string_range.h type.h type_array.h utf.h utf-common.h build_sources_script build_sources_setting build_script yes diff --git a/build/monolithic/settings b/build/monolithic/settings index 6fd56c1..4e87cda 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -22,7 +22,7 @@ build_libraries -lc build_libraries-monolithic build_sources_library level_0/account.c level_0/console.c level_0/conversion.c level_0/directory.c level_0/private-directory.c level_0/environment.c level_0/private-environment.c level_0/file.c level_0/private-file.c level_0/fss.c level_0/iki.c level_0/private-iki.c level_0/memory.c level_0/path.c level_0/private-path.c level_0/pipe.c level_0/print.c level_0/private-print.c level_0/serialize.c level_0/private-serialize.c level_0/signal.c level_0/socket.c level_0/utf.c level_0/private-utf.c level_1/color.c level_1/console.c level_1/conversion.c level_1/directory.c level_1/private-directory.c level_1/environment.c level_1/private-fss.c level_1/fss_basic.c level_1/fss_basic_list.c level_1/fss_extended.c level_1/fss_extended_list.c level_1/iki.c level_1/print.c level_1/status.c level_1/string.c level_1/private-string.c level_1/utf.c level_1/private-utf.c level_1/utf_file.c level_1/private-utf_file.c level_2/error.c level_2/private-error.c level_2/execute.c level_2/private-execute.c level_2/file.c level_2/private-file.c level_2/fss.c level_2/private-fss.c level_2/fss_basic.c level_2/fss_basic_list.c level_2/fss_extended.c level_2/fss_extended_list.c level_2/fss_status.c level_2/iki.c level_2/private-iki.c level_2/path.c level_2/program.c level_2/status.c build_sources_program -build_sources_headers level_0/account.h level_0/account-common.h level_0/color.h level_0/console.h level_0/console-common.h level_0/conversion.h level_0/conversion-common.h level_0/directory.h level_0/directory_type.h level_0/directory-common.h level_0/environment.h level_0/environment-common.h level_0/file.h level_0/file-common.h level_0/fss.h level_0/fss-common.h level_0/fss_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/path-common.h level_0/pipe.h level_0/print.h level_0/serialize.h level_0/serialize-common.h level_0/signal.h level_0/signal-common.h level_0/socket.h level_0/socket-common.h level_0/status.h level_0/status_array.h level_0/string.h level_0/string-common.h level_0/string_dynamic.h level_0/string_map.h level_0/string_quantity.h level_0/string_range.h level_0/type.h level_0/type_array.h level_0/utf.h level_0/utf-common.h level_1/color.h level_1/console.h level_1/conversion.h level_1/directory.h level_1/environment.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_macro.h level_1/fss_status.h level_1/iki.h level_1/print.h level_1/status.h level_1/string.h level_1/utf.h level_1/utf_file.h level_2/error.h level_2/error-common.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/iki.h level_2/path.h level_2/program.h level_2/status.h +build_sources_headers level_0/account.h level_0/account-common.h level_0/color.h level_0/console.h level_0/console-common.h level_0/conversion.h level_0/conversion-common.h level_0/directory.h level_0/directory_type.h level_0/directory-common.h level_0/environment.h level_0/environment-common.h level_0/file.h level_0/file-common.h level_0/fss.h level_0/fss-common.h level_0/fss_named.h level_0/fss_nest.h level_0/fss_quote.h level_0/fss_set.h level_0/iki.h level_0/iki-common.h level_0/memory.h level_0/memory_structure.h level_0/path.h level_0/path-common.h level_0/pipe.h level_0/print.h level_0/serialize.h level_0/serialize-common.h level_0/signal.h level_0/signal-common.h level_0/socket.h level_0/socket-common.h level_0/status.h level_0/status_array.h level_0/string.h level_0/string-common.h level_0/string_dynamic.h level_0/string_map.h level_0/string_quantity.h level_0/string_range.h level_0/type.h level_0/type_array.h level_0/utf.h level_0/utf-common.h level_1/color.h level_1/console.h level_1/conversion.h level_1/directory.h level_1/environment.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_macro.h level_1/fss_status.h level_1/iki.h level_1/print.h level_1/status.h level_1/string.h level_1/utf.h level_1/utf_file.h level_2/error.h level_2/error-common.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/iki.h level_2/path.h level_2/program.h level_2/status.h build_sources_script build_sources_setting build_script yes diff --git a/level_0/f_directory/c/directory.c b/level_0/f_directory/c/directory.c index feed6fe..e863228 100644 --- a/level_0/f_directory/c/directory.c +++ b/level_0/f_directory/c/directory.c @@ -151,7 +151,7 @@ extern "C" { } 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); + f_macro_memory_structure_macro_increment(status, (*names), 1, f_directory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); if (F_status_is_error(status)) break; } diff --git a/level_0/f_fss/c/fss-common.h b/level_0/f_fss/c/fss-common.h index 4d183ce..49a40a5 100644 --- a/level_0/f_fss/c/fss-common.h +++ b/level_0/f_fss/c/fss-common.h @@ -20,25 +20,28 @@ extern "C" { * FSS-specific types. */ #ifndef _di_f_fss_types_t_ - #define f_fss_comment '#' - #define f_fss_space ' ' - #define f_fss_space_holder '_' - #define f_fss_basic_open ' ' - #define f_fss_basic_close '\n' - #define f_fss_extended_open ' ' - #define f_fss_extended_close '\n' - #define f_fss_list_terminator '\n' - #define f_fss_basic_list_open ':' - #define f_fss_basic_list_close '\0' - #define f_fss_extended_list_open '{' - #define f_fss_extended_list_close '}' // also requires '\n'. - #define f_fss_type_header_open '#' - #define f_fss_type_header_part1 ' ' - #define f_fss_type_header_part2 'f' - #define f_fss_type_header_part3 's' - #define f_fss_type_header_part4 's' - #define f_fss_type_header_part5 '-' - #define f_fss_type_header_close '\n' + #define f_fss_comment '#' + #define f_fss_eol f_string_eol[0] + #define f_fss_space ' ' + #define f_fss_space_holder '_' + #define f_fss_basic_open ' ' + #define f_fss_basic_close f_string_eol[0] + #define f_fss_extended_open ' ' + #define f_fss_extended_next ' ' + #define f_fss_extended_close f_string_eol[0] + #define f_fss_list_terminator f_string_eol[0] + #define f_fss_basic_list_open ':' + #define f_fss_basic_list_close f_string_eol[0] + #define f_fss_extended_list_open '{' + #define f_fss_extended_list_close '}' + #define f_fss_extended_list_close_end f_string_eol[0] + #define f_fss_type_header_open '#' + #define f_fss_type_header_part1 ' ' + #define f_fss_type_header_part2 'f' + #define f_fss_type_header_part3 's' + #define f_fss_type_header_part4 's' + #define f_fss_type_header_part5 '-' + #define f_fss_type_header_close f_string_eol[0] typedef unsigned long f_fss_id_t; #endif // _di_f_fss_types_t_ @@ -75,6 +78,27 @@ extern "C" { #endif // _di_f_fss_codes_ /** + * Codes for FSS completeness. + * + * Only "next" and "end" are only meaningful for a Content and will be treated as "none" for an Object. + * + * none: disable completeness. + * partial: complete, but do not add terminating EOL, where applicable. + * full: complete and add terminating EOL, where applicable. + * next: complete as if this is a piece of a set (such as FSS-0001 where there are multiple space separated content). + * end: complete as if this is the final piece of a set, therefore adding an EOL. + */ +#ifndef _di_f_fss_complete_ + enum { + f_fss_complete_none = 1, + f_fss_complete_partial, + f_fss_complete_full, + f_fss_complete_next, + f_fss_complete_end, + }; +#endif // _di_f_fss_complete_ + +/** * Max size of a FSS header. * * The standard FSS character header is: "# fss-0000\n\0", which is 10 characters + newline + EOS = 12. @@ -92,10 +116,8 @@ extern "C" { * Default allocation steps. */ #ifndef _di_f_fss_default_allocation_step_ + // recommended to be set to at least 4 to be UTF-8 friendlier. #define f_fss_default_allocation_step f_memory_default_allocation_step - - // set to 4 to be UTF-8 friendlier. - #define f_fss_default_allocation_step_string 4 #endif // _di_f_fss_default_allocation_step_ /** diff --git a/level_0/f_fss/c/fss.h b/level_0/f_fss/c/fss.h index b8103bb..2a3e45e 100644 --- a/level_0/f_fss/c/fss.h +++ b/level_0/f_fss/c/fss.h @@ -25,7 +25,7 @@ // fll-0 fss includes #include -#include +#include #include #include #include diff --git a/level_0/f_fss/c/fss_named.h b/level_0/f_fss/c/fss_named.h index 70f0453..e3a8d1d 100644 --- a/level_0/f_fss/c/fss_named.h +++ b/level_0/f_fss/c/fss_named.h @@ -17,15 +17,15 @@ extern "C" { #endif /** - * This holds a named set of fss objects, contents, and quotedss. + * This holds a named set of fss objects, contents, and quotess. * - * The objects, contents, and quotedss should each be of the same used and size. + * The objects, contents, and quotess should each be of the same used and size. * Any deviation to this would require implementing custom equivelents to the standard management macros. * * object: The name representing this set. * objects: The array of objects. * contents: The array of contents. - * quotedss: The array of quoted for each content. + * quotess: The array of quote for each content. */ #ifndef _di_f_fss_named_t_ typedef struct { @@ -33,16 +33,16 @@ extern "C" { f_fss_objects_t objects; f_fss_contents_t contents; - f_fss_quotedss_t quotedss; + f_fss_quotess_t quotess; } f_fss_named_t; - #define f_fss_named_t_initialize { f_fss_object_t_initialize, f_fss_objects_t_initialize, f_fss_contents_t_initialize, f_fss_quotedss_t_initialize } + #define f_fss_named_t_initialize { f_fss_object_t_initialize, f_fss_objects_t_initialize, f_fss_contents_t_initialize, f_fss_quotess_t_initialize } #define f_macro_fss_named_t_clear(set) \ f_macro_fss_object_t_clear(set.object) \ f_macro_fss_objects_t_clear(set.objects) \ f_macro_fss_contents_t_clear(set.contents) \ - f_macro_fss_quotedss_t_clear(set.quotedss) + f_macro_fss_quotess_t_clear(set.quotess) #define f_macro_fss_named_t_new(status, set, length) \ f_macro_fss_objects_t_new(status, set.objects, length) \ @@ -50,7 +50,7 @@ extern "C" { f_macro_fss_contents_t_new(status, set.contents, length) \ } \ if (F_status_is_fine(status)) { \ - f_macro_fss_quotedss_t_new(status, set.quotedss, length) \ + f_macro_fss_quotess_t_new(status, set.quotess, length) \ } #define f_macro_fss_named_t_delete(status, set) \ @@ -59,7 +59,7 @@ extern "C" { f_macro_fss_contents_t_delete(status, set.contents) \ } \ if (F_status_is_fine(status)) { \ - f_macro_fss_quotedss_t_delete(status, set.quotedss) \ + f_macro_fss_quotess_t_delete(status, set.quotess) \ } #define f_macro_fss_named_t_destroy(status, set) \ @@ -68,18 +68,18 @@ extern "C" { f_macro_fss_contents_t_destroy(status, set.contents) \ } \ if (F_status_is_fine(status)) { \ - f_macro_fss_quotedss_t_destroy(status, set.quotedss) \ + f_macro_fss_quotess_t_destroy(status, set.quotess) \ } #define f_macro_fss_named_t_delete_simple(set) \ f_macro_fss_objects_t_delete_simple(set.objects) \ f_macro_fss_contents_t_delete_simple(set.contents) \ - f_macro_fss_quotedss_t_delete_simple(set.quotedss) + f_macro_fss_quotess_t_delete_simple(set.quotess) #define f_macro_fss_named_t_destroy_simple(set) \ f_macro_fss_objects_t_destroy_simple(set.objects) \ f_macro_fss_contents_t_destroy_simple(set.contents) \ - f_macro_fss_quotedss_t_destroy_simple(set.quotedss) + f_macro_fss_quotess_t_destroy_simple(set.quotess) #define f_macro_fss_named_t_resize(status, set, new_length) \ f_macro_fss_objects_t_resize(status, set.objects, new_length) \ @@ -87,7 +87,7 @@ extern "C" { f_macro_fss_contents_t_resize(status, set.contents, new_length) \ } \ if (F_status_is_fine(status)) { \ - f_macro_fss_quotedss_t_resize(status, set.quotedss, new_length) \ + f_macro_fss_quotess_t_resize(status, set.quotess, new_length) \ } #define f_macro_fss_named_t_adjust(status, set, new_length) \ @@ -96,7 +96,7 @@ extern "C" { f_macro_fss_contents_t_adjust(status, set.contents, new_length) \ } \ if (F_status_is_fine(status)) { \ - f_macro_fss_quotedss_t_adjust(status, set.quotedss, new_length) \ + f_macro_fss_quotess_t_adjust(status, set.quotess, new_length) \ } #endif // _di_f_fss_named_t_ diff --git a/level_0/f_fss/c/fss_quote.h b/level_0/f_fss/c/fss_quote.h new file mode 100644 index 0000000..bc50497 --- /dev/null +++ b/level_0/f_fss/c/fss_quote.h @@ -0,0 +1,92 @@ +/** + * 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_quote_h +#define _F_fss_quote_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Types for FSS quote. + */ +#ifndef _di_f_fss_quote_type_ + enum { + f_fss_quote_type_single = 1, + f_fss_quote_type_double, + }; +#endif // _di_f_fss_quote_type_ + +/** + * Designate an fss quote. + */ +#ifndef _di_f_fss_quote_t_ + typedef uint8_t f_fss_quote_t; +#endif // _di_f_fss_quote_t_ + +/** + * An array of f_fss_quote_t. + * + * array: the array of fss quote. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_fss_quotes_t_ + typedef f_uint8s_t f_fss_quotes_t; + + #define f_fss_quotes_t_initialize f_uint8s_t_initialize + + #define f_macro_fss_quotes_t_clear(quotes) f_macro_uint8s_t_clear(quotes) + + #define f_macro_fss_quotes_t_new(status, quotes, length) f_macro_uint8s_t_new(status, quotes, length) + + #define f_macro_fss_quotes_t_delete(status, quotes) f_macro_uint8s_t_delete(status, quotes) + #define f_macro_fss_quotes_t_destroy(status, quotes) f_macro_uint8s_t_destroy(status, quotes) + + #define f_macro_fss_quotes_t_delete_simple(quotes) f_macro_uint8s_t_delete_simple(quotes) + #define f_macro_fss_quotes_t_destroy_simple(quotes) f_macro_uint8s_t_destroy_simple(quotes) + + #define f_macro_fss_quotes_t_resize(status, quotes, new_length) f_macro_uint8s_t_resize(status, quotes, new_length) + #define f_macro_fss_quotes_t_adjust(status, quotes, new_length) f_macro_uint8s_t_adjust(status, quotes, new_length) +#endif // _di_f_fss_quotes_t_ + +/** + * An array of f_fss_quotes_t. + * + * array: the array of fss quotes. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_fss_quotess_t_ + typedef f_uint8ss_t f_fss_quotess_t; + + #define f_fss_quotess_t_initialize f_uint8ss_t_initialize + + #define f_macro_fss_quotess_t_clear(quotess) f_macro_uint8ss_t_clear(quotess) + + #define f_macro_fss_quotess_t_new(status, quotess, length) f_macro_uint8ss_t_new(status, quotess, length) + + #define f_macro_fss_quotess_t_delete(status, quotess) f_macro_uint8ss_t_delete(status, quotess) + #define f_macro_fss_quotess_t_destroy(status, quotess) f_macro_uint8ss_t_destroy(status, quotess) + + #define f_macro_fss_quotess_t_delete_simple(quotess) f_macro_uint8ss_t_delete_simple(quotess) + #define f_macro_fss_quotess_t_destroy_simple(quotess) f_macro_uint8ss_t_destroy_simple(quotess) + + #define f_macro_fss_quotess_t_resize(status, quotess, new_length) f_macro_uint8ss_t_resize(status, quotess, new_length) + #define f_macro_fss_quotess_t_adjust(status, quotess, new_length) f_macro_uint8ss_t_adjust(status, quotess, new_length) +#endif // _di_f_fss_quotess_t_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_fss_quote_h diff --git a/level_0/f_fss/c/fss_quoted.h b/level_0/f_fss/c/fss_quoted.h deleted file mode 100644 index 648d7f7..0000000 --- a/level_0/f_fss/c/fss_quoted.h +++ /dev/null @@ -1,92 +0,0 @@ -/** - * 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_t_ - typedef uint8_t f_fss_quoted_t; -#endif // _di_f_fss_quoted_t_ - -/** - * An array of f_fss_quoted_t. - * - * array: the array of fss quoted. - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_fss_quoteds_t_ - typedef f_uint8s_t f_fss_quoteds_t; - - #define f_fss_quoteds_t_initialize f_uint8s_t_initialize - - #define f_macro_fss_quoteds_t_clear(quoteds) f_macro_uint8s_t_clear(quoteds) - - #define f_macro_fss_quoteds_t_new(status, quoteds, length) f_macro_uint8s_t_new(status, quoteds, length) - - #define f_macro_fss_quoteds_t_delete(status, quoteds) f_macro_uint8s_t_delete(status, quoteds) - #define f_macro_fss_quoteds_t_destroy(status, quoteds) f_macro_uint8s_t_destroy(status, quoteds) - - #define f_macro_fss_quoteds_t_delete_simple(quoteds) f_macro_uint8s_t_delete_simple(quoteds) - #define f_macro_fss_quoteds_t_destroy_simple(quoteds) f_macro_uint8s_t_destroy_simple(quoteds) - - #define f_macro_fss_quoteds_t_resize(status, quoteds, new_length) f_macro_uint8s_t_resize(status, quoteds, new_length) - #define f_macro_fss_quoteds_t_adjust(status, quoteds, new_length) f_macro_uint8s_t_adjust(status, quoteds, new_length) -#endif // _di_f_fss_quoteds_t_ - -/** - * An array of f_fss_quoteds_t. - * - * array: the array of fss quoteds. - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_fss_quotedss_t_ - typedef f_uint8ss_t f_fss_quotedss_t; - - #define f_fss_quotedss_t_initialize f_uint8ss_t_initialize - - #define f_macro_fss_quotedss_t_clear(quotedss) f_macro_uint8ss_t_clear(quotedss) - - #define f_macro_fss_quotedss_t_new(status, quotedss, length) f_macro_uint8ss_t_new(status, quotedss, length) - - #define f_macro_fss_quotedss_t_delete(status, quotedss) f_macro_uint8ss_t_delete(status, quotedss) - #define f_macro_fss_quotedss_t_destroy(status, quotedss) f_macro_uint8ss_t_destroy(status, quotedss) - - #define f_macro_fss_quotedss_t_delete_simple(quotedss) f_macro_uint8ss_t_delete_simple(quotedss) - #define f_macro_fss_quotedss_t_destroy_simple(quotedss) f_macro_uint8ss_t_destroy_simple(quotedss) - - #define f_macro_fss_quotedss_t_resize(status, quotedss, new_length) f_macro_uint8ss_t_resize(status, quotedss, new_length) - #define f_macro_fss_quotedss_t_adjust(status, quotedss, new_length) f_macro_uint8ss_t_adjust(status, quotedss, new_length) -#endif // _di_f_fss_quotedss_t_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _F_fss_quoted_h diff --git a/level_0/f_fss/c/fss_set.h b/level_0/f_fss/c/fss_set.h index fa421a5..de4eb24 100644 --- a/level_0/f_fss/c/fss_set.h +++ b/level_0/f_fss/c/fss_set.h @@ -246,131 +246,131 @@ extern "C" { #endif // _di_f_fss_sets_t_ /** - * This holds an fss object with a set of fss content, along with their quoted types. + * This holds an fss object with a set of fss content, along with their quote types. * - * The objects, contents, and quoteds should each be of the same used and size. + * The objects, contents, and quotes should each be of the same used and size. * Any deviation to this would require implementing custom equivelents to the standard management macros. * * objects: the array of objects. * contents: the array of contents. - * objects_quoted: the array of objects quoted types. - * contents_quoted: the array of contents quoted types. + * objects_quote: the array of objects quote types. + * contents_quote: the array of contents quote types. */ -#ifndef _di_f_fss_set_quoted_t_ +#ifndef _di_f_fss_set_quote_t_ typedef struct { f_fss_objects_t objects; f_fss_contents_t contents; - f_fss_quoteds_t objects_quoted; - f_fss_quotedss_t contents_quoted; - } f_fss_set_quoted_t; + f_fss_quotes_t objects_quote; + f_fss_quotess_t contents_quote; + } f_fss_set_quote_t; - #define f_fss_set_quoted_t_initialize { f_fss_objects_t_initialize, f_fss_contents_t_initialize, f_fss_quoteds_t_initialize, f_fss_quotedss_t_initialize } + #define f_fss_set_quote_t_initialize { f_fss_objects_t_initialize, f_fss_contents_t_initialize, f_fss_quotes_t_initialize, f_fss_quotess_t_initialize } - #define f_macro_fss_set_quoted_t_clear(set) \ + #define f_macro_fss_set_quote_t_clear(set) \ f_macro_fss_objects_t_clear(set.objects) \ f_macro_fss_contents_t_clear(set.contents) \ - f_macro_fss_quoteds_t_clear(set.objects_quoted) \ - f_macro_fss_quotedss_t_clear(set.contents_quoted) + f_macro_fss_quotes_t_clear(set.objects_quote) \ + f_macro_fss_quotess_t_clear(set.contents_quote) - #define f_macro_fss_set_quoted_t_new(status, set, length) \ + #define f_macro_fss_set_quote_t_new(status, set, length) \ f_macro_fss_objects_t_new(status, set.objects, length) \ if (F_status_is_fine(status)) { \ f_macro_fss_contents_t_new(status, set.contents, length) \ } \ if (F_status_is_fine(status)) { \ - f_macro_fss_quoteds_t_new(status, set.objects_quoted, length) \ + f_macro_fss_quotes_t_new(status, set.objects_quote, length) \ } \ if (F_status_is_fine(status)) { \ - f_macro_fss_quotedss_t_new(status, set.contents_quoted, length) \ + f_macro_fss_quotess_t_new(status, set.contents_quote, length) \ } - #define f_macro_fss_set_quoted_t_delete(status, set) \ + #define f_macro_fss_set_quote_t_delete(status, set) \ f_macro_fss_objects_t_delete(status, set.objects) \ if (F_status_is_fine(status)) { \ f_macro_fss_contents_t_delete(status, set.contents) \ } \ if (F_status_is_fine(status)) { \ - f_macro_fss_quoteds_t_delete(status, set.objects_quoted) \ + f_macro_fss_quotes_t_delete(status, set.objects_quote) \ } \ if (F_status_is_fine(status)) { \ - f_macro_fss_quotedss_t_delete(status, set.contents_quoted) \ + f_macro_fss_quotess_t_delete(status, set.contents_quote) \ } - #define f_macro_fss_set_quoted_t_destroy(status, set) \ + #define f_macro_fss_set_quote_t_destroy(status, set) \ f_macro_fss_objects_t_destroy(status, set.objects) \ if (F_status_is_fine(status)) { \ f_macro_fss_contents_t_destroy(status, set.contents) \ } \ if (F_status_is_fine(status)) { \ - f_macro_fss_quoteds_t_destroy(status, set.objects_quoted) \ + f_macro_fss_quotes_t_destroy(status, set.objects_quote) \ } \ if (F_status_is_fine(status)) { \ - f_macro_fss_quotedss_t_destroy(status, set.contents_quoted) \ + f_macro_fss_quotess_t_destroy(status, set.contents_quote) \ } - #define f_macro_fss_set_quoted_t_delete_simple(set) \ + #define f_macro_fss_set_quote_t_delete_simple(set) \ f_macro_fss_objects_t_delete_simple(set.objects) \ f_macro_fss_contents_t_delete_simple(set.contents) \ - f_macro_fss_quoteds_t_delete_simple(set.objects_quoted) \ - f_macro_fss_quotedss_t_delete_simple(set.contents_quoted) + f_macro_fss_quotes_t_delete_simple(set.objects_quote) \ + f_macro_fss_quotess_t_delete_simple(set.contents_quote) - #define f_macro_fss_set_quoted_t_destroy_simple(set) \ + #define f_macro_fss_set_quote_t_destroy_simple(set) \ f_macro_fss_objects_t_destroy_simple(set.objects) \ f_macro_fss_contents_t_destroy_simple(set.contents) \ - f_macro_fss_quoteds_t_destroy_simple(set.objects_quoted) \ - f_macro_fss_quotedss_t_destroy_simple(set.contents_quoted) + f_macro_fss_quotes_t_destroy_simple(set.objects_quote) \ + f_macro_fss_quotess_t_destroy_simple(set.contents_quote) - #define f_macro_fss_set_quoted_t_resize(status, set, new_length) \ + #define f_macro_fss_set_quote_t_resize(status, set, new_length) \ f_macro_fss_objects_t_resize(status, set.objects, new_length) \ if (F_status_is_fine(status)) { \ f_macro_fss_contents_t_resize(status, set.contents, new_length) \ } \ if (F_status_is_fine(status)) { \ - f_macro_fss_quoteds_t_resize(status, set.objects_quoted, new_length) \ + f_macro_fss_quotes_t_resize(status, set.objects_quote, new_length) \ } \ if (F_status_is_fine(status)) { \ - f_macro_fss_quotedss_t_resize(status, set.contents_quoted, new_length) \ + f_macro_fss_quotess_t_resize(status, set.contents_quote, new_length) \ } - #define f_macro_fss_set_quoted_t_adjust(status, set, new_length) \ + #define f_macro_fss_set_quote_t_adjust(status, set, new_length) \ f_macro_fss_objects_t_adjust(status, set.objects, new_length) \ if (F_status_is_fine(status)) { \ f_macro_fss_contents_t_adjust(status, set.contents, new_length) \ } \ if (F_status_is_fine(status)) { \ - f_macro_fss_quoteds_t_adjust(status, set.objects_quoted, new_length) \ + f_macro_fss_quotes_t_adjust(status, set.objects_quote, new_length) \ } \ if (F_status_is_fine(status)) { \ - f_macro_fss_quotedss_t_adjust(status, set.contents_quoted, new_length) \ + f_macro_fss_quotess_t_adjust(status, set.contents_quote, new_length) \ } -#endif // _di_f_fss_set_quoted_t_ +#endif // _di_f_fss_set_quote_t_ /** - * This holds an array of f_fss_set_quoted_t. + * This holds an array of f_fss_set_quote_t. * - * array: an array of f_fss_set_quoted_t. + * array: an array of f_fss_set_quote_t. * size: total amount of allocated space. * used: total number of allocated spaces used. */ -#ifndef _di_fss_set_quoteds_t_ +#ifndef _di_fss_set_quotes_t_ typedef struct { f_fss_set_t *array; f_array_length_t size; f_array_length_t used; - } f_fss_set_quoteds_t; + } f_fss_set_quotes_t; - #define f_fss_set_quoteds_t_initialize { 0, 0, 0 } + #define f_fss_set_quotes_t_initialize { 0, 0, 0 } /** * Reset a fss content sets to 0 (clear all values). * * This does not deallocate memory, be certain that memory is not allocated before calling this to avoid potential memory leaks. * - * sets: the f_fss_set_quoteds_t structure to operate on. + * sets: the f_fss_set_quotes_t structure to operate on. */ - #define f_macro_fss_set_quoteds_t_clear(sets) \ + #define f_macro_fss_set_quotes_t_clear(sets) \ sets.array = 0; \ sets.size = 0; \ sets.used = 0; @@ -381,14 +381,14 @@ extern "C" { * This does not deallocate memory, be certain that memory is not allocated before calling this to avoid potential memory leaks. * * status: the status to return. - * sets: the f_fss_set_quoteds_t structure to operate on. + * sets: the f_fss_set_quotes_t structure to operate on. * new_length: the new size of the array. */ - #define f_macro_fss_set_quoteds_t_new(status, sets, length) \ + #define f_macro_fss_set_quotes_t_new(status, sets, length) \ sets.array = 0; \ sets.size = 0; \ sets.used = 0; \ - status = f_memory_new((void **) & sets.array, sizeof(f_fss_set_quoted_t), length); \ + status = f_memory_new((void **) & sets.array, sizeof(f_fss_set_quote_t), length); \ if (status == F_none) { \ sets.size = length; \ sets.used = 0; \ @@ -398,48 +398,48 @@ extern "C" { * Delete a fss content sets. * * status: the status to return. - * sets: the f_fss_set_quoteds_t structure to operate on. + * sets: the f_fss_set_quotes_t structure to operate on. */ - #define f_macro_fss_set_quoteds_t_delete(status, sets) \ + #define f_macro_fss_set_quotes_t_delete(status, sets) \ status = F_none; \ sets.used = sets.size; \ while (sets.used > 0) { \ sets.used--; \ - f_macro_fss_set_quoted_t_delete(status, sets.array[sets.used]); \ + f_macro_fss_set_quote_t_delete(status, sets.array[sets.used]); \ if (status != F_none) break; \ } \ - if (status == F_none) status = f_memory_delete((void **) & sets.array, sizeof(f_fss_set_quoted_t), sets.size); \ + if (status == F_none) status = f_memory_delete((void **) & sets.array, sizeof(f_fss_set_quote_t), sets.size); \ if (status == F_none) sets.size = 0; /** * Destroy a fss content sets. * * status: the status to return. - * sets: the f_fss_set_quoteds_t structure to operate on. + * sets: the f_fss_set_quotes_t structure to operate on. */ - #define f_macro_fss_set_quoteds_t_destroy(status, sets) \ + #define f_macro_fss_set_quotes_t_destroy(status, sets) \ status = F_none; \ sets.used = sets.size; \ while (sets.used > 0) { \ sets.used--; \ - f_macro_fss_set_quoted_t_destroy(status, sets.array[sets.used]); \ + f_macro_fss_set_quote_t_destroy(status, sets.array[sets.used]); \ if (status != F_none) break; \ } \ - if (status == F_none) status = f_memory_destroy((void **) & sets.array, sizeof(f_fss_set_quoted_t), sets.size); \ + if (status == F_none) status = f_memory_destroy((void **) & sets.array, sizeof(f_fss_set_quote_t), sets.size); \ if (status == F_none) sets.size = 0; /** * Delete a fss content sets. * - * sets: the f_fss_set_quoteds_t structure to operate on. + * sets: the f_fss_set_quotes_t structure to operate on. */ - #define f_macro_fss_set_quoteds_t_delete_simple(sets) \ + #define f_macro_fss_set_quotes_t_delete_simple(sets) \ sets.used = sets.size; \ while (sets.used > 0) { \ sets.used--; \ - f_macro_fss_set_quoted_t_delete_simple(sets.array[sets.used]); \ + f_macro_fss_set_quote_t_delete_simple(sets.array[sets.used]); \ if (!sets.used) { \ - if (f_memory_delete((void **) & sets.array, sizeof(f_fss_set_quoted_t), sets.size)) { \ + if (f_memory_delete((void **) & sets.array, sizeof(f_fss_set_quote_t), sets.size)) { \ sets.size = 0; \ } \ } \ @@ -448,15 +448,15 @@ extern "C" { /** * Destroy a fss content sets. * - * sets: the f_fss_set_quoteds_t structure to operate on. + * sets: the f_fss_set_quotes_t structure to operate on. */ - #define f_macro_fss_set_quoteds_t_destroy_simple(sets) \ + #define f_macro_fss_set_quotes_t_destroy_simple(sets) \ sets.used = sets.size; \ while (sets.used > 0) { \ sets.used--; \ - f_macro_fss_set_quoted_t_destroy_simple(sets.array[sets.used]); \ + f_macro_fss_set_quote_t_destroy_simple(sets.array[sets.used]); \ if (!sets.used) { \ - if (f_memory_destroy((void **) & sets.array, sizeof(f_fss_set_quoted_t), sets.size)) { \ + if (f_memory_destroy((void **) & sets.array, sizeof(f_fss_set_quote_t), sets.size)) { \ sets.size = 0; \ } \ } \ @@ -466,22 +466,22 @@ extern "C" { * Resize a fss content sets. * * status: the status to return. - * sets: the f_fss_set_quoteds_t structure to operate on. + * sets: the f_fss_set_quotes_t structure to operate on. * new_length: the new size of the array. */ - #define f_macro_fss_set_quoteds_t_resize(status, sets, new_length) \ + #define f_macro_fss_set_quotes_t_resize(status, sets, new_length) \ status = F_none; \ if (new_length < sets.size) { \ for (f_array_length_t _macro__i = sets.size - new_length; _macro__i < sets.size; _macro__i++) { \ - f_macro_fss_set_quoted_t_delete(status, sets.array[_macro__i]); \ + f_macro_fss_set_quote_t_delete(status, sets.array[_macro__i]); \ if (status != F_none) break; \ } \ } \ - if (status == F_none) status = f_memory_resize((void **) & sets.array, sizeof(f_fss_set_quoted_t), sets.size, new_length); \ + if (status == F_none) status = f_memory_resize((void **) & sets.array, sizeof(f_fss_set_quote_t), sets.size, new_length); \ if (status == F_none) { \ if (new_length > sets.size) { \ for (f_array_length_t _macro__i = sets.size; _macro__i < new_length; _macro__i++) { \ - memset(&sets.array[_macro__i], 0, sizeof(f_fss_set_quoted_t)); \ + memset(&sets.array[_macro__i], 0, sizeof(f_fss_set_quote_t)); \ } \ } \ sets.size = new_length; \ @@ -492,28 +492,28 @@ extern "C" { * Adjust a fss content sets. * * status: the status to return. - * sets: the f_fss_set_quoteds_t structure to operate on. + * sets: the f_fss_set_quotes_t structure to operate on. * new_length: he new size of the array. */ - #define f_macro_fss_set_quoteds_t_adjust(status, sets, new_length) \ + #define f_macro_fss_set_quotes_t_adjust(status, sets, new_length) \ status = F_none; \ if (new_length < sets.size) { \ for (f_array_length_t _macro__i = sets.size - new_length; _macro__i < sets.size; _macro__i++) { \ - f_macro_fss_set_quoted_t_destroy(status, sets.array[_macro__i]); \ + f_macro_fss_set_quote_t_destroy(status, sets.array[_macro__i]); \ if (status != F_none) break; \ } \ } \ - if (status == F_none) status = f_memory_adjust((void **) & sets.array, sizeof(f_fss_set_quoted_t), sets.size, new_length); \ + if (status == F_none) status = f_memory_adjust((void **) & sets.array, sizeof(f_fss_set_quote_t), sets.size, new_length); \ if (status == F_none) { \ if (new_length > sets.size) { \ for (f_array_length_t _macro__i = sets.size; _macro__i < new_length; _macro__i++) { \ - memset(&sets.array[_macro__i], 0, sizeof(f_fss_set_quoted_t)); \ + memset(&sets.array[_macro__i], 0, sizeof(f_fss_set_quote_t)); \ } \ } \ sets.size = new_length; \ if (sets.used > sets.size) sets.used = new_length; \ } -#endif // _di_fss_set_quoteds_t_ +#endif // _di_fss_set_quotes_t_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_fss/data/build/settings b/level_0/f_fss/data/build/settings index cad42d3..c93199e 100644 --- a/level_0/f_fss/data/build/settings +++ b/level_0/f_fss/data/build/settings @@ -22,7 +22,7 @@ build_libraries -lc 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_quoted.h fss_set.h +build_sources_headers fss.h fss-common.h fss_named.h fss_nest.h fss_quote.h fss_set.h build_sources_script build_sources_setting build_script yes diff --git a/level_0/f_serialize/c/serialize.c b/level_0/f_serialize/c/serialize.c index 325b72a..c3aa331 100644 --- a/level_0/f_serialize/c/serialize.c +++ b/level_0/f_serialize/c/serialize.c @@ -50,7 +50,7 @@ extern "C" { width = f_macro_utf_byte_width(serialize.string[i]); if (serialize.string[i] == f_serialize_simple_splitter || i + 1 >= serialize.used) { - f_macro_memory_structure_macro_increment(status, (*strings), 1, f_serialize_default_allocation_step, f_macro_string_dynamics_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*strings), 1, f_serialize_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); if (F_status_is_error(status)) return status; if (start == i) { diff --git a/level_0/f_string/c/string_dynamic.h b/level_0/f_string/c/string_dynamic.h index a84ad58..ae65574 100644 --- a/level_0/f_string/c/string_dynamic.h +++ b/level_0/f_string/c/string_dynamic.h @@ -202,7 +202,7 @@ extern "C" { } \ } - #define f_macro_string_dynamics_resize(status, dynamics, new_length) \ + #define f_macro_string_dynamics_t_resize(status, dynamics, new_length) \ status = F_none; \ if (new_length < dynamics.size) { \ for (f_array_length_t _macro__i = dynamics.size - new_length; _macro__i < dynamics.size; _macro__i++) { \ @@ -221,7 +221,7 @@ extern "C" { if (dynamics.used > dynamics.size) dynamics.used = new_length; \ } - #define f_macro_string_dynamics_adjust(status, dynamics, new_length) \ + #define f_macro_string_dynamics_t_adjust(status, dynamics, new_length) \ status = F_none; \ if (new_length < dynamics.size) { \ for (f_array_length_t _macro__i = dynamics.size - new_length; _macro__i < dynamics.size; _macro__i++) { \ diff --git a/level_1/fl_directory/c/private-directory.c b/level_1/fl_directory/c/private-directory.c index 4245059..7a76d4b 100644 --- a/level_1/fl_directory/c/private-directory.c +++ b/level_1/fl_directory/c/private-directory.c @@ -521,7 +521,7 @@ extern "C" { } if (names->used == names->size) { - f_macro_string_dynamics_resize(status, (*names), names->size + f_directory_default_allocation_step); + f_macro_string_dynamics_t_resize(status, (*names), names->size + f_directory_default_allocation_step); if (F_status_is_error(status)) break; } @@ -538,7 +538,7 @@ extern "C" { if (total > names->array[names->used].size) { f_status_t status = F_none; - f_macro_string_dynamics_resize(status, (*names), total); + f_macro_string_dynamics_t_resize(status, (*names), total); if (F_status_is_error(status)) break; } diff --git a/level_1/fl_environment/c/environment.c b/level_1/fl_environment/c/environment.c index 2053138..25404f1 100644 --- a/level_1/fl_environment/c/environment.c +++ b/level_1/fl_environment/c/environment.c @@ -18,7 +18,7 @@ extern "C" { // When PATH is "", this is actually a valid search path for PWD. // Append an equivalent representation of PWD (string used length is 0). - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); if (F_status_is_error(status)) return status; f_macro_string_dynamic_t_clear(paths->array[paths->used]); @@ -34,7 +34,7 @@ extern "C" { for (i = 0; i <= length; i++) { if (i == length || path[i] == f_path_separator_variable[0]) { - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); if (F_status_is_error(status)) return status; if (!i) { @@ -94,7 +94,7 @@ extern "C" { // When PATH is "", this is actually a valid search path for PWD. // Therefore append an equivalent representation of PWD (string used length is 0). - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); if (F_status_is_error(status)) return status; f_macro_string_dynamic_t_clear(paths->array[paths->used]); @@ -113,7 +113,7 @@ extern "C" { for (i = 0; i <= path.used; i++) { if (i == path.used || path.string[i] == f_path_separator_variable[0]) { - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); if (F_status_is_error(status)) return status; if (!i) { @@ -173,7 +173,7 @@ extern "C" { // When PATH is "", this is actually a valid search path for PWD. // Therefore append an equivalent representation of PWD (string used length is 0). - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); if (F_status_is_error(status)) return status; paths->array[paths->used].string = 0; @@ -195,7 +195,7 @@ extern "C" { j--; if (!j || path[j] == f_path_separator_variable[0]) { - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); if (F_status_is_error(status)) return status; if (path[j] == f_path_separator_variable[0]) { @@ -269,7 +269,7 @@ extern "C" { if (!path.used) { // When PATH is "", this is actually a valid search path for PWD. // Therefore append an equivalent representation of PWD (string used length is 0). - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); if (F_status_is_error(status)) return status; f_macro_string_dynamic_t_clear(paths->array[paths->used]); @@ -290,7 +290,7 @@ extern "C" { j--; if (!j || path.string[j] == f_path_separator_variable[0]) { - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); if (F_status_is_error(status)) return status; if (path.string[j] == f_path_separator_variable[0]) { diff --git a/level_1/fl_fss/c/fss_basic.c b/level_1/fl_fss/c/fss_basic.c index dd61602..220c9b7 100644 --- a/level_1/fl_fss/c/fss_basic.c +++ b/level_1/fl_fss/c/fss_basic.c @@ -6,7 +6,7 @@ extern "C" { #endif #ifndef _di_fl_fss_basic_object_read_ - f_return_status fl_fss_basic_object_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quoted_t *quoted) { + f_return_status fl_fss_basic_object_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quote) { #ifndef _di_level_1_parameter_checking_ if (!buffer) return F_status_set_error(F_parameter); if (!buffer->used ) return F_status_set_error(F_parameter); @@ -19,7 +19,7 @@ extern "C" { f_status_t status = F_none; f_string_lengths_t delimits = f_string_lengths_t_initialize; - status = private_fl_fss_basic_object_read(buffer, range, found, quoted, &delimits); + status = private_fl_fss_basic_object_read(buffer, range, found, quote, &delimits); if (F_status_is_error(status)) { f_macro_string_lengths_t_delete_simple(delimits); @@ -92,18 +92,47 @@ extern "C" { #endif // _di_fl_fss_basic_content_read_ #ifndef _di_fl_fss_basic_object_write_ - f_return_status fl_fss_basic_object_write(const f_string_static_t object, const f_fss_quoted_t quoted, f_string_range_t *range, f_string_dynamic_t *destination) { + f_return_status fl_fss_basic_object_write(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - return private_fl_fss_basic_object_write(object, quoted, range, destination); + const f_status_t status = private_fl_fss_basic_object_write(object, quote ? quote : f_fss_delimit_quote_double, range, destination); + + if (status == F_data_not_stop || status == F_data_not_eos) { + + // Objects cannot be empty, so write a quoted empty string. + const f_status_t status_allocation = private_fl_fss_destination_increase_by(2, destination); + if (F_status_is_error(status_allocation)) return status_allocation; + + destination->string[destination->used++] = quote ? quote : f_fss_delimit_quote_double; + destination->string[destination->used++] = quote ? quote : f_fss_delimit_quote_double; + + if (status == F_data_not_stop) { + return F_none_stop; + } + + return F_none_eos; + } + + if (complete == f_fss_complete_partial || complete == f_fss_complete_full) { + if (status == F_none_stop || status == F_none_eos) { + const f_status_t status_allocation = private_fl_fss_destination_increase(destination); + if (F_status_is_error(status_allocation)) return status_allocation; + + destination->string[destination->used++] = f_fss_basic_open; + } + } + + return status; } #endif // _di_fl_fss_basic_object_write_ #ifndef _di_fl_fss_basic_content_write_ - f_return_status fl_fss_basic_content_write(const f_string_static_t content, f_string_range_t *range, f_string_dynamic_t *destination) { + f_return_status fl_fss_basic_content_write(const f_string_static_t content, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -111,47 +140,52 @@ extern "C" { 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; + if (range->start > range->stop || range->start >= content.used) { - f_string_range_t input_position = f_string_range_t_initialize; - f_string_range_t buffer_position = f_string_range_t_initialize; + // content should be terminated, even if empty. + if (complete == f_fss_complete_full || complete == f_fss_complete_end) { + status = private_fl_fss_destination_increase(destination); + if (F_status_is_error(status)) return status; - // ensure that there is room for the terminating newline. - f_string_length_t size_allocate = destination->used + content.used + 1 + f_fss_default_allocation_step_string; + destination->string[destination->used++] = f_fss_basic_close; + } - buffer_position.start = destination->used; - buffer_position.stop = destination->used; + if (range->start > range->stop) { + return F_data_not_stop; + } - if (size_allocate > destination->size) { - f_macro_string_dynamic_t_resize(status, (*destination), size_allocate); - if (F_status_is_error(status)) return status; + return F_data_not_eos; } - while (range->start <= range->stop && range->start < content.used) { + // ensure that there is room for the potential terminating newline. + status = private_fl_fss_destination_increase_by(destination->used + (range->stop - range->start) + 1, destination); + if (F_status_is_error(status)) return status; + + const f_string_length_t used_start = destination->used; + + for (; range->start <= range->stop && range->start < content.used; range->start++) { if (content.string[range->start] == f_string_eol[0]) { - destination->string[buffer_position.stop] = f_string_eol[0]; - destination->used = buffer_position.stop + 1; - return F_none_eos; + destination->used = used_start; + return F_status_set_error(F_none_eol); } - if (content.string[range->start] != f_fss_delimit_placeholder) { - destination->string[buffer_position.stop] = content.string[range->start]; - buffer_position.stop++; + if (content.string[range->start] == f_fss_delimit_placeholder) { + continue; } - status = f_utf_buffer_increment(content, range, 1); - if (F_status_is_error(status)) return status; + destination->string[destination->used++] = content.string[range->start]; } // while - destination->string[buffer_position.stop] = f_string_eol[0]; - destination->used = buffer_position.stop + 1; + if (complete == f_fss_complete_full || complete == f_fss_complete_end) { + destination->string[destination->used++] = f_fss_basic_close; + } - if (range->start > range->stop) return F_none_stop; - else if (range->start >= content.used) return F_none_eos; + if (range->start > range->stop) { + return F_none_stop; + } - return F_none; + return F_none_eos; } #endif // _di_fl_fss_basic_content_write_ diff --git a/level_1/fl_fss/c/fss_basic.h b/level_1/fl_fss/c/fss_basic.h index fb14fba..d543e60 100644 --- a/level_1/fl_fss/c/fss_basic.h +++ b/level_1/fl_fss/c/fss_basic.h @@ -47,8 +47,8 @@ extern "C" { * 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. + * @param quote + * This will store whether or not this object is quote and what quote is in use. * Set pointer address to 0 to not use. * * @return @@ -74,7 +74,7 @@ extern "C" { * Errors (with error bit) from: f_fss_skip_past_space(). */ #ifndef _di_fl_fss_basic_object_read_ - extern f_return_status fl_fss_basic_object_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quoted_t *quoted); + extern f_return_status fl_fss_basic_object_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quote); #endif // _di_fl_fss_basic_object_read_ /** @@ -127,11 +127,17 @@ extern "C" { * Anything within this range will be escaped as necessary. * This will stop if EOL is reached. * + * The destination string may have NULLs. + * * @param object * The string to write as (does not stop at NULLS, they are ignored and not written). - * @param quoted + * @param quote * 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 complete + * If f_fss_complete_none, then only the object name is written. + * If f_fss_complete_partial, this will write any appropriate open and close aspects of this object. + * If f_fss_complete_full, this will write any appropriate open and close aspects of this object. * @param range * The start/stop location within the object string to write as an object. * @param destination @@ -140,18 +146,16 @@ extern "C" { * @return * F_none on success. * F_none_eos on success after reaching the end of the buffer. + * F_none_stop on success after reaching the range stop. * 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_none_eol (with error bit) after reaching an EOL, which is not supported by the standard. * 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 (with error bit) from: f_utf_buffer_increment(). + * F_string_too_large (with error bit) if appended string length is too large to store in the destination. */ #ifndef _di_fl_fss_basic_object_write_ - extern f_return_status fl_fss_basic_object_write(const f_string_static_t object, const f_fss_quoted_t quoted, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_return_status fl_fss_basic_object_write(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_basic_object_write_ /** @@ -160,8 +164,14 @@ extern "C" { * This will write the given string range as a valid content. * Anything within this range will be escaped as necessary. * + * The destination string may have NULLs. + * * @param content * The string to write as (does not stop at NULLS, they are ignored and not written). + * @param complete + * If f_fss_complete_none, then only the object name is written. + * If f_fss_complete_partial, this will write any appropriate open and close aspects of this object, except for the final newline. + * If f_fss_complete_full, this will write any appropriate open and close aspects of this object, including the final newline. * @param range * The start/stop location within the content string to write as an content. * @param destination @@ -169,18 +179,16 @@ extern "C" { * @return * F_none on success. * F_none_eos on success after reaching the end of the buffer. + * F_none_stop on success after reaching the range stop. * 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_none_eol (with error bit) after reaching an EOL, which is not supported by the standard. * 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 (with error bit) from: f_utf_buffer_increment(). + * F_string_too_large (with error bit) if appended string length is too large to store in the destination. */ #ifndef _di_fl_fss_basic_content_write_ - extern f_return_status fl_fss_basic_content_write(const f_string_static_t content, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_return_status fl_fss_basic_content_write(const f_string_static_t content, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_basic_content_write_ #ifdef __cplusplus diff --git a/level_1/fl_fss/c/fss_basic_list.c b/level_1/fl_fss/c/fss_basic_list.c index dd5571c..c9a3824 100644 --- a/level_1/fl_fss/c/fss_basic_list.c +++ b/level_1/fl_fss/c/fss_basic_list.c @@ -395,7 +395,7 @@ extern "C" { #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_t object, f_string_range_t *range, f_string_dynamic_t *destination) { + f_return_status fl_fss_basic_list_object_write(const f_string_static_t object, const f_fss_quote_t quoted, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -404,7 +404,6 @@ extern "C" { f_string_range_t buffer_position = f_string_range_t_initialize; f_string_length_t start_position = f_string_t_initialize; - f_string_length_t size_allocate = 0; f_string_length_t start_buffer = 0; fl_macro_fss_skip_past_delimit_placeholders(object, (*range)) @@ -414,8 +413,8 @@ extern "C" { start_position = range->start; - // add an additional 2 to ensure that there is room for the slash delimit and the object open character. - size_allocate = destination->used + (range->stop - range->start) + 2 + f_fss_default_allocation_step_string; + // ensure that there is room for the start and stop quotes or a slash delimit and the object open character. + f_string_length_t size_allocate = destination->used + (range->stop - range->start) + 3 + f_fss_default_allocation_step; if (size_allocate > destination->size) { f_macro_string_dynamic_t_resize(status, (*destination), size_allocate); @@ -425,6 +424,19 @@ extern "C" { buffer_position.start = destination->used; buffer_position.stop = destination->used; + bool quote = quoted ? F_true : F_false; + + if (quoted) { + if (quoted == f_fss_quote_type_single) { + destination->string[destination->used] = f_fss_delimit_quote_single; + } + else { + destination->string[destination->used] = f_fss_delimit_quote_double; + } + + destination->used++; + } + while (range->start <= range->stop && range->start < object.used) { if (object.string[range->start] == f_fss_comment) { @@ -482,7 +494,7 @@ extern "C" { size_allocate += slash_count; if (size_allocate > destination->size) { - f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string); + f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step); if (F_status_is_error(status)) return status; } @@ -539,17 +551,36 @@ extern "C" { 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; + if (range->start > range->stop) { + if (destination->used + f_fss_default_allocation_step > f_string_length_t_size) { + if (destination->used + 1 > f_string_length_t_size) { + return F_status_set_error(F_string_too_large); + } + + f_macro_string_dynamic_t_resize(status, (*destination), 1); + if (F_status_is_error(status)) return status; + } + else { + f_macro_string_dynamic_t_resize(status, (*destination), f_fss_default_allocation_step); + if (F_status_is_error(status)) return status; + } + + destination->string[destination->used] = f_fss_extended_close; + destination->used++; + return F_data_not_stop; + } + + if (range->start >= content.used) { + return F_data_not_eos; + } start_position = range->start; // add an additional 2 to ensure that there is room for the slash delimit and the content open character. - size_allocate = destination->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; if (size_allocate > destination->size) { f_macro_string_dynamic_t_resize(status, (*destination), size_allocate); - if (F_status_is_error(status)) return status; } @@ -611,7 +642,7 @@ extern "C" { size_allocate += slash_count + 1; if (size_allocate > destination->size) { - f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string); + f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step); if (F_status_is_error(status)) return status; } @@ -657,7 +688,7 @@ extern "C" { size_allocate++; if (size_allocate > destination->size) { - f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string); + f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step); if (F_status_is_error(status)) return status; } diff --git a/level_1/fl_fss/c/fss_basic_list.h b/level_1/fl_fss/c/fss_basic_list.h index e612b52..c327547 100644 --- a/level_1/fl_fss/c/fss_basic_list.h +++ b/level_1/fl_fss/c/fss_basic_list.h @@ -125,8 +125,13 @@ extern "C" { * Anything within this range will be escaped as necessary. * This will stop if EOL is reached. * + * The destination string may have NULLs. + * * @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 destination @@ -146,7 +151,7 @@ extern "C" { * Errors (with error bit) from: 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_t object, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_return_status fl_fss_basic_list_object_write(const f_string_static_t object, const f_fss_quote_t quoted, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_basic_list_object_write_ /** @@ -155,6 +160,8 @@ extern "C" { * This will write the given string range as a valid content. * Anything within this range will be escaped as necessary. * + * The destination string may have NULLs. + * * @param content * The string to write as (does not stop at NULLS, they are ignored and not written). * @param range diff --git a/level_1/fl_fss/c/fss_extended.c b/level_1/fl_fss/c/fss_extended.c index 5f48b2d..edd1da3 100644 --- a/level_1/fl_fss/c/fss_extended.c +++ b/level_1/fl_fss/c/fss_extended.c @@ -6,7 +6,7 @@ extern "C" { #endif #ifndef _di_fl_fss_extended_object_read_ - f_return_status fl_fss_extended_object_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quoted_t *quoted) { + f_return_status fl_fss_extended_object_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quoted) { #ifndef _di_level_1_parameter_checking_ if (!buffer) return F_status_set_error(F_parameter); if (!buffer->used) return F_status_set_error(F_parameter); @@ -38,7 +38,7 @@ extern "C" { #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_t *buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_quoteds_t *quoteds) { + f_return_status fl_fss_extended_content_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_quotes_t *quotes) { #ifndef _di_level_1_parameter_checking_ if (!buffer) return F_status_set_error(F_parameter); if (!buffer->used) return F_status_set_error(F_parameter); @@ -72,7 +72,7 @@ extern "C" { while (range->start <= range->stop && range->start < buffer->used) { f_string_range_t content_partial = f_string_range_t_initialize; - f_fss_quoted_t quoted = 0; + f_fss_quote_t quoted = 0; status = private_fl_fss_basic_object_read(buffer, range, &content_partial, "ed, &delimits); @@ -93,8 +93,8 @@ extern "C" { if (F_status_is_error(status_allocate)) return status_allocate; - if (quoteds) { - f_macro_fss_quoteds_t_resize(status_allocate, (*quoteds), found->size); + if (quotes) { + f_macro_fss_quotes_t_resize(status_allocate, (*quotes), found->size); if (F_status_is_error(status_allocate)) return status_allocate; } } @@ -102,9 +102,9 @@ extern "C" { found->array[found->used] = content_partial; found->used++; - if (quoteds) { - quoteds->array[quoteds->used] = quoted; - quoteds->used = found->used; + if (quotes) { + quotes->array[quotes->used] = quoted; + quotes->used = found->used; } content_found = 1; @@ -157,23 +157,97 @@ extern "C" { #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_t object, const f_fss_quoted_t quoted, f_string_range_t *range, f_string_dynamic_t *destination) { +f_return_status fl_fss_extended_object_write(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - return private_fl_fss_basic_object_write(object, quoted, range, destination); + const f_status_t status = private_fl_fss_basic_object_write(object, quote ? quote : f_fss_delimit_quote_double, range, destination); + + if (status == F_data_not_stop || status == F_data_not_eos) { + + // Objects cannot be empty, so write a quoted empty string. + const f_status_t status_allocation = private_fl_fss_destination_increase_by(2, destination); + if (F_status_is_error(status_allocation)) return status_allocation; + + destination->string[destination->used++] = quote ? quote : f_fss_delimit_quote_double; + destination->string[destination->used++] = quote ? quote : f_fss_delimit_quote_double; + + if (status == F_data_not_stop) { + return F_none_stop; + } + + return F_none_eos; + } + + if (complete == f_fss_complete_partial || complete == f_fss_complete_full) { + if (status == F_none_stop || status == F_none_eos) { + const f_status_t status_allocation = private_fl_fss_destination_increase(destination); + if (F_status_is_error(status_allocation)) return status_allocation; + + destination->string[destination->used++] = f_fss_extended_open; + } + } + + return status; } #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_t content, const f_fss_quoted_t quoted, f_string_range_t *range, f_string_dynamic_t *destination) { + f_return_status fl_fss_extended_content_write(const f_string_static_t content, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - // 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); + // this operates exactly like an object, syntax-wise. + const f_status_t status = private_fl_fss_basic_object_write(content, quote ? quote : f_fss_delimit_quote_double, range, destination); + + if (status == F_data_not_stop || status == F_data_not_eos) { + f_status_t status_allocation = F_none; + + // content should be terminated, even if empty. + if (complete == f_fss_complete_partial || complete == f_fss_complete_full || complete == f_fss_complete_next) { + status_allocation = private_fl_fss_destination_increase(destination); + if (F_status_is_error(status_allocation)) return status_allocation; + + destination->string[destination->used++] = f_fss_extended_next; + } + + if (complete == f_fss_complete_full || complete == f_fss_complete_end) { + status_allocation = private_fl_fss_destination_increase(destination); + if (F_status_is_error(status_allocation)) return status_allocation; + + destination->string[destination->used++] = f_fss_extended_close; + } + + if (status == F_data_not_stop) { + return F_none_stop; + } + + return F_none_eos; + } + + if (F_status_is_error_not(status)) { + f_status_t status_allocation = F_none; + + if (complete == f_fss_complete_partial || complete == f_fss_complete_full || complete == f_fss_complete_next) { + status_allocation = private_fl_fss_destination_increase(destination); + if (F_status_is_error(status_allocation)) return status_allocation; + + destination->string[destination->used++] = f_fss_extended_next; + } + + if (complete == f_fss_complete_full || complete == f_fss_complete_end) { + status_allocation = private_fl_fss_destination_increase(destination); + if (F_status_is_error(status_allocation)) return status_allocation; + + destination->string[destination->used++] = f_fss_extended_close; + } + } + + return status; } #endif // _di_fl_fss_extended_content_write_ diff --git a/level_1/fl_fss/c/fss_extended.h b/level_1/fl_fss/c/fss_extended.h index ad77be1..5df0c61 100644 --- a/level_1/fl_fss/c/fss_extended.h +++ b/level_1/fl_fss/c/fss_extended.h @@ -74,7 +74,7 @@ extern "C" { * Errors (with error bit) from: f_fss_skip_past_space(). */ #ifndef _di_fl_fss_extended_object_read_ - extern f_return_status fl_fss_extended_object_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quoted_t *quoted); + extern f_return_status fl_fss_extended_object_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quoted); #endif // _di_fl_fss_extended_object_read_ /** @@ -93,7 +93,7 @@ extern "C" { * 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 + * @param quotes * 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. * @@ -120,7 +120,7 @@ extern "C" { * Errors (with error bit) from: f_fss_skip_past_space(). */ #ifndef _di_fl_fss_extended_content_read_ - extern f_return_status fl_fss_extended_content_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_quoteds_t *quoteds); + extern f_return_status fl_fss_extended_content_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_content_t *found, f_fss_quotes_t *quotes); #endif // _di_fl_fss_extended_content_read_ /** @@ -130,11 +130,17 @@ extern "C" { * Anything within this range will be escaped as necessary. * This will stop if EOL is reached. * + * The destination string may have NULLs. + * * @param object * The string to write as (does not stop at NULLS, they are ignored and not written). - * @param quoted + * @param quote * 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 complete + * If f_fss_complete_none, then only the object name is written. + * If f_fss_complete_partial, this will write any appropriate open and close aspects of this object, except for the final newline. + * If f_fss_complete_full, this will write any appropriate open and close aspects of this object, including the final newline. * @param range * The start/stop location within the object string to write as an object. * @param destination @@ -143,18 +149,16 @@ extern "C" { * @return * F_none on success. * F_none_eos on success after reaching the end of the buffer. + * F_none_stop on success after reaching the range stop. * 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_none_eol (with error bit) after reaching an EOL, which is not supported by the standard. * 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 (with error bit) from: f_utf_buffer_increment(). + * F_string_too_large (with error bit) if appended string length is too large to store in the destination. */ #ifndef _di_fl_fss_extended_object_write_ - extern f_return_status fl_fss_extended_object_write(const f_string_static_t object, const f_fss_quoted_t quoted, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_return_status fl_fss_extended_object_write(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_extended_object_write_ /** @@ -163,11 +167,17 @@ extern "C" { * This will write the given string range as a valid content. * Anything within this range will be escaped as necessary. * + * The destination string may have NULLs. + * * @param content * The string to write as (does not stop at NULLS, they are ignored and not written). - * @param quoted + * @param quote * 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 complete + * If f_fss_complete_none, then only the object name is written. + * If f_fss_complete_partial, this will write any appropriate open and close aspects of this object, except for the final newline. + * If f_fss_complete_full, this will write any appropriate open and close aspects of this object, including the final newline. * @param range * The start/stop location within the content string to write as an content. * @param destination @@ -176,18 +186,16 @@ extern "C" { * @return * F_none on success. * F_none_eos on success after reaching the end of the buffer. + * F_none_stop on success after reaching the range stop. * 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_none_eol (with error bit) after reaching an EOL, which is not supported by the standard. * 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 (with error bit) from: f_utf_buffer_increment(). + * F_string_too_large (with error bit) if appended string length is too large to store in the destination. */ #ifndef _di_fl_fss_extended_content_write_ - extern f_return_status fl_fss_extended_content_write(const f_string_static_t content, const f_fss_quoted_t quoted, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_return_status fl_fss_extended_content_write(const f_string_static_t content, const f_fss_quote_t quote, const uint8_t complete, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_extended_content_write_ #ifdef __cplusplus diff --git a/level_1/fl_fss/c/fss_extended_list.c b/level_1/fl_fss/c/fss_extended_list.c index baee672..3999b16 100644 --- a/level_1/fl_fss/c/fss_extended_list.c +++ b/level_1/fl_fss/c/fss_extended_list.c @@ -812,7 +812,7 @@ extern "C" { start_position = range->start; // add an additional 2 to ensure that there is room for the slash delimit and the object open character. - size_allocate = destination->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; if (size_allocate > destination->size) { f_macro_string_dynamic_t_resize(status, (*destination), size_allocate); @@ -880,7 +880,7 @@ extern "C" { size_allocate += slash_count; if (size_allocate > destination->size) { - f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string); + f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step); if (F_status_is_error(status)) return status; } @@ -943,7 +943,7 @@ extern "C" { start_position = range->start; // add an additional 2 to ensure that there is room for the slash delimit and the content open character. - size_allocate = destination->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; if (size_allocate > destination->size) { f_macro_string_dynamic_t_resize(status, (*destination), size_allocate); @@ -1008,7 +1008,7 @@ extern "C" { size_allocate += slash_count + 1; if (size_allocate > destination->size) { - f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string); + f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step); if (F_status_is_error(status)) return status; } @@ -1054,7 +1054,7 @@ extern "C" { size_allocate++; if (size_allocate > destination->size) { - f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string); + f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step); if (F_status_is_error(status)) return status; } diff --git a/level_1/fl_fss/c/fss_extended_list.h b/level_1/fl_fss/c/fss_extended_list.h index 3aa9d0a..8f5c740 100644 --- a/level_1/fl_fss/c/fss_extended_list.h +++ b/level_1/fl_fss/c/fss_extended_list.h @@ -129,6 +129,8 @@ extern "C" { * Anything within this range will be escaped as necessary. * This will stop if EOL is reached. * + * The destination string may have NULLs. + * * @param object * The string to write as (does not stop at NULLS, they are ignored and not written). * @param range @@ -159,6 +161,8 @@ extern "C" { * This will write the given string range as a valid content. * Anything within this range will be escaped as necessary. * + * The destination string may have NULLs. + * * @param content * The string to write as (does not stop at NULLS, they are ignored and not written). * @param range diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index 62d6566..45964e7 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -6,7 +6,7 @@ extern "C" { #endif #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_t *buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quoted_t *quoted, f_string_lengths_t *delimits) { + f_return_status private_fl_fss_basic_object_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quoted, f_string_lengths_t *delimits) { f_status_t status = F_none; status = f_fss_skip_past_space(*buffer, range); @@ -241,10 +241,10 @@ extern "C" { if (status == F_true) { if (quoted) { if (quote == f_fss_delimit_quote_single) { - *quoted = f_fss_quoted_type_single; + *quoted = f_fss_quote_type_single; } else if (quote == f_fss_delimit_quote_double) { - *quoted = f_fss_quoted_type_double; + *quoted = f_fss_quote_type_double; } } @@ -387,10 +387,10 @@ extern "C" { if (status == F_true) { if (quoted) { if (quote == f_fss_delimit_quote_single) { - *quoted = f_fss_quoted_type_single; + *quoted = f_fss_quote_type_single; } else if (quote == f_fss_delimit_quote_double) { - *quoted = f_fss_quoted_type_double; + *quoted = f_fss_quote_type_double; } } @@ -495,321 +495,197 @@ extern "C" { } #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_t object, const f_fss_quoted_t quoted, f_string_range_t *range, f_string_dynamic_t *destination) { +#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) + f_return_status private_fl_fss_basic_object_write(const f_string_static_t object, const f_fss_quote_t quote, f_string_range_t *range, f_string_dynamic_t *destination) { f_status_t 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_t size_allocate = destination->used + (range->stop - range->start) + 3 + f_fss_default_allocation_step_string; - - if (size_allocate > destination->size) { - f_macro_string_dynamic_t_resize(status, (*destination), size_allocate); - if (F_status_is_error(status)) return status; + if (range->start > range->stop) { + return F_data_not_stop; } - const f_string_length_t position_start = range->start; - - f_string_range_t destination_position = f_string_range_t_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++; + if (range->start >= object.used) { + return F_data_not_eos; } - // @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_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string); - if (F_status_is_error(status)) return status; - } + // ensure that there is room for the potential start and stop quotes, a potential delimit at start, and the potential object open character. + status = private_fl_fss_destination_increase_by(destination->used + (range->stop - range->start) + 4, destination); + 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; + const f_string_length_t input_start = range->start; + const f_string_length_t used_start = destination->used; - 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++; + bool quoted = F_false; - if (size_allocate > destination->size) { - f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string); - - if (F_status_is_error(status)) return status; - } + f_string_length_t slash_total = 0; + f_string_length_t slash_first = 0; + f_string_length_t quote_start = 0; + f_string_length_t i = 0; - destination->string[destination_position.stop] = f_fss_delimit_slash; - destination->string[destination_position.stop + 1] = object.string[range->start]; - destination_position.stop += 2; + // use placeholders for potential quote and potential delimited quote to avoid doing things such as memmove(). + destination->string[destination->used++] = f_fss_delimit_placeholder; + destination->string[destination->used++] = f_fss_delimit_placeholder; - status = f_utf_buffer_increment(object, range, 1); - if (F_status_is_error(status)) return status; + // if there is an initial quote, then this must be quoted and the existing quote must be delimited. + if (object.string[input_start] == quote) { + 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(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_t next = *range; - f_string_length_t 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++; + for (; range->start <= range->stop && range->start < object.used; range->start++) { - 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) { + if (object.string[range->start] == f_fss_delimit_slash) { + slash_first = range->start; + slash_total = 1; - // 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); + for (range->start++; range->start <= range->stop && range->start < object.used; range->start++) { - 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; - } - } + if (object.string[range->start] == f_fss_delimit_slash) { + slash_total++; } - else { - // ensure that the slashes before the closing quoted to not delimit the closing quoted. - must_delimit = F_true; + else if (object.string[range->start] != f_fss_delimit_placeholder) { + break; } + } // for - if (must_delimit) { - for (f_string_length_t i = 0; i < slashes; i++) { + if (range->start > range->stop || range->start >= object.used || object.string[range->start] == f_fss_eol) { + for (i = 0; i < slash_total; i++) { + destination->string[destination->used++] = f_fss_delimit_slash; + } // for - destination->string[destination_position.stop] = f_fss_delimit_slash; - destination_position.stop++; - } // for + break; + } - if (slashes % 2) { - size_allocate++; + if (object.string[range->start] == quote) { - if (size_allocate > destination->size) { - f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string); - if (F_status_is_error(status)) return status; - } + // if any space is found after a quote after a slash, then this must be delimited and quoted. + status = f_fss_is_space(object, *range); + if (F_status_is_error(status)) break; - 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_t next = *range; - bool must_delimit = F_false; + if (status == F_true) { + quoted = F_true; - status = f_utf_buffer_increment(object, &next, 1); - if (F_status_is_error(status)) return status; + status = private_fl_fss_destination_increase_by(slash_total, destination); + if (F_status_is_error(status)) break; - fl_macro_fss_skip_past_delimit_placeholders(object, next); + // add the slashes that delimit the slashes. + for (i = 0; i < slash_total; i++) { + destination->string[destination->used++] = f_fss_delimit_slash; + } // for - if (next.start > range->stop || next.start >= object.used) { - must_delimit = F_true; + // add the slashed that get delimited. + for (i = 0; i < slash_total; i++) { + destination->string[destination->used++] = f_fss_delimit_slash; + } // for } - 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; - } + else if (slash_first == input_start) { + destination->string[used_start + 1] = f_fss_delimit_slash; } + } + else { - if (must_delimit) { - size_allocate++; - - if (size_allocate > destination->size) { - f_macro_string_dynamic_t_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++; - } + // there is nothing to delimit, so all slashes should be printed as is. + for (i = 0; i < slash_total; i++) { + destination->string[destination->used++] = f_fss_delimit_slash; + } // for } } - else { + else if (object.string[range->start] == quote) { + for (; range->start <= range->stop && range->start < object.used; range->start++) { + if (object.string[range->start] != f_fss_delimit_placeholder) break; + } // for + + if (range->start > range->stop || range->start >= object.used) { + status = private_fl_fss_destination_increase(destination); + if (F_status_is_error(status)) break; + + destination->string[destination->used++] = f_fss_delimit_slash; + destination->string[destination->used++] = quote; + quoted = F_true; + break; + } + + // if any space is found, then this must be quoted. status = f_fss_is_space(object, *range); + if (F_status_is_error(status)) break; if (status == F_true) { - size_allocate++; - - if (size_allocate > destination->size) { - f_macro_string_dynamic_t_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; + status = private_fl_fss_destination_increase(destination); + if (F_status_is_error(status)) break; - continue; - } - else if (object.string[range->start] != f_fss_delimit_slash) { - break; - } + destination->string[destination->used++] = f_fss_delimit_slash; + destination->string[destination->used++] = quote; + quoted = F_true; + } + } + else if (object.string[range->start] != f_fss_delimit_placeholder) { + destination->string[destination->used++] = object.string[range->start]; + } + } // for - destination->string[destination_position.stop] = object.string[range->start]; - destination_position.stop++; + if (F_status_is_error(status)) { + destination->used = used_start; + return status; + } - status = f_utf_buffer_increment(object, range, 1); - if (F_status_is_error(status)) return status; - } // while + if (quoted) { + destination->string[used_start] = quote; + destination->string[destination->used++] = quote; - if (range->start > range->stop || range->start >= object.used) break; + if (object.string[input_start] == quote) { + destination->string[used_start + 1] = f_fss_delimit_slash; + } + } - if (object.string[range->start] == f_fss_delimit_quote_double) { - size_allocate++; + if (range->start > range->stop) { + return F_none_stop; + } - if (size_allocate > destination->size) { - f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string); - if (F_status_is_error(status)) return status; - } + if (range->start >= object.used) { + return F_none_eos; + } - 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++; + // the only way to make it here should be if stopped at EOL. + return F_status_set_error(F_none_eol); + } +#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) - if (size_allocate > destination->size) { - f_macro_string_dynamic_t_resize(status, (*destination), size_allocate + f_fss_default_allocation_step_string); - if (F_status_is_error(status)) return status; - } +#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) + f_return_status private_fl_fss_destination_increase(f_string_dynamic_t *destination) { + f_status_t status = F_none; - destination->string[destination_position.stop] = f_fss_delimit_slash; - destination_position.stop++; - } - } - else if (F_status_is_error(status)) { - return status; + if (destination->used + 1 > destination->size) { + if (destination->size + f_fss_default_allocation_step > f_string_length_t_size) { + if (destination->size + 1 > f_string_length_t_size) { + return F_status_set_error(F_string_too_large); } + + f_macro_string_dynamic_t_resize(status, (*destination), destination->size + 1); + } + else { + f_macro_string_dynamic_t_resize(status, (*destination), destination->size + f_fss_default_allocation_step); } + } - destination->string[destination_position.stop] = object.string[range->start]; + return status; + } +#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) - status = f_utf_buffer_increment(object, range, 1); - if (F_status_is_error(status)) return status; +#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) + f_return_status private_fl_fss_destination_increase_by(const f_string_length_t amount, f_string_dynamic_t *destination) { + f_status_t status = F_none; - destination_position.stop++; - } // while + if (destination->used + amount > destination->size) { + if (destination->size + amount > f_string_length_t_size) { + return F_status_set_error(F_string_too_large); + } - if (quote) { - destination->string[destination_position.stop] = destination->string[destination_position.start]; - destination_position.stop++; + f_macro_string_dynamic_t_resize(status, (*destination), destination->size + amount); } - 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; + return status; } -#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) +#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) #ifdef __cplusplus } // extern "C" diff --git a/level_1/fl_fss/c/private-fss.h b/level_1/fl_fss/c/private-fss.h index 3485d43..6f62640 100644 --- a/level_1/fl_fss/c/private-fss.h +++ b/level_1/fl_fss/c/private-fss.h @@ -63,7 +63,7 @@ extern "C" { * @see 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_t *buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quoted_t *quoted, f_string_lengths_t *delimits) f_gcc_attribute_visibility_internal; + extern f_return_status private_fl_fss_basic_object_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quoted, f_string_lengths_t *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_) /** @@ -71,6 +71,8 @@ extern "C" { * * Intended to be shared to each of the different implementation variations. * + * Note: this does not attempt to "complete" the object. + * * @param object * The string to write as (does not stop at NULLS, they are ignored and not written). * @param quoted @@ -84,22 +86,63 @@ extern "C" { * @return * F_none on success. * F_none_eos on success after reaching the end of the buffer. + * F_none_stop on success after reaching the range stop. * 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_none_eol (with error bit) after reaching an EOL, which is not supported by the standard. * 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. + * F_string_too_large (with error bit) if appended string length is too large to store in the destination. * - * Errors (with error bit) from: f_utf_buffer_increment(). + * @see fl_fss_basic_object_write() + * @see fl_fss_extended_object_write() + * @see fl_fss_extended_content_write() + */ +#if !defined(fl_fss_basic_object_write) || !defined(fl_fss_extended_object_write) || !defined(_di_fl_fss_extended_content_write_) + extern f_return_status private_fl_fss_basic_object_write(const f_string_static_t object, const f_fss_quote_t quoted, f_string_range_t *range, f_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; +#endif // !defined(fl_fss_basic_object_write) || !defined(fl_fss_extended_object_write) || !defined(_di_fl_fss_extended_content_write_) + +/** + * Increase the size of destination buffer, but only if necessary. + * + * @param destination + * The destination buffer to increment. + * + * @return + * F_none on success. + * F_memory_reallocation (with error bit) on reallocation error. + * F_string_too_large (with error bit) if appended string length is too large to store in the destination. + * + * @see fl_fss_basic_object_write() + * @see fl_fss_basic_content_write() + * @see fl_fss_extended_object_write() + * @see fl_fss_extended_content_write() + */ +#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) + extern f_return_status private_fl_fss_destination_increase(f_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) + +/** + * Increase the size of destination buffer by the given amount, but only if necessary. + * + * @param amount + * The amount to increase by. + * @param destination + * The destination buffer to increment. + * + * @return + * F_none on success. + * F_memory_reallocation (with error bit) on reallocation error. + * F_string_too_large (with error bit) if appended string length is too large to store in the destination. * * @see fl_fss_basic_object_write() + * @see fl_fss_basic_content_write() * @see fl_fss_extended_object_write() + * @see fl_fss_extended_content_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_t object, const f_fss_quoted_t quoted, f_string_range_t *range, f_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; -#endif // !defined(fl_fss_basic_object_write) || !defined(fl_fss_extended_object_write) +#if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) + f_return_status private_fl_fss_destination_increase_by(const f_string_length_t amount, f_string_dynamic_t *destination); +#endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_basic_content_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) #ifdef __cplusplus } // extern "C" diff --git a/level_1/fl_string/c/string.c b/level_1/fl_string/c/string.c index ddd83af..3eb234d 100644 --- a/level_1/fl_string/c/string.c +++ b/level_1/fl_string/c/string.c @@ -1158,7 +1158,7 @@ extern "C" { f_status_t status = F_none; if (strings->size - length > 0) { - f_macro_string_dynamics_resize(status, (*strings), strings->size - length); + f_macro_string_dynamics_t_resize(status, (*strings), strings->size - length); } else if (strings->size - length <= 0) { f_macro_string_dynamics_t_delete(status, (*strings)); @@ -1182,11 +1182,11 @@ extern "C" { return F_status_set_error(F_string_too_large); } - f_macro_string_dynamics_resize(status, (*strings), f_array_length_t_size); + f_macro_string_dynamics_t_resize(status, (*strings), f_array_length_t_size); return F_string_too_large; } - f_macro_string_dynamics_resize(status, (*strings), strings->size + length); + f_macro_string_dynamics_t_resize(status, (*strings), strings->size + length); return status; } #endif // _di_fl_string_dynamics_size_increase_ diff --git a/level_2/fll_execute/c/private-execute.c b/level_2/fll_execute/c/private-execute.c index e2e2b72..e35b684 100644 --- a/level_2/fll_execute/c/private-execute.c +++ b/level_2/fll_execute/c/private-execute.c @@ -11,11 +11,11 @@ extern "C" { if (arguments->used == arguments->size) { if (arguments->size + f_memory_default_allocation_step > f_array_length_t_size) { - if (arguments->size + 1 > f_array_length_t_size) return F_buffer_too_large; - f_macro_string_dynamics_resize(status, (*arguments), arguments->size + 1); + if (arguments->size + 1 > f_array_length_t_size) return F_status_set_error(F_buffer_too_large); + f_macro_string_dynamics_t_resize(status, (*arguments), arguments->size + 1); } else { - f_macro_string_dynamics_resize(status, (*arguments), arguments->size + f_memory_default_allocation_step); + f_macro_string_dynamics_t_resize(status, (*arguments), arguments->size + f_memory_default_allocation_step); } if (F_status_is_error(status)) return status; @@ -52,11 +52,11 @@ extern "C" { if (arguments->used + 1 >= arguments->size) { if (arguments->size + f_memory_default_allocation_step > f_array_length_t_size) { - if (arguments->size + 2 > f_array_length_t_size) return F_buffer_too_large; - f_macro_string_dynamics_resize(status, (*arguments), arguments->size + 2); + if (arguments->size + 2 > f_array_length_t_size) return F_status_set_error(F_buffer_too_large); + f_macro_string_dynamics_t_resize(status, (*arguments), arguments->size + 2); } else { - f_macro_string_dynamics_resize(status, (*arguments), arguments->size + f_memory_default_allocation_step + 1); + f_macro_string_dynamics_t_resize(status, (*arguments), arguments->size + f_memory_default_allocation_step + 1); } if (F_status_is_error(status)) return status; diff --git a/level_2/fll_fss/c/fss.c b/level_2/fll_fss/c/fss.c index 48881f8..d2c15d2 100644 --- a/level_2/fll_fss/c/fss.c +++ b/level_2/fll_fss/c/fss.c @@ -138,7 +138,7 @@ extern "C" { return F_status_set_error(F_buffer_too_large); } - f_macro_string_dynamics_resize(status, (*value), (values[j]->used + content->used)); + f_macro_string_dynamics_t_resize(status, (*value), (values[j]->used + content->used)); if (F_status_is_error(status)) return status; if (indexs) { @@ -373,7 +373,7 @@ extern "C" { if (map_multi->value.used + contents.array[i].used - 1 > map_multi->value.size) { if (map_multi->value.used + contents.array[i].used - 1 > f_array_length_t_size) return F_status_set_error(F_buffer_too_large); - f_macro_string_dynamics_resize(status, map_multi->value, map_multi->value.used + contents.array[i].used - 1); + f_macro_string_dynamics_t_resize(status, map_multi->value, map_multi->value.used + contents.array[i].used - 1); if (F_status_is_error(status)) return status; } @@ -591,7 +591,7 @@ extern "C" { return F_status_set_error(F_buffer_too_large); } - f_macro_string_dynamics_resize(status, map_multi->value, map_multi->value.used + 1); + f_macro_string_dynamics_t_resize(status, map_multi->value, map_multi->value.used + 1); if (F_status_is_error(status)) return status; } @@ -834,7 +834,7 @@ extern "C" { return F_status_set_error(F_buffer_too_large); } - f_macro_string_dynamics_resize(status, (*values[j]), values[j]->used + 1); + f_macro_string_dynamics_t_resize(status, (*values[j]), values[j]->used + 1); if (F_status_is_error(status)) return status; if (indexs) { @@ -843,7 +843,7 @@ extern "C" { } } else { - f_macro_string_dynamics_resize(status, (*values[j]), values[j]->used + f_fss_default_allocation_step); + f_macro_string_dynamics_t_resize(status, (*values[j]), values[j]->used + f_fss_default_allocation_step); if (F_status_is_error(status)) return status; if (indexs) { diff --git a/level_2/fll_fss/c/fss_basic.c b/level_2/fll_fss/c/fss_basic.c index 15480e6..1b75d7c 100644 --- a/level_2/fll_fss/c/fss_basic.c +++ b/level_2/fll_fss/c/fss_basic.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_fll_fss_basic_read_ - f_return_status fll_fss_basic_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quoteds_t *quoted_objects) { + f_return_status fll_fss_basic_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quotes_t *quoted_objects) { #ifndef _di_level_2_parameter_checking_ if (!buffer) return F_status_set_error(F_parameter); if (!range) return F_status_set_error(F_parameter); @@ -19,7 +19,7 @@ extern "C" { bool found_data = F_false; - f_fss_quoted_t *quoted_object = 0; + f_fss_quote_t *quoted_object = 0; do { if (objects->used == objects->size) { @@ -30,7 +30,7 @@ extern "C" { if (F_status_is_error(status2)) return status2; if (quoted_objects) { - f_macro_fss_quoteds_t_resize(status2, (*quoted_objects), quoted_objects->used + f_fss_default_allocation_step); + f_macro_fss_quotes_t_resize(status2, (*quoted_objects), quoted_objects->used + f_fss_default_allocation_step); if (F_status_is_error(status2)) return status2; } } @@ -155,41 +155,35 @@ extern "C" { #endif // _di_fll_fss_basic_read_ #ifndef _di_fll_fss_basic_write_ - f_return_status fll_fss_basic_write(const f_string_static_t object, const f_string_statics_t contents, f_string_dynamic_t *destination) { + f_return_status fll_fss_basic_write(const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_string_dynamic_t *destination) { #ifndef _di_level_2_parameter_checking_ if (!destination) 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_t status = 0; - f_array_length_t current = 0; f_string_range_t range = f_macro_string_range_t_initialize(object.used); - status = fl_fss_basic_object_write(object, 0, &range, destination); + status = fl_fss_basic_object_write(object, quote, f_fss_complete_full, &range, destination); if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) { return status; } if (status == F_none || status == F_none_stop || status == F_none_eos || status == F_none_eol) { - if (contents.used > 0) { + if (content.used) { range.start = 0; - range.stop = contents.array[0].used - 1; + range.stop = content.used - 1; - status = fl_fss_basic_content_write(contents.array[0], &range, destination); - - if (F_status_is_error(status)) { - return status; - } + status = fl_fss_basic_content_write(content, f_fss_complete_full, &range, destination); + if (F_status_is_error(status)) return status; } else { - if (destination->used == destination->size) { - status = fl_string_dynamic_size_increase(f_fss_default_allocation_step_string, destination); + if (destination->used + 1 > destination->size) { + status = fl_string_dynamic_size_increase(f_fss_default_allocation_step, destination); if (F_status_is_error(status)) return status; } - destination->string[destination->used] = f_string_eol[0]; - destination->used++; + destination->string[destination->used++] = f_string_eol[0]; } } diff --git a/level_2/fll_fss/c/fss_basic.h b/level_2/fll_fss/c/fss_basic.h index 9406e85..f7d77a1 100644 --- a/level_2/fll_fss/c/fss_basic.h +++ b/level_2/fll_fss/c/fss_basic.h @@ -61,7 +61,7 @@ extern "C" { * Errors (with error bit) from: fl_fss_basic_object_read(). */ #ifndef _di_fll_fss_basic_read_ - extern f_return_status fll_fss_basic_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quoteds_t *quoted_objects); + extern f_return_status fll_fss_basic_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quotes_t *quoted_objects); #endif // _di_fll_fss_basic_read_ /** @@ -69,10 +69,13 @@ extern "C" { * * @param object * A string representing the object. - * @param contents - * An array of strings representing multiple content to write. - * @param buffer - * The buffer to write to. + * @param content + * A string representing the content. + * @param quote + * 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 destination + * The buffer where the content is written to. * * @return * F_none on success. @@ -90,7 +93,7 @@ extern "C" { * Errors (with error bit) from: fl_string_dynamic_size_increase(). */ #ifndef _di_fll_fss_basic_write_ - extern f_return_status fll_fss_basic_write(const f_string_static_t object, const f_string_statics_t contents, f_string_dynamic_t *buffer); + extern f_return_status fll_fss_basic_write(const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_string_dynamic_t *destination); #endif // _di_fll_fss_basic_write_ #ifdef __cplusplus diff --git a/level_2/fll_fss/c/fss_basic_list.c b/level_2/fll_fss/c/fss_basic_list.c index 44a35fd..0158aa3 100644 --- a/level_2/fll_fss/c/fss_basic_list.c +++ b/level_2/fll_fss/c/fss_basic_list.c @@ -134,7 +134,7 @@ extern "C" { #endif // _di_fll_fss_basic_list_read_ #ifndef _di_fll_fss_basic_list_write_ - f_return_status fll_fss_basic_list_write(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quoted_t quoted, f_string_dynamic_t *buffer) { + f_return_status fll_fss_basic_list_write(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quoted, f_string_dynamic_t *buffer) { #ifndef _di_level_2_parameter_checking_ if (!buffer) return F_status_set_error(F_parameter); if (contents.used > contents.size) return F_status_set_error(F_parameter); @@ -166,7 +166,7 @@ extern "C" { } else { if (buffer->used == buffer->size) { - status = fl_string_dynamic_size_increase(f_fss_default_allocation_step_string, buffer); + status = fl_string_dynamic_size_increase(f_fss_default_allocation_step, buffer); if (F_status_is_error(status)) return status; } diff --git a/level_2/fll_fss/c/fss_basic_list.h b/level_2/fll_fss/c/fss_basic_list.h index 1d07f19..9742bff 100644 --- a/level_2/fll_fss/c/fss_basic_list.h +++ b/level_2/fll_fss/c/fss_basic_list.h @@ -89,7 +89,7 @@ extern "C" { * Errors (with error bit) from: fl_string_dynamic_size_increase(). */ #ifndef _di_fll_fss_basic_list_write_ - extern f_return_status fll_fss_basic_list_write(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quoted_t quoted, f_string_dynamic_t *buffer); + extern f_return_status fll_fss_basic_list_write(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quoted, f_string_dynamic_t *buffer); #endif // _di_fll_fss_basic_list_write_ #ifdef __cplusplus diff --git a/level_2/fll_fss/c/fss_extended.c b/level_2/fll_fss/c/fss_extended.c index a0ce204..ce1b93a 100644 --- a/level_2/fll_fss/c/fss_extended.c +++ b/level_2/fll_fss/c/fss_extended.c @@ -5,7 +5,7 @@ extern "C" { #endif #ifndef _di_fll_fss_extended_read_ - f_return_status fll_fss_extended_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quoteds_t *quoted_objects, f_fss_quotedss_t *quoted_contents) { + f_return_status fll_fss_extended_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quotes_t *quoted_objects, f_fss_quotess_t *quoted_contents) { #ifndef _di_level_2_parameter_checking_ if (!buffer) return F_status_set_error(F_parameter); if (!range) return F_status_set_error(F_parameter); @@ -19,8 +19,8 @@ extern "C" { bool found_data = F_false; - f_fss_quoted_t *quoted_object = 0; - f_fss_quoteds_t *quoted_content = 0; + f_fss_quote_t *quoted_object = 0; + f_fss_quotes_t *quoted_content = 0; do { if (objects->used == objects->size) { @@ -31,12 +31,12 @@ extern "C" { if (F_status_is_error(status2)) return status2; if (quoted_objects) { - f_macro_fss_quoteds_t_resize(status2, (*quoted_objects), quoted_objects->used + f_fss_default_allocation_step); + f_macro_fss_quotes_t_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_t_resize(status2, (*quoted_contents), quoted_contents->used + f_fss_default_allocation_step); + f_macro_fss_quotess_t_resize(status2, (*quoted_contents), quoted_contents->used + f_fss_default_allocation_step); if (F_status_is_error(status2)) return status2; } } @@ -191,38 +191,38 @@ extern "C" { #endif // _di_fll_fss_extended_read_ #ifndef _di_fll_fss_extended_write_ - f_return_status fll_fss_extended_write(const f_string_static_t object, const f_string_statics_t contents, f_string_dynamic_t *buffer) { + f_return_status fll_fss_extended_write(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_string_dynamic_t *destination) { #ifndef _di_level_2_parameter_checking_ - if (!buffer) return F_status_set_error(F_parameter); - if (contents.used > contents.size) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_2_parameter_checking_ f_status_t status = 0; - f_array_length_t current = 0; f_string_range_t range = f_macro_string_range_t_initialize(object.used); - status = fl_fss_extended_object_write(object, 0, &range, buffer); + status = fl_fss_extended_object_write(object, quote, f_fss_complete_full, &range, destination); if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) { return status; } if (status == F_none || status == F_none_stop || status == F_none_eos || status == F_none_eol) { - while (current < contents.used) { + uint8_t complete = f_fss_complete_next; - range.start = 0; - range.stop = contents.array[current].used - 1; - status = fl_fss_extended_content_write(contents.array[current], 0, &range, buffer); + for (f_array_length_t i = 0; i < contents.used; i++) { - if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) { - return status; + if (i + 1 == contents.used) { + complete = f_fss_complete_end; } - current++; - } // while + range.start = 0; + range.stop = contents.array[i].used - 1; + + status = fl_fss_extended_content_write(contents.array[i], quote, complete, &range, destination); - // extended always ends each call with a space, and so the last position should be replaced with an eol. - buffer->string[buffer->used - 1] = f_string_eol[0]; + if (F_status_is_error(status)) { + return status; + } + } // for } return F_none; diff --git a/level_2/fll_fss/c/fss_extended.h b/level_2/fll_fss/c/fss_extended.h index dfb6208..0f499e3 100644 --- a/level_2/fll_fss/c/fss_extended.h +++ b/level_2/fll_fss/c/fss_extended.h @@ -62,7 +62,7 @@ extern "C" { * Errors (with error bit) from: fl_fss_extended_object_read(). */ #ifndef _di_fll_fss_extended_read_ - extern f_return_status fll_fss_extended_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quoteds_t *quoted_objects, f_fss_quotedss_t *quoted_contents); + extern f_return_status fll_fss_extended_read(f_string_dynamic_t *buffer, f_string_range_t *range, f_fss_objects_t *objects, f_fss_contents_t *contents, f_fss_quotes_t *quoted_objects, f_fss_quotess_t *quoted_contents); #endif // _di_fll_fss_extended_read_ /** @@ -72,8 +72,11 @@ extern "C" { * A string representing the object. * @param contents * An array of strings representing multiple content to write. - * @param buffer - * The buffer to write to. + * @param quote + * 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 destination + * The buffer where the content is written to. * * @return * F_none on success. @@ -91,7 +94,7 @@ extern "C" { * Errors (with error bit) from: fl_string_dynamic_size_increase(). */ #ifndef _di_fll_fss_extended_write_ - extern f_return_status fll_fss_extended_write(const f_string_static_t object, const f_string_statics_t contents, f_string_dynamic_t *buffer); + extern f_return_status fll_fss_extended_write(const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_string_dynamic_t *destination); #endif // _di_fll_fss_extended_write_ #ifdef __cplusplus diff --git a/level_2/fll_fss/c/fss_extended_list.c b/level_2/fll_fss/c/fss_extended_list.c index 2b93cbf..8c25ea6 100644 --- a/level_2/fll_fss/c/fss_extended_list.c +++ b/level_2/fll_fss/c/fss_extended_list.c @@ -145,7 +145,7 @@ extern "C" { } else { if (buffer->used == buffer->size) { - status = fl_string_dynamic_size_increase(f_fss_default_allocation_step_string, buffer); + status = fl_string_dynamic_size_increase(f_fss_default_allocation_step, buffer); if (F_status_is_error(status)) return status; } diff --git a/level_2/fll_program/c/program.c b/level_2/fll_program/c/program.c index 4a83f73..7f1a087 100644 --- a/level_2/fll_program/c/program.c +++ b/level_2/fll_program/c/program.c @@ -158,7 +158,7 @@ extern "C" { status = F_none; } else { - f_macro_memory_structure_macro_increment(status, (*destination), 1, f_console_default_allocation_step, f_macro_string_dynamics_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*destination), 1, f_console_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); if (F_status_is_error(status)) break; destination->array[destination->used] = ripped; @@ -232,7 +232,7 @@ extern "C" { } else { if (destination->used == destination->size) { - f_macro_string_dynamics_resize(status, (*destination), destination->size + f_console_default_allocation_step); + f_macro_string_dynamics_t_resize(status, (*destination), destination->size + f_console_default_allocation_step); if (F_status_is_error(status)) return status; } diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index fd53dbf..4d1f06a 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -1164,10 +1164,10 @@ extern "C" { return; } - f_macro_string_dynamics_resize(*status, names, names.used + data_build.setting.environment.used); + f_macro_string_dynamics_t_resize(*status, names, names.used + data_build.setting.environment.used); if (F_status_is_error(*status)) { - fll_error_print(data.error, F_status_set_fine(*status), "f_macro_string_dynamics_resize", F_true); + fll_error_print(data.error, F_status_set_fine(*status), "f_macro_string_dynamics_t_resize", F_true); f_macro_string_dynamic_t_delete_simple(part); f_macro_string_dynamics_t_delete_simple(names); @@ -1214,7 +1214,7 @@ extern "C" { if (F_status_is_error(*status)) { if (F_status_set_fine(*status) == F_memory_reallocation) { - function = "f_macro_string_dynamics_resize"; + function = "f_macro_string_dynamics_t_resize"; break; } } @@ -1225,21 +1225,21 @@ extern "C" { *status = F_status_set_error(F_buffer_too_large); } else { - f_macro_string_dynamics_resize(*status, environment->names, environment->names.size + 1); + f_macro_string_dynamics_t_resize(*status, environment->names, environment->names.size + 1); } } else { - f_macro_string_dynamics_resize(*status, environment->names, environment->names.size + f_memory_default_allocation_step); + f_macro_string_dynamics_t_resize(*status, environment->names, environment->names.size + f_memory_default_allocation_step); } if (F_status_is_error(*status)) { - function = "f_macro_string_dynamics_resize"; + function = "f_macro_string_dynamics_t_resize"; break; } - f_macro_string_dynamics_resize(*status, environment->values, environment->names.size); + f_macro_string_dynamics_t_resize(*status, environment->values, environment->names.size); if (F_status_is_error(*status)) { - function = "f_macro_string_dynamics_resize"; + function = "f_macro_string_dynamics_t_resize"; break; } } diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index 781a019..b5b0f8b 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -281,7 +281,7 @@ extern "C" { 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, 0, &data_make->fakefile.array[data_make->fakefile.used].quotedss); + *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, &data_make->fakefile.array[data_make->fakefile.used].quotess); if (F_status_is_error(*status)) { fake_print_error_fss(data, F_status_set_fine(*status), "fll_fss_extended_read", data.file_data_build_fakefile.string, content_range, F_true); @@ -1136,7 +1136,7 @@ extern "C" { #endif // _di_fake_make_operate_ #ifndef _di_fake_make_operate_expand_ - void fake_make_operate_expand(const fake_data_t data, const f_string_range_t section_name, const f_array_length_t operation, const f_string_static_t operation_name, const f_fss_content_t content, const f_fss_quoteds_t quoteds, fake_make_data_t *data_make, f_string_dynamics_t *arguments, f_status_t *status) { + void fake_make_operate_expand(const fake_data_t data, const f_string_range_t section_name, const f_array_length_t operation, const f_string_static_t operation_name, const f_fss_content_t content, const f_fss_quotes_t quotes, fake_make_data_t *data_make, f_string_dynamics_t *arguments, f_status_t *status) { if (F_status_is_error(*status)) return; if (!content.used) return; @@ -1370,7 +1370,7 @@ extern "C" { unmatched = F_false; if (parameter->array[k].value.used) { - if (quoteds.array[i]) { + if (quotes.array[i]) { for (l = 0; l < parameter->array[k].value.used; l++) { if (l > 0) { @@ -1433,7 +1433,7 @@ extern "C" { if (F_status_is_error(*status)) break; if (unmatched) { - *status = fake_make_operate_expand_build(data, quoteds.array[i], iki_content.array[j], data_make, arguments); + *status = fake_make_operate_expand_build(data, quotes.array[i], iki_content.array[j], data_make, arguments); if (F_status_is_error(*status)) { fll_error_print(data_make->error, F_status_set_fine(*status), "fake_make_operate_expand_build", F_true); @@ -1442,7 +1442,7 @@ extern "C" { } } else if (define_is && data_make->setting_make.load_build) { - *status = fake_make_operate_expand_environment(data, quoteds.array[i], iki_content.array[j], data_make, arguments); + *status = fake_make_operate_expand_environment(data, quotes.array[i], iki_content.array[j], data_make, arguments); if (F_status_is_error(*status)) { fll_error_print(data_make->error, F_status_set_fine(*status), "fake_make_operate_expand_environment", F_true); @@ -1515,7 +1515,7 @@ extern "C" { #endif // _di_fake_make_operate_expand_ #ifndef _di_fake_make_operate_expand_build_ - f_return_status fake_make_operate_expand_build(const fake_data_t data, const f_fss_quoted_t quoted, const f_string_range_t range_name, fake_make_data_t *data_make, f_string_dynamics_t *arguments) { + f_return_status fake_make_operate_expand_build(const fake_data_t data, const f_fss_quote_t quoted, const f_string_range_t range_name, fake_make_data_t *data_make, f_string_dynamics_t *arguments) { f_status_t status = F_none; f_string_dynamic_t value = f_string_dynamic_t_initialize; @@ -1796,7 +1796,7 @@ extern "C" { #endif // _di_fake_make_operate_expand_build_ #ifndef _di_fake_make_operate_expand_environment_ - f_return_status fake_make_operate_expand_environment(const fake_data_t data, const f_fss_quoted_t quoted, const f_string_range_t range_name, fake_make_data_t *data_make, f_string_dynamics_t *arguments) { + f_return_status fake_make_operate_expand_environment(const fake_data_t data, const f_fss_quote_t quoted, const f_string_range_t range_name, fake_make_data_t *data_make, f_string_dynamics_t *arguments) { f_status_t status = F_none; f_string_dynamic_t value = f_string_dynamic_t_initialize; @@ -2052,7 +2052,7 @@ extern "C" { if (F_status_is_error_not(*status)) { operations[i] = operation; - fake_make_operate_expand(data, section->name, operation, *operation_name, section->contents.array[i], section->quotedss.array[i], data_make, &arguments[i], status); + fake_make_operate_expand(data, section->name, operation, *operation_name, section->contents.array[i], section->quotess.array[i], data_make, &arguments[i], status); } if (operation_if == fake_make_operation_if_type_true_next) { @@ -3608,7 +3608,7 @@ extern "C" { return; } else if (F_status_is_error(*status)) { - fll_error_print(data_make->error, F_status_set_fine(*status), "f_macro_string_dynamics_resize", F_true); + fll_error_print(data_make->error, F_status_set_fine(*status), "f_macro_string_dynamics_t_resize", F_true); return; } } @@ -3740,14 +3740,14 @@ extern "C" { // pre-allocate name and value if necessary. if (data_make->environment.names.used + 1 > data_make->environment.names.size) { - f_macro_string_dynamics_resize(status, data_make->environment.names, data_make->environment.names.size + f_memory_default_allocation_step); + f_macro_string_dynamics_t_resize(status, data_make->environment.names, data_make->environment.names.size + f_memory_default_allocation_step); if (F_status_is_error_not(status)) { - f_macro_string_dynamics_resize(status, data_make->environment.values, data_make->environment.values.size + f_memory_default_allocation_step); + f_macro_string_dynamics_t_resize(status, data_make->environment.values, data_make->environment.values.size + f_memory_default_allocation_step); } if (F_status_is_error(status)) { - fll_error_print(data_make->error, F_status_set_fine(status), "f_macro_string_dynamics_resize", F_true); + fll_error_print(data_make->error, F_status_set_fine(status), "f_macro_string_dynamics_t_resize", F_true); return status; } } diff --git a/level_3/fake/c/private-make.h b/level_3/fake/c/private-make.h index 1a5956d..4acebfb 100644 --- a/level_3/fake/c/private-make.h +++ b/level_3/fake/c/private-make.h @@ -568,7 +568,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fake_make_operate_expand_ - extern void fake_make_operate_expand(const fake_data_t data, const f_string_range_t section_name, const f_array_length_t operation, const f_string_static_t operation_name, const f_fss_content_t content, const f_fss_quoteds_t quoteds, fake_make_data_t *data_make, f_string_dynamics_t *arguments, f_status_t *status) f_gcc_attribute_visibility_internal; + extern void fake_make_operate_expand(const fake_data_t data, const f_string_range_t section_name, const f_array_length_t operation, const f_string_static_t operation_name, const f_fss_content_t content, const f_fss_quotes_t quoteds, fake_make_data_t *data_make, f_string_dynamics_t *arguments, f_status_t *status) f_gcc_attribute_visibility_internal; #endif // _di_fake_make_operate_expand_ /** @@ -592,7 +592,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fake_make_operate_expand_environment_ - extern f_return_status fake_make_operate_expand_environment(const fake_data_t data, const f_fss_quoted_t quoted, const f_string_range_t range_name, fake_make_data_t *data_make, f_string_dynamics_t *arguments) f_gcc_attribute_visibility_internal; + extern f_return_status fake_make_operate_expand_environment(const fake_data_t data, const f_fss_quote_t quoted, const f_string_range_t range_name, fake_make_data_t *data_make, f_string_dynamics_t *arguments) f_gcc_attribute_visibility_internal; #endif // _di_fake_make_operate_expand_environment_ /** @@ -616,7 +616,7 @@ extern "C" { * Status codes (with error bit) are returned on any problem. */ #ifndef _di_fake_make_operate_expand_build_ - extern f_return_status fake_make_operate_expand_build(const fake_data_t data, const f_fss_quoted_t quoted, const f_string_range_t range_name, fake_make_data_t *data_make, f_string_dynamics_t *arguments) f_gcc_attribute_visibility_internal; + extern f_return_status fake_make_operate_expand_build(const fake_data_t data, const f_fss_quote_t quoted, const f_string_range_t range_name, fake_make_data_t *data_make, f_string_dynamics_t *arguments) f_gcc_attribute_visibility_internal; #endif // _di_fake_make_operate_expand_build_ /** diff --git a/level_3/firewall/c/firewall.c b/level_3/firewall/c/firewall.c index 09fdcd6..741d612 100644 --- a/level_3/firewall/c/firewall.c +++ b/level_3/firewall/c/firewall.c @@ -220,7 +220,7 @@ extern "C" { } // for } - f_macro_string_dynamics_resize(status, parameters, 7); + f_macro_string_dynamics_t_resize(status, parameters, 7); if (F_status_is_error(status)) { fl_color_print(data->error.to.stream, data->context.set.error, "%sUnable to allocate memory.%c", fll_error_print_error, f_string_eol[0]); diff --git a/level_3/firewall/c/private-firewall.c b/level_3/firewall/c/private-firewall.c index 687b069..338c40b 100644 --- a/level_3/firewall/c/private-firewall.c +++ b/level_3/firewall/c/private-firewall.c @@ -696,7 +696,7 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con status = F_none; if (arguments.used + 2 > arguments.size) { - f_macro_string_dynamics_resize(status, arguments, arguments.size + 2); + f_macro_string_dynamics_t_resize(status, arguments, arguments.size + 2); } if (F_status_is_error(status)) { @@ -968,7 +968,7 @@ f_return_status firewall_create_custom_chains(firewall_reserved_chains_t *reserv if (new_chain) { if (data->chains.used == data->chains.size) { - f_macro_string_dynamics_resize(status, data->chains, data->chains.used + firewall_default_allocation_step); + f_macro_string_dynamics_t_resize(status, data->chains, data->chains.used + firewall_default_allocation_step); if (F_status_is_error(status)) { f_macro_string_dynamics_t_delete_simple(arguments); diff --git a/level_3/firewall/c/private-firewall.h b/level_3/firewall/c/private-firewall.h index a432a5a..5c361b8 100644 --- a/level_3/firewall/c/private-firewall.h +++ b/level_3/firewall/c/private-firewall.h @@ -88,7 +88,7 @@ typedef struct { // TODO: also report: fl_color_print(data.error.to.stream, data.context.set.error, "CRITICAL ERROR: Unable to allocate memory.%c", f_string_eol[0]); #define firewall_macro_append_argument_to_arguments(status, arguments, argument) \ if (arguments.used == arguments.size) { \ - f_macro_string_dynamics_resize(status, arguments, arguments.used + firewall_default_allocation_step); \ + f_macro_string_dynamics_t_resize(status, arguments, arguments.used + firewall_default_allocation_step); \ \ if (F_status_is_error(status)) break; \ } \ diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.c b/level_3/fss_basic_list_write/c/fss_basic_list_write.c index 66cbe79..d579a82 100644 --- a/level_3/fss_basic_list_write/c/fss_basic_list_write.c +++ b/level_3/fss_basic_list_write/c/fss_basic_list_write.c @@ -191,7 +191,7 @@ extern "C" { } } - f_fss_quoted_t quoted = f_fss_delimit_quote_double; + f_fss_quote_t quoted = f_fss_delimit_quote_double; if (F_status_is_error_not(status)) { if (data->parameters[fss_basic_list_write_parameter_double].result == f_console_result_found) { diff --git a/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c b/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c index 664b62d..eb3b45f 100644 --- a/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c +++ b/level_3/fss_basic_list_write/c/private-fss_basic_list_write.c @@ -36,7 +36,7 @@ extern "C" { #endif // _di_fss_basic_list_write_error_parameter_value_missing_print_ #ifndef _di_fss_basic_list_write_process_ - f_return_status fss_basic_list_write_process(const fss_basic_list_write_data_t data, const f_file_t output, const f_string_static_t object, const f_string_static_t content, const f_fss_quoted_t quoted, f_string_dynamic_t *buffer) { + f_return_status fss_basic_list_write_process(const fss_basic_list_write_data_t data, const f_file_t output, const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quoted, f_string_dynamic_t *buffer) { f_status_t status = F_none; f_string_range_t range = f_macro_string_range_t_initialize(object.used); diff --git a/level_3/fss_basic_list_write/c/private-fss_basic_list_write.h b/level_3/fss_basic_list_write/c/private-fss_basic_list_write.h index 4224ae4..2e9fcbd 100644 --- a/level_3/fss_basic_list_write/c/private-fss_basic_list_write.h +++ b/level_3/fss_basic_list_write/c/private-fss_basic_list_write.h @@ -66,7 +66,7 @@ extern "C" { * F_failure (with error bit) for any othe failure. */ #ifndef _di_fss_basic_list_write_process_ - extern f_return_status fss_basic_list_write_process(const fss_basic_list_write_data_t data, const f_file_t output, const f_string_static_t object, const f_string_static_t content, const f_fss_quoted_t quoted, f_string_dynamic_t *buffer) f_gcc_attribute_visibility_internal; + extern f_return_status fss_basic_list_write_process(const fss_basic_list_write_data_t data, const f_file_t output, const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quoted, f_string_dynamic_t *buffer) f_gcc_attribute_visibility_internal; #endif // _di_fss_basic_list_write_process_ #ifdef __cplusplus diff --git a/level_3/fss_basic_write/c/fss_basic_write.c b/level_3/fss_basic_write/c/fss_basic_write.c index 38e7ef7..e72bf60 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.c +++ b/level_3/fss_basic_write/c/fss_basic_write.c @@ -191,18 +191,18 @@ extern "C" { } } - f_fss_quoted_t quoted = f_fss_delimit_quote_double; + f_fss_quote_t quote = f_fss_delimit_quote_double; if (F_status_is_error_not(status)) { if (data->parameters[fss_basic_write_parameter_double].result == f_console_result_found) { if (data->parameters[fss_basic_write_parameter_single].result == f_console_result_found) { if (data->parameters[fss_basic_write_parameter_double].location < data->parameters[fss_basic_write_parameter_single].location) { - quoted = f_fss_delimit_quote_single; + quote = f_fss_delimit_quote_single; } } } else if (data->parameters[fss_basic_write_parameter_single].result == f_console_result_found) { - quoted = f_fss_delimit_quote_single; + quote = f_fss_delimit_quote_single; } } @@ -294,7 +294,7 @@ extern "C" { } } - status = fss_basic_write_process(*data, output, object, content, quoted, &buffer); + status = fss_basic_write_process(*data, output, object, content, quote, &buffer); if (F_status_is_error(status)) break; fprintf(output.stream, "%c", f_string_eol[0]); @@ -376,7 +376,7 @@ extern "C" { } } - status = fss_basic_write_process(*data, output, object, content, quoted, &buffer); + status = fss_basic_write_process(*data, output, object, content, quote, &buffer); if (F_status_is_error(status)) break; fprintf(output.stream, "%c", f_string_eol[0]); @@ -430,7 +430,7 @@ extern "C" { object.used = strnlen(object.string, f_console_length_size); object.size = object.used; - status = fss_basic_write_process(*data, output, object, content, quoted, &buffer); + status = fss_basic_write_process(*data, output, object, content, quote, &buffer); if (F_status_is_error(status)) break; fprintf(output.stream, "%c", f_string_eol[0]); @@ -445,7 +445,7 @@ extern "C" { content.used = strnlen(content.string, f_console_length_size); content.size = content.used; - status = fss_basic_write_process(*data, output, object, content, quoted, &buffer); + status = fss_basic_write_process(*data, output, object, content, quote, &buffer); if (F_status_is_error(status)) break; fprintf(output.stream, "%c", f_string_eol[0]); @@ -463,7 +463,7 @@ extern "C" { content.used = strnlen(content.string, f_console_length_size); content.size = content.used; - status = fss_basic_write_process(*data, output, object, content, quoted, &buffer); + status = fss_basic_write_process(*data, output, object, content, quote, &buffer); if (F_status_is_error(status)) break; fprintf(output.stream, "%c", f_string_eol[0]); diff --git a/level_3/fss_basic_write/c/fss_basic_write.h b/level_3/fss_basic_write/c/fss_basic_write.h index 2bdfcb7..1ba6c04 100644 --- a/level_3/fss_basic_write/c/fss_basic_write.h +++ b/level_3/fss_basic_write/c/fss_basic_write.h @@ -34,6 +34,7 @@ // fll-2 includes #include +#include #include #include diff --git a/level_3/fss_basic_write/c/private-fss_basic_write.c b/level_3/fss_basic_write/c/private-fss_basic_write.c index cd35d00..8cfde33 100644 --- a/level_3/fss_basic_write/c/private-fss_basic_write.c +++ b/level_3/fss_basic_write/c/private-fss_basic_write.c @@ -36,45 +36,13 @@ extern "C" { #endif // _di_fss_basic_write_error_parameter_value_missing_print_ #ifndef _di_fss_basic_write_process_ - f_return_status fss_basic_write_process(const fss_basic_write_data_t data, const f_file_t output, const f_string_static_t object, const f_string_static_t content, const f_fss_quoted_t quoted, f_string_dynamic_t *buffer) { - f_status_t status = F_none; - - f_string_range_t range = f_macro_string_range_t_initialize(object.used); - + f_return_status fss_basic_write_process(const fss_basic_write_data_t data, const f_file_t output, const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_string_dynamic_t *buffer) { buffer->used = 0; - if (data.parameters[fss_basic_write_parameter_object].result == f_console_result_found) { - - status = fl_fss_basic_object_write(object, quoted, &range, buffer); - - if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) { - fll_error_print(data.error, F_status_set_fine(status), "fl_fss_basic_object_write", F_true); - return F_status_set_error(status); - } - } - - if (data.parameters[fss_basic_write_parameter_content].result == f_console_result_found) { - if (content.used) { - range.start = 0; - range.stop = content.used; - } - else { - range.start = 1; - range.stop = 0; - } - - status = fl_fss_basic_content_write(content, &range, buffer); - - if (F_status_is_error(status) || data.parameters[fss_basic_write_parameter_content].result == f_console_result_found) { - fll_error_print(data.error, F_status_set_fine(status), "fl_fss_basic_content_write", F_true); - return F_status_set_error(status); - } - } - - status = fl_string_dynamic_terminate(buffer); + f_status_t status = fll_fss_basic_write(object, content, quote, buffer); if (F_status_is_error(status)) { - fll_error_print(data.error, F_status_set_fine(status), "fl_string_dynamic_terminate", F_true); + fll_error_print(data.error, F_status_set_fine(status), "fll_fss_basic_write", F_true); return F_status_set_error(status); } diff --git a/level_3/fss_basic_write/c/private-fss_basic_write.h b/level_3/fss_basic_write/c/private-fss_basic_write.h index f5a9cc2..687ed35 100644 --- a/level_3/fss_basic_write/c/private-fss_basic_write.h +++ b/level_3/fss_basic_write/c/private-fss_basic_write.h @@ -55,7 +55,7 @@ extern "C" { * The object to validate and print. * @param content * The content to escape and print. - * @param quoted + * @param quote * The quote character to use. * This is either single our double quote. * @param buffer @@ -66,7 +66,7 @@ extern "C" { * F_failure (with error bit) for any othe failure. */ #ifndef _di_fss_basic_write_process_ - extern f_return_status fss_basic_write_process(const fss_basic_write_data_t data, const f_file_t output, const f_string_static_t object, const f_string_static_t content, const f_fss_quoted_t quoted, f_string_dynamic_t *buffer) f_gcc_attribute_visibility_internal; + extern f_return_status fss_basic_write_process(const fss_basic_write_data_t data, const f_file_t output, const f_string_static_t object, const f_string_static_t content, const f_fss_quote_t quote, f_string_dynamic_t *buffer) f_gcc_attribute_visibility_internal; #endif // _di_fss_basic_write_process_ #ifdef __cplusplus diff --git a/level_3/fss_extended_write/c/fss_extended_write.c b/level_3/fss_extended_write/c/fss_extended_write.c index 9d55cc2..6663771 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -191,18 +191,18 @@ extern "C" { } } - f_fss_quoted_t quoted = f_fss_delimit_quote_double; + f_fss_quote_t quote = f_fss_delimit_quote_double; if (F_status_is_error_not(status)) { if (data->parameters[fss_extended_write_parameter_double].result == f_console_result_found) { if (data->parameters[fss_extended_write_parameter_single].result == f_console_result_found) { if (data->parameters[fss_extended_write_parameter_double].location < data->parameters[fss_extended_write_parameter_single].location) { - quoted = f_fss_delimit_quote_single; + quote = f_fss_delimit_quote_single; } } } else if (data->parameters[fss_extended_write_parameter_single].result == f_console_result_found) { - quoted = f_fss_delimit_quote_single; + quote = f_fss_delimit_quote_single; } } @@ -294,7 +294,7 @@ extern "C" { } } - status = fss_extended_write_process(*data, output, object, content, quoted, &buffer); + status = fss_extended_write_process(*data, output, object, content, quote, &buffer); if (F_status_is_error(status)) break; fprintf(output.stream, "%c", f_string_eol[0]); @@ -376,7 +376,7 @@ extern "C" { } } - status = fss_extended_write_process(*data, output, object, content, quoted, &buffer); + status = fss_extended_write_process(*data, output, object, content, quote, &buffer); if (F_status_is_error(status)) break; fprintf(output.stream, "%c", f_string_eol[0]); @@ -430,7 +430,7 @@ extern "C" { object.used = strnlen(object.string, f_console_length_size); object.size = object.used; - status = fss_extended_write_process(*data, output, object, content, quoted, &buffer); + status = fss_extended_write_process(*data, output, object, content, quote, &buffer); if (F_status_is_error(status)) break; fprintf(output.stream, "%c", f_string_eol[0]); @@ -445,7 +445,7 @@ extern "C" { content.used = strnlen(content.string, f_console_length_size); content.size = content.used; - status = fss_extended_write_process(*data, output, object, content, quoted, &buffer); + status = fss_extended_write_process(*data, output, object, content, quote, &buffer); if (F_status_is_error(status)) break; fprintf(output.stream, "%c", f_string_eol[0]); @@ -463,7 +463,7 @@ extern "C" { content.used = strnlen(content.string, f_console_length_size); content.size = content.used; - status = fss_extended_write_process(*data, output, object, content, quoted, &buffer); + status = fss_extended_write_process(*data, output, object, content, quote, &buffer); if (F_status_is_error(status)) break; fprintf(output.stream, "%c", f_string_eol[0]); diff --git a/level_3/fss_extended_write/c/fss_extended_write.h b/level_3/fss_extended_write/c/fss_extended_write.h index 523b478..fc69d49 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.h +++ b/level_3/fss_extended_write/c/fss_extended_write.h @@ -33,6 +33,7 @@ // fll-2 includes #include +#include #include #include diff --git a/level_3/fss_extended_write/c/private-fss_extended_write.c b/level_3/fss_extended_write/c/private-fss_extended_write.c index 9ba4fe2..1a8cac7 100644 --- a/level_3/fss_extended_write/c/private-fss_extended_write.c +++ b/level_3/fss_extended_write/c/private-fss_extended_write.c @@ -36,45 +36,13 @@ extern "C" { #endif // _di_fss_extended_write_error_parameter_value_missing_print_ #ifndef _di_fss_extended_write_process_ - f_return_status fss_extended_write_process(const fss_extended_write_data_t data, const f_file_t output, const f_string_static_t object, const f_string_static_t content, const f_fss_quoted_t quoted, f_string_dynamic_t *buffer) { - f_status_t status = F_none; - - f_string_range_t range = f_macro_string_range_t_initialize(object.used); - + f_return_status fss_extended_write_process(const fss_extended_write_data_t data, const f_file_t output, const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_string_dynamic_t *buffer) { buffer->used = 0; - if (data.parameters[fss_extended_write_parameter_object].result == f_console_result_found) { - - status = fl_fss_extended_object_write(object, quoted, &range, buffer); - - if (F_status_is_error(status) || status == F_data_not_stop || status == F_data_not_eos) { - fll_error_print(data.error, F_status_set_fine(status), "fl_fss_basic_object_write", F_true); - return F_status_set_error(status); - } - } - - if (data.parameters[fss_extended_write_parameter_content].result == f_console_result_found) { - if (content.used) { - range.start = 0; - range.stop = content.used; - } - else { - range.start = 1; - range.stop = 0; - } - - status = fl_fss_extended_content_write(content, quoted, &range, buffer); - - if (F_status_is_error(status) || data.parameters[fss_extended_write_parameter_content].result == f_console_result_found) { - fll_error_print(data.error, F_status_set_fine(status), "fl_fss_basic_content_write", F_true); - return F_status_set_error(status); - } - } - - status = fl_string_dynamic_terminate(buffer); + f_status_t status = fll_fss_extended_write(object, contents, quote, buffer); if (F_status_is_error(status)) { - fll_error_print(data.error, F_status_set_fine(status), "fl_string_dynamic_terminate", F_true); + fll_error_print(data.error, F_status_set_fine(status), "fll_fss_extended_write", F_true); return F_status_set_error(status); } diff --git a/level_3/fss_extended_write/c/private-fss_extended_write.h b/level_3/fss_extended_write/c/private-fss_extended_write.h index 4f06190..c81e9b3 100644 --- a/level_3/fss_extended_write/c/private-fss_extended_write.h +++ b/level_3/fss_extended_write/c/private-fss_extended_write.h @@ -53,9 +53,9 @@ extern "C" { * The file to output to. * @param object * The object to validate and print. - * @param content - * The content to escape and print. - * @param quoted + * @param contents + * An array of content to escape and print. + * @param quote * The quote character to use. * This is either single our double quote. * @param buffer @@ -66,7 +66,7 @@ extern "C" { * F_failure (with error bit) for any othe failure. */ #ifndef _di_fss_extended_write_process_ - extern f_return_status fss_extended_write_process(const fss_extended_write_data_t data, const f_file_t output, const f_string_static_t object, const f_string_static_t content, const f_fss_quoted_t quoted, f_string_dynamic_t *buffer) f_gcc_attribute_visibility_internal; + extern f_return_status fss_extended_write_process(const fss_extended_write_data_t data, const f_file_t output, const f_string_static_t object, const f_string_statics_t contents, const f_fss_quote_t quote, f_string_dynamic_t *buffer) f_gcc_attribute_visibility_internal; #endif // _di_fss_extended_write_process_ #ifdef __cplusplus diff --git a/level_3/iki_read/c/private-iki_read.c b/level_3/iki_read/c/private-iki_read.c index 1f8bdc4..e34a1a6 100644 --- a/level_3/iki_read/c/private-iki_read.c +++ b/level_3/iki_read/c/private-iki_read.c @@ -279,7 +279,7 @@ extern "C" { } // for if (name_missed) { - f_macro_memory_structure_macro_increment(status, names, 1, f_iki_default_allocation_step, f_macro_string_dynamics_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, names, 1, f_iki_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); if (F_status_is_error(status)) { fll_error_print(data->error, F_status_set_fine(status), "iki_read_process_buffer_ranges_whole", F_true); diff --git a/specifications/fss-0000.txt b/specifications/fss-0000.txt index ae4adf1..d176803 100644 --- a/specifications/fss-0000.txt +++ b/specifications/fss-0000.txt @@ -1,22 +1,24 @@ # fss-0002 Featureless Settings Specification: 0000 - Basic: - Each Object starts at the beginning of a line and whitespace to the left of the Object is not treated as an object. + Each Object starts at the beginning of a line and whitespace to the left of the Object is not treated as part of the object. Whitespace separates an Object from the Content. An Object may be followed by a newline, in which case means that the Object has no Content. Content exists on the same line as the Object. Content consists of everything following the first non-whitespace character until the newline. Content includes trailing whitespace before newline is reached. - Content does not include the leading whitespace. + Content does not include any of the leading whitespace. No delimits are supported in the content. + If only printing whitespace follows a valid Object, that Object is considered to have no Content. + Key\: \s = whitespace, except newline. \b = either whitespace or printable, except newline. - \q = non-whitespace or quoteded whitespace, no whitespace outside of quotes. + \q = non-whitespace or quoted whitespace with no whitespace outside of the quotes. \n = newline. - * = 0 or more occurrences. + * = zero or more occurrences. + = one or more occurrences. Structure\: diff --git a/specifications/fss.txt b/specifications/fss.txt index 8c8beac..71fa531 100644 --- a/specifications/fss.txt +++ b/specifications/fss.txt @@ -5,47 +5,48 @@ Featureless Settings Specifications: This specification defines the following\: - Will consist of numerous different kinds of specification files, depending on the type of information stored. - - As with the practice of "#!/bin/bash", the setting files MUST have the following: "# fss-????" format, such as "# fss-0001". - - Multiple sub-standards may be appended to the FSS header, using the same format structure, such as supporting IKI: "# fss-???? iki-????" (or in theory, HTML5, such as: "# fss-???? html-0005"). + - As with the practice of "#!/bin/bash", the setting files SHOULD have the following: "# fss-????" format, such as "# fss-0001". + - Multiple sub-standards may be appended to the FSS header, using the same format structure, such as supporting IKI: "# fss-0000 iki-0000" or HTML5: "# fss-0000 html-0005". - With the ? representing the (hexadecimal/base-16) number that represents the particular specification structure. - - All settings specifications must avoid any form of noise, relative to the data being stored. + - All settings specifications SHOULD avoid any form of noise, relative to the data being stored. - ie: XML would be considered anti-KISS due to the extreme level of noise generated by the XML language (not easy to read). - - The settings files are setup so that they produce easy readability on both the console and in a GUI. + - The settings files are setup so that they should (reasonably) produce easy readability on both the console and in a GUI. - The basic FSS specifications consists of two main parts: an "object" and the "content". - - Object: considered the name or identifier of some particular data. - - Content: the data associated with a given Object; all Content must have an associated Object. + The most basic form of FSS specifications consist of two main parts: an "object" and the "content". + - Object: considered the name or identifier of some particular data; Objects do not need an associated Content. + - Content: the data associated with a given Object; all Content MUST have an associated Object. Objects and Contents can include any characters allowed by the specifications. - The specification may choose, however, how a given Content is represented and parsed. + The specification may choose how a given Object or Content are represented and parsed. For example, in FSS-0000 (Basic), Content is treated as a single item whereas in FSS-0001 (Extended), Content is broken apart in multiple sub parts. - In all cases, specifications that separate Objects from Contents using whitespace (not newlines), the first whitespace separating the Object and Content must not be consided part of the Object nor part of the Content. - All spaces after that may be part of the Content as allowed by the given specification. + In all cases, specifications that separate Objects from Contents using whitespace, the first whitespace separating the Object and Content must not be considered part of the Object nor part of the Content. + All spaces after the first separating whitespace is generally ignored until the first non-whitespace character is found, unless otherwise specified. - Unless explicitly defined by the specification, all specifications are newline sensitive ('\n' only). + Unless otherwise specified, all specifications are newline sensitive ('\n' only). Newline characters are only '\n' and are never anything else ('\r' is not considered newline in any manner). - Whitespaces characters that are printable, such as tabs and spaces must be considered the same type. - Non-printing whitespaces characters (zero-width characters) are ignored or are treated as placeholders for processing (this includes zero-width punctutations characters and similar). + Whitespaces characters that are printable, such as tabs and spaces, must be considered the same type for the purposes of parsing. + Non-printing whitespaces characters (zero-width characters) are ignored, are treated as placeholders for processing, or are considered part of the appropriate character if they are Unicode combining characters (this includes zero-width punctutations characters and similar). In terms of processing, it is recommended that the NULL character is not considered the end of a string, but this is only a suggestion. - Unless explicitly defined, newlines designate the start of a potential new Object or the potential end of some Content. + Unless otherwise specified, newlines designate the potential start (or end) of an Object or Content. - Unless explicitly defined, whitespace may exist to the left of the start of objects. + Unless otherwise specified, whitespace may exist to the left of the start of Objects. + Unless otherwise specified, whitespace may exist to the right of the end of Objects, but only if that given Object is properly quoted and the whitespace is after the terminating quote but before any Content. - Unless explicitly defined, whitespace immediately both before and after an object is not considered part of an object. - This simplifies identifying the object, use quoted objects to support whitespace before/after an object. + Unless otherwise specified, whitespace immediately both before (and after, outside of the terminating quote) an Object is not considered part of the Object. + This simplifies identifying the object, use quoted Objects to support whitespace before/after an object for styling purposes. - Unless explicitly defined, quotes may only be either a single quote (') or a double quote (") and only a backslash '\' may be used as a delimiter. + Unless otherwise specified, quotes may only be either a single quote (') or a double quote (") and only a backslash '\' may be used as a delimiter. For example, FSS-0000 (Basic)\: \"Object 1" has content starting at the '1', with an Object named '"Object'. \\"Object 1" has content starting at the '1', with an Object named '\"Object'. "Object 1\" is an unterminated object due to the escaped closing quote. "Object 1\\" has content starting at the 'has', with an Object named "Object 1\". - Unless explicitly defined by the specification, character/data delimits are performed only when required and not unilaterally. - In the case of Objects, delimits would only apply when that object could be potentially identified as an object when it otherwise should not. - For example, FSS-0001 (Extended) needs quotes to group parts that include spaces, if there is no initial quote, then a quote following the data must not be delimited. + Unless otherwise specified, character/data delimits are performed only when required and not unilaterally. + In the case of Objects, delimits would only apply when that Object could be potentially identified as an Object. + For example, FSS-0001 (Extended) needs quotes to group parts that include spaces, if there is no initial quote, then a quote following the data MUST NOT be delimited. Such as these following three lines\: "Object 1" "This is a single quoted Content." \"Additional unquoted Content." Object_2 This is multiple" Contents and the trailing quote does not need to be delimited. @@ -88,33 +89,31 @@ Featureless Settings Specifications: All specifications are expected to support or be of the character encoding UTF-8; however, there is no imposed restriction on supporting or using any other encoding. Those encodings must only support the appropriate characters required by a given standard for differentiating Objects, Contents, and delimits. + All specifications do assume ASCII and Unicode support. - Unless explicitly defined, comments are designated by the pound symbol '#' but only if only whitespace is to the left of the pound or the pound '#' is at the start of the line. + Unless otherwise specified, comments are designated by the pound symbol '#' but only if only whitespace is to the left of the pound or the pound '#' is at the start of the line. There is no support for inline comments. Unless explicitly defined, the start comment may be delimited by '\' in the same manner as Objects and Contents are. This delimit only applies to the start of a comment (the pound '#' character) as there is no terminating character for a comment (other than a newline '\n'). - Unless explicitly defined, all designation characters must represent ASCII codes. + Unless otherwise specified, all designation characters MUST represent ASCII codes. With designation characters being any character code used to designate how to identify an Object or Content (such as a colon ':' at the end of a basic list). - This keeps the processing and logic simple, for both UTF-8 and ASCII. - Whitespace used for designation characters must include support for UTF-8 whitespace characters, unless explicitly stated otherwise. - Control characters used for designation characters must include support UTF-8 control character support, unless explicitly stated otherwise. + This keeps the processing and logic simple and safe, for both UTF-8 and ASCII. + Whitespace used for designation characters MUST include support for UTF-8 whitespace characters, unless otherwise specified. + However, these whitespace used as a designation character, must be printing whitespace that are not combining whitespace characters. + Any visible/graph character that is considered a whitespace (such as U+1680 ' ') is not to be considered a whitespace, unless otherwise specified. - The UTF-8 BOM is not allowed as a Byte Order Mark; instead, it must always be treated as the character represented by its code (unless explicitly allowed to represent a BOM by a standard). - - Unless explicitly defined, whitespace is to be considered all not visible characters that take up space (including newlines '\n'). - Any visible/graph character that is considered a whitespace (such as U+1680 ' ') is not to be considered a whitespace. + When used for syntax matching purposes, zero-width Unicode characters are only to be considered zero-width unless otherwise specified. + For example, the "invisible plus" character (U+2064) is not to be considered as a plus. - When used for syntax matching purposes, zero-width Unicode characters are only to be considered zero-width unless explicitly stated otherwise. - For example, the "invisible plus" character (U+2064) is not to be considered as a plus (unless explicitly stated otherwise). + The UTF-8 BOM is not allowed as a Byte Order Mark; instead, it must always be treated as the character represented by its code (unless explicitly allowed to represent a BOM by a standard). - The only Unicode dash-like characters allowed as a "dash" are those intended to connect, such as the Unicode hyphens (U+2010 and U+2011) (unless explicitly stated otherwise). + The only Unicode dash-like characters allowed as a "dash" are those intended to connect, such as the Unicode hyphens (U+2010 and U+2011) (unless otherwise specified). - In any specification where security is intended, if there exists a Unicode character that matches an ASCII character, that Unicode character may potentially be prohibeted by that standard in favor of the ASCII equivalent. + In any specification where security is intended, if there exists a Unicode character that matches an ASCII character, that Unicode character MAY be prohibited by that standard in favor of the ASCII equivalent. One such example is in the case of a URL, where the name could be used to trick a person (http://this-site.com/ vs http://this‐site.com/). This (potential insecure behavior) is allowed in general because a well written program would be able to detect and communicate the possible misunderstanding and thereby avoid mistakes without imposing any character restrictions. - @todo document that certain special UTF-8 characters are not allowed in certain terminology groups, such as "word characters", "number characters", etc.. so that potential confusion can be avoided. This is a common behavior for security reasons, each character used for any special purposes must be visibly distinct, with whitespace and non-printing characters as the exception to the words "visibly distinct". The follow specifications are defined in this project.