From 3452a73866e06224f51822aa193c74778e6a18c9 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 8 Feb 2022 22:53:22 -0600 Subject: [PATCH] Progress: Continue mass converting to f_string_static_t. Some of the append functions use *_adjust() functions and are now using *_resize() functions. The f_string_dynamicss_t and similar structures are added. This is done hastily with the expectation that I will get to writing unit tests eventually and will better review this code. --- level_0/f_fss/c/fss_quote.h | 4 +- level_0/f_fss/c/private-fss.c | 66 ++++-- level_0/f_string/c/private-string.c | 260 ++++++++++++++++++++- level_0/f_string/c/private-string.h | 238 ++++++++++++++++++- level_0/f_string/c/string_dynamic.c | 107 +++++++++ level_0/f_string/c/string_dynamic.h | 210 ++++++++++++++++- level_0/f_string/c/string_map.c | 259 ++++++++++++++++++-- level_0/f_string/c/string_map.h | 217 +++++++++++++++++ level_0/f_type/c/type.h | 2 +- level_0/f_type_array/c/type_array-common.h | 118 +++++----- level_1/fl_fss/c/fss_basic.c | 4 +- level_1/fl_fss/c/fss_basic_list.c | 5 +- level_1/fl_fss/c/fss_basic_list.h | 2 +- level_1/fl_fss/c/fss_embedded_list.c | 6 +- level_1/fl_fss/c/fss_embedded_list.h | 2 +- level_1/fl_fss/c/fss_extended.c | 33 +-- level_1/fl_fss/c/fss_extended.h | 8 +- level_1/fl_fss/c/fss_extended_list.c | 6 +- level_1/fl_fss/c/fss_extended_list.h | 2 +- level_1/fl_fss/c/private-fss.c | 71 +++--- level_1/fl_fss/c/private-fss.h | 4 +- level_3/fake/c/common.h | 4 +- level_3/fss_basic_list_write/c/common.h | 6 +- .../fss_basic_list_write/c/fss_basic_list_write.c | 35 +-- level_3/fss_basic_list_write/c/private-write.c | 30 ++- level_3/fss_basic_list_write/c/private-write.h | 4 +- level_3/fss_basic_write/c/private-write.c | 4 +- level_3/fss_embedded_list_write/c/private-write.c | 4 +- level_3/fss_extended_list_write/c/private-write.c | 4 +- level_3/fss_extended_write/c/private-write.c | 4 +- level_3/fss_payload_write/c/private-write.c | 4 +- 31 files changed, 1511 insertions(+), 212 deletions(-) diff --git a/level_0/f_fss/c/fss_quote.h b/level_0/f_fss/c/fss_quote.h index b64a0cd..a64ec02 100644 --- a/level_0/f_fss/c/fss_quote.h +++ b/level_0/f_fss/c/fss_quote.h @@ -31,7 +31,7 @@ extern "C" { #endif // _di_f_fss_quote_type_ /** - * Designate an fss quote. + * A number representing a quote type fom the FSS quote type enumeration. */ #ifndef _di_f_fss_quote_t_ typedef uint8_t f_fss_quote_t; @@ -66,7 +66,7 @@ extern "C" { /** * An array of f_fss_quotes_t. * - * array: The array of fss quotes. + * array: The array of an array of fss quote. * size: Total amount of allocated space. * used: Total number of allocated spaces used. */ diff --git a/level_0/f_fss/c/private-fss.c b/level_0/f_fss/c/private-fss.c index 6c88c95..0a148d3 100644 --- a/level_0/f_fss/c/private-fss.c +++ b/level_0/f_fss/c/private-fss.c @@ -24,7 +24,9 @@ extern "C" { } } - return status; + if (F_status_is_error(status)) return status; + + return F_none; } #endif // !defined(_di_f_fss_items_adjust_) || !defined(_di_f_fss_items_decimate_by_) @@ -47,7 +49,9 @@ extern "C" { } } - return status; + if (F_status_is_error(status)) return status; + + return F_none; } #endif // !defined(_di_f_fss_items_decrease_by_) || !defined(_di_f_fss_items_increase_) || !defined(_di_f_fss_items_increase_by_) || !defined(_di_f_fss_items_resize_) @@ -63,8 +67,9 @@ extern "C" { if (F_status_is_error(status)) return status; macro_f_uint8ss_t_adjust(status, named->quotess, length) + if (F_status_is_error(status)) return status; - return status; + return F_none; } #endif // !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_decimate_by_) @@ -80,8 +85,9 @@ extern "C" { if (F_status_is_error(status)) return status; macro_f_uint8ss_t_resize(status, named->quotess, length) + if (F_status_is_error(status)) return status; - return status; + return F_none; } #endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_increase_) || !defined(_di_f_fss_nameds_increase_by_) || !defined(_di_f_fss_nameds_resize_) @@ -105,7 +111,9 @@ extern "C" { } } - return status; + if (F_status_is_error(status)) return status; + + return F_none; } #endif // !defined(_di_f_fss_nameds_adjust_) || !defined(_di_f_fss_nameds_decimate_by_) @@ -129,7 +137,9 @@ extern "C" { } } - return status; + if (F_status_is_error(status)) return status; + + return F_none; } #endif // !defined(_di_f_fss_nameds_decrease_by_) || !defined(_di_f_fss_nameds_increase_) || !defined(_di_f_fss_nameds_increase_by_) || !defined(_di_f_fss_nameds_resize_) @@ -153,7 +163,9 @@ extern "C" { } } - return status; + if (F_status_is_error(status)) return status; + + return F_none; } #endif // !defined(_di_f_fss_nest_adjust_) || !defined(_di_f_fss_nest_decimate_by_) @@ -177,7 +189,9 @@ extern "C" { } } - return status; + if (F_status_is_error(status)) return status; + + return F_none; } #endif // !defined(_di_f_fss_nest_decrease_by_) || !defined(_di_f_fss_nest_increase_) || !defined(_di_f_fss_nest_increase_by_) || !defined(_di_f_fss_nest_resize_) @@ -201,7 +215,9 @@ extern "C" { } } - return status; + if (F_status_is_error(status)) return status; + + return F_none; } #endif // !defined(_di_f_fss_nests_adjust_) || !defined(_di_f_fss_nests_decimate_by_) @@ -225,7 +241,9 @@ extern "C" { } } - return status; + if (F_status_is_error(status)) return status; + + return F_none; } #endif // !defined(_di_f_fss_nests_decrease_by_) || !defined(_di_f_fss_nests_increase_) || !defined(_di_f_fss_nests_increase_by_) || !defined(_di_f_fss_nests_resize_) @@ -238,8 +256,9 @@ extern "C" { if (F_status_is_error(status)) return status; macro_f_fss_contents_t_adjust(status, set->contents, length); + if (F_status_is_error(status)) return status; - return status; + return F_none; } #endif // !defined(_di_f_fss_set_adjust_) || !defined(_di_f_fss_set_decimate_by_) @@ -252,8 +271,9 @@ extern "C" { if (F_status_is_error(status)) return status; macro_f_fss_contents_t_resize(status, set->contents, length); + if (F_status_is_error(status)) return status; - return status; + return F_none; } #endif // !defined(_di_f_fss_set_decrease_by_) || !defined(_di_f_fss_set_increase_) || !defined(_di_f_fss_set_increase_by_) || !defined(_di_f_fss_set_resize_) @@ -272,8 +292,9 @@ extern "C" { if (F_status_is_error(status)) return status; macro_f_fss_quotess_t_adjust(status, set_quote->contents_quote, length); + if (F_status_is_error(status)) return status; - return status; + return F_none; } #endif // !defined(_di_f_fss_set_quote_adjust_) || !defined(_di_f_fss_set_quote_decimate_by_) @@ -292,8 +313,9 @@ extern "C" { if (F_status_is_error(status)) return status; macro_f_fss_quotess_t_resize(status, set_quote->contents_quote, length); + if (F_status_is_error(status)) return status; - return status; + return F_none; } #endif // !defined(_di_f_fss_set_quote_decrease_by_) || !defined(_di_f_fss_set_quote_increase_) || !defined(_di_f_fss_set_quote_increase_by_) || !defined(_di_f_fss_set_quote_resize_) @@ -327,7 +349,9 @@ extern "C" { } } - return status; + if (F_status_is_error(status)) return status; + + return F_none; } #endif // !defined(_di_f_fss_set_quotes_adjust_) || !defined(_di_f_fss_set_quotes_decimate_by_) @@ -360,7 +384,9 @@ extern "C" { } } - return status; + if (F_status_is_error(status)) return status; + + return F_none; } #endif // !defined(_di_f_fss_set_quotes_decrease_by_) || !defined(_di_f_fss_set_quotes_increase_) || !defined(_di_f_fss_set_quotes_increase_by_) || !defined(_di_f_fss_set_quotes_resize_) @@ -388,7 +414,9 @@ extern "C" { } } - return status; + if (F_status_is_error(status)) return status; + + return F_none; } #endif // !defined(_di_f_fss_sets_adjust_) || !defined(_di_f_fss_sets_decimate_by_) @@ -416,7 +444,9 @@ extern "C" { } } - return status; + if (F_status_is_error(status)) return status; + + return F_none; } #endif // !defined(_di_f_fss_sets_decrease_by_) || !defined(_di_f_fss_sets_increase_) || !defined(_di_f_fss_sets_increase_by_) || !defined(_di_f_fss_sets_resize_) diff --git a/level_0/f_string/c/private-string.c b/level_0/f_string/c/private-string.c index 066277a..d404084 100644 --- a/level_0/f_string/c/private-string.c +++ b/level_0/f_string/c/private-string.c @@ -156,7 +156,7 @@ extern "C" { f_status_t status = F_none; if (destination->used + source.used > destination->size) { - status = private_f_string_dynamics_adjust(destination->used + source.used, destination); + status = private_f_string_dynamics_resize(destination->used + source.used, destination); if (F_status_is_error(status)) return status; } @@ -203,6 +203,88 @@ extern "C" { } #endif // !defined(_di_f_string_dynamics_decrease_by_) || !defined(_di_f_string_dynamics_increase_) || !defined(_di_f_string_dynamics_increase_by_) +#if !defined(_di_f_string_dynamicss_adjust_) || !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_dynamicss_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) + f_status_t private_f_string_dynamicss_adjust(const f_array_length_t length, f_string_dynamicss_t * const dynamicss) { + + if (dynamicss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamicss->size; ++i) { + + status = private_f_string_dynamics_adjust(0, &dynamicss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(dynamicss->size, length, sizeof(f_string_dynamics_t), (void **) & dynamicss->array); + + if (F_status_is_error_not(status)) { + dynamicss->size = length; + + if (dynamicss->used > dynamicss->size) { + dynamicss->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_string_dynamicss_adjust_) || !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_dynamicss_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) + +#if !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_map_multis_append_) + f_status_t private_f_string_dynamicss_append(const f_string_dynamicss_t source, f_string_dynamicss_t *destination) { + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_string_dynamicss_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].used = 0; + + if (source.array[i].used) { + status = private_f_string_dynamics_append(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_map_multis_append_) + +#if !defined(_di_f_string_dynamicss_decrease_by_) || !defined(_di_f_string_dynamicss_increase_) || !defined(_di_f_string_dynamicss_increase_by_) + f_status_t private_f_string_dynamicss_resize(const f_array_length_t length, f_string_dynamicss_t * const dynamicss) { + + if (dynamicss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < dynamicss->size; ++i) { + + status = private_f_string_dynamics_resize(0, &dynamicss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(dynamicss->size, length, sizeof(f_string_dynamics_t), (void **) & dynamicss->array); + + if (F_status_is_error_not(status)) { + dynamicss->size = length; + + if (dynamicss->used > dynamicss->size) { + dynamicss->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_string_dynamicss_decrease_by_) || !defined(_di_f_string_dynamicss_increase_) || !defined(_di_f_string_dynamicss_increase_by_) + #if !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_decimate_by_) f_status_t private_f_string_map_multis_adjust(const f_array_length_t length, f_string_map_multis_t *map_multis) { @@ -235,6 +317,36 @@ extern "C" { } #endif // !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_decimate_by_) +#if !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multis_append_) + f_status_t private_f_string_map_multis_append(const f_string_map_multis_t source, f_string_map_multis_t *destination) { + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_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_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_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 // !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multis_append_) + #if !defined(_di_f_string_map_multis_decrease_by_) || !defined(_di_f_string_map_multis_increase_) || !defined(_di_f_string_map_multis_increase_by_) || !defined(_di_f_string_map_multis_terminate_) || !defined(_di_f_string_map_multis_terminate_after_) f_status_t private_f_string_map_multis_resize(const f_array_length_t length, f_string_map_multis_t *map_multis) { @@ -267,6 +379,64 @@ extern "C" { } #endif // !defined(_di_f_string_map_multis_decrease_by_) || !defined(_di_f_string_map_multis_increase_) || !defined(_di_f_string_map_multis_increase_by_) || !defined(_di_f_string_map_multis_terminate_) || !defined(_di_f_string_map_multis_terminate_after_) +#if !defined(_di_f_string_map_multiss_adjust_) || !defined(_di_f_string_map_multiss_decimate_by_) + f_status_t private_f_string_map_multiss_adjust(const f_array_length_t length, f_string_map_multiss_t *map_multiss) { + + if (map_multiss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < map_multiss->size; ++i) { + + status = private_f_string_map_multis_adjust(0, &map_multiss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(map_multiss->size, length, sizeof(f_string_map_multis_t), (void **) & map_multiss->array); + + if (F_status_is_error_not(status)) { + map_multiss->size = length; + + if (map_multiss->used > map_multiss->size) { + map_multiss->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_string_map_multiss_adjust_) || !defined(_di_f_string_map_multiss_decimate_by_) + +#if !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) || !defined(_di_f_string_map_multiss_terminate_) || !defined(_di_f_string_map_multiss_terminate_after_) + f_status_t private_f_string_map_multiss_resize(const f_array_length_t length, f_string_map_multiss_t *map_multiss) { + + if (map_multiss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < map_multiss->size; ++i) { + + status = private_f_string_map_multis_resize(0, &map_multiss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(map_multiss->size, length, sizeof(f_string_map_multis_t), (void **) & map_multiss->array); + + if (F_status_is_error_not(status)) { + map_multiss->size = length; + + if (map_multiss->used > map_multiss->size) { + map_multiss->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) || !defined(_di_f_string_map_multiss_terminate_) || !defined(_di_f_string_map_multiss_terminate_after_) + #if !defined(_di_f_string_maps_adjust_) || !defined(_di_f_string_maps_decimate_by_) f_status_t private_f_string_maps_adjust(const f_array_length_t length, f_string_maps_t *maps) { @@ -299,6 +469,36 @@ extern "C" { } #endif // !defined(_di_f_string_maps_adjust_) || !defined(_di_f_string_maps_decimate_by_) +#if !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_maps_append_) + f_status_t private_f_string_maps_append(const f_string_maps_t source, f_string_maps_t *destination) { + + f_status_t status = F_none; + + if (destination->used + source.used > destination->size) { + status = private_f_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_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_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 // !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_maps_append_) + #if !defined(_di_f_string_maps_decrease_by_) || !defined(_di_f_string_maps_increase_) || !defined(_di_f_string_maps_increase_by_) || !defined(_di_f_string_maps_terminate_) || !defined(_di_f_string_maps_terminate_after_) f_status_t private_f_string_maps_resize(const f_array_length_t length, f_string_maps_t *maps) { @@ -331,6 +531,64 @@ extern "C" { } #endif // !defined(_di_f_string_maps_decrease_by_) || !defined(_di_f_string_maps_increase_) || !defined(_di_f_string_maps_increase_by_) || !defined(_di_f_string_maps_terminate_) || !defined(_di_f_string_maps_terminate_after_) +#if !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) + f_status_t private_f_string_mapss_adjust(const f_array_length_t length, f_string_mapss_t *mapss) { + + if (mapss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < mapss->size; ++i) { + + status = private_f_string_maps_adjust(0, &mapss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_adjust(mapss->size, length, sizeof(f_string_maps_t), (void **) & mapss->array); + + if (F_status_is_error_not(status)) { + mapss->size = length; + + if (mapss->used > mapss->size) { + mapss->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) + +#if !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) || !defined(_di_f_string_mapss_terminate_) || !defined(_di_f_string_mapss_terminate_after_) + f_status_t private_f_string_mapss_resize(const f_array_length_t length, f_string_mapss_t *mapss) { + + if (mapss->used + length > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + f_status_t status = F_none; + + for (f_array_length_t i = length; i < mapss->size; ++i) { + + status = private_f_string_maps_resize(0, &mapss->array[i]); + if (F_status_is_error(status)) return status; + } // for + + status = f_memory_resize(mapss->size, length, sizeof(f_string_maps_t), (void **) & mapss->array); + + if (F_status_is_error_not(status)) { + mapss->size = length; + + if (mapss->used > mapss->size) { + mapss->used = length; + } + } + + return status; + } +#endif // !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) || !defined(_di_f_string_mapss_terminate_) || !defined(_di_f_string_mapss_terminate_after_) + #if !defined(_di_f_string_dynamic_mish_) || !defined(_di_f_string_dynamic_partial_mish_) || !defined(_di_f_string_dynamic_partial_prepend_assure_) || !defined(_di_f_string_dynamic_partial_prepend_) || !defined(_di_f_string_dynamic_prepend_assure_) || !defined(_di_f_string_dynamic_prepend_) || !defined(_di_f_string_mish_) || !defined(_di_f_string_prepend_assure_) || !defined(_di_f_string_prepend_) f_status_t private_f_string_prepend(const f_string_t source, const f_array_length_t length, f_string_dynamic_t * const destination) { diff --git a/level_0/f_string/c/private-string.h b/level_0/f_string/c/private-string.h index 74511c4..22228c9 100644 --- a/level_0/f_string/c/private-string.h +++ b/level_0/f_string/c/private-string.h @@ -256,8 +256,9 @@ extern "C" { * * 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: f_memory_resize(). * + * @see f_memory_resize() * @see f_string_dynamics_append() * @see f_string_map_multis_append() */ @@ -298,6 +299,85 @@ extern "C" { * * @param length * The new size to use. + * @param dynamicss + * The strings to adjust. + * + * @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_memory_adjust() + * @see f_string_dynamicss_adjust() + * @see f_string_dynamicss_append() + * @see f_string_dynamicss_decimate_by() + * @see f_string_map_multis_adjust() + * @see f_string_map_multis_append() + */ +#if !defined(_di_f_string_dynamicss_adjust_) || !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_dynamicss_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_append_) + extern f_status_t private_f_string_dynamicss_adjust(const f_array_length_t length, f_string_dynamicss_t * const dynamicss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_dynamicss_adjust_) || !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_dynamicss_decimate_by_) || !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_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_resize(). + * + * @see f_memory_resize() + * @see f_string_dynamicss_append() + * @see f_string_map_multis_append() + */ +#if !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_map_multis_append_) + extern f_status_t private_f_string_dynamicss_append(const f_string_dynamicss_t source, f_string_dynamicss_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_dynamicss_append_) || !defined(_di_f_string_map_multis_append_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param dynamicss + * The strings to resize. + * + * @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(). + * + * @see f_memory_resize() + * @see f_string_dynamicss_decrease_by() + * @see f_string_dynamicss_increase() + * @see f_string_dynamicss_increase_by() + */ +#if !defined(_di_f_string_dynamicss_decrease_by_) || !defined(_di_f_string_dynamicss_increase_) || !defined(_di_f_string_dynamicss_increase_by_) + extern f_status_t private_f_string_dynamicss_resize(const f_array_length_t length, f_string_dynamicss_t * const dynamicss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_dynamicss_decrease_by_) || !defined(_di_f_string_dynamicss_increase_) || !defined(_di_f_string_dynamicss_increase_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. * @param map_multis * The map_multis to adjust. * @@ -316,6 +396,33 @@ extern "C" { #endif // !defined(_di_f_string_map_multis_adjust_) || !defined(_di_f_string_map_multis_decimate_by_) /** + * 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_resize(). + * Errors (with error bit) from: f_string_map_multis_append(). + * Errors (with error bit) from: f_string_map_multiss_append(). + * + * @see f_memory_resize() + * @see f_string_map_multis_append() + * @see f_string_map_multiss_append() + */ +#if !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multis_append_) + extern f_status_t private_f_string_map_multis_append(const f_string_map_multis_t source, f_string_map_multis_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_map_multiss_append_) || !defined(_di_f_string_map_multis_append_) + +/** * Private implementation for resizing. * * Intended to be shared to each of the different implementation variations. @@ -350,6 +457,58 @@ extern "C" { * * @param length * The new size to use. + * @param map_multiss + * The map_multiss to adjust. + * + * @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_memory_adjust() + * @see f_string_map_multiss_adjust() + */ +#if !defined(_di_f_string_map_multiss_adjust_) || !defined(_di_f_string_map_multiss_decimate_by_) + extern f_status_t private_f_string_map_multiss_adjust(const f_array_length_t length, f_string_map_multiss_t *map_multiss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_map_multiss_adjust_) || !defined(_di_f_string_map_multiss_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param map_multiss + * The map_multiss to resize. + * + * @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(). + * + * @see f_memory_adjust() + * @see f_string_map_multiss_decrease_by() + * @see f_string_map_multiss_increase() + * @see f_string_map_multiss_increase_by() + * @see f_string_map_multiss_terminate() + * @see f_string_map_multiss_terminate_after() + */ +#if !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) || !defined(_di_f_string_map_multiss_terminate_) || !defined(_di_f_string_map_multiss_terminate_after_) + extern f_status_t private_f_string_map_multiss_resize(const f_array_length_t length, f_string_map_multiss_t *map_multiss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_map_multiss_decrease_by_) || !defined(_di_f_string_map_multiss_increase_) || !defined(_di_f_string_map_multiss_increase_by_) || !defined(_di_f_string_map_multiss_terminate_) || !defined(_di_f_string_map_multiss_terminate_after_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. * @param maps * The maps to adjust. * @@ -368,6 +527,31 @@ extern "C" { #endif // !defined(_di_f_string_maps_adjust_) || !defined(_di_f_string_maps_decimate_by_) /** + * 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_resize(). + * + * @see f_memory_resize() + * @see f_string_maps_append() + * @see f_string_mapss_append() + */ +#if !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_maps_append_) + extern f_status_t private_f_string_maps_append(const f_string_maps_t source, f_string_maps_t *destination) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_mapss_append_) || !defined(_di_f_string_maps_append_) + +/** * Private implementation for resizing. * * Intended to be shared to each of the different implementation variations. @@ -396,6 +580,58 @@ extern "C" { #endif // !defined(_di_f_string_maps_decrease_by_) || !defined(_di_f_string_maps_increase_) || !defined(_di_f_string_maps_increase_by_) || !defined(_di_f_string_maps_terminate_) || !defined(_di_f_string_maps_terminate_after_) /** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param mapss + * The mapss to adjust. + * + * @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_memory_adjust() + * @see f_string_mapss_adjust() + */ +#if !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) + extern f_status_t private_f_string_mapss_adjust(const f_array_length_t length, f_string_mapss_t *mapss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_mapss_adjust_) || !defined(_di_f_string_mapss_decimate_by_) + +/** + * Private implementation for resizing. + * + * Intended to be shared to each of the different implementation variations. + * + * @param length + * The new size to use. + * @param mapss + * The mapss to resize. + * + * @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(). + * + * @see f_memory_adjust() + * @see f_string_mapss_decrease_by() + * @see f_string_mapss_increase() + * @see f_string_mapss_increase_by() + * @see f_string_mapss_terminate() + * @see f_string_mapss_terminate_after() + */ +#if !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) || !defined(_di_f_string_mapss_terminate_) || !defined(_di_f_string_mapss_terminate_after_) + extern f_status_t private_f_string_mapss_resize(const f_array_length_t length, f_string_mapss_t *mapss) F_attribute_visibility_internal_d; +#endif // !defined(_di_f_string_mapss_decrease_by_) || !defined(_di_f_string_mapss_increase_) || !defined(_di_f_string_mapss_increase_by_) || !defined(_di_f_string_mapss_terminate_) || !defined(_di_f_string_mapss_terminate_after_) + +/** * Private implementation of f_string_prepend(). * * Intended to be shared to each of the different implementation variations. diff --git a/level_0/f_string/c/string_dynamic.c b/level_0/f_string/c/string_dynamic.c index a80ed02..8578ecf 100644 --- a/level_0/f_string/c/string_dynamic.c +++ b/level_0/f_string/c/string_dynamic.c @@ -1130,6 +1130,113 @@ extern "C" { } #endif // _di_f_string_dynamics_resize_ +#ifndef _di_f_string_dynamicss_adjust_ + f_status_t f_string_dynamicss_adjust(const f_array_length_t length, f_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_string_dynamicss_adjust(length, dynamicss); + } +#endif // _di_f_string_dynamicss_adjust_ + +#ifndef _di_f_string_dynamicss_append_ + f_status_t f_string_dynamicss_append(const f_string_dynamicss_t source, f_string_dynamicss_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_string_dynamicss_append(source, destination); + } +#endif // _di_f_string_dynamicss_append_ + +#ifndef _di_f_string_dynamicss_decimate_by_ + f_status_t f_string_dynamicss_decimate_by(const f_array_length_t amount, f_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (dynamicss->size - amount > 0) { + return private_f_string_dynamicss_adjust(dynamicss->size - amount, dynamicss); + } + + return private_f_string_dynamicss_adjust(0, dynamicss); + } +#endif // _di_f_string_dynamicss_decimate_by_ + +#ifndef _di_f_string_dynamicss_decrease_by_ + f_status_t f_string_dynamicss_decrease_by(const f_array_length_t amount, f_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (dynamicss->size - amount > 0) { + return private_f_string_dynamicss_resize(dynamicss->size - amount, dynamicss); + } + + return private_f_string_dynamicss_resize(0, dynamicss); + } +#endif // _di_f_string_dynamicss_decrease_by_ + +#ifndef _di_f_string_dynamicss_increase_ + f_status_t f_string_dynamicss_increase(const uint16_t step, f_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (dynamicss->used + 1 > dynamicss->size) { + f_array_length_t size = dynamicss->used + step; + + if (size > F_array_length_t_size_d) { + if (dynamicss->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_string_dynamicss_resize(size, dynamicss); + } + + return F_data_not; + } +#endif // _di_f_string_dynamicss_increase_ + +#ifndef _di_f_string_dynamicss_increase_by_ + f_status_t f_string_dynamicss_increase_by(const f_array_length_t amount, f_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (dynamicss->used + amount > dynamicss->size) { + if (dynamicss->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_string_dynamicss_resize(dynamicss->used + amount, dynamicss); + } + + return F_data_not; + } +#endif // _di_f_string_dynamicss_increase_by_ + +#ifndef _di_f_string_dynamicss_resize_ + f_status_t f_string_dynamicss_resize(const f_array_length_t length, f_string_dynamicss_t * const dynamicss) { + #ifndef _di_level_0_parameter_checking_ + if (!dynamicss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_string_dynamicss_resize(length, dynamicss); + } +#endif // _di_f_string_dynamicss_resize_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string_dynamic.h b/level_0/f_string/c/string_dynamic.h index 48c6175..cf56e8d 100644 --- a/level_0/f_string/c/string_dynamic.h +++ b/level_0/f_string/c/string_dynamic.h @@ -82,9 +82,9 @@ extern "C" { #endif // _di_f_string_dynamic_t_ /** - * An array of static dynamics. + * An array of static strings. * - * array: The array of static dynamics. + * array: The array of static strings. * size: Total amount of space available. * used: Total number of space used. */ @@ -131,6 +131,55 @@ extern "C" { #endif // _di_f_string_dynamics_t_ /** + * An array of static strings. + * + * array: The array of static strings. + * size: Total amount of space available. + * used: Total number of space used. + */ +#ifndef _di_f_string_staticss_t_ + typedef struct { + f_string_statics_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_string_staticss_t; + + #define f_string_staticss_t_initialize { 0, 0, 0 } + + #define macro_f_string_staticss_t_clear(staticss) \ + staticss.array = 0; \ + staticss.size = 0; \ + staticss.used = 0; +#endif // _di_f_string_staticss_t_ + +/** + * An array of dynamic dynamicss. + * + * array: The array of dynamic dynamicss. + * size: Total amount of allocated space. + * used: Total number of allocated spaces used. + */ +#ifndef _di_f_string_dynamicss_t_ + typedef f_string_staticss_t f_string_dynamicss_t; + + #define f_string_dynamicss_t_initialize f_string_staticss_t_initialize + + #define macro_f_string_dynamicss_t_clear(dynamicss) macro_f_string_staticss_t_clear(dynamicss) + + #define macro_f_string_dynamicss_t_resize(status, dynamicss, length) status = f_string_dynamicss_resize(length, &dynamicss); + #define macro_f_string_dynamicss_t_adjust(status, dynamicss, length) status = f_string_dynamicss_adjust(length, &dynamicss); + + #define macro_f_string_dynamicss_t_delete_simple(dynamicss) f_string_dynamicss_resize(0, &dynamicss); + #define macro_f_string_dynamicss_t_destroy_simple(dynamicss) f_string_dynamicss_adjust(0, &dynamicss); + + #define macro_f_string_dynamicss_t_increase(status, step, dynamicss) status = f_string_dynamicss_increase(step, &dynamicss); + #define macro_f_string_dynamicss_t_increase_by(status, dynamicss, amount) status = f_string_dynamicss_increase_by(amount, &dynamicss); + #define macro_f_string_dynamicss_t_decrease_by(status, dynamicss, amount) status = f_string_dynamicss_decrease_by(amount, &dynamicss); + #define macro_f_string_dynamicss_t_decimate_by(status, dynamicss, amount) status = f_string_dynamicss_decimate_by(amount, &dynamicss); +#endif // _di_f_string_dynamicss_t_ + +/** * Provide a static empty string. * * This is intended to represent an empty string. @@ -1612,6 +1661,163 @@ extern "C" { extern f_status_t f_string_dynamics_resize(const f_array_length_t length, f_string_dynamics_t * const dynamics); #endif // _di_f_string_dynamics_resize_ +/** + * Resize the dynamics string array. + * + * @param length + * The new size to use. + * @param dynamicss + * The array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_adjust(). + */ +#ifndef _di_f_string_dynamicss_adjust_ + extern f_status_t f_string_dynamicss_adjust(const f_array_length_t length, f_string_dynamicss_t * const dynamicss); +#endif // _di_f_string_dynamicss_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_string_dynamicss_append_ + extern f_status_t f_string_dynamicss_append(const f_string_dynamicss_t source, f_string_dynamicss_t *destination); +#endif // _di_f_string_dynamicss_append_ + +/** + * Resize the dynamics string array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param dynamicss + * The array to resize. + * + * @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. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_dynamicss_decimate_by_ + extern f_status_t f_string_dynamicss_decimate_by(const f_array_length_t amount, f_string_dynamicss_t * const dynamicss); +#endif // _di_f_string_dynamicss_decimate_by_ + +/** + * Resize the dynamics string array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param dynamicss + * The array to resize. + * + * @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. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_dynamicss_decrease_by_ + extern f_status_t f_string_dynamicss_decrease_by(const f_array_length_t amount, f_string_dynamicss_t * const dynamicss); +#endif // _di_f_string_dynamicss_decrease_by_ + +/** + * Increase the size of the dynamics string array, but only if necessary. + * + * If the given length is too large for the buffer, then attempt to set max buffer size (F_array_length_t_size_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param step + * The allocation step to use. + * Must be greater than 0. + * @param dynamicss + * The 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_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_dynamicss_increase_ + extern f_status_t f_string_dynamicss_increase(const uint16_t step, f_string_dynamicss_t * const dynamicss); +#endif // _di_f_string_dynamicss_increase_ + +/** + * Resize the dynamics string array to a larger size. + * + * This will resize making the array 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_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param dynamicss + * The 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_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_string_dynamicss_increase_by_ + extern f_status_t f_string_dynamicss_increase_by(const f_array_length_t amount, f_string_dynamicss_t * const dynamicss); +#endif // _di_f_string_dynamicss_increase_by_ + +/** + * Resize the dynamics string array. + * + * @param length + * The new size to use. + * @param dynamicss + * The array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_dynamicss_resize_ + extern f_status_t f_string_dynamicss_resize(const f_array_length_t length, f_string_dynamicss_t * const dynamicss); +#endif // _di_f_string_dynamicss_resize_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string_map.c b/level_0/f_string/c/string_map.c index ce80853..8e7f0cd 100644 --- a/level_0/f_string/c/string_map.c +++ b/level_0/f_string/c/string_map.c @@ -132,49 +132,147 @@ extern "C" { } #endif // _di_f_string_map_multis_resize_ -#ifndef _di_f_string_maps_adjust_ - f_status_t f_string_maps_adjust(const f_array_length_t length, f_string_maps_t * const maps) { +#ifndef _di_f_string_map_multiss_adjust_ + f_status_t f_string_map_multiss_adjust(const f_array_length_t length, f_string_map_multiss_t * const map_multiss) { #ifndef _di_level_0_parameter_checking_ - if (!maps) return F_status_set_error(F_parameter); + if (!map_multiss) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ - return private_f_string_maps_adjust(length, maps); + return private_f_string_map_multiss_adjust(length, map_multiss); } -#endif // _di_f_string_maps_adjust_ +#endif // _di_f_string_map_multiss_adjust_ -#ifndef _di_f_string_maps_append_ - f_status_t f_string_maps_append(const f_string_maps_t source, f_string_maps_t * const destination) { +#ifndef _di_f_string_map_multiss_append_ + f_status_t f_string_map_multiss_append(const f_string_map_multiss_t source, f_string_map_multiss_t * const 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_string_maps_resize(destination->used + source.used, destination); + status = private_f_string_map_multiss_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; + destination->array[destination->used].used = 0; - if (source.array[i].name.used) { - status = private_f_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_string_append(source.array[i].value.string, source.array[i].value.used, &destination->array[destination->used].value); + if (source.array[i].used) { + status = private_f_string_map_multis_append(source.array[i], &destination->array[destination->used]); if (F_status_is_error(status)) return status; } } // for return F_none; } +#endif // _di_f_string_map_multiss_append_ + +#ifndef _di_f_string_map_multiss_decimate_by_ + f_status_t f_string_map_multiss_decimate_by(const f_array_length_t amount, f_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (map_multiss->size - amount > 0) { + return private_f_string_map_multiss_adjust(map_multiss->size - amount, map_multiss); + } + + return private_f_string_map_multiss_adjust(0, map_multiss); + } +#endif // _di_f_string_map_multiss_decimate_by_ + +#ifndef _di_f_string_map_multiss_decrease_by_ + f_status_t f_string_map_multiss_decrease_by(const f_array_length_t amount, f_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (map_multiss->size - amount > 0) { + return private_f_string_map_multiss_resize(map_multiss->size - amount, map_multiss); + } + + return private_f_string_map_multiss_resize(0, map_multiss); + } +#endif // _di_f_string_map_multiss_decrease_by_ + +#ifndef _di_f_string_map_multiss_increase_ + f_status_t f_string_map_multiss_increase(const uint16_t step, f_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (map_multiss->used + 1 > map_multiss->size) { + f_array_length_t size = map_multiss->used + step; + + if (size > F_array_length_t_size_d) { + if (map_multiss->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_string_map_multiss_resize(size, map_multiss); + } + + return F_data_not; + } +#endif // _di_f_string_map_multiss_increase_ + +#ifndef _di_f_string_map_multiss_increase_by_ + f_status_t f_string_map_multiss_increase_by(const f_array_length_t amount, f_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (map_multiss->used + amount > map_multiss->size) { + if (map_multiss->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_string_map_multiss_resize(map_multiss->used + amount, map_multiss); + } + + return F_data_not; + } +#endif // _di_f_string_map_multiss_increase_by_ + +#ifndef _di_f_string_map_multiss_resize_ + f_status_t f_string_map_multiss_resize(const f_array_length_t length, f_string_map_multiss_t * const map_multiss) { + #ifndef _di_level_0_parameter_checking_ + if (!map_multiss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_string_map_multiss_resize(length, map_multiss); + } +#endif // _di_f_string_map_multiss_resize_ + +#ifndef _di_f_string_maps_adjust_ + f_status_t f_string_maps_adjust(const f_array_length_t length, f_string_maps_t * const maps) { + #ifndef _di_level_0_parameter_checking_ + if (!maps) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_string_maps_adjust(length, maps); + } +#endif // _di_f_string_maps_adjust_ + +#ifndef _di_f_string_maps_append_ + f_status_t f_string_maps_append(const f_string_maps_t source, f_string_maps_t * const 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_string_maps_append(source, destination); + } #endif // _di_f_string_maps_append_ #ifndef _di_f_string_maps_decimate_by_ @@ -261,6 +359,129 @@ extern "C" { } #endif // _di_f_string_maps_resize_ +#ifndef _di_f_string_mapss_adjust_ + f_status_t f_string_mapss_adjust(const f_array_length_t length, f_string_mapss_t * const mapss) { + #ifndef _di_level_0_parameter_checking_ + if (!mapss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_string_mapss_adjust(length, mapss); + } +#endif // _di_f_string_mapss_adjust_ + +#ifndef _di_f_string_mapss_append_ + f_status_t f_string_mapss_append(const f_string_mapss_t source, f_string_mapss_t * const 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_string_mapss_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].used = 0; + + if (source.array[i].used) { + status = private_f_string_maps_append(source.array[i], &destination->array[destination->used]); + if (F_status_is_error(status)) return status; + } + } // for + + return F_none; + } +#endif // _di_f_string_mapss_append_ + +#ifndef _di_f_string_mapss_decimate_by_ + f_status_t f_string_mapss_decimate_by(const f_array_length_t amount, f_string_mapss_t * const mapss) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!mapss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (mapss->size - amount > 0) { + return private_f_string_mapss_adjust(mapss->size - amount, mapss); + } + + return private_f_string_mapss_adjust(0, mapss); + } +#endif // _di_f_string_mapss_decimate_by_ + +#ifndef _di_f_string_mapss_decrease_by_ + f_status_t f_string_mapss_decrease_by(const f_array_length_t amount, f_string_mapss_t * const mapss) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!mapss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (mapss->size - amount > 0) { + return private_f_string_mapss_resize(mapss->size - amount, mapss); + } + + return private_f_string_mapss_resize(0, mapss); + } +#endif // _di_f_string_mapss_decrease_by_ + +#ifndef _di_f_string_mapss_increase_ + f_status_t f_string_mapss_increase(const uint16_t step, f_string_mapss_t * const mapss) { + #ifndef _di_level_0_parameter_checking_ + if (!step) return F_status_set_error(F_parameter); + if (!mapss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (mapss->used + 1 > mapss->size) { + f_array_length_t size = mapss->used + step; + + if (size > F_array_length_t_size_d) { + if (mapss->used + 1 > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + size = F_array_length_t_size_d; + } + + return private_f_string_mapss_resize(size, mapss); + } + + return F_data_not; + } +#endif // _di_f_string_mapss_increase_ + +#ifndef _di_f_string_mapss_increase_by_ + f_status_t f_string_mapss_increase_by(const f_array_length_t amount, f_string_mapss_t * const mapss) { + #ifndef _di_level_0_parameter_checking_ + if (!amount) return F_status_set_error(F_parameter); + if (!mapss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (mapss->used + amount > mapss->size) { + if (mapss->used + amount > F_array_length_t_size_d) { + return F_status_set_error(F_array_too_large); + } + + return private_f_string_mapss_resize(mapss->used + amount, mapss); + } + + return F_data_not; + } +#endif // _di_f_string_mapss_increase_by_ + +#ifndef _di_f_string_mapss_resize_ + f_status_t f_string_mapss_resize(const f_array_length_t length, f_string_mapss_t * const mapss) { + #ifndef _di_level_0_parameter_checking_ + if (!mapss) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + return private_f_string_mapss_resize(length, mapss); + } +#endif // _di_f_string_mapss_resize_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_string/c/string_map.h b/level_0/f_string/c/string_map.h index e3bbd46..ee156de 100644 --- a/level_0/f_string/c/string_map.h +++ b/level_0/f_string/c/string_map.h @@ -75,6 +75,37 @@ extern "C" { #endif // _di_f_string_maps_t_ /** + * An array of string maps. + * + * array: the array of an array of string maps. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_string_mapss_t_ + typedef struct { + f_string_maps_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_string_mapss_t; + + #define f_string_mapss_t_initialize f_string_statics_t_initialize + + #define macro_f_string_mapss_t_clear(maps) macro_f_memory_structure_clear(maps) + + #define macro_f_string_mapss_t_resize(status, maps, length) status = f_string_mapss_resize(length, &maps); + #define macro_f_string_mapss_t_adjust(status, maps, length) status = f_string_mapss_adjust(length, &maps); + + #define macro_f_string_mapss_t_delete_simple(maps) f_string_mapss_resize(0, &maps); + #define macro_f_string_mapss_t_destroy_simple(maps) f_string_mapss_adjust(0, &maps); + + #define macro_f_string_mapss_t_increase(status, step, maps) status = f_string_mapss_increase(step, maps); + #define macro_f_string_mapss_t_increase_by(status, maps, amount) status = f_string_mapss_increase_by(amount, maps); + #define macro_f_string_mapss_t_decrease_by(status, maps, amount) status = f_string_mapss_decrease_by(amount, maps); + #define macro_f_string_mapss_t_decimate_by(status, maps, amount) status = f_string_mapss_decimate_by(amount, maps); +#endif // _di_f_string_mapss_t_ + +/** * A string map consisting of a name and multiple values. * * name: A string representing the map name. @@ -133,6 +164,37 @@ extern "C" { #endif // _di_f_string_map_multis_t_ /** + * An array of string maps. + * + * array: the array of an array of string maps. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_string_map_multiss_t_ + typedef struct { + f_string_map_multis_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_string_map_multiss_t; + + #define f_string_map_multiss_t_initialize f_string_statics_t_initialize + + #define macro_f_string_map_multiss_t_clear(map_multis) macro_f_memory_structure_clear(map_multis) + + #define macro_f_string_map_multiss_t_resize(status, map_multis, length) status = f_string_map_multiss_resize(length, &map_multis); + #define macro_f_string_map_multiss_t_adjust(status, map_multis, length) status = f_string_map_multiss_adjust(length, &map_multis); + + #define macro_f_string_map_multiss_t_delete_simple(map_multis) f_string_map_multiss_resize(0, &map_multis); + #define macro_f_string_map_multiss_t_destroy_simple(map_multis) f_string_map_multiss_adjust(0, &map_multis); + + #define macro_f_string_map_multiss_t_increase(status, step, map_multis) status = f_string_map_multiss_increase(step, &map_multis); + #define macro_f_string_map_multiss_t_increase_by(status, map_multis, amount) status = f_string_map_multiss_increase_by(amount, &map_multis); + #define macro_f_string_map_multiss_t_decrease_by(status, map_multis, amount) status = f_string_map_multiss_decrease_by(amount, &map_multis); + #define macro_f_string_map_multiss_t_decimate_by(status, map_multis, amount) status = f_string_map_multiss_decimate_by(amount, &map_multis); +#endif // _di_f_string_map_multiss_t_ + +/** * Resize the map_multis array. * * @param length @@ -442,6 +504,161 @@ extern "C" { extern f_status_t f_string_maps_resize(const f_array_length_t length, f_string_maps_t * const maps); #endif // _di_f_string_maps_resize_ +/** + * Resize the string mapss array. + * + * @param length + * The new size to use. + * @param mapss + * The string mapss array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_mapss_adjust_ + extern f_status_t f_string_mapss_adjust(const f_array_length_t length, f_string_mapss_t * const mapss); +#endif // _di_f_string_mapss_adjust_ + +/** + * Append the source mapss onto the destination. + * + * @param source + * The source mapss to append. + * @param destination + * The destination mapss 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_string_mapss_append_ + extern f_status_t f_string_mapss_append(const f_string_mapss_t source, f_string_mapss_t * const destination); +#endif // _di_f_string_mapss_append_ + +/** + * Resize the string mapss array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decimate the size by. + * @param mapss + * The string mapss array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_mapss_decimate_by_ + extern f_status_t f_string_mapss_decimate_by(const f_array_length_t amount, f_string_mapss_t * const mapss); +#endif // _di_f_string_mapss_decimate_by_ + +/** + * Resize the string mapss array to a smaller size. + * + * This will resize making the array smaller based on (size - given length). + * If the given length is too small, then the resize will fail. + * This will not shrink the size to less than 0. + * + * @param amount + * A positive number representing how much to decrease the size by. + * @param mapss + * The string mapss array to resize. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_mapss_decrease_by_ + extern f_status_t f_string_mapss_decrease_by(const f_array_length_t amount, f_string_mapss_t * const mapss); +#endif // _di_f_string_mapss_decrease_by_ + +/** + * Increase the size of the string mapss 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_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param step + * The allocation step to use. + * Must be greater than 0. + * @param mapss + * The string mapss 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_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_mapss_increase_ + extern f_status_t f_string_mapss_increase(const uint16_t step, f_string_mapss_t * const mapss); +#endif // _di_f_string_mapss_increase_ + +/** + * Resize the string mapss 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_d). + * If already set to the maximum buffer size, then the resize will fail. + * + * @param amount + * A positive number representing how much to increase the size by. + * @param mapss + * The string mapss 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_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_string_mapss_increase_by_ + extern f_status_t f_string_mapss_increase_by(const f_array_length_t amount, f_string_mapss_t * const mapss); +#endif // _di_f_string_mapss_increase_by_ + +/** + * Resize the string mapss array. + * + * @param length + * The new size to use. + * @param mapss + * The string mapss array to adjust. + * + * @return + * F_none on success. + * + * F_parameter (with error bit) if a parameter is invalid. + * + * Errors (with error bit) from: f_memory_resize(). + */ +#ifndef _di_f_string_mapss_resize_ + extern f_status_t f_string_mapss_resize(const f_array_length_t length, f_string_mapss_t * const mapss); +#endif // _di_f_string_mapss_resize_ + #ifdef __cplusplus } // extern "C" #endif diff --git a/level_0/f_type/c/type.h b/level_0/f_type/c/type.h index 632a178..973e84f 100644 --- a/level_0/f_type/c/type.h +++ b/level_0/f_type/c/type.h @@ -558,7 +558,7 @@ extern "C" { * size: Total amount of allocated space. * used: Total number of allocated spaces used. */ -#ifndef _di_f_array_t_int8_t_ +#ifndef _di_int8s_t_ typedef struct { int8_t *array; diff --git a/level_0/f_type_array/c/type_array-common.h b/level_0/f_type_array/c/type_array-common.h index 065f8ea..fbd636c 100644 --- a/level_0/f_type_array/c/type_array-common.h +++ b/level_0/f_type_array/c/type_array-common.h @@ -197,9 +197,9 @@ extern "C" { #endif // _di_f_array_lengthss_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for int8_t, see type.h for typedefs. */ -#ifndef _di_f_array_t_int8_t_ +#ifndef _di_f_int8_t_ #define macro_f_int8s_t_clear(int8s) macro_f_memory_structures_clear(int8s) #define macro_f_int8s_t_resize(status, int8s, length) status = f_type_int8s_resize(length, &int8s); @@ -212,12 +212,12 @@ extern "C" { #define macro_f_int8s_t_delete_simple(int8s) f_type_int8s_resize(0, &int8s); #define macro_f_int8s_t_destroy_simple(int8s) f_type_int8s_adjust(0, &int8s); -#endif // _di_int8s_t_ +#endif // _di_f_int8_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_int8s_t, see type.h for typedefs. */ -#ifndef _di_int8ss_t_ +#ifndef _di_f_int8ss_t_ #define macro_f_int8ss_t_clear(int8ss) macro_f_memory_structures_clear(int8ss) #define macro_f_int8ss_t_resize(status, int8ss, length) status = f_type_int8ss_resize(length, &int8ss); @@ -230,12 +230,12 @@ extern "C" { #define macro_f_int8ss_t_delete_simple(int8ss) f_type_int8ss_resize(0, &int8ss); #define macro_f_int8ss_t_destroy_simple(int8ss) f_type_int8ss_adjust(0, &int8ss); -#endif // _di_int8ss_t_ +#endif // _di_f_int8ss_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_uint8s_t, see type.h for typedefs. */ -#ifndef _di_uint8s_t_ +#ifndef _di_f_uint8s_t_ #define macro_f_uint8s_t_clear(uint8s) macro_f_memory_structures_clear(uint8s) #define macro_f_uint8s_t_resize(status, uint8s, length) status = f_type_uint8s_resize(length, &uint8s); @@ -248,12 +248,12 @@ extern "C" { #define macro_f_uint8s_t_increase_by(status, uint8s, amount) status = f_type_uint8s_increase_by(amount, &uint8s); #define macro_f_uint8s_t_decrease_by(status, uint8s, amount) status = f_type_uint8s_decrease_by(amount, &uint8s); #define macro_f_uint8s_t_decimate_by(status, uint8s, amount) status = f_type_uint8s_decimate_by(amount, &uint8s); -#endif // _di_uint8s_t_ +#endif // _di_f_uint8s_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_uint8ss_t, see type.h for typedefs. */ -#ifndef _di_uint8ss_t_ +#ifndef _di_f_uint8ss_t_ #define macro_f_uint8ss_t_clear(uint8ss) macro_f_memory_structures_clear(uint8ss) #define macro_f_uint8ss_t_resize(status, uint8ss, length) status = f_type_uint8ss_resize(length, &uint8ss); @@ -266,12 +266,12 @@ extern "C" { #define macro_f_uint8ss_t_increase_by(status, uint8ss, amount) status = f_type_uint8ss_increase_by(amount, &uint8ss); #define macro_f_uint8ss_t_decrease_by(status, uint8ss, amount) status = f_type_uint8ss_decrease_by(amount, &uint8ss); #define macro_f_uint8ss_t_decimate_by(status, uint8ss, amount) status = f_type_uint8ss_decimate_by(amount, &uint8ss); -#endif // _di_uint8ss_t_ +#endif // _di_f_uint8ss_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_int16s_t, see type.h for typedefs. */ -#ifndef _di_int16s_t_ +#ifndef _di_f_int16s_t_ #define macro_f_int16s_t_clear(int16s) macro_f_memory_structures_clear(int16s) #define macro_f_int16s_t_resize(status, int16s, length) status = f_type_int16s_resize(length, &int16s); @@ -284,12 +284,12 @@ extern "C" { #define macro_f_int16s_t_delete_simple(int16s) f_type_int16s_resize(0, &int16s); #define macro_f_int16s_t_destroy_simple(int16s) f_type_int16s_adjust(0, &int16s); -#endif // _di_int16s_t_ +#endif // _di_f_int16s_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_int16ss_t, see type.h for typedefs. */ -#ifndef _di_int16ss_t_ +#ifndef _di_f_int16ss_t_ #define macro_f_int16ss_t_clear(int16ss) macro_f_memory_structures_clear(int16ss) #define macro_f_int16ss_t_resize(status, int16ss, length) status = f_type_int16ss_resize(length, &int16ss); @@ -302,12 +302,12 @@ extern "C" { #define macro_f_int16ss_t_delete_simple(int16ss) f_type_int16ss_resize(0, &int16ss); #define macro_f_int16ss_t_destroy_simple(int16ss) f_type_int16ss_adjust(0, &int16ss); -#endif // _di_int16ss_t_ +#endif // _di_f_int16ss_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_uint16s_t, see type.h for typedefs. */ -#ifndef _di_uint16s_t_ +#ifndef _di_f_uint16s_t_ #define macro_f_uint16s_t_clear(uint16s) macro_f_memory_structures_clear(uint16s) #define macro_f_uint16s_t_resize(status, uint16s, length) status = f_type_uint16s_resize(length, &uint16s); @@ -320,12 +320,12 @@ extern "C" { #define macro_f_uint16s_t_increase_by(status, uint16s, amount) status = f_type_uint16s_increase_by(amount, &uint16s); #define macro_f_uint16s_t_decrease_by(status, uint16s, amount) status = f_type_uint16s_decrease_by(amount, &uint16s); #define macro_f_uint16s_t_decimate_by(status, uint16s, amount) status = f_type_uint16s_decimate_by(amount, &uint16s); -#endif // _di_uint16s_t_ +#endif // _di_f_uint16s_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_uint16ss_t, see type.h for typedefs. */ -#ifndef _di_uint16ss_t_ +#ifndef _di_f_uint16ss_t_ #define macro_f_uint16ss_t_clear(uint16ss) macro_f_memory_structures_clear(uint16ss) #define macro_f_uint16ss_t_resize(status, uint16ss, length) status = f_type_uint16ss_resize(length, &uint16ss); @@ -338,12 +338,12 @@ extern "C" { #define macro_f_uint16ss_t_increase_by(status, uint16ss, amount) status = f_type_uint16ss_increase_by(amount, &uint16ss); #define macro_f_uint16ss_t_decrease_by(status, uint16ss, amount) status = f_type_uint16ss_decrease_by(amount, &uint16ss); #define macro_f_uint16ss_t_decimate_by(status, uint16ss, amount) status = f_type_uint16ss_decimate_by(amount, &uint16ss); -#endif // _di_uint16ss_t_ +#endif // _di_f_uint16ss_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_int32s_t, see type.h for typedefs. */ -#ifndef _di_int32s_t_ +#ifndef _di_f_int32s_t_ #define macro_f_int32s_t_clear(int32s) macro_f_memory_structures_clear(int32s) #define macro_f_int32s_t_resize(status, int32s, length) status = f_type_int32s_resize(length, &int32s); @@ -356,12 +356,12 @@ extern "C" { #define macro_f_int32s_t_increase_by(status, int32s, amount) status = f_type_int32s_increase_by(amount, &int32s); #define macro_f_int32s_t_decrease_by(status, int32s, amount) status = f_type_int32s_decrease_by(amount, &int32s); #define macro_f_int32s_t_decimate_by(status, int32s, amount) status = f_type_int32s_decimate_by(amount, &int32s); -#endif // _di_int32s_t_ +#endif // _di_f_int32s_t_ /** * Macros for f_array_lengths_t, see type.h for typedefs. */ -#ifndef _di_int32ss_t_ +#ifndef _di_f_int32ss_t_ #define macro_f_int32ss_t_clear(int32ss) macro_f_memory_structures_clear(int32ss) #define macro_f_int32ss_t_resize(status, int32ss, length) status = f_type_int32ss_resize(length, &int32ss); @@ -374,12 +374,12 @@ extern "C" { #define macro_f_int32ss_t_increase_by(status, int32ss, amount) status = f_type_int32ss_increase_by(amount, &int32ss); #define macro_f_int32ss_t_decrease_by(status, int32ss, amount) status = f_type_int32ss_decrease_by(amount, &int32ss); #define macro_f_int32ss_t_decimate_by(status, int32ss, amount) status = f_type_int32ss_decimate_by(amount, &int32ss); -#endif // _di_int32ss_t_ +#endif // _di_f_int32ss_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_uint32s_t, see type.h for typedefs. */ -#ifndef _di_uint32s_t_ +#ifndef _di_f_uint32s_t_ #define macro_f_uint32s_t_clear(uint32s) macro_f_memory_structures_clear(uint32s) #define macro_f_uint32s_t_resize(status, uint32s, length) status = f_type_uint32s_resize(length, &uint32s); @@ -392,12 +392,12 @@ extern "C" { #define macro_f_uint32s_t_increase_by(status, uint32s, amount) status = f_type_uint32s_increase_by(amount, &uint32s); #define macro_f_uint32s_t_decrease_by(status, uint32s, amount) status = f_type_uint32s_decrease_by(amount, &uint32s); #define macro_f_uint32s_t_decimate_by(status, uint32s, amount) status = f_type_uint32s_decimate_by(amount, &uint32s); -#endif // _di_uint32s_t_ +#endif // _di_f_uint32s_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_uint32ss_t, see type.h for typedefs. */ -#ifndef _di_uint32ss_t_ +#ifndef _di_f_uint32ss_t_ #define macro_f_uint32ss_t_clear(uint32ss) macro_f_memory_structures_clear(uint32ss) #define macro_f_uint32ss_t_resize(status, uint32ss, length) status = f_type_uint32ss_resize(length, &uint32ss); @@ -410,12 +410,12 @@ extern "C" { #define macro_f_uint32ss_t_increase_by(status, uint32ss, amount) status = f_type_uint32ss_increase_by(amount, &uint32ss); #define macro_f_uint32ss_t_decrease_by(status, uint32ss, amount) status = f_type_uint32ss_decrease_by(amount, &uint32ss); #define macro_f_uint32ss_t_decimate_by(status, uint32ss, amount) status = f_type_uint32ss_decimate_by(amount, &uint32ss); -#endif // _di_uint32ss_t_ +#endif // _di_f_uint32ss_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_int64s_t, see type.h for typedefs. */ -#ifndef _di_int64s_t_ +#ifndef _di_f_int64s_t_ #define macro_f_int64s_t_clear(int64s) macro_f_memory_structures_clear(int64s) #define macro_f_int64s_t_resize(status, int64s, length) status = f_type_int64s_resize(length, &int64s); @@ -428,12 +428,12 @@ extern "C" { #define macro_f_int64s_t_delete_simple(int64s) f_type_int64s_resize(0, &int64s); #define macro_f_int64s_t_destroy_simple(int64s) f_type_int64s_adjust(0, &int64s); -#endif // _di_int64s_t_ +#endif // _di_f_int64s_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_int64ss_t, see type.h for typedefs. */ -#ifndef _di_int64ss_t_ +#ifndef _di_f_int64ss_t_ #define macro_f_int64ss_t_clear(int64ss) macro_f_memory_structures_clear(int64ss) #define macro_f_int64ss_t_resize(status, int64ss, length) status = f_type_int64ss_resize(length, &int64ss); @@ -446,12 +446,12 @@ extern "C" { #define macro_f_int64ss_t_delete_simple(int64ss) f_type_int64ss_resize(0, &int64ss); #define macro_f_int64ss_t_destroy_simple(int64ss) f_type_int64ss_adjust(0, &int64ss); -#endif // _di_int64ss_t_ +#endif // _di_f_int64ss_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_uint64s_t, see type.h for typedefs. */ -#ifndef _di_uint64s_t_ +#ifndef _di_f_uint64s_t_ #define macro_f_uint64s_t_clear(uint64s) macro_f_memory_structures_clear(uint64s) #define macro_f_uint64s_t_resize(status, uint64s, length) status = f_type_uint64s_resize(length, &uint64s); @@ -464,12 +464,12 @@ extern "C" { #define macro_f_uint64s_t_delete_simple(uint64s) f_type_uint64s_resize(0, &uint64s); #define macro_f_uint64s_t_destroy_simple(uint64s) f_type_uint64s_adjust(0, &uint64s); -#endif // _di_uint64s_t_ +#endif // _di_f_uint64s_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_uint64ss_t, see type.h for typedefs. */ -#ifndef _di_uint64ss_t_ +#ifndef _di_f_uint64ss_t_ #define macro_f_uint64ss_t_clear(uint64ss) macro_f_memory_structures_clear(uint64ss) #define macro_f_uint64ss_t_resize(status, uint64ss, length) status = f_type_uint64ss_resize(length, &uint64ss); @@ -482,12 +482,12 @@ extern "C" { #define macro_f_uint64ss_t_delete_simple(uint64ss) f_type_uint64ss_resize(0, &uint64ss); #define macro_f_uint64ss_t_destroy_simple(uint64ss) f_type_uint64ss_adjust(0, &uint64ss); -#endif // _di_uint64ss_t_ +#endif // _di_f_uint64ss_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_int128s_t, see type.h for typedefs. */ -#ifndef _di_int128s_t_ +#ifndef _di_f_int128s_t_ #define macro_f_int128s_t_clear(int128s) macro_f_memory_structures_clear(int128s) #define macro_f_int128s_t_resize(status, int128s, length) status = f_type_int128s_resize(length, &int128s); @@ -500,12 +500,12 @@ extern "C" { #define macro_f_int128s_t_increase_by(status, int128s, amount) status = f_type_int128s_increase_by(amount, &int128s); #define macro_f_int128s_t_decrease_by(status, int128s, amount) status = f_type_int128s_decrease_by(amount, &int128s); #define macro_f_int128s_t_decimate_by(status, int128s, amount) status = f_type_int128s_decimate_by(amount, &int128s); -#endif // _di_int128s_t_ +#endif // _di_f_int128s_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_int128ss_t, see type.h for typedefs. */ -#ifndef _di_int128ss_t_ +#ifndef _di_f_int128ss_t_ #define macro_f_int128ss_t_clear(int128ss) macro_f_memory_structures_clear(int128ss) #define macro_f_int128ss_t_resize(status, int128ss, length) status = f_type_int128ss_resize(length, &int128ss); @@ -518,12 +518,12 @@ extern "C" { #define macro_f_int128ss_t_increase_by(status, int128ss, amount) status = f_type_int128ss_increase_by(amount, &int128ss); #define macro_f_int128ss_t_decrease_by(status, int128ss, amount) status = f_type_int128ss_decrease_by(amount, &int128ss); #define macro_f_int128ss_t_decimate_by(status, int128ss, amount) status = f_type_int128ss_decimate_by(amount, &int128ss); -#endif // _di_int128ss_t_ +#endif // _di_f_int128ss_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_uint128s_t, see type.h for typedefs. */ -#ifndef _di_uint128s_t_ +#ifndef _di_f_uint128s_t_ #define macro_f_uint128s_t_clear(uint128s) macro_f_memory_structures_clear(uint128s) #define macro_f_uint128s_t_resize(status, uint128s, length) status = f_type_uint128s_resize(length, &uint128s); @@ -536,12 +536,12 @@ extern "C" { #define macro_f_uint128s_t_increase_by(status, uint128s, amount) status = f_type_uint128s_increase_by(amount, &uint128s); #define macro_f_uint128s_t_decrease_by(status, uint128s, amount) status = f_type_uint128s_decrease_by(amount, &uint128s); #define macro_f_uint128s_t_decimate_by(status, uint128s, amount) status = f_type_uint128s_decimate_by(amount, &uint128s); -#endif // _di_uint128s_t_ +#endif // _di_f_uint128s_t_ /** - * Macros for f_array_lengths_t, see type.h for typedefs. + * Macros for f_uint128ss_t, see type.h for typedefs. */ -#ifndef _di_uint128ss_t_ +#ifndef _di_f_uint128ss_t_ #define macro_f_uint128ss_t_clear(uint128ss) macro_f_memory_structures_clear(uint128ss) #define macro_f_uint128ss_t_resize(status, uint128ss, length) status = f_type_uint128ss_resize(length, &uint128ss); @@ -554,7 +554,7 @@ extern "C" { #define macro_f_uint128ss_t_increase_by(status, uint128ss, amount) status = f_type_uint128ss_increase_by(amount, &uint128ss); #define macro_f_uint128ss_t_decrease_by(status, uint128ss, amount) status = f_type_uint128ss_decrease_by(amount, &uint128ss); #define macro_f_uint128ss_t_decimate_by(status, uint128ss, amount) status = f_type_uint128ss_decimate_by(amount, &uint128ss); -#endif // _di_uint128ss_t_ +#endif // _di_f_uint128ss_t_ #ifdef __cplusplus } // extern "C" diff --git a/level_1/fl_fss/c/fss_basic.c b/level_1/fl_fss/c/fss_basic.c index 7e46531..447d9bf 100644 --- a/level_1/fl_fss/c/fss_basic.c +++ b/level_1/fl_fss/c/fss_basic.c @@ -114,8 +114,8 @@ extern "C" { return status_allocation; } - destination->string[destination->used++] = quote ? quote : f_fss_delimit_quote_double_s.string[0]; - destination->string[destination->used++] = quote ? quote : f_fss_delimit_quote_double_s.string[0]; + destination->string[destination->used++] = quote ? f_fss_delimit_quote_single_s.string[0] : f_fss_delimit_quote_double_s.string[0]; + destination->string[destination->used++] = quote ? f_fss_delimit_quote_single_s.string[0] : f_fss_delimit_quote_double_s.string[0]; } if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { diff --git a/level_1/fl_fss/c/fss_basic_list.c b/level_1/fl_fss/c/fss_basic_list.c index 6272b1d..07b4980 100644 --- a/level_1/fl_fss/c/fss_basic_list.c +++ b/level_1/fl_fss/c/fss_basic_list.c @@ -803,7 +803,7 @@ extern "C" { bool is_comment = F_false; bool has_graph = F_false; - bool do_prepend = F_true; + bool do_prepend = prepend ? F_true : F_false; f_array_length_t i = 0; f_array_length_t slash_count = 0; @@ -843,6 +843,7 @@ extern "C" { if (F_status_set_fine(status) == F_interrupt) { status = F_status_set_error(F_interrupt); + break; } } @@ -956,7 +957,7 @@ extern "C" { do_prepend = F_false; } - if (content.string[range->start] == f_fss_eol_s.string[0]) { + if (content.string[range->start] == f_fss_eol_s.string[0] && prepend) { do_prepend = F_true; } diff --git a/level_1/fl_fss/c/fss_basic_list.h b/level_1/fl_fss/c/fss_basic_list.h index 56b7399..8e92ca1 100644 --- a/level_1/fl_fss/c/fss_basic_list.h +++ b/level_1/fl_fss/c/fss_basic_list.h @@ -214,7 +214,7 @@ extern "C" { * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this content, including the final newline. * @param prepend * A string of whitespace to prepend at the start of each line. - * This should only be whitespace, anything else could product invalid content. + * This should only be whitespace, anything else could produce invalid content. * Set the pointer address to 0 to disable. * @param state * A state for handling interrupts during long running operations. diff --git a/level_1/fl_fss/c/fss_embedded_list.c b/level_1/fl_fss/c/fss_embedded_list.c index 6582cb5..e67e8bc 100644 --- a/level_1/fl_fss/c/fss_embedded_list.c +++ b/level_1/fl_fss/c/fss_embedded_list.c @@ -1244,7 +1244,7 @@ extern "C" { bool is_comment = F_false; bool ends_on_eol = F_false; bool has_graph = F_false; - bool do_prepend = F_true; + bool do_prepend = prepend ? F_true : F_false; f_array_length_t i = 0; f_array_length_t slash_count = 0; @@ -1363,7 +1363,7 @@ extern "C" { if (range->start >= content.used || range->start > range->stop || content.string[range->start] == f_fss_eol_s.string[0]) { - if (content.string[range->start] == f_fss_eol_s.string[0]) { + if (content.string[range->start] == f_fss_eol_s.string[0] && prepend) { do_prepend = F_true; ends_on_eol = F_true; } @@ -1431,7 +1431,7 @@ extern "C" { do_prepend = F_false; } - if (content.string[range->start] == f_fss_eol_s.string[0]) { + if (content.string[range->start] == f_fss_eol_s.string[0] && prepend) { do_prepend = F_true; ends_on_eol = F_true; } diff --git a/level_1/fl_fss/c/fss_embedded_list.h b/level_1/fl_fss/c/fss_embedded_list.h index 0b12a13..e380109 100644 --- a/level_1/fl_fss/c/fss_embedded_list.h +++ b/level_1/fl_fss/c/fss_embedded_list.h @@ -217,7 +217,7 @@ extern "C" { * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this content, including the final newline. * @param prepend * A string of whitespace to prepend at the start of each line. - * This should only be whitespace, anything else could product invalid content. + * This should only be whitespace, anything else could produce invalid content. * Set the pointer address to 0 to disable. * @param ignore * An optional list of ranges within the string to ignore. diff --git a/level_1/fl_fss/c/fss_extended.c b/level_1/fl_fss/c/fss_extended.c index 9a446e9..29a0564 100644 --- a/level_1/fl_fss/c/fss_extended.c +++ b/level_1/fl_fss/c/fss_extended.c @@ -65,11 +65,13 @@ extern "C" { const f_array_length_t delimits_used = delimits->used; uint8_t content_found = 0; + f_fss_quote_t quoted = 0; while (range->start <= range->stop && range->start < buffer.used) { f_string_range_t content_partial = f_string_range_t_initialize; - f_fss_quote_t quoted = 0; + + quoted = 0; status = private_fl_fss_basic_read(buffer, F_false, state, range, &content_partial, "ed, delimits); @@ -93,7 +95,7 @@ extern "C" { ++found->used; if (quotes) { - quotes->array[quotes->used] = quoted; + quotes->array[quotes->used] = quoted == f_fss_quote_type_double_e ? f_string_ascii_quote_double_s.string[0] : f_string_ascii_quote_single_s.string[0]; quotes->used = found->used; } @@ -110,6 +112,7 @@ extern "C" { } content_found = 2; + break; } else if (status == F_data_not_stop) { @@ -118,12 +121,14 @@ extern "C" { } content_found = 2; + break; } else if (status == F_terminated_not_group_eos || status == F_terminated_not_group_eos) { if (content_found) { content_found = 2; } + break; } else if (F_status_is_error(status)) { @@ -146,7 +151,7 @@ extern "C" { #endif // _di_fl_fss_extended_content_read_ #ifndef _di_fl_fss_extended_object_write_ -f_status_t fl_fss_extended_object_write(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { +f_status_t fl_fss_extended_object_write(const f_string_static_t object, const f_fss_quote_t quoted, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -154,7 +159,7 @@ f_status_t fl_fss_extended_object_write(const f_string_static_t object, const f_ const f_array_length_t used_start = destination->used; - f_status_t status = private_fl_fss_basic_write(F_true, object, quote ? quote : f_fss_delimit_quote_double_s.string[0], state, range, destination); + f_status_t status = private_fl_fss_basic_write(F_true, object, quoted ? quoted : f_fss_delimit_quote_double_s.string[0], state, range, destination); if (status == F_data_not_stop || status == F_data_not_eos) { @@ -162,8 +167,8 @@ f_status_t fl_fss_extended_object_write(const f_string_static_t object, const f_ const f_status_t status_allocation = f_string_dynamic_increase_by(2, destination); if (F_status_is_error(status_allocation)) return status_allocation; - destination->string[destination->used++] = quote ? quote : f_fss_delimit_quote_double_s.string[0]; - destination->string[destination->used++] = quote ? quote : f_fss_delimit_quote_double_s.string[0]; + destination->string[destination->used++] = quoted ? f_fss_delimit_quote_single_s.string[0] : f_fss_delimit_quote_double_s.string[0]; + destination->string[destination->used++] = quoted ? f_fss_delimit_quote_single_s.string[0] : f_fss_delimit_quote_double_s.string[0]; } if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e) { @@ -171,7 +176,7 @@ f_status_t fl_fss_extended_object_write(const f_string_static_t object, const f_ f_status_t status2 = F_none; if (complete == f_fss_complete_full_trim_e) { - status2 = private_fl_fss_basic_write_object_trim(quote ? quote : f_fss_delimit_quote_double_s.string[0], used_start, state, destination); + status2 = private_fl_fss_basic_write_object_trim(quoted ? quoted : f_fss_delimit_quote_double_s.string[0], used_start, state, destination); if (F_status_is_error(status2)) return status2; } @@ -187,25 +192,25 @@ f_status_t fl_fss_extended_object_write(const f_string_static_t object, const f_ #endif // _di_fl_fss_extended_object_write_ #ifndef _di_fl_fss_extended_content_write_ - f_status_t fl_fss_extended_content_write(const f_string_static_t content, const f_fss_quote_t quote, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { + f_status_t fl_fss_extended_content_write(const f_string_static_t content, const f_fss_quote_t quoted, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ - // this operates exactly like an object, syntax-wise. - const f_status_t status = private_fl_fss_basic_write(F_false, content, quote ? quote : f_fss_delimit_quote_double_s.string[0], state, range, destination); + // This operates exactly like an object, syntax-wise. + const f_status_t status = private_fl_fss_basic_write(F_false, content, quoted ? quoted : f_fss_delimit_quote_double_s.string[0], state, range, destination); if (status == F_data_not_stop || status == F_data_not_eos) { - // content that is empty must be represented by a quoted empty string. + // Content that is empty must be represented by a quoted empty string. const f_status_t status_allocation = f_string_dynamic_increase_by(4, destination); if (F_status_is_error(status_allocation)) return status_allocation; - destination->string[destination->used++] = quote ? quote : f_fss_delimit_quote_double_s.string[0]; - destination->string[destination->used++] = quote ? quote : f_fss_delimit_quote_double_s.string[0]; + destination->string[destination->used++] = quoted ? f_fss_delimit_quote_single_s.string[0] : f_fss_delimit_quote_double_s.string[0]; + destination->string[destination->used++] = quoted ? f_fss_delimit_quote_single_s.string[0] : f_fss_delimit_quote_double_s.string[0]; - // content should be terminated, even if empty. + // Content should be terminated, even if empty. if (complete == f_fss_complete_partial_e || complete == f_fss_complete_partial_trim_e || complete == f_fss_complete_full_e || complete == f_fss_complete_full_trim_e || complete == f_fss_complete_next_e) { destination->string[destination->used++] = f_fss_extended_next_s.string[0]; } diff --git a/level_1/fl_fss/c/fss_extended.h b/level_1/fl_fss/c/fss_extended.h index 2c0e6c7..67d5670 100644 --- a/level_1/fl_fss/c/fss_extended.h +++ b/level_1/fl_fss/c/fss_extended.h @@ -149,7 +149,7 @@ extern "C" { * * @param object * The string to write as (does not stop at NULLS, they are ignored and not written). - * @param quote + * @param quoted * If 0, then double quotes are auto-inserted, when required. * Otherwise, this is the type of quote to wrap the object in when writing. * @param complete @@ -189,7 +189,7 @@ extern "C" { * Errors (with error bit) from: f_utf_buffer_increment(). */ #ifndef _di_fl_fss_extended_object_write_ - extern f_status_t fl_fss_extended_object_write(const f_string_static_t object, const f_fss_quote_t quote, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_status_t fl_fss_extended_object_write(const f_string_static_t object, const f_fss_quote_t quoted, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_extended_object_write_ /** @@ -202,7 +202,7 @@ extern "C" { * * @param content * The string to write as (does not stop at NULLS, they are ignored and not written). - * @param quote + * @param quoted * If 0, then double quotes are auto-inserted, when required. * Otherwise, this is the type of quote to wrap the object in when writing. * @param complete @@ -244,7 +244,7 @@ extern "C" { * Errors (with error bit) from: f_utf_buffer_increment(). */ #ifndef _di_fl_fss_extended_content_write_ - extern f_status_t fl_fss_extended_content_write(const f_string_static_t content, const f_fss_quote_t quote, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination); + extern f_status_t fl_fss_extended_content_write(const f_string_static_t content, const f_fss_quote_t quoted, const uint8_t complete, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination); #endif // _di_fl_fss_extended_content_write_ #ifdef __cplusplus diff --git a/level_1/fl_fss/c/fss_extended_list.c b/level_1/fl_fss/c/fss_extended_list.c index e198d96..9b4509a 100644 --- a/level_1/fl_fss/c/fss_extended_list.c +++ b/level_1/fl_fss/c/fss_extended_list.c @@ -801,7 +801,7 @@ extern "C" { bool is_comment = F_false; bool ends_on_eol = F_false; bool has_graph = F_false; - bool do_prepend = F_true; + bool do_prepend = prepend ? F_true : F_false; f_array_length_t i = 0; f_array_length_t slash_count = 0; @@ -919,7 +919,7 @@ extern "C" { if (content.string[range->start] == f_fss_eol_s.string[0] || range->start >= content.used || range->start > range->stop) { - if (content.string[range->start] == f_fss_eol_s.string[0]) { + if (content.string[range->start] == f_fss_eol_s.string[0] && prepend) { do_prepend = F_true; ends_on_eol = F_true; } @@ -989,7 +989,7 @@ extern "C" { do_prepend = F_false; } - if (content.string[range->start] == f_fss_eol_s.string[0]) { + if (content.string[range->start] == f_fss_eol_s.string[0] && prepend) { do_prepend = F_true; ends_on_eol = F_true; } diff --git a/level_1/fl_fss/c/fss_extended_list.h b/level_1/fl_fss/c/fss_extended_list.h index cb63b6b..6c7b043 100644 --- a/level_1/fl_fss/c/fss_extended_list.h +++ b/level_1/fl_fss/c/fss_extended_list.h @@ -215,7 +215,7 @@ extern "C" { * If f_fss_complete_full_e, this will write any appropriate open and close aspects of this content, including the final newline. * @param prepend * A string of whitespace to prepend at the start of each line. - * This should only be whitespace, anything else could product invalid content. + * This should only be whitespace, anything else could produce invalid content. * Set the pointer address to 0 to disable. * @param ignore * An optional list of ranges within the string to ignore. diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index 7b58818..929c9e5 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -7,13 +7,14 @@ extern "C" { #endif #if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) - f_status_t private_fl_fss_basic_write_object_trim(const f_fss_quote_t quote, const f_array_length_t used_start, f_state_t state, f_string_dynamic_t *destination) { + f_status_t private_fl_fss_basic_write_object_trim(const f_fss_quote_t quoted, const f_array_length_t used_start, f_state_t state, f_string_dynamic_t *destination) { f_status_t status = F_none; f_string_range_t destination_range = macro_f_string_range_t_initialize(destination->used); f_array_length_t i = 0; uint8_t width = 0; + const char quote_char = quoted == f_fss_quote_type_double_e ? f_string_ascii_quote_double_s.string[0] : f_string_ascii_quote_single_s.string[0]; // If there are any spaces, then this will be quoted so find the first non-placeholder character. for (; destination_range.start < destination->used; ++destination_range.start) { @@ -31,7 +32,7 @@ extern "C" { if (destination->string[destination_range.start] != f_fss_delimit_placeholder_s.string[0]) break; } // for - if (destination->string[destination_range.start] == quote) { + if (destination->string[destination_range.start] == quote_char) { const f_array_length_t front = destination_range.start; for (++destination_range.start; destination_range.start < destination->used; ++destination_range.start) { @@ -80,7 +81,7 @@ extern "C" { } } - if (destination->string[destination_range.start] == quote) { + if (destination->string[destination_range.start] == quote_char) { --destination_range.start; break; } @@ -277,7 +278,7 @@ extern "C" { #endif // !defined(_di_fl_fss_basic_list_object_write_) || !defined(_di_fl_fss_extended_list_object_write_) #if !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_) || !defined(_di_fl_fss_extended_content_read_) - f_status_t private_fl_fss_basic_read(const f_string_static_t buffer, const bool object_as, f_state_t state, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quote, f_fss_delimits_t *delimits) { + f_status_t private_fl_fss_basic_read(const f_string_static_t buffer, const bool object_as, f_state_t state, f_string_range_t *range, f_fss_object_t *found, f_fss_quote_t *quoted, f_fss_delimits_t *delimits) { f_status_t status = f_fss_skip_past_space(buffer, range); if (F_status_is_error(status)) return status; @@ -334,8 +335,8 @@ extern "C" { // Handle quoted support. char quote_found = 0; - if (quote) { - *quote = 0; + if (quoted) { + *quoted = 0; } // Identify where the object begins. @@ -560,12 +561,12 @@ extern "C" { } if (status == F_true) { - if (quote) { + if (quoted) { if (quote_found == f_fss_delimit_quote_single_s.string[0]) { - *quote = f_fss_quote_type_single_e; + *quoted = f_fss_quote_type_single_e; } else if (quote_found == f_fss_delimit_quote_double_s.string[0]) { - *quote = f_fss_quote_type_double_e; + *quoted = f_fss_quote_type_double_e; } } @@ -716,12 +717,12 @@ extern "C" { range->start = location; if (status == F_true) { - if (quote) { + if (quoted) { if (quote_found == f_fss_delimit_quote_single_s.string[0]) { - *quote = f_fss_quote_type_single_e; + *quoted = f_fss_quote_type_single_e; } else if (quote_found == f_fss_delimit_quote_double_s.string[0]) { - *quote = f_fss_quote_type_double_e; + *quoted = f_fss_quote_type_double_e; } } @@ -846,7 +847,7 @@ extern "C" { #endif // !defined(_di_fl_fss_basic_object_read_) || !defined(_di_fl_fss_extended_object_read_) #if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) || !defined(_di_fl_fss_extended_content_write_) - f_status_t private_fl_fss_basic_write(const bool object_as, const f_string_static_t object, const f_fss_quote_t quote, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { + f_status_t private_fl_fss_basic_write(const bool object_as, const f_string_static_t object, const f_fss_quote_t quoted, f_state_t state, f_string_range_t *range, f_string_dynamic_t *destination) { f_status_t status = f_fss_skip_past_space(object, range); if (F_status_is_error(status)) return status; @@ -866,20 +867,22 @@ extern "C" { const f_array_length_t input_start = range->start; const f_array_length_t used_start = destination->used; - bool quoted = F_false; + bool quoted_is = F_false; bool commented = F_false; f_array_length_t item_first = 0; f_array_length_t item_total = 0; f_array_length_t i = 0; + const char quote_char = quoted == f_fss_quote_type_double_e ? f_string_ascii_quote_double_s.string[0] : f_string_ascii_quote_single_s.string[0]; + // Use placeholders for potential quote and potential delimited quote to avoid doing things such as memmove(). destination->string[destination->used++] = f_fss_delimit_placeholder_s.string[0]; destination->string[destination->used++] = f_fss_delimit_placeholder_s.string[0]; // If there is an initial quote, then this must be quoted and the existing quote must be delimited. - if (object.string[input_start] == quote) { - quoted = F_true; + if (object.string[input_start] == quote_char) { + quoted_is = F_true; } else if (object_as && object.string[input_start] == f_fss_comment_s.string[0]) { commented = F_true; @@ -924,7 +927,7 @@ extern "C" { if (range->start > range->stop || range->start >= object.used) { // Slashes before the final quote must be escaped when quoted, add the delimit slashes. - if (quoted) { + if (quoted_is) { // If this is the first quote, then only a single delimit slash is needed. if (item_first == input_start) { @@ -958,7 +961,7 @@ extern "C" { break; } - if (object.string[range->start] == quote) { + if (object.string[range->start] == quote_char) { item_first = range->start++; status = f_fss_skip_past_delimit(object, range); @@ -973,7 +976,7 @@ extern "C" { destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; } // for - destination->string[destination->used++] = quote; + destination->string[destination->used++] = quote_char; break; } @@ -983,7 +986,7 @@ extern "C" { if (F_status_is_error(status)) break; if (status == F_true) { - quoted = F_true; + quoted_is = F_true; status = f_string_dynamic_increase_by(item_total, destination); if (F_status_is_error(status)) break; @@ -1014,7 +1017,7 @@ extern "C" { destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; } // for - destination->string[destination->used++] = quote; + destination->string[destination->used++] = quote_char; for (i = 0; i < width; ++i) { destination->string[destination->used++] = object.string[range->start + i]; @@ -1046,7 +1049,7 @@ extern "C" { if (F_status_is_error(status)) break; if (status == F_true) { - quoted = F_true; + quoted_is = F_true; } width = macro_f_utf_byte_width(object.string[range->start]); @@ -1067,7 +1070,7 @@ extern "C" { } // for } } - else if (object.string[range->start] == quote) { + else if (object.string[range->start] == quote_char) { item_first = range->start++; // The very first quote, must be escaped, when quoting is disabled. @@ -1086,15 +1089,15 @@ extern "C" { status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; - destination->string[destination->used++] = quote; + destination->string[destination->used++] = quote_char; break; } - if (object.string[range->start] == quote) { + if (object.string[range->start] == quote_char) { status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) break; - destination->string[destination->used++] = quote; + destination->string[destination->used++] = quote_char; // The next quote must also be checked, so do not increment. continue; @@ -1112,7 +1115,7 @@ extern "C" { destination->string[destination->used++] = f_fss_delimit_slash_s.string[0]; } - quoted = F_true; + quoted_is = F_true; } width = macro_f_utf_byte_width(object.string[range->start]); @@ -1120,7 +1123,7 @@ extern "C" { status = f_string_dynamic_increase_by(1 + width, destination); if (F_status_is_error(status)) break; - destination->string[destination->used++] = quote; + destination->string[destination->used++] = quote_char; for (i = 0; i < width; ++i) { destination->string[destination->used++] = object.string[range->start + i]; @@ -1131,12 +1134,12 @@ extern "C" { break; } else if (object.string[range->start] != f_fss_delimit_placeholder_s.string[0]) { - if (!quoted) { + if (!quoted_is) { status = f_fss_is_space(object, *range); if (F_status_is_error(status)) break; if (status == F_true) { - quoted = F_true; + quoted_is = F_true; } } @@ -1160,7 +1163,7 @@ extern "C" { return status; } - if (quoted) { + if (quoted_is) { status = f_string_dynamic_increase(state.step_large, destination); if (F_status_is_error(status)) { @@ -1169,11 +1172,11 @@ extern "C" { return status; } - destination->string[used_start] = quote; - destination->string[destination->used++] = quote; + destination->string[used_start] = quote_char; + destination->string[destination->used++] = quote_char; // The start quote may or may not need to be delimited in this case. - if (destination->string[input_start] == quote) { + if (destination->string[input_start] == quote_char) { for (i = input_start + 1; i <= range->stop && i < object.used; ++i) { diff --git a/level_1/fl_fss/c/private-fss.h b/level_1/fl_fss/c/private-fss.h index 476d26c..bd2045c 100644 --- a/level_1/fl_fss/c/private-fss.h +++ b/level_1/fl_fss/c/private-fss.h @@ -18,7 +18,7 @@ extern "C" { /** * Trim a given object used by the basic and extended object write functions. * - * @param quote + * @param quoted * If 0, then double quotes are auto-inserted, when required. * Otherwise, this is the type of quote to wrap the object in when writing. * @param used_start @@ -46,7 +46,7 @@ extern "C" { * @see fl_fss_extended_object_write() */ #if !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) - extern f_status_t private_fl_fss_basic_write_object_trim(const f_fss_quote_t quote, const f_array_length_t used_start, f_state_t state, f_string_dynamic_t *destination) F_attribute_visibility_internal_d; + extern f_status_t private_fl_fss_basic_write_object_trim(const f_fss_quote_t quoted, const f_array_length_t used_start, f_state_t state, f_string_dynamic_t *destination) F_attribute_visibility_internal_d; #endif // !defined(_di_fl_fss_basic_object_write_) || !defined(_di_fl_fss_extended_object_write_) /** diff --git a/level_3/fake/c/common.h b/level_3/fake/c/common.h index a9e2329..3d15dea 100644 --- a/level_3/fake/c/common.h +++ b/level_3/fake/c/common.h @@ -74,10 +74,10 @@ extern "C" { * * Set to at least 4 to provide a UTF-8 friendly allocation step. */ -#ifndef _di_fake_default_allocation_step_ +#ifndef _di_fake_default_allocation_ #define fake_default_allocation_large_d 64 #define fake_default_allocation_small_d 8 -#endif // _di_fake_default_allocation_step_ +#endif // _di_fake_default_allocation_ /** * The build operation utilizes pre-defined path structures. diff --git a/level_3/fss_basic_list_write/c/common.h b/level_3/fss_basic_list_write/c/common.h index a1a57e2..732c37d 100644 --- a/level_3/fss_basic_list_write/c/common.h +++ b/level_3/fss_basic_list_write/c/common.h @@ -65,9 +65,9 @@ extern "C" { #ifndef _di_fss_basic_list_write_defines_ #define fss_basic_list_write_signal_check_d 10000 - #define FSS_BASIC_LIST_WRITE_pipe_content_end_s '\f' - #define FSS_BASIC_LIST_WRITE_pipe_content_ignore_s '\v' - #define FSS_BASIC_LIST_WRITE_pipe_content_start_s '\b' + #define FSS_BASIC_LIST_WRITE_pipe_content_end_s "\f" + #define FSS_BASIC_LIST_WRITE_pipe_content_ignore_s "\v" + #define FSS_BASIC_LIST_WRITE_pipe_content_start_s "\b" #define FSS_BASIC_LIST_WRITE_pipe_content_end_s_length 1 #define FSS_BASIC_LIST_WRITE_pipe_content_ignore_s_length 1 diff --git a/level_3/fss_basic_list_write/c/fss_basic_list_write.c b/level_3/fss_basic_list_write/c/fss_basic_list_write.c index 692eee9..918cbd9 100644 --- a/level_3/fss_basic_list_write/c/fss_basic_list_write.c +++ b/level_3/fss_basic_list_write/c/fss_basic_list_write.c @@ -182,10 +182,10 @@ extern "C" { output.id = -1; output.stream = 0; - status = f_file_stream_open(argv[index], f_string_static_empty_s, &output); + status = f_file_stream_open(main->parameters.arguments.array[index], f_string_empty_s, &output); if (F_status_is_error(status)) { - fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, argv[index], f_file_operation_open_s, fll_error_file_type_file_e); + fll_error_file_print(main->error, F_status_set_fine(status), "f_file_stream_open", F_true, main->parameters.arguments.array[index], f_file_operation_open_s, fll_error_file_type_file_e); } } } @@ -325,12 +325,12 @@ extern "C" { else if (main->parameters.array[fss_basic_list_write_parameter_prepend_e].result == f_console_result_additional_e) { const f_array_length_t index = main->parameters.array[fss_basic_list_write_parameter_prepend_e].values.array[main->parameters.array[fss_basic_list_write_parameter_prepend_e].values.used - 1]; - if (argv[index].used) { - f_string_range_t range = macro_f_string_range_t_initialize(argv[index].used); + if (main->parameters.arguments.array[index].used) { + f_string_range_t range = macro_f_string_range_t_initialize(main->parameters.arguments.array[index].used); - for (; range.start < argv[index].used; ++range.start) { + for (; range.start < main->parameters.arguments.array[index].used; ++range.start) { - status = f_fss_is_space(argv[index], range); + status = f_fss_is_space(main->parameters.arguments.array[index], range); if (F_status_is_error(status)) break; if (status == F_false) { @@ -398,18 +398,18 @@ extern "C" { } } - f_fss_quote_t quote = F_fss_delimit_quote_double_s; + f_fss_quote_t quoted = f_fss_quote_type_double_e; if (F_status_is_error_not(status)) { if (main->parameters.array[fss_basic_list_write_parameter_double_e].result == f_console_result_found_e) { if (main->parameters.array[fss_basic_list_write_parameter_single_e].result == f_console_result_found_e) { if (main->parameters.array[fss_basic_list_write_parameter_double_e].location < main->parameters.array[fss_basic_list_write_parameter_single_e].location) { - quote = F_fss_delimit_quote_single_s; + quoted = f_fss_quote_type_single_e; } } } else if (main->parameters.array[fss_basic_list_write_parameter_single_e].result == f_console_result_found_e) { - quote = F_fss_delimit_quote_single_s; + quoted = f_fss_quote_type_single_e; } } @@ -417,7 +417,7 @@ extern "C" { if (F_status_is_error_not(status)) { if (main->process_pipe) { - status = fss_basic_list_write_process_pipe(main, output, quote, &buffer); + status = fss_basic_list_write_process_pipe(main, output, quoted, &buffer); if (F_status_is_error(status)) { if (main->error.verbosity != f_console_verbosity_quiet_e) { @@ -432,8 +432,9 @@ extern "C" { } if (F_status_is_error_not(status)) { - if (main->parameters.array[fss_basic_list_write_parameter_partial_e].result == f_console_result_found_e) { + f_array_length_t index = 0; + if (main->parameters.array[fss_basic_list_write_parameter_partial_e].result == f_console_result_found_e) { if (main->parameters.array[fss_basic_list_write_parameter_object_e].result == f_console_result_additional_e) { for (f_array_length_t i = 0; i < main->parameters.array[fss_basic_list_write_parameter_object_e].values.used; ++i) { @@ -443,7 +444,9 @@ extern "C" { break; } - status = fss_basic_list_write_process(main, output, quote, &argv[main->parameters.array[fss_basic_list_write_parameter_object_e].values.array[i]], 0, &buffer); + index = main->parameters.array[fss_basic_list_write_parameter_object_e].values.array[i]; + + status = fss_basic_list_write_process(main, output, quoted, &main->parameters.arguments.array[index], 0, &buffer); if (F_status_is_error(status)) break; } // for } @@ -456,7 +459,9 @@ extern "C" { break; } - status = fss_basic_list_write_process(main, output, quote, 0, &argv[main->parameters.array[fss_basic_list_write_parameter_content_e].values.array[i]], &buffer); + index = main->parameters.array[fss_basic_list_write_parameter_content_e].values.array[i]; + + status = fss_basic_list_write_process(main, output, quoted, 0, &main->parameters.arguments.array[index], &buffer); if (F_status_is_error(status)) break; } // for } @@ -470,7 +475,9 @@ extern "C" { break; } - status = fss_basic_list_write_process(main, output, quote, &argv[main->parameters.array[fss_basic_list_write_parameter_object_e].values.array[i]], &argv[main->parameters.array[fss_basic_list_write_parameter_content_e].values.array[i]], &buffer); + index = main->parameters.array[fss_basic_list_write_parameter_object_e].values.array[i]; + + status = fss_basic_list_write_process(main, output, quoted, &main->parameters.arguments.array[index], &main->parameters.arguments.array[main->parameters.array[fss_basic_list_write_parameter_content_e].values.array[i]], &buffer); if (F_status_is_error(status)) break; } // for } diff --git a/level_3/fss_basic_list_write/c/private-write.c b/level_3/fss_basic_list_write/c/private-write.c index a16924c..1b2aee9 100644 --- a/level_3/fss_basic_list_write/c/private-write.c +++ b/level_3/fss_basic_list_write/c/private-write.c @@ -62,7 +62,7 @@ extern "C" { #endif // _di_fss_basic_list_write_error_parameter_value_missing_print_ #ifndef _di_fss_basic_list_write_process_ - f_status_t fss_basic_list_write_process(fll_program_data_t * const main, const f_file_t output, const f_fss_quote_t quote, const f_string_static_t *object, const f_string_static_t *content, f_string_dynamic_t *buffer) { + f_status_t fss_basic_list_write_process(fll_program_data_t * const main, const f_file_t output, const f_fss_quote_t quote, const f_string_static_t *object, const f_string_static_t *content, f_string_dynamic_t * const buffer) { f_status_t status = F_none; f_state_t state = macro_f_state_t_initialize(fss_basic_list_write_common_allocation_large_d, fss_basic_list_write_common_allocation_small_d, 0, 0, 0, 0, 0); @@ -108,7 +108,15 @@ extern "C" { range.start = 0; range.stop = content->used - 1; - status = fl_fss_basic_list_content_write(*content, object ? f_fss_complete_full_e : f_fss_complete_none_e, &main->prepend, state, &range, buffer); + f_string_static_t *prepend = 0; + + if (main->parameters.array[fss_basic_list_write_parameter_prepend_e].result == f_console_result_additional_e) { + const f_array_length_t index = main->parameters.array[fss_basic_list_write_parameter_prepend_e].values.array[main->parameters.array[fss_basic_list_write_parameter_prepend_e].values.used - 1]; + + prepend = &main->parameters.arguments.array[index]; + } + + status = fl_fss_basic_list_content_write(*content, object ? f_fss_complete_full_e : f_fss_complete_none_e, prepend, state, &range, buffer); if (F_status_is_error(status)) { fll_error_print(main->error, F_status_set_fine(status), "fl_fss_basic_list_content_write", F_true); @@ -118,10 +126,10 @@ extern "C" { } if (!object || !content) { - status = f_string_append(f_string_eol_s, 1, buffer); + status = f_string_dynamic_append(f_string_eol_s, buffer); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_append", F_true); + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true); return status; } @@ -136,7 +144,7 @@ extern "C" { #endif // _di_fss_basic_list_write_process_ #ifndef _di_fss_basic_list_write_process_pipe_ - f_status_t fss_basic_list_write_process_pipe(fll_program_data_t * const main, const f_file_t output, const f_fss_quote_t quote, f_string_dynamic_t *buffer) { + f_status_t fss_basic_list_write_process_pipe(fll_program_data_t * const main, const f_file_t output, const f_fss_quote_t quote, f_string_dynamic_t * const buffer) { f_status_t status = F_none; f_status_t status_pipe = F_none; @@ -205,21 +213,21 @@ extern "C" { for (; range.start <= range.stop; ++range.start) { - if (block.string[range.start] == fss_basic_list_write_pipe_content_start_s) { + if (block.string[range.start] == fss_basic_list_write_pipe_content_start_s.string[0]) { state = 0x2; ++range.start; break; } - if (block.string[range.start] == fss_basic_list_write_pipe_content_end_s) { + if (block.string[range.start] == fss_basic_list_write_pipe_content_end_s.string[0]) { state = 0x3; ++range.start; break; } - if (block.string[range.start] == fss_basic_list_write_pipe_content_ignore_s) { + if (block.string[range.start] == fss_basic_list_write_pipe_content_ignore_s.string[0]) { // This is not used by objects. continue; @@ -255,7 +263,7 @@ extern "C" { for (; range.start <= range.stop; ++range.start) { - if (block.string[range.start] == fss_basic_list_write_pipe_content_start_s) { + if (block.string[range.start] == fss_basic_list_write_pipe_content_start_s.string[0]) { if (main->error.verbosity != f_console_verbosity_quiet_e) { fll_print_format("%r%[%sThis standard only supports one content per object.%]%r", main->error.to.stream, f_string_eol_s, main->error.context, main->error.prefix, main->error.context, f_string_eol_s); } @@ -265,14 +273,14 @@ extern "C" { break; } - if (block.string[range.start] == fss_basic_list_write_pipe_content_end_s) { + if (block.string[range.start] == fss_basic_list_write_pipe_content_end_s.string[0]) { state = 0x3; ++range.start; break; } - if (block.string[range.start] == fss_basic_list_write_pipe_content_ignore_s) { + if (block.string[range.start] == fss_basic_list_write_pipe_content_ignore_s.string[0]) { // This is not used by this program. continue; diff --git a/level_3/fss_basic_list_write/c/private-write.h b/level_3/fss_basic_list_write/c/private-write.h index 220962e..dac0b4d 100644 --- a/level_3/fss_basic_list_write/c/private-write.h +++ b/level_3/fss_basic_list_write/c/private-write.h @@ -70,7 +70,7 @@ extern "C" { * F_failure (with error bit) for any othe failure. */ #ifndef _di_fss_basic_list_write_process_ - extern f_status_t fss_basic_list_write_process(fll_program_data_t * const main, const f_file_t output, const f_fss_quote_t quote, const f_string_static_t *object, const f_string_static_t *content, f_string_dynamic_t *buffer) F_attribute_visibility_internal_d; + extern f_status_t fss_basic_list_write_process(fll_program_data_t * const main, const f_file_t output, const f_fss_quote_t quote, const f_string_static_t *object, const f_string_static_t *content, f_string_dynamic_t * const buffer) F_attribute_visibility_internal_d; #endif // _di_fss_basic_list_write_process_ /** @@ -91,7 +91,7 @@ extern "C" { * F_failure (with error bit) for any othe failure. */ #ifndef _di_fss_basic_list_write_process_pipe_ - extern f_status_t fss_basic_list_write_process_pipe(fll_program_data_t * const main, const f_file_t output, const f_fss_quote_t quote, f_string_dynamic_t *buffer) F_attribute_visibility_internal_d; + extern f_status_t fss_basic_list_write_process_pipe(fll_program_data_t * const main, const f_file_t output, const f_fss_quote_t quote, f_string_dynamic_t * const buffer) F_attribute_visibility_internal_d; #endif // _di_fss_basic_list_write_process_pipe_ #ifdef __cplusplus diff --git a/level_3/fss_basic_write/c/private-write.c b/level_3/fss_basic_write/c/private-write.c index 372c673..8b81abb 100644 --- a/level_3/fss_basic_write/c/private-write.c +++ b/level_3/fss_basic_write/c/private-write.c @@ -130,10 +130,10 @@ extern "C" { } if (!object || !content) { - status = f_string_append(f_string_eol_s, 1, buffer); + status = f_string_dynamic_append(f_string_eol_s, buffer); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_append", F_true); + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true); return status; } diff --git a/level_3/fss_embedded_list_write/c/private-write.c b/level_3/fss_embedded_list_write/c/private-write.c index 46bf8c5..8ffb042 100644 --- a/level_3/fss_embedded_list_write/c/private-write.c +++ b/level_3/fss_embedded_list_write/c/private-write.c @@ -118,10 +118,10 @@ extern "C" { } if (!object || !content) { - status = f_string_append(f_string_eol_s, 1, buffer); + status = f_string_dynamic_append(f_string_eol_s, buffer); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_append", F_true); + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true); return status; } diff --git a/level_3/fss_extended_list_write/c/private-write.c b/level_3/fss_extended_list_write/c/private-write.c index 2c3d4aa..7d82be2 100644 --- a/level_3/fss_extended_list_write/c/private-write.c +++ b/level_3/fss_extended_list_write/c/private-write.c @@ -118,10 +118,10 @@ extern "C" { } if (!object || !content) { - status = f_string_append(f_string_eol_s, 1, buffer); + status = f_string_dynamic_append(f_string_eol_s, buffer); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_append", F_true); + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true); return status; } diff --git a/level_3/fss_extended_write/c/private-write.c b/level_3/fss_extended_write/c/private-write.c index fbce8d7..ae349cc 100644 --- a/level_3/fss_extended_write/c/private-write.c +++ b/level_3/fss_extended_write/c/private-write.c @@ -134,10 +134,10 @@ extern "C" { } } else if (!object) { - status = f_string_append(f_string_eol_s, 1, buffer); + status = f_string_dynamic_append(f_string_eol_s, buffer); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_append", F_true); + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true); return status; } diff --git a/level_3/fss_payload_write/c/private-write.c b/level_3/fss_payload_write/c/private-write.c index a862b10..0217d77 100644 --- a/level_3/fss_payload_write/c/private-write.c +++ b/level_3/fss_payload_write/c/private-write.c @@ -151,10 +151,10 @@ extern "C" { } if (!object || !content) { - status = f_string_append(f_string_eol_s, 1, buffer); + status = f_string_dynamic_append(f_string_eol_s, buffer); if (F_status_is_error(status)) { - fll_error_print(main->error, F_status_set_fine(status), "f_string_append", F_true); + fll_error_print(main->error, F_status_set_fine(status), "f_string_dynamic_append", F_true); return status; } -- 1.8.3.1