From 2aea87c58158535ae798f9970d07b29d35653d87 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 16 Jan 2021 21:24:47 -0600 Subject: [PATCH] Update: synchronize f_utf (and fl_utf) with f_string (and fl_string), update f_string and fl_string, and fix some bugs. Get the UTF related code more up to date and in sync with all of the string changes. This brings the UTF string types in line with the normal string types. Much of the code is moved out of fl_utf and fl_string and into f_utf and f_string. This is only the first pass at updating the UTF code. The function comments need a cleanup pass. The pre-existing incomplete UTF code remains incomplete. There were some minor bugs and typos that needed fixing that I happened across while working on this. The UTF string types should just use the same length types as the string types. Rename the *_non_graph() functions to *_graph_non(). There will need to be another follow up commit to cleanup the code that as of this commit now contains duplicate code. The FSS processing code is a likely case for this. --- build/level_0/settings | 4 +- build/monolithic/settings | 4 +- build/scripts/bootstrap-example.sh | 2 +- level_0/f_string/c/private-string.c | 34 +- level_0/f_string/c/private-string.h | 46 +- level_0/f_string/c/string.c | 100 +- level_0/f_string/c/string.h | 112 ++ level_0/f_utf/c/private-utf.c | 581 ++++++++++ level_0/f_utf/c/private-utf.h | 654 +++++++++++ level_0/f_utf/c/utf-common.c | 49 + level_0/f_utf/c/utf-common.h | 560 ++------- level_0/f_utf/c/utf.c | 998 ++++++++++++++++ level_0/f_utf/c/utf.h | 1033 +++++++++++++++++ level_0/f_utf/c/utf_dynamic.c | 190 ++++ level_0/f_utf/c/utf_dynamic.h | 370 ++++++ level_0/f_utf/c/utf_map.c | 196 ++++ level_0/f_utf/c/utf_map.h | 389 +++++++ level_0/f_utf/c/utf_quantity.c | 196 ++++ level_0/f_utf/c/utf_quantity.h | 354 ++++++ level_0/f_utf/c/utf_range.c | 196 ++++ level_0/f_utf/c/utf_range.h | 362 ++++++ level_0/f_utf/c/utf_triple.c | 103 ++ level_0/f_utf/c/utf_triple.h | 217 ++++ level_0/f_utf/data/build/settings | 4 +- level_1/fl_print/c/print.c | 8 +- level_1/fl_print/c/print.h | 8 +- level_1/fl_print/c/private-print.c | 4 +- level_1/fl_print/c/private-print.h | 4 +- level_1/fl_string/c/string.c | 110 +- level_1/fl_string/c/string.h | 331 ++---- level_1/fl_utf/c/private-utf.c | 232 +--- level_1/fl_utf/c/private-utf.h | 140 +-- level_1/fl_utf/c/utf.c | 1193 ++------------------ level_1/fl_utf/c/utf.h | 1170 +------------------ level_1/fl_utf_file/c/private-utf_file.c | 8 +- level_1/fl_utf_file/c/private-utf_file.h | 2 +- level_1/fl_utf_file/c/utf_file.c | 24 +- level_1/fl_utf_file/c/utf_file.h | 10 +- level_2/fll_program/data/build/dependencies | 1 - level_2/fll_program/data/build/settings | 2 +- level_3/byte_dump/c/private-byte_dump.c | 4 +- level_3/byte_dump/data/build/dependencies | 2 - level_3/byte_dump/data/build/settings | 2 +- level_3/control/data/build/dependencies | 2 - level_3/control/data/build/settings | 2 +- level_3/controller/data/build/dependencies | 1 - level_3/controller/data/build/settings | 2 +- level_3/fake/c/private-make.c | 6 +- level_3/fake/data/build/dependencies | 1 - level_3/fake/data/build/settings | 2 +- .../fss_basic_list_write/data/build/dependencies | 1 - level_3/fss_basic_write/data/build/dependencies | 1 - .../data/build/dependencies | 1 - .../data/build/dependencies | 1 - level_3/fss_extended_write/data/build/dependencies | 1 - level_3/fss_status_code/data/build/dependencies | 2 - level_3/fss_status_code/data/build/settings | 2 +- level_3/iki_write/c/iki_write.c | 6 +- level_3/iki_write/data/build/dependencies | 1 - level_3/iki_write/data/build/settings | 2 +- level_3/init/data/build/dependencies | 1 - level_3/init/data/build/settings | 2 +- level_3/status_code/data/build/dependencies | 2 - level_3/status_code/data/build/settings | 2 +- 64 files changed, 6570 insertions(+), 3480 deletions(-) create mode 100644 level_0/f_utf/c/utf-common.c create mode 100644 level_0/f_utf/c/utf_dynamic.c create mode 100644 level_0/f_utf/c/utf_dynamic.h create mode 100644 level_0/f_utf/c/utf_map.c create mode 100644 level_0/f_utf/c/utf_map.h create mode 100644 level_0/f_utf/c/utf_quantity.c create mode 100644 level_0/f_utf/c/utf_quantity.h create mode 100644 level_0/f_utf/c/utf_range.c create mode 100644 level_0/f_utf/c/utf_range.h create mode 100644 level_0/f_utf/c/utf_triple.c create mode 100644 level_0/f_utf/c/utf_triple.h diff --git a/build/level_0/settings b/build/level_0/settings index 4d3229e..6a2a00d 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -21,10 +21,10 @@ build_language c build_libraries -lc -lcap build_libraries-level build_libraries-level_threadless -build_sources_library account.c private-account.c capability.c color.c color-common.c console.c console-common.c control_group.c control_group-common.c conversion.c directory.c private-directory.c environment.c private-environment.c file.c file-common.c private-file.c fss.c private-fss.c fss_named.c fss_nest.c fss_set.c iki.c iki-common.c private-iki.c limit.c memory.c memory_structure.c private-memory.c path.c path-common.c private-path.c pipe.c print.c private-print.c serialize.c serialize-common.c private-serialize.c signal.c socket.c string.c string-common.c private-string.c string_dynamic.c string_map.c string_quantity.c string_range.c string_triple.c type_array.c private-type_array.c utf.c private-utf.c +build_sources_library account.c private-account.c capability.c color.c color-common.c console.c console-common.c control_group.c control_group-common.c conversion.c directory.c private-directory.c environment.c private-environment.c file.c file-common.c private-file.c fss.c private-fss.c fss_named.c fss_nest.c fss_set.c iki.c iki-common.c private-iki.c limit.c memory.c memory_structure.c private-memory.c path.c path-common.c private-path.c pipe.c print.c private-print.c serialize.c serialize-common.c private-serialize.c signal.c socket.c string.c string-common.c private-string.c string_dynamic.c string_map.c string_quantity.c string_range.c string_triple.c type_array.c private-type_array.c utf.c utf-common.c private-utf.c utf_dynamic.c utf_map.c utf_quantity.c utf_range.c utf_triple.c build_sources_library-level thread.c build_sources_program -build_sources_headers account.h account-common.h capability.h capability-common.h color.h color-common.h console.h console-common.h control_group.h control_group-common.h conversion.h conversion-common.h directory.h directory_type.h directory-common.h environment.h environment-common.h execute.h execute-common.h file.h file-common.h fss.h private-fss.h fss-common.h fss_comment.h fss_delimit.h fss_named.h fss_nest.h fss_quote.h fss_set.h iki.h iki-common.h limit.h limit-common.h memory.h memory_structure.h memory-common.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 private-string.h string_dynamic.h string_map.h string_quantity.h string_range.h string_triple.h type.h type_array.h private-type_array.h type_array-common.h utf.h utf-common.h +build_sources_headers account.h account-common.h capability.h capability-common.h color.h color-common.h console.h console-common.h control_group.h control_group-common.h conversion.h conversion-common.h directory.h directory_type.h directory-common.h environment.h environment-common.h execute.h execute-common.h file.h file-common.h fss.h private-fss.h fss-common.h fss_comment.h fss_delimit.h fss_named.h fss_nest.h fss_quote.h fss_set.h iki.h iki-common.h limit.h limit-common.h memory.h memory_structure.h memory-common.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 private-string.h string_dynamic.h string_map.h string_quantity.h string_range.h string_triple.h type.h type_array.h private-type_array.h type_array-common.h utf.h utf-common.h utf_dynamic.h utf_map.h utf_quantity.h utf_range.h utf_triple.h build_sources_headers-level thread.h thread-common.h build_sources_script build_sources_setting diff --git a/build/monolithic/settings b/build/monolithic/settings index 8a7408a..1322c32 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -21,10 +21,10 @@ build_language c build_libraries -lc -lcap build_libraries-monolithic build_libraries-monolithic_threadless -build_sources_library level_0/account.c level_0/private-account.c level_0/capability.c level_0/color.c level_0/color-common.c level_0/console.c level_0/console-common.c level_0/control_group.c level_0/control_group-common.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/file-common.c level_0/private-file.c level_0/fss.c level_0/private-fss.c level_0/fss_named.c level_0/fss_nest.c level_0/fss_set.c level_0/iki.c level_0/iki-common.c level_0/private-iki.c level_0/limit.c level_0/memory.c level_0/memory_structure.c level_0/private-memory.c level_0/path.c level_0/path-common.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/serialize-common.c level_0/private-serialize.c level_0/signal.c level_0/socket.c level_0/string.c level_0/string-common.c level_0/private-string.c level_0/string_dynamic.c level_0/string_map.c level_0/string_quantity.c level_0/string_range.c level_0/string_triple.c level_0/type_array.c level_0/private-type_array.c level_0/utf.c level_0/private-utf.c level_1/color.c level_1/console.c level_1/control_group.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_embedded_list.c level_1/fss_extended.c level_1/fss_extended_list.c level_1/iki.c level_1/print.c level_1/private-print.c level_1/status.c level_1/string.c level_1/private-string.c level_1/utf.c level_1/private-utf.c level_1/utf_file.c level_1/private-utf_file.c level_2/control_group.c level_2/error.c level_2/error-common.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_embedded_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_library level_0/account.c level_0/private-account.c level_0/capability.c level_0/color.c level_0/color-common.c level_0/console.c level_0/console-common.c level_0/control_group.c level_0/control_group-common.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/file-common.c level_0/private-file.c level_0/fss.c level_0/private-fss.c level_0/fss_named.c level_0/fss_nest.c level_0/fss_set.c level_0/iki.c level_0/iki-common.c level_0/private-iki.c level_0/limit.c level_0/memory.c level_0/memory_structure.c level_0/private-memory.c level_0/path.c level_0/path-common.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/serialize-common.c level_0/private-serialize.c level_0/signal.c level_0/socket.c level_0/string.c level_0/string-common.c level_0/private-string.c level_0/string_dynamic.c level_0/string_map.c level_0/string_quantity.c level_0/string_range.c level_0/string_triple.c level_0/type_array.c level_0/private-type_array.c level_0/utf.c level_0/utf-common.c level_0/private-utf.c level_0/utf_dynamic.c level_0/utf_map.c level_0/utf_quantity.c level_0/utf_range.c level_0/utf_triple.c level_1/color.c level_1/console.c level_1/control_group.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_embedded_list.c level_1/fss_extended.c level_1/fss_extended_list.c level_1/iki.c level_1/print.c level_1/private-print.c level_1/status.c level_1/string.c level_1/private-string.c level_1/utf.c level_1/private-utf.c level_1/utf_file.c level_1/private-utf_file.c level_2/control_group.c level_2/error.c level_2/error-common.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_embedded_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_library-monolithic level_0/thread.c build_sources_program -build_sources_headers level_0/account.h level_0/account-common.h level_0/capability.h level_0/capability-common.h level_0/color.h level_0/color-common.h level_0/console.h level_0/console-common.h level_0/control_group.h level_0/control_group-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/execute.h level_0/execute-common.h level_0/file.h level_0/file-common.h level_0/fss.h level_0/private-fss.h level_0/fss-common.h level_0/fss_comment.h level_0/fss_delimit.h level_0/fss_named.h level_0/fss_nest.h level_0/fss_quote.h level_0/fss_set.h level_0/iki.h level_0/iki-common.h level_0/limit.h level_0/limit-common.h level_0/memory.h level_0/memory_structure.h level_0/memory-common.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/private-string.h level_0/string_dynamic.h level_0/string_map.h level_0/string_quantity.h level_0/string_range.h level_0/string_triple.h level_0/type.h level_0/type_array.h level_0/private-type_array.h level_0/type_array-common.h level_0/utf.h level_0/utf-common.h level_1/color.h level_1/console.h level_1/control_group.h level_1/conversion.h level_1/directory.h level_1/environment.h level_1/execute.h level_1/execute-common.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_embedded_list.h level_1/fss_extended.h level_1/fss_extended_list.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/control_group.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_embedded_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/capability.h level_0/capability-common.h level_0/color.h level_0/color-common.h level_0/console.h level_0/console-common.h level_0/control_group.h level_0/control_group-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/execute.h level_0/execute-common.h level_0/file.h level_0/file-common.h level_0/fss.h level_0/private-fss.h level_0/fss-common.h level_0/fss_comment.h level_0/fss_delimit.h level_0/fss_named.h level_0/fss_nest.h level_0/fss_quote.h level_0/fss_set.h level_0/iki.h level_0/iki-common.h level_0/limit.h level_0/limit-common.h level_0/memory.h level_0/memory_structure.h level_0/memory-common.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/private-string.h level_0/string_dynamic.h level_0/string_map.h level_0/string_quantity.h level_0/string_range.h level_0/string_triple.h level_0/type.h level_0/type_array.h level_0/private-type_array.h level_0/type_array-common.h level_0/utf.h level_0/utf-common.h level_0/utf_dynamic.h level_0/utf_map.h level_0/utf_quantity.h level_0/utf_range.h level_0/utf_triple.h level_1/color.h level_1/console.h level_1/control_group.h level_1/conversion.h level_1/directory.h level_1/environment.h level_1/execute.h level_1/execute-common.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_embedded_list.h level_1/fss_extended.h level_1/fss_extended_list.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/control_group.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_embedded_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-monolithic level_0/thread.h level_0/thread-common.h build_sources_script build_sources_setting diff --git a/build/scripts/bootstrap-example.sh b/build/scripts/bootstrap-example.sh index 01ec4d2..8c81843 100644 --- a/build/scripts/bootstrap-example.sh +++ b/build/scripts/bootstrap-example.sh @@ -56,7 +56,7 @@ if [[ $1 == "individual" ]] ; then bash build/scripts/package.sh $verbose $color build -i if [[ $? -eq 0 ]] ; then - for i in f_type f_status f_memory f_type_array f_string f_utf f_account f_capability f_color f_console f_control_group f_conversion f_directory f_environment f_execute f_file f_fss f_iki f_limit f_path f_pipe f_print f_serialize f_signal f_socket f_thread fl_color fl_console fl_control_group fl_conversion fl_directory fl_environment fl_execute fl_fss fl_iki fl_print fl_status fl_string fl_type fl_utf fl_utf_file fll_control_group fll_error fll_execute fll_file fll_fss fll_iki fll_path fll_program fll_status ; do + for i in f_type f_status f_memory f_type_array f_string f_utf f_account f_capability f_color f_console f_control_group f_conversion f_directory f_environment f_execute f_file f_fss f_iki f_limit f_path f_pipe f_print f_serialize f_signal f_socket f_thread fl_color fl_console fl_control_group fl_conversion fl_directory fl_environment fl_execute fl_fss fl_iki fl_print fl_status fl_string fl_utf fl_utf_file fll_control_group fll_error fll_execute fll_file fll_fss fll_iki fll_path fll_program fll_status ; do echo && echo "Processing $i." && cd package/individual/$i-$2/ && diff --git a/level_0/f_string/c/private-string.c b/level_0/f_string/c/private-string.c index 0c65b70..12116e9 100644 --- a/level_0/f_string/c/private-string.c +++ b/level_0/f_string/c/private-string.c @@ -5,23 +5,6 @@ extern "C" { #endif -#if !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) - f_status_t private_f_string_dynamic_adjust(const f_string_length_t length, f_string_dynamic_t *dynamic) { - - f_status_t status = f_memory_adjust(dynamic->size, length, sizeof(f_string_t), (void **) & dynamic->string); - - if (F_status_is_error_not(status)) { - dynamic->size = length; - - if (dynamic->used > dynamic->size) { - dynamic->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) - #if !defined(_di_f_string_append_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_mash_) f_status_t private_f_string_append(const f_string_t source, const f_string_length_t length, f_string_dynamic_t *destination) { @@ -89,6 +72,23 @@ extern "C" { } #endif // !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_mash_nulless_) +#if !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) + f_status_t private_f_string_dynamic_adjust(const f_string_length_t length, f_string_dynamic_t *dynamic) { + + f_status_t status = f_memory_adjust(dynamic->size, length, sizeof(f_string_t), (void **) & dynamic->string); + + if (F_status_is_error_not(status)) { + dynamic->size = length; + + if (dynamic->used > dynamic->size) { + dynamic->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) + #if !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_append_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_dynamic_prepend_nulless_) f_status_t private_f_string_dynamic_increase_by(const f_string_length_t amount, f_string_dynamic_t *dynamic) { diff --git a/level_0/f_string/c/private-string.h b/level_0/f_string/c/private-string.h index 4928467..3512761 100644 --- a/level_0/f_string/c/private-string.h +++ b/level_0/f_string/c/private-string.h @@ -16,29 +16,6 @@ extern "C" { #endif /** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param string - * The string to adjust. - * - * @return - * F_none on success. - * - * Errors (with error bit) from: f_memory_adjust(). - * - * @see f_memory_adjust() - * @see f_string_dynamic_adjust() - * @see f_string_dynamic_decimate_by() - */ -#if !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) - extern f_status_t private_f_string_dynamic_adjust(const f_string_length_t length, f_string_dynamic_t *string) f_gcc_attribute_visibility_internal; -#endif // !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) - -/** * Private implementation of f_string_append(). * * Intended to be shared to each of the different implementation variations. @@ -107,6 +84,29 @@ extern "C" { #endif // !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_mash_nulless_) /** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param string + * The string to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_string_dynamic_adjust() + * @see f_string_dynamic_decimate_by() + */ +#if !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) + extern f_status_t private_f_string_dynamic_adjust(const f_string_length_t length, f_string_dynamic_t *string) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) + +/** * Private implementation of f_string_dynamic_increase_by(). * * Intended to be shared to each of the different implementation variations. diff --git a/level_0/f_string/c/string.c b/level_0/f_string/c/string.c index 3579cc6..f4cdff3 100644 --- a/level_0/f_string/c/string.c +++ b/level_0/f_string/c/string.c @@ -417,7 +417,7 @@ extern "C" { #endif // _di_f_string_dynamic_partial_mash_nulless_ #ifndef _di_f_string_dynamic_partial_mish_ - f_status_t fl_string_partial_dynamic_mish(const f_string_t glue, const f_string_length_t glue_length, const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t *destination) { + f_status_t f_string_partial_dynamic_mish(const f_string_t glue, const f_string_length_t glue_length, const f_string_static_t source, const f_string_range_t range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -666,6 +666,66 @@ extern "C" { } #endif // _di_f_string_dynamic_prepend_nulless_ +#ifndef _di_f_string_dynamic_seek_line_ + f_status_t f_string_dynamic_seek_line(const f_string_t string, f_string_range_t *range) { + #ifndef _di_level_1_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + if (!string) return F_data_not; + if (range->start > range->stop) return F_data_not_stop; + + while (string[range->start] != f_string_eol_s[0]) { + range->start++; + + if (range->start > range->stop) return F_none_stop; + } // while + + return F_none; + } +#endif // _di_f_string_dynamic_seek_line_ + +#ifndef _di_f_string_dynamic_seek_line_to_ + f_status_t f_string_dynamic_seek_line_to(const f_string_t string, const int8_t seek_to_this, f_string_range_t *range) { + #ifndef _di_level_1_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + if (!string) return F_data_not; + if (range->start > range->stop) return F_data_not_stop; + + while (string[range->start] != seek_to_this) { + + if (string[range->start] == f_string_eol_s[0]) return F_none_eol; + + range->start++; + + if (range->start > range->stop) return F_none_stop; + } // while + + return F_none; + } +#endif // _di_f_string_dynamic_seek_line_to_ + +#ifndef _di_f_string_dynamic_seek_to_ + f_status_t f_string_dynamic_seek_to(const f_string_t string, const int8_t seek_to_this, f_string_range_t *range) { + #ifndef _di_level_1_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + if (!string) return F_data_not; + if (range->start > range->stop) return F_data_not_stop; + + while (string[range->start] != seek_to_this) { + range->start++; + + if (range->start > range->stop) return F_none_stop; + } // while + + return F_none; + } +#endif // _di_f_string_dynamic_seek_to_ + #ifndef _di_f_string_dynamic_terminate_ f_status_t f_string_dynamic_terminate(f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ @@ -885,6 +945,44 @@ extern "C" { } #endif // _di_f_string_prepend_nulless_ +#ifndef _di_f_string_seek_line_to_ + f_status_t f_string_seek_line_to(const f_string_t string, const int8_t seek_to, f_string_range_t *range) { + #ifndef _di_level_1_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + if (range->start > range->stop) return F_data_not_stop; + + while (string[range->start] != seek_to) { + if (string[range->start] == f_string_eol_s[0]) return F_none_eol; + + range->start++; + + if (range->start > range->stop) return F_none_stop; + } // while + + return F_none; + } +#endif // _di_f_string_seek_line_to_ + +#ifndef _di_f_string_seek_to_ + f_status_t f_string_seek_to(const f_string_t string, const int8_t seek_to, f_string_range_t *range) { + #ifndef _di_level_1_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + if (range->start > range->stop) return F_data_not_stop; + + while (string[range->start] != seek_to) { + range->start++; + + if (range->start > range->stop) return F_none_stop; + } // while + + return F_none; + } +#endif // _di_f_string_seek_to_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string.h b/level_0/f_string/c/string.h index 2389d49..bf260b4 100644 --- a/level_0/f_string/c/string.h +++ b/level_0/f_string/c/string.h @@ -713,6 +713,73 @@ extern "C" { #endif // _di_f_string_dynamic_prepend_nulless_ /** + * Seek the buffer location forward until EOL is reached. + * + * @param string + * The string to traverse. + * @param range + * A range within the buffer representing the start and stop locations. + * The start location will be incremented by seek. + * + * @return + * F_none on success. + * F_none_stop on success, but stopped at end of range. + * F_data_not on success, but there was no string data to seek. + * F_data_not_stop on success, but the range.start > range.stop. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_string_dynamic_seek_line_ + extern f_status_t f_string_dynamic_seek_line(const f_string_t string, f_string_range_t *range); +#endif // _di_f_string_dynamic_seek_line_ + +/** + * Seek the buffer location forward until the character (1-byte wide) or EOL is reached. + * + * @param string + * The string to traverse. + * @param seek_to_this + * A single-width character representing a character to seek to. + * @param range + * A range within the buffer representing the start and stop locations. + * The start location will be incremented by seek. + * + * @return + * F_none on success. + * F_none_eol on success, but stopped at EOL. + * F_none_stop on success, but stopped at end of range. + * F_data_not on success, but there was no string data to seek. + * F_data_not_stop on success, but the range.start > range.stop. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_string_dynamic_seek_line_to_ + extern f_status_t f_string_dynamic_seek_line_to(const f_string_t string, const int8_t seek_to_this, f_string_range_t *range); +#endif // _di_f_string_dynamic_seek_line_to_ + +/** + * Seek the buffer location forward until the character (1-byte wide) is reached. + * + * @param string + * The string to traverse. + * @param seek_to_this + * A single-width character representing a character to seek to. + * @param range + * A range within the buffer representing the start and stop locations. + * The start location will be incremented by seek. + * + * @return + * F_none on success. + * F_none_stop on success, but stopped at end of range. + * F_data_not on success, but there was no string data to seek. + * F_data_not_stop on success, but the range.start > range.stop. + * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. + * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_string_dynamic_seek_to_ + extern f_status_t f_string_dynamic_seek_to(const f_string_t string, const int8_t seek_to_this, f_string_range_t *range); +#endif // _di_f_string_dynamic_seek_to_ + +/** * Guarantee that an end of string (NULL) exists at the end of the string. * * This is intended to be used for anything requiring NULL terminated strings. @@ -968,6 +1035,51 @@ extern "C" { extern f_status_t f_string_prepend_nulless(const f_string_t source, const f_string_length_t length, f_string_dynamic_t *destination); #endif // _di_f_string_prepend_nulless_ +/** + * Seek the string location forward until the character (1-byte wide) or EOL is reached. + * + * @param string + * The string to traverse. + * @param seek_to + * A single-width character representing a character to seek to. + * @param range + * A range within the buffer representing the start and stop locations. + * The start location will be incremented by seek. + * + * @return + * F_none on success. + * F_none_eol on success, but stopped at EOL. + * F_none_stop on success, but stopped stop location. + * F_data_not_stop if range.start > range.stop. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_string_seek_line_to_ + extern f_status_t f_string_seek_line_to(const f_string_t string, const int8_t seek_to, f_string_range_t *range); +#endif // _di_f_string_seek_line_to_ + +/** + * Seek the string location forward until the character (1-byte wide) is reached. + * + * @param string + * The string to traverse. + * @param seek_to + * A single-width character representing a character to seek to. + * @param range + * A range within the buffer representing the start and stop locations. + * The start location will be incremented by seek. + * + * @return + * F_none on success. + * F_none_stop on success, but stopped stop location. + * F_data_not_stop if range.start > range.stop. + * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. + * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_string_seek_to_ + extern f_status_t f_string_seek_to(const f_string_t string, const int8_t seek_to, f_string_range_t *range); +#endif // _di_f_string_seek_to_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/private-utf.c b/level_0/f_utf/c/private-utf.c index b103e25..13961fd 100644 --- a/level_0/f_utf/c/private-utf.c +++ b/level_0/f_utf/c/private-utf.c @@ -2212,6 +2212,587 @@ extern "C" { } #endif // !defined(_di_f_utf_character_is_zero_width_) || !defined(_di_f_utf_is_zero_width_) +#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_mash_) + f_status_t private_f_utf_string_append(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + + if (destination->used + length > destination->size) { + const f_status_t status = private_f_utf_string_dynamic_increase_by(length, destination); + if (F_status_is_error(status)) return status; + } + + memcpy(destination->string + destination->used, source, length); + destination->used = destination->used + length; + + return F_none; + } +#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_mash_) + +#if !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_mash_nulless_) + f_status_t private_f_utf_string_append_nulless(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + + if (destination->used + length > f_string_length_t_size) { + return F_status_set_error(F_string_too_large); + } + + f_status_t status = F_none; + + f_string_length_t i = 0; + f_string_length_t first = 0; + f_string_length_t size = 0; + + for (; i < length; i++) { + + if (source[i]) continue; + + if (i && i > first) { + size = i - first; + + if (destination->used + size > destination->size) { + status = private_f_utf_string_dynamic_increase_by(size, destination); + if (F_status_is_error(status)) return status; + } + + memcpy(destination->string + destination->used, source + first, size); + destination->used = destination->used + size; + } + + while (i + 1 < length && !source[i + 1]) { + i++; + } // while + + first = i + 1; + } // for + + if (i > first) { + size = i - first; + + if (destination->used + size > destination->size) { + status = private_f_utf_string_dynamic_increase_by(size, destination); + if (F_status_is_error(status)) return status; + } + + memcpy(destination->string + destination->used, source + first, size); + destination->used = destination->used + size; + } + + return F_none; + } +#endif // !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_mash_nulless_) + +#if !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) + f_status_t private_f_utf_string_dynamic_adjust(const f_string_length_t length, f_utf_string_dynamic_t *dynamic) { + + f_status_t status = f_memory_adjust(dynamic->size, length, sizeof(f_utf_string_t), (void **) & dynamic->string); + + if (F_status_is_error_not(status)) { + dynamic->size = length; + + if (dynamic->used > dynamic->size) { + dynamic->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) + +#if !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) + f_status_t private_f_utf_string_dynamic_increase_by(const f_string_length_t amount, f_utf_string_dynamic_t *dynamic) { + + if (dynamic->used + amount > dynamic->size) { + if (dynamic->used + amount > f_string_length_t_size) { + return F_status_set_error(F_string_too_large); + } + + return private_f_utf_string_dynamic_resize(dynamic->used + amount, dynamic); + } + + return F_data_not; + } +#endif // !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) + +#if !defined(_di_f_utf_string_dynamic_decrease_by_) || !defined(_di_f_utf_string_dynamic_increase_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) + f_status_t private_f_utf_string_dynamic_resize(const f_string_length_t length, f_utf_string_dynamic_t *dynamic) { + + const f_status_t status = f_memory_resize(dynamic->size, length, sizeof(f_utf_string_t), (void **) & dynamic->string); + + if (F_status_is_error_not(status)) { + dynamic->size = length; + + if (dynamic->used > dynamic->size) { + dynamic->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_dynamic_decrease_by_) || !defined(_di_f_utf_string_dynamic_increase_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) + +#if !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_decimate_by_) + f_status_t private_f_utf_string_dynamics_adjust(const f_string_length_t length, f_utf_string_dynamics_t *dynamics) { + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamics->size; ++i) { + status = private_f_utf_string_dynamic_adjust(0, &dynamics->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(dynamics->size, length, sizeof(f_utf_string_dynamic_t), (void **) & dynamics->array); + + if (F_status_is_error_not(status)) { + dynamics->size = length; + + if (dynamics->used > dynamics->size) { + dynamics->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_decimate_by_) + +#if !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) + f_status_t private_f_utf_string_dynamics_resize(const f_string_length_t length, f_utf_string_dynamics_t *dynamics) { + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamics->size; ++i) { + status = private_f_utf_string_dynamic_resize(0, &dynamics->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(dynamics->size, length, sizeof(f_utf_string_dynamic_t), (void **) & dynamics->array); + + if (F_status_is_error_not(status)) { + dynamics->size = length; + + if (dynamics->used > dynamics->size) { + dynamics->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) + +#if !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_decimate_by_) + f_status_t private_f_utf_string_map_multis_adjust(const f_string_length_t length, f_utf_string_map_multis_t *map_multis) { + f_status_t status = F_none; + + for (f_array_length_t i = length; i < map_multis->size; ++i) { + + status = private_f_utf_string_dynamic_adjust(0, &map_multis->array[i].name); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamics_adjust(0, &map_multis->array[i].value); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(map_multis->size, length, sizeof(f_utf_string_map_multi_t), (void **) & map_multis->array); + + if (F_status_is_error_not(status)) { + map_multis->size = length; + + if (map_multis->used > map_multis->size) { + map_multis->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_decimate_by_) + +#if !defined(_di_f_utf_string_map_multis_decrease_by_) || !defined(_di_f_utf_string_map_multis_increase_) || !defined(_di_f_utf_string_map_multis_increase_by_) || !defined(_di_f_utf_string_map_multis_terminate_) || !defined(_di_f_utf_string_map_multis_terminate_after_) + f_status_t private_f_utf_string_map_multis_resize(const f_string_length_t length, f_utf_string_map_multis_t *map_multis) { + f_status_t status = F_none; + + for (f_array_length_t i = length; i < map_multis->size; ++i) { + + status = private_f_utf_string_dynamic_resize(0, &map_multis->array[i].name); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamics_resize(0, &map_multis->array[i].value); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(map_multis->size, length, sizeof(f_utf_string_map_multi_t), (void **) & map_multis->array); + + if (F_status_is_error_not(status)) { + map_multis->size = length; + + if (map_multis->used > map_multis->size) { + map_multis->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_map_multis_decrease_by_) || !defined(_di_f_utf_string_map_multis_increase_) || !defined(_di_f_utf_string_map_multis_increase_by_) || !defined(_di_f_utf_string_map_multis_terminate_) || !defined(_di_f_utf_string_map_multis_terminate_after_) + +#if !defined(_di_f_utf_string_maps_adjust_) || !defined(_di_f_utf_string_maps_decimate_by_) + f_status_t private_f_utf_string_maps_adjust(const f_string_length_t length, f_utf_string_maps_t *maps) { + f_status_t status = F_none; + + for (f_array_length_t i = length; i < maps->size; ++i) { + + status = private_f_utf_string_dynamic_adjust(0, &maps->array[i].name); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamic_adjust(0, &maps->array[i].value); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(maps->size, length, sizeof(f_utf_string_map_t), (void **) & maps->array); + + if (F_status_is_error_not(status)) { + maps->size = length; + + if (maps->used > maps->size) { + maps->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_maps_adjust_) || !defined(_di_f_utf_string_maps_decimate_by_) + +#if !defined(_di_f_utf_string_maps_decrease_by_) || !defined(_di_f_utf_string_maps_increase_) || !defined(_di_f_utf_string_maps_increase_by_) || !defined(_di_f_utf_string_maps_terminate_) || !defined(_di_f_utf_string_maps_terminate_after_) + f_status_t private_f_utf_string_maps_resize(const f_string_length_t length, f_utf_string_maps_t *maps) { + f_status_t status = F_none; + + for (f_array_length_t i = length; i < maps->size; ++i) { + + status = private_f_utf_string_dynamic_resize(0, &maps->array[i].name); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamic_resize(0, &maps->array[i].value); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(maps->size, length, sizeof(f_utf_string_map_t), (void **) & maps->array); + + if (F_status_is_error_not(status)) { + maps->size = length; + + if (maps->used > maps->size) { + maps->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_maps_decrease_by_) || !defined(_di_f_utf_string_maps_increase_) || !defined(_di_f_utf_string_maps_increase_by_) || !defined(_di_f_utf_string_maps_terminate_) || !defined(_di_f_utf_string_maps_terminate_after_) + +#if !defined(_di_f_utf_string_dynamic_mish_) || !defined(_di_f_utf_string_dynamic_partial_mish_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_) || !defined(_di_f_utf_string_dynamic_partial_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_assure_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_mish_) || !defined(_di_f_utf_string_prepend_assure_) || !defined(_di_f_utf_string_prepend_) + f_status_t private_f_utf_string_prepend(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + + if (destination->used + length > f_string_length_t_size) { + return F_status_set_error(F_string_too_large); + } + + if (destination->used + length > destination->size) { + const f_status_t status = private_f_utf_string_dynamic_increase_by(length, destination); + if (F_status_is_error(status)) return status; + } + + if (destination->used) { + memmove(destination->string + length, destination->string, destination->used); + memcpy(destination->string, source, length); + } + else { + memcpy(destination->string, source, length); + } + + destination->used = destination->used + length; + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamic_mish_) || !defined(_di_f_utf_string_dynamic_partial_mish_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_) || !defined(_di_f_utf_string_dynamic_partial_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_assure_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_mish_) || !defined(_di_f_utf_string_prepend_assure_) || !defined(_di_f_utf_string_prepend_) + +#if !defined(_di_f_utf_string_dynamic_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_mish_nulless_) || !defined(_di_f_utf_string_prepend_assure_nulless_) || !defined(_di_f_utf_string_prepend_nulless_) + f_status_t private_f_utf_string_prepend_nulless(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + + if (destination->used + length > f_string_length_t_size) { + return F_status_set_error(F_string_too_large); + } + + f_status_t status = F_none; + + f_string_length_t first = 0; + f_string_length_t offset = 0; + + f_string_length_t size = 0; + + for (f_string_length_t i = 0; i <= length; i++) { + + if (i == length) { + if (i > first) { + size = i - first; + + if (destination->used + size > destination->size) { + status = private_f_utf_string_dynamic_increase_by(size, destination); + if (F_status_is_error(status)) return status; + } + + memmove(destination->string + offset + size, destination->string + offset, destination->used - offset); + memcpy(destination->string + offset, source + first, size); + + destination->used = destination->used + size; + offset += size; + } + + break; + } + + if (!source[i]) { + if (i > 0) { + if (i > first) { + size = i - first; + + if (destination->used + size > destination->size) { + status = private_f_utf_string_dynamic_increase_by(size, destination); + if (F_status_is_error(status)) return status; + } + + memmove(destination->string + offset + size, destination->string + offset, destination->used - offset); + memcpy(destination->string + offset, source + first, size); + + destination->used = destination->used + size; + offset += size; + } + } + + while (i + 1 < length && !source[i + 1]) { + i++; + } // while + + first = i + 1; + continue; + } + } // for + + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamic_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_mish_nulless_) || !defined(_di_f_utf_string_prepend_assure_nulless_) || !defined(_di_f_utf_string_prepend_nulless_) + +#if !defined(_di_f_utf_string_quantitys_adjust_) || !defined(_di_f_utf_string_quantitys_decimate_by_) + f_status_t private_f_utf_string_quantitys_adjust(const f_string_length_t length, f_utf_string_quantitys_t *quantitys) { + + const f_status_t status = f_memory_adjust(quantitys->size, length, sizeof(f_utf_string_quantity_t), (void **) & quantitys->array); + + if (F_status_is_error_not(status)) { + quantitys->size = length; + + if (quantitys->used > quantitys->size) { + quantitys->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_quantitys_adjust_) || !defined(_di_f_utf_string_quantitys_decimate_by_) + +#if !defined(_di_f_utf_string_quantitys_decrease_) || !defined(_di_f_utf_string_quantitys_decrease_by_) || !defined(_di_f_utf_string_quantitys_increase_) || !defined(_di_f_utf_string_quantitys_increase_by_) || !defined(_di_f_utf_string_quantitys_terminate_) || !defined(_di_f_utf_string_quantitys_terminate_after_) + f_status_t private_f_utf_string_quantitys_resize(const f_string_length_t length, f_utf_string_quantitys_t *quantitys) { + + const f_status_t status = f_memory_resize(quantitys->size, length, sizeof(f_utf_string_quantity_t), (void **) & quantitys->array); + + if (F_status_is_error_not(status)) { + quantitys->size = length; + + if (quantitys->used > quantitys->size) { + quantitys->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_quantitys_decrease_) || !defined(_di_f_utf_string_quantitys_decrease_by_) || !defined(_di_f_utf_string_quantitys_increase_) || !defined(_di_f_utf_string_quantitys_increase_by_) || !defined(_di_f_utf_string_quantitys_terminate_) || !defined(_di_f_utf_string_quantitys_terminate_after_) + +#if !defined(_di_f_utf_string_quantityss_adjust_) || !defined(_di_f_utf_string_quantityss_decimate_by_) + f_status_t private_f_utf_string_quantityss_adjust(const f_string_length_t length, f_utf_string_quantityss_t *quantityss) { + f_status_t status = F_none; + + for (f_array_length_t i = length; i < quantityss->size; ++i) { + status = private_f_utf_string_quantitys_adjust(0, &quantityss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(quantityss->size, length, sizeof(f_utf_string_quantitys_t), (void **) & quantityss->array); + + if (F_status_is_error_not(status)) { + quantityss->size = length; + + if (quantityss->used > quantityss->size) { + quantityss->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_quantityss_adjust_) || !defined(_di_f_utf_string_quantityss_decimate_by_) + +#if !defined(_di_f_utf_string_quantityss_decrease_) || !defined(_di_f_utf_string_quantityss_decrease_by_) || !defined(_di_f_utf_string_quantityss_increase_) || !defined(_di_f_utf_string_quantityss_increase_by_) || !defined(_di_f_utf_string_quantityss_terminate_) || !defined(_di_f_utf_string_quantityss_terminate_after_) + f_status_t private_f_utf_string_quantityss_resize(const f_string_length_t length, f_utf_string_quantityss_t *quantityss) { + f_status_t status = F_none; + + for (f_array_length_t i = length; i < quantityss->size; ++i) { + status = private_f_utf_string_quantitys_resize(0, &quantityss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(quantityss->size, length, sizeof(f_utf_string_quantitys_t), (void **) & quantityss->array); + + if (F_status_is_error_not(status)) { + quantityss->size = length; + + if (quantityss->used > quantityss->size) { + quantityss->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_quantityss_decrease_) || !defined(_di_f_utf_string_quantityss_decrease_by_) || !defined(_di_f_utf_string_quantityss_increase_) || !defined(_di_f_utf_string_quantityss_increase_by_) || !defined(_di_f_utf_string_quantityss_terminate_) || !defined(_di_f_utf_string_quantityss_terminate_after_) + +#if !defined(_di_f_utf_string_ranges_adjust_) || !defined(_di_f_utf_string_ranges_decimate_by_) + f_status_t private_f_utf_string_ranges_adjust(const f_string_length_t length, f_utf_string_ranges_t *ranges) { + + const f_status_t status = f_memory_adjust(ranges->size, length, sizeof(f_utf_string_range_t), (void **) & ranges->array); + + if (F_status_is_error_not(status)) { + ranges->size = length; + + if (ranges->used > ranges->size) { + ranges->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_ranges_adjust_) || !defined(_di_f_utf_string_ranges_decimate_by_) + +#if !defined(_di_f_utf_string_ranges_decrease_) || !defined(_di_f_utf_string_ranges_decrease_by_) || !defined(_di_f_utf_string_ranges_increase_) || !defined(_di_f_utf_string_ranges_increase_by_) || !defined(_di_f_utf_string_ranges_terminate_) || !defined(_di_f_utf_string_ranges_terminate_after_) + f_status_t private_f_utf_string_ranges_resize(const f_string_length_t length, f_utf_string_ranges_t *ranges) { + + const f_status_t status = f_memory_resize(ranges->size, length, sizeof(f_utf_string_range_t), (void **) & ranges->array); + + if (F_status_is_error_not(status)) { + ranges->size = length; + + if (ranges->used > ranges->size) { + ranges->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_ranges_decrease_) || !defined(_di_f_utf_string_ranges_decrease_by_) || !defined(_di_f_utf_string_ranges_increase_) || !defined(_di_f_utf_string_ranges_increase_by_) || !defined(_di_f_utf_string_ranges_terminate_) || !defined(_di_f_utf_string_ranges_terminate_after_) + +#if !defined(_di_f_utf_string_rangess_adjust_) || !defined(_di_f_utf_string_rangess_decimate_by_) + f_status_t private_f_utf_string_rangess_adjust(const f_string_length_t length, f_utf_string_rangess_t *rangess) { + f_status_t status = F_none; + + for (f_array_length_t i = length; i < rangess->size; ++i) { + status = private_f_utf_string_ranges_adjust(0, &rangess->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(rangess->size, length, sizeof(f_utf_string_ranges_t), (void **) & rangess->array); + + if (F_status_is_error_not(status)) { + rangess->size = length; + + if (rangess->used > rangess->size) { + rangess->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_rangess_adjust_) || !defined(_di_f_utf_string_rangess_decimate_by_) + +#if !defined(_di_f_utf_string_rangess_decrease_) || !defined(_di_f_utf_string_rangess_decrease_by_) || !defined(_di_f_utf_string_rangess_increase_) || !defined(_di_f_utf_string_rangess_increase_by_) || !defined(_di_f_utf_string_rangess_terminate_) || !defined(_di_f_utf_string_rangess_terminate_after_) + f_status_t private_f_utf_string_rangess_resize(const f_string_length_t length, f_utf_string_rangess_t *rangess) { + f_status_t status = F_none; + + for (f_array_length_t i = length; i < rangess->size; ++i) { + status = private_f_utf_string_ranges_resize(0, &rangess->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(rangess->size, length, sizeof(f_utf_string_ranges_t), (void **) & rangess->array); + + if (F_status_is_error_not(status)) { + rangess->size = length; + + if (rangess->used > rangess->size) { + rangess->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_rangess_decrease_) || !defined(_di_f_utf_string_rangess_decrease_by_) || !defined(_di_f_utf_string_rangess_increase_) || !defined(_di_f_utf_string_rangess_increase_by_) || !defined(_di_f_utf_string_rangess_terminate_) || !defined(_di_f_utf_string_rangess_terminate_after_) + +#if !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) + f_status_t private_f_utf_string_triples_adjust(const f_string_length_t length, f_utf_string_triples_t *triples) { + f_status_t status = F_none; + + for (f_array_length_t i = length; i < triples->size; ++i) { + + status = private_f_utf_string_dynamic_adjust(0, &triples->array[i].one); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamic_adjust(0, &triples->array[i].two); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamic_adjust(0, &triples->array[i].three); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(triples->size, length, sizeof(f_utf_string_triple_t), (void **) & triples->array); + + if (F_status_is_error_not(status)) { + triples->size = length; + + if (triples->used > triples->size) { + triples->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) + +#if !defined(_di_f_utf_string_triples_decrease_) || !defined(_di_f_utf_string_triples_decrease_by_) || !defined(_di_f_utf_string_triples_increase_) || !defined(_di_f_utf_string_triples_increase_by_) || !defined(_di_f_utf_string_triples_terminate_) || !defined(_di_f_utf_string_triples_terminate_after_) + f_status_t private_f_utf_string_triples_resize(const f_string_length_t length, f_utf_string_triples_t *triples) { + f_status_t status = F_none; + + for (f_array_length_t i = length; i < triples->size; ++i) { + + status = private_f_utf_string_dynamic_resize(0, &triples->array[i].one); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamic_resize(0, &triples->array[i].two); + if (F_status_is_error(status)) return status; + + status = private_f_utf_string_dynamic_resize(0, &triples->array[i].three); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(triples->size, length, sizeof(f_utf_string_triple_t), (void **) & triples->array); + + if (F_status_is_error_not(status)) { + triples->size = length; + + if (triples->used > triples->size) { + triples->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_utf_string_triples_decrease_) || !defined(_di_f_utf_string_triples_decrease_by_) || !defined(_di_f_utf_string_triples_increase_) || !defined(_di_f_utf_string_triples_increase_by_) || !defined(_di_f_utf_string_triples_terminate_) || !defined(_di_f_utf_string_triples_terminate_after_) + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/private-utf.h b/level_0/f_utf/c/private-utf.h index c22c227..fb5c1c2 100644 --- a/level_0/f_utf/c/private-utf.h +++ b/level_0/f_utf/c/private-utf.h @@ -535,6 +535,660 @@ extern "C" { extern f_status_t private_f_utf_character_is_zero_width(const f_utf_character_t character, const uint8_t width) f_gcc_attribute_visibility_internal; #endif // !defined(_di_f_utf_character_is_zero_width_) || !defined(_di_f_utf_is_zero_width_) +/** + * Private implementation of f_utf_string_append(). + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source string to append. + * @param length + * Length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: private_f_utf_string_dynamic_increase_by(). + * + * @see memcpy() + * + * @see f_utf_string_append() + * @see f_utf_string_dynamic_append() + * @see f_utf_string_dynamic_mash() + * @see f_utf_string_mash() + * + * @see private_f_utf_string_dynamic_increase_by() + */ +#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_mash_) + extern f_status_t private_f_utf_string_append(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_mash_) + +/** + * Private implementation of f_utf_string_append_nulless(). + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source string to append. + * @param length + * Length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: private_f_utf_string_dynamic_increase_by(). + * + * @see memcpy() + * + * @see f_macro_utf_string_dynamic_t_resize() + * @see f_utf_string_append_nulless() + * @see f_utf_string_dynamic_append_nulless() + * @see f_utf_string_dynamic_mash_nulless() + * @see f_utf_string_mash_nulless() + * + * @see private_f_utf_string_dynamic_increase_by() + */ +#if !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_mash_nulless_) + extern f_status_t private_f_utf_string_append_nulless(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_mash_nulless_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param string + * The string to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_dynamic_adjust() + * @see f_utf_string_dynamic_decimate_by() + */ +#if !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) + extern f_status_t private_f_utf_string_dynamic_adjust(const f_string_length_t length, f_utf_string_dynamic_t *string) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) + +/** + * Private implementation of f_utf_string_dynamic_increase_by(). + * + * Intended to be shared to each of the different implementation variations. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param string + * The string to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: private_f_utf_string_dynamic_resize(). + * + * @see memcpy() + * + * @see f_utf_string_append() + * @see f_utf_string_append_mash() + * @see f_utf_string_append_nulless() + * @see f_utf_string_dynamic_append() + * @see f_utf_string_dynamic_append_nulless() + * @see f_utf_string_dynamic_increase_by() + * @see f_utf_string_dynamic_mash() + * @see f_utf_string_dynamic_mash_nulless() + * @see f_utf_string_dynamic_prepend() + * @see f_utf_string_dynamic_prepend_nulless() + * @see f_utf_string_mash_nulless() + * @see f_utf_string_prepend() + * @see f_utf_string_prepend_nulless() + */ +#if !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) + extern f_status_t private_f_utf_string_dynamic_increase_by(const f_string_length_t amount, f_utf_string_dynamic_t *string) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param string + * The string to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * + * @see f_memory_resize() + * @see f_utf_string_dynamic_decrease_by() + * @see f_utf_string_dynamic_increase() + * @see f_utf_string_dynamic_increase_by() + * @see f_utf_string_dynamic_terminate() + * @see f_utf_string_dynamic_terminate_after() + */ +#if !defined(_di_f_utf_string_dynamic_decrease_by_) || !defined(_di_f_utf_string_dynamic_increase_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) + extern f_status_t private_f_utf_string_dynamic_resize(const f_string_length_t length, f_utf_string_dynamic_t *string) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_dynamic_decrease_by_) || !defined(_di_f_utf_string_dynamic_increase_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param strings + * The strings to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: private_f_utf_string_dynamic_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_dynamics_adjust() + * @see f_utf_string_dynamics_decimate_by() + * + * @see private_f_utf_string_dynamic_adjust() + */ +#if !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_decimate_by_) + extern f_status_t private_f_utf_string_dynamics_adjust(const f_string_length_t length, f_utf_string_dynamics_t *strings) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param strings + * The strings to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: private_f_utf_string_dynamic_resize(). + * + * @see f_memory_resize() + * @see f_utf_string_dynamics_decrease_by() + * @see f_utf_string_dynamics_increase() + * @see f_utf_string_dynamics_increase_by() + * + * @see private_f_utf_string_dynamic_resize() + */ +#if !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) + extern f_status_t private_f_utf_string_dynamics_resize(const f_string_length_t length, f_utf_string_dynamics_t *strings) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_dynamics_decrease_by_) || !defined(_di_f_utf_string_dynamics_increase_) || !defined(_di_f_utf_string_dynamics_increase_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param map_multis + * The map_multis to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: private_f_utf_string_dynamic_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_map_multis_adjust() + * + * @see private_f_utf_string_dynamic_adjust() + */ +#if !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_decimate_by_) + extern f_status_t private_f_utf_string_map_multis_adjust(const f_string_length_t length, f_utf_string_map_multis_t *map_multis) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param map_multis + * The map_multis to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: private_f_utf_string_dynamic_resize(). + * + * @see f_memory_adjust() + * @see f_utf_string_map_multis_decrease_by() + * @see f_utf_string_map_multis_increase() + * @see f_utf_string_map_multis_increase_by() + * @see f_utf_string_map_multis_terminate() + * @see f_utf_string_map_multis_terminate_after() + * + * @see private_f_utf_string_dynamic_resize() + */ +#if !defined(_di_f_utf_string_map_multis_decrease_by_) || !defined(_di_f_utf_string_map_multis_increase_) || !defined(_di_f_utf_string_map_multis_increase_by_) || !defined(_di_f_utf_string_map_multis_terminate_) || !defined(_di_f_utf_string_map_multis_terminate_after_) + extern f_status_t private_f_utf_string_map_multis_resize(const f_string_length_t length, f_utf_string_map_multis_t *map_multis) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_map_multis_decrease_by_) || !defined(_di_f_utf_string_map_multis_increase_) || !defined(_di_f_utf_string_map_multis_increase_by_) || !defined(_di_f_utf_string_map_multis_terminate_) || !defined(_di_f_utf_string_map_multis_terminate_after_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param maps + * The maps to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: private_f_utf_string_dynamic_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_maps_adjust() + * + * @see private_f_utf_string_dynamic_adjust() + */ +#if !defined(_di_f_utf_string_maps_adjust_) || !defined(_di_f_utf_string_maps_decimate_by_) + extern f_status_t private_f_utf_string_maps_adjust(const f_string_length_t length, f_utf_string_maps_t *maps) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_maps_adjust_) || !defined(_di_f_utf_string_maps_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param maps + * The maps to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: private_f_utf_string_dynamic_resize(). + * + * @see f_memory_adjust() + * @see f_utf_string_maps_decrease_by() + * @see f_utf_string_maps_increase() + * @see f_utf_string_maps_increase_by() + * @see f_utf_string_maps_terminate() + * @see f_utf_string_maps_terminate_after() + * + * @see private_f_utf_string_dynamic_resize() + */ +#if !defined(_di_f_utf_string_maps_decrease_by_) || !defined(_di_f_utf_string_maps_increase_) || !defined(_di_f_utf_string_maps_increase_by_) || !defined(_di_f_utf_string_maps_terminate_) || !defined(_di_f_utf_string_maps_terminate_after_) + extern f_status_t private_f_utf_string_maps_resize(const f_string_length_t length, f_utf_string_maps_t *maps) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_maps_decrease_by_) || !defined(_di_f_utf_string_maps_increase_) || !defined(_di_f_utf_string_maps_increase_by_) || !defined(_di_f_utf_string_maps_terminate_) || !defined(_di_f_utf_string_maps_terminate_after_) + +/** + * Private implementation of f_utf_string_prepend(). + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source string to prepend. + * @param length + * Length of source to append. + * @param destination + * The destination string the source and glue are prepended onto. + * + * @return + * F_none on success. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: private_f_utf_string_dynamic_increase_by(). + * + * @see memcopy() + * @see memmove() + * + * @see f_utf_string_dynamic_mish() + * @see f_utf_string_dynamic_partial_mish() + * @see f_utf_string_dynamic_partial_prepend_assure() + * @see f_utf_string_dynamic_partial_prepend() + * @see f_utf_string_dynamic_prepend_assure() + * @see f_utf_string_dynamic_prepend() + * @see f_utf_string_mish() + * @see f_utf_string_prepend_assure() + * @see f_utf_string_prepend() + * + * @see private_f_utf_string_dynamic_increase_by() + */ +#if !defined(_di_f_utf_string_dynamic_mish_) || !defined(_di_f_utf_string_dynamic_partial_mish_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_) || !defined(_di_f_utf_string_dynamic_partial_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_assure_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_mish_) || !defined(_di_f_utf_string_prepend_assure_) || !defined(_di_f_utf_string_prepend_) + extern f_status_t private_f_utf_string_prepend(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_dynamic_mish_) || !defined(_di_f_utf_string_dynamic_partial_mish_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_) || !defined(_di_f_utf_string_dynamic_partial_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_assure_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_mish_) || !defined(_di_f_utf_string_prepend_assure_) || !defined(_di_f_utf_string_prepend_) + +/** + * Private implementation of f_utf_string_prepend_nulless(). + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source string to prepend. + * @param length + * Length of source to append. + * @param destination + * The destination string the source and glue are prepended onto. + * + * @return + * F_none on success. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: private_f_utf_string_dynamic_increase_by(). + * + * @see memcopy() + * @see memmove() + * + * @see f_utf_string_dynamic_mish_nulless() + * @see f_utf_string_dynamic_partial_mish_nulless() + * @see f_utf_string_dynamic_partial_prepend_assure_nulless() + * @see f_utf_string_dynamic_partial_prepend_nulless() + * @see f_utf_string_dynamic_prepend_assure_nulless() + * @see f_utf_string_dynamic_prepend_nulless() + * @see f_utf_string_mish_nulless() + * @see f_utf_string_prepend_assure_nulless() + * @see f_utf_string_prepend_nulless() + * + * @see private_f_utf_string_dynamic_increase_by() + */ +#if !defined(_di_f_utf_string_dynamic_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_mish_nulless_) || !defined(_di_f_utf_string_prepend_assure_nulless_) || !defined(_di_f_utf_string_prepend_nulless_) + extern f_status_t private_f_utf_string_prepend_nulless(const f_utf_string_t source, f_string_length_t length, f_utf_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_dynamic_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_mish_nulless_) || !defined(_di_f_utf_string_prepend_assure_nulless_) || !defined(_di_f_utf_string_prepend_nulless_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param quantitys + * The quantitys to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: private_f_utf_string_dynamic_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_quantitys_adjust() + * @see f_utf_string_quantitys_decimate_by() + * @see private_f_utf_string_dynamic_adjust() + */ +#if !defined(_di_f_utf_string_quantitys_adjust_) || !defined(_di_f_utf_string_quantitys_decimate_by_) + extern f_status_t private_f_utf_string_quantitys_adjust(const f_string_length_t length, f_utf_string_quantitys_t *quantitys) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_quantitys_adjust_) || !defined(_di_f_utf_string_quantitys_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param quantitys + * The quantitys to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: private_f_utf_string_dynamic_adjust(). + * + * @see f_memory_resize() + * @see f_utf_string_quantitys_decrease_by() + * @see f_utf_string_quantitys_increase() + * @see f_utf_string_quantitys_increase_by() + * @see f_utf_string_quantitys_terminate() + * @see f_utf_string_quantitys_terminate_after() + * @see private_f_utf_string_dynamic_resize() + */ +#if !defined(_di_f_utf_string_quantitys_decrease_by_) || !defined(_di_f_utf_string_quantitys_increase_) || !defined(_di_f_utf_string_quantitys_increase_by_) || !defined(_di_f_utf_string_quantitys_terminate_) || !defined(_di_f_utf_string_quantitys_terminate_after_) + extern f_status_t private_f_utf_string_quantitys_resize(const f_string_length_t length, f_utf_string_quantitys_t *quantitys) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_quantitys_decrease_by_) || !defined(_di_f_utf_string_quantitys_increase_) || !defined(_di_f_utf_string_quantitys_increase_by_) || !defined(_di_f_utf_string_quantitys_terminate_) || !defined(_di_f_utf_string_quantitys_terminate_after_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param quantityss + * The quantityss to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: private_f_utf_string_dynamic_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_quantityss_adjust() + * @see f_utf_string_quantityss_decimate_by() + * @see private_f_utf_string_dynamic_adjust() + */ +#if !defined(_di_f_utf_string_quantityss_adjust_) || !defined(_di_f_utf_string_quantityss_decimate_by_) + extern f_status_t private_f_utf_string_quantityss_adjust(const f_string_length_t length, f_utf_string_quantityss_t *quantityss) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_quantityss_adjust_) || !defined(_di_f_utf_string_quantityss_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param quantityss + * The quantityss to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: private_f_utf_string_dynamic_adjust(). + * + * @see f_memory_resize() + * @see f_utf_string_quantityss_decrease_by() + * @see f_utf_string_quantityss_increase() + * @see f_utf_string_quantityss_increase_by() + * @see f_utf_string_quantityss_terminate() + * @see f_utf_string_quantityss_terminate_after() + * @see private_f_utf_string_dynamic_resize() + */ +#if !defined(_di_f_utf_string_quantityss_decrease_by_) || !defined(_di_f_utf_string_quantityss_increase_) || !defined(_di_f_utf_string_quantityss_increase_by_) || !defined(_di_f_utf_string_quantityss_terminate_) || !defined(_di_f_utf_string_quantityss_terminate_after_) + extern f_status_t private_f_utf_string_quantityss_resize(const f_string_length_t length, f_utf_string_quantityss_t *quantityss) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_quantityss_decrease_by_) || !defined(_di_f_utf_string_quantityss_increase_) || !defined(_di_f_utf_string_quantityss_increase_by_) || !defined(_di_f_utf_string_quantityss_terminate_) || !defined(_di_f_utf_string_quantityss_terminate_after_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param ranges + * The ranges to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: private_f_utf_string_dynamic_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_ranges_adjust() + * @see f_utf_string_ranges_decimate_by() + * @see private_f_utf_string_dynamic_adjust() + */ +#if !defined(_di_f_utf_string_ranges_adjust_) || !defined(_di_f_utf_string_ranges_decimate_by_) + extern f_status_t private_f_utf_string_ranges_adjust(const f_string_length_t length, f_utf_string_ranges_t *ranges) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_ranges_adjust_) || !defined(_di_f_utf_string_ranges_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param ranges + * The ranges to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: private_f_utf_string_dynamic_adjust(). + * + * @see f_memory_resize() + * @see f_utf_string_ranges_decrease_by() + * @see f_utf_string_ranges_increase() + * @see f_utf_string_ranges_increase_by() + * @see f_utf_string_ranges_terminate() + * @see f_utf_string_ranges_terminate_after() + * @see private_f_utf_string_dynamic_resize() + */ +#if !defined(_di_f_utf_string_ranges_decrease_by_) || !defined(_di_f_utf_string_ranges_increase_) || !defined(_di_f_utf_string_ranges_increase_by_) || !defined(_di_f_utf_string_ranges_terminate_) || !defined(_di_f_utf_string_ranges_terminate_after_) + extern f_status_t private_f_utf_string_ranges_resize(const f_string_length_t length, f_utf_string_ranges_t *ranges) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_ranges_decrease_by_) || !defined(_di_f_utf_string_ranges_increase_) || !defined(_di_f_utf_string_ranges_increase_by_) || !defined(_di_f_utf_string_ranges_terminate_) || !defined(_di_f_utf_string_ranges_terminate_after_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param rangess + * The rangess to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: private_f_utf_string_dynamic_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_rangess_adjust() + * @see f_utf_string_rangess_decimate_by() + * @see private_f_utf_string_dynamic_adjust() + */ +#if !defined(_di_f_utf_string_rangess_adjust_) || !defined(_di_f_utf_string_rangess_decimate_by_) + extern f_status_t private_f_utf_string_rangess_adjust(const f_string_length_t length, f_utf_string_rangess_t *rangess) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_rangess_adjust_) || !defined(_di_f_utf_string_rangess_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param rangess + * The rangess to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: private_f_utf_string_dynamic_adjust(). + * + * @see f_memory_resize() + * @see f_utf_string_rangess_decrease_by() + * @see f_utf_string_rangess_increase() + * @see f_utf_string_rangess_increase_by() + * @see f_utf_string_rangess_terminate() + * @see f_utf_string_rangess_terminate_after() + * @see private_f_utf_string_dynamic_resize() + */ +#if !defined(_di_f_utf_string_rangess_decrease_by_) || !defined(_di_f_utf_string_rangess_increase_) || !defined(_di_f_utf_string_rangess_increase_by_) || !defined(_di_f_utf_string_rangess_terminate_) || !defined(_di_f_utf_string_rangess_terminate_after_) + extern f_status_t private_f_utf_string_rangess_resize(const f_string_length_t length, f_utf_string_rangess_t *rangess) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_rangess_decrease_by_) || !defined(_di_f_utf_string_rangess_increase_) || !defined(_di_f_utf_string_rangess_increase_by_) || !defined(_di_f_utf_string_rangess_terminate_) || !defined(_di_f_utf_string_rangess_terminate_after_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param triples + * The triples to adjust. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_adjust(). + * Errors (with error bit) from: private_f_utf_string_dynamic_adjust(). + * + * @see f_memory_adjust() + * @see f_utf_string_triples_adjust() + * @see f_utf_string_triples_decimate_by() + * @see private_f_utf_string_dynamic_adjust() + */ +#if !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) + extern f_status_t private_f_utf_string_triples_adjust(const f_string_length_t length, f_utf_string_triples_t *triples) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param triples + * The triples to resize. + * + * @return + * F_none on success. + * + * Errors (with error bit) from: f_memory_resize(). + * Errors (with error bit) from: private_f_utf_string_dynamic_adjust(). + * + * @see f_memory_resize() + * @see f_utf_string_triples_decrease_by() + * @see f_utf_string_triples_increase() + * @see f_utf_string_triples_increase_by() + * @see f_utf_string_triples_terminate() + * @see f_utf_string_triples_terminate_after() + * @see private_f_utf_string_dynamic_resize() + */ +#if !defined(_di_f_utf_string_triples_decrease_by_) || !defined(_di_f_utf_string_triples_increase_) || !defined(_di_f_utf_string_triples_increase_by_) || !defined(_di_f_utf_string_triples_terminate_) || !defined(_di_f_utf_string_triples_terminate_after_) + extern f_status_t private_f_utf_string_triples_resize(const f_string_length_t length, f_utf_string_triples_t *triples) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_triples_decrease_by_) || !defined(_di_f_utf_string_triples_increase_) || !defined(_di_f_utf_string_triples_increase_by_) || !defined(_di_f_utf_string_triples_terminate_) || !defined(_di_f_utf_string_triples_terminate_after_) + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf-common.c b/level_0/f_utf/c/utf-common.c new file mode 100644 index 0000000..4dba900 --- /dev/null +++ b/level_0/f_utf/c/utf-common.c @@ -0,0 +1,49 @@ +#include "utf.h" +#include "private-utf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_space_ + const int8_t f_utf_space_em_s[f_utf_space_em_length] = { 0xe2, 0x80, 0x83 }; + const int8_t f_utf_space_em_quad_s[f_utf_space_em_quad_length] = { 0xe2, 0x80, 0x81 }; + const int8_t f_utf_space_em_per_three_s[f_utf_space_em_per_three_length] = { 0xe2, 0x80, 0x84 }; + const int8_t f_utf_space_em_per_four_s[f_utf_space_em_per_four_length] = { 0xe2, 0x80, 0x85 }; + const int8_t f_utf_space_em_per_six_s[f_utf_space_em_per_six_length] = { 0xe2, 0x80, 0x86 }; + + const int8_t f_utf_space_en_s[f_utf_space_en_length] = { 0xe2, 0x80, 0x82 }; + const int8_t f_utf_space_en_quad_s[f_utf_space_en_quad_length] = { 0xe2, 0x80, 0x80 }; + + const int8_t f_utf_space_line_feed_reverse_s[f_utf_space_line_feed_reverse_length] = { 0xc2, 0x8d }; + const int8_t f_utf_space_line_next_s[f_utf_space_line_next_length] = { 0xc2, 0x85 }; + + const int8_t f_utf_space_medium_mathematical_s[f_utf_space_medium_mathematical_length] = { 0xe2, 0x81, 0x9f }; + + const int8_t f_utf_space_no_break_s[f_utf_space_no_break_length] = { 0xc2, 0xa0 }; + const int8_t f_utf_space_no_break_narrow_s[f_utf_space_no_break_narrow_length] = { 0xe2, 0x80, 0xaf }; + + const int8_t f_utf_space_ogham_s[f_utf_space_ogham_length] = { 0xe1, 0x9a, 0x80 }; + const int8_t f_utf_space_figure_s[f_utf_space_figure_length] = { 0xe2, 0x80, 0x87 }; + const int8_t f_utf_space_punctuation_s[f_utf_space_punctuation_length] = { 0xe2, 0x80, 0x88 }; + const int8_t f_utf_space_thin_s[f_utf_space_thin_length] = { 0xe2, 0x80, 0x89 }; + const int8_t f_utf_space_hair_s[f_utf_space_hair_length] = { 0xe2, 0x80, 0x8a }; + const int8_t f_utf_space_ideographic_s[f_utf_space_ideographic_length] = { 0xe3, 0x80, 0x80 }; + + const int8_t f_utf_space_separator_line_s[f_utf_space_separator_line_length] = { 0xe2, 0x80, 0xa8 }; + const int8_t f_utf_space_separator_paragraph_s[f_utf_space_separator_paragraph_length] = { 0xe2, 0x80, 0xa8 }; +#endif // _di_f_utf_space_ + +#ifndef _di_f_utf_substitute_ + const int8_t f_utf_substitute_symbol_blank_s[f_utf_substitute_symbol_blank_length] = { 0xe2, 0x90, 0xa2 }; + const int8_t f_utf_substitute_symbol_space_s[f_utf_substitute_symbol_space_length] = { 0xe2, 0x90, 0xa0 }; + + const int8_t f_utf_substitute_middle_dot_s[f_utf_substitute_middle_dot_length] = { 0xc2, 0xb7 }; + + const int8_t f_utf_substitute_open_box_s[f_utf_substitute_open_box_length] = { 0xe2, 0x90, 0xa3 }; + const int8_t f_utf_substitute_open_box_shouldered_s[f_utf_substitute_open_box_shouldered_length] = { 0xe2, 0x8d, 0xbd }; +#endif // _di_f_utf_substitute_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf-common.h b/level_0/f_utf/c/utf-common.h index 2801e84..f8465c1 100644 --- a/level_0/f_utf/c/utf-common.h +++ b/level_0/f_utf/c/utf-common.h @@ -56,6 +56,96 @@ extern "C" { #endif // _di_f_utf_byte_ /** + * Define the UTF-8 general whitespace codes. + * + * These are integers representing character codes that represent types of spaces. + * + * This does not provide whitespace codes for standard ascii whitespaces, such as '\t' or '\r'. + */ +#ifndef _di_f_utf_space_ + #define f_utf_space_em_length 3 + #define f_utf_space_em_quad_length 3 + #define f_utf_space_em_per_three_length 3 + #define f_utf_space_em_per_four_length 3 + #define f_utf_space_em_per_six_length 3 + + #define f_utf_space_en_length 3 + #define f_utf_space_en_quad_length 3 + + #define f_utf_space_line_feed_reverse_length 2 + #define f_utf_space_line_next_length 2 + + #define f_utf_space_medium_mathematical_length 3 + + #define f_utf_space_no_break_length 2 + #define f_utf_space_no_break_narrow_length 3 + + #define f_utf_space_ogham_length 3 + #define f_utf_space_figure_length 3 + #define f_utf_space_punctuation_length 3 + #define f_utf_space_thin_length 3 + #define f_utf_space_hair_length 3 + #define f_utf_space_ideographic_length 3 + + #define f_utf_space_separator_line_length 3 + #define f_utf_space_separator_paragraph_length 3 + + extern const int8_t f_utf_space_em_s[]; + extern const int8_t f_utf_space_em_quad_s[]; + extern const int8_t f_utf_space_em_per_three_s[]; + extern const int8_t f_utf_space_em_per_four_s[]; + extern const int8_t f_utf_space_em_per_six_s[]; + + extern const int8_t f_utf_space_en_s[]; + extern const int8_t f_utf_space_en_quad_s[]; + + extern const int8_t f_utf_space_line_feed_reverse_s[]; + extern const int8_t f_utf_space_line_next_s[]; + + extern const int8_t f_utf_space_medium_mathematical_s[]; + + extern const int8_t f_utf_space_no_break_s[]; + extern const int8_t f_utf_space_no_break_narrow_s[]; + + extern const int8_t f_utf_space_ogham_s[]; + extern const int8_t f_utf_space_figure_s[]; + extern const int8_t f_utf_space_punctuation_s[]; + extern const int8_t f_utf_space_thin_s[]; + extern const int8_t f_utf_space_hair_s[]; + extern const int8_t f_utf_space_ideographic_s[]; + + extern const int8_t f_utf_space_separator_line_s[]; + extern const int8_t f_utf_space_separator_paragraph_s[]; +#endif // _di_f_utf_space_ + +/** + * Define the UTF-8 general substitute whitespace codes. + * + * These are integers representing character codes that represent types of substitute spaces. + * + * Substitute codes are not actual codes and are actually prints of the codes so they should not be treated as the actual codes. + * + * This does not provide substitute whitespace codes for standard ascii whitespaces, such as '\t' or '\r'. + */ +#ifndef _di_f_utf_substitute_ + #define f_utf_substitute_symbol_blank_length 3 + #define f_utf_substitute_symbol_space_length 3 + + #define f_utf_substitute_middle_dot_length 2 + + #define f_utf_substitute_open_box_length 3 + #define f_utf_substitute_open_box_shouldered_length 3 + + extern const int8_t f_utf_substitute_symbol_blank_s[]; + extern const int8_t f_utf_substitute_symbol_space_s[]; + + extern const int8_t f_utf_substitute_middle_dot_s[]; + + extern const int8_t f_utf_substitute_open_box_s[]; + extern const int8_t f_utf_substitute_open_box_shouldered_s[]; +#endif // _di_f_utf_substitute_ + +/** * Provide a basic UTF-8 character as a single 4-byte variable. * * This is intended to be used when a single variable is desired to represent a 1-byte, 2-byte, 3-byte, or even 4-byte character. @@ -112,476 +202,24 @@ extern "C" { #endif // _di_f_utf_character_t_codes_ /** - * Provide a UTF-8 characters set to 4-bits wide as a string. + * Define the basic string type. + * + * Dynamic allocation macros are provided, but it is recommended to utilize the f_utf_string_dynamic_t for dynamic allocation. */ #ifndef _di_f_utf_string_t_ typedef f_utf_character_t *f_utf_string_t; - #define f_utf_string_t_size_max f_number_t_size_unsigned - - #define f_utf_string_t_initialize f_utf_character_t_eos + #define f_utf_string_t_initialize 0 - #define f_macro_utf_string_t_new(status, string, length) status = f_memory_new(length, sizeof(f_utf_string_t), (void **) & string); + #define f_macro_utf_string_t_clear(string) string = 0; - #define f_macro_utf_string_t_resize(status, string, old_length, new_length) status = f_memory_resize(old_length, new_length, sizeof(f_utf_string_t), (void **) & string); - #define f_macro_utf_string_t_adjust(status, string, old_length, new_length) status = f_memory_adjust(old_length, new_length, sizeof(f_utf_string_t), (void **) & string); + #define f_macro_utf_string_t_resize(status, string, length_old, length_new) status = f_memory_resize(length_old, length_new, sizeof(f_utf_string_t), (void **) & string); + #define f_macro_utf_string_t_adjust(status, string, length_old, length_new) status = f_memory_adjust(length_old, length_new, sizeof(f_utf_string_t), (void **) & string); - #define f_macro_utf_string_t_delete(status, string, size) status = f_memory_delete(size, sizeof(f_utf_string_t), (void **) & string); - #define f_macro_utf_string_t_destroy(status, string, size) status = f_memory_destroy(size, sizeof(f_utf_string_t), (void **) & string); + #define f_macro_utf_string_t_delete_simple(string, length) f_memory_resize(length, 0, sizeof(f_utf_string_t), (void **) & string); + #define f_macro_utf_string_t_destroy_simple(string, length) f_memory_adjust(length, 0, sizeof(f_utf_string_t), (void **) & string); #endif // _di_f_utf_string_t_ -/** - * Provide a type specifically for UTF-8 strings. - */ -#ifndef _di_f_utf_string_length_t_ - typedef f_number_unsigned_t f_utf_string_length_t; - - #define f_utf_string_length_t_size 0xfffffffffffffffe - #define f_utf_string_length_t_size_max f_number_t_size_max_unsigned - - #define f_macro_utf_string_length_t_new(status, string, length) status = f_memory_new(length, sizeof(f_utf_string_length_t), (void **) & string); - - #define f_macro_utf_string_length_t_resize(status, length, old_length, new_length) status = f_memory_resize(old_length, new_length, sizeof(f_utf_string_length_t), (void **) & length); - #define f_macro_utf_string_length_t_adjust(status, length, old_length, new_length) status = f_memory_adjust(old_length, new_length, sizeof(f_utf_string_length_t), (void **) & length); - - #define f_macro_utf_string_length_t_delete(status, string, length) status = f_memory_delete(length, sizeof(f_utf_string_length_t), (void **) & string); - #define f_macro_utf_string_length_t_destroy(status, string, size) status = f_memory_destroy(size, sizeof(f_utf_string_length_t), (void **) & string); -#endif // _di_f_utf_string_length_t_ - -/** - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_lengths_t_ - typedef struct { - f_utf_string_length_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_lengths_t; - - #define f_utf_string_lengths_t_initialize { 0, 0, 0 } - - #define f_macro_utf_string_lengths_t_clear(lengths) f_macro_memory_structure_clear(lengths); - - #define f_macro_utf_string_lengths_t_new(status, string_lengths, length) f_macro_memory_structure_new(status, string_lengths, f_utf_string_length_t, length); - - #define f_macro_utf_string_lengths_t_resize(status, string_lengths, length) f_macro_memory_structure_resize(status, string_lengths, f_utf_string_length_t, length); - #define f_macro_utf_string_lengths_t_adjust(status, string_lengths, length) f_macro_memory_structure_adjust(status, string_lengths, f_utf_string_length_t, length); - - #define f_macro_utf_string_lengths_t_delete(status, string_lengths) f_macro_memory_structure_delete(status, string_lengths, f_utf_string_length_t); - #define f_macro_utf_string_lengths_t_destroy(status, string_lengths) f_macro_memory_structure_destroy(status, string_lengths, f_utf_string_length_t); - - #define f_macro_utf_string_lengths_t_delete_simple(string_lengths) f_macro_memory_structure_delete_simple(string_lengths, f_utf_string_length_t); - #define f_macro_utf_string_lengths_t_destroy_simple(string_lengths) f_macro_memory_structure_destroy_simple(string_lengths, f_utf_string_length_t); - - #define f_macro_utf_string_lengths_t_increase(status, string_lengths) f_macro_memory_structure_increase(status, string_lengths, f_utf_string_length_t); - #define f_macro_utf_string_lengths_t_increase_by(status, string_lengths, amount) f_macro_memory_structure_increase_by(status, string_lengths, f_utf_string_length_t, amount); - #define f_macro_utf_string_lengths_t_decrease_by(status, string_lengths, amount) f_macro_memory_structure_decrease_by(status, string_lengths, f_utf_string_length_t, amount); - #define f_macro_utf_string_lengths_t_decimate_by(status, string_lengths, amount) f_macro_memory_structure_decimate_by(status, string_lengths, f_utf_string_length_t, amount); -#endif // _di_f_utf_string_lengths_t_ - -/** - * Designates a start and stop position that represents a sub-string inside of some parent string. - * use this to avoid resizing, restructuring, and reallocating the parent string to separate the sub-string. - * - * A special f_macro_utf_string_range_t_initialize() is provided for the special purpose of easily initialize a static string range. - */ -#ifndef _di_f_utf_string_range_t_ - typedef struct { - f_utf_string_length_t start; - f_utf_string_length_t stop; - } f_utf_string_range_t; - - #define f_utf_string_range_t_initialize { 1, 0 } - - #define f_macro_utf_string_range_t_initialize(length) { length ? 0 : 1, length ? length - 1 : 0 } - - #define f_macro_utf_string_range_t_new(status, utf_string_range, length) status = f_memory_new(length, sizeof(f_utf_string_range_t), (void **) & utf_string_range); - - #define f_macro_utf_string_range_t_resize(status, utf_string_range, old_length, new_length) status = f_memory_resize(old_length, new_length, sizeof(f_utf_string_range_t), (void **) & utf_string_range); - #define f_macro_utf_string_range_t_adjust(status, utf_string_range, old_length, new_length) status = f_memory_adjust(old_length, new_length, sizeof(f_utf_string_range_t), (void **) & utf_string_range); - - #define f_macro_utf_string_range_t_delete(status, utf_string_range, size) status = f_memory_delete(size, sizeof(f_utf_string_range_t), (void **) & utf_string_range); - #define f_macro_utf_string_range_t_destroy(status, utf_string_range, size) status = f_memory_destroy(size, sizeof(f_utf_string_range_t), (void **) & utf_string_range); -#endif // _di_f_utf_string_range_t_ - -/** - * An array of string ranges. - * - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_ranges_t_ - typedef struct { - f_utf_string_range_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_ranges_t; - - #define f_utf_string_ranges_t_initialize { 0, 0, 0 } - - #define f_macro_utf_string_ranges_t_clear(lengths) f_macro_memory_structure_clear(lengths); - - #define f_macro_utf_string_ranges_t_new(status, string_ranges, length) f_macro_memory_structure_new(status, string_ranges, f_utf_string_range_t, length); - - #define f_macro_utf_string_ranges_t_resize(status, string_ranges, length) f_macro_memory_structure_resize(status, string_ranges, f_utf_string_range_t, length); - #define f_macro_utf_string_ranges_t_adjust(status, string_ranges, length) f_macro_memory_structure_adjust(status, string_ranges, f_utf_string_range_t, length); - - #define f_macro_utf_string_ranges_t_delete(status, string_ranges) f_macro_memory_structure_delete(status, string_ranges, f_utf_string_range_t); - #define f_macro_utf_string_ranges_t_destroy(status, string_ranges) f_macro_memory_structure_destroy(status, string_ranges, f_utf_string_range_t); - - #define f_macro_utf_string_ranges_t_delete_simple(string_ranges) f_macro_memory_structure_delete_simple(string_ranges, f_utf_string_range_t); - #define f_macro_utf_string_ranges_t_destroy_simple(string_ranges) f_macro_memory_structure_destroy_simple(string_ranges, f_utf_string_range_t); - - #define f_macro_utf_string_ranges_t_increase(status, string_ranges) f_macro_memory_structure_increase(status, string_ranges, f_utf_string_range_t); - #define f_macro_utf_string_ranges_t_increase_by(status, string_ranges, amount) f_macro_memory_structure_increase_by(status, string_ranges, f_utf_string_range_t, amount); - #define f_macro_utf_string_ranges_t_decrease_by(status, string_ranges, amount) f_macro_memory_structure_decrease_by(status, string_ranges, f_utf_string_range_t, amount); - #define f_macro_utf_string_ranges_t_decimate_by(status, string_ranges, amount) f_macro_memory_structure_decimate_by(status, string_ranges, f_utf_string_range_t, amount); -#endif // _di_f_utf_string_ranges_t_ - -/** - * Store string quantity. - * - * Similar to f_utf_string_range_t, except total is relative to start and is not an absolute stop position. - * - * Two common uses for when total is 0 is: - * 1) Exactly that, process a total of 0 strings bytes. - * 2) Process with no limit, aka infinite. - * - * start: The position where the string starts (based on some string/buffer). - * total: The total number of elements within that string/buffer the quantity represents. - */ -#ifndef _di_f_utf_string_quantity_t_ - typedef struct { - f_utf_string_length_t start; - f_utf_string_length_t total; - } f_utf_string_quantity_t; - - #define f_utf_string_quantity_t_initialize { 0, 0 } -#endif // _di_f_utf_string_quantity_t_ - -/** - * An array of string quantities. - * - * array: the array of string quantities. - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_quantitys_t_ - typedef struct { - f_utf_string_quantity_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_quantitys_t; - - #define f_utf_string_quantitys_t_initialize {0, 0, 0} - - #define f_macro_utf_string_quantitys_t_clear(lengths) f_macro_memory_structure_clear(lengths); - - #define f_macro_utf_string_quantitys_t_new(status, quantitys, length) f_macro_memory_structure_new(status, quantitys, f_utf_string_quantity_t, length); - - #define f_macro_utf_string_quantitys_t_resize(status, quantitys, length) f_macro_memory_structure_resize(status, quantitys, f_utf_string_quantity_t, length); - #define f_macro_utf_string_quantitys_t_adjust(status, quantitys, length) f_macro_memory_structure_adjust(status, quantitys, f_utf_string_quantity_t, length); - - #define f_macro_utf_string_quantitys_t_delete(status, quantitys) f_macro_memory_structure_delete(status, quantitys, f_utf_string_quantity_t); - #define f_macro_utf_string_quantitys_t_destroy(status, quantitys) f_macro_memory_structure_destroy(status, quantitys, f_utf_string_quantity_t); - - #define f_macro_utf_string_quantitys_t_delete_simple(quantitys) f_macro_memory_structure_delete_simple(quantitys, f_utf_string_quantity_t); - #define f_macro_utf_string_quantitys_t_destroy_simple(quantitys) f_macro_memory_structure_destroy_simple(quantitys, f_utf_string_quantity_t); - - #define f_macro_utf_string_quantitys_t_increase(status, quantitys) f_macro_memory_structure_increase(status, quantitys, f_utf_string_quantity_t); - #define f_macro_utf_string_quantitys_t_increase_by(status, quantitys, amount) f_macro_memory_structure_increase_by(status, quantitys, f_utf_string_quantity_t, amount); - #define f_macro_utf_string_quantitys_t_decrease_by(status, quantitys, amount) f_macro_memory_structure_decrease_by(status, quantitys, f_utf_string_quantity_t, amount); - #define f_macro_utf_string_quantitys_t_decimate_by(status, quantitys, amount) f_macro_memory_structure_decimate_by(status, quantitys, f_utf_string_quantity_t, amount); -#endif // _di_f_utf_string_quantitys_t_ - -/** - * A string that is analogous to f_utf_string_dynamic_t but intended for static-only uses. - * - * The f_utf_string_static_t type should never be directly allocated or deallocated. - * - * A special f_macro_utf_string_static_t_initialize() is provided for the special purpose of easily initialize a static string. - * - * string: the string. - * size: total amount of space available. - * used: total number of space used. - */ -#ifndef _di_f_utf_string_static_t_ - typedef struct { - f_utf_string_t string; - - f_utf_string_length_t size; - f_utf_string_length_t used; - } f_utf_string_static_t; - - #define f_utf_string_static_t_initialize { f_utf_string_t_initialize, 0, 0 } - - #define f_macro_utf_string_static_t_clear(string_static) \ - string_static.string = 0; \ - string_static.size = 0; \ - string_static.used = 0; - - #define f_macro_utf_string_static_t_initialize(string, length) { string, length, length } -#endif // _di_f_string_static_t_ - -/** - * A string that supports contains a size attribute to handle dynamic allocations and deallocations. - * save the string size along with the string, so that strlen(..) commands can be avoided as much as possible. - * - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_dynamic_t_ - typedef f_utf_string_static_t f_utf_string_dynamic_t; - - #define f_utf_string_dynamic_t_initialize f_utf_string_static_t_initialize - - #define f_macro_utf_string_dynamic_t_clear(dynamic) f_macro_utf_string_static_t_clear(dynamic) - - #define f_macro_utf_string_dynamic_t_new(status, dynamic, new_length) \ - f_clear_utf_string_dynamic_t(dynamic) \ - status = f_memory_new(new_length, sizeof(f_utf_string_t), (void **) & dynamic.string); \ - if (status == F_none) { \ - dynamic.size = new_length; \ - dynamic.used = 0; \ - } - - #define f_macro_utf_string_dynamic_t_resize(status, dynamic, new_length) \ - status = f_memory_resize(dynamic.size, new_length, sizeof(f_utf_string_t), (void **) & dynamic.string); \ - if (status == F_none) { \ - dynamic.size = new_length; \ - if (dynamic.used > dynamic.size) dynamic.used = new_length; \ - } - - #define f_macro_utf_string_dynamic_t_adjust(status, dynamic, new_length) \ - status = f_memory_adjust(dynamic.size, new_length, sizeof(f_utf_string_t), (void **) & dynamic.string); \ - if (status == F_none) { \ - dynamic.size = new_length; \ - if (dynamic.used > dynamic.size) dynamic.used = new_length; \ - } - - #define f_macro_utf_string_dynamic_t_delete(status, dynamic) \ - status = f_memory_delete(dynamic.size, sizeof(f_utf_string_t), (void **) & dynamic.string); \ - if (status == F_none) { \ - dynamic.size = 0; \ - dynamic.used = 0; \ - } - - #define f_macro_utf_string_dynamic_t_destroy(status, dynamic) \ - status = f_memory_destroy(dynamic.size, sizeof(f_utf_string_t), (void **) & dynamic.string); \ - if (status == F_none) { \ - dynamic.size = 0; \ - dynamic.used = 0; \ - } - - #define f_macro_utf_string_dynamic_t_delete_simple(dynamic) \ - f_memory_delete(dynamic.size, sizeof(f_utf_string_t), (void **) & dynamic.string); \ - dynamic.size = 0; \ - dynamic.used = 0; - - #define f_macro_utf_string_dynamic_t_destroy_simple(dynamic) \ - f_memory_destroy(dynamic.size, sizeof(f_utf_string_t), (void **) & dynamic.string); \ - dynamic.size = 0; \ - dynamic.used = 0; -#endif // _di_f_utf_string_dynamic_t_ - -/** - * An array of dynamic utf_strings. - * - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_dynamics_t_ - typedef struct { - f_utf_string_dynamic_t *array; - - f_utf_string_length_t size; - f_utf_string_length_t used; - } f_utf_string_dynamics_t; - - #define f_utf_string_dynamics_t_initialize { 0, 0, 0 } - - #define f_macro_utf_string_dynamics_t_clear(dynamics) \ - dynamics.array = 0; \ - dynamics.size = 0; \ - dynamics.used = 0; - - #define f_macro_utf_string_dynamics_t_new(status, dynamics, length) \ - dynamics.array = 0; \ - dynamics.size = 0; \ - dynamics.used = 0; \ - status = f_memory_new(length, sizeof(f_utf_string_dynamic_t), (void **) & dynamics.array); \ - if (status == F_none) { \ - dynamics.size = length; \ - dynamics.used = 0; \ - } - - #define f_macro_utf_string_dynamics_t_resize(status, dynamics, new_length) \ - status = F_none; \ - if (new_length < dynamics.size) { \ - for (f_utf_string_length_t _macro__i = dynamics.size - new_length; _macro__i < dynamics.size; ++_macro__i) { \ - f_macro_utf_string_dynamic_t_destroy(status, dynamics.array[_macro__i]); \ - if (F_status_is_error(status)) break; \ - } \ - } \ - if (status == F_none) status = f_memory_resize(dynamics.size, new_length, sizeof(f_utf_string_dynamic_t), (void **) & dynamics.array); \ - if (status == F_none) { \ - dynamics.size = new_length; \ - if (dynamics.used > dynamics.size) dynamics.used = new_length; \ - } - - #define f_macro_utf_string_dynamics_t_adjust(status, dynamics, new_length) \ - status = F_none; \ - if (new_length < dynamics.size) { \ - for (f_utf_string_length_t _macro__i = dynamics.size - new_length; _macro__i < dynamics.size; ++_macro__i) { \ - f_macro_utf_string_dynamic_t_destroy(status, dynamics.array[_macro__i], f_utf_string_dynamic_t); \ - if (F_status_is_error(status)) break; \ - } \ - } \ - if (status == F_none) status = f_memory_adjust(dynamics.size, new_length, sizeof(f_utf_string_dynamic_t), (void **) & dynamics.array); \ - if (status == F_none) { \ - dynamics.size = new_length; \ - if (dynamics.used > dynamics.size) dynamics.used = new_length; \ - } - - #define f_macro_utf_string_dynamics_t_delete(status, dynamics) \ - status = F_none; \ - while (dynamics.size > 0) { \ - --dynamics.size; \ - f_macro_utf_string_dynamic_t_destroy(status, dynamics.array[dynamics.size]); \ - if (F_status_is_error(status)) break; \ - } \ - if (status == F_none) status = f_memory_delete(dynamics.size, sizeof(f_utf_string_dynamic_t), (void **) & dynamics.array); \ - if (status == F_none) dynamics.used = 0; - - #define f_macro_utf_string_dynamics_t_destroy(status, dynamics) \ - status = F_none; \ - while (dynamics.size > 0) { \ - --dynamics.size; \ - f_macro_utf_string_dynamic_t_destroy(status, dynamics.array[dynamics.size]); \ - if (F_status_is_error(status)) break; \ - } \ - if (status == F_none) status = f_memory_destroy(dynamics.size, sizeof(f_utf_string_dynamic_t), (void **) & dynamics.array); \ - if (status == F_none) dynamics.used = 0; - - #define f_macro_utf_string_dynamics_t_delete_simple(dynamics) \ - dynamics.used = dynamics.size; \ - while (dynamics.used > 0) { \ - dynamics.used--; \ - f_macro_string_dynamic_t_delete_simple(dynamics.array[dynamics.used]); \ - if (!dynamics.used) { \ - if (f_memory_delete(dynamics.size, sizeof(f_utf_string_dynamic_t), (void **) & dynamics.array)) { \ - dynamics.size = 0; \ - } \ - } \ - } - - #define f_macro_utf_string_dynamics_t_destroy_simple(dynamics) \ - dynamics.used = dynamics.size; \ - while (dynamics.used > 0) { \ - dynamics.used--; \ - f_macro_string_dynamic_t_destroy_simple(dynamics.array[dynamics.used]); \ - if (!dynamics.used) { \ - if (f_memory_destroy(dynamics.size, sizeof(f_utf_string_dynamic_t), (void **) & dynamics.array)) { \ - dynamics.size = 0; \ - } \ - } \ - } -#endif // _di_f_utf_string_dynamic_t_ - -/** - * Define the UTF-8 general whitespace codes. - * - * These are integers representing character codes that represent types of spaces. - * - * This does not provide whitespace codes for standard ascii whitespaces, such as '\t' or '\r'. - */ -#ifndef _di_f_utf_space_ - #define f_utf_space_em_length 3 - #define f_utf_space_em_quad_length 3 - #define f_utf_space_em_per_three_length 3 - #define f_utf_space_em_per_four_length 3 - #define f_utf_space_em_per_six_length 3 - - #define f_utf_space_en_length 3 - #define f_utf_space_en_quad_length 3 - - #define f_utf_space_line_feed_reverse_length 2 - #define f_utf_space_line_next_length 2 - - #define f_utf_space_medium_mathematical_length 3 - - #define f_utf_space_no_break_length 2 - #define f_utf_space_no_break_narrow_length 3 - - #define f_utf_space_ogham_length 3 - #define f_utf_space_figure_length 3 - #define f_utf_space_punctuation_length 3 - #define f_utf_space_thin_length 3 - #define f_utf_space_hair_length 3 - #define f_utf_space_ideographic_length 3 - - #define f_utf_space_separator_line_length 3 - #define f_utf_space_separator_paragraph_length 3 - - const static int8_t f_utf_space_em[f_utf_space_em_length] = { 0xe2, 0x80, 0x83 }; - const static int8_t f_utf_space_em_quad[f_utf_space_em_quad_length] = { 0xe2, 0x80, 0x81 }; - const static int8_t f_utf_space_em_per_three[f_utf_space_em_per_three_length] = { 0xe2, 0x80, 0x84 }; - const static int8_t f_utf_space_em_per_four[f_utf_space_em_per_four_length] = { 0xe2, 0x80, 0x85 }; - const static int8_t f_utf_space_em_per_six[f_utf_space_em_per_six_length] = { 0xe2, 0x80, 0x86 }; - - const static int8_t f_utf_space_en[f_utf_space_en_length] = { 0xe2, 0x80, 0x82 }; - const static int8_t f_utf_space_en_quad[f_utf_space_en_quad_length] = { 0xe2, 0x80, 0x80 }; - - const static int8_t f_utf_space_line_feed_reverse[f_utf_space_line_feed_reverse_length] = { 0xc2, 0x8d }; - const static int8_t f_utf_space_line_next[f_utf_space_line_next_length] = { 0xc2, 0x85 }; - - const static int8_t f_utf_space_medium_mathematical[f_utf_space_medium_mathematical_length] = { 0xe2, 0x81, 0x9f }; - - const static int8_t f_utf_space_no_break[f_utf_space_no_break_length] = { 0xc2, 0xa0 }; - const static int8_t f_utf_space_no_break_narrow[f_utf_space_no_break_narrow_length] = { 0xe2, 0x80, 0xaf }; - - const static int8_t f_utf_space_ogham[f_utf_space_ogham_length] = { 0xe1, 0x9a, 0x80 }; - const static int8_t f_utf_space_figure[f_utf_space_figure_length] = { 0xe2, 0x80, 0x87 }; - const static int8_t f_utf_space_punctuation[f_utf_space_punctuation_length] = { 0xe2, 0x80, 0x88 }; - const static int8_t f_utf_space_thin[f_utf_space_thin_length] = { 0xe2, 0x80, 0x89 }; - const static int8_t f_utf_space_hair[f_utf_space_hair_length] = { 0xe2, 0x80, 0x8a }; - const static int8_t f_utf_space_ideographic[f_utf_space_ideographic_length] = { 0xe3, 0x80, 0x80 }; - - const static int8_t f_utf_space_separator_line[f_utf_space_separator_line_length] = { 0xe2, 0x80, 0xa8 }; - const static int8_t f_utf_space_separator_paragraph[f_utf_space_separator_paragraph_length] = { 0xe2, 0x80, 0xa8 }; -#endif // _di_f_utf_space_ - -/** - * Define the UTF-8 general substitute whitespace codes. - * - * These are integers representing character codes that represent types of substitute spaces. - * - * Substitute codes are not actual codes and are actually prints of the codes so they should not be treated as the actual codes. - * - * This does not provide substitute whitespace codes for standard ascii whitespaces, such as '\t' or '\r'. - */ -#ifndef _di_f_utf_substitute_ - #define f_utf_substitute_symbol_blank_length 3 - #define f_utf_substitute_symbol_space_length 3 - - #define f_utf_substitute_middle_dot_length 2 - - #define f_utf_substitute_open_box_length 3 - #define f_utf_substitute_open_box_shouldered_length 3 - - const static int8_t f_utf_substitute_symbol_blank[f_utf_substitute_symbol_blank_length] = { 0xe2, 0x90, 0xa2 }; - const static int8_t f_utf_substitute_symbol_space[f_utf_substitute_symbol_space_length] = { 0xe2, 0x90, 0xa0 }; - - const static int8_t f_utf_substitute_middle_dot[f_utf_substitute_middle_dot_length] = { 0xc2, 0xb7 }; - - const static int8_t f_utf_substitute_open_box[f_utf_substitute_open_box_length] = { 0xe2, 0x90, 0xa3 }; - const static int8_t f_utf_substitute_open_box_shouldered[f_utf_substitute_open_box_shouldered_length] = { 0xe2, 0x8d, 0xbd }; -#endif // _di_f_utf_substitute_ - #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf.c b/level_0/f_utf/c/utf.c index 0e1f9f6..205c3a7 100644 --- a/level_0/f_utf/c/utf.c +++ b/level_0/f_utf/c/utf.c @@ -1601,6 +1601,1004 @@ extern "C" { } #endif // _di_f_utf_char_to_character_ +#ifndef _di_f_utf_string_append_ + f_status_t f_utf_string_append(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not_eos; + + return private_f_utf_string_append(source, length, destination); + } +#endif // _di_f_utf_string_append_ + +#ifndef _di_f_utf_string_append_assure_ + f_status_t f_utf_string_append_assure(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not_eos; + if (destination->used < length) return private_f_utf_string_append(source, length, destination); + + f_string_length_t i = 1; + f_string_length_t j = 1; + + while (i <= length && j <= destination->used) { + if (!source[length - i]) { + i++; + continue; + } + + if (!destination->string[destination->used - j]) { + j++; + continue; + } + + if (source[length - i] != destination->string[destination->used - j]) { + return private_f_utf_string_append(source, length, destination); + } + + i++; + j++; + } // while + + return F_none; + } +#endif // _di_f_utf_string_append_assure_ + +#ifndef _di_f_utf_string_append_assure_nulless_ + f_status_t f_utf_string_append_assure_nulless(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not_eos; + + if (destination->used < length) { + return private_f_utf_string_append_nulless(source, length, destination); + } + + f_string_length_t i = 1; + f_string_length_t j = 1; + + while (i <= length && j <= destination->used) { + if (!source[length - i]) { + i++; + continue; + } + + if (!destination->string[destination->used - j]) { + j++; + continue; + } + + if (source[length - i] != destination->string[destination->used - j]) { + return private_f_utf_string_append_nulless(source, length, destination); + } + + i++; + j++; + } // while + + return F_none; + } +#endif // _di_f_utf_string_append_assure_nulless_ + +#ifndef _di_f_utf_string_append_nulless_ + f_status_t f_utf_string_append_nulless(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not_eos; + + return private_f_utf_string_append_nulless(source, length, destination); + } +#endif // _di_f_utf_string_append_nulless_ + +#ifndef _di_f_utf_string_dynamic_append_ + f_status_t f_utf_string_dynamic_append(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + + return private_f_utf_string_append(source.string, source.used, destination); + } +#endif // _di_f_utf_string_dynamic_append_ + +#ifndef _di_f_utf_string_dynamic_append_assure_ + f_status_t f_utf_string_dynamic_append_assure(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + + if (destination->used < source.used) { + return private_f_utf_string_append(source.string, source.used, destination); + } + + f_string_length_t i = 1; + f_string_length_t j = 1; + + while (i <= source.used && j <= destination->used) { + if (!source.string[source.used - i]) { + i++; + continue; + } + + if (!destination->string[destination->used - j]) { + j++; + continue; + } + + if (source.string[source.used - i] != destination->string[destination->used - j]) { + return private_f_utf_string_append(source.string, source.used, destination); + } + + i++; + j++; + } // while + + return F_none; + } +#endif // _di_f_utf_string_dynamic_append_assure_ + +#ifndef _di_f_utf_string_dynamic_append_assure_nulless_ + f_status_t f_utf_string_dynamic_append_assure_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + + if (destination->used < source.used) { + return private_f_utf_string_append_nulless(source.string, source.used, destination); + } + + f_string_length_t i = 1; + f_string_length_t j = 1; + + while (i <= source.used && j <= destination->used) { + if (!source.string[source.used - i]) { + i++; + continue; + } + + if (!destination->string[destination->used - j]) { + j++; + continue; + } + + if (source.string[source.used - i] != destination->string[destination->used - j]) { + return private_f_utf_string_append_nulless(source.string, source.used, destination); + } + + i++; + j++; + } // while + + return F_none; + } +#endif // _di_f_utf_string_dynamic_append_assure_nulless_ + +#ifndef _di_f_utf_string_dynamic_append_nulless_ + f_status_t f_utf_string_dynamic_append_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + + return private_f_utf_string_append_nulless(source.string, source.used, destination); + } +#endif // _di_f_utf_string_dynamic_append_nulless_ + +#ifndef _di_f_utf_string_dynamic_mash_ + f_status_t f_utf_string_dynamic_mash(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + + if (glue_length && destination->used) { + const f_status_t status = private_f_utf_string_append(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_append(source.string, source.used, destination); + } +#endif // _di_f_utf_string_dynamic_mash_ + +#ifndef _di_f_utf_string_dynamic_mash_nulless_ + f_status_t f_utf_string_dynamic_mash_nulless(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + + if (glue_length && destination->used) { + const f_status_t status = private_f_utf_string_append_nulless(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_append_nulless(source.string, source.used, destination); + } +#endif // _di_f_utf_string_dynamic_mash_nulless_ + +#ifndef _di_f_utf_string_dynamic_mish_ + f_status_t f_utf_string_dynamic_mish(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + + if (glue_length && destination->used) { + const f_status_t status = private_f_utf_string_prepend(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_prepend(source.string, source.used, destination); + } +#endif // _di_f_utf_string_dynamic_mish_ + +#ifndef _di_f_utf_string_dynamic_mish_nulless_ + f_status_t f_utf_string_dynamic_mish_nulless(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + + if (glue_length && destination->used) { + const f_status_t status = private_f_utf_string_prepend_nulless(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_prepend_nulless(source.string, source.used, destination); + } +#endif // _di_f_utf_string_dynamic_mish_nulless_ + +#ifndef _di_f_utf_string_dynamic_partial_append_ + f_status_t f_utf_string_dynamic_partial_append(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (source.used <= range.stop) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + if (range.start > range.stop) return F_data_not_stop; + + return private_f_utf_string_append(source.string + range.start, (range.stop - range.start) + 1, destination); + } +#endif // _di_f_utf_string_dynamic_partial_append_ + +#ifndef _di_f_utf_string_dynamic_partial_append_assure_ + f_status_t f_utf_string_dynamic_partial_append_assure(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (source.used <= range.stop) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + if (range.start > range.stop) return F_data_not_stop; + + const f_string_length_t length = (range.stop - range.start) + 1; + + if (destination->used < length) { + return private_f_utf_string_append(source.string + range.start, length, destination); + } + + f_string_length_t i = 1; + f_string_length_t j = 1; + + while (i <= length && j <= destination->used) { + if (!source.string[range.stop - i]) { + i++; + continue; + } + + if (!destination->string[destination->used - j]) { + j++; + continue; + } + + if (source.string[range.stop - i] != destination->string[destination->used - j]) { + return private_f_utf_string_append(source.string + range.start, length, destination); + } + + i++; + j++; + } // while + } +#endif // _di_f_utf_string_dynamic_partial_append_assure_ + +#ifndef _di_f_utf_string_dynamic_partial_append_assure_nulless_ + f_status_t f_utf_string_dynamic_partial_append_assure_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (source.used <= range.stop) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + if (range.start > range.stop) return F_data_not_stop; + + const f_string_length_t length = (range.stop - range.start) + 1; + + if (destination->used < length) { + return private_f_utf_string_append_nulless(source.string + range.start, length, destination); + } + + f_string_length_t i = 1; + f_string_length_t j = 1; + + while (i <= length && j <= destination->used) { + if (!source.string[range.stop - i]) { + i++; + continue; + } + + if (!destination->string[destination->used - j]) { + j++; + continue; + } + + if (source.string[range.stop - i] != destination->string[destination->used - j]) { + return private_f_utf_string_append_nulless(source.string + range.start, length, destination); + } + + i++; + j++; + } // while + } +#endif // _di_f_utf_string_dynamic_append_assure_nulless_ + +#ifndef _di_f_utf_string_dynamic_partial_append_nulless_ + f_status_t f_utf_string_dynamic_partial_append_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (source.used <= range.stop) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + if (range.start > range.stop) return F_data_not_stop; + + return private_f_utf_string_append_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); + } +#endif // _di_f_utf_string_dynamic_partial_append_nulless_ + +#ifndef _di_f_utf_string_dynamic_partial_mash_ + f_status_t f_utf_string_dynamic_partial_mash(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (source.used <= range.stop) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + if (range.start > range.stop) return F_data_not_stop; + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_append(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_append(source.string + range.start, (range.stop - range.start) + 1, destination); + } +#endif // _di_f_utf_string_dynamic_partial_mash_ + +#ifndef _di_f_utf_string_dynamic_partial_mash_nulless_ + f_status_t f_utf_string_dynamic_partial_mash_nulless(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (source.used <= range.stop) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + if (range.start > range.stop) return F_data_not_stop; + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_append_nulless(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_append_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); + } +#endif // _di_f_utf_string_dynamic_partial_mash_nulless_ + +#ifndef _di_f_utf_string_dynamic_partial_mish_ + f_status_t f_utf_string_dynamic_partial_mish(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (source.used <= range.stop) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + if (range.start > range.stop) return F_data_not_stop; + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_prepend(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_prepend(source.string + range.start, (range.stop - range.start) + 1, destination); + } +#endif // _di_f_utf_string_dynamic_partial_mish_ + +#ifndef _di_f_utf_string_dynamic_partial_mish_nulless_ + f_status_t f_utf_string_dynamic_partial_mish_nulless(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (source.used <= range.stop) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + if (range.start > range.stop) return F_data_not_stop; + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_prepend_nulless(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_prepend_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); + } +#endif // _di_f_utf_string_dynamic_partial_mish_nulless_ + +#ifndef _di_f_utf_string_dynamic_partial_prepend_ + f_status_t f_utf_string_dynamic_partial_prepend(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (source.used <= range.stop) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + if (range.start > range.stop) return F_data_not_stop; + + return private_f_utf_string_prepend(source.string + range.start, (range.stop - range.start) + 1, destination); + } +#endif // _di_f_utf_string_dynamic_partial_prepend_ + +#ifndef _di_f_utf_string_dynamic_partial_prepend_assure_ + f_status_t f_utf_string_dynamic_partial_prepend_assure(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (source.used <= range.stop) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + if (range.start > range.stop) return F_data_not_stop; + + const f_string_length_t length = (range.stop - range.start) + 1; + + if (destination->used < length) { + return private_f_utf_string_prepend(source.string + range.start, length, destination); + } + + f_string_length_t i = 0; + f_string_length_t j = 0; + + while (i < length && j < destination->used) { + if (!source.string[i + range.start]) { + i++; + continue; + } + + if (!destination->string[j]) { + j++; + continue; + } + + if (source.string[i + range.start] != destination->string[i]) { + return private_f_utf_string_prepend(source.string + range.start, length, destination); + } + + i++; + j++; + } // while + + return F_none; + } +#endif // _di_f_utf_string_dynamic_partial_prepend_assure_ + +#ifndef _di_f_utf_string_dynamic_partial_prepend_assure_nulless_ + f_status_t f_utf_string_dynamic_partial_prepend_assure_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (source.used <= range.stop) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + if (range.start > range.stop) return F_data_not_stop; + + const f_string_length_t length = (range.stop - range.start) + 1; + + if (destination->used < length) { + return private_f_utf_string_prepend_nulless(source.string + range.start, length, destination); + } + + f_string_length_t i = 0; + f_string_length_t j = 0; + + while (i < length && j < destination->used) { + if (!source.string[i + range.start]) { + i++; + continue; + } + + if (!destination->string[j]) { + j++; + continue; + } + + if (source.string[i + range.start] != destination->string[i]) { + return private_f_utf_string_prepend_nulless(source.string + range.start, length, destination); + } + + i++; + j++; + } // while + + return F_none; + } +#endif // _di_f_utf_string_dynamic_partial_prepend_assure_nulless + +#ifndef _di_f_utf_string_dynamic_partial_prepend_nulless_ + f_status_t f_utf_string_dynamic_partial_prepend_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (source.used <= range.stop) return F_status_set_error(F_parameter); + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + if (range.start > range.stop) return F_data_not_stop; + + return private_f_utf_string_prepend_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); + } +#endif // _di_f_utf_string_dynamic_partial_prepend_nulless + +#ifndef _di_f_utf_string_dynamic_prepend_ + f_status_t f_utf_string_dynamic_prepend(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + + return private_f_utf_string_prepend(source.string, source.used, destination); + } +#endif // _di_f_utf_string_dynamic_prepend_ + +#ifndef _di_f_utf_string_dynamic_prepend_assure_ + f_status_t f_utf_string_dynamic_prepend_assure(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + + if (destination->used < source.used) { + return private_f_utf_string_prepend(source.string, source.used, destination); + } + + f_string_length_t i = 0; + f_string_length_t j = 0; + + while (i < source.used && j < destination->used) { + if (!source.string[i]) { + i++; + continue; + } + + if (!destination->string[j]) { + j++; + continue; + } + + if (source.string[i] != destination->string[i]) { + return private_f_utf_string_prepend(source.string, source.used, destination); + } + + i++; + j++; + } // while + + return F_none; + } +#endif // _di_f_utf_string_dynamic_prepend_assure_ + +#ifndef _di_f_utf_string_dynamic_prepend_assure_nulless_ + f_status_t f_utf_string_dynamic_prepend_assure_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + + if (destination->used < source.used) { + return private_f_utf_string_prepend_nulless(source.string, source.used, destination); + } + + f_string_length_t i = 0; + f_string_length_t j = 0; + + while (i < source.used && j < destination->used) { + if (!source.string[i]) { + i++; + continue; + } + + if (!destination->string[j]) { + j++; + continue; + } + + if (source.string[i] != destination->string[i]) { + return private_f_utf_string_prepend_nulless(source.string, source.used, destination); + } + + i++; + j++; + } // while + + return F_none; + } +#endif // _di_f_utf_string_dynamic_prepend_assure_nulless_ + +#ifndef _di_f_utf_string_dynamic_prepend_nulless_ + f_status_t f_utf_string_dynamic_prepend_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!source.used) return F_data_not_eos; + + return private_f_utf_string_prepend_nulless(source.string, source.used, destination); + } +#endif // _di_f_utf_string_dynamic_prepend_nulless_ + +#ifndef _di_f_utf_string_dynamic_seek_line_to_ + f_status_t f_utf_string_dynamic_seek_line_to(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t seek_to_this) { + #ifndef _di_level_0_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + if (buffer.used <= range->start) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!buffer.used) return F_data_not_eos; + if (range->start > range->stop) return F_data_not_stop; + + if (f_macro_utf_character_t_width_is(buffer.string[range->start]) == 1) { + return F_status_set_error(F_utf); + } + + while (buffer.string[range->start] != seek_to_this) { + + if (buffer.string[range->start] == f_utf_character_t_eol) { + return F_none_eol; + } + + range->start++; + + if (f_macro_utf_character_t_width_is(buffer.string[range->start]) == 1) return F_status_set_error(F_utf); + + if (range->start >= buffer.used) return F_none_eos; + if (range->start > range->stop) return F_none_stop; + } // while + + return F_none; + } +#endif // _di_f_utf_string_dynamic_seek_line_to_ + +#ifndef _di_f_utf_string_dynamic_seek_to_ + f_status_t f_utf_string_dynamic_seek_to(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t seek_to_this) { + #ifndef _di_level_0_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + if (buffer.used <= range->start) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!buffer.used) return F_data_not_eos; + if (range->start > range->stop) return F_data_not_stop; + + if (f_macro_utf_character_t_width_is(buffer.string[range->start]) == 1) { + return F_status_set_error(F_utf); + } + + while (buffer.string[range->start] != seek_to_this) { + range->start++; + + if (f_macro_utf_character_t_width_is(buffer.string[range->start]) == 1) { + return F_status_set_error(F_utf); + } + + if (range->start >= buffer.used) return F_none_eos; + if (range->start > range->stop) return F_none_stop; + } // while + + return F_none; + } +#endif // _di_f_utf_string_dynamic_seek_to_ + +#ifndef _di_f_utf_string_dynamic_terminate_ + f_status_t f_utf_string_dynamic_terminate(f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + if (destination->used > destination->size) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!destination->used && destination->size && !destination->string[destination->used - 1]) { + return F_none; + } + + if (destination->used == f_string_length_t_size) { + return F_status_set_error(F_string_too_large); + } + + const f_string_length_t total = destination->used + 1; + + if (total > destination->size) { + const f_status_t status = private_f_utf_string_dynamic_resize(total, destination); + if (F_status_is_error(status)) return status; + } + + destination->string[destination->used] = 0; + destination->used = total; + + return F_none; + } +#endif // _di_f_utf_string_dynamic_terminate_ + +#ifndef _di_f_utf_string_dynamic_terminate_after_ + f_status_t f_utf_string_dynamic_terminate_after(f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + if (destination->used > destination->size) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (destination->used) { + for (; destination->used; destination->used--) { + if (!destination->string[destination->used - 1]) continue; + break; + } // for + } + + if (destination->used == f_string_length_t_size) { + return F_status_set_error(F_string_too_large); + } + + const f_string_length_t total = destination->used + 1; + + if (total > destination->size) { + const f_status_t status = private_f_utf_string_dynamic_resize(total, destination); + if (F_status_is_error(status)) return status; + } + + destination->string[destination->used] = 0; + destination->used = total - 1; + + return F_none; + } +#endif // _di_f_utf_string_dynamic_terminate_after_ + +#ifndef _di_f_utf_string_mash_ + f_status_t f_utf_string_mash(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not_eos; + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_append(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_append(source, length, destination); + } +#endif // _di_f_utf_string_mash_ + +#ifndef _di_f_utf_string_mash_nulless_ + f_status_t f_utf_string_mash_nulless(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not_eos; + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_append_nulless(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_append_nulless(source, length, destination); + } +#endif // _di_f_utf_string_mash_nulless_ + +#ifndef _di_f_utf_string_mish_ + f_status_t f_utf_string_mish(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not_eos; + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_prepend(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_prepend(source, length, destination); + } +#endif // _di_f_utf_string_mish_ + +#ifndef _di_f_utf_string_mish_nulless_ + f_status_t f_utf_string_mish_nulless(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not_eos; + + if (glue_length && destination->used) { + f_status_t status = private_f_utf_string_prepend_nulless(glue, glue_length, destination); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_string_prepend_nulless(source, length, destination); + } +#endif // _di_f_utf_string_mish_nulless_ + +#ifndef _di_f_utf_string_prepend_ + f_status_t f_utf_string_prepend(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not_eos; + + return private_f_utf_string_prepend(source, length, destination); + } +#endif // _di_f_utf_string_prepend_ + +#ifndef _di_f_utf_string_prepend_assure_ + f_status_t f_utf_string_prepend_assure(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not_eos; + if (destination->used < length) return private_f_utf_string_prepend(source, length, destination); + + f_string_length_t i = 0; + f_string_length_t j = 0; + + while (i < length && j < destination->used) { + if (!source[i]) { + i++; + continue; + } + + if (!destination->string[j]) { + j++; + continue; + } + + if (source[i] != destination->string[i]) return private_f_utf_string_prepend(source, length, destination); + + i++; + j++; + } // while + + return F_none; + } +#endif // _di_f_utf_string_prepend_assure_ + +#ifndef _di_f_utf_string_prepend_assure_nulless_ + f_status_t f_utf_string_prepend_assure_nulless(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not_eos; + if (destination->used < length) return private_f_utf_string_prepend_nulless(source, length, destination); + + f_string_length_t i = 0; + f_string_length_t j = 0; + + while (i < length && j < destination->used) { + if (!source[i]) { + i++; + continue; + } + + if (!destination->string[j]) { + j++; + continue; + } + + if (source[i] != destination->string[i]) return private_f_utf_string_prepend_nulless(source, length, destination); + + i++; + j++; + } // while + + return F_none; + } +#endif // _di_f_utf_string_prepend_assure_nulless_ + +#ifndef _di_f_utf_string_prepend_nulless_ + f_status_t f_utf_string_prepend_nulless(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!length) return F_data_not_eos; + + return private_f_utf_string_prepend_nulless(source, length, destination); + } +#endif // _di_f_utf_string_prepend_nulless_ + +#ifndef _di_f_utf_string_seek_line_to_ + f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t seek_to_this) { + #ifndef _di_level_0_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (range->start > range->stop) return F_data_not_stop; + + if (f_macro_utf_character_t_width_is(string[range->start]) == 1) { + return F_status_set_error(F_utf); + } + + while (string[range->start] != seek_to_this) { + + if (string[range->start] == f_utf_character_t_eol) { + return F_none_eol; + } + + range->start++; + + if (f_macro_utf_character_t_width_is(string[range->start]) == 1) { + return F_status_set_error(F_utf); + } + + if (range->start > range->stop) return F_none_stop; + } // while + + return F_none; + } +#endif // _di_f_utf_string_seek_line_to_ + +#ifndef _di_f_utf_string_seek_to_ + f_status_t f_utf_string_seek_to(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t seek_to_this) { + #ifndef _di_level_0_parameter_checking_ + if (!range) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (range->start > range->stop) return F_data_not_stop; + + if (f_macro_utf_character_t_width_is(string[range->start]) == 1) { + return F_status_set_error(F_utf); + } + + while (string[range->start] != seek_to_this) { + range->start++; + + if (f_macro_utf_character_t_width_is(string[range->start]) == 1) { + return F_status_set_error(F_utf); + } + + if (range->start > range->stop) return F_none_stop; + } // while + + return F_none; + } +#endif // _di_f_utf_string_seek_to_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf.h b/level_0/f_utf/c/utf.h index 07cae0c..7fd91fe 100644 --- a/level_0/f_utf/c/utf.h +++ b/level_0/f_utf/c/utf.h @@ -48,6 +48,11 @@ // fll-0 utf includes #include +#include +#include +#include +#include +#include #ifdef __cplusplus extern "C" { @@ -1322,6 +1327,1034 @@ extern "C" { extern f_status_t f_utf_char_to_character(const f_string_t character, const f_string_length_t width_max, f_utf_character_t *character_utf); #endif // _di_f_utf_char_to_character_ +/** + * Append the source string onto the destination. + * + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_append_ + extern f_status_t f_utf_string_append(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_append_ + +/** + * Append the source string onto the destination, but only if the string is not already at the end. + * + * This ignores NULL characters when comparing both the source and the destination. + * + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_append_assure_ + extern f_status_t f_utf_string_append_assure(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_append_assure_ + +/** + * Append the source string onto the destination, but only if the string is not already at the end. + * + * This ignores NULL characters when comparing both the source and the destination. + * Skips over NULL characters from source when appending. + * + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_append_assure_nulless_ + extern f_status_t f_utf_string_append_assure_nulless(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_append_assure_nulless_ + +/** + * Append the source string onto the destination. + * + * Skips over NULL characters from source when appending. + * + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_append_nulless_ + extern f_status_t f_utf_string_append_nulless(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_append_nulless_ + +/** + * Append the source string onto the destination. + * + * @param source + * The source string to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_append_ + extern f_status_t f_utf_string_dynamic_append(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_append_ + +/** + * Append the source string onto the destination. + * + * @param source + * The source string to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_append_assure_ + extern f_status_t f_utf_string_dynamic_append_assure(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_append_assure_ + +/** + * Append the source string onto the destination. + * + * Skips over NULL characters from source when appending. + * + * @param source + * The source string to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_append_assure_nulless_ + extern f_status_t f_utf_string_dynamic_append_assure_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_append_assure_nulless_ + +/** + * Append the source string onto the destination. + * + * Skips over NULL characters from source when appending. + * + * @param source + * The source string to append. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_append_nulless_ + extern f_status_t f_utf_string_dynamic_append_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_append_nulless_ + +/** + * Append the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_mash_ + extern f_status_t f_utf_string_dynamic_mash(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_mash_ + +/** + * Append the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * Skips over NULL characters from glue and source when appending. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_mash_nulless_ + extern f_status_t f_utf_string_dynamic_mash_nulless(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_mash_nulless_ + +/** + * Prepend the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_mish_ + extern f_status_t f_utf_string_dynamic_mish(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_mish_ + +/** + * Prepend the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * Skips over NULL characters from glue and source when appending. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_mish_nulless_ + extern f_status_t f_utf_string_dynamic_mish_nulless(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_mish_nulless_ + +/** + * Append the source string onto the destination, but restricted to the given range. + * + * @param source + * The source string to append. + * @param range + * A range within the source to restrict the copy from. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_partial_append_ + extern f_status_t f_utf_string_dynamic_partial_append(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_partial_append_ + +/** + * Append the source string onto the destination, but only if the string is not already at the end and restricted to the given range + * + * This ignores NULL characters when comparing both the source and the destination. + * + * @param source + * The source string to append. + * @param range + * A range within the source to restrict the copy from. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_partial_append_assure_ + extern f_status_t f_utf_string_dynamic_partial_append_assure(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_partial_append_assure_ + +/** + * Append the source string onto the destination, but only if the string is not already at the end and restricted to the given range + * + * This ignores NULL characters when comparing both the source and the destination. + * + * Skips over NULL characters from source when appending. + * + * @param source + * The source string to append. + * @param range + * A range within the source to restrict the copy from. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_partial_append_assure_nulless_ + extern f_status_t f_utf_string_dynamic_partial_append_assure_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_partial_append_assure_nulless_ + +/** + * Append the source string onto the destination, but restricted to the given range. + * + * Skips over NULL characters from source when appending. + * + * @param source + * The source string to append. + * @param range + * A range within the source to restrict the copy from. + * @param destination + * The destination string the source is appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_partial_append_nulless_ + extern f_status_t f_utf_string_dynamic_partial_append_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_partial_append_nulless_ + +/** + * Append the source string onto the destination with the glue in between, but restricted to the given range. + * + * If the destination string is empty, then no glue is appended. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param range + * A range within the source to restrict the copy from. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_partial_mash_ + extern f_status_t f_utf_string_dynamic_partial_mash(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_partial_mash_ + +/** + * Append the source string onto the destination with the glue in between, but restricted to the given range. + * + * If the destination string is empty, then no glue is appended. + * + * Skips over NULL characters from glue and source when appending. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param range + * A range within the source to restrict the copy from. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_partial_mash_nulless_ + extern f_status_t f_utf_string_dynamic_partial_mash_nulless(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_partial_mash_nulless_ + +/** + * Prepend the source string onto the destination with the glue in between, but restricted to the given range. + * + * If the destination string is empty, then no glue is appended. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param range + * A range within the source to restrict the copy from. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_partial_mish_ + extern f_status_t f_utf_string_dynamic_partial_mish(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_partial_mish_ + +/** + * Prepend the source string onto the destination with the glue in between, but restricted to the given range. + * + * If the destination string is empty, then no glue is appended. + * + * Skips over NULL characters from glue and source when appending. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param range + * A range within the source to restrict the copy from. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_partial_mish_nulless_ + extern f_status_t f_utf_string_dynamic_partial_mish_nulless(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_partial_mish_nulless_ + +/** + * Prepend the source string onto the destination, but restricted to the given range. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * @param source + * The source string to prepend. + * @param range + * A range within the source to restrict the copy from. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_partial_prepend_ + extern f_status_t f_utf_string_dynamic_partial_prepend(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_partial_prepend_ + +/** + * Prepend the source string onto the destination, but only if the string is not already at the end and restricted to the given range + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * This ignores NULL characters when comparing both the source and the destination. + * + * @param source + * The source string to prepend. + * @param range + * A range within the source to restrict the copy from. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_partial_prepend_assure_ + extern f_status_t f_utf_string_dynamic_partial_prepend_assure(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_partial_prepend_assure_ + +/** + * Prepend the source string onto the destination, but only if the string is not already at the end and restricted to the given range + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * This ignores NULL characters when comparing both the source and the destination. + * + * @param source + * The source string to prepend. + * @param range + * A range within the source to restrict the copy from. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_partial_prepend_assure_nulless_ + extern f_status_t f_utf_string_dynamic_partial_prepend_assure_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_partial_prepend_assure_nulless_ + +/** + * Prepend the source string onto the destination, but restricted to the given range. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * @param source + * The source string to prepend. + * @param range + * A range within the source to restrict the copy from. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_partial_prepend_nulless_ + extern f_status_t f_utf_string_dynamic_partial_prepend_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_partial_prepend_nulless_ + +/** + * Prepend the source string onto the destination. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * @param source + * The source string to prepend. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_prepend_ + extern f_status_t f_utf_string_dynamic_prepend(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_prepend_ + +/** + * Prepend the source string onto the destination, but only if the string is not already at the beginning. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * This ignores NULL characters when comparing both the source and the destination. + * + * @param source + * The source string to prepend. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_prepend_assure_ + extern f_status_t f_utf_string_dynamic_prepend_assure(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_prepend_assure_ + +/** + * Prepend the source string onto the destination, but only if the string is not already at the beginning. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * This ignores NULL characters when comparing both the source and the destination. + * + * @param source + * The source string to prepend. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_prepend_assure_nulless_ + extern f_status_t f_utf_string_dynamic_prepend_assure_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_prepend_assure_nulless_ + +/** + * Prepend the source string onto the destination. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * @param source + * The source string to prepend. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_data_not_stop if range.start > range.stop. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_prepend_nulless_ + extern f_status_t f_utf_string_dynamic_prepend_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_prepend_nulless_ + +/** + * Seek the buffer location forward until the UTF-8 character or EOL is reached. + * + * @param buffer + * The buffer to traverse. + * @param range + * A range within the buffer representing the start and stop locations. + * The start location will be incremented by seek. + * @param seek_to_this + * A UTF-8 character representing a character to seek to. + * + * @return + * F_none on success. + * F_none_eol on success, but stopped at EOL. + * F_none_eos on success, but stopped at end of buffer. + * F_none_stop on success, but stopped stop location. + * F_data_not_eos if buffer length is 0. + * F_data_not_stop if range.start > range.stop. + * F_parameter (with error bit) if a parameter is invalid. + * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. + */ +#ifndef _di_f_utf_string_dynamic_seek_line_to_ + extern f_status_t f_utf_string_dynamic_seek_line_to(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t seek_to_this); +#endif // _di_f_utf_string_dynamic_seek_line_to_ + +/** + * Seek the buffer location forward until the UTF-8 character is reached. + * + * @param buffer + * The buffer to traverse. + * @param range + * A range within the buffer representing the start and stop locations. + * The start location will be incremented by seek. + * @param seek_to_this + * A UTF-8 character representing a character to seek to. + * + * @return + * F_none on success. + * F_none_eos on success, but stopped at end of buffer. + * F_none_stop on success, but stopped stop location. + * F_data_not_eos if buffer length is 0. + * F_data_not_stop if range.start > range.stop. + * F_parameter (with error bit) if a parameter is invalid. + * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. + */ +#ifndef _di_f_utf_string_dynamic_seek_to_ + extern f_status_t f_utf_string_dynamic_seek_to(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t seek_to_this); +#endif // _di_f_utf_string_dynamic_seek_to_ + +/** + * Guarantee that an end of string (NULL) exists at the end of the string. + * + * This is intended to be used for anything requiring NULL terminated strings. + * This will reallocate more space if necessary. + * + * If destination size is 0, then it will be reallocated and have the NULL assigned at index 0. + * + * @param destination + * The new string, which will be allocated or reallocated as necessary. + * + * @return + * F_none on success. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if string is too large to fit into the buffer. + */ +#ifndef _di_f_utf_string_dynamic_terminate_ + extern f_status_t f_utf_string_dynamic_terminate(f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_terminate_ + +/** + * Guarantee that an end of string (NULL) exists at the end of the string. + * + * This ensures that the terminating NULL not only exists but is not counted in destination.used. + * + * This is intended to be used for anything requiring NULL terminated strings whose used length cannot be counted. + * This will reallocate more space if necessary. + * + * If destination size is 0, then it will be reallocated and have the NULL assigned at index 0. + * + * @param destination + * The new string, which will be allocated or reallocated as necessary. + * + * @return + * F_none on success. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if string is too large to fit into the buffer. + */ +#ifndef _di_f_utf_string_dynamic_terminate_after_ + extern f_status_t f_utf_string_dynamic_terminate_after(f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_dynamic_terminate_after_ + +/** + * Append the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_mash_ + extern f_status_t f_utf_string_mash(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_mash_ + +/** + * Append the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * Skips over NULL characters from glue and source when appending. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_mash_nulless_ + extern f_status_t f_utf_string_mash_nulless(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_mash_nulless_ + +/** + * Prepend the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_mish_ + extern f_status_t f_utf_string_mish(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_mish_ + +/** + * Prepend the source string onto the destination with the glue in between. + * + * If the destination string is empty, then no glue is appended. + * + * Skips over NULL characters from glue and source when appending. + * + * @param glue + * A string to append between the source and destination, such as a space: ' '. + * @param glue_length + * The number of bytes the glue takes up. + * @param source + * The source string to append. + * @param length + * The length of source to append. + * @param destination + * The destination string the source and glue are appended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_mish_nulless_ + extern f_status_t f_utf_string_mish_nulless(const f_utf_string_t glue, const f_string_length_t glue_length, const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_mish_nulless_ + +/** + * Prepend the source string onto the destination. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * @param source + * The source string to prepend. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_prepend_ + extern f_status_t f_utf_string_prepend(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_prepend_ + +/** + * Prepend the source string onto the destination, but only if the string is not already at the beginning. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * This ignores NULL characters when comparing both the source and the destination. + * + * @param source + * The source string to prepend. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_prepend_assure_ + extern f_status_t f_utf_string_prepend_assure(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_prepend_assure_ + +/** + * Prepend the source string onto the destination, but only if the string is not already at the beginning. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * This ignores NULL characters when comparing both the source and the destination. + * Skips over NULL characters from source when prepending. + * + * @param source + * The source string to prepend. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_prepend_assure_nulless_ + extern f_status_t f_utf_string_prepend_assure_nulless(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_prepend_assure_nulless_ + +/** + * Prepend the source string onto the destination, but only if the string is not already at the beginning. + * + * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * + * This ignores NULL characters when comparing both the source and the destination. + * Skips over NULL characters from source when prepending. + * + * @param source + * The source string to prepend. + * @param length + * The length of source to append. + * @param destination + * The destination string the source is prepended onto. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_prepend_nulless_ + extern f_status_t f_utf_string_prepend_nulless(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_prepend_nulless_ + +/** + * Seek the UTF-8 string location forward until the character (1-byte wide) or EOL is reached. + * + * @param string + * The string to traverse. + * @param range + * A range within the buffer representing the start and stop locations. + * The start location will be incremented by seek. + * @param seek_to_this + * A single-width character representing a character to seek to. + * + * @return + * F_none on success. + * F_none_eol on success, but stopped at EOL. + * F_none_stop on success, but stopped stop location. + * F_data_not_stop if range.start > range.stop. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_seek_line_to_ + extern f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t seek_to_this); +#endif // _di_f_utf_string_seek_line_to_ + +/** + * Seek the string location forward until the character (1-byte wide) is reached. + * + * @param string + * The sting to traverse. + * @param range + * A range within the buffer representing the start and stop locations. + * The start location will be incremented by seek. + * @param seek_to_this + * A UTF-8 character representing a character to seek to. + * + * @return + * F_none on success. + * F_none_stop on success, but stopped stop location. + * F_data_not_stop if range.start > range.stop. + * F_parameter (with error bit) if a parameter is invalid. + * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. + */ +#ifndef _di_f_utf_string_seek_to_ + extern f_status_t f_utf_string_seek_to(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t seek_to_this); +#endif // _di_f_utf_string_seek_to_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_utf/c/utf_dynamic.c b/level_0/f_utf/c/utf_dynamic.c new file mode 100644 index 0000000..87853ad --- /dev/null +++ b/level_0/f_utf/c/utf_dynamic.c @@ -0,0 +1,190 @@ +#include "utf.h" +#include "private-utf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_static_empty_s_ + const f_utf_string_static_t f_utf_string_static_empty_s = f_macro_utf_string_static_t_initialize(0, 0); +#endif // _di_f_utf_string_static_empty_s_ + +#ifndef _di_f_utf_string_dynamic_adjust_ + f_status_t f_utf_string_dynamic_adjust(const f_string_length_t length, f_utf_string_dynamic_t *dynamic) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamic) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_dynamic_adjust(length, dynamic); + } +#endif // _di_f_utf_string_dynamic_adjust_ + +#ifndef _di_f_utf_string_dynamic_decimate_by_ + f_status_t f_utf_string_dynamic_decimate_by(const f_string_length_t amount, f_utf_string_dynamic_t *dynamic) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!dynamic) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (dynamic->size - amount > 0) { + return private_f_utf_string_dynamic_adjust(dynamic->size - amount, dynamic); + } + + return private_f_utf_string_dynamic_adjust(0, dynamic); + } +#endif // _di_f_utf_string_dynamic_decimate_by_ + +#ifndef _di_f_utf_string_dynamic_decrease_by_ + f_status_t f_utf_string_dynamic_decrease_by(const f_string_length_t amount, f_utf_string_dynamic_t *dynamic) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!dynamic) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (dynamic->size - amount > 0) { + return private_f_utf_string_dynamic_resize(dynamic->size - amount, dynamic); + } + + return private_f_utf_string_dynamic_resize(0, dynamic); + } +#endif // _di_f_utf_string_dynamic_decrease_by_ + +#ifndef _di_f_utf_string_dynamic_increase_ + f_status_t f_utf_string_dynamic_increase(f_utf_string_dynamic_t *dynamic) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamic) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (dynamic->used + 1 > dynamic->size) { + f_array_length_t size = dynamic->used + f_memory_default_allocation_step; + + if (size > f_string_length_t_size) { + if (dynamic->used + 1 > f_string_length_t_size) { + return F_status_set_error(F_string_too_large); + } + + size = f_string_length_t_size; + } + + return private_f_utf_string_dynamic_resize(size, dynamic); + } + + return F_data_not; + } +#endif // _di_f_utf_string_dynamic_increase_ + +#ifndef _di_f_utf_string_dynamic_increase_by_ + f_status_t f_utf_string_dynamic_increase_by(const f_string_length_t amount, f_utf_string_dynamic_t *dynamic) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamic) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_dynamic_increase_by(amount, dynamic); + } +#endif // _di_f_utf_string_dynamic_increase_by_ + +#ifndef _di_f_utf_string_dynamic_resize_ + f_status_t f_utf_string_dynamic_resize(const f_string_length_t length, f_utf_string_dynamic_t *dynamic) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamic) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_dynamic_resize(length, dynamic); + } +#endif // _di_f_utf_string_dynamic_resize_ + +#ifndef _di_f_utf_string_dynamics_adjust_ + f_status_t f_utf_string_dynamics_adjust(const f_string_length_t length, f_utf_string_dynamics_t *dynamics) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamics) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_dynamics_adjust(length, dynamics); + } +#endif // _di_f_utf_string_dynamics_adjust_ + +#ifndef _di_f_utf_string_dynamics_decimate_by_ + f_status_t f_utf_string_dynamics_decimate_by(const f_array_length_t amount, f_utf_string_dynamics_t *dynamics) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!dynamics) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (dynamics->size - amount > 0) { + return private_f_utf_string_dynamics_adjust(dynamics->size - amount, dynamics); + } + + return private_f_utf_string_dynamics_adjust(0, dynamics); + } +#endif // _di_f_utf_string_dynamics_decimate_by_ + +#ifndef _di_f_utf_string_dynamics_decrease_by_ + f_status_t f_utf_string_dynamics_decrease_by(const f_array_length_t amount, f_utf_string_dynamics_t *dynamics) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!dynamics) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (dynamics->size - amount > 0) { + return private_f_utf_string_dynamics_resize(dynamics->size - amount, dynamics); + } + + return private_f_utf_string_dynamics_resize(0, dynamics); + } +#endif // _di_f_utf_string_dynamics_decrease_by_ + +#ifndef _di_f_utf_string_dynamics_increase_ + f_status_t f_utf_string_dynamics_increase(f_utf_string_dynamics_t *dynamics) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamics) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (dynamics->used + 1 > dynamics->size) { + f_array_length_t size = dynamics->used + f_memory_default_allocation_step; + + if (size > f_array_length_t_size) { + if (dynamics->used + 1 > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + size = f_array_length_t_size; + } + + return private_f_utf_string_dynamics_resize(size, dynamics); + } + + return F_data_not; + } +#endif // _di_f_utf_string_dynamics_increase_ + +#ifndef _di_f_utf_string_dynamics_increase_by_ + f_status_t f_utf_string_dynamics_increase_by(const f_array_length_t amount, f_utf_string_dynamics_t *dynamics) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamics) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (dynamics->used + amount > dynamics->size) { + if (dynamics->used + amount > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_dynamics_resize(dynamics->used + amount, dynamics); + } + + return F_data_not; + } +#endif // _di_f_utf_string_dynamics_increase_by_ + +#ifndef _di_f_utf_string_dynamics_resize_ + f_status_t f_utf_string_dynamics_resize(const f_string_length_t length, f_utf_string_dynamics_t *dynamics) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamics) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_dynamics_resize(length, dynamics); + } +#endif // _di_f_utf_string_dynamics_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf_dynamic.h b/level_0/f_utf/c/utf_dynamic.h new file mode 100644 index 0000000..f61613c --- /dev/null +++ b/level_0/f_utf/c/utf_dynamic.h @@ -0,0 +1,370 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.5 + * Licenses: lgplv2.1 + * + * Defines dynamic (and static) string data. + * + * This is auto-included by string.h and should not need to be explicitly included. + */ +#ifndef _F_utf_string_dynamic_h +#define _F_utf_string_dynamic_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A string that is analogous to f_utf_string_dynamic_t but intended for static-only uses. + * + * The f_utf_string_static_t type should never be directly allocated or deallocated. + * + * A special f_macro_utf_string_static_t_initialize() is provided for the special purpose of easily initialize a static string. + * + * string: the string. + * size: total amount of space available. + * used: total number of space used. + */ +#ifndef _di_f_utf_string_static_t_ + typedef struct { + f_utf_string_t string; + + f_string_length_t size; + f_string_length_t used; + } f_utf_string_static_t; + + #define f_utf_string_static_t_initialize { 0, 0, 0 } + + #define f_macro_utf_string_static_t_clear(string_static) \ + string_static.string = 0; \ + string_static.size = 0; \ + string_static.used = 0; + + #define f_macro_utf_string_static_t_initialize(string, length) { string, length, length } +#endif // _di_f_utf_string_static_t_ + +/** + * A string that supports contains a size attribute to handle dynamic allocations and deallocations. + * + * Save the string size along with the string, so that strlen(..) commands can be avoided as much as possible. + * + * This is a sub-type of f_utf_string_static_t, allowing it to be passed into any f_utf_string_static_t type. + * It is recommended that f_utf_string_static_t are not otherwise casted into f_utf_string_dynamic_t to avoid potential memory allocation issues. + * + * string: the string. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_dynamic_t_ + typedef f_utf_string_static_t f_utf_string_dynamic_t; + + #define f_utf_string_dynamic_t_initialize f_utf_string_static_t_initialize + + #define f_macro_utf_string_dynamic_t_clear(dynamic) f_macro_utf_string_static_t_clear(dynamic) + + #define f_macro_utf_string_dynamic_t_resize(status, dynamic, length) status = f_utf_string_dynamic_resize(length, &dynamic); + #define f_macro_utf_string_dynamic_t_adjust(status, dynamic, length) status = f_utf_string_dynamic_adjust(length, &dynamic); + + #define f_macro_utf_string_dynamic_t_delete_simple(dynamic) f_utf_string_dynamic_resize(0, &dynamic); + #define f_macro_utf_string_dynamic_t_destroy_simple(dynamic) f_utf_string_dynamic_adjust(0, &dynamic); + + #define f_macro_utf_string_dynamic_t_increase(status, dynamic) status = f_utf_string_dynamic_increase(&dynamic); + #define f_macro_utf_string_dynamic_t_increase_by(status, dynamic, amount) status = f_utf_string_dynamic_increase_by(amount, &dynamic); + #define f_macro_utf_string_dynamic_t_decrease_by(status, dynamic, amount) status = f_utf_string_dynamic_decrease_by(amount, &dynamic); + #define f_macro_utf_string_dynamic_t_decimate_by(status, dynamic, amount) status = f_utf_string_dynamic_decimate_by(amount, &dynamic); +#endif // _di_f_utf_string_dynamic_t_ + +/** + * An array of static dynamics. + * + * array: the array of static dynamics. + * size: total amount of space available. + * used: total number of space used. + */ +#ifndef _di_f_utf_string_statics_t_ + typedef struct { + f_utf_string_static_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_statics_t; + + #define f_utf_string_statics_t_initialize { 0, 0, 0 } + + #define f_macro_utf_string_statics_t_clear(statics) \ + statics.array = 0; \ + statics.size = 0; \ + statics.used = 0; +#endif // _di_f_utf_string_statics_t_ + +/** + * An array of dynamic dynamics. + * + * array: the array of dynamic dynamics. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_dynamics_t_ + typedef f_utf_string_statics_t f_utf_string_dynamics_t; + + #define f_utf_string_dynamics_t_initialize f_utf_string_statics_t_initialize + + #define f_macro_utf_string_dynamics_t_clear(dynamics) f_macro_utf_string_statics_t_clear(dynamics) + + #define f_macro_utf_string_dynamics_t_resize(status, dynamics, length) status = f_utf_string_dynamics_resize(length, &dynamics); + #define f_macro_utf_string_dynamics_t_adjust(status, dynamics, length) status = f_utf_string_dynamics_adjust(length, &dynamics); + + #define f_macro_utf_string_dynamics_t_delete_simple(dynamics) f_utf_string_dynamics_resize(0, &dynamics); + #define f_macro_utf_string_dynamics_t_destroy_simple(dynamics) f_utf_string_dynamics_adjust(0, &dynamics); + + #define f_macro_utf_string_dynamics_t_increase(status, dynamics) status = f_utf_string_dynamics_increase(&dynamics); + #define f_macro_utf_string_dynamics_t_increase_by(status, dynamics, amount) status = f_utf_string_dynamics_increase_by(amount, &dynamics); + #define f_macro_utf_string_dynamics_t_decrease_by(status, dynamics, amount) status = f_utf_string_dynamics_decrease_by(amount, &dynamics); + #define f_macro_utf_string_dynamics_t_decimate_by(status, dynamics, amount) status = f_utf_string_dynamics_decimate_by(amount, &dynamics); +#endif // _di_f_utf_string_dynamics_t_ + +#ifndef _di_f_utf_string_static_empty_s_ + const extern f_utf_string_static_t f_utf_string_static_empty_s; +#endif // _di_f_utf_string_static_empty_s_ + +/** + * Resize the dynamic string. + * + * @param length + * The new size to use. + * @param dynamic + * The string to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_dynamic_adjust_ + extern f_status_t f_utf_string_dynamic_adjust(const f_array_length_t length, f_utf_string_dynamic_t *dynamic); +#endif // _di_f_utf_string_dynamic_adjust_ + +/** + * Resize the dynamic string to a smaller size. + * + * This will resize making the string smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param dynamic + * The string to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to decrease size (size = 0). + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_dynamic_decrease_by_ + extern f_status_t f_utf_string_dynamic_decrease_by(const f_string_length_t amount, f_utf_string_dynamic_t *dynamic); +#endif // _di_f_utf_string_dynamic_decrease_by_ + +/** + * Resize the dynamic string to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (f_string_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param dynamic + * The string to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_increase_ + extern f_status_t f_utf_string_dynamic_increase(f_utf_string_dynamic_t *dynamic); +#endif // _di_f_utf_string_dynamic_increase_ + +/** + * Resize the dynamic string to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (f_string_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param dynamic + * The string to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_string_too_large (with error bit) if the combined string is too large. + */ +#ifndef _di_f_utf_string_dynamic_increase_by_ + extern f_status_t f_utf_string_dynamic_increase_by(const f_string_length_t amount, f_utf_string_dynamic_t *dynamic); +#endif // _di_f_utf_string_dynamic_increase_by_ + +/** + * Resize the dynamic string. + * + * @param length + * The new size to use. + * @param dynamic + * The string to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_dynamic_resize_ + extern f_status_t f_utf_string_dynamic_resize(const f_array_length_t length, f_utf_string_dynamic_t *dynamic); +#endif // _di_f_utf_string_dynamic_resize_ + +/** + * Resize the dynamic string array. + * + * @param length + * The new size to use. + * @param dynamics + * The string array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_dynamics_adjust_ + extern f_status_t f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t *dynamics); +#endif // _di_f_utf_string_dynamics_adjust_ + +/** + * Resize the dynamic string array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param dynamics + * The string array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0). + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_dynamics_decimate_by_ + extern f_status_t f_utf_string_dynamics_decimate_by(const f_array_length_t amount, f_utf_string_dynamics_t *dynamics); +#endif // _di_f_utf_string_dynamics_decimate_by_ + +/** + * Resize the dynamic string array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param dynamics + * The string array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0). + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_dynamics_decrease_by_ + extern f_status_t f_utf_string_dynamics_decrease_by(const f_array_length_t amount, f_utf_string_dynamics_t *dynamics); +#endif // _di_f_utf_string_dynamics_decrease_by_ + +/** + * Increase the size of the dynamic string array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param dynamics + * The string array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_array_too_large (with error bit) if the new array length is too large. + */ +#ifndef _di_f_utf_string_dynamics_increase_ + extern f_status_t f_utf_string_dynamics_increase(f_utf_string_dynamics_t *dynamics); +#endif // _di_f_utf_string_dynamics_increase_ + +/** + * Resize the dynamic string array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param dynamics + * The string array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_array_too_large (with error bit) if the new array length is too large. + */ +#ifndef _di_f_utf_string_dynamics_increase_by_ + extern f_status_t f_utf_string_dynamics_increase_by(const f_array_length_t amount, f_utf_string_dynamics_t *dynamics); +#endif // _di_f_utf_string_dynamics_increase_by_ + +/** + * Resize the dynamic string array. + * + * @param length + * The new size to use. + * @param dynamics + * The string array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_dynamics_resize_ + extern f_status_t f_utf_string_dynamics_resize(const f_array_length_t length, f_utf_string_dynamics_t *dynamics); +#endif // _di_f_utf_string_dynamics_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_string_dynamic_h diff --git a/level_0/f_utf/c/utf_map.c b/level_0/f_utf/c/utf_map.c new file mode 100644 index 0000000..86d7c58 --- /dev/null +++ b/level_0/f_utf/c/utf_map.c @@ -0,0 +1,196 @@ +#include "utf.h" +#include "private-utf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_map_multis_adjust_ + f_status_t f_utf_string_map_multis_adjust(const f_string_length_t length, f_utf_string_map_multis_t *map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_map_multis_adjust(length, map_multis); + } +#endif // _di_f_utf_string_map_multis_adjust_ + +#ifndef _di_f_utf_string_map_multis_decimate_by_ + f_status_t f_utf_string_map_multis_decimate_by(const f_array_length_t amount, f_utf_string_map_multis_t *map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (map_multis->size - amount > 0) { + return private_f_utf_string_map_multis_adjust(map_multis->size - amount, map_multis); + } + + return private_f_utf_string_map_multis_adjust(0, map_multis); + } +#endif // _di_f_utf_string_map_multis_decimate_by_ + +#ifndef _di_f_utf_string_map_multis_decrease_by_ + f_status_t f_utf_string_map_multis_decrease_by(const f_array_length_t amount, f_utf_string_map_multis_t *map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (map_multis->size - amount > 0) { + return private_f_utf_string_map_multis_resize(map_multis->size - amount, map_multis); + } + + return private_f_utf_string_map_multis_resize(0, map_multis); + } +#endif // _di_f_utf_string_map_multis_decrease_by_ + +#ifndef _di_f_utf_string_map_multis_increase_ + f_status_t f_utf_string_map_multis_increase(f_utf_string_map_multis_t *map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (map_multis->used + 1 > map_multis->size) { + f_array_length_t size = map_multis->used + f_memory_default_allocation_step; + + if (size > f_array_length_t_size) { + if (map_multis->used + 1 > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + size = f_array_length_t_size; + } + + return private_f_utf_string_map_multis_resize(size, map_multis); + } + + return F_data_not; + } +#endif // _di_f_utf_string_map_multis_increase_ + +#ifndef _di_f_utf_string_map_multis_increase_by_ + f_status_t f_utf_string_map_multis_increase_by(const f_array_length_t amount, f_utf_string_map_multis_t *map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (map_multis->used + amount > map_multis->size) { + if (map_multis->used + amount > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_map_multis_resize(map_multis->used + amount, map_multis); + } + + return F_data_not; + } +#endif // _di_f_utf_string_map_multis_increase_by_ + +#ifndef _di_f_utf_string_map_multis_resize_ + f_status_t f_utf_string_map_multis_resize(const f_string_length_t length, f_utf_string_map_multis_t *map_multis) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multis) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_map_multis_resize(length, map_multis); + } +#endif // _di_f_utf_string_map_multis_resize_ + +#ifndef _di_f_utf_string_maps_adjust_ + f_status_t f_utf_string_maps_adjust(const f_string_length_t length, f_utf_string_maps_t *maps) { + #ifndef _di_level_0_parameter_checking_ + if (!maps) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_maps_adjust(length, maps); + } +#endif // _di_f_utf_string_maps_adjust_ + +#ifndef _di_f_utf_string_maps_decimate_by_ + f_status_t f_utf_string_maps_decimate_by(const f_array_length_t amount, f_utf_string_maps_t *maps) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!maps) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (maps->size - amount > 0) { + return private_f_utf_string_maps_adjust(maps->size - amount, maps); + } + + return private_f_utf_string_maps_adjust(0, maps); + } +#endif // _di_f_utf_string_maps_decimate_by_ + +#ifndef _di_f_utf_string_maps_decrease_by_ + f_status_t f_utf_string_maps_decrease_by(const f_array_length_t amount, f_utf_string_maps_t *maps) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!maps) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (maps->size - amount > 0) { + return private_f_utf_string_maps_resize(maps->size - amount, maps); + } + + return private_f_utf_string_maps_resize(0, maps); + } +#endif // _di_f_utf_string_maps_decrease_by_ + +#ifndef _di_f_utf_string_maps_increase_ + f_status_t f_utf_string_maps_increase(f_utf_string_maps_t *maps) { + #ifndef _di_level_0_parameter_checking_ + if (!maps) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (maps->used + 1 > maps->size) { + f_array_length_t size = maps->used + f_memory_default_allocation_step; + + if (size > f_array_length_t_size) { + if (maps->used + 1 > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + size = f_array_length_t_size; + } + + return private_f_utf_string_maps_resize(size, maps); + } + + return F_data_not; + } +#endif // _di_f_utf_string_maps_increase_ + +#ifndef _di_f_utf_string_maps_increase_by_ + f_status_t f_utf_string_maps_increase_by(const f_array_length_t amount, f_utf_string_maps_t *maps) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!maps) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (maps->used + amount > maps->size) { + if (maps->used + amount > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_maps_resize(maps->used + amount, maps); + } + + return F_data_not; + } +#endif // _di_f_utf_string_maps_increase_by_ + +#ifndef _di_f_utf_string_maps_resize_ + f_status_t f_utf_string_maps_resize(const f_string_length_t length, f_utf_string_maps_t *maps) { + #ifndef _di_level_0_parameter_checking_ + if (!maps) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_maps_resize(length, maps); + } +#endif // _di_f_utf_string_maps_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf_map.h b/level_0/f_utf/c/utf_map.h new file mode 100644 index 0000000..dcc74d9 --- /dev/null +++ b/level_0/f_utf/c/utf_map.h @@ -0,0 +1,389 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.5 + * Licenses: lgplv2.1 + * + * Defines map string data. + * + * This is auto-included by string.h and should not need to be explicitly included. + */ +#ifndef _F_utf_string_map_h +#define _F_utf_string_map_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A string map consisting of a name and value. + * + * name: A string representing the map name. + * value: A string representing the map value. + */ +#ifndef _di_f_utf_string_map_t_ + typedef struct { + f_utf_string_dynamic_t name; + f_utf_string_dynamic_t value; + } f_utf_string_map_t; + + #define f_utf_string_map_t_initialize { f_utf_string_dynamic_t_initialize, f_utf_string_dynamic_t_initialize } + + #define f_macro_utf_string_map_t_clear(map) \ + f_macro_utf_string_dynamic_t_clear(map.name) \ + f_macro_utf_string_dynamic_t_clear(map.value) + + #define f_macro_utf_string_map_t_delete_simple(map) \ + f_macro_utf_string_dynamic_t_delete_simple(map.name) \ + f_macro_utf_string_dynamic_t_delete_simple(map.value) + + #define f_macro_utf_string_map_t_destroy_simple(map) \ + f_macro_utf_string_dynamic_t_destroy_simple(map.name) \ + f_macro_utf_string_dynamic_t_destroy_simple(map.value) +#endif // _di_f_utf_string_map_t_ + +/** + * An array of string maps. + * + * array: the array of string maps. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_maps_t_ + typedef struct { + f_utf_string_map_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_maps_t; + + #define f_utf_string_maps_t_initialize f_utf_string_statics_t_initialize + + #define f_macro_utf_string_maps_t_clear(maps) f_macro_memory_structure_clear(maps) + + #define f_macro_utf_string_maps_t_resize(status, maps, length) status = f_utf_string_maps_resize(length, &maps); + #define f_macro_utf_string_maps_t_adjust(status, maps, length) status = f_utf_string_maps_adjust(length, &maps); + + #define f_macro_utf_string_maps_t_delete_simple(maps) f_utf_string_maps_resize(0, &maps); + #define f_macro_utf_string_maps_t_destroy_simple(maps) f_utf_string_maps_adjust(0, &maps); + + #define f_macro_utf_string_maps_t_increase(status, maps) status = f_utf_string_maps_increase(maps); + #define f_macro_utf_string_maps_t_increase_by(status, maps, amount) status = f_utf_string_maps_increase_by(amount, maps); + #define f_macro_utf_string_maps_t_decrease_by(status, maps, amount) status = f_utf_string_maps_decrease_by(amount, maps); + #define f_macro_utf_string_maps_t_decimate_by(status, maps, amount) status = f_utf_string_maps_decimate_by(amount, maps); +#endif // _di_f_utf_string_maps_t_ + +/** + * A string map consisting of a name and multiple values. + * + * name: A string representing the map name. + * value: An array of strings representing the map value. + */ +#ifndef _di_f_utf_string_map_multi_t_ + typedef struct { + f_utf_string_dynamic_t name; + f_utf_string_dynamics_t value; + } f_utf_string_map_multi_t; + + #define f_utf_string_map_multi_t_initialize { f_utf_string_dynamic_t_initialize, f_utf_string_dynamics_t_initialize } + + #define f_macro_utf_string_map_multi_t_clear(map) \ + f_macro_utf_string_dynamic_t_clear(map.name) \ + f_macro_utf_string_dynamics_t_clear(map.value) + + #define f_macro_utf_string_map_multi_t_delete_simple(map) \ + f_macro_utf_string_dynamic_t_delete_simple(map.name) \ + f_macro_utf_string_dynamics_t_delete_simple(map.value) + + #define f_macro_utf_string_map_multi_t_destroy_simple(map) \ + f_macro_utf_string_dynamic_t_destroy_simple(map.name) \ + f_macro_utf_string_dynamics_t_destroy_simple(map.value) +#endif // _di_f_utf_string_map_multi_t_ + +/** + * An array of string maps. + * + * array: the array of string maps. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_map_multis_t_ + typedef struct { + f_utf_string_map_multi_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_map_multis_t; + + #define f_utf_string_map_multis_t_initialize f_utf_string_statics_t_initialize + + #define f_macro_utf_string_map_multis_t_clear(map_multis) f_macro_memory_structure_clear(map_multis) + + #define f_macro_utf_string_map_multis_t_resize(status, map_multis, length) status = f_utf_string_map_multis_resize(length, &map_multis); + #define f_macro_utf_string_map_multis_t_adjust(status, map_multis, length) status = f_utf_string_map_multis_adjust(length, &map_multis); + + #define f_macro_utf_string_map_multis_t_delete_simple(map_multis) f_utf_string_map_multis_resize(0, &map_multis); + #define f_macro_utf_string_map_multis_t_destroy_simple(map_multis) f_utf_string_map_multis_adjust(0, &map_multis); + + #define f_macro_utf_string_map_multis_t_increase(status, map_multis) status = f_utf_string_map_multis_increase(&map_multis); + #define f_macro_utf_string_map_multis_t_increase_by(status, map_multis, amount) status = f_utf_string_map_multis_increase_by(amount, &map_multis); + #define f_macro_utf_string_map_multis_t_decrease_by(status, map_multis, amount) status = f_utf_string_map_multis_decrease_by(amount, &map_multis); + #define f_macro_utf_string_map_multis_t_decimate_by(status, map_multis, amount) status = f_utf_string_map_multis_decimate_by(amount, &map_multis); +#endif // _di_f_utf_string_map_multis_t_ + +/** + * Resize the string map_multis array. + * + * @param length + * The new size to use. + * @param map_multis + * The string map_multis array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_map_multis_adjust_ + extern f_status_t f_utf_string_map_multis_adjust(const f_array_length_t length, f_utf_string_map_multis_t *map_multis); +#endif // _di_f_utf_string_map_multis_adjust_ + +/** + * Resize the string map_multis array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param map_multis + * The string map_multis array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_map_multis_decimate_by_ + extern f_status_t f_utf_string_map_multis_decimate_by(const f_array_length_t amount, f_utf_string_map_multis_t *map_multis); +#endif // _di_f_utf_string_map_multis_decimate_by_ + +/** + * Resize the string map_multis array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param map_multis + * The string map_multis array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_map_multis_decrease_by_ + extern f_status_t f_utf_string_map_multis_decrease_by(const f_array_length_t amount, f_utf_string_map_multis_t *map_multis); +#endif // _di_f_utf_string_map_multis_decrease_by_ + +/** + * Increase the size of the string map_multis array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param map_multis + * The string map_multis array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_map_multis_increase_ + extern f_status_t f_utf_string_map_multis_increase(f_utf_string_map_multis_t *map_multis); +#endif // _di_f_utf_string_map_multis_increase_ + +/** + * Resize the string map_multis array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param map_multis + * The string map_multis array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_array_too_large (with error bit) if the new array length is too large. + */ +#ifndef _di_f_utf_string_map_multis_increase_by_ + extern f_status_t f_utf_string_map_multis_increase_by(const f_array_length_t amount, f_utf_string_map_multis_t *map_multis); +#endif // _di_f_utf_string_map_multis_increase_by_ + +/** + * Resize the string map_multis array. + * + * @param length + * The new size to use. + * @param map_multis + * The string map_multis array to adjust. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_map_multis_resize_ + extern f_status_t f_utf_string_map_multis_resize(const f_array_length_t length, f_utf_string_map_multis_t *map_multis); +#endif // _di_f_utf_string_map_multis_resize_ + +/** + * Resize the string maps array. + * + * @param length + * The new size to use. + * @param maps + * The string maps array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_maps_adjust_ + extern f_status_t f_utf_string_maps_adjust(const f_array_length_t length, f_utf_string_maps_t *maps); +#endif // _di_f_utf_string_maps_adjust_ + +/** + * Resize the string maps array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param maps + * The string maps array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_maps_decimate_by_ + extern f_status_t f_utf_string_maps_decimate_by(const f_array_length_t amount, f_utf_string_maps_t *maps); +#endif // _di_f_utf_string_maps_decimate_by_ + +/** + * Resize the string maps array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param maps + * The string maps array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_maps_decrease_by_ + extern f_status_t f_utf_string_maps_decrease_by(const f_array_length_t amount, f_utf_string_maps_t *maps); +#endif // _di_f_utf_string_maps_decrease_by_ + +/** + * Increase the size of the string maps array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param maps + * The string maps array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_maps_increase_ + extern f_status_t f_utf_string_maps_increase(f_utf_string_maps_t *maps); +#endif // _di_f_utf_string_maps_increase_ + +/** + * Resize the string maps array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param maps + * The string maps array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_array_too_large (with error bit) if the new array length is too large. + */ +#ifndef _di_f_utf_string_maps_increase_by_ + extern f_status_t f_utf_string_maps_increase_by(const f_array_length_t amount, f_utf_string_maps_t *maps); +#endif // _di_f_utf_string_maps_increase_by_ + +/** + * Resize the string maps array. + * + * @param length + * The new size to use. + * @param maps + * The string maps array to adjust. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_maps_resize_ + extern f_status_t f_utf_string_maps_resize(const f_array_length_t length, f_utf_string_maps_t *maps); +#endif // _di_f_utf_string_maps_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_string_map_h diff --git a/level_0/f_utf/c/utf_quantity.c b/level_0/f_utf/c/utf_quantity.c new file mode 100644 index 0000000..204c274 --- /dev/null +++ b/level_0/f_utf/c/utf_quantity.c @@ -0,0 +1,196 @@ +#include "utf.h" +#include "private-utf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_quantitys_adjust_ + f_status_t f_utf_string_quantitys_adjust(const f_string_length_t length, f_utf_string_quantitys_t *quantitys) { + #ifndef _di_level_0_parameter_checking_ + if (!quantitys) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_quantitys_adjust(length, quantitys); + } +#endif // _di_f_utf_string_quantitys_adjust_ + +#ifndef _di_f_utf_string_quantitys_decimate_by_ + f_status_t f_utf_string_quantitys_decimate_by(const f_array_length_t amount, f_utf_string_quantitys_t *quantitys) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!quantitys) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (quantitys->size - amount > 0) { + return private_f_utf_string_quantitys_adjust(quantitys->size - amount, quantitys); + } + + return private_f_utf_string_quantitys_adjust(0, quantitys); + } +#endif // _di_f_utf_string_quantitys_decimate_by_ + +#ifndef _di_f_utf_string_quantitys_decrease_by_ + f_status_t f_utf_string_quantitys_decrease_by(const f_array_length_t amount, f_utf_string_quantitys_t *quantitys) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!quantitys) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (quantitys->size - amount > 0) { + return private_f_utf_string_quantitys_resize(quantitys->size - amount, quantitys); + } + + return private_f_utf_string_quantitys_resize(0, quantitys); + } +#endif // _di_f_utf_string_quantitys_decrease_by_ + +#ifndef _di_f_utf_string_quantitys_increase_ + f_status_t f_utf_string_quantitys_increase(f_utf_string_quantitys_t *quantitys) { + #ifndef _di_level_0_parameter_checking_ + if (!quantitys) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (quantitys->used + 1 > quantitys->size) { + f_array_length_t size = quantitys->used + f_memory_default_allocation_step; + + if (size > f_array_length_t_size) { + if (quantitys->used + 1 > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + size = f_array_length_t_size; + } + + return private_f_utf_string_quantitys_resize(size, quantitys); + } + + return F_data_not; + } +#endif // _di_f_utf_string_quantitys_increase_ + +#ifndef _di_f_utf_string_quantitys_increase_by_ + f_status_t f_utf_string_quantitys_increase_by(const f_array_length_t amount, f_utf_string_quantitys_t *quantitys) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!quantitys) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (quantitys->used + amount > quantitys->size) { + if (quantitys->used + amount > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_quantitys_resize(quantitys->used + amount, quantitys); + } + + return F_data_not; + } +#endif // _di_f_utf_string_quantitys_increase_by_ + +#ifndef _di_f_utf_string_quantitys_resize_ + f_status_t f_utf_string_quantitys_resize(const f_string_length_t length, f_utf_string_quantitys_t *quantitys) { + #ifndef _di_level_0_parameter_checking_ + if (!quantitys) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_quantitys_resize(length, quantitys); + } +#endif // _di_f_utf_string_quantitys_resize_ + +#ifndef _di_f_utf_string_quantityss_adjust_ + f_status_t f_utf_string_quantityss_adjust(const f_string_length_t length, f_utf_string_quantityss_t *quantityss) { + #ifndef _di_level_0_parameter_checking_ + if (!quantityss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_quantityss_adjust(length, quantityss); + } +#endif // _di_f_utf_string_quantityss_adjust_ + +#ifndef _di_f_utf_string_quantityss_decimate_by_ + f_status_t f_utf_string_quantityss_decimate_by(const f_array_length_t amount, f_utf_string_quantityss_t *quantityss) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!quantityss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (quantityss->size - amount > 0) { + return private_f_utf_string_quantityss_adjust(quantityss->size - amount, quantityss); + } + + return private_f_utf_string_quantityss_adjust(0, quantityss); + } +#endif // _di_f_utf_string_quantityss_decimate_by_ + +#ifndef _di_f_utf_string_quantityss_decrease_by_ + f_status_t f_utf_string_quantityss_decrease_by(const f_array_length_t amount, f_utf_string_quantityss_t *quantityss) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!quantityss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (quantityss->size - amount > 0) { + return private_f_utf_string_quantityss_resize(quantityss->size - amount, quantityss); + } + + return private_f_utf_string_quantityss_resize(0, quantityss); + } +#endif // _di_f_utf_string_quantityss_decrease_by_ + +#ifndef _di_f_utf_string_quantityss_increase_ + f_status_t f_utf_string_quantityss_increase(f_utf_string_quantityss_t *quantityss) { + #ifndef _di_level_0_parameter_checking_ + if (!quantityss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (quantityss->used + 1 > quantityss->size) { + f_array_length_t size = quantityss->used + f_memory_default_allocation_step; + + if (size > f_array_length_t_size) { + if (quantityss->used + 1 > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + size = f_array_length_t_size; + } + + return private_f_utf_string_quantityss_resize(size, quantityss); + } + + return F_data_not; + } +#endif // _di_f_utf_string_quantityss_increase_ + +#ifndef _di_f_utf_string_quantityss_increase_by_ + f_status_t f_utf_string_quantityss_increase_by(const f_array_length_t amount, f_utf_string_quantityss_t *quantityss) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!quantityss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (quantityss->used + amount > quantityss->size) { + if (quantityss->used + amount > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_quantityss_resize(quantityss->used + amount, quantityss); + } + + return F_data_not; + } +#endif // _di_f_utf_string_quantityss_increase_by_ + +#ifndef _di_f_utf_string_quantityss_resize_ + f_status_t f_utf_string_quantityss_resize(const f_string_length_t length, f_utf_string_quantityss_t *quantityss) { + #ifndef _di_level_0_parameter_checking_ + if (!quantityss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_quantityss_resize(length, quantityss); + } +#endif // _di_f_utf_string_quantityss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf_quantity.h b/level_0/f_utf/c/utf_quantity.h new file mode 100644 index 0000000..58b651c --- /dev/null +++ b/level_0/f_utf/c/utf_quantity.h @@ -0,0 +1,354 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.5 + * Licenses: lgplv2.1 + * + * Defines quantity string data. + * + * This is auto-included by string.h and should not need to be explicitly included. + */ +#ifndef _F_utf_string_quantity_h +#define _F_utf_string_quantity_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Store string quantity. + * + * Similar to f_utf_string_range_t, except total is relative to start and is not an absolute stop position. + * + * Two common uses for when total is 0 is: + * 1) Exactly that, process a total of 0 strings bytes. + * 2) Process with no limit, aka infinite. + * + * start: The position where the string starts (based on some string/buffer). + * total: The total number of elements within that string/buffer the quantity represents. + */ +#ifndef _di_f_utf_string_quantity_t_ + typedef struct { + f_string_length_t start; + f_string_length_t total; + } f_utf_string_quantity_t; + + #define f_utf_string_quantity_t_initialize { 0, 0 } +#endif // _di_f_utf_string_quantity_t_ + +/** + * An array of string quantitys. + * + * array: the array of string quantitys. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_quantitys_t_ + typedef struct { + f_utf_string_quantity_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_quantitys_t; + + #define f_utf_string_quantitys_t_initialize { 0, 0, 0 } + + #define f_macro_utf_string_quantitys_t_clear(quantitys) f_macro_memory_structure_clear(quantitys) + + #define f_macro_utf_string_quantitys_t_resize(status, quantitys, length) status = f_utf_string_quantitys_resize(length, &quantitys); + #define f_macro_utf_string_quantitys_t_adjust(status, quantitys, length) status = f_utf_string_quantitys_adjust(length, &quantitys); + + #define f_macro_utf_string_quantitys_t_delete_simple(quantitys) f_utf_string_quantitys_resize(0, &quantitys); + #define f_macro_utf_string_quantitys_t_destroy_simple(quantitys) f_utf_string_quantitys_adjust(0, &quantitys); + + #define f_macro_utf_string_quantitys_t_increase(status, quantitys) status = f_utf_string_quantitys_increase(&quantitys); + #define f_macro_utf_string_quantitys_t_increase_by(status, quantitys, amount) status = f_utf_string_quantitys_increase_by(amount, &quantitys); + #define f_macro_utf_string_quantitys_t_decrease_by(status, quantitys, amount) status = f_utf_string_quantitys_decrease_by(amount, &quantitys); + #define f_macro_utf_string_quantitys_t_decimate_by(status, quantitys, amount) status = f_utf_string_quantitys_decimate_by(amount, &quantitys); +#endif // _di_f_utf_string_quantitys_t_ + +/** + * This holds an array of f_utf_string_quantitys_t. + * + * array: The array of quantitys arrays. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_quantityss_t_ + typedef struct { + f_utf_string_quantitys_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_quantityss_t; + + #define f_utf_string_quantityss_t_initialize { 0, 0, 0 } + + #define f_macro_utf_string_quantityss_t_clear(quantityss) f_macro_memory_structures_clear(quantityss) + + #define f_macro_utf_string_quantityss_t_resize(status, quantityss, length) status = f_utf_string_quantityss_resize(length, &quantityss); + #define f_macro_utf_string_quantityss_t_adjust(status, quantityss, length) status = f_utf_string_quantityss_adjust(length, &quantityss); + + #define f_macro_utf_string_quantityss_t_delete_simple(quantityss) f_utf_string_quantityss_resize(0, &quantityss); + #define f_macro_utf_string_quantityss_t_destroy_simple(quantityss) f_utf_string_quantityss_adjust(0, &quantityss); + + #define f_macro_utf_string_quantityss_t_increase(status, quantityss) status = f_utf_string_quantityss_increase(&quantityss); + #define f_macro_utf_string_quantityss_t_increase_by(status, quantityss, amount) status = f_utf_string_quantityss_increase_by(amount, &quantityss); + #define f_macro_utf_string_quantityss_t_decrease_by(status, quantityss, amount) status = f_utf_string_quantityss_decrease_by(amount, &quantityss); + #define f_macro_utf_string_quantityss_t_decimate_by(status, quantityss, amount) status = f_utf_string_quantityss_decimate_by(amount, &quantityss); +#endif // _di_f_utf_string_quantityss_t_ + +/** + * Resize the string quantitys array. + * + * @param length + * The new size to use. + * @param quantitys + * The string quantitys array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_quantitys_adjust_ + extern f_status_t f_utf_string_quantitys_adjust(const f_array_length_t length, f_utf_string_quantitys_t *quantitys); +#endif // _di_f_utf_string_quantitys_adjust_ + +/** + * Resize the string quantitys array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param quantitys + * The string quantitys array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_quantitys_decimate_by_ + extern f_status_t f_utf_string_quantitys_decimate_by(const f_array_length_t amount, f_utf_string_quantitys_t *quantitys); +#endif // _di_f_utf_string_quantitys_decimate_by_ + +/** + * Resize the string quantitys array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param quantitys + * The string quantitys array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_quantitys_decrease_by_ + extern f_status_t f_utf_string_quantitys_decrease_by(const f_array_length_t amount, f_utf_string_quantitys_t *quantitys); +#endif // _di_f_utf_string_quantitys_decrease_by_ + +/** + * Increase the size of the string quantitys array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param quantitys + * The string quantitys array to resize. + * + * @return + * F_none on success. + * F_array_too_large (with error bit) if the new array length is too large. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_quantitys_increase_ + extern f_status_t f_utf_string_quantitys_increase(f_utf_string_quantitys_t *quantitys); +#endif // _di_f_utf_string_quantitys_increase_ + +/** + * Resize the string quantitys array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param quantitys + * The string quantitys array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_array_too_large (with error bit) if the new array length is too large. + */ +#ifndef _di_f_utf_string_quantitys_increase_by_ + extern f_status_t f_utf_string_quantitys_increase_by(const f_array_length_t amount, f_utf_string_quantitys_t *quantitys); +#endif // _di_f_utf_string_quantitys_increase_by_ + +/** + * Resize the string quantitys array. + * + * @param length + * The new size to use. + * @param quantitys + * The string quantitys array to adjust. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_quantitys_resize_ + extern f_status_t f_utf_string_quantitys_resize(const f_array_length_t length, f_utf_string_quantitys_t *quantitys); +#endif // _di_f_utf_string_quantitys_resize_ + +/** + * Resize the string quantityss array. + * + * @param length + * The new size to use. + * @param quantityss + * The string quantityss array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_quantityss_adjust_ + extern f_status_t f_utf_string_quantityss_adjust(const f_array_length_t length, f_utf_string_quantityss_t *quantityss); +#endif // _di_f_utf_string_quantityss_adjust_ + +/** + * Resize the string quantityss array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param quantityss + * The string quantityss array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_quantityss_decimate_by_ + extern f_status_t f_utf_string_quantityss_decimate_by(const f_array_length_t amount, f_utf_string_quantityss_t *quantityss); +#endif // _di_f_utf_string_quantityss_decimate_by_ + +/** + * Resize the string quantityss array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param quantityss + * The string quantityss array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_quantityss_decrease_by_ + extern f_status_t f_utf_string_quantityss_decrease_by(const f_array_length_t amount, f_utf_string_quantityss_t *quantityss); +#endif // _di_f_utf_string_quantityss_decrease_by_ + +/** + * Increase the size of the string quantityss array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param quantityss + * The string quantityss array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_quantityss_increase_ + extern f_status_t f_utf_string_quantityss_increase(f_utf_string_quantityss_t *quantityss); +#endif // _di_f_utf_string_quantityss_increase_ + +/** + * Resize the string quantityss array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param quantityss + * The string quantityss array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_array_too_large (with error bit) if the new array length is too large. + */ +#ifndef _di_f_utf_string_quantityss_increase_by_ + extern f_status_t f_utf_string_quantityss_increase_by(const f_array_length_t amount, f_utf_string_quantityss_t *quantityss); +#endif // _di_f_utf_string_quantityss_increase_by_ + +/** + * Resize the string quantityss array. + * + * @param length + * The new size to use. + * @param quantityss + * The string quantityss array to adjust. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_quantityss_resize_ + extern f_status_t f_utf_string_quantityss_resize(const f_array_length_t length, f_utf_string_quantityss_t *quantityss); +#endif // _di_f_utf_string_quantityss_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_string_quantity_h diff --git a/level_0/f_utf/c/utf_range.c b/level_0/f_utf/c/utf_range.c new file mode 100644 index 0000000..afb2642 --- /dev/null +++ b/level_0/f_utf/c/utf_range.c @@ -0,0 +1,196 @@ +#include "utf.h" +#include "private-utf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_ranges_adjust_ + f_status_t f_utf_string_ranges_adjust(const f_string_length_t length, f_utf_string_ranges_t *ranges) { + #ifndef _di_level_0_parameter_checking_ + if (!ranges) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_ranges_adjust(length, ranges); + } +#endif // _di_f_utf_string_ranges_adjust_ + +#ifndef _di_f_utf_string_ranges_decimate_by_ + f_status_t f_utf_string_ranges_decimate_by(const f_array_length_t amount, f_utf_string_ranges_t *ranges) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!ranges) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (ranges->size - amount > 0) { + return private_f_utf_string_ranges_adjust(ranges->size - amount, ranges); + } + + return private_f_utf_string_ranges_adjust(0, ranges); + } +#endif // _di_f_utf_string_ranges_decimate_by_ + +#ifndef _di_f_utf_string_ranges_decrease_by_ + f_status_t f_utf_string_ranges_decrease_by(const f_array_length_t amount, f_utf_string_ranges_t *ranges) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!ranges) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (ranges->size - amount > 0) { + return private_f_utf_string_ranges_resize(ranges->size - amount, ranges); + } + + return private_f_utf_string_ranges_resize(0, ranges); + } +#endif // _di_f_utf_string_ranges_decrease_by_ + +#ifndef _di_f_utf_string_ranges_increase_ + f_status_t f_utf_string_ranges_increase(f_utf_string_ranges_t *ranges) { + #ifndef _di_level_0_parameter_checking_ + if (!ranges) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (ranges->used + 1 > ranges->size) { + f_array_length_t size = ranges->used + f_memory_default_allocation_step; + + if (size > f_array_length_t_size) { + if (ranges->used + 1 > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + size = f_array_length_t_size; + } + + return private_f_utf_string_ranges_resize(size, ranges); + } + + return F_data_not; + } +#endif // _di_f_utf_string_ranges_increase_ + +#ifndef _di_f_utf_string_ranges_increase_by_ + f_status_t f_utf_string_ranges_increase_by(const f_array_length_t amount, f_utf_string_ranges_t *ranges) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!ranges) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (ranges->used + amount > ranges->size) { + if (ranges->used + amount > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_ranges_resize(ranges->used + amount, ranges); + } + + return F_data_not; + } +#endif // _di_f_utf_string_ranges_increase_by_ + +#ifndef _di_f_utf_string_ranges_resize_ + f_status_t f_utf_string_ranges_resize(const f_string_length_t length, f_utf_string_ranges_t *ranges) { + #ifndef _di_level_0_parameter_checking_ + if (!ranges) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_ranges_resize(length, ranges); + } +#endif // _di_f_utf_string_ranges_resize_ + +#ifndef _di_f_utf_string_rangess_adjust_ + f_status_t f_utf_string_rangess_adjust(const f_string_length_t length, f_utf_string_rangess_t *rangess) { + #ifndef _di_level_0_parameter_checking_ + if (!rangess) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_rangess_adjust(length, rangess); + } +#endif // _di_f_utf_string_rangess_adjust_ + +#ifndef _di_f_utf_string_rangess_decimate_by_ + f_status_t f_utf_string_rangess_decimate_by(const f_array_length_t amount, f_utf_string_rangess_t *rangess) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!rangess) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (rangess->size - amount > 0) { + return private_f_utf_string_rangess_adjust(rangess->size - amount, rangess); + } + + return private_f_utf_string_rangess_adjust(0, rangess); + } +#endif // _di_f_utf_string_rangess_decimate_by_ + +#ifndef _di_f_utf_string_rangess_decrease_by_ + f_status_t f_utf_string_rangess_decrease_by(const f_array_length_t amount, f_utf_string_rangess_t *rangess) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!rangess) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (rangess->size - amount > 0) { + return private_f_utf_string_rangess_resize(rangess->size - amount, rangess); + } + + return private_f_utf_string_rangess_resize(0, rangess); + } +#endif // _di_f_utf_string_rangess_decrease_by_ + +#ifndef _di_f_utf_string_rangess_increase_ + f_status_t f_utf_string_rangess_increase(f_utf_string_rangess_t *rangess) { + #ifndef _di_level_0_parameter_checking_ + if (!rangess) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (rangess->used + 1 > rangess->size) { + f_array_length_t size = rangess->used + f_memory_default_allocation_step; + + if (size > f_array_length_t_size) { + if (rangess->used + 1 > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + size = f_array_length_t_size; + } + + return private_f_utf_string_rangess_resize(size, rangess); + } + + return F_data_not; + } +#endif // _di_f_utf_string_rangess_increase_ + +#ifndef _di_f_utf_string_rangess_increase_by_ + f_status_t f_utf_string_rangess_increase_by(const f_array_length_t amount, f_utf_string_rangess_t *rangess) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!rangess) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (rangess->used + amount > rangess->size) { + if (rangess->used + amount > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_rangess_resize(rangess->used + amount, rangess); + } + + return F_data_not; + } +#endif // _di_f_utf_string_rangess_increase_by_ + +#ifndef _di_f_utf_string_rangess_resize_ + f_status_t f_utf_string_rangess_resize(const f_string_length_t length, f_utf_string_rangess_t *rangess) { + #ifndef _di_level_0_parameter_checking_ + if (!rangess) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_rangess_resize(length, rangess); + } +#endif // _di_f_utf_string_rangess_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf_range.h b/level_0/f_utf/c/utf_range.h new file mode 100644 index 0000000..30ee1ae --- /dev/null +++ b/level_0/f_utf/c/utf_range.h @@ -0,0 +1,362 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.5 + * Licenses: lgplv2.1 + * + * Defines range string data. + * + * This is auto-included by string.h and should not need to be explicitly included. + */ +#ifndef _F_utf_string_range_h +#define _F_utf_string_range_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A structure designating a start and stop range for some string. + * + * In general, this project uses the start and stop position inclusively, meaning that a range of 0 to 1 would include positions 0 and position 1. + * Therefore, a range from 0 to 0 would be include position 0. + * Set start to some value larger than stop to designate that there is no range (such as start = 1, stop = 0). + * + * A special f_macro_utf_string_range_t_initialize() is provided for the special purpose of easily initialize a static string range. + * + * start: the start position. + * stop: the stop position. + */ +#ifndef _di_f_utf_string_range_t_ + typedef struct { + f_string_length_t start; + f_string_length_t stop; + } f_utf_string_range_t; + + #define f_utf_string_range_t_initialize { 1, 0 } + + #define f_macro_utf_string_range_t_initialize(length) { length ? 0 : 1, length ? length - 1 : 0 } + + #define f_macro_utf_string_range_t_clear(range) \ + range.start = 1; \ + range.stop = 0; +#endif // _di_f_utf_string_range_t_ + +/** + * An array of string ranges. + * + * array: the array of string ranges. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_ranges_t_ + typedef struct { + f_utf_string_range_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_ranges_t; + + #define f_utf_string_ranges_t_initialize { 0, 0, 0 } + + #define f_macro_utf_string_ranges_t_clear(ranges) f_macro_memory_structure_clear(ranges) + + #define f_macro_utf_string_ranges_t_resize(status, ranges, length) status = f_utf_string_ranges_resize(length, &ranges); + #define f_macro_utf_string_ranges_t_adjust(status, ranges, length) status = f_utf_string_ranges_adjust(length, &ranges); + + #define f_macro_utf_string_ranges_t_delete_simple(ranges) f_utf_string_ranges_resize(0, &ranges); + #define f_macro_utf_string_ranges_t_destroy_simple(ranges) f_utf_string_ranges_adjust(0, &ranges); + + #define f_macro_utf_string_ranges_t_increase(status, ranges) status = f_utf_string_ranges_increase(&ranges); + #define f_macro_utf_string_ranges_t_increase_by(status, ranges, amount) status = f_utf_string_ranges_increase_by(amount, &ranges); + #define f_macro_utf_string_ranges_t_decrease_by(status, ranges, amount) status = f_utf_string_ranges_decrease_by(amount, &ranges); + #define f_macro_utf_string_ranges_t_decimate_by(status, ranges, amount) status = f_utf_string_ranges_decimate_by(amount, &ranges); +#endif // _di_f_utf_string_ranges_t_ + +/** + * This holds an array of f_utf_string_ranges_t. + * + * array: The array of ranges arrays. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_rangess_t_ + typedef struct { + f_utf_string_ranges_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_rangess_t; + + #define f_utf_string_rangess_t_initialize { 0, 0, 0 } + + #define f_macro_utf_string_rangess_t_clear(rangess) f_macro_memory_structures_clear(rangess) + + #define f_macro_utf_string_rangess_t_resize(status, rangess, length) status = f_utf_string_rangess_resize(length, &rangess); + #define f_macro_utf_string_rangess_t_adjust(status, rangess, length) status = f_utf_string_rangess_adjust(length, &rangess); + + #define f_macro_utf_string_rangess_t_delete_simple(rangess) f_utf_string_rangess_resize(0, &rangess); + #define f_macro_utf_string_rangess_t_destroy_simple(rangess) f_utf_string_rangess_adjust(0, &rangess); + + #define f_macro_utf_string_rangess_t_increase(status, rangess) status = f_utf_string_rangess_increase(&rangess); + #define f_macro_utf_string_rangess_t_increase_by(status, rangess, amount) status = f_utf_string_rangess_increase_by(amount, &rangess); + #define f_macro_utf_string_rangess_t_decrease_by(status, rangess, amount) status = f_utf_string_rangess_decrease_by(amount, &rangess); + #define f_macro_utf_string_rangess_t_decimate_by(status, rangess, amount) status = f_utf_string_rangess_decimate_by(amount, &rangess); +#endif // _di_f_utf_string_rangess_t_ + +/** + * Resize the string ranges array. + * + * @param length + * The new size to use. + * @param ranges + * The string ranges array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_ranges_adjust_ + extern f_status_t f_utf_string_ranges_adjust(const f_array_length_t length, f_utf_string_ranges_t *ranges); +#endif // _di_f_utf_string_ranges_adjust_ + +/** + * Resize the string ranges array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param ranges + * The string ranges array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_ranges_decimate_by_ + extern f_status_t f_utf_string_ranges_decimate_by(const f_array_length_t amount, f_utf_string_ranges_t *ranges); +#endif // _di_f_utf_string_ranges_decimate_by_ + +/** + * Resize the string ranges array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param ranges + * The string ranges array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_ranges_decrease_by_ + extern f_status_t f_utf_string_ranges_decrease_by(const f_array_length_t amount, f_utf_string_ranges_t *ranges); +#endif // _di_f_utf_string_ranges_decrease_by_ + +/** + * Increase the size of the string ranges array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param ranges + * The string ranges array to resize. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * @return + * F_none on success. + * F_array_too_large (with error bit) if the new array length is too large. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_ranges_increase_ + extern f_status_t f_utf_string_ranges_increase(f_utf_string_ranges_t *ranges); +#endif // _di_f_utf_string_ranges_increase_ + +/** + * Resize the string ranges array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param ranges + * The string ranges array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_array_too_large (with error bit) if the new array length is too large. + */ +#ifndef _di_f_utf_string_ranges_increase_by_ + extern f_status_t f_utf_string_ranges_increase_by(const f_array_length_t amount, f_utf_string_ranges_t *ranges); +#endif // _di_f_utf_string_ranges_increase_by_ + +/** + * Resize the string ranges array. + * + * @param length + * The new size to use. + * @param ranges + * The string ranges array to adjust. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_ranges_resize_ + extern f_status_t f_utf_string_ranges_resize(const f_array_length_t length, f_utf_string_ranges_t *ranges); +#endif // _di_f_utf_string_ranges_resize_ + +/** + * Resize the string rangess array. + * + * @param length + * The new size to use. + * @param rangess + * The string rangess array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_rangess_adjust_ + extern f_status_t f_utf_string_rangess_adjust(const f_array_length_t length, f_utf_string_rangess_t *rangess); +#endif // _di_f_utf_string_rangess_adjust_ + +/** + * Resize the string rangess array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param rangess + * The string rangess array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_rangess_decimate_by_ + extern f_status_t f_utf_string_rangess_decimate_by(const f_array_length_t amount, f_utf_string_rangess_t *rangess); +#endif // _di_f_utf_string_rangess_decimate_by_ + +/** + * Resize the string rangess array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param rangess + * The string rangess array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_rangess_decrease_by_ + extern f_status_t f_utf_string_rangess_decrease_by(const f_array_length_t amount, f_utf_string_rangess_t *rangess); +#endif // _di_f_utf_string_rangess_decrease_by_ + +/** + * Increase the size of the string rangess array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param rangess + * The string rangess array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_rangess_increase_ + extern f_status_t f_utf_string_rangess_increase(f_utf_string_rangess_t *rangess); +#endif // _di_f_utf_string_rangess_increase_ + +/** + * Resize the string rangess array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param rangess + * The string rangess array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_array_too_large (with error bit) if the new array length is too large. + */ +#ifndef _di_f_utf_string_rangess_increase_by_ + extern f_status_t f_utf_string_rangess_increase_by(const f_array_length_t amount, f_utf_string_rangess_t *rangess); +#endif // _di_f_utf_string_rangess_increase_by_ + +/** + * Resize the string rangess array. + * + * @param length + * The new size to use. + * @param rangess + * The string rangess array to adjust. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_rangess_resize_ + extern f_status_t f_utf_string_rangess_resize(const f_array_length_t length, f_utf_string_rangess_t *rangess); +#endif // _di_f_utf_string_rangess_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_string_range_h diff --git a/level_0/f_utf/c/utf_triple.c b/level_0/f_utf/c/utf_triple.c new file mode 100644 index 0000000..e5cf0d7 --- /dev/null +++ b/level_0/f_utf/c/utf_triple.c @@ -0,0 +1,103 @@ +#include "utf.h" +#include "private-utf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _di_f_utf_string_triples_adjust_ + f_status_t f_utf_string_triples_adjust(const f_string_length_t length, f_utf_string_triples_t *triples) { + #ifndef _di_level_0_parameter_checking_ + if (!triples) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_triples_adjust(length, triples); + } +#endif // _di_f_utf_string_triples_adjust_ + +#ifndef _di_f_utf_string_triples_decimate_by_ + f_status_t f_utf_string_triples_decimate_by(const f_array_length_t amount, f_utf_string_triples_t *triples) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!triples) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (triples->size - amount > 0) { + return private_f_utf_string_triples_adjust(triples->size - amount, triples); + } + + return private_f_utf_string_triples_adjust(0, triples); + } +#endif // _di_f_utf_string_triples_decimate_by_ + +#ifndef _di_f_utf_string_triples_decrease_by_ + f_status_t f_utf_string_triples_decrease_by(const f_array_length_t amount, f_utf_string_triples_t *triples) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!triples) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (triples->size - amount > 0) { + return private_f_utf_string_triples_resize(triples->size - amount, triples); + } + + return private_f_utf_string_triples_resize(0, triples); + } +#endif // _di_f_utf_string_triples_decrease_by_ + +#ifndef _di_f_utf_string_triples_increase_ + f_status_t f_utf_string_triples_increase(f_utf_string_triples_t *triples) { + #ifndef _di_level_0_parameter_checking_ + if (!triples) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (triples->used + 1 > triples->size) { + f_array_length_t size = triples->used + f_memory_default_allocation_step; + + if (size > f_array_length_t_size) { + if (triples->used + 1 > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + size = f_array_length_t_size; + } + + return private_f_utf_string_triples_resize(size, triples); + } + + return F_data_not; + } +#endif // _di_f_utf_string_triples_increase_ + +#ifndef _di_f_utf_string_triples_increase_by_ + f_status_t f_utf_string_triples_increase_by(const f_array_length_t amount, f_utf_string_triples_t *triples) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!triples) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (triples->used + amount > triples->size) { + if (triples->used + amount > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + + return private_f_utf_string_triples_resize(triples->used + amount, triples); + } + + return F_data_not; + } +#endif // _di_f_utf_string_triples_increase_by_ + +#ifndef _di_f_utf_string_triples_resize_ + f_status_t f_utf_string_triples_resize(const f_string_length_t length, f_utf_string_triples_t *triples) { + #ifndef _di_level_0_parameter_checking_ + if (!triples) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_utf_string_triples_resize(length, triples); + } +#endif // _di_f_string_triples_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif diff --git a/level_0/f_utf/c/utf_triple.h b/level_0/f_utf/c/utf_triple.h new file mode 100644 index 0000000..801ddf6 --- /dev/null +++ b/level_0/f_utf/c/utf_triple.h @@ -0,0 +1,217 @@ +/** + * FLL - Level 0 + * + * Project: UTF + * API Version: 0.5 + * Licenses: lgplv2.1 + * + * Defines 3-tuple of string data called a triple (which is an ordered list of 3 strings). + * + * This is auto-included by string.h and should not need to be explicitly included. + */ +#ifndef _F_utf_string_triple_h +#define _F_utf_string_triple_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A string triple consisting of a set of three strings. + * + * one: A string representing the first string in the triple. + * two: A string representing the second string in the triple. + * three: A string representing the third string in the triple. + */ +#ifndef _di_f_utf_string_triple_t_ + typedef struct { + f_utf_string_dynamic_t one; + f_utf_string_dynamic_t two; + f_utf_string_dynamic_t three; + } f_utf_string_triple_t; + + #define f_utf_string_triple_t_initialize { f_utf_string_dynamic_t_initialize, f_utf_string_dynamic_t_initialize, f_utf_string_dynamic_t_initialize } + + #define f_macro_utf_string_triple_t_clear(triple) \ + triple.one.array = 0; \ + triple.one.size = 0; \ + triple.one.used = 0; \ + triple.two.array = 0; \ + triple.two.size = 0; \ + triple.two.used = 0; \ + triple.three.array = 0; \ + triple.three.size = 0; \ + triple.three.used = 0; + + #define f_macro_utf_string_triple_t_delete_simple(triple) \ + f_macro_utf_string_dynamic_t_delete_simple(triple.one) \ + f_macro_utf_string_dynamic_t_delete_simple(triple.two) \ + f_macro_utf_string_dynamic_t_delete_simple(triple.three) + + #define f_macro_utf_string_triple_t_destroy_simple(triple) \ + f_macro_utf_string_dynamic_t_destroy_simple(triple.one) \ + f_macro_utf_string_dynamic_t_destroy_simple(triple.two) \ + f_macro_utf_string_dynamic_t_destroy_simple(triple.three) +#endif // _di_f_utf_string_triple_t_ + +/** + * An array of string triples. + * + * array: the array of string triples. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_utf_string_triples_t_ + typedef struct { + f_utf_string_triple_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_utf_string_triples_t; + + #define f_utf_string_triples_t_initialize f_utf_string_statics_t_initialize + + #define f_macro_utf_string_triples_t_clear(triples) f_macro_memory_structure_clear(triples) + + #define f_macro_utf_string_triples_t_resize(status, triples, length) status = f_utf_string_triples_resize(length, &triples); + #define f_macro_utf_string_triples_t_adjust(status, triples, length) status = f_utf_string_triples_adjust(length, &triples); + + #define f_macro_utf_string_triples_t_delete_simple(triples) f_utf_string_triples_resize(0, &triples); + #define f_macro_utf_string_triples_t_destroy_simple(triples) f_utf_string_triples_adjust(0, &triples); + + #define f_macro_utf_string_triples_t_increase(status, triples) status = f_utf_string_triples_increase(triples); + #define f_macro_utf_string_triples_t_increase_by(status, triples, amount) status = f_utf_string_triples_increase_by(amount, triples); + #define f_macro_utf_string_triples_t_decrease_by(status, triples, amount) status = f_utf_string_triples_decrease_by(amount, triples); + #define f_macro_utf_string_triples_t_decimate_by(status, triples, amount) status = f_utf_string_triples_decimate_by(amount, triples); +#endif // _di_f_utf_string_triples_t_ + +/** + * Resize the string triples array. + * + * @param length + * The new size to use. + * @param triples + * The string triples array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_triples_adjust_ + extern f_status_t f_utf_string_triples_adjust(const f_array_length_t length, f_utf_string_triples_t *triples); +#endif // _di_f_utf_string_triples_adjust_ + +/** + * Resize the string triples array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param triples + * The string triples array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_triples_decimate_by_ + extern f_status_t f_utf_string_triples_decimate_by(const f_array_length_t amount, f_utf_string_triples_t *triples); +#endif // _di_f_utf_string_triples_decimate_by_ + +/** + * Resize the string triples array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param triples + * The string triples array to resize. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_triples_decrease_by_ + extern f_status_t f_utf_string_triples_decrease_by(const f_array_length_t amount, f_utf_string_triples_t *triples); +#endif // _di_f_utf_string_triples_decrease_by_ + +/** + * Increase the size of the string triples array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param triples + * The string triples array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + 1 <= size). + * + * F_array_too_large (with error bit) if the new array length is too large. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_triples_increase_ + extern f_status_t f_utf_string_triples_increase(f_utf_string_triples_t *triples); +#endif // _di_f_utf_string_triples_increase_ + +/** + * Resize the string triples array to a larger size. + * + * This will resize making the string larger based on the given length. + * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param triples + * The string triples array to resize. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (used + amount <= size). + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * F_array_too_large (with error bit) if the new array length is too large. + */ +#ifndef _di_f_utf_string_triples_increase_by_ + extern f_status_t f_utf_string_triples_increase_by(const f_array_length_t amount, f_utf_string_triples_t *triples); +#endif // _di_f_utf_string_triples_increase_by_ + +/** + * Resize the string triples array. + * + * @param length + * The new size to use. + * @param triples + * The string triples array to adjust. + * + * @return + * F_none on success. + * + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_f_utf_string_triples_resize_ + extern f_status_t f_utf_string_triples_resize(const f_array_length_t length, f_utf_string_triples_t *triples); +#endif // _di_f_utf_string_triples_resize_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_utf_string_triple_h diff --git a/level_0/f_utf/data/build/settings b/level_0/f_utf/data/build/settings index 9783ea1..f84d852 100644 --- a/level_0/f_utf/data/build/settings +++ b/level_0/f_utf/data/build/settings @@ -20,9 +20,9 @@ build_indexer ar build_language c build_libraries -lc build_libraries-individual -lf_memory -lf_string -build_sources_library utf.c private-utf.c +build_sources_library utf.c utf-common.c private-utf.c utf_dynamic.c utf_map.c utf_quantity.c utf_range.c utf_triple.c build_sources_program -build_sources_headers utf.h utf-common.h +build_sources_headers utf.h utf-common.h utf_dynamic.h utf_map.h utf_quantity.h utf_range.h utf_triple.h build_sources_script build_sources_setting build_script yes diff --git a/level_1/fl_print/c/print.c b/level_1/fl_print/c/print.c index 7810579..f1e77b2 100644 --- a/level_1/fl_print/c/print.c +++ b/level_1/fl_print/c/print.c @@ -48,7 +48,7 @@ extern "C" { #endif // _di_fl_print_trim_except_dynamic_partial_ #ifndef _di_fl_print_trim_except_utf_ - f_status_t fl_print_trim_except_utf(FILE *output, const f_utf_string_t string, const f_utf_string_length_t length, const f_utf_string_lengths_t except) { + f_status_t fl_print_trim_except_utf(FILE *output, const f_utf_string_t string, const f_string_length_t length, const f_string_lengths_t except) { #ifndef _di_level_1_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -60,7 +60,7 @@ extern "C" { #endif // _di_fl_print_trim_except_utf_ #ifndef _di_fl_print_trim_except_utf_dynamic_ - f_status_t fl_print_trim_except_utf_dynamic(FILE *output, const f_utf_string_static_t buffer, const f_utf_string_lengths_t except) { + f_status_t fl_print_trim_except_utf_dynamic(FILE *output, const f_utf_string_static_t buffer, const f_string_lengths_t except) { #ifndef _di_level_1_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -72,7 +72,7 @@ extern "C" { #endif // _di_fl_print_trim_except_utf_dynamic_ #ifndef _di_fl_print_trim_except_utf_dynamic_partial_ - f_status_t fl_print_trim_except_utf_dynamic_partial(FILE *output, const f_utf_string_static_t buffer, const f_utf_string_range_t range, const f_utf_string_lengths_t except) { + f_status_t fl_print_trim_except_utf_dynamic_partial(FILE *output, const f_utf_string_static_t buffer, const f_utf_string_range_t range, const f_string_lengths_t except) { #ifndef _di_level_1_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -132,7 +132,7 @@ extern "C" { #endif // _di_fl_print_trim_dynamic_partial_ #ifndef _di_fl_print_trim_utf_ - f_status_t fl_print_trim_utf(FILE *output, const f_utf_string_t string, const f_utf_string_length_t length) { + f_status_t fl_print_trim_utf(FILE *output, const f_utf_string_t string, const f_string_length_t length) { #ifndef _di_level_1_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ diff --git a/level_1/fl_print/c/print.h b/level_1/fl_print/c/print.h index 4af7e08..ed4129b 100644 --- a/level_1/fl_print/c/print.h +++ b/level_1/fl_print/c/print.h @@ -153,7 +153,7 @@ extern "C" { * Errors (with error bit) from: f_utf_character_is_whitespace(). */ #ifndef _di_fl_print_trim_except_utf_ - extern f_status_t fl_print_trim_except_utf(FILE *output, const f_utf_string_t string, const f_utf_string_length_t length, const f_utf_string_lengths_t except); + extern f_status_t fl_print_trim_except_utf(FILE *output, const f_utf_string_t string, const f_string_length_t length, const f_string_lengths_t except); #endif // _di_fl_print_trim_except_utf_ /** @@ -185,7 +185,7 @@ extern "C" { * Errors (with error bit) from: f_utf_character_is_whitespace(). */ #ifndef _di_fl_print_trim_except_utf_dynamic_ - extern f_status_t fl_print_trim_except_utf_dynamic(FILE *output, const f_utf_string_static_t buffer, const f_utf_string_lengths_t except); + extern f_status_t fl_print_trim_except_utf_dynamic(FILE *output, const f_utf_string_static_t buffer, const f_string_lengths_t except); #endif // _di_fl_print_trim_except_utf_dynamic_ /** @@ -219,7 +219,7 @@ extern "C" { * Errors (with error bit) from: f_utf_character_is_whitespace(). */ #ifndef _di_fl_print_trim_except_utf_dynamic_partial_ - extern f_status_t fl_print_trim_except_utf_dynamic_partial(FILE *output, const f_utf_string_static_t buffer, const f_utf_string_range_t range, const f_utf_string_lengths_t except); + extern f_status_t fl_print_trim_except_utf_dynamic_partial(FILE *output, const f_utf_string_static_t buffer, const f_utf_string_range_t range, const f_string_lengths_t except); #endif // _di_fl_print_trim_except_utf_dynamic_partial_ /** @@ -335,7 +335,7 @@ extern "C" { * Errors (with error bit) from: f_utf_character_is_whitespace(). */ #ifndef _di_fl_print_trim_utf_ - extern f_status_t fl_print_trim_utf(FILE *output, const f_utf_string_t string, const f_utf_string_length_t length); + extern f_status_t fl_print_trim_utf(FILE *output, const f_utf_string_t string, const f_string_length_t length); #endif // _di_fl_print_trim_utf_ /** diff --git a/level_1/fl_print/c/private-print.c b/level_1/fl_print/c/private-print.c index 4ddbccc..e4428ef 100644 --- a/level_1/fl_print/c/private-print.c +++ b/level_1/fl_print/c/private-print.c @@ -129,7 +129,7 @@ extern "C" { #endif // !defined(_di_fl_print_trim_except_) || !defined(_di_fl_print_trim_except_dynamic_) || !defined(_di_fl_print_trim_except_dynamic_partial_) #if !defined(_di_fl_print_trim_except_utf_) || !defined(_di_fl_print_trim_except_utf_dynamic_) || !defined(_di_fl_print_trim_except_utf_dynamic_partial_) - f_status_t private_fl_print_trim_except_utf(FILE *output, const f_utf_string_t string, const f_utf_string_length_t start, const f_utf_string_length_t stop, const f_utf_string_lengths_t except) { + f_status_t private_fl_print_trim_except_utf(FILE *output, const f_utf_string_t string, const f_string_length_t start, const f_string_length_t stop, const f_string_lengths_t except) { register f_string_length_t i = start; f_string_length_t j = 0; @@ -308,7 +308,7 @@ extern "C" { #endif // !defined(_di_fl_print_trim_) || !defined(_di_fl_print_trim_dynamic_) || !defined(_di_fl_print_trim_dynamic_partial_) #if !defined(_di_fl_print_trim_utf_) || !defined(_di_fl_print_trim_utf_dynamic_) || !defined(_di_fl_print_trim_utf_dynamic_partial_) - f_status_t private_fl_print_trim_utf(FILE *output, const f_utf_string_t string, const f_utf_string_length_t length) { + f_status_t private_fl_print_trim_utf(FILE *output, const f_utf_string_t string, const f_string_length_t length) { register f_string_length_t i = 0; f_string_length_t j = 0; diff --git a/level_1/fl_print/c/private-print.h b/level_1/fl_print/c/private-print.h index 6eb75b9..56f5387 100644 --- a/level_1/fl_print/c/private-print.h +++ b/level_1/fl_print/c/private-print.h @@ -82,7 +82,7 @@ extern "C" { * @see fl_print_trim_except_utf_dynamic_partial() */ #if !defined(_di_fl_print_trim_except_utf_) || !defined(_di_fl_print_trim_except_utf_dynamic_) || !defined(_di_fl_print_trim_except_utf_dynamic_partial_) - extern f_status_t private_fl_print_trim_except_utf(FILE *output, const f_utf_string_t string, const f_string_length_t start, const f_utf_string_length_t stop, const f_utf_string_lengths_t except) f_gcc_attribute_visibility_internal; + extern f_status_t private_fl_print_trim_except_utf(FILE *output, const f_utf_string_t string, const f_string_length_t start, const f_string_length_t stop, const f_string_lengths_t except) f_gcc_attribute_visibility_internal; #endif // !defined(_di_fl_print_trim_except_utf_) || !defined(_di_fl_print_trim_except_utf_dynamic_) || !defined(_di_fl_print_trim_except_utf_dynamic_partial_) /** @@ -142,7 +142,7 @@ extern "C" { * @see fl_print_trim_utf_dynamic_partial() */ #if !defined(_di_fl_print_trim_utf_) || !defined(_di_fl_print_trim_utf_dynamic_) || !defined(_di_fl_print_trim_utf_dynamic_partial_) - extern f_status_t private_fl_print_trim_utf(FILE *output, const f_utf_string_t string, const f_utf_string_length_t length) f_gcc_attribute_visibility_internal; + extern f_status_t private_fl_print_trim_utf(FILE *output, const f_utf_string_t string, const f_string_length_t length) f_gcc_attribute_visibility_internal; #endif // !defined(_di_fl_print_trim_utf_) || !defined(_di_fl_print_trim_utf_dynamic_) || !defined(_di_fl_print_trim_utf_dynamic_partial_) #ifdef __cplusplus diff --git a/level_1/fl_string/c/string.c b/level_1/fl_string/c/string.c index 31af4a9..585d299 100644 --- a/level_1/fl_string/c/string.c +++ b/level_1/fl_string/c/string.c @@ -253,47 +253,6 @@ extern "C" { } #endif // _di_fl_string_dynamic_rip_nulless_ -#ifndef _di_fl_string_dynamic_seek_line_ - f_status_t fl_string_dynamic_seek_line(const f_string_t string, f_string_range_t *range) { - #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!string) return F_data_not; - if (range->start > range->stop) return F_data_not_stop; - - while (string[range->start] != f_string_eol_s[0]) { - range->start++; - - if (range->start > range->stop) return F_none_stop; - } // while - - return F_none; - } -#endif // _di_fl_string_dynamic_seek_line_ - -#ifndef _di_fl_string_dynamic_seek_line_to_ - f_status_t fl_string_dynamic_seek_line_to(const f_string_t string, const int8_t seek_to_this, f_string_range_t *range) { - #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!string) return F_data_not; - if (range->start > range->stop) return F_data_not_stop; - - while (string[range->start] != seek_to_this) { - - if (string[range->start] == f_string_eol_s[0]) return F_none_eol; - - range->start++; - - if (range->start > range->stop) return F_none_stop; - } // while - - return F_none; - } -#endif // _di_fl_string_dynamic_seek_line_to_ - #ifndef _di_fl_string_dynamic_seek_line_to_utf_character_ f_status_t fl_string_dynamic_seek_line_to_utf_character(const f_string_t string, const f_utf_character_t seek_to_this, f_string_range_t *range) { #ifndef _di_level_1_parameter_checking_ @@ -395,8 +354,8 @@ extern "C" { } #endif // _di_fl_string_dynamic_seek_line_until_graph_ -#ifndef _di_fl_string_dynamic_seek_line_until_non_graph_ - f_status_t fl_string_dynamic_seek_line_until_non_graph(const f_string_t string, const int8_t placeholder, f_string_range_t *range) { +#ifndef _di_fl_string_dynamic_seek_line_until_graph_non_ + f_status_t fl_string_dynamic_seek_line_until_graph_non(const f_string_t string, const int8_t placeholder, f_string_range_t *range) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -437,26 +396,7 @@ extern "C" { return F_none; } -#endif // _di_fl_string_dynamic_seek_line_until_non_graph_ - -#ifndef _di_fl_string_dynamic_seek_to_ - f_status_t fl_string_dynamic_seek_to(const f_string_t string, const int8_t seek_to_this, f_string_range_t *range) { - #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!string) return F_data_not; - if (range->start > range->stop) return F_data_not_stop; - - while (string[range->start] != seek_to_this) { - range->start++; - - if (range->start > range->stop) return F_none_stop; - } // while - - return F_none; - } -#endif // _di_fl_string_dynamic_seek_to_ +#endif // _di_fl_string_dynamic_seek_line_until_graph_non_ #ifndef _di_fl_string_dynamic_seek_to_utf_character_ f_status_t fl_string_dynamic_seek_to_utf_character(const f_string_t string, const f_utf_character_t seek_to_this, f_string_range_t *range) { @@ -551,26 +491,6 @@ extern "C" { } #endif // _di_fl_string_rip_nulless_ -#ifndef _di_fl_string_seek_line_to_ - f_status_t fl_string_seek_line_to(const f_string_t string, const int8_t seek_to, f_string_range_t *range) { - #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (range->start > range->stop) return F_data_not_stop; - - while (string[range->start] != seek_to) { - if (string[range->start] == f_string_eol_s[0]) return F_none_eol; - - range->start++; - - if (range->start > range->stop) return F_none_stop; - } // while - - return F_none; - } -#endif // _di_fl_string_seek_line_to_ - #ifndef _di_fl_string_seek_line_to_utf_character_ f_status_t fl_string_seek_line_to_utf_character(const f_string_t string, const f_utf_character_t seek_to, f_string_range_t *range) { #ifndef _di_level_1_parameter_checking_ @@ -665,8 +585,8 @@ extern "C" { } #endif // _di_fl_string_seek_line_until_graph_ -#ifndef _di_fl_string_seek_line_until_non_graph_ - f_status_t fl_string_seek_line_until_non_graph(const f_string_t string, const int8_t placeholder, f_string_range_t *range) { +#ifndef _di_fl_string_seek_line_until_graph_non_ + f_status_t fl_string_seek_line_until_graph_non(const f_string_t string, const int8_t placeholder, f_string_range_t *range) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -709,25 +629,7 @@ extern "C" { return F_none; } -#endif // _di_fl_string_seek_line_until_non_graph_ - -#ifndef _di_fl_string_seek_to_ - f_status_t fl_string_seek_to(const f_string_t string, const int8_t seek_to, f_string_range_t *range) { - #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (range->start > range->stop) return F_data_not_stop; - - while (string[range->start] != seek_to) { - range->start++; - - if (range->start > range->stop) return F_none_stop; - } // while - - return F_none; - } -#endif // _di_fl_string_seek_to_ +#endif // _di_fl_string_seek_line_until_graph_non_ #ifndef _di_fl_string_seek_to_utf_character_ f_status_t fl_string_seek_to_utf_character(const f_string_t string, const f_utf_character_t seek_to, f_string_range_t *range) { diff --git a/level_1/fl_string/c/string.h b/level_1/fl_string/c/string.h index 3b0fbed..1d0b7da 100644 --- a/level_1/fl_string/c/string.h +++ b/level_1/fl_string/c/string.h @@ -413,6 +413,28 @@ extern "C" { #endif // _di_fl_string_dynamic_partial_compare_ /** + * Compare two strings, similar to strncmp(), but restricted to the given range for the second string. + * + * This does not stop on NULL. + * NULL characters are ignored. + * + * @param string1 + * String to compare. + * @param string2 + * String to compare. + * @param range2 + * A range within the string2 to restrict the comparison to. + * + * @return + * F_equal_to when both strings equal. + * F_equal_to_not when both strings do not equal. + * F_parameter (with error bit) if a parameter is invalid. + */ +#ifndef _di_fl_string_dynamic_partial_compare_dynamic_ + extern f_status_t fl_string_dynamic_partial_compare_dynamic(const f_string_static_t string1, const f_string_static_t string2, const f_string_range_t range2); +#endif // _di_fl_string_dynamic_partial_compare_dynamic_ + +/** * Compare two strings, similar to strncmp(), but restricted to the given ranges. * * This does not stop on NULL. @@ -506,7 +528,7 @@ extern "C" { #endif // _di_fl_string_dynamic_partial_compare_except_string_ /** - * Compare two strings, similar to strncmp(), but restricted to the given range for the second string. + * Compare two strings, similar to strncmp(), but restricted to the given ranges. * * This does not stop on NULL. * NULL characters are ignored. @@ -517,6 +539,8 @@ extern "C" { * String to compare. * @param string2 * String to compare. + * @param range1 + * A range within the string1 to restrict the comparison to. * @param range2 * A range within the string2 to restrict the comparison to. * @param except1 @@ -535,15 +559,13 @@ extern "C" { * * @see f_utf_is_whitespace() */ -#ifndef _di_fl_string_dynamic_partial_compare_except_trim_dynamic_ - extern f_status_t fl_string_dynamic_partial_compare_except_trim_dynamic(const f_string_static_t string1, const f_string_static_t string2, const f_string_range_t range2, const f_string_lengths_t except1, const f_string_lengths_t except2); -#endif // _di_fl_string_dynamic_partial_compare_except_trim_dynamic_ +#ifndef _di_fl_string_dynamic_partial_compare_except_trim_ + extern f_status_t fl_string_dynamic_partial_compare_except_trim(const f_string_static_t string1, const f_string_static_t string2, const f_string_range_t range1, const f_string_range_t range2, const f_string_lengths_t except1, const f_string_lengths_t except2); +#endif // _di_fl_string_dynamic_partial_compare_except_trim_ /** * Compare two strings, similar to strncmp(), but restricted to the given range for the second string. * - * This operates with the first string being a traditional string. - * * This does not stop on NULL. * NULL characters are ignored. * Ignores leading and trailing whitespace. @@ -553,8 +575,6 @@ extern "C" { * String to compare. * @param string2 * String to compare. - * @param length1 - * The length of string1. * @param range2 * A range within the string2 to restrict the comparison to. * @param except1 @@ -573,12 +593,14 @@ extern "C" { * * @see f_utf_is_whitespace() */ -#ifndef _di_fl_string_dynamic_partial_compare_except_trim_string_ - extern f_status_t fl_string_dynamic_partial_compare_except_trim_string(const f_string_t string1, const f_string_static_t string2, const f_string_length_t length1, const f_string_range_t range2, const f_string_lengths_t except1, const f_string_lengths_t except2); -#endif // _di_fl_string_dynamic_partial_compare_except_trim_string_ +#ifndef _di_fl_string_dynamic_partial_compare_except_trim_dynamic_ + extern f_status_t fl_string_dynamic_partial_compare_except_trim_dynamic(const f_string_static_t string1, const f_string_static_t string2, const f_string_range_t range2, const f_string_lengths_t except1, const f_string_lengths_t except2); +#endif // _di_fl_string_dynamic_partial_compare_except_trim_dynamic_ /** - * Compare two strings, similar to strncmp(), but restricted to the given ranges. + * Compare two strings, similar to strncmp(), but restricted to the given range for the second string. + * + * This operates with the first string being a traditional string. * * This does not stop on NULL. * NULL characters are ignored. @@ -589,8 +611,8 @@ extern "C" { * String to compare. * @param string2 * String to compare. - * @param range1 - * A range within the string1 to restrict the comparison to. + * @param length1 + * The length of string1. * @param range2 * A range within the string2 to restrict the comparison to. * @param except1 @@ -609,31 +631,9 @@ extern "C" { * * @see f_utf_is_whitespace() */ -#ifndef _di_fl_string_dynamic_partial_compare_except_trim_ - extern f_status_t fl_string_dynamic_partial_compare_except_trim(const f_string_static_t string1, const f_string_static_t string2, const f_string_range_t range1, const f_string_range_t range2, const f_string_lengths_t except1, const f_string_lengths_t except2); -#endif // _di_fl_string_dynamic_partial_compare_except_trim_ - -/** - * Compare two strings, similar to strncmp(), but restricted to the given range for the second string. - * - * This does not stop on NULL. - * NULL characters are ignored. - * - * @param string1 - * String to compare. - * @param string2 - * String to compare. - * @param range2 - * A range within the string2 to restrict the comparison to. - * - * @return - * F_equal_to when both strings equal. - * F_equal_to_not when both strings do not equal. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_fl_string_dynamic_partial_compare_dynamic_ - extern f_status_t fl_string_dynamic_partial_compare_dynamic(const f_string_static_t string1, const f_string_static_t string2, const f_string_range_t range2); -#endif // _di_fl_string_dynamic_partial_compare_dynamic_ +#ifndef _di_fl_string_dynamic_partial_compare_except_trim_string_ + extern f_status_t fl_string_dynamic_partial_compare_except_trim_string(const f_string_t string1, const f_string_static_t string2, const f_string_length_t length1, const f_string_range_t range2, const f_string_lengths_t except1, const f_string_lengths_t except2); +#endif // _di_fl_string_dynamic_partial_compare_except_trim_string_ /** * Compare two strings, similar to strncmp(), but restricted to the given range for the second string. @@ -720,35 +720,6 @@ extern "C" { #endif // _di_fl_string_dynamic_partial_compare_trim_string_ /** - * Compare two strings, similar to strncmp(), but restricted to the given ranges. - * - * This does not stop on NULL. - * NULL characters are ignored. - * Ignores leading and trailing whitespace. - * - * @param string1 - * String to compare. - * @param string2 - * String to compare. - * @param range1 - * A range within the string1 to restrict the comparison to. - * @param range2 - * A range within the string2 to restrict the comparison to. - * - * @return - * F_equal_to when both strings equal. - * F_equal_to_not when both strings do not equal. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_utf_is_whitespace(). - * - * @see f_utf_is_whitespace() - */ -#ifndef _di_fl_string_dynamic_partial_compare_trim_ - extern f_status_t fl_string_dynamic_partial_compare_trim(const f_string_static_t string1, const f_string_static_t string2, const f_string_range_t range1, const f_string_range_t range2); -#endif // _di_fl_string_dynamic_partial_compare_trim_ - -/** * Allocate a new string from the provided range in the buffer. * * Ignores leading and trailing whitespace. @@ -802,107 +773,6 @@ extern "C" { #endif // _di_fl_string_dynamic_rip_nulless_ /** - * Allocate a new string from the provided range in the string. - * - * Ignores leading and trailing whitespace. - * Ignores leading and trailing NULL characters. - * As a result, resulting size may be smaller than requested length. - * - * @param source - * The string to rip from. - * @param length - * The length of source to append. - * @param destination - * The new string, which will be allocated or reallocated as necessary. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_utf_is_whitespace(). - * - * @see f_utf_is_whitespace() - */ -#ifndef _di_fl_string_rip_ - extern f_status_t fl_string_rip(const f_string_t source, const f_string_length_t length, f_string_dynamic_t *destination); -#endif // _di_fl_string_rip_ - -/** - * Allocate a new string from the provided range in the string. - * - * Ignores leading and trailing whitespace. - * Ignores leading and trailing NULL characters. - * As a result, resulting size may be smaller than requested length. - * - * Skips over NULL characters from source when ripping. - * - * @param source - * The string to rip from. - * @param length - * The length of source to append. - * @param destination - * The new string, which will be allocated or reallocated as necessary. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_utf_is_whitespace(). - * - * @see f_utf_is_whitespace() - */ -#ifndef _di_fl_string_rip_nulless_ - extern f_status_t fl_string_rip_nulless(const f_string_t source, const f_string_length_t length, f_string_dynamic_t *destination); -#endif // _di_fl_string_rip_nulless_ - -/** - * Seek the buffer location forward until EOL is reached. - * - * @param string - * The string to traverse. - * @param range - * A range within the buffer representing the start and stop locations. - * The start location will be incremented by seek. - * - * @return - * F_none on success. - * F_none_stop on success, but stopped at end of range. - * F_data_not on success, but there was no string data to seek. - * F_data_not_stop on success, but the range.start > range.stop. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_fl_string_dynamic_seek_line_ - extern f_status_t fl_string_dynamic_seek_line(const f_string_t string, f_string_range_t *range); -#endif // _di_fl_string_dynamic_seek_line_ - -/** - * Seek the buffer location forward until the character (1-byte wide) or EOL is reached. - * - * @param string - * The string to traverse. - * @param seek_to_this - * A single-width character representing a character to seek to. - * @param range - * A range within the buffer representing the start and stop locations. - * The start location will be incremented by seek. - * - * @return - * F_none on success. - * F_none_eol on success, but stopped at EOL. - * F_none_stop on success, but stopped at end of range. - * F_data_not on success, but there was no string data to seek. - * F_data_not_stop on success, but the range.start > range.stop. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_fl_string_dynamic_seek_line_to_ - extern f_status_t fl_string_dynamic_seek_line_to(const f_string_t string, const int8_t seek_to_this, f_string_range_t *range); -#endif // _di_fl_string_dynamic_seek_line_to_ - -/** * Seek the buffer location forward until the character (up to 4-byte wide) or EOL is reached. * * @param string @@ -986,33 +856,9 @@ extern "C" { * * @see f_utf_is_graph() */ -#ifndef _di_fl_string_dynamic_seek_line_until_non_graph_ - extern f_status_t fl_string_dynamic_seek_line_until_non_graph(const f_string_t string, const int8_t placeholder, f_string_range_t *range); -#endif // _di_fl_string_dynamic_seek_line_until_non_graph_ - -/** - * Seek the buffer location forward until the character (1-byte wide) is reached. - * - * @param string - * The string to traverse. - * @param seek_to_this - * A single-width character representing a character to seek to. - * @param range - * A range within the buffer representing the start and stop locations. - * The start location will be incremented by seek. - * - * @return - * F_none on success. - * F_none_stop on success, but stopped at end of range. - * F_data_not on success, but there was no string data to seek. - * F_data_not_stop on success, but the range.start > range.stop. - * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. - * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_fl_string_dynamic_seek_to_ - extern f_status_t fl_string_dynamic_seek_to(const f_string_t string, const int8_t seek_to_this, f_string_range_t *range); -#endif // _di_fl_string_dynamic_seek_to_ +#ifndef _di_fl_string_dynamic_seek_line_until_graph_non_ + extern f_status_t fl_string_dynamic_seek_line_until_graph_non(const f_string_t string, const int8_t placeholder, f_string_range_t *range); +#endif // _di_fl_string_dynamic_seek_line_until_graph_non_ /** * Seek the buffer location forward until the UTF-8 character (up to 4-byte wide) is reached. @@ -1044,26 +890,62 @@ extern "C" { #endif // _di_fl_string_dynamic_seek_to_utf_character_ /** - * Seek the string location forward until the character (1-byte wide) or EOL is reached. + * Allocate a new string from the provided range in the string. * - * @param string - * The string to traverse. - * @param seek_to - * A single-width character representing a character to seek to. - * @param range - * A range within the buffer representing the start and stop locations. - * The start location will be incremented by seek. + * Ignores leading and trailing whitespace. + * Ignores leading and trailing NULL characters. + * As a result, resulting size may be smaller than requested length. + * + * @param source + * The string to rip from. + * @param length + * The length of source to append. + * @param destination + * The new string, which will be allocated or reallocated as necessary. * * @return * F_none on success. - * F_none_eol on success, but stopped at EOL. - * F_none_stop on success, but stopped stop location. - * F_data_not_stop if range.start > range.stop. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_utf_is_whitespace(). + * + * @see f_utf_is_whitespace() */ -#ifndef _di_fl_string_seek_line_to_ - extern f_status_t fl_string_seek_line_to(const f_string_t string, const int8_t seek_to, f_string_range_t *range); -#endif // _di_fl_string_seek_line_to_ +#ifndef _di_fl_string_rip_ + extern f_status_t fl_string_rip(const f_string_t source, const f_string_length_t length, f_string_dynamic_t *destination); +#endif // _di_fl_string_rip_ + +/** + * Allocate a new string from the provided range in the string. + * + * Ignores leading and trailing whitespace. + * Ignores leading and trailing NULL characters. + * As a result, resulting size may be smaller than requested length. + * + * Skips over NULL characters from source when ripping. + * + * @param source + * The string to rip from. + * @param length + * The length of source to append. + * @param destination + * The new string, which will be allocated or reallocated as necessary. + * + * @return + * F_none on success. + * F_data_not_eos if source length is 0. + * F_memory_not (with error bit) on out of memory. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_utf_is_whitespace(). + * + * @see f_utf_is_whitespace() + */ +#ifndef _di_fl_string_rip_nulless_ + extern f_status_t fl_string_rip_nulless(const f_string_t source, const f_string_length_t length, f_string_dynamic_t *destination); +#endif // _di_fl_string_rip_nulless_ /** * Seek the string location forward until the character (up to 4-byte wide) or EOL is reached. @@ -1146,32 +1028,9 @@ extern "C" { * * @see f_utf_is_whitespace() */ -#ifndef _di_fl_string_seek_line_until_non_graph_ - extern f_status_t fl_string_seek_line_until_non_graph(const f_string_t string, const int8_t placeholder, f_string_range_t *range); -#endif // _di_fl_string_seek_line_until_non_graph_ - -/** - * Seek the string location forward until the character (1-byte wide) is reached. - * - * @param string - * The string to traverse. - * @param seek_to - * A single-width character representing a character to seek to. - * @param range - * A range within the buffer representing the start and stop locations. - * The start location will be incremented by seek. - * - * @return - * F_none on success. - * F_none_stop on success, but stopped stop location. - * F_data_not_stop if range.start > range.stop. - * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. - * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_fl_string_seek_to_ - extern f_status_t fl_string_seek_to(const f_string_t string, const int8_t seek_to, f_string_range_t *range); -#endif // _di_fl_string_seek_to_ +#ifndef _di_fl_string_seek_line_until_graph_non_ + extern f_status_t fl_string_seek_line_until_graph_non(const f_string_t string, const int8_t placeholder, f_string_range_t *range); +#endif // _di_fl_string_seek_line_until_graph_non_ /** * Seek the string location forward until the UTF-8 character (up to 4-byte wide) is reached. diff --git a/level_1/fl_utf/c/private-utf.c b/level_1/fl_utf/c/private-utf.c index 11f6fe2..368add5 100644 --- a/level_1/fl_utf/c/private-utf.c +++ b/level_1/fl_utf/c/private-utf.c @@ -5,98 +5,10 @@ extern "C" { #endif -#if !defined(_di_fl_utf_string_append_) || !defined(_di_fl_utf_string_dynamic_append_) || !defined(_di_fl_utf_string_append_mash_) || !defined(_di_fl_utf_string_dynamic_mash_) - f_status_t private_fl_utf_string_append(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination) { - - if (destination->used + length > f_utf_string_t_size_max) return F_status_set_error(F_string_too_large); - - f_status_t status = F_none; - - const f_utf_string_length_t total = destination->used + length; - - if (total > destination->size) { - f_macro_utf_string_dynamic_t_resize(status, (*destination), total); - if (F_status_is_error(status)) return status; - } - - memcpy(destination->string + destination->used, source, length); - destination->used = total; - - return F_none; - } -#endif // !defined(_di_fl_utf_string_append_) || !defined(_di_fl_utf_string_dynamic_append_) || !defined(_di_fl_utf_string_append_mash_) || !defined(_di_fl_utf_string_dynamic_mash_) - -#if !defined(_di_fl_utf_string_append_nulless_) || !defined(_di_fl_utf_string_dynamic_append_nulless_) || !defined(_di_fl_utf_string_mash_nulless_) || !defined(_di_fl_utf_string_dynamic_mash_nulless_) - f_status_t private_fl_utf_string_append_nulless(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination) { - - if (destination->used + length > f_utf_string_t_size_max) return F_status_set_error(F_string_too_large); - - f_status_t status = F_none; - - f_utf_string_length_t first = 0; - - for (f_utf_string_length_t i = 0; i <= length; i++) { - - if (i == length) { - if (i > first) { - f_utf_string_length_t size = i - first; - - if (destination->used + size > f_utf_string_t_size_max) { - return F_status_set_error(F_string_too_large); - } - - f_utf_string_length_t total = destination->used + size; - - if (total > destination->size) { - f_macro_utf_string_dynamic_t_resize(status, (*destination), total); - if (F_status_is_error(status)) return status; - } - - memcpy(destination->string + destination->used, source + first, size); - destination->used = total; - } - - break; - } - - if (source[i] == f_utf_character_t_eos) { - if (i > 0) { - if (i > first) { - f_utf_string_length_t size = i - first; - - if (destination->used + size > f_utf_string_t_size_max) { - return F_status_set_error(F_string_too_large); - } - - f_utf_string_length_t total = destination->used + size; - - if (total > destination->size) { - f_macro_utf_string_dynamic_t_resize(status, (*destination), total); - if (F_status_is_error(status)) return status; - } - - memcpy(destination->string + destination->used, source + first, size); - destination->used = total; - } - } - - while (i + 1 < length && source[i + 1] == f_utf_character_t_eos) { - i++; - } // while - - first = i + 1; - continue; - } - } // for - - return F_none; - } -#endif // !defined(_di_fl_utf_string_append_nulless_) || !defined(_di_fl_utf_string_dynamic_append_nulless_) || !defined(_di_fl_utf_string_mash_nulless_) || !defined(_di_fl_utf_string_dynamic_mash_nulless_) - -#if !defined(_di_fl_utfl_string_compare_) || !defined(_di_fl_utfl_string_dynamic_compare_) || !defined(_di_fl_utfl_string_dynamic_partial_compare_) - f_status_t private_fl_utfl_string_compare(const f_utf_string_t string1, const f_utf_string_t string2, const f_utf_string_length_t offset1, const f_utf_string_length_t offset2, const f_utf_string_length_t stop1, const f_utf_string_length_t stop2) { - f_utf_string_length_t i1 = offset1; - f_utf_string_length_t i2 = offset2; +#if !defined(_di_fl_utf_string_compare_) || !defined(_di_fl_utf_string_dynamic_compare_) || !defined(_di_fl_utf_string_dynamic_partial_compare_) + f_status_t private_fl_utf_string_compare(const f_utf_string_t string1, const f_utf_string_t string2, const f_string_length_t offset1, const f_string_length_t offset2, const f_string_length_t stop1, const f_string_length_t stop2) { + f_string_length_t i1 = offset1; + f_string_length_t i2 = offset2; for (; i1 < stop1 && i2 < stop2; i1++, i2++) { @@ -122,12 +34,12 @@ extern "C" { return F_equal_to; } -#endif // !defined(_di_fl_utfl_string_compare_) || !defined(_di_fl_utfl_string_dynamic_compare_) || !defined(_di_fl_utfl_string_dynamic_partial_compare_) +#endif // !defined(_di_fl_utf_string_compare_) || !defined(_di_fl_utf_string_dynamic_compare_) || !defined(_di_fl_utf_string_dynamic_partial_compare_) -#if !defined(_di_fl_utfl_string_compare_trim_) || !defined(_di_fl_utfl_string_dynamic_compare_trim_) || !defined(_di_fl_utfl_string_dynamic_partial_compare_trim_) - f_status_t private_fl_utfl_string_compare_trim(const f_utf_string_t string1, const f_utf_string_t string2, const f_utf_string_length_t offset1, const f_utf_string_length_t offset2, const f_utf_string_length_t stop1, const f_utf_string_length_t stop2) { - f_utf_string_length_t i1 = offset1; - f_utf_string_length_t i2 = offset2; +#if !defined(_di_fl_utf_string_compare_trim_) || !defined(_di_fl_utf_string_dynamic_compare_trim_) || !defined(_di_fl_utf_string_dynamic_partial_compare_trim_) + f_status_t private_fl_utf_string_compare_trim(const f_utf_string_t string1, const f_utf_string_t string2, const f_string_length_t offset1, const f_string_length_t offset2, const f_string_length_t stop1, const f_string_length_t stop2) { + f_string_length_t i1 = offset1; + f_string_length_t i2 = offset2; f_status_t status = F_none; @@ -169,16 +81,16 @@ extern "C" { if (status == F_false) break; } // for - f_utf_string_length_t last1 = i1; - f_utf_string_length_t last2 = i2; + f_string_length_t last1 = i1; + f_string_length_t last2 = i2; { // size1 and size2 are to represent to total number of characters after trim. - f_utf_string_length_t size1 = 0; - f_utf_string_length_t size2 = 0; + f_string_length_t size1 = 0; + f_string_length_t size2 = 0; // determine where the last non-whitespace is in string1. - for (f_utf_string_length_t j = i1; j < stop1; j++) { + for (f_string_length_t j = i1; j < stop1; j++) { // skip past NULL in string1. while (j < stop1 && !string1[j]) j++; @@ -200,7 +112,7 @@ extern "C" { } // for // determine where the last non-whitespace is in string2. - for (f_utf_string_length_t j = i2; j < stop2; j++) { + for (f_string_length_t j = i2; j < stop2; j++) { // skip past NULL in string2. while (j < stop2 && !string2[j]) j++; @@ -248,116 +160,10 @@ extern "C" { return F_equal_to; } -#endif // !defined(_di_fl_utfl_string_compare_trim_) || !defined(_di_fl_utfl_string_dynamic_compare_trim_) || !defined(_di_fl_utfl_string_dynamic_partial_compare_trim_) - -#if !defined(_di_fl_utf_string_prepend_) || !defined(_di_fl_utf_string_dynamic_prepend_) - f_status_t private_fl_utf_string_prepend(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination) { - - if (destination->used + length > f_utf_string_t_size_max) { - return F_status_set_error(F_string_too_large); - } - - f_status_t status = F_none; - - const f_utf_string_length_t total = destination->used + length; - - if (total > destination->size) { - f_macro_utf_string_dynamic_t_resize(status, (*destination), total); - if (F_status_is_error(status)) return status; - } - - if (destination->used > 0) { - memmove(destination->string + length, destination->string, destination->used); - memcpy(destination->string, source, length); - } - else { - memcpy(destination->string, source, length); - } - - destination->used = total; - return F_none; - } -#endif // !defined(_di_fl_utf_string_prepend_) || !defined(_di_fl_utf_string_dynamic_prepend_) - -#if !defined(_di_fl_utf_string_prepend_nulless_) || !defined(_di_fl_utf_string_dynamic_prepend_nulless_) - f_status_t private_fl_utf_string_prepend_nulless(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination) { - - if (destination->used + length > f_utf_string_t_size_max) { - return F_status_set_error(F_string_too_large); - } - - f_status_t status = F_none; - - f_utf_string_length_t first = 0; - f_utf_string_length_t offset = 0; - - for (f_utf_string_length_t i = 0; i <= length; i++) { - - if (i == length) { - if (i > first) { - const f_utf_string_length_t size = i - first; - - if (destination->used + size > f_utf_string_t_size_max) { - return F_status_set_error(F_string_too_large); - } - - const f_utf_string_length_t total = destination->used + size; - - if (total > destination->size) { - f_macro_utf_string_dynamic_t_resize(status, (*destination), total); - if (F_status_is_error(status)) return status; - } - - memmove(destination->string + offset + size, destination->string + offset, destination->used - offset); - memcpy(destination->string + offset, source + first, size); - - destination->used = total; - offset += size; - } - - break; - } - - if (source[i] == f_utf_character_t_eos) { - if (i > 0) { - if (i > first) { - const f_utf_string_length_t size = i - first; - - if (destination->used + size > f_utf_string_t_size_max) { - return F_status_set_error(F_string_too_large); - } - - const f_utf_string_length_t total = destination->used + size; - - if (total > destination->size) { - f_macro_utf_string_dynamic_t_resize(status, (*destination), total); - - if (F_status_is_error(status)) return status; - } - - memmove(destination->string + offset + size, destination->string + offset, destination->used - offset); - memcpy(destination->string + offset, source + first, size); - - destination->used = total; - offset += size; - } - } - - while (i + 1 < length && source[i + 1] == f_utf_character_t_eos) { - i++; - } // while - - first = i + 1; - continue; - } - } // for - - return F_none; - } -#endif // !defined(_di_fl_utf_string_prepend_nulless_) || !defined(_di_fl_utf_string_dynamic_prepend_nulless_) +#endif // !defined(_di_fl_utf_string_compare_trim_) || !defined(_di_fl_utf_string_dynamic_compare_trim_) || !defined(_di_fl_utf_string_dynamic_partial_compare_trim_) -#if !defined(_di_fl_utfl_string_rip_) || !defined(_di_fl_utfl_string_dynamic_rip_) || !defined(_di_fl_utfl_string_rip_nulless_) || !defined(_di_fl_utfl_string_dynamic_rip_nulless_) - f_status_t private_fl_utfl_string_rip_find_range(const f_utf_string_t source, f_utf_string_length_t *start, f_utf_string_length_t *stop) { +#if !defined(_di_fl_utf_string_rip_) || !defined(_di_fl_utf_string_dynamic_rip_) || !defined(_di_fl_utf_string_rip_nulless_) || !defined(_di_fl_utf_string_dynamic_rip_nulless_) + f_status_t private_fl_utf_string_rip_find_range(const f_utf_string_t source, f_string_length_t *start, f_string_length_t *stop) { f_status_t status = F_none; @@ -418,7 +224,7 @@ extern "C" { return F_none; } -#endif // !defined(_di_fl_utfl_string_rip_) || !defined(_di_fl_utfl_string_dynamic_rip_) || !defined(_di_fl_utfl_string_rip_nulless_) || !defined(_di_fl_utfl_string_dynamic_rip_nulless_) +#endif // !defined(_di_fl_utf_string_rip_) || !defined(_di_fl_utf_string_dynamic_rip_) || !defined(_di_fl_utf_string_rip_nulless_) || !defined(_di_fl_utf_string_dynamic_rip_nulless_) #ifdef __cplusplus } // extern "C" diff --git a/level_1/fl_utf/c/private-utf.h b/level_1/fl_utf/c/private-utf.h index 5877c85..7b1a06e 100644 --- a/level_1/fl_utf/c/private-utf.h +++ b/level_1/fl_utf/c/private-utf.h @@ -16,62 +16,6 @@ extern "C" { #endif /** - * Private implementation of fl_utf_string_append(). - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source string to append. - * @param length - * Length of source to append. - * @param destination - * The destination string the source and glue are appended onto. - * - * @return - * F_none on success. - * F_data_not if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * @see fl_utf_string_append() - * @see fl_utf_string_mash() - * @see fl_utf_string_dynamic_append() - * @see fl_utf_string_dynamic_mash() - */ -#if !defined(_di_fl_utf_string_append_) || !defined(_di_fl_utf_string_dynamic_append_) || !defined(_di_fl_utf_string_append_mash_) || !defined(_di_fl_utf_string_dynamic_mash_) - extern f_status_t private_fl_utf_string_append(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; -#endif // !defined(_di_fl_utf_string_append_) || !defined(_di_fl_utf_string_dynamic_append_) || !defined(_di_fl_utf_string_append_mash_) || !defined(_di_fl_utf_string_dynamic_mash_) - -/** - * Private implementation of fl_utf_string_append_nulless(). - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source string to append. - * @param length - * Length of source to append. - * @param destination - * The destination string the source and glue are appended onto. - * - * @return - * F_none on success. - * F_data_not if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * @see fl_utf_string_append_nulless() - * @see fl_utf_string_mash_nulless() - * @see fl_utf_string_dynamic_append_nulless() - * @see fl_utf_string_dynamic_mash_nulless() - */ -#if !defined(_di_fl_utf_string_append_nulless_) || !defined(_di_fl_utf_string_dynamic_append_nulless_) || !defined(_di_fl_utf_string_mash_nulless_) || !defined(_di_fl_utf_string_dynamic_mash_nulless_) - extern f_status_t private_fl_utf_string_append_nulless(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; -#endif // !defined(_di_fl_utf_string_append_nulless_) || !defined(_di_fl_utf_string_dynamic_append_nulless_) || !defined(_di_fl_utf_string_mash_nulless_) || !defined(_di_fl_utf_string_dynamic_mash_nulless_) - -/** * Private implementation of fl_utfl_string_compare(). * * Intended to be shared to each of the different implementation variations. @@ -94,16 +38,16 @@ extern "C" { * F_equal_to_not when both strings do not equal. * F_parameter (with error bit) if a parameter is invalid. * - * @see fl_utfl_string_compare() - * @see fl_utfl_string_dynamic_compare() - * @see fl_utfl_string_dynamic_partial_compare() + * @see fl_utf_string_compare() + * @see fl_utf_string_dynamic_compare() + * @see fl_utf_string_dynamic_partial_compare() */ #if !defined(_di_fl_utfl_string_compare_) || !defined(_di_fl_utfl_string_dynamic_compare_) || !defined(_di_fl_utfl_string_dynamic_partial_compare_) - extern f_status_t private_fl_utfl_string_compare(const f_utf_string_t string1, const f_utf_string_t string2, const f_utf_string_length_t offset1, const f_utf_string_length_t offset2, const f_utf_string_length_t stop1, const f_utf_string_length_t stop2) f_gcc_attribute_visibility_internal; + extern f_status_t private_fl_utf_string_compare(const f_utf_string_t string1, const f_utf_string_t string2, const f_string_length_t offset1, const f_string_length_t offset2, const f_string_length_t stop1, const f_string_length_t stop2) f_gcc_attribute_visibility_internal; #endif // !defined(_di_fl_utfl_string_compare_) || !defined(_di_fl_utfl_string_dynamic_compare_) || !defined(_di_fl_utfl_string_dynamic_partial_compare_) /** - * Private implementation of fl_utfl_string_compare_trim(). + * Private implementation of fl_utf_string_compare_trim(). * * Intended to be shared to each of the different implementation variations. * @@ -125,66 +69,16 @@ extern "C" { * F_equal_to_not when both strings do not equal. * F_parameter (with error bit) if a parameter is invalid. * - * @see fl_utfl_string_compare_trim() - * @see fl_utfl_string_dynamic_compare_trim() - * @see fl_utfl_string_dynamic_partial_compare_trim() - */ -#if !defined(_di_fl_utfl_string_compare_trim_) || !defined(_di_fl_utfl_string_dynamic_compare_trim_) || !defined(_di_fl_utfl_string_dynamic_partial_compare_trim_) - extern f_status_t private_fl_utfl_string_compare_trim(const f_utf_string_t string1, const f_utf_string_t string2, const f_utf_string_length_t offset1, const f_utf_string_length_t offset2, const f_utf_string_length_t stop1, const f_utf_string_length_t stop2) f_gcc_attribute_visibility_internal; -#endif // !defined(_di_fl_utfl_string_compare_trim_) || !defined(_di_fl_utfl_string_dynamic_compare_trim_) || !defined(_di_fl_utfl_string_dynamic_partial_compare_trim_) - -/** - * Private implementation of fl_utf_string_prepend(). - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source string to prepend. - * @param length - * Length of source to append. - * @param destination - * The destination string the source and glue are prepended onto. - * - * @return - * F_none on success. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * @see fl_utf_string_prepend() - * @see fl_utf_string_dynamic_prepend() - */ -#if !defined(_di_fl_utf_string_prepend_) || !defined(_di_fl_utf_string_dynamic_prepend_) || !defined(_di_fl_utf_string_append_mish_) || !defined(_di_fl_utf_string_dynamic_mish_) - extern f_status_t private_fl_utf_string_prepend(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; -#endif // !defined(_di_fl_utf_string_prepend_) || !defined(_di_fl_utf_string_dynamic_prepend_) || !defined(_di_fl_utf_string_append_mish_) || !defined(_di_fl_utf_string_dynamic_mish_) - -/** - * Private implementation of fl_utf_string_prepend_nulless(). - * - * Intended to be shared to each of the different implementation variations. - * - * @param source - * The source string to prepend. - * @param length - * Length of source to append. - * @param destination - * The destination string the source and glue are prepended onto. - * - * @return - * F_none on success. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - * - * @see fl_utf_string_prepend_nulless() - * @see fl_utf_string_dynamic_prepend_nulless() + * @see fl_utf_string_compare_trim() + * @see fl_utf_string_dynamic_compare_trim() + * @see fl_utf_string_dynamic_partial_compare_trim() */ -#if !defined(_di_fl_utf_string_prepend_nulless_) || !defined(_di_fl_utf_string_dynamic_prepend_nulless_) || !defined(_di_fl_utf_string_append_mish_) || !defined(_di_fl_utf_string_dynamic_mish_) - extern f_status_t private_fl_utf_string_prepend_nulless(const f_utf_string_t source, f_utf_string_length_t length, f_utf_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; -#endif // !defined(_di_fl_utf_string_prepend_nulless_) || !defined(_di_fl_utf_string_dynamic_prepend_nulless_) || !defined(_di_fl_utf_string_append_mish_) || !defined(_di_fl_utf_string_dynamic_mish_) +#if !defined(_di_fl_utf_string_compare_trim_) || !defined(_di_fl_utf_string_dynamic_compare_trim_) || !defined(_di_fl_utf_string_dynamic_partial_compare_trim_) + extern f_status_t private_fl_utf_string_compare_trim(const f_utf_string_t string1, const f_utf_string_t string2, const f_string_length_t offset1, const f_string_length_t offset2, const f_string_length_t stop1, const f_string_length_t stop2) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_fl_utf_string_compare_trim_) || !defined(_di_fl_utf_string_dynamic_compare_trim_) || !defined(_di_fl_utf_string_dynamic_partial_compare_trim_) /** - * Private implementation of fl_utfl_string_rip(), but only the part for finding the start/stop range. + * Private implementation of fl_utf_string_rip(), but only the part for finding the start/stop range. * * Intended to be shared to each of the different implementation variations. * @@ -203,12 +97,12 @@ extern "C" { * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. * - * @see fl_utfl_string_dynamic_rip() - * @see fl_utfl_string_rip() + * @see fl_utf_string_dynamic_rip() + * @see fl_utf_string_rip() */ -#if !defined(_di_fl_utfl_string_rip_) || !defined(_di_fl_utfl_string_dynamic_rip_) || !defined(_di_fl_utfl_string_rip_nulless_) || !defined(_di_fl_utfl_string_dynamic_rip_nulless_) - extern f_status_t private_fl_utfl_string_rip_find_range(const f_utf_string_t source, f_utf_string_length_t *start, f_utf_string_length_t *stop) f_gcc_attribute_visibility_internal; -#endif // !defined(_di_fl_utfl_string_rip_) || !defined(_di_fl_utfl_string_dynamic_rip_) || !defined(_di_fl_utfl_string_rip_nulless_) || !defined(_di_fl_utfl_string_dynamic_rip_nulless_) +#if !defined(_di_fl_utf_string_rip_) || !defined(_di_fl_utf_string_dynamic_rip_) || !defined(_di_fl_utf_string_rip_nulless_) || !defined(_di_fl_utf_string_dynamic_rip_nulless_) + extern f_status_t private_fl_utf_string_rip_find_range(const f_utf_string_t source, f_string_length_t *start, f_string_length_t *stop) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_fl_utf_string_rip_) || !defined(_di_fl_utf_string_dynamic_rip_) || !defined(_di_fl_utf_string_rip_nulless_) || !defined(_di_fl_utf_string_dynamic_rip_nulless_) #ifdef __cplusplus } // extern "C" diff --git a/level_1/fl_utf/c/utf.c b/level_1/fl_utf/c/utf.c index 8e8d425..4a77e5a 100644 --- a/level_1/fl_utf/c/utf.c +++ b/level_1/fl_utf/c/utf.c @@ -5,728 +5,54 @@ extern "C" { #endif -#ifndef _di_fl_utf_string_append_ - f_status_t fl_utf_string_append(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_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_ - - if (!length) return F_data_not_eos; - - return private_fl_utf_string_append(source, length, destination); - } -#endif // _di_fl_utf_string_append_ - -#ifndef _di_fl_utf_string_append_assure_ - f_status_t fl_utf_string_append_assure(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_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_ - - if (!length) return F_data_not_eos; - - if (destination->used < length) { - return private_fl_utf_string_append(source, length, destination); - } - - f_utf_string_length_t i = 1; - f_utf_string_length_t j = 1; - - while (i <= length && j <= destination->used) { - - if (source[length - i] == f_utf_character_t_eos) { - i++; - continue; - } - - if (destination->string[destination->used - j] == f_utf_character_t_eos) { - j++; - continue; - } - - if (source[length - i] != destination->string[destination->used - j]) { - return private_fl_utf_string_append(source, length, destination); - } - - i++; - j++; - } // while - - return F_none; - } -#endif // _di_fl_utf_string_append_assure_ - -#ifndef _di_fl_utf_string_append_assure_nulless_ - f_status_t fl_utf_string_append_assure_nulless(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_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_ - - if (!length) return F_data_not_eos; - - if (destination->used < length) { - return private_fl_utf_string_append_nulless(source, length, destination); - } - - f_utf_string_length_t i = 1; - f_utf_string_length_t j = 1; - - while (i <= length && j <= destination->used) { - - if (source[length - i] == f_utf_character_t_eos) { - i++; - continue; - } - - if (destination->string[destination->used - j] == f_utf_character_t_eos) { - j++; - continue; - } - - if (source[length - i] != destination->string[destination->used - j]) { - return private_fl_utf_string_append_nulless(source, length, destination); - } - - i++; - j++; - } // while - - return F_none; - } -#endif // _di_fl_utf_string_append_assure_nulless_ - -#ifndef _di_fl_utf_string_append_nulless_ - f_status_t fl_utf_string_append_nulless(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_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_ - - if (!length) return F_data_not_eos; - - return private_fl_utf_string_append_nulless(source, length, destination); - } -#endif // _di_fl_utf_string_append_nulless_ - -#ifndef _di_fl_utfl_string_compare_ - f_status_t fl_utfl_string_compare(const f_utf_string_t string1, const f_utf_string_t string2, const f_utf_string_length_t length1, const f_utf_string_length_t length2) { - return private_fl_utfl_string_compare(string1, string2, 0, 0, length1, length2); - } -#endif // _di_fl_utfl_string_compare_ - -#ifndef _di_fl_utfl_string_compare_trim_ - f_status_t fl_utfl_string_compare_trim(const f_utf_string_t string1, const f_utf_string_t string2, const f_utf_string_length_t length1, const f_utf_string_length_t length2) { - return private_fl_utfl_string_compare_trim(string1, string2, 0, 0, length1, length2); - } -#endif // _di_fl_utfl_string_compare_trim_ - -#ifndef _di_fl_utf_string_dynamic_append_ - f_status_t fl_utf_string_dynamic_append(const f_utf_string_static_t source, f_utf_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_ - - if (!source.used) return F_data_not_eos; - - return private_fl_utf_string_append(source.string, source.used, destination); - } -#endif // _di_fl_utf_string_dynamic_append_ - -#ifndef _di_fl_utf_string_dynamic_append_assure_ - f_status_t fl_utf_string_dynamic_append_assure(const f_utf_string_static_t source, f_utf_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_ - - if (!source.used) return F_data_not_eos; - - if (destination->used < source.used) { - return private_fl_utf_string_append(source.string, source.used, destination); - } - - f_utf_string_length_t i = 1; - f_utf_string_length_t j = 1; - - while (i <= source.used && j <= destination->used) { - - if (source.string[source.used - i] == f_utf_character_t_eos) { - i++; - continue; - } - - if (destination->string[destination->used - j] == f_utf_character_t_eos) { - j++; - continue; - } - - if (source.string[source.used - i] != destination->string[destination->used - j]) { - return private_fl_utf_string_append(source.string, source.used, destination); - } - - i++; - j++; - } // while - - return F_none; - } -#endif // _di_fl_utf_string_dynamic_append_assure_ - -#ifndef _di_fl_utf_string_dynamic_append_assure_nulless_ - f_status_t fl_utf_string_dynamic_append_assure_nulless(const f_utf_string_static_t source, f_utf_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_ - - if (!source.used) return F_data_not_eos; - - if (destination->used < source.used) { - return private_fl_utf_string_append_nulless(source.string, source.used, destination); - } - - f_utf_string_length_t i = 1; - f_utf_string_length_t j = 1; - - while (i <= source.used && j <= destination->used) { - - if (source.string[source.used - i] == f_utf_character_t_eos) { - i++; - continue; - } - - if (destination->string[destination->used - j] == f_utf_character_t_eos) { - j++; - continue; - } - - if (source.string[source.used - i] != destination->string[destination->used - j]) { - return private_fl_utf_string_append_nulless(source.string, source.used, destination); - } - - i++; - j++; - } // while - - return F_none; - } -#endif // _di_fl_utf_string_dynamic_append_assure_nulless_ - -#ifndef _di_fl_utf_string_dynamic_append_nulless_ - f_status_t fl_utf_string_dynamic_append_nulless(const f_utf_string_static_t source, f_utf_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_ - - if (!source.used) return F_data_not_eos; - - return private_fl_utf_string_append_nulless(source.string, source.used, destination); - } -#endif // _di_fl_utf_string_dynamic_append_nulless_ - -#ifndef _di_fl_utfl_string_dynamic_compare_ - f_status_t fl_utfl_string_dynamic_compare(const f_utf_string_static_t string1, const f_utf_string_static_t string2) { - return private_fl_utfl_string_compare(string1.string, string2.string, 0, 0, string1.used, string2.used); - } -#endif // _di_fl_utfl_string_dynamic_compare_ - -#ifndef _di_f_utfl_string_dynamic_compare_trim_ - f_status_t f_utfl_string_dynamic_compare_trim(const f_utf_string_static_t string1, const f_utf_string_static_t string2) { - return private_fl_utfl_string_compare_trim(string1.string, string2.string, 0, 0, string1.used, string2.used); - } -#endif // _di_f_utfl_string_dynamic_compare_trim_ - -#ifndef _di_fl_utf_string_dynamic_mash_ - f_status_t fl_utf_string_dynamic_mash(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, f_utf_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_ - - if (!source.used) return F_data_not_eos; - - if (glue_length > 0 && destination->used > 0) { - const f_status_t status = private_fl_utf_string_append(glue, glue_length, destination); - if (F_status_is_error(status)) return status; - } - - return private_fl_utf_string_append(source.string, source.used, destination); - } -#endif // _di_fl_utf_string_dynamic_mash_ - -#ifndef _di_fl_utf_string_dynamic_mash_nulless_ - f_status_t fl_utf_string_dynamic_mash_nulless(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, f_utf_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_ - - if (!source.used) return F_data_not_eos; - - if (glue_length > 0 && destination->used > 0) { - const f_status_t status = private_fl_utf_string_append_nulless(glue, glue_length, destination); - if (F_status_is_error(status)) return status; - } - - return private_fl_utf_string_append_nulless(source.string, source.used, destination); - } -#endif // _di_fl_utf_string_dynamic_mash_nulless_ - -#ifndef _di_fl_utf_string_dynamic_mish_ - f_status_t fl_utf_string_dynamic_mish(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, f_utf_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_ - - if (!source.used) return F_data_not_eos; - - if (glue_length > 0 && destination->used > 0) { - const f_status_t status = private_fl_utf_string_prepend(glue, glue_length, destination); - if (F_status_is_error(status)) return status; - } - - return private_fl_utf_string_prepend(source.string, source.used, destination); - } -#endif // _di_fl_utf_string_dynamic_mish_ - -#ifndef _di_fl_utf_string_dynamic_mish_nulless_ - f_status_t fl_utf_string_dynamic_mish_nulless(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, f_utf_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_ - - if (!source.used) return F_data_not_eos; - - if (glue_length > 0 && destination->used > 0) { - const f_status_t status = private_fl_utf_string_prepend_nulless(glue, glue_length, destination); - if (F_status_is_error(status)) return status; - } - - return private_fl_utf_string_prepend_nulless(source.string, source.used, destination); - } -#endif // _di_fl_utf_string_dynamic_mish_nulless_ - -#ifndef _di_fl_utf_string_dynamic_partial_append_ - f_status_t fl_utf_string_dynamic_partial_append(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { - #ifndef _di_level_1_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!source.used) return F_data_not_eos; - if (range.start > range.stop) return F_data_not_stop; - - return private_fl_utf_string_append(source.string + range.start, (range.stop - range.start) + 1, destination); - } -#endif // _di_fl_utf_string_dynamic_partial_append_ - -#ifndef _di_fl_utf_string_dynamic_partial_append_assure_ - f_status_t fl_utf_string_dynamic_partial_append_assure(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { - #ifndef _di_level_1_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!source.used) return F_data_not_eos; - if (range.start > range.stop) return F_data_not_stop; - - const f_utf_string_length_t length = (range.stop - range.start) + 1; - - if (destination->used < length) { - return private_fl_utf_string_append(source.string + range.start, length, destination); - } - - f_utf_string_length_t i = 1; - f_utf_string_length_t j = 1; - - while (i <= length && j <= destination->used) { - - if (source.string[range.stop - i] == f_utf_character_t_eos) { - i++; - continue; - } - - if (destination->string[destination->used - j] == f_utf_character_t_eos) { - j++; - continue; - } - - if (source.string[range.stop - i] != destination->string[destination->used - j]) { - return private_fl_utf_string_append(source.string + range.start, length, destination); - } - - i++; - j++; - } // while - } -#endif // _di_fl_utf_string_dynamic_partial_append_assure_ - -#ifndef _di_fl_utf_string_dynamic_partial_append_assure_nulless_ - f_status_t fl_utf_string_dynamic_partial_append_assure_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { - #ifndef _di_level_1_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!source.used) return F_data_not_eos; - if (range.start > range.stop) return F_data_not_stop; - - const f_utf_string_length_t length = (range.stop - range.start) + 1; - - if (destination->used < length) { - return private_fl_utf_string_append_nulless(source.string + range.start, length, destination); - } - - f_utf_string_length_t i = 1; - f_utf_string_length_t j = 1; - - while (i <= length && j <= destination->used) { - - if (source.string[range.stop - i] == f_utf_character_t_eos) { - i++; - continue; - } - - if (destination->string[destination->used - j] == f_utf_character_t_eos) { - j++; - continue; - } - - if (source.string[range.stop - i] != destination->string[destination->used - j]) { - return private_fl_utf_string_append_nulless(source.string + range.start, length, destination); - } - - i++; - j++; - } // while - } -#endif // _di_fl_utf_string_dynamic_partial_append_assure_nulless_ - -#ifndef _di_fl_utf_string_dynamic_partial_append_nulless_ - f_status_t fl_utf_string_dynamic_partial_append_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { - #ifndef _di_level_1_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!source.used) return F_data_not_eos; - if (range.start > range.stop) return F_data_not_stop; - - return private_fl_utf_string_append_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); - } -#endif // _di_fl_utf_string_dynamic_partial_append_nulless_ - -#ifndef _di_fl_utfl_string_dynamic_partial_compare_ - f_status_t fl_utfl_string_dynamic_partial_compare(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_utf_string_range_t range1, const f_utf_string_range_t range2) { - #ifndef _di_level_1_parameter_checking_ - if (string1.used <= range1.stop) return F_status_set_error(F_parameter); - if (string2.used <= range2.stop) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - return private_fl_utfl_string_compare(string1.string, string2.string, range1.start, range2.start, range1.stop + 1, range2.stop + 1); - } -#endif // _di_fl_utfl_string_dynamic_partial_compare_ - -#ifndef _di_fl_utfl_string_dynamic_partial_compare_trim_ - f_status_t fl_utfl_string_dynamic_partial_comparetrim(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_utf_string_range_t range1, const f_utf_string_range_t range2) { - #ifndef _di_level_1_parameter_checking_ - if (string1.used <= range1.stop) return F_status_set_error(F_parameter); - if (string2.used <= range2.stop) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - return private_fl_utfl_string_compare_trim(string1.string, string2.string, range1.start, range2.start, range1.stop + 1, range2.stop + 1); - } -#endif // _di_fl_utfl_string_dynamic_partial_compare_trim_ - -#ifndef _di_fl_utf_string_dynamic_partial_mash_ - f_status_t fl_utf_string_dynamic_partial_mash(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { - #ifndef _di_level_1_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!source.used) return F_data_not_eos; - if (range.start > range.stop) return F_data_not_stop; - - if (glue_length > 0 && destination->used > 0) { - f_status_t status = private_fl_utf_string_append(glue, glue_length, destination); - if (F_status_is_error(status)) return status; - } - - return private_fl_utf_string_append(source.string + range.start, (range.stop - range.start) + 1, destination); - } -#endif // _di_fl_utf_string_dynamic_partial_mash_ - -#ifndef _di_fl_utf_string_dynamic_partial_mash_nulless_ - f_status_t fl_utf_string_dynamic_partial_mash_nulless(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { - #ifndef _di_level_1_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!source.used) return F_data_not_eos; - if (range.start > range.stop) return F_data_not_stop; - - if (glue_length > 0 && destination->used > 0) { - f_status_t status = private_fl_utf_string_append_nulless(glue, glue_length, destination); - if (F_status_is_error(status)) return status; - } - - return private_fl_utf_string_append_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); - } -#endif // _di_fl_utf_string_dynamic_partial_mash_nulless_ - -#ifndef _di_fl_utf_string_dynamic_partial_mish_ - f_status_t fl_utf_string_dynamic_partial_mish(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { - #ifndef _di_level_1_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!source.used) return F_data_not_eos; - if (range.start > range.stop) return F_data_not_stop; - - if (glue_length > 0 && destination->used > 0) { - f_status_t status = private_fl_utf_string_prepend(glue, glue_length, destination); - if (F_status_is_error(status)) return status; - } - - return private_fl_utf_string_prepend(source.string + range.start, (range.stop - range.start) + 1, destination); - } -#endif // _di_fl_utf_string_dynamic_partial_mish_ - -#ifndef _di_fl_utf_string_dynamic_partial_mish_nulless_ - f_status_t fl_utf_string_dynamic_partial_mish_nulless(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { - #ifndef _di_level_1_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!source.used) return F_data_not_eos; - if (range.start > range.stop) return F_data_not_stop; - - if (glue_length > 0 && destination->used > 0) { - f_status_t status = private_fl_utf_string_prepend_nulless(glue, glue_length, destination); - if (F_status_is_error(status)) return status; - } - - return private_fl_utf_string_prepend_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); - } -#endif // _di_fl_utf_string_dynamic_partial_mish_nulless_ - -#ifndef _di_fl_utf_string_dynamic_partial_prepend_ - f_status_t fl_utf_string_dynamic_partial_prepend(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { - #ifndef _di_level_1_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!source.used) return F_data_not_eos; - if (range.start > range.stop) return F_data_not_stop; - - return private_fl_utf_string_prepend(source.string + range.start, (range.stop - range.start) + 1, destination); - } -#endif // _di_fl_utf_string_dynamic_partial_prepend_ - -#ifndef _di_fl_utf_string_dynamic_partial_prepend_assure_ - f_status_t fl_utf_string_dynamic_partial_prepend_assure(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { - #ifndef _di_level_1_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!source.used) return F_data_not_eos; - if (range.start > range.stop) return F_data_not_stop; - - const f_utf_string_length_t length = (range.stop - range.start) + 1; - - if (destination->used < length) { - return private_fl_utf_string_prepend(source.string + range.start, length, destination); - } - - f_utf_string_length_t i = 0; - f_utf_string_length_t j = 0; - - while (i < length && j < destination->used) { - - if (source.string[i + range.start] == f_utf_character_t_eos) { - i++; - continue; - } - - if (destination->string[j] == f_utf_character_t_eos) { - j++; - continue; - } - - if (source.string[i + range.start] != destination->string[i]) { - return private_fl_utf_string_prepend(source.string + range.start, length, destination); - } - - i++; - j++; - } // while - - return F_none; - } -#endif // _di_fl_utf_string_dynamic_partial_prepend_assure_ - -#ifndef _di_fl_utf_string_dynamic_partial_prepend_assure_nulless_ - f_status_t fl_utf_string_dynamic_partial_prepend_assure_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { - #ifndef _di_level_1_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!source.used) return F_data_not_eos; - if (range.start > range.stop) return F_data_not_stop; - - const f_utf_string_length_t length = (range.stop - range.start) + 1; - - if (destination->used < length) { - return private_fl_utf_string_prepend_nulless(source.string + range.start, length, destination); - } - - f_utf_string_length_t i = 0; - f_utf_string_length_t j = 0; - - while (i < length && j < destination->used) { - - if (source.string[i + range.start] == f_utf_character_t_eos) { - i++; - continue; - } - - if (destination->string[j] == f_utf_character_t_eos) { - j++; - continue; - } - - if (source.string[i + range.start] != destination->string[i]) { - return private_fl_utf_string_prepend_nulless(source.string + range.start, length, destination); - } - - i++; - j++; - } // while - - return F_none; - } -#endif // _di_fl_utf_string_dynamic_partial_prepend_assure_nulless_ - -#ifndef _di_fl_utf_string_dynamic_partial_prepend_nulless_ - f_status_t fl_utf_string_dynamic_partial_prepend_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { - #ifndef _di_level_1_parameter_checking_ - if (source.used <= range.stop) return F_status_set_error(F_parameter); - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!source.used) return F_data_not_eos; - if (range.start > range.stop) return F_data_not_stop; - - return private_fl_utf_string_prepend_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); - } -#endif // _di_fl_utf_string_dynamic_partial_prepend_nulless_ - -#ifndef _di_fl_utf_string_dynamic_prepend_ - f_status_t fl_utf_string_dynamic_prepend(const f_utf_string_static_t source, f_utf_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_ - - if (!source.used) return F_data_not_eos; - - return private_fl_utf_string_prepend(source.string, source.used, destination); - } -#endif // _di_fl_utf_string_dynamic_prepend_ - -#ifndef _di_fl_utf_string_dynamic_prepend_assure_ - f_status_t fl_utf_string_dynamic_prepend_assure(const f_utf_string_static_t source, f_utf_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_ - - if (!source.used) return F_data_not_eos; - - if (destination->used < source.used) { - return private_fl_utf_string_prepend(source.string, source.used, destination); - } - - f_utf_string_length_t i = 0; - f_utf_string_length_t j = 0; - - while (i < source.used && j < destination->used) { - - if (source.string[i] == f_utf_character_t_eos) { - i++; - continue; - } - - if (destination->string[j] == f_utf_character_t_eos) { - j++; - continue; - } - - if (source.string[i] != destination->string[i]) { - return private_fl_utf_string_prepend(source.string, source.used, destination); - } - - i++; - j++; - } // while - - return F_none; - } -#endif // _di_fl_utf_string_dynamic_prepend_assure_ - -#ifndef _di_fl_utf_string_dynamic_prepend_assure_nulless_ - f_status_t fl_utf_string_dynamic_prepend_assure_nulless(const f_utf_string_static_t source, f_utf_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_ - - if (!source.used) return F_data_not_eos; - - if (destination->used < source.used) { - return private_fl_utf_string_prepend_nulless(source.string, source.used, destination); - } - - f_utf_string_length_t i = 0; - f_utf_string_length_t j = 0; - - while (i < source.used && j < destination->used) { +#ifndef _di_fl_utf_string_compare_ + f_status_t fl_utf_string_compare(const f_utf_string_t string1, const f_utf_string_t string2, const f_string_length_t length1, const f_string_length_t length2) { + return private_fl_utf_string_compare(string1, string2, 0, 0, length1, length2); + } +#endif // _di_fl_utf_string_compare_ - if (source.string[i] == f_utf_character_t_eos) { - i++; - continue; - } +#ifndef _di_fl_utf_string_compare_trim_ + f_status_t fl_utf_string_compare_trim(const f_utf_string_t string1, const f_utf_string_t string2, const f_string_length_t length1, const f_string_length_t length2) { + return private_fl_utf_string_compare_trim(string1, string2, 0, 0, length1, length2); + } +#endif // _di_fl_utf_string_compare_trim_ - if (destination->string[j] == f_utf_character_t_eos) { - j++; - continue; - } +#ifndef _di_fl_utf_string_dynamic_compare_ + f_status_t fl_utf_string_dynamic_compare(const f_utf_string_static_t string1, const f_utf_string_static_t string2) { + return private_fl_utf_string_compare(string1.string, string2.string, 0, 0, string1.used, string2.used); + } +#endif // _di_fl_utf_string_dynamic_compare_ - if (source.string[i] != destination->string[i]) { - return private_fl_utf_string_prepend_nulless(source.string, source.used, destination); - } +#ifndef _di_fl_utf_string_dynamic_compare_trim_ + f_status_t fl_utf_string_dynamic_compare_trim(const f_utf_string_static_t string1, const f_utf_string_static_t string2) { + return private_fl_utf_string_compare_trim(string1.string, string2.string, 0, 0, string1.used, string2.used); + } +#endif // _di_fl_utf_string_dynamic_compare_trim_ - i++; - j++; - } // while +#ifndef _di_fl_utf_string_dynamic_partial_compare_ + f_status_t fl_utf_string_dynamic_partial_compare(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_utf_string_range_t range1, const f_utf_string_range_t range2) { + #ifndef _di_level_1_parameter_checking_ + if (string1.used <= range1.stop) return F_status_set_error(F_parameter); + if (string2.used <= range2.stop) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ - return F_none; + return private_fl_utf_string_compare(string1.string, string2.string, range1.start, range2.start, range1.stop + 1, range2.stop + 1); } -#endif // _di_fl_utf_string_dynamic_prepend_assure_nulless_ +#endif // _di_fl_utf_string_dynamic_partial_compare_ -#ifndef _di_fl_utf_string_dynamic_prepend_nulless_ - f_status_t fl_utf_string_dynamic_prepend_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { +#ifndef _di_fl_utf_string_dynamic_partial_compare_trim_ + f_status_t fl_utf_string_dynamic_partial_compare_trim(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_utf_string_range_t range1, const f_utf_string_range_t range2) { #ifndef _di_level_1_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); + if (string1.used <= range1.stop) return F_status_set_error(F_parameter); + if (string2.used <= range2.stop) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - if (!source.used) return F_data_not_eos; - - return private_fl_utf_string_prepend_nulless(source.string, source.used, destination); + return private_fl_utf_string_compare_trim(string1.string, string2.string, range1.start, range2.start, range1.stop + 1, range2.stop + 1); } -#endif // _di_fl_utf_string_dynamic_prepend_nulless_ +#endif // _di_fl_utf_string_dynamic_partial_compare_trim_ -#ifndef _di_fl_utfl_string_dynamic_rip_ - f_status_t fl_utfl_string_dynamic_rip(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { +#ifndef _di_fl_utf_string_dynamic_rip_ + f_status_t fl_utf_string_dynamic_rip(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (source.used <= range.start) return F_status_set_error(F_parameter); if (source.used <= range.stop) return F_status_set_error(F_parameter); @@ -736,12 +62,12 @@ extern "C" { if (!source.used) return F_data_not_eos; if (range.start > range.stop) return F_data_not_stop; - return private_fl_utf_string_append(source.string + range.start, (range.stop - range.start) + 1, destination); + return f_utf_string_append(source.string + range.start, (range.stop - range.start) + 1, destination); } -#endif // _di_fl_utfl_string_dynamic_rip_ +#endif // _di_fl_utf_string_dynamic_rip_ -#ifndef _di_fl_utfl_string_dynamic_rip_nulless_ - f_status_t fl_utfl_string_dynamic_rip_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { +#ifndef _di_fl_utf_string_dynamic_rip_nulless_ + f_status_t fl_utf_string_dynamic_rip_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (source.used <= range.start) return F_status_set_error(F_parameter); if (source.used <= range.stop) return F_status_set_error(F_parameter); @@ -751,49 +77,15 @@ extern "C" { if (!source.used) return F_data_not_eos; if (range.start > range.stop) return F_data_not_stop; - return private_fl_utf_string_append_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); - } -#endif // _di_fl_utfl_string_dynamic_rip_nulless_ - -#ifndef _di_fl_utfl_string_dynamic_seek_line_to_ - f_status_t fl_utfl_string_dynamic_seek_line_to(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t seek_to_this) { - #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); - if (buffer.used <= range->start) return F_status_set_error(F_parameter); - if (buffer.used <= range->stop) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!buffer.used) return F_data_not_eos; - if (range->start > range->stop) return F_data_not_stop; - - if (f_macro_utf_character_t_width_is(buffer.string[range->start]) == 1) { - return F_status_set_error(F_utf); - } - - while (buffer.string[range->start] != seek_to_this) { - - if (buffer.string[range->start] == f_utf_character_t_eol) { - return F_none_eol; - } - - range->start++; - - if (f_macro_utf_character_t_width_is(buffer.string[range->start]) == 1) return F_status_set_error(F_utf); - - if (range->start >= buffer.used) return F_none_eos; - if (range->start > range->stop) return F_none_stop; - } // while - - return F_none; + return f_utf_string_append_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); } -#endif // _di_fl_utfl_string_dynamic_seek_line_to_ +#endif // _di_fl_utf_string_dynamic_rip_nulless_ -#ifndef _di_fl_utfl_string_dynamic_seek_line_to_char_ - f_status_t fl_utfl_string_dynamic_seek_line_to_char(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const int8_t seek_to_this) { +#ifndef _di_fl_utf_string_dynamic_seek_line_to_char_ + f_status_t fl_utf_string_dynamic_seek_line_to_char(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const int8_t seek_to_this) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (buffer.used <= range->start) return F_status_set_error(F_parameter); - if (buffer.used <= range->stop) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ if (!buffer.used) return F_data_not_eos; @@ -823,14 +115,13 @@ extern "C" { return F_none; } -#endif // _di_fl_utfl_string_dynamic_seek_line_to_character_ +#endif // _di_fl_utf_string_dynamic_seek_line_to_char_ -#ifndef _di_fl_utfl_string_dynamic_seek_line_until_graph_ - f_status_t fl_utfl_string_dynamic_seek_line_until_graph(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t placeholder) { +#ifndef _di_fl_utf_string_dynamic_seek_line_until_graph_ + f_status_t fl_utf_string_dynamic_seek_line_until_graph(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t placeholder) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (buffer.used <= range->start) return F_status_set_error(F_parameter); - if (buffer.used <= range->stop) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ if (!buffer.used) return F_data_not_eos; @@ -861,14 +152,13 @@ extern "C" { return F_none; } -#endif // _di_fl_utfl_string_dynamic_seek_line_until_graph_ +#endif // _di_fl_utf_string_dynamic_seek_line_until_graph_ -#ifndef _di_fl_utfl_string_dynamic_seek_line_until_non_graph_ - f_status_t fl_utfl_string_dynamic_seek_line_until_non_graph(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t placeholder) { +#ifndef _di_fl_utf_string_dynamic_seek_line_until_graph_non_ + f_status_t fl_utf_string_dynamic_seek_line_until_graph_non(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t placeholder) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (buffer.used <= range->start) return F_status_set_error(F_parameter); - if (buffer.used <= range->stop) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ if (!buffer.used) return F_data_not_eos; @@ -899,44 +189,13 @@ extern "C" { return F_none; } -#endif // _di_fl_utfl_string_dynamic_seek_line_until_non_graph_ - -#ifndef _di_fl_utfl_string_dynamic_seek_to_ - f_status_t fl_utfl_string_dynamic_seek_to(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t seek_to_this) { - #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); - if (buffer.used <= range->start) return F_status_set_error(F_parameter); - if (buffer.used <= range->stop) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (!buffer.used) return F_data_not_eos; - if (range->start > range->stop) return F_data_not_stop; - - if (f_macro_utf_character_t_width_is(buffer.string[range->start]) == 1) { - return F_status_set_error(F_utf); - } - - while (buffer.string[range->start] != seek_to_this) { - range->start++; - - if (f_macro_utf_character_t_width_is(buffer.string[range->start]) == 1) { - return F_status_set_error(F_utf); - } - - if (range->start >= buffer.used) return F_none_eos; - if (range->start > range->stop) return F_none_stop; - } // while - - return F_none; - } -#endif // _di_fl_utfl_string_dynamic_seek_to_ +#endif // _di_fl_utf_string_dynamic_seek_line_until_graph_non_ -#ifndef _di_fl_utfl_string_dynamic_seek_to_char_ - f_status_t fl_utfl_string_dynamic_seek_to_char(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const int8_t seek_to_this) { +#ifndef _di_fl_utf_string_dynamic_seek_to_char_ + f_status_t fl_utf_string_dynamic_seek_to_char(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const int8_t seek_to_this) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (buffer.used <= range->start) return F_status_set_error(F_parameter); - if (buffer.used <= range->stop) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ if (!buffer.used) return F_data_not_eos; @@ -961,316 +220,50 @@ extern "C" { return F_none; } -#endif // _di_fl_utfl_string_dynamic_seek_to_char_ - -#ifndef _di_fl_utf_string_dynamic_terminate_ - f_status_t fl_utf_string_dynamic_terminate(f_utf_string_dynamic_t *destination) { - #ifndef _di_level_1_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - if (destination->used > destination->size) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (destination->used > 0 && destination->string[destination->used - 1] == f_utf_character_t_eos) { - return F_none; - } - - if (destination->used == f_utf_string_length_t_size) { - return F_status_set_error(F_string_too_large); - } - - const f_utf_string_length_t total = destination->used + 1; - - if (total > destination->size) { - f_status_t status = F_none; - - f_macro_utf_string_dynamic_t_resize(status, (*destination), total); - if (F_status_is_error(status)) return status; - } - - destination->string[destination->used] = f_utf_character_t_eos; - destination->used = total; - - return F_none; - } -#endif // _di_fl_utf_string_dynamic_terminate_ - -#ifndef _di_fl_utf_string_dynamic_terminate_after_ - f_status_t fl_utf_string_dynamic_terminate_after(f_utf_string_dynamic_t *destination) { - #ifndef _di_level_1_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - if (destination->used > destination->size) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (destination->used > 0) { - for (; destination->used > 0; destination->used--) { - if (!destination->string[destination->used - 1]) continue; - break; - } // for - } - - if (destination->used == f_utf_string_length_t_size) { - return F_status_set_error(F_string_too_large); - } - - const f_utf_string_length_t total = destination->used + 1; - - if (total > destination->size) { - f_status_t status = F_none; - - f_macro_utf_string_dynamic_t_resize(status, (*destination), total); - if (F_status_is_error(status)) return status; - } - - destination->string[destination->used] = 0; - destination->used = total - 1; - - return F_none; - } -#endif // _di_fl_utf_string_dynamic_terminate_after_ - -#ifndef _di_fl_utf_string_mash_ - f_status_t fl_utf_string_mash(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_t source, const f_utf_string_length_t length, f_utf_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_ - - if (!length) return F_data_not_eos; - - if (glue_length > 0 && destination->used > 0) { - f_status_t status = private_fl_utf_string_append(glue, glue_length, destination); - if (F_status_is_error(status)) return status; - } - - return private_fl_utf_string_append(source, length, destination); - } -#endif // _di_fl_utf_string_mash_ - -#ifndef _di_fl_utf_string_mash_nulless_ - f_status_t fl_utf_string_mash_nulless(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_t source, const f_utf_string_length_t length, f_utf_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_ - - if (!length) return F_data_not_eos; - - if (glue_length > 0 && destination->used > 0) { - f_status_t status = private_fl_utf_string_append_nulless(glue, glue_length, destination); - if (F_status_is_error(status)) return status; - } - - return private_fl_utf_string_append_nulless(source, length, destination); - } -#endif // _di_fl_utf_string_mash_nulless_ - -#ifndef _di_fl_utf_string_mish_ - f_status_t fl_utf_string_mish(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_t source, const f_utf_string_length_t length, f_utf_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_ - - if (!length) return F_data_not_eos; - - if (glue_length > 0 && destination->used > 0) { - f_status_t status = private_fl_utf_string_prepend(glue, glue_length, destination); - if (F_status_is_error(status)) return status; - } - - return private_fl_utf_string_prepend(source, length, destination); - } -#endif // _di_fl_utf_string_mish_ - -#ifndef _di_fl_utf_string_mish_nulless_ - f_status_t fl_utf_string_mish_nulless(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_t source, const f_utf_string_length_t length, f_utf_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_ - - if (!length) return F_data_not_eos; - - if (glue_length > 0 && destination->used > 0) { - f_status_t status = private_fl_utf_string_prepend_nulless(glue, glue_length, destination); - if (F_status_is_error(status)) return status; - } - - return private_fl_utf_string_prepend_nulless(source, length, destination); - } -#endif // _di_fl_utf_string_mish_nulless_ - -#ifndef _di_fl_utf_string_prepend_ - f_status_t fl_utf_string_prepend(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_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_ - - if (!length) return F_data_not_eos; - - return private_fl_utf_string_prepend(source, length, destination); - } -#endif // _di_fl_utf_string_prepend_ - -#ifndef _di_fl_utf_string_prepend_assure_ - f_status_t fl_utf_string_prepend_assure(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_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_ - - if (!length) return F_data_not_eos; - - if (destination->used < length) { - return private_fl_utf_string_prepend(source, length, destination); - } - - f_utf_string_length_t i = 0; - f_utf_string_length_t j = 0; - - while (i < length && j < destination->used) { - - if (source[i] == f_utf_character_t_eos) { - i++; - continue; - } - - if (destination->string[j] == f_utf_character_t_eos) { - j++; - continue; - } - - if (source[i] != destination->string[i]) { - return private_fl_utf_string_prepend(source, length, destination); - } - - i++; - j++; - } // while - - return F_none; - } -#endif // _di_fl_utf_string_prepend_assure_ - -#ifndef _di_fl_utf_string_prepend_assure_nulless_ - f_status_t fl_utf_string_prepend_assure_nulless(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_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_ - - if (!length) return F_data_not_eos; - - if (destination->used < length) { - return private_fl_utf_string_prepend_nulless(source, length, destination); - } - - f_utf_string_length_t i = 0; - f_utf_string_length_t j = 0; - - while (i < length && j < destination->used) { - - if (source[i] == f_utf_character_t_eos) { - i++; - continue; - } - - if (destination->string[j] == f_utf_character_t_eos) { - j++; - continue; - } - - if (source[i] != destination->string[i]) { - return private_fl_utf_string_prepend_nulless(source, length, destination); - } - - i++; - j++; - } // while - - return F_none; - } -#endif // _di_fl_utf_string_prepend_assure_nulless_ - -#ifndef _di_fl_utf_string_prepend_nulless_ - f_status_t fl_utf_string_prepend_nulless(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_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_ - - if (!length) return F_data_not_eos; - - return private_fl_utf_string_prepend_nulless(source, length, destination); - } -#endif // _di_fl_utf_string_prepend_nulless_ +#endif // _di_fl_utf_string_dynamic_seek_to_char_ -#ifndef _di_fl_utfl_string_rip_ - f_status_t fl_utfl_string_rip(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination) { +#ifndef _di_fl_utf_string_rip_ + f_status_t fl_utf_string_rip(const f_utf_string_t source, const f_string_length_t length, f_utf_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_ if (!length) return F_data_not_eos; - f_utf_string_length_t begin = 0; - f_utf_string_length_t end = length - 1; + f_string_length_t begin = 0; + f_string_length_t end = length - 1; - f_status_t status = private_fl_utfl_string_rip_find_range(source, &begin, &end); + f_status_t status = private_fl_utf_string_rip_find_range(source, &begin, &end); if (F_status_is_error(status)) return status; if (status == F_data_not) return status; - return private_fl_utf_string_append(source + begin, (end - begin) + 1, destination); + return f_utf_string_append(source + begin, (end - begin) + 1, destination); } -#endif // _di_fl_utfl_string_rip_ +#endif // _di_fl_utf_string_rip_ -#ifndef _di_fl_utfl_string_rip_nulless_ - f_status_t fl_utfl_string_rip_nulless(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination) { +#ifndef _di_fl_utf_string_rip_nulless_ + f_status_t fl_utf_string_rip_nulless(const f_utf_string_t source, const f_string_length_t length, f_utf_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_ if (!length) return F_data_not_eos; - f_utf_string_length_t begin = 0; - f_utf_string_length_t end = length - 1; + f_string_length_t begin = 0; + f_string_length_t end = length - 1; - f_status_t status = private_fl_utfl_string_rip_find_range(source, &begin, &end); + f_status_t status = private_fl_utf_string_rip_find_range(source, &begin, &end); if (F_status_is_error(status)) return status; if (status == F_data_not) return status; - return private_fl_utf_string_append_nulless(source + begin, (end - begin) + 1, destination); - } -#endif // _di_fl_utfl_string_rip_nulless_ - -#ifndef _di_fl_utfl_string_seek_line_to_ - f_status_t fl_utfl_string_seek_line_to(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t seek_to_this) { - #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (range->start > range->stop) return F_data_not_stop; - - if (f_macro_utf_character_t_width_is(string[range->start]) == 1) { - return F_status_set_error(F_utf); - } - - while (string[range->start] != seek_to_this) { - - if (string[range->start] == f_utf_character_t_eol) { - return F_none_eol; - } - - range->start++; - - if (f_macro_utf_character_t_width_is(string[range->start]) == 1) { - return F_status_set_error(F_utf); - } - - if (range->start > range->stop) return F_none_stop; - } // while - - return F_none; + return f_utf_string_append_nulless(source + begin, (end - begin) + 1, destination); } -#endif // _di_fl_utfl_string_seek_line_to_ +#endif // _di_fl_utf_string_rip_nulless_ -#ifndef _di_fl_utfl_string_seek_line_to_char_ - f_status_t fl_utfl_string_seek_line_to_char(const f_utf_string_t string, f_utf_string_range_t *range, const int8_t seek_to_this) { +#ifndef _di_fl_utf_string_seek_line_to_char_ + f_status_t fl_utf_string_seek_line_to_char(const f_utf_string_t string, f_utf_string_range_t *range, const int8_t seek_to_this) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -1291,10 +284,10 @@ extern "C" { return F_none_stop; } -#endif // _di_fl_utfl_string_seek_line_to_char_ +#endif // _di_fl_utf_string_seek_line_to_char_ -#ifndef _di_fl_utfl_string_seek_line_until_graph_ - f_status_t fl_utfl_string_seek_line_until_graph(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t placeholder) { +#ifndef _di_fl_utf_string_seek_line_until_graph_ + f_status_t fl_utf_string_seek_line_until_graph(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t placeholder) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -1325,10 +318,10 @@ extern "C" { return F_none; } -#endif // _di_fl_utfl_string_seek_line_until_graph_ +#endif // _di_fl_utf_string_seek_line_until_graph_ -#ifndef _di_fl_utfl_string_seek_line_until_non_graph_ - f_status_t fl_utfl_string_seek_line_until_non_graph(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t placeholder) { +#ifndef _di_fl_utf_string_seek_line_until_graph_non_ + f_status_t fl_utf_string_seek_line_until_graph_non(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t placeholder) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -1357,36 +350,10 @@ extern "C" { return F_none; } -#endif // _di_fl_utfl_string_seek_line_until_non_graph_ - -#ifndef _di_fl_utfl_string_seek_to_ - f_status_t fl_utfl_string_seek_to(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t seek_to_this) { - #ifndef _di_level_1_parameter_checking_ - if (!range) return F_status_set_error(F_parameter); - #endif // _di_level_1_parameter_checking_ - - if (range->start > range->stop) return F_data_not_stop; - - if (f_macro_utf_character_t_width_is(string[range->start]) == 1) { - return F_status_set_error(F_utf); - } - - while (string[range->start] != seek_to_this) { - range->start++; - - if (f_macro_utf_character_t_width_is(string[range->start]) == 1) { - return F_status_set_error(F_utf); - } - - if (range->start > range->stop) return F_none_stop; - } // while - - return F_none; - } -#endif // _di_fl_utfl_string_seek_to_ +#endif // _di_fl_utf_string_seek_line_until_graph_non_ -#ifndef _di_fl_utfl_string_seek_to_char_ - f_status_t fl_utfl_string_seek_to_char(const f_utf_string_t string, f_utf_string_range_t *range, const int8_t seek_to_this) { +#ifndef _di_fl_utf_string_seek_to_char_ + f_status_t fl_utf_string_seek_to_char(const f_utf_string_t string, f_utf_string_range_t *range, const int8_t seek_to_this) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -1414,7 +381,7 @@ extern "C" { return F_none_stop; } -#endif // _di_fl_utfl_string_seek_to_utf_character_ +#endif // _di_fl_utf_string_seek_to_utf_character_ #ifdef __cplusplus } // extern "C" diff --git a/level_1/fl_utf/c/utf.h b/level_1/fl_utf/c/utf.h index 5190028..710e70d 100644 --- a/level_1/fl_utf/c/utf.h +++ b/level_1/fl_utf/c/utf.h @@ -35,98 +35,6 @@ extern "C" { #endif /** - * Append the source UTF-8 string onto the destination. - * - * @param source - * The source string to append. - * @param length - * The length of source to append. - * @param destination - * The destination string the source is appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0.. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_append_ - extern f_status_t fl_utf_string_append(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_append_ - -/** - * Append the source UTF-8 string onto the destination, but only if the string is not already at the end. - * - * This ignores NULL characters when comparing both the source and the destination. - * Skips over NULL characters from source when appending. - * - * @param source - * The source string to append. - * @param length - * The length of source to append. - * @param destination - * The destination string the source is appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_append_assure_ - extern f_status_t fl_utf_string_append_assure(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_append_assure_ - -/** - * Append the UTF-8 source string onto the destination, but only if the string is not already at the end. - * - * This ignores NULL characters when comparing both the source and the destination. - * Skips over NULL characters from source when appending. - * - * @param source - * The source string to append. - * @param length - * The length of source to append. - * @param destination - * The destination string the source is appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_append_assure_nulless_ - extern f_status_t fl_utf_string_append_assure_nulless(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_append_assure_nulless_ - -/** - * Append the UTF-8 source string onto the destination. - * - * Skips over NULL characters from source when appending. - * - * @param source - * The source string to append. - * @param length - * The length of source to append. - * @param destination - * The destination string the source is appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_append_nulless_ - extern f_status_t fl_utf_string_append_nulless(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_append_nulless_ - -/** * Compare two UTF-8 strings, similar to strncmp(). * * This does not stop on NULL. @@ -146,9 +54,9 @@ extern "C" { * F_equal_to_not when both strings do not equal. * F_parameter (with error bit) if a parameter is invalid. */ -#ifndef _di_fl_utfl_string_compare_ - extern f_status_t fl_utfl_string_compare(const f_utf_string_t string1, const f_utf_string_t string2, const f_utf_string_length_t length1, const f_utf_string_length_t length2); -#endif // _di_fl_utfl_string_compare_ +#ifndef _di_fl_utf_string_compare_ + extern f_status_t fl_utf_string_compare(const f_utf_string_t string1, const f_utf_string_t string2, const f_string_length_t length1, const f_string_length_t length2); +#endif // _di_fl_utf_string_compare_ /** * Compare two UTF-8 strings, similar to strncmp(). @@ -175,89 +83,9 @@ extern "C" { * * @see f_utf_character_is_whitespace() */ -#ifndef _di_fl_utfl_string_compare_trim_ - extern f_status_t fl_utfl_string_compare_trim(const f_utf_string_t string1, const f_utf_string_t string2, const f_utf_string_length_t length1, const f_utf_string_length_t length2); -#endif // _di_fl_utfl_string_compare_trim_ - -/** - * Append the UTF-8 source string onto the destination. - * - * @param source - * The source string to append. - * @param destination - * The destination string the source is appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_append_ - extern f_status_t fl_utf_string_dynamic_append(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_append_ - -/** - * Append the UTF-8 source string onto the destination. - * - * @param source - * The source string to append. - * @param destination - * The destination string the source is appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_append_assure_ - extern f_status_t fl_utf_string_dynamic_append_assure(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_append_assure_ - -/** - * Append the UTF-8 source string onto the destination. - * - * Skips over NULL characters from source when appending. - * - * @param source - * The source string to append. - * @param destination - * The destination string the source is appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_append_assure_nulless_ - extern f_status_t fl_utf_string_dynamic_append_assure_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_append_assure_nulless_ - -/** - * Append the UTF-8 source string onto the destination. - * - * Skips over NULL characters from source when appending. - * - * @param source - * The source string to append. - * @param destination - * The destination string the source is appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_append_nulless_ - extern f_status_t fl_utf_string_dynamic_append_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_append_nulless_ +#ifndef _di_fl_utf_string_compare_trim_ + extern f_status_t fl_utf_string_compare_trim(const f_utf_string_t string1, const f_utf_string_t string2, const f_string_length_t length1, const f_string_length_t length2); +#endif // _di_fl_utf_string_compare_trim_ /** * Compare two UTF-8 strings, similar to strncmp(). @@ -276,9 +104,9 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) if a character in the string is an invalid UTF-8 character. */ -#ifndef _di_fl_utfl_string_dynamic_compare_ - extern f_status_t fl_utfl_string_dynamic_compare(const f_utf_string_static_t string1, const f_utf_string_static_t string2); -#endif // _di_fl_utfl_string_dynamic_compare_ +#ifndef _di_fl_utf_string_dynamic_compare_ + extern f_status_t fl_utf_string_dynamic_compare(const f_utf_string_static_t string1, const f_utf_string_static_t string2); +#endif // _di_fl_utf_string_dynamic_compare_ /** * Compare two UTF-8 strings, similar to strncmp(). @@ -302,209 +130,9 @@ extern "C" { * * @see f_utf_character_is_whitespace() */ -#ifndef _di_f_utfl_string_dynamic_compare_trim_ - extern f_status_t f_utfl_string_dynamic_compare_trim(const f_utf_string_static_t string1, const f_utf_string_static_t string2); -#endif // _di_f_utfl_string_dynamic_compare_trim_ - -/** - * Append the UTF-8 source string onto the destination with the glue in between. - * - * If the destination string is empty, then no glue is appended. - * - * @param glue - * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. - * @param source - * The source string to append. - * @param destination - * The destination string the source and glue are appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_mash_ - extern f_status_t fl_utf_string_dynamic_mash(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_mash_ - -/** - * Append the UTF-8 source string onto the destination with the glue in between. - * - * If the destination string is empty, then no glue is appended. - * - * Skips over NULL characters from glue and source when appending. - * - * @param glue - * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. - * @param source - * The source string to append. - * @param destination - * The destination string the source and glue are appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_mash_nulless_ - extern f_status_t fl_utf_string_dynamic_mash_nulless(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_mash_nulless_ - -/** - * Prepend the UTF-8 source string onto the destination with the glue in between. - * - * If the destination string is empty, then no glue is appended. - * - * @param glue - * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. - * @param source - * The source string to append. - * @param destination - * The destination string the source and glue are appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_mish_ - extern f_status_t fl_utf_string_dynamic_mish(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_mish_ - -/** - * Prepend the UTF-8 source string onto the destination with the glue in between. - * - * If the destination string is empty, then no glue is appended. - * - * Skips over NULL characters from glue and source when appending. - * - * @param glue - * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. - * @param source - * The source string to append. - * @param destination - * The destination string the source and glue are appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_mish_nulless_ - extern f_status_t fl_utf_string_dynamic_mish_nulless(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_mish_nulless_ - -/** - * Append the UTF-8 source string onto the destination, but restricted to the given range. - * - * @param source - * The source string to append. - * @param range - * A range within the source to restrict the copy from. - * @param destination - * The destination string the source is appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_partial_append_ - extern f_status_t fl_utf_string_dynamic_partial_append(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_partial_append_ - -/** - * Append the UTF-8 source string onto the destination, but only if the string is not already at the end and restricted to the given range - * - * This ignores NULL characters when comparing both the source and the destination. - * - * @param source - * The source string to append. - * @param range - * A range within the source to restrict the copy from. - * @param destination - * The destination string the source is appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_partial_append_assure_ - extern f_status_t fl_utf_string_dynamic_partial_append_assure(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_partial_append_assure_ - -/** - * Append the UTF-8 source string onto the destination, but only if the string is not already at the end and restricted to the given range - * - * This ignores NULL characters when comparing both the source and the destination. - * - * Skips over NULL characters from source when appending. - * - * @param source - * The source string to append. - * @param range - * A range within the source to restrict the copy from. - * @param destination - * The destination string the source is appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_partial_append_assure_nulless_ - extern f_status_t fl_utf_string_dynamic_partial_append_assure_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_partial_append_assure_nulless_ - -/** - * Append the UTF-8 source string onto the destination, but restricted to the given range. - * - * Skips over NULL characters from source when appending. - * - * @param source - * The source string to append. - * @param range - * A range within the source to restrict the copy from. - * @param destination - * The destination string the source is appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_partial_append_nulless_ - extern f_status_t fl_utf_string_dynamic_partial_append_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_partial_append_nulless_ +#ifndef _di_fl_utf_string_dynamic_compare_trim_ + extern f_status_t fl_utf_string_dynamic_compare_trim(const f_utf_string_static_t string1, const f_utf_string_static_t string2); +#endif // _di_fl_utf_string_dynamic_compare_trim_ /** * Compare two UTF-8 strings, similar to strncmp(), but restricted to the given ranges. @@ -526,9 +154,9 @@ extern "C" { * F_equal_to_not when both strings do not equal. * F_parameter (with error bit) if a parameter is invalid. */ -#ifndef _di_fl_utfl_string_dynamic_partial_compare_ - extern f_status_t fl_utfl_string_dynamic_partial_compare(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_utf_string_range_t range1, const f_utf_string_range_t range2); -#endif // _di_fl_utfl_string_dynamic_partial_compare_ +#ifndef _di_fl_utf_string_dynamic_partial_compare_ + extern f_status_t fl_utf_string_dynamic_partial_compare(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_utf_string_range_t range1, const f_utf_string_range_t range2); +#endif // _di_fl_utf_string_dynamic_partial_compare_ /** * Compare two UTF-8 strings, similar to strncmp(), but restricted to the given ranges. @@ -550,322 +178,14 @@ extern "C" { * F_equal_to when both strings equal. * F_equal_to_not when both strings do not equal. * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_utf_character_is_whitespace(). - * - * @see f_utf_character_is_whitespace() - */ -#ifndef _di_fl_utfl_string_dynamic_partial_compare_trim_ - extern f_status_t fl_utfl_string_dynamic_partial_compare_trim(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_utf_string_range_t range1, const f_utf_string_range_t range2); -#endif // _di_fl_utfl_string_dynamic_partial_compare_trim_ - -/** - * Append the UTF-8 source string onto the destination with the glue in between, but restricted to the given range. - * - * If the destination string is empty, then no glue is appended. - * - * @param glue - * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. - * @param source - * The source string to append. - * @param range - * A range within the source to restrict the copy from. - * @param destination - * The destination string the source and glue are appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_partial_mash_ - extern f_status_t fl_utf_string_dynamic_partial_mash(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_partial_mash_ - -/** - * Append the UTF-8 source string onto the destination with the glue in between, but restricted to the given range. - * - * If the destination string is empty, then no glue is appended. - * - * Skips over NULL characters from glue and source when appending. - * - * @param glue - * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. - * @param source - * The source string to append. - * @param range - * A range within the source to restrict the copy from. - * @param destination - * The destination string the source and glue are appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_partial_mash_nulless_ - extern f_status_t fl_utf_string_dynamic_partial_mash_nulless(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_partial_mash_nulless_ - -/** - * Prepend the UTF-8 source string onto the destination with the glue in between, but restricted to the given range. - * - * If the destination string is empty, then no glue is appended. - * - * @param glue - * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. - * @param source - * The source string to append. - * @param range - * A range within the source to restrict the copy from. - * @param destination - * The destination string the source and glue are appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_partial_mish_ - extern f_status_t fl_utf_string_dynamic_partial_mish(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_partial_mish_ - -/** - * Prepend the UTF-8 source string onto the destination with the glue in between, but restricted to the given range. - * - * If the destination string is empty, then no glue is appended. - * - * Skips over NULL characters from glue and source when appending. - * - * @param glue - * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. - * @param source - * The source string to append. - * @param range - * A range within the source to restrict the copy from. - * @param destination - * The destination string the source and glue are appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_partial_mish_nulless_ - extern f_status_t fl_utf_string_dynamic_partial_mish_nulless(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_partial_mish_nulless_ - -/** - * Prepend the UTF-8 source string onto the destination, but restricted to the given range. - * - * Prepend operations require memory move operations and are therefore likely more expensive than append operations. - * - * @param source - * The source string to prepend. - * @param range - * A range within the source to restrict the copy from. - * @param destination - * The destination string the source is prepended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_partial_prepend_ - extern f_status_t fl_utf_string_dynamic_partial_prepend(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_partial_prepend_ - -/** - * Prepend the UTF-8 source string onto the destination, but only if the string is not already at the end and restricted to the given range - * - * Prepend operations require memory move operations and are therefore likely more expensive than append operations. - * - * This ignores NULL characters when comparing both the source and the destination. - * - * @param source - * The source string to prepend. - * @param range - * A range within the source to restrict the copy from. - * @param destination - * The destination string the source is prepended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_partial_prepend_assure_ - extern f_status_t fl_utf_string_dynamic_partial_prepend_assure(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_partial_prepend_assure_ - -/** - * Prepend the UTF-8 source string onto the destination, but only if the string is not already at the end and restricted to the given range - * - * Prepend operations require memory move operations and are therefore likely more expensive than append operations. - * - * This ignores NULL characters when comparing both the source and the destination. - * - * @param source - * The source string to prepend. - * @param range - * A range within the source to restrict the copy from. - * @param destination - * The destination string the source is prepended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_partial_prepend_assure_nulless_ - extern f_status_t fl_utf_string_dynamic_partial_prepend_assure_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_partial_prepend_assure_nulless_ - -/** - * Prepend the UTF-8 source string onto the destination, but restricted to the given range. - * - * Prepend operations require memory move operations and are therefore likely more expensive than append operations. - * - * @param source - * The source string to prepend. - * @param range - * A range within the source to restrict the copy from. - * @param destination - * The destination string the source is prepended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_partial_prepend_nulless_ - extern f_status_t fl_utf_string_dynamic_partial_prepend_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_partial_prepend_nulless_ - -/** - * Prepend the source string onto the destination. - * - * Prepend operations require memory move operations and are therefore likely more expensive than append operations. - * - * @param source - * The source string to prepend. - * @param destination - * The destination string the source is prepended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_prepend_ - extern f_status_t fl_utf_string_dynamic_prepend(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_prepend_ - -/** - * Prepend the UTF-8 source string onto the destination, but only if the string is not already at the beginning. - * - * Prepend operations require memory move operations and are therefore likely more expensive than append operations. - * - * This ignores NULL characters when comparing both the source and the destination. - * - * @param source - * The source string to prepend. - * @param destination - * The destination string the source is prepended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_prepend_assure_ - extern f_status_t fl_utf_string_dynamic_prepend_assure(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_prepend_assure_ - -/** - * Prepend the UTF-8 source string onto the destination, but only if the string is not already at the beginning. - * - * Prepend operations require memory move operations and are therefore likely more expensive than append operations. - * - * This ignores NULL characters when comparing both the source and the destination. - * - * @param source - * The source string to prepend. - * @param destination - * The destination string the source is prepended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_dynamic_prepend_assure_nulless_ - extern f_status_t fl_utf_string_dynamic_prepend_assure_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_prepend_assure_nulless_ - -/** - * Prepend the UTF-8 source string onto the destination. - * - * Prepend operations require memory move operations and are therefore likely more expensive than append operations. - * - * @param source - * The source string to prepend. - * @param destination - * The destination string the source is prepended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_data_not_stop if range.start > range.stop. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_utf_character_is_whitespace(). + * + * @see f_utf_character_is_whitespace() */ -#ifndef _di_fl_utf_string_dynamic_prepend_nulless_ - extern f_status_t fl_utf_string_dynamic_prepend_nulless(const f_utf_string_static_t source, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_prepend_nulless_ +#ifndef _di_fl_utf_string_dynamic_partial_compare_trim_ + extern f_status_t fl_utf_string_dynamic_partial_compare_trim(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_utf_string_range_t range1, const f_utf_string_range_t range2); +#endif // _di_fl_utf_string_dynamic_partial_compare_trim_ /** * Allocate a new UTF-8 string from the provided range in the buffer. @@ -888,9 +208,9 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * F_string_too_large (with error bit) if the combined string is too large. */ -#ifndef _di_fl_utfl_string_dynamic_rip_ - extern f_status_t fl_utfl_string_dynamic_rip(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utfl_string_dynamic_rip_ +#ifndef _di_fl_utf_string_dynamic_rip_ + extern f_status_t fl_utf_string_dynamic_rip(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); +#endif // _di_fl_utf_string_dynamic_rip_ /** * Allocate a new UTF-8 string from the provided range in the buffer. @@ -914,34 +234,9 @@ extern "C" { * F_memory_not (with error bit) on out of memory. * F_parameter (with error bit) if a parameter is invalid. */ -#ifndef _di_fl_utfl_string_dynamic_rip_nulless_ - extern f_status_t fl_utfl_string_dynamic_rip_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utfl_string_dynamic_rip_nulless_ - -/** - * Seek the buffer location forward until the UTF-8 character or EOL is reached. - * - * @param buffer - * The buffer to traverse. - * @param range - * A range within the buffer representing the start and stop locations. - * The start location will be incremented by seek. - * @param seek_to_this - * A UTF-8 character representing a character to seek to. - * - * @return - * F_none on success. - * F_none_eol on success, but stopped at EOL. - * F_none_eos on success, but stopped at end of buffer. - * F_none_stop on success, but stopped stop location. - * F_data_not_eos if buffer length is 0. - * F_data_not_stop if range.start > range.stop. - * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. - */ -#ifndef _di_fl_utfl_string_dynamic_seek_line_to_ - extern f_status_t fl_utfl_string_dynamic_seek_line_to(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t seek_to_this); -#endif // _di_fl_utfl_string_dynamic_seek_line_to_ +#ifndef _di_fl_utf_string_dynamic_rip_nulless_ + extern f_status_t fl_utf_string_dynamic_rip_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); +#endif // _di_fl_utf_string_dynamic_rip_nulless_ /** * Seek the buffer location forward until the (1-byte wide) character or EOL is reached. @@ -963,9 +258,9 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. */ -#ifndef _di_fl_utfl_string_seek_line_to_char_ - extern f_status_t fl_utfl_string_dynamic_seek_line_to_char(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const int8_t seek_to_this); -#endif // _di_fl_utfl_string_seek_line_to_char_ +#ifndef _di_fl_utf_string_dynamic_seek_line_to_char_ + extern f_status_t fl_utf_string_dynamic_seek_line_to_char(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const int8_t seek_to_this); +#endif // _di_fl_utf_string_dynamic_seek_line_to_char_ /** * Increment buffer location until a graph character or an EOL is matched. @@ -990,9 +285,9 @@ extern "C" { * * @see f_utf_character_is_graph() */ -#ifndef _di_fl_utfl_string_dynamic_seek_line_until_graph_ - extern f_status_t fl_utfl_string_dynamic_seek_line_until_graph(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t placeholder); -#endif // _di_fl_utfl_string_dynamic_seek_line_until_graph_ +#ifndef _di_fl_utf_string_dynamic_seek_line_until_graph_ + extern f_status_t fl_utf_string_dynamic_seek_line_until_graph(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t placeholder); +#endif // _di_fl_utf_string_dynamic_seek_line_until_graph_ /** * Increment buffer location until a non-graph character or an EOL is matched. @@ -1018,33 +313,9 @@ extern "C" { * * @see f_utf_character_is_graph() */ -#ifndef _di_fl_utfl_string_dynamic_seek_line_until_non_graph_ - extern f_status_t fl_utfl_string_dynamic_seek_line_until_non_graph(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t placeholder); -#endif // _di_fl_utfl_string_dynamic_seek_line_until_non_graph_ - -/** - * Seek the buffer location forward until the UTF-8 character is reached. - * - * @param buffer - * The buffer to traverse. - * @param range - * A range within the buffer representing the start and stop locations. - * The start location will be incremented by seek. - * @param seek_to_this - * A UTF-8 character representing a character to seek to. - * - * @return - * F_none on success. - * F_none_eos on success, but stopped at end of buffer. - * F_none_stop on success, but stopped stop location. - * F_data_not_eos if buffer length is 0. - * F_data_not_stop if range.start > range.stop. - * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. - */ -#ifndef _di_fl_utfl_string_dynamic_seek_to_ - extern f_status_t fl_utfl_string_dynamic_seek_to(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t seek_to_this); -#endif // _di_fl_utfl_string_dynamic_seek_to_ +#ifndef _di_fl_utf_string_dynamic_seek_line_until_graph_non_ + extern f_status_t fl_utf_string_dynamic_seek_line_until_graph_non(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t placeholder); +#endif // _di_fl_utf_string_dynamic_seek_line_until_graph_non_ /** * Seek the buffer location forward until the UTF-8 character (1-byte wide) is reached. @@ -1066,292 +337,9 @@ extern "C" { * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. * F_parameter (with error bit) if a parameter is invalid. */ -#ifndef _di_fl_utfl_string_dynamic_seek_to_char_ - extern f_status_t fl_utfl_string_dynamic_seek_to_char(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const int8_t seek_to_this); -#endif // _di_fl_utfl_string_dynamic_seek_to_char_ - -/** - * Seek the buffer location forward until the (4-byte wide) UTF-8 character is reached. - * - * @param buffer - * The buffer to traverse. - * @param range - * A range within the buffer representing the start and stop locations. - * The start location will be incremented by seek. - * @param seek_to_this - * A 1-width, 2-width, 3-width, or 4-width character representing a character to seek to. - * - * @return - * F_none on success. - * F_none_eos on success, but stopped at end of buffer. - * F_none_stop on success, but stopped stop location. - * F_data_not_eos if buffer length is 0. - * F_data_not_stop if range.start > range.stop. - * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. - * F_complete_not_utf_eos (with error bit) if end of string is reached before a complete UTF-8 character can be processed. - * F_complete_not_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. - * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if character is an invalid UTF-8 character. - */ -#ifndef _di_fl_utfl_string_dynamic_seek_to_utf_character_ - extern f_status_t fl_utfl_string_dynamic_seek_to_utf_character(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t seek_to_this); -#endif // _di_fl_utfl_string_dynamic_seek_to_utf_character_ - -/** - * Guarantee that an end of UTF-8 string (NULL) exists at the end of the string. - * - * This is intended to be used for anything requiring NULL terminated strings. - * This will reallocate more space if necessary. - * - * If destination size is 0, then it will be reallocated and have the NULL assigned at index 0. - * - * @param destination - * The new string, which will be allocated or reallocated as necessary. - * - * @return - * F_none on success. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if string is too large to fit into the buffer. - */ -#ifndef _di_fl_utf_string_dynamic_terminate_ - extern f_status_t fl_utf_string_dynamic_terminate(f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_terminate_ - -/** - * Guarantee that an end of string (NULL) exists at the end of the UTF-8 string. - * - * This ensures that the terminating NULL not only exists but is not counted in destination.used. - * - * This is intended to be used for anything requiring NULL terminated strings whose used length cannot be counted. - * This will reallocate more space if necessary. - * - * If destination size is 0, then it will be reallocated and have the NULL assigned at index 0. - * - * @param destination - * The new string, which will be allocated or reallocated as necessary. - * - * @return - * F_none on success. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if string is too large to fit into the buffer. - */ -#ifndef _di_fl_utf_string_dynamic_terminate_after_ - extern f_status_t fl_utf_string_dynamic_terminate_after(f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_dynamic_terminate_after_ - -/** - * Append the UTF-8 source string onto the destination with the glue in between. - * - * If the destination string is empty, then no glue is appended. - * - * @param glue - * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. - * @param source - * The source string to append. - * @param length - * The length of source to append. - * @param destination - * The destination string the source and glue are appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_mash_ - extern f_status_t fl_utf_string_mash(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_mash_ - -/** - * Append the UTF-8 source string onto the destination with the glue in between. - * - * If the destination string is empty, then no glue is appended. - * - * Skips over NULL characters from glue and source when appending. - * - * @param glue - * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. - * @param source - * The source string to append. - * @param length - * The length of source to append. - * @param destination - * The destination string the source and glue are appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_mash_nulless_ - extern f_status_t fl_utf_string_mash_nulless(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_mash_nulless_ - -/** - * Prepend the UTF-8 source string onto the destination with the glue in between. - * - * If the destination string is empty, then no glue is appended. - * - * @param glue - * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. - * @param source - * The source string to append. - * @param length - * The length of source to append. - * @param destination - * The destination string the source and glue are appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_mish_ - extern f_status_t fl_utf_string_mish(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_mish_ - -/** - * Prepend the UTF-8 source string onto the destination with the glue in between. - * - * If the destination string is empty, then no glue is appended. - * - * Skips over NULL characters from glue and source when appending. - * - * @param glue - * A string to append between the source and destination, such as a space: ' '. - * @param glue_length - * The number of bytes the glue takes up. - * @param source - * The source string to append. - * @param length - * The length of source to append. - * @param destination - * The destination string the source and glue are appended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_mish_nulless_ - extern f_status_t fl_utf_string_mish_nulless(const f_utf_string_t glue, const f_utf_string_length_t glue_length, const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_mish_nulless_ - -/** - * Prepend the UTF-8 source string onto the destination. - * - * Prepend operations require memory move operations and are therefore likely more expensive than append operations. - * - * @param source - * The source string to prepend. - * @param length - * The length of source to append. - * @param destination - * The destination string the source is prepended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_prepend_ - extern f_status_t fl_utf_string_prepend(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_prepend_ - -/** - * Prepend the UTF-8 source string onto the destination, but only if the string is not already at the beginning. - * - * Prepend operations require memory move operations and are therefore likely more expensive than append operations. - * - * This ignores NULL characters when comparing both the source and the destination. - * - * @param source - * The source string to prepend. - * @param length - * The length of source to append. - * @param destination - * The destination string the source is prepended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_prepend_assure_ - extern f_status_t fl_utf_string_prepend_assure(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_prepend_assure_ - -/** - * Prepend the UTF-8 source string onto the destination, but only if the string is not already at the beginning. - * - * Prepend operations require memory move operations and are therefore likely more expensive than append operations. - * - * This ignores NULL characters when comparing both the source and the destination. - * Skips over NULL characters from source when prepending. - * - * @param source - * The source string to prepend. - * @param length - * The length of source to append. - * @param destination - * The destination string the source is prepended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_prepend_assure_nulless_ - extern f_status_t fl_utf_string_prepend_assure_nulless(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_prepend_assure_nulless_ - -/** - * Prepend the UTF-8 source string onto the destination, but only if the string is not already at the beginning. - * - * Prepend operations require memory move operations and are therefore likely more expensive than append operations. - * - * This ignores NULL characters when comparing both the source and the destination. - * Skips over NULL characters from source when prepending. - * - * @param source - * The source string to prepend. - * @param length - * The length of source to append. - * @param destination - * The destination string the source is prepended onto. - * - * @return - * F_none on success. - * F_data_not_eos if source length is 0. - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - * F_string_too_large (with error bit) if the combined string is too large. - */ -#ifndef _di_fl_utf_string_prepend_nulless_ - extern f_status_t fl_utf_string_prepend_nulless(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utf_string_prepend_nulless_ +#ifndef _di_fl_utf_string_dynamic_seek_to_char_ + extern f_status_t fl_utf_string_dynamic_seek_to_char(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const int8_t seek_to_this); +#endif // _di_fl_utf_string_dynamic_seek_to_char_ /** * Allocate a new UTF-8 string from the provided range in the string. @@ -1376,9 +364,9 @@ extern "C" { * * @see f_utf_character_is_whitespace() */ -#ifndef _di_fl_utfl_string_rip_ - extern f_status_t fl_utfl_string_rip(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utfl_string_rip_ +#ifndef _di_fl_utf_string_rip_ + extern f_status_t fl_utf_string_rip(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_fl_utf_string_rip_ /** * Allocate a new UTF-8 string from the provided range in the string. @@ -1405,31 +393,9 @@ extern "C" { * * @see f_utf_character_is_whitespace() */ -#ifndef _di_fl_utfl_string_rip_nulless_ - extern f_status_t fl_utfl_string_rip_nulless(const f_utf_string_t source, const f_utf_string_length_t length, f_utf_string_dynamic_t *destination); -#endif // _di_fl_utfl_string_rip_nulless_ - -/** - * Seek the UTF-8 string location forward until the character (1-byte wide) or EOL is reached. - * - * @param string - * The string to traverse. - * @param range - * A range within the buffer representing the start and stop locations. - * The start location will be incremented by seek. - * @param seek_to_this - * A single-width character representing a character to seek to. - * - * @return - * F_none on success. - * F_none_eol on success, but stopped at EOL. - * F_none_stop on success, but stopped stop location. - * F_data_not_stop if range.start > range.stop. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_fl_utfl_string_seek_line_to_ - extern f_status_t fl_utfl_string_seek_line_to(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t seek_to_this); -#endif // _di_fl_utfl_string_seek_line_to_ +#ifndef _di_fl_utf_string_rip_nulless_ + extern f_status_t fl_utf_string_rip_nulless(const f_utf_string_t source, const f_string_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_fl_utf_string_rip_nulless_ /** * Seek the string location forward until the 1-byte wide character or EOL is reached. @@ -1450,9 +416,9 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. */ -#ifndef _di_fl_utfl_string_seek_line_to_char_ - extern f_status_t fl_utfl_string_seek_line_to_char(const f_utf_string_t string, f_utf_string_range_t *range, const int8_t seek_to_this); -#endif // _di_fl_utfl_string_seek_line_to_char_ +#ifndef _di_fl_utf_string_seek_line_to_char_ + extern f_status_t fl_utf_string_seek_line_to_char(const f_utf_string_t string, f_utf_string_range_t *range, const int8_t seek_to_this); +#endif // _di_fl_utf_string_seek_line_to_char_ /** * Increment string location until a UTF-8 graph character or an EOL is matched. @@ -1479,9 +445,9 @@ extern "C" { * * @see f_utf_character_is_graph() */ -#ifndef _di_fl_utfl_string_seek_line_until_graph_ - extern f_status_t fl_utfl_string_seek_line_until_graph(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t placeholder); -#endif // _di_fl_utfl_string_seek_line_until_graph_ +#ifndef _di_fl_utf_string_seek_line_until_graph_ + extern f_status_t fl_utf_string_seek_line_until_graph(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t placeholder); +#endif // _di_fl_utf_string_seek_line_until_graph_ /** * Increment string location until a non-graph UTF-8 character or an EOL is matched. @@ -1509,31 +475,9 @@ extern "C" { * * @see f_utf_character_is_graph() */ -#ifndef _di_fl_utfl_string_seek_line_until_non_graph_ - extern f_status_t fl_utfl_string_seek_line_until_non_graph(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t placeholder); -#endif // _di_fl_utfl_string_seek_line_until_non_graph_ - -/** - * Seek the string location forward until the character (1-byte wide) is reached. - * - * @param string - * The sting to traverse. - * @param range - * A range within the buffer representing the start and stop locations. - * The start location will be incremented by seek. - * @param seek_to_this - * A UTF-8 character representing a character to seek to. - * - * @return - * F_none on success. - * F_none_stop on success, but stopped stop location. - * F_data_not_stop if range.start > range.stop. - * F_parameter (with error bit) if a parameter is invalid. - * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. - */ -#ifndef _di_fl_utfl_string_seek_to_ - extern f_status_t fl_utfl_string_seek_to(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t seek_to_this); -#endif // _di_fl_utfl_string_seek_to_ +#ifndef _di_fl_utf_string_seek_line_until_graph_non_ + extern f_status_t fl_utf_string_seek_line_until_graph_non(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t placeholder); +#endif // _di_fl_utf_string_seek_line_until_graph_non_ /** * Seek the string location forward until the UTF-8 character (up to 4-byte wide) is reached. @@ -1554,8 +498,8 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. */ -#ifndef _di_fl_utfl_string_seek_to_character_ - extern f_status_t fl_utfl_string_seek_to_char(const f_utf_string_t string, f_utf_string_range_t *range, const int8_t seek_to_this); +#ifndef _di_fl_utf_string_seek_to_character_ + extern f_status_t fl_utf_string_seek_to_char(const f_utf_string_t string, f_utf_string_range_t *range, const int8_t seek_to_this); #endif // _di_fl_utf_string__seek_to_character_ #ifdef __cplusplus diff --git a/level_1/fl_utf_file/c/private-utf_file.c b/level_1/fl_utf_file/c/private-utf_file.c index 7431c0a..f41f795 100644 --- a/level_1/fl_utf_file/c/private-utf_file.c +++ b/level_1/fl_utf_file/c/private-utf_file.c @@ -70,13 +70,13 @@ extern "C" { #endif // !defined(_di_fl_utf_file_read_) || !defined(_di_fl_utf_file_read_until_) || !defined(_di_fl_utf_file_read_range_) #if !defined(_di_fl_utf_file_write_) || !defined(_di_fl_utf_file_write_until_) || !defined(fl_utf_file_write_range) - f_status_t private_fl_utf_file_write_until(const f_file_t file, const f_utf_string_t string, const f_utf_string_length_t total, f_utf_string_length_t *written) { + f_status_t private_fl_utf_file_write_until(const f_file_t file, const f_utf_string_t string, const f_string_length_t total, f_string_length_t *written) { *written = 0; f_status_t status = F_none; - f_utf_string_length_t write_size = file.size_write > 4 ? file.size_write : 4; - f_utf_string_length_t write_max = total; - f_utf_string_length_t i = 0; + f_string_length_t write_size = file.size_write > 4 ? file.size_write : 4; + f_string_length_t write_max = total; + f_string_length_t i = 0; if (write_size > write_max) { write_size = write_max; diff --git a/level_1/fl_utf_file/c/private-utf_file.h b/level_1/fl_utf_file/c/private-utf_file.h index 204e92a..a8c4a10 100644 --- a/level_1/fl_utf_file/c/private-utf_file.h +++ b/level_1/fl_utf_file/c/private-utf_file.h @@ -77,7 +77,7 @@ extern "C" { * @see fl_utf_file_write_until() */ #if !defined(_di_fl_utf_file_write_) || !defined(_di_fl_utf_file_write_until_) || !defined(_di_fl_utf_file_write_range_) - extern f_status_t private_fl_utf_file_write_until(const f_file_t file, const f_utf_string_t string, const f_utf_string_length_t total, f_utf_string_length_t *written) f_gcc_attribute_visibility_internal; + extern f_status_t private_fl_utf_file_write_until(const f_file_t file, const f_utf_string_t string, const f_string_length_t total, f_string_length_t *written) f_gcc_attribute_visibility_internal; #endif // !defined(_di_fl_utf_file_write_) || !defined(_di_fl_utf_file_write_until_) || !defined(_di_fl_utf_file_write_range_) #ifdef __cplusplus diff --git a/level_1/fl_utf_file/c/utf_file.c b/level_1/fl_utf_file/c/utf_file.c index 187ce73..ab516da 100644 --- a/level_1/fl_utf_file/c/utf_file.c +++ b/level_1/fl_utf_file/c/utf_file.c @@ -29,7 +29,7 @@ extern "C" { while ((size_read = read(file.id, buffer_read, file.size_read)) > 0) { if (buffer->used + size_read > buffer->size) { - if (buffer->size + size_read > f_utf_string_length_t_size) { + if (buffer->size + size_read > f_string_length_t_size) { return F_status_set_error(F_string_too_large); } @@ -127,7 +127,7 @@ extern "C" { #endif // _di_fl_utf_file_read_block_ #ifndef _di_fl_utf_file_read_until_ - f_status_t fl_utf_file_read_until(const f_file_t file, const f_utf_string_length_t total, f_utf_string_dynamic_t *buffer) { + f_status_t fl_utf_file_read_until(const f_file_t file, const f_string_length_t total, f_utf_string_dynamic_t *buffer) { #ifndef _di_level_1_parameter_checking_ if (!file.size_read) return F_status_set_error(F_parameter); if (buffer->used > buffer->size) return F_status_set_error(F_parameter); @@ -142,8 +142,8 @@ extern "C" { uint8_t width = 0; int8_t width_last = -1; - f_utf_string_length_t buffer_size = file.size_read; - f_utf_string_length_t buffer_count = 0; + f_string_length_t buffer_size = file.size_read; + f_string_length_t buffer_count = 0; if (total < buffer_size) { buffer_size = total; @@ -195,7 +195,7 @@ extern "C" { #endif // _di_fl_utf_file_read_until_ #ifndef _di_fl_utf_file_write_ - f_status_t fl_utf_file_write(const f_file_t file, const f_utf_string_static_t buffer, f_utf_string_length_t *written) { + f_status_t fl_utf_file_write(const f_file_t file, const f_utf_string_static_t buffer, f_string_length_t *written) { #ifndef _di_level_0_parameter_checking_ if (!file.size_write) return F_status_set_error(F_parameter); if (buffer.used > buffer.size) return F_status_set_error(F_parameter); @@ -219,7 +219,7 @@ extern "C" { #endif // _di_fl_utf_file_write_ #ifndef _di_fl_utf_file_write_block_ - f_status_t fl_utf_file_write_block(const f_file_t file, const f_utf_string_static_t buffer, f_utf_string_length_t *written) { + f_status_t fl_utf_file_write_block(const f_file_t file, const f_utf_string_static_t buffer, f_string_length_t *written) { #ifndef _di_level_0_parameter_checking_ if (!file.size_write) return F_status_set_error(F_parameter); if (buffer.used > buffer.size) return F_status_set_error(F_parameter); @@ -233,7 +233,7 @@ extern "C" { return F_data_not; } - f_utf_string_length_t write_max = file.size_write; + f_string_length_t write_max = file.size_write; if (write_max > buffer.used) { write_max = buffer.used; @@ -249,7 +249,7 @@ extern "C" { #endif // _di_fl_utf_file_write_block_ #ifndef _di_fl_utf_file_write_until_ - f_status_t fl_utf_file_write_until(const f_file_t file, const f_utf_string_static_t buffer, const f_utf_string_length_t total, f_utf_string_length_t *written) { + f_status_t fl_utf_file_write_until(const f_file_t file, const f_utf_string_static_t buffer, const f_string_length_t total, f_string_length_t *written) { #ifndef _di_level_0_parameter_checking_ if (!file.size_write) return F_status_set_error(F_parameter); if (buffer.used > buffer.size) return F_status_set_error(F_parameter); @@ -263,7 +263,7 @@ extern "C" { return F_data_not; } - f_utf_string_length_t write_max = file.size_write; + f_string_length_t write_max = file.size_write; if (write_max > buffer.used) { write_max = buffer.used; @@ -279,7 +279,7 @@ extern "C" { #endif // _di_fl_utf_file_write_until_ #ifndef _di_fl_utf_file_write_range_ - f_status_t fl_utf_file_write_range(const f_file_t file, const f_utf_string_static_t buffer, const f_utf_string_range_t range, f_utf_string_length_t *written) { + f_status_t fl_utf_file_write_range(const f_file_t file, const f_utf_string_static_t buffer, const f_utf_string_range_t range, f_string_length_t *written) { #ifndef _di_level_0_parameter_checking_ if (!file.size_write) return F_status_set_error(F_parameter); if (buffer.used > buffer.size) return F_status_set_error(F_parameter); @@ -295,8 +295,8 @@ extern "C" { return F_data_not; } - const f_utf_string_length_t total = (range.stop - range.start) + 1; - f_utf_string_length_t write_max = total; + const f_string_length_t total = (range.stop - range.start) + 1; + f_string_length_t write_max = total; if (write_max > buffer.used) { write_max = buffer.used; diff --git a/level_1/fl_utf_file/c/utf_file.h b/level_1/fl_utf_file/c/utf_file.h index 85c08ec..3900ffc 100644 --- a/level_1/fl_utf_file/c/utf_file.h +++ b/level_1/fl_utf_file/c/utf_file.h @@ -122,7 +122,7 @@ extern "C" { * @see read() */ #ifndef _di_fl_utf_file_read_until_ - extern f_status_t fl_utf_file_read_until(const f_file_t file, const f_utf_string_length_t total, f_utf_string_dynamic_t *buffer); + extern f_status_t fl_utf_file_read_until(const f_file_t file, const f_string_length_t total, f_utf_string_dynamic_t *buffer); #endif // _di_fl_utf_file_read_until_ /** @@ -154,7 +154,7 @@ extern "C" { * @see write() */ #ifndef _di_fl_utf_file_write_ - extern f_status_t fl_utf_file_write(const f_file_t file, const f_utf_string_static_t buffer, f_utf_string_length_t *written); + extern f_status_t fl_utf_file_write(const f_file_t file, const f_utf_string_static_t buffer, f_string_length_t *written); #endif // _di_fl_utf_file_write_ /** @@ -188,7 +188,7 @@ extern "C" { * @see write() */ #ifndef _di_fl_utf_file_write_block_ - extern f_status_t fl_utf_file_write_block(const f_file_t file, const f_utf_string_static_t buffer, f_utf_string_length_t *written); + extern f_status_t fl_utf_file_write_block(const f_file_t file, const f_utf_string_static_t buffer, f_string_length_t *written); #endif // _di_fl_utf_file_write_block_ /** @@ -222,7 +222,7 @@ extern "C" { * @see write() */ #ifndef _di_fl_utf_file_write_until_ - extern f_status_t fl_utf_file_write_until(const f_file_t file, const f_utf_string_static_t buffer, const f_utf_string_length_t total, f_utf_string_length_t *written); + extern f_status_t fl_utf_file_write_until(const f_file_t file, const f_utf_string_static_t buffer, const f_string_length_t total, f_string_length_t *written); #endif // _di_fl_utf_file_write_until_ /** @@ -256,7 +256,7 @@ extern "C" { * @see write() */ #ifndef _di_fl_utf_file_write_range_ - extern f_status_t fl_utf_file_write_range(const f_file_t file, const f_utf_string_static_t buffer, const f_utf_string_range_t range, f_utf_string_length_t *written); + extern f_status_t fl_utf_file_write_range(const f_file_t file, const f_utf_string_static_t buffer, const f_utf_string_range_t range, f_string_length_t *written); #endif // _di_fl_utf_file_write_range_ #ifdef __cplusplus diff --git a/level_2/fll_program/data/build/dependencies b/level_2/fll_program/data/build/dependencies index 6518702..6ae2734 100644 --- a/level_2/fll_program/data/build/dependencies +++ b/level_2/fll_program/data/build/dependencies @@ -7,4 +7,3 @@ f_string f_utf f_console fl_color -fl_string diff --git a/level_2/fll_program/data/build/settings b/level_2/fll_program/data/build/settings index 7bf54a1..b1ac316 100644 --- a/level_2/fll_program/data/build/settings +++ b/level_2/fll_program/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfl_color -lfl_string -lf_color -lf_console -lf_file -lf_memory -lf_print -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfl_color -lf_color -lf_console -lf_file -lf_memory -lf_print -lf_string -lf_type_array -lf_utf build_sources_library program.c build_sources_program build_sources_headers program.h diff --git a/level_3/byte_dump/c/private-byte_dump.c b/level_3/byte_dump/c/private-byte_dump.c index a326b37..693d070 100644 --- a/level_3/byte_dump/c/private-byte_dump.c +++ b/level_3/byte_dump/c/private-byte_dump.c @@ -27,7 +27,7 @@ extern "C" { // Store the current character data until it can be printed. f_utf_string_dynamic_t characters = f_utf_string_dynamic_t_initialize; f_utf_character_t character_array[data.width]; - f_utf_string_length_t character_current = 0; + f_string_length_t character_current = 0; // The row starts based on the first byte starting point and how many columns of bytes are displayed per row. if (data.first > 0) { @@ -240,7 +240,7 @@ extern "C" { bool reset = F_false; - f_utf_string_length_t character_current = characters.used - 1; + f_string_length_t character_current = characters.used - 1; if (byte_current == 1) { byte = f_macro_utf_character_t_to_char_1(characters.string[character_current]); diff --git a/level_3/byte_dump/data/build/dependencies b/level_3/byte_dump/data/build/dependencies index 5b7965d..e88ed86 100644 --- a/level_3/byte_dump/data/build/dependencies +++ b/level_3/byte_dump/data/build/dependencies @@ -14,7 +14,5 @@ f_print fl_color fl_console fl_conversion -fl_string -fl_utf fll_error fll_program diff --git a/level_3/byte_dump/data/build/settings b/level_3/byte_dump/data/build/settings index d827471..4bf00f7 100644 --- a/level_3/byte_dump/data/build/settings +++ b/level_3/byte_dump/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_program -lfl_color -lfl_console -lfl_conversion -lfl_string -lfl_utf -lf_color -lf_console -lf_conversion -lf_file -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_program -lfl_color -lfl_console -lfl_conversion -lf_color -lf_console -lf_conversion -lf_file -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library byte_dump.c private-byte_dump.c diff --git a/level_3/control/data/build/dependencies b/level_3/control/data/build/dependencies index 3b53a6c..7aeed1c 100644 --- a/level_3/control/data/build/dependencies +++ b/level_3/control/data/build/dependencies @@ -12,7 +12,5 @@ f_pipe f_print fl_color fl_console -fl_string fll_error fll_program -fll_status diff --git a/level_3/control/data/build/settings b/level_3/control/data/build/settings index cf9682f..91f8468 100644 --- a/level_3/control/data/build/settings +++ b/level_3/control/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_program -lfll_status -lfl_color -lfl_console -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_file -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_program -lfl_color -lfl_console -lf_color -lf_console -lf_conversion -lf_file -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library control.c private-control.c diff --git a/level_3/controller/data/build/dependencies b/level_3/controller/data/build/dependencies index 795b0d9..cca5649 100644 --- a/level_3/controller/data/build/dependencies +++ b/level_3/controller/data/build/dependencies @@ -37,4 +37,3 @@ fll_execute fll_fss fll_path fll_program -fll_status diff --git a/level_3/controller/data/build/settings b/level_3/controller/data/build/settings index c62035e..ce9f015 100644 --- a/level_3/controller/data/build/settings +++ b/level_3/controller/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -lcap -build_libraries-individual -lfll_control_group -lfll_error -lfll_execute -lfll_fss -lfll_path -lfll_program -lfll_status -lfl_color -lfl_console -lfl_control_group -lfl_conversion -lfl_directory -lfl_environment -lfl_fss -lfl_iki -lfl_status -lfl_string -lf_account -lf_capability -lf_color -lf_console -lf_control_group -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_iki -lf_limit -lf_memory -lf_path -lf_pipe -lf_print -lf_signal -lf_string -lf_thread -lf_type_array -lf_utf +build_libraries-individual -lfll_control_group -lfll_error -lfll_execute -lfll_fss -lfll_path -lfll_program -lfl_color -lfl_console -lfl_control_group -lfl_conversion -lfl_directory -lfl_environment -lfl_fss -lfl_iki -lfl_status -lfl_string -lf_account -lf_capability -lf_color -lf_console -lf_control_group -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_iki -lf_limit -lf_memory -lf_path -lf_pipe -lf_print -lf_signal -lf_string -lf_thread -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library controller.c private-control.c private-controller.c private-entry.c private-rule.c diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index a32012c..67c7af7 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -1449,7 +1449,7 @@ extern "C" { *status = f_string_dynamic_terminate_after(&arguments->array[arguments->used]); if (F_status_is_error(*status)) { - fll_error_print(data_make->error, F_status_set_fine(*status), "fl_string_terminate_after", F_true); + fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_terminate_after", F_true); break; } @@ -1507,7 +1507,7 @@ extern "C" { *status = f_string_dynamic_terminate_after(&arguments->array[arguments->used - 1]); if (F_status_is_error(*status)) { - fll_error_print(data_make->error, F_status_set_fine(*status), "fl_string_terminate_after", F_true); + fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_terminate_after", F_true); break; } } @@ -1533,7 +1533,7 @@ extern "C" { *status = f_string_dynamic_terminate_after(&arguments->array[arguments->used]); if (F_status_is_error(*status)) { - fll_error_print(data_make->error, F_status_set_fine(*status), "fl_string_terminate_after", F_true); + fll_error_print(data_make->error, F_status_set_fine(*status), "f_string_terminate_after", F_true); break; } diff --git a/level_3/fake/data/build/dependencies b/level_3/fake/data/build/dependencies index 7a1f748..9c579ce 100644 --- a/level_3/fake/data/build/dependencies +++ b/level_3/fake/data/build/dependencies @@ -30,7 +30,6 @@ fl_fss fl_iki fl_status fl_string -fl_utf fll_error fll_execute fll_file diff --git a/level_3/fake/data/build/settings b/level_3/fake/data/build/settings index 84decdc..76a2994 100644 --- a/level_3/fake/data/build/settings +++ b/level_3/fake/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -lcap -build_libraries-individual -lfll_error -lfll_execute -lfll_file -lfll_fss -lfll_path -lfll_program -lfl_color -lfl_console -lfl_control_group -lfl_conversion -lfl_directory -lfl_environment -lfl_fss -lfl_iki -lfl_status -lfl_string -lfl_utf -lf_account -lf_capability -lf_color -lf_console -lf_control_group -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_iki -lf_limit -lf_memory -lf_path -lf_print -lf_signal -lf_string -lf_thread -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_execute -lfll_file -lfll_fss -lfll_path -lfll_program -lfl_color -lfl_console -lfl_control_group -lfl_conversion -lfl_directory -lfl_environment -lfl_fss -lfl_iki -lfl_status -lfl_string -lf_account -lf_capability -lf_color -lf_console -lf_control_group -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_iki -lf_limit -lf_memory -lf_path -lf_print -lf_signal -lf_string -lf_thread -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fake.c private-fake.c private-clean.c private-build.c private-make.c private-print.c private-skeleton.c diff --git a/level_3/fss_basic_list_write/data/build/dependencies b/level_3/fss_basic_list_write/data/build/dependencies index df503dc..fe0deee 100644 --- a/level_3/fss_basic_list_write/data/build/dependencies +++ b/level_3/fss_basic_list_write/data/build/dependencies @@ -18,7 +18,6 @@ fl_console fl_conversion fl_fss fl_status -fl_string fll_error fll_file fll_fss diff --git a/level_3/fss_basic_write/data/build/dependencies b/level_3/fss_basic_write/data/build/dependencies index df503dc..fe0deee 100644 --- a/level_3/fss_basic_write/data/build/dependencies +++ b/level_3/fss_basic_write/data/build/dependencies @@ -18,7 +18,6 @@ fl_console fl_conversion fl_fss fl_status -fl_string fll_error fll_file fll_fss diff --git a/level_3/fss_embedded_list_write/data/build/dependencies b/level_3/fss_embedded_list_write/data/build/dependencies index df503dc..fe0deee 100644 --- a/level_3/fss_embedded_list_write/data/build/dependencies +++ b/level_3/fss_embedded_list_write/data/build/dependencies @@ -18,7 +18,6 @@ fl_console fl_conversion fl_fss fl_status -fl_string fll_error fll_file fll_fss diff --git a/level_3/fss_extended_list_write/data/build/dependencies b/level_3/fss_extended_list_write/data/build/dependencies index df503dc..fe0deee 100644 --- a/level_3/fss_extended_list_write/data/build/dependencies +++ b/level_3/fss_extended_list_write/data/build/dependencies @@ -18,7 +18,6 @@ fl_console fl_conversion fl_fss fl_status -fl_string fll_error fll_file fll_fss diff --git a/level_3/fss_extended_write/data/build/dependencies b/level_3/fss_extended_write/data/build/dependencies index 1f1706b..779e9c9 100644 --- a/level_3/fss_extended_write/data/build/dependencies +++ b/level_3/fss_extended_write/data/build/dependencies @@ -17,7 +17,6 @@ fl_color fl_conversion fl_fss fl_status -fl_string fll_error fll_file fll_fss diff --git a/level_3/fss_status_code/data/build/dependencies b/level_3/fss_status_code/data/build/dependencies index 6b134dd..def0f70 100644 --- a/level_3/fss_status_code/data/build/dependencies +++ b/level_3/fss_status_code/data/build/dependencies @@ -19,8 +19,6 @@ fl_console fl_conversion fl_fss fl_status -fl_string -fl_utf fll_error fll_file fll_fss diff --git a/level_3/fss_status_code/data/build/settings b/level_3/fss_status_code/data/build/settings index d8d1558..47705c5 100644 --- a/level_3/fss_status_code/data/build/settings +++ b/level_3/fss_status_code/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_program -lfll_status -lfl_color -lfl_console -lfl_conversion -lfl_directory -lfl_fss -lfl_status -lfl_string -lfl_utf -lf_color -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_file -lfll_fss -lfll_program -lfll_status -lfl_color -lfl_console -lfl_conversion -lfl_directory -lfl_fss -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_directory -lf_environment -lf_file -lf_fss -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library fss_status_code.c private-fss_status_code.c diff --git a/level_3/iki_write/c/iki_write.c b/level_3/iki_write/c/iki_write.c index 6787ceb..29ad661 100644 --- a/level_3/iki_write/c/iki_write.c +++ b/level_3/iki_write/c/iki_write.c @@ -287,17 +287,17 @@ extern "C" { } previous = range.start; - status = fl_string_dynamic_seek_line(buffer.string, &range); + status = f_string_dynamic_seek_line(buffer.string, &range); if (F_status_is_error(status)) { - fll_error_print(data->error, F_status_set_fine(status), "fl_string_dynamic_seek_line", F_true); + fll_error_print(data->error, F_status_set_fine(status), "f_string_dynamic_seek_line", F_true); break; } if (status == F_data_not_stop) { status = F_status_set_error(F_parameter); - fll_error_print(data->error, F_parameter, "fl_string_dynamic_seek_line", F_true); + fll_error_print(data->error, F_parameter, "f_string_dynamic_seek_line", F_true); break; } diff --git a/level_3/iki_write/data/build/dependencies b/level_3/iki_write/data/build/dependencies index d92f738..31135ac 100644 --- a/level_3/iki_write/data/build/dependencies +++ b/level_3/iki_write/data/build/dependencies @@ -14,7 +14,6 @@ f_print fl_color fl_console fl_iki -fl_string fll_iki fll_error fll_program diff --git a/level_3/iki_write/data/build/settings b/level_3/iki_write/data/build/settings index b62ba53..1240482 100644 --- a/level_3/iki_write/data/build/settings +++ b/level_3/iki_write/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_iki -lfll_program -lfl_color -lfl_console -lfl_iki -lfl_string -lf_color -lf_console -lf_conversion -lf_file -lf_iki -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_iki -lfll_program -lfl_color -lfl_console -lfl_iki -lf_color -lf_console -lf_conversion -lf_file -lf_iki -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library iki_write.c private-iki_write.c diff --git a/level_3/init/data/build/dependencies b/level_3/init/data/build/dependencies index 0de85e9..55647b2 100644 --- a/level_3/init/data/build/dependencies +++ b/level_3/init/data/build/dependencies @@ -18,4 +18,3 @@ fl_iki fl_string fll_error fll_program -fll_status diff --git a/level_3/init/data/build/settings b/level_3/init/data/build/settings index c670027..16b22fc 100644 --- a/level_3/init/data/build/settings +++ b/level_3/init/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_program -lfll_status -lfl_color -lfl_conversion -lfl_iki -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_file -lf_iki -lf_memory -lf_print -lf_signal -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_program -lfl_color -lfl_conversion -lfl_iki -lfl_string -lf_color -lf_console -lf_conversion -lf_file -lf_iki -lf_memory -lf_print -lf_signal -lf_string -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library init.c private-init.c diff --git a/level_3/status_code/data/build/dependencies b/level_3/status_code/data/build/dependencies index 9e6b577..8057a39 100644 --- a/level_3/status_code/data/build/dependencies +++ b/level_3/status_code/data/build/dependencies @@ -15,8 +15,6 @@ fl_color fl_console fl_conversion fl_status -fl_string -fl_utf fll_error fll_program fll_status diff --git a/level_3/status_code/data/build/settings b/level_3/status_code/data/build/settings index 0afe008..78db2f0 100644 --- a/level_3/status_code/data/build/settings +++ b/level_3/status_code/data/build/settings @@ -19,7 +19,7 @@ build_compiler gcc build_indexer ar build_language c build_libraries -lc -build_libraries-individual -lfll_error -lfll_program -lfll_status -lfl_color -lfl_console -lfl_conversion -lfl_status -lfl_string -lfl_utf -lf_color -lf_console -lf_conversion -lf_file -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf +build_libraries-individual -lfll_error -lfll_program -lfll_status -lfl_color -lfl_console -lfl_conversion -lfl_status -lfl_string -lf_color -lf_console -lf_conversion -lf_file -lf_memory -lf_path -lf_pipe -lf_print -lf_string -lf_type_array -lf_utf build_libraries-level -lfll_2 -lfll_1 -lfll_0 build_libraries-monolithic -lfll build_sources_library status_code.c private-status_code.c -- 1.8.3.1