From 12fac9bc849814b759271060ca5cf2c1a82e63a0 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 14 Mar 2021 19:46:12 -0500 Subject: [PATCH] Update: update utf string with string changes and fix problems with string. Synchronize the utf string with the latest string changes. I noticed that some of the disable macros are not used and should be for the private functions. The *seek* functions needed to be fixed in string. Add a missing *seek* function. --- level_0/f_string/c/private-string.c | 24 +- level_0/f_string/c/private-string.h | 81 +++- level_0/f_string/c/string.c | 38 +- level_0/f_string/c/string.h | 22 + level_0/f_string/c/string_dynamic.c | 29 +- level_0/f_string/c/string_dynamic.h | 34 +- level_0/f_utf/c/private-utf.c | 123 ++++- level_0/f_utf/c/private-utf.h | 203 +++++--- level_0/f_utf/c/utf.c | 926 ++++++------------------------------ level_0/f_utf/c/utf.h | 817 ++++--------------------------- level_0/f_utf/c/utf_dynamic.c | 720 +++++++++++++++++++++++++++- level_0/f_utf/c/utf_dynamic.h | 845 +++++++++++++++++++++++++++++++- level_0/f_utf/c/utf_map.c | 68 +++ level_0/f_utf/c/utf_map.h | 106 ++++- level_0/f_utf/c/utf_quantity.c | 25 + level_0/f_utf/c/utf_quantity.h | 62 ++- level_0/f_utf/c/utf_range.c | 25 + level_0/f_utf/c/utf_range.h | 57 ++- level_0/f_utf/c/utf_triple.c | 43 +- level_0/f_utf/c/utf_triple.h | 38 +- level_3/iki_write/c/iki_write.c | 2 +- 21 files changed, 2549 insertions(+), 1739 deletions(-) diff --git a/level_0/f_string/c/private-string.c b/level_0/f_string/c/private-string.c index 1ebfe7d..d5b7dc5 100644 --- a/level_0/f_string/c/private-string.c +++ b/level_0/f_string/c/private-string.c @@ -5,7 +5,7 @@ extern "C" { #endif -#if !defined(_di_f_string_append_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_mash_) || !defined(f_string_map_multis_append) || !defined(f_string_maps_append) +#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_mash_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_triples_append_) f_status_t private_f_string_append(const f_string_t source, const f_array_length_t length, f_string_dynamic_t *destination) { if (destination->used + length > destination->size) { @@ -18,9 +18,9 @@ extern "C" { return F_none; } -#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_mash_) || !defined(f_string_map_multis_append) || !defined(f_string_maps_append) +#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_mash_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_triples_append_) -#if !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_append_assure_nulless_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_assure_nulless_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_string_dynamic_partial_append_nulless_) || !defined(_di_f_string_dynamic_partial_mash_nulless_) || !defined(_di_f_string_mash_nulless_) f_status_t private_f_string_append_nulless(const f_string_t source, const f_array_length_t length, f_string_dynamic_t *destination) { if (destination->used + length > f_array_length_t_size) { @@ -70,9 +70,9 @@ extern "C" { return F_none; } -#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_) +#endif // !defined(_di_f_string_append_assure_nulless_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_assure_nulless_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_string_dynamic_partial_append_nulless_) || !defined(_di_f_string_dynamic_partial_mash_nulless_) || !defined(_di_f_string_mash_nulless_) -#if !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) +#if !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) f_status_t private_f_string_dynamic_adjust(const f_array_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); @@ -87,9 +87,9 @@ extern "C" { return status; } -#endif // !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) +#endif // !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_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_) +#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) f_status_t private_f_string_dynamic_increase_by(const f_array_length_t amount, f_string_dynamic_t *dynamic) { if (dynamic->used + amount > dynamic->size) { @@ -102,9 +102,9 @@ extern "C" { return F_data_not; } -#endif // !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_) +#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) -#if !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) +#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) f_status_t private_f_string_dynamic_resize(const f_array_length_t length, f_string_dynamic_t *dynamic) { const f_status_t status = f_memory_resize(dynamic->size, length, sizeof(f_string_t), (void **) & dynamic->string); @@ -119,9 +119,9 @@ extern "C" { return status; } -#endif // !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) +#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) -#if !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_decimate_by_) +#if !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) f_status_t private_f_string_dynamics_adjust(const f_array_length_t length, f_string_dynamics_t *dynamics) { if (dynamics->used + length > f_array_length_t_size) { @@ -147,7 +147,7 @@ extern "C" { return status; } -#endif // !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_decimate_by_) +#endif // !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) #if !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) f_status_t private_f_string_dynamics_append(const f_string_dynamics_t source, f_string_dynamics_t *destination) { diff --git a/level_0/f_string/c/private-string.h b/level_0/f_string/c/private-string.h index cade35e..f5249ba 100644 --- a/level_0/f_string/c/private-string.h +++ b/level_0/f_string/c/private-string.h @@ -37,15 +37,22 @@ extern "C" { * @see memcpy() * * @see f_string_append() + * @see f_string_append_assure() * @see f_string_dynamic_append() + * @see f_string_dynamic_append_assure() * @see f_string_dynamic_mash() + * @see f_string_dynamic_partial_append) + * @see f_string_dynamic_partial_append_assure() + * @see f_string_dynamic_partial_mash() + * @see f_string_dynamics_append() * @see f_string_map_multis_append() - * @see f_string_maps_append() * @see f_string_mash() + * @see f_string_maps_append() + * @see f_string_triples_append() */ -#if !defined(_di_f_string_append_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_mash_) || !defined(f_string_map_multis_append) || !defined(f_string_maps_append) +#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_mash_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_triples_append_) extern f_status_t private_f_string_append(const f_string_t source, const f_array_length_t length, f_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; -#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_mash_) || !defined(f_string_map_multis_append) || !defined(f_string_maps_append) +#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_mash_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_triples_append_) /** * Private implementation of f_string_append_nulless(). @@ -66,15 +73,19 @@ extern "C" { * * @see memcpy() * - * @see f_macro_string_dynamic_t_resize() + * @see f_string_append_assure_nulless() * @see f_string_append_nulless() + * @see f_string_dynamic_append_assure_nulless() * @see f_string_dynamic_append_nulless() * @see f_string_dynamic_mash_nulless() + * @see f_string_dynamic_partial_append_assure_nulless() + * @see f_string_dynamic_partial_append_nulless() + * @see f_string_dynamic_partial_mash_nulless() * @see f_string_mash_nulless() */ -#if !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_append_assure_nulless_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_assure_nulless_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_string_dynamic_partial_append_nulless_) || !defined(_di_f_string_dynamic_partial_mash_nulless_) || !defined(_di_f_string_mash_nulless_) extern f_status_t private_f_string_append_nulless(const f_string_t source, const f_array_length_t length, f_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; -#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_) +#endif // !defined(_di_f_string_append_assure_nulless_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_assure_nulless_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_string_dynamic_partial_append_nulless_) || !defined(_di_f_string_dynamic_partial_mash_nulless_) || !defined(_di_f_string_mash_nulless_) /** * Private implementation for resizing. @@ -94,10 +105,17 @@ extern "C" { * @see f_memory_adjust() * @see f_string_dynamic_adjust() * @see f_string_dynamic_decimate_by() + * @see f_string_dynamics_adjust() + * @see f_string_dynamics_append() + * @see f_string_dynamics_decimate_by() + * @see f_string_map_multis_adjust() + * @see f_string_map_multis_append() + * @see f_string_triples_adjust() + * @see f_string_triples_decimate_by() */ -#if !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) +#if !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) extern f_status_t private_f_string_dynamic_adjust(const f_array_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_) +#endif // !defined(_di_f_string_dynamic_adjust_) || !defined(_di_f_string_dynamic_decimate_by_) || !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_triples_adjust_) || !defined(_di_f_string_triples_decimate_by_) /** * Private implementation of f_string_dynamic_increase_by(). @@ -120,22 +138,32 @@ extern "C" { * @see memcpy() * * @see f_string_append() + * @see f_string_append_assure() * @see f_string_append_mash() * @see f_string_append_nulless() * @see f_string_dynamic_append() + * @see f_string_dynamic_append_assure() * @see f_string_dynamic_append_nulless() * @see f_string_dynamic_increase_by() * @see f_string_dynamic_mash() * @see f_string_dynamic_mash_nulless() + * @see f_string_dynamic_partial_append) + * @see f_string_dynamic_partial_append_assure() + * @see f_string_dynamic_partial_mash() * @see f_string_dynamic_prepend() * @see f_string_dynamic_prepend_nulless() + * @see f_string_dynamics_append() + * @see f_string_map_multis_append() + * @see f_string_mash() * @see f_string_mash_nulless() + * @see f_string_maps_append() * @see f_string_prepend() * @see f_string_prepend_nulless() + * @see f_string_triples_append() */ -#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_) +#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) extern f_status_t private_f_string_dynamic_increase_by(const f_array_length_t amount, f_string_dynamic_t *string) f_gcc_attribute_visibility_internal; -#endif // !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_) +#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(_di_f_string_dynamic_partial_append_) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) /** * Private implementation for resizing. @@ -153,15 +181,37 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). * * @see f_memory_resize() + * @see f_string_append() + * @see f_string_append_assure() + * @see f_string_append_mash() + * @see f_string_append_nulless() + * @see f_string_dynamic_append() + * @see f_string_dynamic_append_assure() + * @see f_string_dynamic_append_nulless() * @see f_string_dynamic_decrease_by() * @see f_string_dynamic_increase() * @see f_string_dynamic_increase_by() + * @see f_string_dynamic_mash() + * @see f_string_dynamic_mash_nulless() + * @see f_string_dynamic_partial_append) + * @see f_string_dynamic_partial_append_assure() + * @see f_string_dynamic_partial_mash() + * @see f_string_dynamic_prepend() + * @see f_string_dynamic_prepend_nulless() * @see f_string_dynamic_terminate() * @see f_string_dynamic_terminate_after() + * @see f_string_dynamics_append() + * @see f_string_map_multis_append() + * @see f_string_mash_nulless() + * @see f_string_mash() + * @see f_string_maps_append() + * @see f_string_prepend() + * @see f_string_prepend_nulless() + * @see f_string_triples_append() */ -#if !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) +#if !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) extern f_status_t private_f_string_dynamic_resize(const f_array_length_t length, f_string_dynamic_t *string) f_gcc_attribute_visibility_internal; -#endif // !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) +#endif // !defined(_di_f_string_append_) || !defined(_di_f_string_append_assure_) || !defined(_di_f_string_append_mash_) || !defined(_di_f_string_append_nulless_) || !defined(_di_f_string_dynamic_append_) || !defined(_di_f_string_dynamic_append_assure_) || !defined(_di_f_string_dynamic_append_nulless_) || !defined(_di_f_string_dynamic_decrease_by_) || !defined(_di_f_string_dynamic_increase_) || !defined(_di_f_string_dynamic_increase_by_) || !defined(_di_f_string_dynamic_mash_) || !defined(_di_f_string_dynamic_mash_nulless_) || !defined(f_string_dynamic_partial_append) || !defined(_di_f_string_dynamic_partial_append_assure_) || !defined(_di_f_string_dynamic_partial_mash_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_dynamic_prepend_nulless_) || !defined(_di_f_string_dynamic_terminate_) || !defined(_di_f_string_dynamic_terminate_after_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_map_multis_append_) || !defined(_di_f_string_mash_nulless_) || !defined(_di_f_string_mash_) || !defined(_di_f_string_maps_append_) || !defined(_di_f_string_prepend_) || !defined(_di_f_string_prepend_nulless_) || !defined(_di_f_string_triples_append_) /** * Private implementation for resizing. @@ -182,11 +232,14 @@ extern "C" { * * @see f_memory_adjust() * @see f_string_dynamics_adjust() + * @see f_string_dynamics_append() * @see f_string_dynamics_decimate_by() + * @see f_string_map_multis_adjust() + * @see f_string_map_multis_append() */ -#if !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_decimate_by_) +#if !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) extern f_status_t private_f_string_dynamics_adjust(const f_array_length_t length, f_string_dynamics_t *strings) f_gcc_attribute_visibility_internal; -#endif // !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_decimate_by_) +#endif // !defined(_di_f_string_dynamics_adjust_) || !defined(_di_f_string_dynamics_append_) || !defined(_di_f_string_dynamics_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) /** * Private implementation for appending. diff --git a/level_0/f_string/c/string.c b/level_0/f_string/c/string.c index 5f10325..a026e54 100644 --- a/level_0/f_string/c/string.c +++ b/level_0/f_string/c/string.c @@ -189,12 +189,16 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!length) return F_data_not_eos; - if (destination->used < length) return private_f_string_prepend(source, length, destination); + + if (destination->used < length) { + return private_f_string_prepend(source, length, destination); + } f_array_length_t i = 0; f_array_length_t j = 0; while (i < length && j < destination->used) { + if (!source[i]) { i++; continue; @@ -205,7 +209,9 @@ extern "C" { continue; } - if (source[i] != destination->string[i]) return private_f_string_prepend(source, length, destination); + if (source[i] != destination->string[i]) { + return private_f_string_prepend(source, length, destination); + } i++; j++; @@ -222,12 +228,16 @@ extern "C" { #endif // _di_level_0_parameter_checking_ if (!length) return F_data_not_eos; - if (destination->used < length) return private_f_string_prepend_nulless(source, length, destination); + + if (destination->used < length) { + return private_f_string_prepend_nulless(source, length, destination); + } f_array_length_t i = 0; f_array_length_t j = 0; while (i < length && j < destination->used) { + if (!source[i]) { i++; continue; @@ -238,7 +248,9 @@ extern "C" { continue; } - if (source[i] != destination->string[i]) return private_f_string_prepend_nulless(source, length, destination); + if (source[i] != destination->string[i]) { + return private_f_string_prepend_nulless(source, length, destination); + } i++; j++; @@ -260,6 +272,24 @@ extern "C" { } #endif // _di_f_string_prepend_nulless_ +#ifndef _di_f_string_seek_line_ + f_status_t f_string_seek_line(const f_string_t string, f_string_range_t *range) { + #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; + + 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_seek_line_ + #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_0_parameter_checking_ diff --git a/level_0/f_string/c/string.h b/level_0/f_string/c/string.h index 76b8b5b..ea289b9 100644 --- a/level_0/f_string/c/string.h +++ b/level_0/f_string/c/string.h @@ -361,6 +361,28 @@ extern "C" { #endif // _di_f_string_prepend_nulless_ /** + * Seek the string 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_stop on success, but the range.start > range.stop. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_seek_line_ + extern f_status_t f_string_seek_line(const f_string_t string, f_string_range_t *range); +#endif // _di_f_string_seek_line_ + +/** * Seek the string location forward until the character (1-byte wide) or EOL is reached. * * @param string diff --git a/level_0/f_string/c/string_dynamic.c b/level_0/f_string/c/string_dynamic.c index d8799fa..ec44020 100644 --- a/level_0/f_string/c/string_dynamic.c +++ b/level_0/f_string/c/string_dynamic.c @@ -648,27 +648,28 @@ extern "C" { #endif // _di_f_string_dynamic_prepend_nulless_ #ifndef _di_f_string_dynamic_resize_ - f_status_t f_string_dynamic_resize(const f_array_length_t length, f_string_dynamic_t *dynamic) { + f_status_t f_string_dynamic_resize(const f_array_length_t length, f_string_dynamic_t *buffer) { #ifndef _di_level_0_parameter_checking_ - if (!dynamic) return F_status_set_error(F_parameter); + if (!buffer) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_string_dynamic_resize(length, dynamic); + return private_f_string_dynamic_resize(length, buffer); } #endif // _di_f_string_dynamic_resize_ #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) { + f_status_t f_string_dynamic_seek_line(const f_string_static_t buffer, f_string_range_t *range) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!string) return F_data_not; + if (!buffer.used) return F_data_not_eos; if (range->start > range->stop) return F_data_not_stop; - while (string[range->start] != f_string_eol_s[0]) { + while (buffer.string[range->start] != f_string_eol_s[0]) { range->start++; + if (range->start >= buffer.used) return F_none_eos; if (range->start > range->stop) return F_none_stop; } // while @@ -677,20 +678,21 @@ extern "C" { #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) { + f_status_t f_string_dynamic_seek_line_to(const f_string_static_t buffer, const int8_t seek_to_this, f_string_range_t *range) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!string) return F_data_not; + if (!buffer.used) return F_data_not_eos; if (range->start > range->stop) return F_data_not_stop; - while (string[range->start] != seek_to_this) { + while (buffer.string[range->start] != seek_to_this) { - if (string[range->start] == f_string_eol_s[0]) return F_none_eol; + if (buffer.string[range->start] == f_string_eol_s[0]) return F_none_eol; range->start++; + if (range->start >= buffer.used) return F_none_eos; if (range->start > range->stop) return F_none_stop; } // while @@ -699,17 +701,18 @@ extern "C" { #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) { + f_status_t f_string_dynamic_seek_to(const f_string_static_t buffer, const int8_t seek_to_this, f_string_range_t *range) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - if (!string) return F_data_not; + if (!buffer.used) return F_data_not_eos; if (range->start > range->stop) return F_data_not_stop; - while (string[range->start] != seek_to_this) { + while (buffer.string[range->start] != seek_to_this) { range->start++; + if (range->start >= buffer.used) return F_none_eos; if (range->start > range->stop) return F_none_stop; } // while diff --git a/level_0/f_string/c/string_dynamic.h b/level_0/f_string/c/string_dynamic.h index 2f4cb23..2f17f1a 100644 --- a/level_0/f_string/c/string_dynamic.h +++ b/level_0/f_string/c/string_dynamic.h @@ -865,7 +865,7 @@ extern "C" { * * @param length * The new size to use. - * @param dynamic + * @param buffer * The string to resize. * * @return @@ -876,22 +876,23 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_string_dynamic_resize_ - extern f_status_t f_string_dynamic_resize(const f_array_length_t length, f_string_dynamic_t *dynamic); + extern f_status_t f_string_dynamic_resize(const f_array_length_t length, f_string_dynamic_t *buffer); #endif // _di_f_string_dynamic_resize_ /** * Seek the buffer location forward until EOL is reached. * - * @param string - * The string to traverse. + * @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. * * @return * F_none on success. + * F_none_eos on success, but stopped at end of string. * 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_eos 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. @@ -899,14 +900,14 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #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); + extern f_status_t f_string_dynamic_seek_line(const f_string_static_t buffer, 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 buffer + * The buffer to traverse. * @param seek_to_this * A single-width character representing a character to seek to. * @param range @@ -915,9 +916,9 @@ extern "C" { * * @return * F_none on success. - * F_none_eol on success, but stopped at EOL. + * F_none_eos on success, but stopped at end of string. * 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_eos 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. @@ -925,14 +926,14 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #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); + extern f_status_t f_string_dynamic_seek_line_to(const f_string_static_t buffer, 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 buffer + * The buffer to traverse. * @param seek_to_this * A single-width character representing a character to seek to. * @param range @@ -941,18 +942,17 @@ extern "C" { * * @return * F_none on success. + * F_none_eos on success, but stopped at end of string. * 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_eos 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. * * Errors (with error bit) from: f_memory_resize(). */ #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); + extern f_status_t f_string_dynamic_seek_to(const f_string_static_t buffer, const int8_t seek_to_this, f_string_range_t *range); #endif // _di_f_string_dynamic_seek_to_ /** diff --git a/level_0/f_utf/c/private-utf.c b/level_0/f_utf/c/private-utf.c index f03f6ba..dbbffc0 100644 --- a/level_0/f_utf/c/private-utf.c +++ b/level_0/f_utf/c/private-utf.c @@ -2212,7 +2212,7 @@ 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_) +#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_triples_append_) f_status_t private_f_utf_string_append(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination) { if (destination->used + length > destination->size) { @@ -2225,9 +2225,9 @@ extern "C" { 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_) +#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_triples_append_) -#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_) +#if !defined(_di_f_utf_string_append_assure_nulless_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_nulless_) || !defined(_di_f_utf_string_dynamic_partial_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_array_length_t length, f_utf_string_dynamic_t *destination) { if (destination->used + length > f_array_length_t_size) { @@ -2277,9 +2277,9 @@ extern "C" { 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_) +#endif // !defined(_di_f_utf_string_append_assure_nulless_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_nulless_) || !defined(_di_f_utf_string_dynamic_partial_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_) +#if !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) || !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) f_status_t private_f_utf_string_dynamic_adjust(const f_array_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); @@ -2294,9 +2294,9 @@ extern "C" { return status; } -#endif // !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) +#endif // !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) || !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_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_) +#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) f_status_t private_f_utf_string_dynamic_increase_by(const f_array_length_t amount, f_utf_string_dynamic_t *dynamic) { if (dynamic->used + amount > dynamic->size) { @@ -2309,9 +2309,9 @@ extern "C" { 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_) +#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) -#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_) +#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !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_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) f_status_t private_f_utf_string_dynamic_resize(const f_array_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); @@ -2326,10 +2326,15 @@ extern "C" { 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_) +#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !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_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) -#if !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_decimate_by_) +#if !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) f_status_t private_f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t *dynamics) { + + if (dynamics->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + f_status_t status = F_none; for (f_array_length_t i = length; i < dynamics->size; ++i) { @@ -2349,10 +2354,38 @@ extern "C" { return status; } -#endif // !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_decimate_by_) +#endif // !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + +#if !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) + f_status_t private_f_utf_string_dynamics_append(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t *destination) { + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_dynamics_adjust(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].used = 0; + + if (source.array[i].used) { + status = private_f_utf_string_append(source.array[i].string, source.array[i].used, &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) #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_array_length_t length, f_utf_string_dynamics_t *dynamics) { + + if (dynamics->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + f_status_t status = F_none; for (f_array_length_t i = length; i < dynamics->size; ++i) { @@ -2376,6 +2409,11 @@ extern "C" { #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_array_length_t length, f_utf_string_map_multis_t *map_multis) { + + if (map_multis->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + f_status_t status = F_none; for (f_array_length_t i = length; i < map_multis->size; ++i) { @@ -2403,6 +2441,11 @@ extern "C" { #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_array_length_t length, f_utf_string_map_multis_t *map_multis) { + + if (map_multis->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + f_status_t status = F_none; for (f_array_length_t i = length; i < map_multis->size; ++i) { @@ -2430,6 +2473,11 @@ extern "C" { #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_array_length_t length, f_utf_string_maps_t *maps) { + + if (maps->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + f_status_t status = F_none; for (f_array_length_t i = length; i < maps->size; ++i) { @@ -2457,6 +2505,11 @@ extern "C" { #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_array_length_t length, f_utf_string_maps_t *maps) { + + if (maps->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + f_status_t status = F_none; for (f_array_length_t i = length; i < maps->size; ++i) { @@ -2576,6 +2629,10 @@ extern "C" { #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_array_length_t length, f_utf_string_quantitys_t *quantitys) { + if (quantitys->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + 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)) { @@ -2593,6 +2650,10 @@ extern "C" { #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_array_length_t length, f_utf_string_quantitys_t *quantitys) { + if (quantitys->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + 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)) { @@ -2609,6 +2670,11 @@ extern "C" { #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_array_length_t length, f_utf_string_quantityss_t *quantityss) { + + if (quantityss->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + f_status_t status = F_none; for (f_array_length_t i = length; i < quantityss->size; ++i) { @@ -2632,6 +2698,11 @@ extern "C" { #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_array_length_t length, f_utf_string_quantityss_t *quantityss) { + + if (quantityss->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + f_status_t status = F_none; for (f_array_length_t i = length; i < quantityss->size; ++i) { @@ -2656,6 +2727,10 @@ extern "C" { #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_array_length_t length, f_utf_string_ranges_t *ranges) { + if (ranges->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + 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)) { @@ -2673,6 +2748,10 @@ extern "C" { #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_array_length_t length, f_utf_string_ranges_t *ranges) { + if (ranges->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + 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)) { @@ -2689,6 +2768,11 @@ extern "C" { #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_array_length_t length, f_utf_string_rangess_t *rangess) { + + if (rangess->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + f_status_t status = F_none; for (f_array_length_t i = length; i < rangess->size; ++i) { @@ -2712,6 +2796,11 @@ extern "C" { #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_array_length_t length, f_utf_string_rangess_t *rangess) { + + if (rangess->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + f_status_t status = F_none; for (f_array_length_t i = length; i < rangess->size; ++i) { @@ -2735,6 +2824,11 @@ extern "C" { #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_array_length_t length, f_utf_string_triples_t *triples) { + + if (triples->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + f_status_t status = F_none; for (f_array_length_t i = length; i < triples->size; ++i) { @@ -2765,6 +2859,11 @@ extern "C" { #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_array_length_t length, f_utf_string_triples_t *triples) { + + if (triples->used + length > f_array_length_t_size) { + return F_status_set_error(F_array_too_large); + } + f_status_t status = F_none; for (f_array_length_t i = length; i < triples->size; ++i) { diff --git a/level_0/f_utf/c/private-utf.h b/level_0/f_utf/c/private-utf.h index a002da5..5d42b70 100644 --- a/level_0/f_utf/c/private-utf.h +++ b/level_0/f_utf/c/private-utf.h @@ -549,28 +549,30 @@ extern "C" { * * @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. + * 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(). + * Errors (with error bit) from: f_memory_resize(). * * @see memcpy() * * @see f_utf_string_append() + * @see f_utf_string_append_assure() * @see f_utf_string_dynamic_append() + * @see f_utf_string_dynamic_append_assure() * @see f_utf_string_dynamic_mash() + * @see f_utf_string_dynamic_partial_append) + * @see f_utf_string_dynamic_partial_append_assure() + * @see f_utf_string_dynamic_partial_mash() + * @see f_utf_string_dynamics_append() + * @see f_utf_string_map_multis_append() * @see f_utf_string_mash() - * - * @see private_f_utf_string_dynamic_increase_by() + * @see f_utf_string_maps_append() + * @see f_utf_string_triples_append() */ -#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_) +#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_triples_append_) extern f_status_t private_f_utf_string_append(const f_utf_string_t source, const f_array_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_) +#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_triples_append_) /** * Private implementation of f_utf_string_append_nulless(). @@ -587,21 +589,23 @@ extern "C" { * @return * F_none on success. * - * Errors (with error bit) from: private_f_utf_string_dynamic_increase_by(). + * F_string_too_large (with error bit) if the combined string is too large. * * @see memcpy() * - * @see f_macro_utf_string_dynamic_t_resize() + * @see f_utf_string_append_assure_nulless() * @see f_utf_string_append_nulless() + * @see f_utf_string_dynamic_append_assure_nulless() * @see f_utf_string_dynamic_append_nulless() * @see f_utf_string_dynamic_mash_nulless() + * @see f_utf_string_dynamic_partial_append_assure_nulless() + * @see f_utf_string_dynamic_partial_append_nulless() + * @see f_utf_string_dynamic_partial_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_) +#if !defined(_di_f_utf_string_append_assure_nulless_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_nulless_) || !defined(_di_f_utf_string_dynamic_partial_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_array_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_) +#endif // !defined(_di_f_utf_string_append_assure_nulless_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mash_nulless_) || !defined(_di_f_utf_string_mash_nulless_) /** * Private implementation for resizing. @@ -621,10 +625,17 @@ extern "C" { * @see f_memory_adjust() * @see f_utf_string_dynamic_adjust() * @see f_utf_string_dynamic_decimate_by() + * @see f_utf_string_dynamics_adjust() + * @see f_utf_string_dynamics_append() + * @see f_utf_string_dynamics_decimate_by() + * @see f_utf_string_map_multis_adjust() + * @see f_utf_string_map_multis_append() + * @see f_utf_string_triples_adjust() + * @see f_utf_string_triples_decimate_by() */ -#if !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) +#if !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) || !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) extern f_status_t private_f_utf_string_dynamic_adjust(const f_array_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_) +#endif // !defined(_di_f_utf_string_dynamic_adjust_) || !defined(_di_f_utf_string_dynamic_decimate_by_) || !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) /** * Private implementation of f_utf_string_dynamic_increase_by(). @@ -639,29 +650,40 @@ extern "C" { * @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(). + * Errors (with error bit) from: f_memory_resize(). * * @see memcpy() * * @see f_utf_string_append() + * @see f_utf_string_append_assure() * @see f_utf_string_append_mash() * @see f_utf_string_append_nulless() * @see f_utf_string_dynamic_append() + * @see f_utf_string_dynamic_append_assure() * @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_partial_append) + * @see f_utf_string_dynamic_partial_append_assure() + * @see f_utf_string_dynamic_partial_mash() * @see f_utf_string_dynamic_prepend() * @see f_utf_string_dynamic_prepend_nulless() + * @see f_utf_string_dynamics_append() + * @see f_utf_string_map_multis_append() + * @see f_utf_string_mash() * @see f_utf_string_mash_nulless() + * @see f_utf_string_maps_append() * @see f_utf_string_prepend() * @see f_utf_string_prepend_nulless() + * @see f_utf_string_triples_append() */ -#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_) +#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) extern f_status_t private_f_utf_string_dynamic_increase_by(const f_array_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_) +#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !defined(_di_f_utf_string_dynamic_increase_by_) || !defined(_di_f_utf_string_dynamic_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(_di_f_utf_string_dynamic_partial_append_) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) /** * Private implementation for resizing. @@ -679,15 +701,37 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). * * @see f_memory_resize() + * @see f_utf_string_append() + * @see f_utf_string_append_assure() + * @see f_utf_string_append_mash() + * @see f_utf_string_append_nulless() + * @see f_utf_string_dynamic_append() + * @see f_utf_string_dynamic_append_assure() + * @see f_utf_string_dynamic_append_nulless() * @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_mash() + * @see f_utf_string_dynamic_mash_nulless() + * @see f_utf_string_dynamic_partial_append) + * @see f_utf_string_dynamic_partial_append_assure() + * @see f_utf_string_dynamic_partial_mash() + * @see f_utf_string_dynamic_prepend() + * @see f_utf_string_dynamic_prepend_nulless() * @see f_utf_string_dynamic_terminate() * @see f_utf_string_dynamic_terminate_after() + * @see f_utf_string_dynamics_append() + * @see f_utf_string_map_multis_append() + * @see f_utf_string_mash_nulless() + * @see f_utf_string_mash() + * @see f_utf_string_maps_append() + * @see f_utf_string_prepend() + * @see f_utf_string_prepend_nulless() + * @see f_utf_string_triples_append() */ -#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_) +#if !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !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_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) extern f_status_t private_f_utf_string_dynamic_resize(const f_array_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_) +#endif // !defined(_di_f_utf_string_append_) || !defined(_di_f_utf_string_append_assure_) || !defined(_di_f_utf_string_append_mash_) || !defined(_di_f_utf_string_append_nulless_) || !defined(_di_f_utf_string_dynamic_append_) || !defined(_di_f_utf_string_dynamic_append_assure_) || !defined(_di_f_utf_string_dynamic_append_nulless_) || !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_mash_) || !defined(_di_f_utf_string_dynamic_mash_nulless_) || !defined(f_utf_string_dynamic_partial_append) || !defined(_di_f_utf_string_dynamic_partial_append_assure_) || !defined(_di_f_utf_string_dynamic_partial_mash_) || !defined(_di_f_utf_string_dynamic_prepend_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_terminate_) || !defined(_di_f_utf_string_dynamic_terminate_after_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) || !defined(_di_f_utf_string_mash_nulless_) || !defined(_di_f_utf_string_mash_) || !defined(_di_f_utf_string_maps_append_) || !defined(_di_f_utf_string_prepend_) || !defined(_di_f_utf_string_prepend_nulless_) || !defined(_di_f_utf_string_triples_append_) /** * Private implementation for resizing. @@ -702,18 +746,44 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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_append() * @see f_utf_string_dynamics_decimate_by() - * - * @see private_f_utf_string_dynamic_adjust() + * @see f_utf_string_map_multis_adjust() + * @see f_utf_string_map_multis_append() */ -#if !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_decimate_by_) +#if !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) extern f_status_t private_f_utf_string_dynamics_adjust(const f_array_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_) +#endif // !defined(_di_f_utf_string_dynamics_adjust_) || !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_dynamics_decimate_by_) || !defined(_di_f_utf_string_map_multis_adjust_) || !defined(_di_f_utf_string_map_multis_append_) + +/** + * Private implementation for appending. + * + * Intended to be shared to each of the different implementation variations. + * + * @param source + * The source strings to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * + * F_array_too_large (with error bit) if the combined array is too large. + * + * Errors (with error bit) from: f_memory_adjust(). + * + * @see f_utf_string_dynamics_append() + * @see f_utf_string_map_multis_append() + */ +#if !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) + extern f_status_t private_f_utf_string_dynamics_append(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t *destination) f_gcc_attribute_visibility_internal; +#endif // !defined(_di_f_utf_string_dynamics_append_) || !defined(_di_f_utf_string_map_multis_append_) /** * Private implementation for resizing. @@ -728,15 +798,14 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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_array_length_t length, f_utf_string_dynamics_t *strings) f_gcc_attribute_visibility_internal; @@ -755,13 +824,12 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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_array_length_t length, f_utf_string_map_multis_t *map_multis) f_gcc_attribute_visibility_internal; @@ -780,8 +848,9 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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() @@ -789,8 +858,6 @@ extern "C" { * @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_array_length_t length, f_utf_string_map_multis_t *map_multis) f_gcc_attribute_visibility_internal; @@ -809,13 +876,12 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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_array_length_t length, f_utf_string_maps_t *maps) f_gcc_attribute_visibility_internal; @@ -834,8 +900,9 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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() @@ -843,8 +910,6 @@ extern "C" { * @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_array_length_t length, f_utf_string_maps_t *maps) f_gcc_attribute_visibility_internal; @@ -864,9 +929,10 @@ extern "C" { * * @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(). + * Errors (with error bit) from: f_memory_resize(). * * @see memcopy() * @see memmove() @@ -880,8 +946,6 @@ extern "C" { * @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_array_length_t length, f_utf_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; @@ -901,9 +965,10 @@ extern "C" { * * @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(). + * Errors (with error bit) from: f_memory_resize(). * * @see memcopy() * @see memmove() @@ -917,8 +982,6 @@ extern "C" { * @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_array_length_t length, f_utf_string_dynamic_t *destination) f_gcc_attribute_visibility_internal; @@ -937,13 +1000,13 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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_array_length_t length, f_utf_string_quantitys_t *quantitys) f_gcc_attribute_visibility_internal; @@ -962,8 +1025,9 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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() @@ -971,7 +1035,6 @@ extern "C" { * @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_array_length_t length, f_utf_string_quantitys_t *quantitys) f_gcc_attribute_visibility_internal; @@ -990,13 +1053,13 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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_array_length_t length, f_utf_string_quantityss_t *quantityss) f_gcc_attribute_visibility_internal; @@ -1015,8 +1078,9 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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() @@ -1024,7 +1088,6 @@ extern "C" { * @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_array_length_t length, f_utf_string_quantityss_t *quantityss) f_gcc_attribute_visibility_internal; @@ -1043,13 +1106,13 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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_array_length_t length, f_utf_string_ranges_t *ranges) f_gcc_attribute_visibility_internal; @@ -1068,8 +1131,9 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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() @@ -1077,7 +1141,6 @@ extern "C" { * @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_array_length_t length, f_utf_string_ranges_t *ranges) f_gcc_attribute_visibility_internal; @@ -1096,13 +1159,13 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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_array_length_t length, f_utf_string_rangess_t *rangess) f_gcc_attribute_visibility_internal; @@ -1121,8 +1184,9 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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() @@ -1130,7 +1194,6 @@ extern "C" { * @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_array_length_t length, f_utf_string_rangess_t *rangess) f_gcc_attribute_visibility_internal; @@ -1149,13 +1212,13 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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_array_length_t length, f_utf_string_triples_t *triples) f_gcc_attribute_visibility_internal; @@ -1174,8 +1237,9 @@ extern "C" { * @return * F_none on success. * + * F_array_too_large (with error bit) if the combined array is too large. + * * 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() @@ -1183,7 +1247,6 @@ extern "C" { * @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_array_length_t length, f_utf_string_triples_t *triples) f_gcc_attribute_visibility_internal; diff --git a/level_0/f_utf/c/utf.c b/level_0/f_utf/c/utf.c index bf30fc6..cfaa1f5 100644 --- a/level_0/f_utf/c/utf.c +++ b/level_0/f_utf/c/utf.c @@ -76,6 +76,51 @@ extern "C" { } #endif // _di_f_utf_buffer_increment_ +#ifndef _di_f_utf_char_to_character_ + f_status_t f_utf_char_to_character(const f_string_t character, const f_array_length_t width_max, f_utf_character_t *character_utf) { + #ifndef _di_level_0_parameter_checking_ + if (width_max < 1) return F_status_set_error(F_parameter); + if (!character_utf) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + const uint8_t width = f_macro_utf_byte_width_is(*character); + + if (!width) { + *character_utf = f_macro_utf_character_t_from_char_1(character[0]); + return F_none; + } + else if (width == 1) { + return F_status_is_error(F_utf); + } + + if (width > width_max) { + return F_status_set_error(F_failure); + } + + *character_utf = f_macro_utf_character_t_from_char_1(character[0]); + + if (width < 2) { + return F_none; + } + + *character_utf |= f_macro_utf_character_t_from_char_2(character[1]); + + if (width == 2) { + return F_none; + } + + *character_utf |= f_macro_utf_character_t_from_char_3(character[2]); + + if (width == 3) { + return F_none; + } + + *character_utf |= f_macro_utf_character_t_from_char_4(character[3]); + + return F_none; + } +#endif // _di_f_utf_char_to_character_ + #ifndef _di_f_utf_character_is_ f_status_t f_utf_character_is(const f_utf_character_t character) { const uint8_t width = f_macro_utf_character_t_width_is(character); @@ -1556,51 +1601,6 @@ extern "C" { } #endif // _di_f_utf_is_zero_width_ -#ifndef _di_f_utf_char_to_character_ - f_status_t f_utf_char_to_character(const f_string_t character, const f_array_length_t width_max, f_utf_character_t *character_utf) { - #ifndef _di_level_0_parameter_checking_ - if (width_max < 1) return F_status_set_error(F_parameter); - if (!character_utf) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - const uint8_t width = f_macro_utf_byte_width_is(*character); - - if (!width) { - *character_utf = f_macro_utf_character_t_from_char_1(character[0]); - return F_none; - } - else if (width == 1) { - return F_status_is_error(F_utf); - } - - if (width > width_max) { - return F_status_set_error(F_failure); - } - - *character_utf = f_macro_utf_character_t_from_char_1(character[0]); - - if (width < 2) { - return F_none; - } - - *character_utf |= f_macro_utf_character_t_from_char_2(character[1]); - - if (width == 2) { - return F_none; - } - - *character_utf |= f_macro_utf_character_t_from_char_3(character[2]); - - if (width == 3) { - return F_none; - } - - *character_utf |= f_macro_utf_character_t_from_char_4(character[3]); - - return F_none; - } -#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_array_length_t length, f_utf_string_dynamic_t *destination) { #ifndef _di_level_0_parameter_checking_ @@ -1698,874 +1698,217 @@ extern "C" { } #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_array_length_t i = 1; - f_array_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_array_length_t i = 1; - f_array_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_array_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { +#ifndef _di_f_utf_string_mash_ + f_status_t f_utf_string_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_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 (!source.used) return F_data_not_eos; + if (!length) return F_data_not_eos; if (glue_length && destination->used) { - const f_status_t status = private_f_utf_string_append(glue, glue_length, destination); + 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); + return private_f_utf_string_append(source, length, destination); } -#endif // _di_f_utf_string_dynamic_mash_ +#endif // _di_f_utf_string_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_array_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { +#ifndef _di_f_utf_string_mash_nulless_ + f_status_t f_utf_string_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_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 (!source.used) return F_data_not_eos; + if (!length) 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); + 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); + return private_f_utf_string_append_nulless(source, length, destination); } -#endif // _di_f_utf_string_dynamic_mash_nulless_ +#endif // _di_f_utf_string_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_array_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { +#ifndef _di_f_utf_string_mish_ + f_status_t f_utf_string_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_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 (!source.used) return F_data_not_eos; + if (!length) return F_data_not_eos; if (glue_length && destination->used) { - const f_status_t status = private_f_utf_string_prepend(glue, glue_length, destination); + 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); + return private_f_utf_string_prepend(source, length, destination); } -#endif // _di_f_utf_string_dynamic_mish_ +#endif // _di_f_utf_string_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_array_length_t glue_length, const f_utf_string_static_t source, f_utf_string_dynamic_t *destination) { +#ifndef _di_f_utf_string_mish_nulless_ + f_status_t f_utf_string_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_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 (!source.used) return F_data_not_eos; + if (!length) 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); + 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); + return private_f_utf_string_prepend_nulless(source, length, destination); } -#endif // _di_f_utf_string_dynamic_mish_nulless_ +#endif // _di_f_utf_string_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_f_utf_string_prepend_ + f_status_t f_utf_string_prepend(const f_utf_string_t source, const f_array_length_t length, 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 (!length) return F_data_not_eos; - return private_f_utf_string_append(source.string + range.start, (range.stop - range.start) + 1, destination); + return private_f_utf_string_prepend(source, length, destination); } -#endif // _di_f_utf_string_dynamic_partial_append_ +#endif // _di_f_utf_string_prepend_ -#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_f_utf_string_prepend_assure_ + f_status_t f_utf_string_prepend_assure(const f_utf_string_t source, const f_array_length_t length, 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_array_length_t length = (range.stop - range.start) + 1; + if (!length) return F_data_not_eos; if (destination->used < length) { - return private_f_utf_string_append(source.string + range.start, length, destination); + return private_f_utf_string_prepend(source, length, destination); } - f_array_length_t i = 1; - f_array_length_t j = 1; + f_array_length_t i = 0; + f_array_length_t j = 0; - while (i <= length && j <= destination->used) { - if (!source.string[range.stop - i]) { + while (i < length && j < destination->used) { + + if (!source[i]) { i++; continue; } - if (!destination->string[destination->used - j]) { + if (!destination->string[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); + 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_dynamic_partial_append_assure_ +#endif // _di_f_utf_string_prepend_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_f_utf_string_prepend_assure_nulless_ + f_status_t f_utf_string_prepend_assure_nulless(const f_utf_string_t source, const f_array_length_t length, 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_array_length_t length = (range.stop - range.start) + 1; + if (!length) return F_data_not_eos; if (destination->used < length) { - return private_f_utf_string_append_nulless(source.string + range.start, length, destination); + return private_f_utf_string_prepend_nulless(source, length, destination); } - f_array_length_t i = 1; - f_array_length_t j = 1; + f_array_length_t i = 0; + f_array_length_t j = 0; - while (i <= length && j <= destination->used) { - if (!source.string[range.stop - i]) { + while (i < length && j < destination->used) { + + if (!source[i]) { i++; continue; } - if (!destination->string[destination->used - j]) { + if (!destination->string[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); + 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_dynamic_append_assure_nulless_ +#endif // _di_f_utf_string_prepend_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_f_utf_string_prepend_nulless_ + f_status_t f_utf_string_prepend_nulless(const f_utf_string_t source, const f_array_length_t length, 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 (!length) return F_data_not_eos; - return private_f_utf_string_append_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); + return private_f_utf_string_prepend_nulless(source, length, destination); } -#endif // _di_f_utf_string_dynamic_partial_append_nulless_ +#endif // _di_f_utf_string_prepend_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_array_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_f_utf_string_seek_line_ + f_status_t f_utf_string_seek_line(const f_utf_string_t string, f_utf_string_range_t *range) { #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); + if (!range) 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; - } + 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_mash_ + while (string[range->start] != f_utf_character_t_eol) { -#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_array_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 (f_macro_utf_character_t_width_is(string[range->start]) == 1) { + return F_status_set_error(F_utf); + } - if (!source.used) return F_data_not_eos; - if (range.start > range.stop) return F_data_not_stop; + range->start++; - 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; - } + if (range->start > range->stop) return F_none_stop; + } // while - return private_f_utf_string_append_nulless(source.string + range.start, (range.stop - range.start) + 1, destination); + return F_none; } -#endif // _di_f_utf_string_dynamic_partial_mash_nulless_ +#endif // _di_f_utf_string_seek_line_ -#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_array_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_f_utf_string_seek_line_to_ + f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, const int8_t seek_to, f_utf_string_range_t *range) { #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); + if (!range) 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 (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_array_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_array_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_array_length_t i = 0; - f_array_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_array_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_array_length_t i = 0; - f_array_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_array_length_t i = 0; - f_array_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_array_length_t i = 0; - f_array_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 + while (string[range->start] != seek_to) { - 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) { + if (f_macro_utf_character_t_width_is(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_array_length_t_size) { - return F_status_set_error(F_string_too_large); - } - - const f_array_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_array_length_t_size) { - return F_status_set_error(F_string_too_large); - } - - const f_array_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_array_length_t glue_length, const f_utf_string_t source, const f_array_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_array_length_t glue_length, const f_utf_string_t source, const f_array_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_array_length_t glue_length, const f_utf_string_t source, const f_array_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_array_length_t glue_length, const f_utf_string_t source, const f_array_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_array_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_array_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_array_length_t i = 0; - f_array_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_array_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_array_length_t i = 0; - f_array_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_array_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; - } + 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 @@ -2574,24 +1917,21 @@ extern "C" { #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) { + f_status_t f_utf_string_seek_to(const f_utf_string_t string, const int8_t seek_to, f_utf_string_range_t *range) { #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++; + while (string[range->start] != seek_to) { if (f_macro_utf_character_t_width_is(string[range->start]) == 1) { return F_status_set_error(F_utf); } + range->start++; + if (range->start > range->stop) return F_none_stop; } // while diff --git a/level_0/f_utf/c/utf.h b/level_0/f_utf/c/utf.h index dcbc2f0..8586f53 100644 --- a/level_0/f_utf/c/utf.h +++ b/level_0/f_utf/c/utf.h @@ -1340,764 +1340,91 @@ extern "C" { * @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_array_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_array_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_array_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_array_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_array_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_array_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_array_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_array_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_array_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_array_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_array_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_array_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. + * Errors (with error bit) from: f_memory_resize(). */ -#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_ +#ifndef _di_f_utf_string_append_ + extern f_status_t f_utf_string_append(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_append_ /** - * 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. + * 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 prepend. - * @param range - * A range within the source to restrict the copy from. + * The source string to append. + * @param length + * The length of source to append. * @param destination - * The destination string the source is prepended onto. + * 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_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. + * Errors (with error bit) from: f_memory_resize(). */ -#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_ +#ifndef _di_f_utf_string_append_assure_ + extern f_status_t f_utf_string_append_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_append_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. + * 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 prepend. + * The source string to append. + * @param length + * The length of source to append. * @param destination - * The destination string the source is prepended onto. + * 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_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. + * + * Errors (with error bit) from: f_memory_resize(). */ -#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_ +#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_array_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_append_assure_nulless_ /** - * Prepend the source string onto the destination. + * Append the source string onto the destination. * - * Prepend operations require memory move operations and are therefore likely more expensive than append operations. + * Skips over NULL characters from source when appending. * * @param source - * The source string to prepend. + * The source string to append. + * @param length + * The length of source to append. * @param destination - * The destination string the source is prepended onto. + * 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_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. + * F_string_too_large (with error bit) if the combined string is too large. * - * @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. + * Errors (with error bit) from: f_memory_resize(). */ -#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_ +#ifndef _di_f_utf_string_append_nulless_ + extern f_status_t f_utf_string_append_nulless(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); +#endif // _di_f_utf_string_append_nulless_ /** * Append the source string onto the destination with the glue in between. @@ -2118,9 +1445,11 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_mash_ extern f_status_t f_utf_string_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); @@ -2147,9 +1476,11 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_mash_nulless_ extern f_status_t f_utf_string_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); @@ -2174,9 +1505,11 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_mish_ extern f_status_t f_utf_string_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); @@ -2203,9 +1536,11 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_mish_nulless_ extern f_status_t f_utf_string_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); @@ -2226,9 +1561,11 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_prepend_ extern f_status_t f_utf_string_prepend(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); @@ -2251,9 +1588,11 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_prepend_assure_ extern f_status_t f_utf_string_prepend_assure(const f_utf_string_t source, const f_array_length_t length, f_utf_string_dynamic_t *destination); @@ -2277,9 +1616,11 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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_array_length_t length, f_utf_string_dynamic_t *destination); @@ -2303,56 +1644,84 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_prepend_nulless_ extern f_status_t f_utf_string_prepend_nulless(const f_utf_string_t source, const f_array_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. + * Seek the string 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. - * @param seek_to_this + * + * @return + * F_none on success. + * F_none_stop on success, but stopped at end of range. + * F_data_not_stop on success, but the range.start > range.stop. + * + * F_parameter (with error bit) if a parameter is invalid. + * F_utf (with error bit) if character is invalid UTF-8. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_seek_line_ + extern f_status_t f_utf_string_seek_line(const f_utf_string_t string, f_utf_string_range_t *range); +#endif // _di_f_utf_string_seek_line_ + +/** + * 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. + * F_utf (with error bit) if character is invalid UTF-8. */ #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); + extern f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, const int8_t seek_to, f_utf_string_range_t *range); #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. + * 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. - * @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. + * F_utf (with error bit) if character is invalid UTF-8. */ #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); + extern f_status_t f_utf_string_seek_to(const f_utf_string_t string, const int8_t seek_to, f_utf_string_range_t *range); #endif // _di_f_utf_string_seek_to_ #ifdef __cplusplus diff --git a/level_0/f_utf/c/utf_dynamic.c b/level_0/f_utf/c/utf_dynamic.c index 9bde3ca..2cc5e29 100644 --- a/level_0/f_utf/c/utf_dynamic.c +++ b/level_0/f_utf/c/utf_dynamic.c @@ -19,6 +19,106 @@ extern "C" { } #endif // _di_f_utf_string_dynamic_adjust_ +#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_array_length_t i = 1; + f_array_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_array_length_t i = 1; + f_array_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_decimate_by_ f_status_t f_utf_string_dynamic_decimate_by(const f_array_length_t amount, f_utf_string_dynamic_t *dynamic) { #ifndef _di_level_0_parameter_checking_ @@ -83,16 +183,618 @@ extern "C" { } #endif // _di_f_utf_string_dynamic_increase_by_ +#ifndef _di_f_utf_string_dynamic_mash_ + f_status_t f_utf_string_dynamic_mash(const f_utf_string_t glue, const f_array_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_array_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_array_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_array_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_array_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_array_length_t i = 1; + f_array_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_array_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_array_length_t i = 1; + f_array_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_array_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_array_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_partial_dynamic_mish(const f_utf_string_t glue, const f_array_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_array_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_array_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_array_length_t i = 0; + f_array_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_array_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_array_length_t i = 0; + f_array_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_array_length_t i = 0; + f_array_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_array_length_t i = 0; + f_array_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_resize_ - f_status_t f_utf_string_dynamic_resize(const f_array_length_t length, f_utf_string_dynamic_t *dynamic) { + f_status_t f_utf_string_dynamic_resize(const f_array_length_t length, f_utf_string_dynamic_t *buffer) { #ifndef _di_level_0_parameter_checking_ - if (!dynamic) return F_status_set_error(F_parameter); + if (!buffer) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_utf_string_dynamic_resize(length, dynamic); + return private_f_utf_string_dynamic_resize(length, buffer); } #endif // _di_f_utf_string_dynamic_resize_ +#ifndef _di_f_utf_string_dynamic_seek_line_ + f_status_t f_utf_string_dynamic_seek_line(const f_utf_string_static_t buffer, f_utf_string_range_t *range) { + #ifndef _di_level_0_parameter_checking_ + if (!range) 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; + + while (buffer.string[range->start] != f_utf_character_t_eol) { + + if (f_macro_utf_character_t_width_is(buffer.string[range->start]) == 1) { + return F_status_set_error(F_utf); + } + + range->start++; + + 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_ + +#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, const int8_t seek_to_this, f_utf_string_range_t *range) { + #ifndef _di_level_0_parameter_checking_ + if (!range) 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; + + while (buffer.string[range->start] != seek_to_this) { + + if (f_macro_utf_character_t_width_is(buffer.string[range->start]) == 1) { + return F_status_set_error(F_utf); + } + + if (buffer.string[range->start] == f_utf_character_t_eol) return F_none_eol; + + range->start++; + + 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, const int8_t seek_to_this, f_utf_string_range_t *range) { + #ifndef _di_level_0_parameter_checking_ + if (!range) 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; + + while (buffer.string[range->start] != seek_to_this) { + + if (f_macro_utf_character_t_width_is(buffer.string[range->start]) == 1) { + return F_status_set_error(F_utf); + } + + range->start++; + + 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_array_length_t_size) { + return F_status_set_error(F_string_too_large); + } + + const f_array_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_array_length_t_size) { + return F_status_set_error(F_string_too_large); + } + + const f_array_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_dynamics_adjust_ f_status_t f_utf_string_dynamics_adjust(const f_array_length_t length, f_utf_string_dynamics_t *dynamics) { #ifndef _di_level_0_parameter_checking_ @@ -103,6 +805,18 @@ extern "C" { } #endif // _di_f_utf_string_dynamics_adjust_ +#ifndef _di_f_utf_string_dynamics_append_ + f_status_t f_utf_string_dynamics_append(const f_utf_string_dynamics_t source, f_utf_string_dynamics_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; + + return private_f_utf_string_dynamics_append(source, destination); + } +#endif // _di_f_utf_string_dynamics_append_ + #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_ diff --git a/level_0/f_utf/c/utf_dynamic.h b/level_0/f_utf/c/utf_dynamic.h index 9723ec3..c418140 100644 --- a/level_0/f_utf/c/utf_dynamic.h +++ b/level_0/f_utf/c/utf_dynamic.h @@ -16,6 +16,9 @@ extern "C" { #endif +// fll-0 string includes +#include + /** * A string that is analogous to f_utf_string_dynamic_t but intended for static-only uses. * @@ -148,6 +151,112 @@ extern "C" { #endif // _di_f_utf_string_dynamic_adjust_ /** + * 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_ + +/** + * 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_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_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamic_append_ + extern f_status_t f_utf_string_dynamic_append(const f_utf_string_dynamic_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_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_memory_resize(). + */ +#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_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_memory_resize(). + */ +#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_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_memory_resize(). + */ +#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_ + +/** * Resize the dynamic string to a smaller size. * * This will resize making the string smaller based on (size - given length). @@ -161,10 +270,11 @@ extern "C" { * * @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. + * F_string_too_large (with error bit) if the combined string is too large. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_decrease_by_ extern f_status_t f_utf_string_dynamic_decrease_by(const f_array_length_t amount, f_utf_string_dynamic_t *dynamic); @@ -186,9 +296,10 @@ extern "C" { * 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. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_increase_ extern f_status_t f_utf_string_dynamic_increase(f_utf_string_dynamic_t *dynamic); @@ -210,33 +321,710 @@ extern "C" { * 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. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_increase_by_ extern f_status_t f_utf_string_dynamic_increase_by(const f_array_length_t amount, f_utf_string_dynamic_t *dynamic); #endif // _di_f_utf_string_dynamic_increase_by_ /** + * 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_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_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamic_mash_ + extern f_status_t f_utf_string_dynamic_mash(const f_utf_string_t glue, const f_array_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_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_memory_resize(). + */ +#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_array_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_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_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamic_mish_ + extern f_status_t f_utf_string_dynamic_mish(const f_utf_string_t glue, const f_array_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_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_memory_resize(). + */ +#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_array_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_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_memory_resize(). + */ +#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_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_memory_resize(). + */ +#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_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_memory_resize(). + */ +#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_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_memory_resize(). + */ +#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_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_memory_resize(). + */ +#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_array_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_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_memory_resize(). + */ +#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_array_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_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_memory_resize(). + */ +#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_array_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_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_memory_resize(). + */ +#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_array_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_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_memory_resize(). + */ +#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_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_memory_resize(). + */ +#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_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_memory_resize(). + */ +#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_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_memory_resize(). + */ +#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_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_memory_resize(). + */ +#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_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_memory_resize(). + */ +#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_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_memory_resize(). + */ +#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_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_memory_resize(). + */ +#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_ + +/** * Resize the dynamic string. * * @param length * The new size to use. - * @param dynamic + * @param buffer * 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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); + extern f_status_t f_utf_string_dynamic_resize(const f_array_length_t length, f_utf_string_dynamic_t *buffer); #endif // _di_f_utf_string_dynamic_resize_ /** + * Seek the buffer location forward until 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. + * + * @return + * F_none on success. + * F_none_eos on success, but stopped at end of string. + * F_none_stop on success, but stopped at end of range. + * F_data_not_eos 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. + * F_utf (with error bit) if character is invalid UTF-8. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamic_seek_line_ + extern f_status_t f_utf_string_dynamic_seek_line(const f_utf_string_static_t buffer, f_utf_string_range_t *range); +#endif // _di_f_utf_string_dynamic_seek_line_ + +/** + * Seek the buffer location forward until the character (1-byte wide) or EOL is reached. + * + * @param buffer + * The buffer 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_eos on success, but stopped at end of string. + * F_none_stop on success, but stopped at end of range. + * F_data_not_eos 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. + * F_utf (with error bit) if character is invalid UTF-8. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#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, const int8_t seek_to_this, f_utf_string_range_t *range); +#endif // _di_f_utf_string_dynamic_seek_line_to_ + +/** + * Seek the buffer location forward until the character (1-byte wide) is reached. + * + * @param buffer + * The buffer 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_eos on success, but stopped at end of string. + * F_none_stop on success, but stopped at end of range. + * F_data_not_eos 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. + * F_utf (with error bit) if character is invalid UTF-8. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#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, const int8_t seek_to_this, f_utf_string_range_t *range); +#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_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. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#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_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. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#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_ + +/** * Resize the dynamic string array. * * @param length @@ -247,14 +1035,36 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_adjust(). */ #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_ /** + * Append the source strings onto the destination. + * + * @param source + * The source strings to append. + * @param destination + * The destination strings the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * 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_memory_resize(). + */ +#ifndef _di_f_utf_string_dynamics_append_ + extern f_status_t f_utf_string_dynamics_append(const f_utf_string_dynamics_t source, f_utf_string_dynamics_t *destination); +#endif // _di_f_utf_string_dynamics_append_ + +/** * Resize the dynamic string array to a smaller size. * * This will resize making the array smaller based on (size - given length). @@ -270,8 +1080,9 @@ extern "C" { * 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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -293,8 +1104,9 @@ extern "C" { * 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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -313,9 +1125,10 @@ extern "C" { * 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. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamics_increase_ extern f_status_t f_utf_string_dynamics_increase(f_utf_string_dynamics_t *dynamics); @@ -337,9 +1150,10 @@ extern "C" { * 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. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -356,8 +1170,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); diff --git a/level_0/f_utf/c/utf_map.c b/level_0/f_utf/c/utf_map.c index 31ef625..68e12ff 100644 --- a/level_0/f_utf/c/utf_map.c +++ b/level_0/f_utf/c/utf_map.c @@ -15,6 +15,39 @@ extern "C" { } #endif // _di_f_utf_string_map_multis_adjust_ +#ifndef _di_f_utf_string_map_multis_append_ + f_status_t f_utf_string_map_multis_append(const f_utf_string_map_multis_t source, f_utf_string_map_multis_t *destination) { + #ifndef _di_level_0_parameter_checking_ + if (!destination) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_map_multis_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].name.used = 0; + destination->array[destination->used].value.used = 0; + + if (source.array[i].name.used) { + status = private_f_utf_string_append(source.array[i].name.string, source.array[i].name.used, &destination->array[destination->used].name); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].value.used) { + status = private_f_utf_string_dynamics_append(source.array[i].value, &destination->array[destination->used].value); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_utf_string_map_multis_append_ + #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_ @@ -108,6 +141,41 @@ extern "C" { } #endif // _di_f_utf_string_maps_adjust_ +#ifndef _di_f_utf_string_maps_append_ + f_status_t f_utf_string_maps_append(const f_utf_string_maps_t source, f_utf_string_maps_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; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_maps_resize(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].name.used = 0; + destination->array[destination->used].value.used = 0; + + if (source.array[i].name.used) { + status = private_f_utf_string_append(source.array[i].name.string, source.array[i].name.used, &destination->array[destination->used].name); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].value.used) { + status = private_f_utf_string_append(source.array[i].value.string, source.array[i].value.used, &destination->array[destination->used].value); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_utf_string_maps_append_ + #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_ diff --git a/level_0/f_utf/c/utf_map.h b/level_0/f_utf/c/utf_map.h index dcc74d9..9203536 100644 --- a/level_0/f_utf/c/utf_map.h +++ b/level_0/f_utf/c/utf_map.h @@ -133,25 +133,47 @@ extern "C" { #endif // _di_f_utf_string_map_multis_t_ /** - * Resize the string map_multis array. + * Resize the map_multis array. * * @param length * The new size to use. * @param map_multis - * The string map_multis array to resize. + * The 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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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. + * Append the source map_multis onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * 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_memory_resize(). + */ +#ifndef _di_f_utf_string_map_multis_append_ + f_status_t f_utf_string_map_multis_append(const f_utf_string_map_multis_t source, f_utf_string_map_multis_t *destination); +#endif // _di_f_utf_string_map_multis_append_ + +/** + * Resize the 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. @@ -160,20 +182,21 @@ extern "C" { * @param amount * A positive number representing how much to decimate the size by. * @param map_multis - * The string map_multis array to resize. + * The 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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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. + * Resize the 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. @@ -182,41 +205,43 @@ extern "C" { * @param amount * A positive number representing how much to decrease the size by. * @param map_multis - * The string map_multis array to resize. + * The 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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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. + * Increase the size of the 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. + * The 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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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. + * Resize the 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). @@ -225,33 +250,35 @@ extern "C" { * @param amount * A positive number representing how much to increase the size by. * @param map_multis - * The string map_multis array to resize. + * The 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. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). */ #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. + * Resize the map_multis array. * * @param length * The new size to use. * @param map_multis - * The string map_multis array to adjust. + * The 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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -268,14 +295,36 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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_ /** + * Append the source maps onto the destination. + * + * @param source + * The source maps to append. + * @param destination + * The destination maps the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * 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_memory_resize(). + */ +#ifndef _di_f_utf_string_maps_append_ + extern f_status_t f_utf_string_maps_append(const f_utf_string_maps_t source, f_utf_string_maps_t *destination); +#endif // _di_f_utf_string_maps_append_ + +/** * Resize the string maps array to a smaller size. * * This will resize making the array smaller based on (size - given length). @@ -290,8 +339,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -312,8 +362,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -333,8 +384,9 @@ extern "C" { * 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. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_maps_increase_ extern f_status_t f_utf_string_maps_increase(f_utf_string_maps_t *maps); @@ -356,9 +408,10 @@ extern "C" { * 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. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -375,8 +428,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); diff --git a/level_0/f_utf/c/utf_quantity.c b/level_0/f_utf/c/utf_quantity.c index 399bcbc..5663c14 100644 --- a/level_0/f_utf/c/utf_quantity.c +++ b/level_0/f_utf/c/utf_quantity.c @@ -15,6 +15,31 @@ extern "C" { } #endif // _di_f_utf_string_quantitys_adjust_ +#ifndef _di_f_utf_string_quantitys_append_ + f_status_t f_utf_string_quantitys_append(const f_utf_string_quantitys_t source, f_utf_string_quantitys_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; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_quantitys_adjust(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].start = source.array[i].start; + destination->array[destination->used].total = source.array[i].total; + } // for + + return F_none; + } +#endif // _di_f_utf_string_quantitys_append_ + #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_ diff --git a/level_0/f_utf/c/utf_quantity.h b/level_0/f_utf/c/utf_quantity.h index c012938..f2e7ad9 100644 --- a/level_0/f_utf/c/utf_quantity.h +++ b/level_0/f_utf/c/utf_quantity.h @@ -110,14 +110,35 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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_ /** + * Append the source quantitys onto the destination. + * + * @param source + * The source quantitys to append. + * @param destination + * The destination quantitys the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_quantitys_append_ + extern f_status_t f_utf_string_quantitys_append(const f_utf_string_quantitys_t source, f_utf_string_quantitys_t *destination); +#endif // _di_f_utf_string_quantitys_append_ + +/** * Resize the string quantitys array to a smaller size. * * This will resize making the array smaller based on (size - given length). @@ -132,8 +153,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -154,8 +176,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -172,10 +195,11 @@ extern "C" { * * @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_array_too_large (with error bit) if the new array length is too large. * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_quantitys_increase_ extern f_status_t f_utf_string_quantitys_increase(f_utf_string_quantitys_t *quantitys); @@ -196,9 +220,10 @@ extern "C" { * @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. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -215,8 +240,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -233,8 +259,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -255,8 +282,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -277,8 +305,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -298,8 +327,9 @@ extern "C" { * 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. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_quantityss_increase_ extern f_status_t f_utf_string_quantityss_increase(f_utf_string_quantityss_t *quantityss); @@ -321,9 +351,10 @@ extern "C" { * 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. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -340,8 +371,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); diff --git a/level_0/f_utf/c/utf_range.c b/level_0/f_utf/c/utf_range.c index 3d91a88..d37e917 100644 --- a/level_0/f_utf/c/utf_range.c +++ b/level_0/f_utf/c/utf_range.c @@ -15,6 +15,31 @@ extern "C" { } #endif // _di_f_utf_string_ranges_adjust_ +#ifndef _di_f_utf_string_ranges_append_ + f_status_t f_utf_string_ranges_append(const f_utf_string_ranges_t source, f_utf_string_ranges_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; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_ranges_adjust(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].start = source.array[i].start; + destination->array[destination->used].stop = source.array[i].stop; + } // for + + return F_none; + } +#endif // _di_f_utf_string_ranges_append_ + #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_ diff --git a/level_0/f_utf/c/utf_range.h b/level_0/f_utf/c/utf_range.h index a5c1bed..53b9766 100644 --- a/level_0/f_utf/c/utf_range.h +++ b/level_0/f_utf/c/utf_range.h @@ -124,6 +124,26 @@ extern "C" { #endif // _di_f_utf_string_ranges_adjust_ /** + * Append the source ranges onto the destination. + * + * @param source + * The source ranges to append. + * @param destination + * The destination ranges the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is nothing to append (size == 0). + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_utf_string_ranges_append_ + extern f_status_t f_utf_string_ranges_append(const f_utf_string_ranges_t source, f_utf_string_ranges_t *destination); +#endif // _di_f_utf_string_ranges_append_ + +/** * Resize the string ranges array to a smaller size. * * This will resize making the array smaller based on (size - given length). @@ -138,8 +158,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -160,8 +181,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -181,8 +203,9 @@ extern "C" { * 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. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_ranges_increase_ extern f_status_t f_utf_string_ranges_increase(f_utf_string_ranges_t *ranges); @@ -204,9 +227,10 @@ extern "C" { * 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. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -223,8 +247,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -241,8 +266,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -263,8 +289,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -285,8 +312,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -306,8 +334,9 @@ extern "C" { * 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. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_rangess_increase_ extern f_status_t f_utf_string_rangess_increase(f_utf_string_rangess_t *rangess); @@ -329,9 +358,10 @@ extern "C" { * 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. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -348,8 +378,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); diff --git a/level_0/f_utf/c/utf_triple.c b/level_0/f_utf/c/utf_triple.c index 8061d31..f4cb4e0 100644 --- a/level_0/f_utf/c/utf_triple.c +++ b/level_0/f_utf/c/utf_triple.c @@ -15,6 +15,47 @@ extern "C" { } #endif // _di_f_utf_string_triples_adjust_ +#ifndef _di_f_utf_string_triples_append_ + f_status_t f_utf_string_triples_append(const f_utf_string_triples_t source, f_utf_string_triples_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; + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_utf_string_triples_adjust(destination->used + source.used, destination); + if (F_status_is_error(status)) return status; + } + + for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { + + destination->array[destination->used].one.used = 0; + destination->array[destination->used].two.used = 0; + destination->array[destination->used].three.used = 0; + + if (source.array[i].one.used) { + status = private_f_utf_string_append(source.array[i].one.string, source.array[i].one.used, &destination->array[destination->used].one); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].two.used) { + status = private_f_utf_string_append(source.array[i].two.string, source.array[i].two.used, &destination->array[destination->used].two); + if (F_status_is_error(status)) return status; + } + + if (source.array[i].three.used) { + status = private_f_utf_string_append(source.array[i].three.string, source.array[i].three.used, &destination->array[destination->used].three); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_utf_string_triples_append_ + #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_ @@ -96,7 +137,7 @@ extern "C" { return private_f_utf_string_triples_resize(length, triples); } -#endif // _di_f_string_triples_resize_ +#endif // _di_f_utf_string_triples_resize_ #ifdef __cplusplus } // extern "C" diff --git a/level_0/f_utf/c/utf_triple.h b/level_0/f_utf/c/utf_triple.h index 801ddf6..8686942 100644 --- a/level_0/f_utf/c/utf_triple.h +++ b/level_0/f_utf/c/utf_triple.h @@ -104,6 +104,27 @@ extern "C" { #endif // _di_f_utf_string_triples_adjust_ /** + * Append the source triples onto the destination. + * + * @param source + * The source triples to append. + * @param destination + * The destination triples the source is appended onto. + * + * @return + * F_none on success. + * F_data_not on success, but there is no reason to increase size (size == 0). + * + * 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_memory_resize(). + */ +#ifndef _di_f_utf_string_triples_append_ + extern f_status_t f_utf_string_triples_append(const f_utf_string_triples_t source, f_utf_string_triples_t *destination); +#endif // _di_f_utf_string_triples_append_ + +/** * Resize the string triples array to a smaller size. * * This will resize making the array smaller based on (size - given length). @@ -118,8 +139,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -140,8 +162,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -161,8 +184,9 @@ extern "C" { * 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. + * + * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_triples_increase_ extern f_status_t f_utf_string_triples_increase(f_utf_string_triples_t *triples); @@ -184,9 +208,10 @@ extern "C" { * 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. + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); @@ -203,8 +228,9 @@ extern "C" { * @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. + * + * Errors (with error bit) from: f_memory_resize(). */ #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); diff --git a/level_3/iki_write/c/iki_write.c b/level_3/iki_write/c/iki_write.c index 973d525..d260b90 100644 --- a/level_3/iki_write/c/iki_write.c +++ b/level_3/iki_write/c/iki_write.c @@ -287,7 +287,7 @@ extern "C" { } previous = range.start; - status = f_string_dynamic_seek_line(buffer.string, &range); + status = f_string_dynamic_seek_line(buffer, &range); if (F_status_is_error(status)) { fll_error_print(data->error, F_status_set_fine(status), "f_string_dynamic_seek_line", F_true); -- 1.8.3.1