From: Kevin Day Date: Fri, 25 Jun 2021 00:35:30 +0000 (-0500) Subject: Update: Implement *_except_in* print functions, remove redundant UTF types, and have... X-Git-Tag: 0.5.4~7 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=fc6bd22797cef1edc32375a81df8d90493897839;p=fll Update: Implement *_except_in* print functions, remove redundant UTF types, and have FSS read functions utilize *_except_in*. When I wrote the *print_except* and *print_trim_except* functions I was hoping to avoid having to pass both individual positions as well as ranges for the "except" list. Looking at how the FSS read functions are, I now realize that I must implement these. Implement these as seperate functions where reasonable and in other cases implement the *_except_in* with the *_except* functions. I added some of the UTF string types for consistency and completeness. After looking at this later on I now believe the cost of the extra maintenance and resources is not worth it. (It might, however, be worth implementing these as a define or a typedef of the string types.) Replace f_utf_string_range_t with f_string_range_t (and related), removing all related functions. Remove f_utf_string_quantity_t (and related), removing all related functions. With the *_except_in* functions implemented, the relevant FSS read functions can now use them and properly not print valid comments. --- diff --git a/build/level_0/settings b/build/level_0/settings index d4340ec..f374afb 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -21,10 +21,10 @@ build_language c build_libraries -lc -lcap build_libraries-level build_libraries-level_threadless -build_sources_library account.c private-account.c capability.c color.c color-common.c console.c console-common.c control_group.c control_group-common.c conversion.c directory.c private-directory.c environment.c private-environment.c file.c file-common.c private-file.c fss.c private-fss.c fss-common.c fss_named.c fss_nest.c fss_set.c iki.c iki-common.c private-iki.c limit.c memory.c memory_structure.c private-memory.c path.c path-common.c private-path.c pipe.c print.c private-print.c serialize.c serialize-common.c private-serialize.c signal.c socket.c string.c string-common.c private-string.c string_dynamic.c string_map.c string_quantity.c string_range.c string_triple.c type_array.c private-type_array.c utf.c utf-common.c private-utf.c utf_dynamic.c utf_map.c utf_quantity.c utf_range.c utf_triple.c +build_sources_library account.c private-account.c capability.c color.c color-common.c console.c console-common.c control_group.c control_group-common.c conversion.c directory.c private-directory.c environment.c private-environment.c file.c file-common.c private-file.c fss.c private-fss.c fss-common.c fss_named.c fss_nest.c fss_set.c iki.c iki-common.c private-iki.c limit.c memory.c memory_structure.c private-memory.c path.c path-common.c private-path.c pipe.c print.c private-print.c serialize.c serialize-common.c private-serialize.c signal.c socket.c string.c string-common.c private-string.c string_dynamic.c string_map.c string_quantity.c string_range.c string_triple.c type_array.c private-type_array.c utf.c utf-common.c private-utf.c utf_dynamic.c utf_map.c utf_triple.c build_sources_library-level thread.c private-thread.c build_sources_program -build_sources_headers account.h account-common.h capability.h capability-common.h color.h color-common.h console.h console-common.h control_group.h control_group-common.h conversion.h conversion-common.h directory.h directory_type.h directory-common.h environment.h environment-common.h execute.h execute-common.h file.h file-common.h fss.h private-fss.h fss-common.h fss_comment.h fss_delimit.h fss_named.h fss_nest.h fss_quote.h fss_set.h iki.h iki-common.h limit.h limit-common.h memory.h memory_structure.h memory-common.h path.h path-common.h pipe.h print.h serialize.h serialize-common.h signal.h signal-common.h socket.h socket-common.h status.h string.h string-common.h private-string.h string_dynamic.h string_map.h string_quantity.h string_range.h string_triple.h type.h type_array.h private-type_array.h type_array-common.h utf.h utf-common.h utf_dynamic.h utf_map.h utf_quantity.h utf_range.h utf_triple.h +build_sources_headers account.h account-common.h capability.h capability-common.h color.h color-common.h console.h console-common.h control_group.h control_group-common.h conversion.h conversion-common.h directory.h directory_type.h directory-common.h environment.h environment-common.h execute.h execute-common.h file.h file-common.h fss.h private-fss.h fss-common.h fss_comment.h fss_delimit.h fss_named.h fss_nest.h fss_quote.h fss_set.h iki.h iki-common.h limit.h limit-common.h memory.h memory_structure.h memory-common.h path.h path-common.h pipe.h print.h serialize.h serialize-common.h signal.h signal-common.h socket.h socket-common.h status.h string.h string-common.h private-string.h string_dynamic.h string_map.h string_quantity.h string_range.h string_triple.h type.h type_array.h private-type_array.h type_array-common.h utf.h utf-common.h utf_dynamic.h utf_map.h utf_triple.h build_sources_headers-level thread.h thread-common.h build_sources_script build_sources_setting diff --git a/build/monolithic/settings b/build/monolithic/settings index 2dc47fa..e70f75e 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -21,10 +21,10 @@ build_language c build_libraries -lc -lcap build_libraries-monolithic build_libraries-monolithic_threadless -build_sources_library level_0/account.c level_0/private-account.c level_0/capability.c level_0/color.c level_0/color-common.c level_0/console.c level_0/console-common.c level_0/control_group.c level_0/control_group-common.c level_0/conversion.c level_0/directory.c level_0/private-directory.c level_0/environment.c level_0/private-environment.c level_0/file.c level_0/file-common.c level_0/private-file.c level_0/fss.c level_0/private-fss.c level_0/fss-common.c level_0/fss_named.c level_0/fss_nest.c level_0/fss_set.c level_0/iki.c level_0/iki-common.c level_0/private-iki.c level_0/limit.c level_0/memory.c level_0/memory_structure.c level_0/private-memory.c level_0/path.c level_0/path-common.c level_0/private-path.c level_0/pipe.c level_0/print.c level_0/private-print.c level_0/serialize.c level_0/serialize-common.c level_0/private-serialize.c level_0/signal.c level_0/socket.c level_0/string.c level_0/string-common.c level_0/private-string.c level_0/string_dynamic.c level_0/string_map.c level_0/string_quantity.c level_0/string_range.c level_0/string_triple.c level_0/type_array.c level_0/private-type_array.c level_0/utf.c level_0/utf-common.c level_0/private-utf.c level_0/utf_dynamic.c level_0/utf_map.c level_0/utf_quantity.c level_0/utf_range.c level_0/utf_triple.c level_1/console.c level_1/control_group.c level_1/conversion.c level_1/directory.c level_1/private-directory.c level_1/environment.c level_1/private-fss.c level_1/fss_basic.c level_1/fss_basic_list.c level_1/fss_embedded_list.c level_1/fss_extended.c level_1/fss_extended_list.c level_1/iki.c level_1/print.c level_1/private-print.c level_1/signal.c level_1/status.c level_1/string.c level_1/private-string.c level_1/utf.c level_1/private-utf.c level_1/utf_file.c level_1/private-utf_file.c level_2/control_group.c level_2/error.c level_2/error-common.c level_2/private-error.c level_2/execute.c level_2/private-execute.c level_2/file.c level_2/private-file.c level_2/fss.c level_2/private-fss.c level_2/fss_basic.c level_2/fss_basic_list.c level_2/fss_embedded_list.c level_2/fss_extended.c level_2/fss_extended_list.c level_2/fss_status.c level_2/iki.c level_2/private-iki.c level_2/path.c level_2/program.c level_2/status.c +build_sources_library level_0/account.c level_0/private-account.c level_0/capability.c level_0/color.c level_0/color-common.c level_0/console.c level_0/console-common.c level_0/control_group.c level_0/control_group-common.c level_0/conversion.c level_0/directory.c level_0/private-directory.c level_0/environment.c level_0/private-environment.c level_0/file.c level_0/file-common.c level_0/private-file.c level_0/fss.c level_0/private-fss.c level_0/fss-common.c level_0/fss_named.c level_0/fss_nest.c level_0/fss_set.c level_0/iki.c level_0/iki-common.c level_0/private-iki.c level_0/limit.c level_0/memory.c level_0/memory_structure.c level_0/private-memory.c level_0/path.c level_0/path-common.c level_0/private-path.c level_0/pipe.c level_0/print.c level_0/private-print.c level_0/serialize.c level_0/serialize-common.c level_0/private-serialize.c level_0/signal.c level_0/socket.c level_0/string.c level_0/string-common.c level_0/private-string.c level_0/string_dynamic.c level_0/string_map.c level_0/string_quantity.c level_0/string_range.c level_0/string_triple.c level_0/type_array.c level_0/private-type_array.c level_0/utf.c level_0/utf-common.c level_0/private-utf.c level_0/utf_dynamic.c level_0/utf_map.c level_0/utf_triple.c level_1/console.c level_1/control_group.c level_1/conversion.c level_1/directory.c level_1/private-directory.c level_1/environment.c level_1/private-fss.c level_1/fss_basic.c level_1/fss_basic_list.c level_1/fss_embedded_list.c level_1/fss_extended.c level_1/fss_extended_list.c level_1/iki.c level_1/print.c level_1/private-print.c level_1/signal.c level_1/status.c level_1/string.c level_1/private-string.c level_1/utf.c level_1/private-utf.c level_1/utf_file.c level_1/private-utf_file.c level_2/control_group.c level_2/error.c level_2/error-common.c level_2/private-error.c level_2/execute.c level_2/private-execute.c level_2/file.c level_2/private-file.c level_2/fss.c level_2/private-fss.c level_2/fss_basic.c level_2/fss_basic_list.c level_2/fss_embedded_list.c level_2/fss_extended.c level_2/fss_extended_list.c level_2/fss_status.c level_2/iki.c level_2/private-iki.c level_2/path.c level_2/program.c level_2/status.c build_sources_library-monolithic level_0/thread.c level_0/private-thread.c build_sources_program -build_sources_headers level_0/account.h level_0/account-common.h level_0/capability.h level_0/capability-common.h level_0/color.h level_0/color-common.h level_0/console.h level_0/console-common.h level_0/control_group.h level_0/control_group-common.h level_0/conversion.h level_0/conversion-common.h level_0/directory.h level_0/directory_type.h level_0/directory-common.h level_0/environment.h level_0/environment-common.h level_0/execute.h level_0/execute-common.h level_0/file.h level_0/file-common.h level_0/fss.h level_0/private-fss.h level_0/fss-common.h level_0/fss_comment.h level_0/fss_delimit.h level_0/fss_named.h level_0/fss_nest.h level_0/fss_quote.h level_0/fss_set.h level_0/iki.h level_0/iki-common.h level_0/limit.h level_0/limit-common.h level_0/memory.h level_0/memory_structure.h level_0/memory-common.h level_0/path.h level_0/path-common.h level_0/pipe.h level_0/print.h level_0/serialize.h level_0/serialize-common.h level_0/signal.h level_0/signal-common.h level_0/socket.h level_0/socket-common.h level_0/status.h level_0/string.h level_0/string-common.h level_0/private-string.h level_0/string_dynamic.h level_0/string_map.h level_0/string_quantity.h level_0/string_range.h level_0/string_triple.h level_0/type.h level_0/type_array.h level_0/private-type_array.h level_0/type_array-common.h level_0/utf.h level_0/utf-common.h level_0/utf_dynamic.h level_0/utf_map.h level_0/utf_quantity.h level_0/utf_range.h level_0/utf_triple.h level_1/console.h level_1/control_group.h level_1/conversion.h level_1/directory.h level_1/environment.h level_1/execute.h level_1/execute-common.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_embedded_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_status.h level_1/iki.h level_1/print.h level_1/signal.h level_1/signal-common.h level_1/status.h level_1/string.h level_1/utf.h level_1/utf_file.h level_2/control_group.h level_2/error.h level_2/error-common.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_embedded_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/iki.h level_2/path.h level_2/program.h level_2/status.h +build_sources_headers level_0/account.h level_0/account-common.h level_0/capability.h level_0/capability-common.h level_0/color.h level_0/color-common.h level_0/console.h level_0/console-common.h level_0/control_group.h level_0/control_group-common.h level_0/conversion.h level_0/conversion-common.h level_0/directory.h level_0/directory_type.h level_0/directory-common.h level_0/environment.h level_0/environment-common.h level_0/execute.h level_0/execute-common.h level_0/file.h level_0/file-common.h level_0/fss.h level_0/private-fss.h level_0/fss-common.h level_0/fss_comment.h level_0/fss_delimit.h level_0/fss_named.h level_0/fss_nest.h level_0/fss_quote.h level_0/fss_set.h level_0/iki.h level_0/iki-common.h level_0/limit.h level_0/limit-common.h level_0/memory.h level_0/memory_structure.h level_0/memory-common.h level_0/path.h level_0/path-common.h level_0/pipe.h level_0/print.h level_0/serialize.h level_0/serialize-common.h level_0/signal.h level_0/signal-common.h level_0/socket.h level_0/socket-common.h level_0/status.h level_0/string.h level_0/string-common.h level_0/private-string.h level_0/string_dynamic.h level_0/string_map.h level_0/string_quantity.h level_0/string_range.h level_0/string_triple.h level_0/type.h level_0/type_array.h level_0/private-type_array.h level_0/type_array-common.h level_0/utf.h level_0/utf-common.h level_0/utf_dynamic.h level_0/utf_map.h level_0/utf_triple.h level_1/console.h level_1/control_group.h level_1/conversion.h level_1/directory.h level_1/environment.h level_1/execute.h level_1/execute-common.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_embedded_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_status.h level_1/iki.h level_1/print.h level_1/signal.h level_1/signal-common.h level_1/status.h level_1/string.h level_1/utf.h level_1/utf_file.h level_2/control_group.h level_2/error.h level_2/error-common.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_embedded_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/iki.h level_2/path.h level_2/program.h level_2/status.h build_sources_headers-monolithic level_0/thread.h level_0/thread-common.h build_sources_script build_sources_setting diff --git a/level_0/f_print/c/print.c b/level_0/f_print/c/print.c index 2f5e5f1..021a59c 100644 --- a/level_0/f_print/c/print.c +++ b/level_0/f_print/c/print.c @@ -79,6 +79,52 @@ extern "C" { } #endif // _di_f_print_except_dynamic_ +#ifndef _di_f_print_except_in_ + f_status_t f_print_except_in(FILE *output, const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in) { + #ifndef _di_level_0_parameter_checking_ + if (!output) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!string || length == 0) { + return F_data_not; + } + + return private_f_print_except_in(output, string, 0, length, except_at, except_in); + } +#endif // _di_f_print_except_in_ + +#ifndef _di_f_print_except_in_dynamic_ + f_status_t f_print_except_in_dynamic(FILE *output, const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in) { + #ifndef _di_level_0_parameter_checking_ + if (!output) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!buffer.used) return F_data_not; + + return private_f_print_except_in(output, buffer.string, 0, buffer.used, except_at, except_in); + } +#endif // _di_f_print_except_in_dynamic_ + +#ifndef _di_f_print_except_in_dynamic_partial_ + f_status_t f_print_except_in_dynamic_partial(FILE *output, const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in) { + #ifndef _di_level_0_parameter_checking_ + if (!output) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (!buffer.used || range.start > range.stop || range.start >= buffer.used) { + return F_data_not; + } + + f_array_length_t length = (range.stop - range.start) + 1; + + if (length + range.start > buffer.used) { + length = buffer.used - range.start; + } + + return private_f_print_except_in(output, buffer.string, range.start, range.start + length, except_at, except_in); + } +#endif // _di_f_print_except_in_dynamic_partial_ + #ifndef _di_f_print_except_dynamic_partial_ f_status_t f_print_except_dynamic_partial(FILE *output, const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except) { #ifndef _di_level_0_parameter_checking_ diff --git a/level_0/f_print/c/print.h b/level_0/f_print/c/print.h index af93515..9032a76 100644 --- a/level_0/f_print/c/print.h +++ b/level_0/f_print/c/print.h @@ -169,6 +169,109 @@ extern "C" { #endif // _di_f_print_except_dynamic_ /** + * Similar to a c-library printf, except that this will only print a specific range. + * + * Will not stop at NULL. + * Will not print NULL. + * Will not print any 1-byte character at a location specified in except_at array. + * Will not print any 1-byte character within the ranges specified in except_in array. + * Will print up to length 1-byte characters. + * + * @param output + * The file to output to, including standard streams such as stdout and stderr. + * @param string + * The string to output. + * @param length + * The total number of characters to print. + * @param except_at + * An array of locations within the given string to not print. + * The array of locations is required/assumed to be in linear order. + * @param except_in + * An array of ranges within the string to not print. + * The array of ranges is required/assumed to be in linear order. + * + * @return + * F_none on success. + * F_data_not if there is nothing to print. + * + * F_output (with error bit) on failure. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see fputc() + */ +#ifndef _di_f_print_except_in_ + extern f_status_t f_print_except_in(FILE *output, const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in); +#endif // _di_f_print_except_in_ + +/** + * Similar to a c-library printf, except that this prints a given dynamic string. + * + * Will not stop at NULL. + * Will not print NULL. + * Will not print any 1-byte character at a location specified in except_at array. + * Will not print any 1-byte character within the ranges specified in except_in array. + * Will print up to the length of the buffer. + * + * @param output + * The file to output to, including standard streams such as stdout and stderr. + * @param buffer + * The string to output. + * @param except_at + * An array of locations within the given string to not print. + * The array of locations is required/assumed to be in linear order. + * @param except_in + * An array of ranges within the string to not print. + * The array of ranges is required/assumed to be in linear order. + * + * @return + * F_none on success. + * F_data_not if there is nothing to print. + * + * F_output (with error bit) on failure. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see fputc() + */ +#ifndef _di_f_print_except_in_dynamic_ + extern f_status_t f_print_except_in_dynamic(FILE *output, const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in); +#endif // _di_f_print_except_in_dynamic_ + +/** + * Similar to a c-library printf, except that this will only print a specific range in a given dynamic string. + * + * Will not stop at NULL. + * Will not print NULL. + * Will not print any 1-byte character at a location specified in except_at array. + * Will not print any 1-byte character within the ranges specified in except_in array. + * Will print up to the specified range within the buffer. + * + * @param output + * The file to output to, including standard streams such as stdout and stderr. + * @param buffer + * The string to output. + * @param range + * The range within the provided string to print. + * @param except_at + * An array of locations within the given string to not print. + * The array of locations is required/assumed to be in linear order. + * @param except_in + * An array of ranges within the string to not print. + * The array of ranges is required/assumed to be in linear order. + * + * @return + * F_none on success. + * F_data_not if there is nothing to print. + * + * F_output (with error bit) on failure. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see fputc() + */ +#ifndef _di_f_print_dynamic_except_partial_ + extern f_status_t f_print_except_in_dynamic_partial(FILE *output, const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in); +#endif // _di_f_print_except_in_dynamic_partial_ + +/** * Similar to a c-library printf, except that this will only print a specific range in a given dynamic string. * * Will not stop at NULL. diff --git a/level_0/f_print/c/private-print.c b/level_0/f_print/c/private-print.c index 275081b..90c8a93 100644 --- a/level_0/f_print/c/private-print.c +++ b/level_0/f_print/c/private-print.c @@ -7,7 +7,8 @@ extern "C" { #if !defined(_di_f_print_) || !defined(_di_f_print_dynamic_) || !defined(_di_f_print_dynamic_partial_) f_status_t private_f_print(FILE *output, const f_string_t string, const f_array_length_t length) { - for (register f_array_length_t i = 0; i < length; ++i) { + + for (f_array_length_t i = 0; i < length; ++i) { if (string[i]) { if (!fputc(string[i], output)) { @@ -22,13 +23,14 @@ extern "C" { #if !defined(_di_f_print_except_) || !defined(_di_f_print_except_dynamic_) || !defined(_di_f_print_except_dynamic_partial_) f_status_t private_f_print_except(FILE *output, const f_string_t string, const f_array_length_t offset, const f_array_length_t stop, const f_array_lengths_t except) { + f_array_length_t j = 0; - for (register f_array_length_t i = offset; i < stop; ++i) { + for (f_array_length_t i = offset; i < stop; ++i) { - for (; j < except.used && except.array[j] < i; ++j) { - // do nothing. - } // for + while (j < except.used && except.array[j] < i) { + ++j; + } // while if (j < except.used && except.array[j] == i) continue; @@ -43,10 +45,54 @@ extern "C" { } #endif // !defined(_di_f_print_except_) || !defined(_di_f_print_except_dynamic_) || !defined(_di_f_print_except_dynamic_partial_) +#if !defined(_di_f_print_except_in_) || !defined(_di_f_print_except_in_dynamic_) || !defined(_di_f_print_except_in_dynamic_partial_) + f_status_t private_f_print_except_in(FILE *output, const f_string_t string, const f_array_length_t offset, const f_array_length_t stop, const f_array_lengths_t except_at, const f_string_ranges_t except_in) { + + f_array_length_t i = offset; + f_array_length_t at = 0; + f_array_length_t in = 0; + + while (i < stop) { + + while (at < except_at.used && except_at.array[at] < i) { + ++at; + } // while + + if (at < except_at.used && except_at.array[at] == i) { + ++i; + + continue; + } + + if (in < except_in.used) { + while (in < except_in.used && except_in.array[in].start < i && except_in.array[in].stop < i) { + ++in; + } // while + + if (in < except_in.used && except_in.array[in].start <= i && except_in.array[in].stop >= i) { + i = except_in.array[in].stop + 1; + + continue; + } + } + + if (string[i]) { + if (!fputc(string[i], output)) { + return F_status_set_error(F_output); + } + } + + ++i; + } // while + + return F_none; + } +#endif // !defined(_di_f_print_except_in_) || !defined(_di_f_print_except_in_dynamic_) || !defined(_di_f_print_except_in_dynamic_partial_) + #if !defined(_di_f_print_to_) || !defined(_di_f_print_dynamic_to_) || !defined(_di_f_print_dynamic_partial_to_) f_status_t private_f_print_to(const int id, const f_string_t string, const f_array_length_t length) { - register f_array_length_t i = 0; + f_array_length_t i = 0; f_array_length_t start = 0; f_array_length_t total = 0; @@ -96,17 +142,17 @@ extern "C" { #if !defined(_di_f_print_to_except_) || !defined(_di_f_print_to_except_dynamic_) || !defined(_di_f_print_to_except_dynamic_partial_) f_status_t private_f_print_to_except(const int id, const f_string_t string, const f_array_length_t offset, const f_array_length_t stop, const f_array_lengths_t except) { - register f_array_length_t i = offset; + f_array_length_t i = offset; f_array_length_t j = 0; f_array_length_t start = offset; f_array_length_t total = 0; for (; i < stop; ++i) { - for (; j < except.used && except.array[j] < i; ++j) { - // do nothing. - } // for + while (j < except.used && except.array[j] < i) { + ++j; + } // while if (j >= except.used || except.array[j] != i) { if (string[i]) { diff --git a/level_0/f_print/c/private-print.h b/level_0/f_print/c/private-print.h index e269804..703d34c 100644 --- a/level_0/f_print/c/private-print.h +++ b/level_0/f_print/c/private-print.h @@ -75,6 +75,41 @@ extern "C" { #endif // !defined(_di_f_print_except_) || !defined(_di_f_print_except_dynamic_) || !defined(_di_f_print_except_dynamic_partial_) /** + * Private implementation of f_print_except_in(). + * + * Intended to be shared to each of the different implementation variations. + * + * @param output + * The file to output to, including standard streams such as stdout and stderr. + * @param string + * The string to output. + * @param offset + * The inclusive start point to start printing. + * @param stop + * The exclusive stop point to stop printing. + * @param except_at + * An array of locations within the given string to not print. + * The array of locations is required/assumed to be in linear order. + * @param except_in + * An array of ranges within the string to not print. + * The array of ranges is required/assumed to be in linear order. + * + * @return + * F_none on success. + * F_data_not if length is 0. + * + * F_output (with error bit) on failure. + * F_parameter (with error bit) if a parameter is invalid. + * + * @see f_print_except_in() + * @see f_print_except_in_dynamic() + * @see f_print_except_in_dynamic_partial() + */ +#if !defined(_di_f_print_except_in_) || !defined(_di_f_print_except_dynamic_in_) || !defined(_di_f_print_except_in_dynamic_partial_) + extern f_status_t private_f_print_except_in(FILE *output, const f_string_t string, const f_array_length_t offset, const f_array_length_t stop, const f_array_lengths_t except_at, f_string_ranges_t except_in) f_attribute_visibility_internal; +#endif // !defined(_di_f_print_except_in_) || !defined(_di_f_print_except_dynamic_in_) || !defined(_di_f_print_except_in_dynamic_partial_) + +/** * Private implementation of f_print_to(). * * Intended to be shared to each of the different implementation variations. diff --git a/level_0/f_utf/c/private-utf.c b/level_0/f_utf/c/private-utf.c index 76f0a5d..c2635d3 100644 --- a/level_0/f_utf/c/private-utf.c +++ b/level_0/f_utf/c/private-utf.c @@ -2667,206 +2667,6 @@ extern "C" { } #endif // !defined(_di_f_utf_string_dynamic_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_mish_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_partial_prepend_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_assure_nulless_) || !defined(_di_f_utf_string_dynamic_prepend_nulless_) || !defined(_di_f_utf_string_mish_nulless_) || !defined(_di_f_utf_string_prepend_assure_nulless_) || !defined(_di_f_utf_string_prepend_nulless_) -#if !defined(_di_f_utf_string_quantitys_adjust_) || !defined(_di_f_utf_string_quantitys_decimate_by_) - f_status_t private_f_utf_string_quantitys_adjust(const f_array_length_t length, f_utf_string_quantitys_t *quantitys) { - - if (quantitys->used + length > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - const f_status_t status = f_memory_adjust(quantitys->size, length, sizeof(f_utf_string_quantity_t), (void **) & quantitys->array); - - if (F_status_is_error_not(status)) { - quantitys->size = length; - - if (quantitys->used > quantitys->size) { - quantitys->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_utf_string_quantitys_adjust_) || !defined(_di_f_utf_string_quantitys_decimate_by_) - -#if !defined(_di_f_utf_string_quantitys_decrease_) || !defined(_di_f_utf_string_quantitys_decrease_by_) || !defined(_di_f_utf_string_quantitys_increase_) || !defined(_di_f_utf_string_quantitys_increase_by_) || !defined(_di_f_utf_string_quantitys_terminate_) || !defined(_di_f_utf_string_quantitys_terminate_after_) - f_status_t private_f_utf_string_quantitys_resize(const f_array_length_t length, f_utf_string_quantitys_t *quantitys) { - - if (quantitys->used + length > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - const f_status_t status = f_memory_resize(quantitys->size, length, sizeof(f_utf_string_quantity_t), (void **) & quantitys->array); - - if (F_status_is_error_not(status)) { - quantitys->size = length; - - if (quantitys->used > quantitys->size) { - quantitys->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_utf_string_quantitys_decrease_) || !defined(_di_f_utf_string_quantitys_decrease_by_) || !defined(_di_f_utf_string_quantitys_increase_) || !defined(_di_f_utf_string_quantitys_increase_by_) || !defined(_di_f_utf_string_quantitys_terminate_) || !defined(_di_f_utf_string_quantitys_terminate_after_) - -#if !defined(_di_f_utf_string_quantityss_adjust_) || !defined(_di_f_utf_string_quantityss_decimate_by_) - f_status_t private_f_utf_string_quantityss_adjust(const f_array_length_t length, f_utf_string_quantityss_t *quantityss) { - - if (quantityss->used + length > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < quantityss->size; ++i) { - - status = private_f_utf_string_quantitys_adjust(0, &quantityss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(quantityss->size, length, sizeof(f_utf_string_quantitys_t), (void **) & quantityss->array); - - if (F_status_is_error_not(status)) { - quantityss->size = length; - - if (quantityss->used > quantityss->size) { - quantityss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_utf_string_quantityss_adjust_) || !defined(_di_f_utf_string_quantityss_decimate_by_) - -#if !defined(_di_f_utf_string_quantityss_decrease_) || !defined(_di_f_utf_string_quantityss_decrease_by_) || !defined(_di_f_utf_string_quantityss_increase_) || !defined(_di_f_utf_string_quantityss_increase_by_) || !defined(_di_f_utf_string_quantityss_terminate_) || !defined(_di_f_utf_string_quantityss_terminate_after_) - f_status_t private_f_utf_string_quantityss_resize(const f_array_length_t length, f_utf_string_quantityss_t *quantityss) { - - if (quantityss->used + length > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < quantityss->size; ++i) { - - status = private_f_utf_string_quantitys_resize(0, &quantityss->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(quantityss->size, length, sizeof(f_utf_string_quantitys_t), (void **) & quantityss->array); - - if (F_status_is_error_not(status)) { - quantityss->size = length; - - if (quantityss->used > quantityss->size) { - quantityss->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_utf_string_quantityss_decrease_) || !defined(_di_f_utf_string_quantityss_decrease_by_) || !defined(_di_f_utf_string_quantityss_increase_) || !defined(_di_f_utf_string_quantityss_increase_by_) || !defined(_di_f_utf_string_quantityss_terminate_) || !defined(_di_f_utf_string_quantityss_terminate_after_) - -#if !defined(_di_f_utf_string_ranges_adjust_) || !defined(_di_f_utf_string_ranges_decimate_by_) - f_status_t private_f_utf_string_ranges_adjust(const f_array_length_t length, f_utf_string_ranges_t *ranges) { - - if (ranges->used + length > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - const f_status_t status = f_memory_adjust(ranges->size, length, sizeof(f_utf_string_range_t), (void **) & ranges->array); - - if (F_status_is_error_not(status)) { - ranges->size = length; - - if (ranges->used > ranges->size) { - ranges->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_utf_string_ranges_adjust_) || !defined(_di_f_utf_string_ranges_decimate_by_) - -#if !defined(_di_f_utf_string_ranges_decrease_) || !defined(_di_f_utf_string_ranges_decrease_by_) || !defined(_di_f_utf_string_ranges_increase_) || !defined(_di_f_utf_string_ranges_increase_by_) || !defined(_di_f_utf_string_ranges_terminate_) || !defined(_di_f_utf_string_ranges_terminate_after_) - f_status_t private_f_utf_string_ranges_resize(const f_array_length_t length, f_utf_string_ranges_t *ranges) { - - if (ranges->used + length > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - const f_status_t status = f_memory_resize(ranges->size, length, sizeof(f_utf_string_range_t), (void **) & ranges->array); - - if (F_status_is_error_not(status)) { - ranges->size = length; - - if (ranges->used > ranges->size) { - ranges->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_utf_string_ranges_decrease_) || !defined(_di_f_utf_string_ranges_decrease_by_) || !defined(_di_f_utf_string_ranges_increase_) || !defined(_di_f_utf_string_ranges_increase_by_) || !defined(_di_f_utf_string_ranges_terminate_) || !defined(_di_f_utf_string_ranges_terminate_after_) - -#if !defined(_di_f_utf_string_rangess_adjust_) || !defined(_di_f_utf_string_rangess_decimate_by_) - f_status_t private_f_utf_string_rangess_adjust(const f_array_length_t length, f_utf_string_rangess_t *rangess) { - - if (rangess->used + length > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < rangess->size; ++i) { - - status = private_f_utf_string_ranges_adjust(0, &rangess->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_adjust(rangess->size, length, sizeof(f_utf_string_ranges_t), (void **) & rangess->array); - - if (F_status_is_error_not(status)) { - rangess->size = length; - - if (rangess->used > rangess->size) { - rangess->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_utf_string_rangess_adjust_) || !defined(_di_f_utf_string_rangess_decimate_by_) - -#if !defined(_di_f_utf_string_rangess_decrease_) || !defined(_di_f_utf_string_rangess_decrease_by_) || !defined(_di_f_utf_string_rangess_increase_) || !defined(_di_f_utf_string_rangess_increase_by_) || !defined(_di_f_utf_string_rangess_terminate_) || !defined(_di_f_utf_string_rangess_terminate_after_) - f_status_t private_f_utf_string_rangess_resize(const f_array_length_t length, f_utf_string_rangess_t *rangess) { - - if (rangess->used + length > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - f_status_t status = F_none; - - for (f_array_length_t i = length; i < rangess->size; ++i) { - - status = private_f_utf_string_ranges_resize(0, &rangess->array[i]); - if (F_status_is_error(status)) return status; - } // for - - status = f_memory_resize(rangess->size, length, sizeof(f_utf_string_ranges_t), (void **) & rangess->array); - - if (F_status_is_error_not(status)) { - rangess->size = length; - - if (rangess->used > rangess->size) { - rangess->used = length; - } - } - - return status; - } -#endif // !defined(_di_f_utf_string_rangess_decrease_) || !defined(_di_f_utf_string_rangess_decrease_by_) || !defined(_di_f_utf_string_rangess_increase_) || !defined(_di_f_utf_string_rangess_increase_by_) || !defined(_di_f_utf_string_rangess_terminate_) || !defined(_di_f_utf_string_rangess_terminate_after_) - #if !defined(_di_f_utf_string_triples_adjust_) || !defined(_di_f_utf_string_triples_decimate_by_) f_status_t private_f_utf_string_triples_adjust(const f_array_length_t length, f_utf_string_triples_t *triples) { diff --git a/level_0/f_utf/c/private-utf.h b/level_0/f_utf/c/private-utf.h index 1b3a1df..66a1e9b 100644 --- a/level_0/f_utf/c/private-utf.h +++ b/level_0/f_utf/c/private-utf.h @@ -1071,218 +1071,6 @@ extern "C" { * * @param length * The new size to use. - * @param quantitys - * The quantitys 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_utf_string_quantitys_adjust() - * @see f_utf_string_quantitys_decimate_by() - */ -#if !defined(_di_f_utf_string_quantitys_adjust_) || !defined(_di_f_utf_string_quantitys_decimate_by_) - extern f_status_t private_f_utf_string_quantitys_adjust(const f_array_length_t length, f_utf_string_quantitys_t *quantitys) f_attribute_visibility_internal; -#endif // !defined(_di_f_utf_string_quantitys_adjust_) || !defined(_di_f_utf_string_quantitys_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param quantitys - * The quantitys to resize. - * - * @return - * F_none on success. - * - * 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_utf_string_quantitys_decrease_by() - * @see f_utf_string_quantitys_increase() - * @see f_utf_string_quantitys_increase_by() - * @see f_utf_string_quantitys_terminate() - * @see f_utf_string_quantitys_terminate_after() - */ -#if !defined(_di_f_utf_string_quantitys_decrease_by_) || !defined(_di_f_utf_string_quantitys_increase_) || !defined(_di_f_utf_string_quantitys_increase_by_) || !defined(_di_f_utf_string_quantitys_terminate_) || !defined(_di_f_utf_string_quantitys_terminate_after_) - extern f_status_t private_f_utf_string_quantitys_resize(const f_array_length_t length, f_utf_string_quantitys_t *quantitys) f_attribute_visibility_internal; -#endif // !defined(_di_f_utf_string_quantitys_decrease_by_) || !defined(_di_f_utf_string_quantitys_increase_) || !defined(_di_f_utf_string_quantitys_increase_by_) || !defined(_di_f_utf_string_quantitys_terminate_) || !defined(_di_f_utf_string_quantitys_terminate_after_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param quantityss - * The quantityss to adjust. - * - * @return - * F_none on success. - * - * 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_utf_string_quantityss_adjust() - * @see f_utf_string_quantityss_decimate_by() - */ -#if !defined(_di_f_utf_string_quantityss_adjust_) || !defined(_di_f_utf_string_quantityss_decimate_by_) - extern f_status_t private_f_utf_string_quantityss_adjust(const f_array_length_t length, f_utf_string_quantityss_t *quantityss) f_attribute_visibility_internal; -#endif // !defined(_di_f_utf_string_quantityss_adjust_) || !defined(_di_f_utf_string_quantityss_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param quantityss - * The quantityss to resize. - * - * @return - * F_none on success. - * - * 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_utf_string_quantityss_decrease_by() - * @see f_utf_string_quantityss_increase() - * @see f_utf_string_quantityss_increase_by() - * @see f_utf_string_quantityss_terminate() - * @see f_utf_string_quantityss_terminate_after() - */ -#if !defined(_di_f_utf_string_quantityss_decrease_by_) || !defined(_di_f_utf_string_quantityss_increase_) || !defined(_di_f_utf_string_quantityss_increase_by_) || !defined(_di_f_utf_string_quantityss_terminate_) || !defined(_di_f_utf_string_quantityss_terminate_after_) - extern f_status_t private_f_utf_string_quantityss_resize(const f_array_length_t length, f_utf_string_quantityss_t *quantityss) f_attribute_visibility_internal; -#endif // !defined(_di_f_utf_string_quantityss_decrease_by_) || !defined(_di_f_utf_string_quantityss_increase_) || !defined(_di_f_utf_string_quantityss_increase_by_) || !defined(_di_f_utf_string_quantityss_terminate_) || !defined(_di_f_utf_string_quantityss_terminate_after_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param ranges - * The ranges to adjust. - * - * @return - * F_none on success. - * - * 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_utf_string_ranges_adjust() - * @see f_utf_string_ranges_decimate_by() - */ -#if !defined(_di_f_utf_string_ranges_adjust_) || !defined(_di_f_utf_string_ranges_decimate_by_) - extern f_status_t private_f_utf_string_ranges_adjust(const f_array_length_t length, f_utf_string_ranges_t *ranges) f_attribute_visibility_internal; -#endif // !defined(_di_f_utf_string_ranges_adjust_) || !defined(_di_f_utf_string_ranges_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param ranges - * The ranges to resize. - * - * @return - * F_none on success. - * - * 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_utf_string_ranges_decrease_by() - * @see f_utf_string_ranges_increase() - * @see f_utf_string_ranges_increase_by() - * @see f_utf_string_ranges_terminate() - * @see f_utf_string_ranges_terminate_after() - */ -#if !defined(_di_f_utf_string_ranges_decrease_by_) || !defined(_di_f_utf_string_ranges_increase_) || !defined(_di_f_utf_string_ranges_increase_by_) || !defined(_di_f_utf_string_ranges_terminate_) || !defined(_di_f_utf_string_ranges_terminate_after_) - extern f_status_t private_f_utf_string_ranges_resize(const f_array_length_t length, f_utf_string_ranges_t *ranges) f_attribute_visibility_internal; -#endif // !defined(_di_f_utf_string_ranges_decrease_by_) || !defined(_di_f_utf_string_ranges_increase_) || !defined(_di_f_utf_string_ranges_increase_by_) || !defined(_di_f_utf_string_ranges_terminate_) || !defined(_di_f_utf_string_ranges_terminate_after_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param rangess - * The rangess to adjust. - * - * @return - * F_none on success. - * - * 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_utf_string_rangess_adjust() - * @see f_utf_string_rangess_decimate_by() - */ -#if !defined(_di_f_utf_string_rangess_adjust_) || !defined(_di_f_utf_string_rangess_decimate_by_) - extern f_status_t private_f_utf_string_rangess_adjust(const f_array_length_t length, f_utf_string_rangess_t *rangess) f_attribute_visibility_internal; -#endif // !defined(_di_f_utf_string_rangess_adjust_) || !defined(_di_f_utf_string_rangess_decimate_by_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. - * @param rangess - * The rangess to resize. - * - * @return - * F_none on success. - * - * 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_utf_string_rangess_decrease_by() - * @see f_utf_string_rangess_increase() - * @see f_utf_string_rangess_increase_by() - * @see f_utf_string_rangess_terminate() - * @see f_utf_string_rangess_terminate_after() - */ -#if !defined(_di_f_utf_string_rangess_decrease_by_) || !defined(_di_f_utf_string_rangess_increase_) || !defined(_di_f_utf_string_rangess_increase_by_) || !defined(_di_f_utf_string_rangess_terminate_) || !defined(_di_f_utf_string_rangess_terminate_after_) - extern f_status_t private_f_utf_string_rangess_resize(const f_array_length_t length, f_utf_string_rangess_t *rangess) f_attribute_visibility_internal; -#endif // !defined(_di_f_utf_string_rangess_decrease_by_) || !defined(_di_f_utf_string_rangess_increase_) || !defined(_di_f_utf_string_rangess_increase_by_) || !defined(_di_f_utf_string_rangess_terminate_) || !defined(_di_f_utf_string_rangess_terminate_after_) - -/** - * Private implementation for resizing. - * - * Intended to be shared to each of the different implementation variations. - * - * @param length - * The new size to use. * @param triples * The triples to adjust. * diff --git a/level_0/f_utf/c/utf.c b/level_0/f_utf/c/utf.c index 893fc6f..7d55a57 100644 --- a/level_0/f_utf/c/utf.c +++ b/level_0/f_utf/c/utf.c @@ -1898,7 +1898,7 @@ extern "C" { #endif // _di_f_utf_string_prepend_nulless_ #ifndef _di_f_utf_string_seek_line_ - f_status_t f_utf_string_seek_line(const f_utf_string_t string, f_utf_string_range_t *range) { + f_status_t f_utf_string_seek_line(const f_utf_string_t string, f_string_range_t *range) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -1925,7 +1925,7 @@ extern "C" { #endif // _di_f_utf_string_seek_line_ #ifndef _di_f_utf_string_seek_line_to_ - f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, const uint8_t seek_to, f_utf_string_range_t *range) { + f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, const uint8_t seek_to, f_string_range_t *range) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -1956,7 +1956,7 @@ extern "C" { #endif // _di_f_utf_string_seek_line_to_ #ifndef _di_f_utf_string_seek_to_ - f_status_t f_utf_string_seek_to(const f_utf_string_t string, const uint8_t seek_to, f_utf_string_range_t *range) { + f_status_t f_utf_string_seek_to(const f_utf_string_t string, const uint8_t seek_to, f_string_range_t *range) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ diff --git a/level_0/f_utf/c/utf.h b/level_0/f_utf/c/utf.h index 1c4df3f..059c345 100644 --- a/level_0/f_utf/c/utf.h +++ b/level_0/f_utf/c/utf.h @@ -50,8 +50,6 @@ #include #include #include -#include -#include #include #ifdef __cplusplus @@ -1766,7 +1764,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_seek_line_ - extern f_status_t f_utf_string_seek_line(const f_utf_string_t string, f_utf_string_range_t *range); + extern f_status_t f_utf_string_seek_line(const f_utf_string_t string, f_string_range_t *range); #endif // _di_f_utf_string_seek_line_ /** @@ -1790,7 +1788,7 @@ extern "C" { * F_utf (with error bit) if character is invalid UTF-8. */ #ifndef _di_f_utf_string_seek_line_to_ - extern f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, const uint8_t seek_to, f_utf_string_range_t *range); + extern f_status_t f_utf_string_seek_line_to(const f_utf_string_t string, const uint8_t seek_to, f_string_range_t *range); #endif // _di_f_utf_string_seek_line_to_ /** @@ -1813,7 +1811,7 @@ extern "C" { * F_utf (with error bit) if character is invalid UTF-8. */ #ifndef _di_f_utf_string_seek_to_ - extern f_status_t f_utf_string_seek_to(const f_utf_string_t string, const uint8_t seek_to, f_utf_string_range_t *range); + extern f_status_t f_utf_string_seek_to(const f_utf_string_t string, const uint8_t seek_to, f_string_range_t *range); #endif // _di_f_utf_string_seek_to_ /** diff --git a/level_0/f_utf/c/utf_dynamic.c b/level_0/f_utf/c/utf_dynamic.c index dece63d..14e62bb 100644 --- a/level_0/f_utf/c/utf_dynamic.c +++ b/level_0/f_utf/c/utf_dynamic.c @@ -268,7 +268,7 @@ extern "C" { #endif // _di_f_utf_string_dynamic_mish_nulless_ #ifndef _di_f_utf_string_dynamic_partial_append_ - f_status_t f_utf_string_dynamic_partial_append(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_append(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_0_parameter_checking_ if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -287,7 +287,7 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_append_ #ifndef _di_f_utf_string_dynamic_partial_append_assure_ - f_status_t f_utf_string_dynamic_partial_append_assure(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_append_assure(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_0_parameter_checking_ if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -337,7 +337,7 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_append_assure_ #ifndef _di_f_utf_string_dynamic_partial_append_assure_nulless_ - f_status_t f_utf_string_dynamic_partial_append_assure_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_append_assure_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_0_parameter_checking_ if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -382,7 +382,7 @@ extern "C" { #endif // _di_f_utf_string_dynamic_append_assure_nulless_ #ifndef _di_f_utf_string_dynamic_partial_append_nulless_ - f_status_t f_utf_string_dynamic_partial_append_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_append_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_0_parameter_checking_ if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -401,7 +401,7 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_append_nulless_ #ifndef _di_f_utf_string_dynamic_partial_mash_ - f_status_t f_utf_string_dynamic_partial_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_0_parameter_checking_ if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -425,7 +425,7 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_mash_ #ifndef _di_f_utf_string_dynamic_partial_mash_nulless_ - f_status_t f_utf_string_dynamic_partial_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_0_parameter_checking_ if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -449,7 +449,7 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_mash_nulless_ #ifndef _di_f_utf_string_dynamic_partial_mish_ - f_status_t f_utf_string_partial_dynamic_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_partial_dynamic_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_0_parameter_checking_ if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -473,7 +473,7 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_mish_ #ifndef _di_f_utf_string_dynamic_partial_mish_nulless_ - f_status_t f_utf_string_dynamic_partial_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_0_parameter_checking_ if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -497,7 +497,7 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_mish_nulless_ #ifndef _di_f_utf_string_dynamic_partial_prepend_ - f_status_t f_utf_string_dynamic_partial_prepend(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_prepend(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_0_parameter_checking_ if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -516,7 +516,7 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_prepend_ #ifndef _di_f_utf_string_dynamic_partial_prepend_assure_ - f_status_t f_utf_string_dynamic_partial_prepend_assure(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_prepend_assure(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_0_parameter_checking_ if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -566,7 +566,7 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_prepend_assure_ #ifndef _di_f_utf_string_dynamic_partial_prepend_assure_nulless_ - f_status_t f_utf_string_dynamic_partial_prepend_assure_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_prepend_assure_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_0_parameter_checking_ if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -616,7 +616,7 @@ extern "C" { #endif // _di_f_utf_string_dynamic_partial_prepend_assure_nulless #ifndef _di_f_utf_string_dynamic_partial_prepend_nulless_ - f_status_t f_utf_string_dynamic_partial_prepend_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t f_utf_string_dynamic_partial_prepend_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_0_parameter_checking_ if (source.used <= range.stop) return F_status_set_error(F_parameter); if (!destination) return F_status_set_error(F_parameter); @@ -748,7 +748,7 @@ extern "C" { #endif // _di_f_utf_string_dynamic_resize_ #ifndef _di_f_utf_string_dynamic_seek_line_ - f_status_t f_utf_string_dynamic_seek_line(const f_utf_string_static_t buffer, f_utf_string_range_t *range) { + f_status_t f_utf_string_dynamic_seek_line(const f_utf_string_static_t buffer, f_string_range_t *range) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -773,7 +773,7 @@ extern "C" { #endif // _di_f_utf_string_dynamic_seek_line_ #ifndef _di_f_utf_string_dynamic_seek_line_to_ - f_status_t f_utf_string_dynamic_seek_line_to(const f_utf_string_static_t buffer, const char seek_to_this, f_utf_string_range_t *range) { + f_status_t f_utf_string_dynamic_seek_line_to(const f_utf_string_static_t buffer, const char seek_to_this, f_string_range_t *range) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ @@ -800,7 +800,7 @@ extern "C" { #endif // _di_f_utf_string_dynamic_seek_line_to_ #ifndef _di_f_utf_string_dynamic_seek_to_ - f_status_t f_utf_string_dynamic_seek_to(const f_utf_string_static_t buffer, const char seek_to_this, f_utf_string_range_t *range) { + f_status_t f_utf_string_dynamic_seek_to(const f_utf_string_static_t buffer, const char seek_to_this, f_string_range_t *range) { #ifndef _di_level_0_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ diff --git a/level_0/f_utf/c/utf_dynamic.h b/level_0/f_utf/c/utf_dynamic.h index 6402d44..1dd6bfd 100644 --- a/level_0/f_utf/c/utf_dynamic.h +++ b/level_0/f_utf/c/utf_dynamic.h @@ -16,9 +16,6 @@ extern "C" { #endif -// fll-0 string includes -#include - /** * A string that is analogous to f_utf_string_dynamic_t but intended for static-only uses. * @@ -464,7 +461,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_append_ - extern f_status_t f_utf_string_dynamic_partial_append(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_append(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); #endif // _di_f_utf_string_dynamic_partial_append_ /** @@ -490,7 +487,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_append_assure_ - extern f_status_t f_utf_string_dynamic_partial_append_assure(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_append_assure(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); #endif // _di_f_utf_string_dynamic_partial_append_assure_ /** @@ -518,7 +515,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_append_assure_nulless_ - extern f_status_t f_utf_string_dynamic_partial_append_assure_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_append_assure_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); #endif // _di_f_utf_string_dynamic_partial_append_assure_nulless_ /** @@ -544,7 +541,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_append_nulless_ - extern f_status_t f_utf_string_dynamic_partial_append_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_append_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); #endif // _di_f_utf_string_dynamic_partial_append_nulless_ /** @@ -574,7 +571,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_mash_ - extern f_status_t f_utf_string_dynamic_partial_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_mash(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); #endif // _di_f_utf_string_dynamic_partial_mash_ /** @@ -606,7 +603,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_mash_nulless_ - extern f_status_t f_utf_string_dynamic_partial_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_mash_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); #endif // _di_f_utf_string_dynamic_partial_mash_nulless_ /** @@ -636,7 +633,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_mish_ - extern f_status_t f_utf_string_dynamic_partial_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_mish(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); #endif // _di_f_utf_string_dynamic_partial_mish_ /** @@ -668,7 +665,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_mish_nulless_ - extern f_status_t f_utf_string_dynamic_partial_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_mish_nulless(const f_utf_string_t glue, const f_array_length_t glue_length, const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); #endif // _di_f_utf_string_dynamic_partial_mish_nulless_ /** @@ -694,7 +691,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_prepend_ - extern f_status_t f_utf_string_dynamic_partial_prepend(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_prepend(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); #endif // _di_f_utf_string_dynamic_partial_prepend_ /** @@ -722,7 +719,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_prepend_assure_ - extern f_status_t f_utf_string_dynamic_partial_prepend_assure(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_prepend_assure(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); #endif // _di_f_utf_string_dynamic_partial_prepend_assure_ /** @@ -750,7 +747,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_prepend_assure_nulless_ - extern f_status_t f_utf_string_dynamic_partial_prepend_assure_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_prepend_assure_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); #endif // _di_f_utf_string_dynamic_partial_prepend_assure_nulless_ /** @@ -776,7 +773,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_partial_prepend_nulless_ - extern f_status_t f_utf_string_dynamic_partial_prepend_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t f_utf_string_dynamic_partial_prepend_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); #endif // _di_f_utf_string_dynamic_partial_prepend_nulless_ /** @@ -920,7 +917,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_seek_line_ - extern f_status_t f_utf_string_dynamic_seek_line(const f_utf_string_static_t buffer, f_utf_string_range_t *range); + extern f_status_t f_utf_string_dynamic_seek_line(const f_utf_string_static_t buffer, f_string_range_t *range); #endif // _di_f_utf_string_dynamic_seek_line_ /** @@ -947,7 +944,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_seek_line_to_ - extern f_status_t f_utf_string_dynamic_seek_line_to(const f_utf_string_static_t buffer, const char seek_to_this, f_utf_string_range_t *range); + extern f_status_t f_utf_string_dynamic_seek_line_to(const f_utf_string_static_t buffer, const char seek_to_this, f_string_range_t *range); #endif // _di_f_utf_string_dynamic_seek_line_to_ /** @@ -974,7 +971,7 @@ extern "C" { * Errors (with error bit) from: f_memory_resize(). */ #ifndef _di_f_utf_string_dynamic_seek_to_ - extern f_status_t f_utf_string_dynamic_seek_to(const f_utf_string_static_t buffer, const char seek_to_this, f_utf_string_range_t *range); + extern f_status_t f_utf_string_dynamic_seek_to(const f_utf_string_static_t buffer, const char seek_to_this, f_string_range_t *range); #endif // _di_f_utf_string_dynamic_seek_to_ /** diff --git a/level_0/f_utf/c/utf_quantity.c b/level_0/f_utf/c/utf_quantity.c deleted file mode 100644 index 2edd524..0000000 --- a/level_0/f_utf/c/utf_quantity.c +++ /dev/null @@ -1,223 +0,0 @@ -#include "utf.h" -#include "private-utf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_f_utf_string_quantitys_adjust_ - f_status_t f_utf_string_quantitys_adjust(const f_array_length_t length, f_utf_string_quantitys_t *quantitys) { - #ifndef _di_level_0_parameter_checking_ - if (!quantitys) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_quantitys_adjust(length, quantitys); - } -#endif // _di_f_utf_string_quantitys_adjust_ - -#ifndef _di_f_utf_string_quantitys_append_ - f_status_t f_utf_string_quantitys_append(const f_utf_string_quantitys_t source, f_utf_string_quantitys_t *destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_utf_string_quantitys_adjust(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].start = source.array[i].start; - destination->array[destination->used].total = source.array[i].total; - } // for - - return F_none; - } -#endif // _di_f_utf_string_quantitys_append_ - -#ifndef _di_f_utf_string_quantitys_decimate_by_ - f_status_t f_utf_string_quantitys_decimate_by(const f_array_length_t amount, f_utf_string_quantitys_t *quantitys) { - #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!quantitys) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (quantitys->size - amount > 0) { - return private_f_utf_string_quantitys_adjust(quantitys->size - amount, quantitys); - } - - return private_f_utf_string_quantitys_adjust(0, quantitys); - } -#endif // _di_f_utf_string_quantitys_decimate_by_ - -#ifndef _di_f_utf_string_quantitys_decrease_by_ - f_status_t f_utf_string_quantitys_decrease_by(const f_array_length_t amount, f_utf_string_quantitys_t *quantitys) { - #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!quantitys) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (quantitys->size - amount > 0) { - return private_f_utf_string_quantitys_resize(quantitys->size - amount, quantitys); - } - - return private_f_utf_string_quantitys_resize(0, quantitys); - } -#endif // _di_f_utf_string_quantitys_decrease_by_ - -#ifndef _di_f_utf_string_quantitys_increase_ - f_status_t f_utf_string_quantitys_increase(const uint16_t step, f_utf_string_quantitys_t *quantitys) { - #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); - if (!quantitys) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (quantitys->used + 1 > quantitys->size) { - f_array_length_t size = quantitys->used + step; - - if (size > f_array_length_t_size) { - if (quantitys->used + 1 > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - size = f_array_length_t_size; - } - - return private_f_utf_string_quantitys_resize(size, quantitys); - } - - return F_data_not; - } -#endif // _di_f_utf_string_quantitys_increase_ - -#ifndef _di_f_utf_string_quantitys_increase_by_ - f_status_t f_utf_string_quantitys_increase_by(const f_array_length_t amount, f_utf_string_quantitys_t *quantitys) { - #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!quantitys) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (quantitys->used + amount > quantitys->size) { - if (quantitys->used + amount > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - return private_f_utf_string_quantitys_resize(quantitys->used + amount, quantitys); - } - - return F_data_not; - } -#endif // _di_f_utf_string_quantitys_increase_by_ - -#ifndef _di_f_utf_string_quantitys_resize_ - f_status_t f_utf_string_quantitys_resize(const f_array_length_t length, f_utf_string_quantitys_t *quantitys) { - #ifndef _di_level_0_parameter_checking_ - if (!quantitys) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_quantitys_resize(length, quantitys); - } -#endif // _di_f_utf_string_quantitys_resize_ - -#ifndef _di_f_utf_string_quantityss_adjust_ - f_status_t f_utf_string_quantityss_adjust(const f_array_length_t length, f_utf_string_quantityss_t *quantityss) { - #ifndef _di_level_0_parameter_checking_ - if (!quantityss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_quantityss_adjust(length, quantityss); - } -#endif // _di_f_utf_string_quantityss_adjust_ - -#ifndef _di_f_utf_string_quantityss_decimate_by_ - f_status_t f_utf_string_quantityss_decimate_by(const f_array_length_t amount, f_utf_string_quantityss_t *quantityss) { - #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!quantityss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (quantityss->size - amount > 0) { - return private_f_utf_string_quantityss_adjust(quantityss->size - amount, quantityss); - } - - return private_f_utf_string_quantityss_adjust(0, quantityss); - } -#endif // _di_f_utf_string_quantityss_decimate_by_ - -#ifndef _di_f_utf_string_quantityss_decrease_by_ - f_status_t f_utf_string_quantityss_decrease_by(const f_array_length_t amount, f_utf_string_quantityss_t *quantityss) { - #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!quantityss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (quantityss->size - amount > 0) { - return private_f_utf_string_quantityss_resize(quantityss->size - amount, quantityss); - } - - return private_f_utf_string_quantityss_resize(0, quantityss); - } -#endif // _di_f_utf_string_quantityss_decrease_by_ - -#ifndef _di_f_utf_string_quantityss_increase_ - f_status_t f_utf_string_quantityss_increase(const uint16_t step, f_utf_string_quantityss_t *quantityss) { - #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); - if (!quantityss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (quantityss->used + 1 > quantityss->size) { - f_array_length_t size = quantityss->used + step; - - if (size > f_array_length_t_size) { - if (quantityss->used + 1 > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - size = f_array_length_t_size; - } - - return private_f_utf_string_quantityss_resize(size, quantityss); - } - - return F_data_not; - } -#endif // _di_f_utf_string_quantityss_increase_ - -#ifndef _di_f_utf_string_quantityss_increase_by_ - f_status_t f_utf_string_quantityss_increase_by(const f_array_length_t amount, f_utf_string_quantityss_t *quantityss) { - #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!quantityss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (quantityss->used + amount > quantityss->size) { - if (quantityss->used + amount > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - return private_f_utf_string_quantityss_resize(quantityss->used + amount, quantityss); - } - - return F_data_not; - } -#endif // _di_f_utf_string_quantityss_increase_by_ - -#ifndef _di_f_utf_string_quantityss_resize_ - f_status_t f_utf_string_quantityss_resize(const f_array_length_t length, f_utf_string_quantityss_t *quantityss) { - #ifndef _di_level_0_parameter_checking_ - if (!quantityss) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_quantityss_resize(length, quantityss); - } -#endif // _di_f_utf_string_quantityss_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_utf/c/utf_quantity.h b/level_0/f_utf/c/utf_quantity.h deleted file mode 100644 index bc1445f..0000000 --- a/level_0/f_utf/c/utf_quantity.h +++ /dev/null @@ -1,392 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: UTF - * API Version: 0.5 - * Licenses: lgplv2.1 - * - * Defines quantity string data. - * - * This is auto-included by string.h and should not need to be explicitly included. - */ -#ifndef _F_utf_string_quantity_h -#define _F_utf_string_quantity_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Store string quantity. - * - * Similar to f_utf_string_range_t, except total is relative to start and is not an absolute stop position. - * - * Two common uses for when total is 0 is: - * 1) Exactly that, process a total of 0 strings bytes. - * 2) Process with no limit, aka infinite. - * - * start: The position where the string starts (based on some string/buffer). - * total: The total number of elements within that string/buffer the quantity represents. - */ -#ifndef _di_f_utf_string_quantity_t_ - typedef struct { - f_array_length_t start; - f_array_length_t total; - } f_utf_string_quantity_t; - - #define f_utf_string_quantity_t_initialize { 0, 0 } -#endif // _di_f_utf_string_quantity_t_ - -/** - * An array of string quantitys. - * - * array: the array of string quantitys. - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_quantitys_t_ - typedef struct { - f_utf_string_quantity_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_quantitys_t; - - #define f_utf_string_quantitys_t_initialize { 0, 0, 0 } - - #define macro_f_utf_string_quantitys_t_clear(quantitys) macro_f_memory_structure_clear(quantitys) - - #define macro_f_utf_string_quantitys_t_resize(status, quantitys, length) status = f_utf_string_quantitys_resize(length, &quantitys); - #define macro_f_utf_string_quantitys_t_adjust(status, quantitys, length) status = f_utf_string_quantitys_adjust(length, &quantitys); - - #define macro_f_utf_string_quantitys_t_delete_simple(quantitys) f_utf_string_quantitys_resize(0, &quantitys); - #define macro_f_utf_string_quantitys_t_destroy_simple(quantitys) f_utf_string_quantitys_adjust(0, &quantitys); - - #define macro_f_utf_string_quantitys_t_increase(status, quantitys) status = f_utf_string_quantitys_increase(&quantitys); - #define macro_f_utf_string_quantitys_t_increase_by(status, quantitys, amount) status = f_utf_string_quantitys_increase_by(amount, &quantitys); - #define macro_f_utf_string_quantitys_t_decrease_by(status, quantitys, amount) status = f_utf_string_quantitys_decrease_by(amount, &quantitys); - #define macro_f_utf_string_quantitys_t_decimate_by(status, quantitys, amount) status = f_utf_string_quantitys_decimate_by(amount, &quantitys); -#endif // _di_f_utf_string_quantitys_t_ - -/** - * This holds an array of f_utf_string_quantitys_t. - * - * array: The array of quantitys arrays. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_quantityss_t_ - typedef struct { - f_utf_string_quantitys_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_quantityss_t; - - #define f_utf_string_quantityss_t_initialize { 0, 0, 0 } - - #define macro_f_utf_string_quantityss_t_clear(quantityss) macro_f_memory_structures_clear(quantityss) - - #define macro_f_utf_string_quantityss_t_resize(status, quantityss, length) status = f_utf_string_quantityss_resize(length, &quantityss); - #define macro_f_utf_string_quantityss_t_adjust(status, quantityss, length) status = f_utf_string_quantityss_adjust(length, &quantityss); - - #define macro_f_utf_string_quantityss_t_delete_simple(quantityss) f_utf_string_quantityss_resize(0, &quantityss); - #define macro_f_utf_string_quantityss_t_destroy_simple(quantityss) f_utf_string_quantityss_adjust(0, &quantityss); - - #define macro_f_utf_string_quantityss_t_increase(status, quantityss) status = f_utf_string_quantityss_increase(&quantityss); - #define macro_f_utf_string_quantityss_t_increase_by(status, quantityss, amount) status = f_utf_string_quantityss_increase_by(amount, &quantityss); - #define macro_f_utf_string_quantityss_t_decrease_by(status, quantityss, amount) status = f_utf_string_quantityss_decrease_by(amount, &quantityss); - #define macro_f_utf_string_quantityss_t_decimate_by(status, quantityss, amount) status = f_utf_string_quantityss_decimate_by(amount, &quantityss); -#endif // _di_f_utf_string_quantityss_t_ - -/** - * Resize the string quantitys array. - * - * @param length - * The new size to use. - * @param quantitys - * The string quantitys array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_quantitys_adjust_ - extern f_status_t f_utf_string_quantitys_adjust(const f_array_length_t length, f_utf_string_quantitys_t *quantitys); -#endif // _di_f_utf_string_quantitys_adjust_ - -/** - * Append the source quantitys onto the destination. - * - * @param source - * The source quantitys to append. - * @param destination - * The destination quantitys the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_quantitys_append_ - extern f_status_t f_utf_string_quantitys_append(const f_utf_string_quantitys_t source, f_utf_string_quantitys_t *destination); -#endif // _di_f_utf_string_quantitys_append_ - -/** - * Resize the string quantitys array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param quantitys - * The string quantitys array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_quantitys_decimate_by_ - extern f_status_t f_utf_string_quantitys_decimate_by(const f_array_length_t amount, f_utf_string_quantitys_t *quantitys); -#endif // _di_f_utf_string_quantitys_decimate_by_ - -/** - * Resize the string quantitys array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param quantitys - * The string quantitys array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_quantitys_decrease_by_ - extern f_status_t f_utf_string_quantitys_decrease_by(const f_array_length_t amount, f_utf_string_quantitys_t *quantitys); -#endif // _di_f_utf_string_quantitys_decrease_by_ - -/** - * Increase the size of the string quantitys array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param quantitys - * The string quantitys array to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_quantitys_increase_ - extern f_status_t f_utf_string_quantitys_increase(const uint16_t step, f_utf_string_quantitys_t *quantitys); -#endif // _di_f_utf_string_quantitys_increase_ - -/** - * Resize the string quantitys array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param quantitys - * The string quantitys array to resize. - * - * @return - * F_none on success. - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_quantitys_increase_by_ - extern f_status_t f_utf_string_quantitys_increase_by(const f_array_length_t amount, f_utf_string_quantitys_t *quantitys); -#endif // _di_f_utf_string_quantitys_increase_by_ - -/** - * Resize the string quantitys array. - * - * @param length - * The new size to use. - * @param quantitys - * The string quantitys array to adjust. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_quantitys_resize_ - extern f_status_t f_utf_string_quantitys_resize(const f_array_length_t length, f_utf_string_quantitys_t *quantitys); -#endif // _di_f_utf_string_quantitys_resize_ - -/** - * Resize the string quantityss array. - * - * @param length - * The new size to use. - * @param quantityss - * The string quantityss array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_quantityss_adjust_ - extern f_status_t f_utf_string_quantityss_adjust(const f_array_length_t length, f_utf_string_quantityss_t *quantityss); -#endif // _di_f_utf_string_quantityss_adjust_ - -/** - * Resize the string quantityss array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param quantityss - * The string quantityss array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_quantityss_decimate_by_ - extern f_status_t f_utf_string_quantityss_decimate_by(const f_array_length_t amount, f_utf_string_quantityss_t *quantityss); -#endif // _di_f_utf_string_quantityss_decimate_by_ - -/** - * Resize the string quantityss array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param quantityss - * The string quantityss array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_quantityss_decrease_by_ - extern f_status_t f_utf_string_quantityss_decrease_by(const f_array_length_t amount, f_utf_string_quantityss_t *quantityss); -#endif // _di_f_utf_string_quantityss_decrease_by_ - -/** - * Increase the size of the string quantityss array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param step - * The allocation step to use. - * Must be greater than 0. - * @param quantityss - * The string quantityss array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_quantityss_increase_ - extern f_status_t f_utf_string_quantityss_increase(const uint16_t step, f_utf_string_quantityss_t *quantityss); -#endif // _di_f_utf_string_quantityss_increase_ - -/** - * Resize the string quantityss array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param quantityss - * The string quantityss array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_quantityss_increase_by_ - extern f_status_t f_utf_string_quantityss_increase_by(const f_array_length_t amount, f_utf_string_quantityss_t *quantityss); -#endif // _di_f_utf_string_quantityss_increase_by_ - -/** - * Resize the string quantityss array. - * - * @param length - * The new size to use. - * @param quantityss - * The string quantityss array to adjust. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_quantityss_resize_ - extern f_status_t f_utf_string_quantityss_resize(const f_array_length_t length, f_utf_string_quantityss_t *quantityss); -#endif // _di_f_utf_string_quantityss_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _F_utf_string_quantity_h diff --git a/level_0/f_utf/c/utf_range.c b/level_0/f_utf/c/utf_range.c deleted file mode 100644 index ee43d86..0000000 --- a/level_0/f_utf/c/utf_range.c +++ /dev/null @@ -1,223 +0,0 @@ -#include "utf.h" -#include "private-utf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _di_f_utf_string_ranges_adjust_ - f_status_t f_utf_string_ranges_adjust(const f_array_length_t length, f_utf_string_ranges_t *ranges) { - #ifndef _di_level_0_parameter_checking_ - if (!ranges) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_ranges_adjust(length, ranges); - } -#endif // _di_f_utf_string_ranges_adjust_ - -#ifndef _di_f_utf_string_ranges_append_ - f_status_t f_utf_string_ranges_append(const f_utf_string_ranges_t source, f_utf_string_ranges_t *destination) { - #ifndef _di_level_0_parameter_checking_ - if (!destination) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (!source.used) return F_data_not; - - f_status_t status = F_none; - - if (destination->used + source.used > destination->size) { - status = private_f_utf_string_ranges_adjust(destination->used + source.used, destination); - if (F_status_is_error(status)) return status; - } - - for (f_array_length_t i = 0; i < source.used; ++i, ++destination->used) { - - destination->array[destination->used].start = source.array[i].start; - destination->array[destination->used].stop = source.array[i].stop; - } // for - - return F_none; - } -#endif // _di_f_utf_string_ranges_append_ - -#ifndef _di_f_utf_string_ranges_decimate_by_ - f_status_t f_utf_string_ranges_decimate_by(const f_array_length_t amount, f_utf_string_ranges_t *ranges) { - #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!ranges) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (ranges->size - amount > 0) { - return private_f_utf_string_ranges_adjust(ranges->size - amount, ranges); - } - - return private_f_utf_string_ranges_adjust(0, ranges); - } -#endif // _di_f_utf_string_ranges_decimate_by_ - -#ifndef _di_f_utf_string_ranges_decrease_by_ - f_status_t f_utf_string_ranges_decrease_by(const f_array_length_t amount, f_utf_string_ranges_t *ranges) { - #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!ranges) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (ranges->size - amount > 0) { - return private_f_utf_string_ranges_resize(ranges->size - amount, ranges); - } - - return private_f_utf_string_ranges_resize(0, ranges); - } -#endif // _di_f_utf_string_ranges_decrease_by_ - -#ifndef _di_f_utf_string_ranges_increase_ - f_status_t f_utf_string_ranges_increase(const uint16_t step, f_utf_string_ranges_t *ranges) { - #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); - if (!ranges) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (ranges->used + 1 > ranges->size) { - f_array_length_t size = ranges->used + step; - - if (size > f_array_length_t_size) { - if (ranges->used + 1 > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - size = f_array_length_t_size; - } - - return private_f_utf_string_ranges_resize(size, ranges); - } - - return F_data_not; - } -#endif // _di_f_utf_string_ranges_increase_ - -#ifndef _di_f_utf_string_ranges_increase_by_ - f_status_t f_utf_string_ranges_increase_by(const f_array_length_t amount, f_utf_string_ranges_t *ranges) { - #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!ranges) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (ranges->used + amount > ranges->size) { - if (ranges->used + amount > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - return private_f_utf_string_ranges_resize(ranges->used + amount, ranges); - } - - return F_data_not; - } -#endif // _di_f_utf_string_ranges_increase_by_ - -#ifndef _di_f_utf_string_ranges_resize_ - f_status_t f_utf_string_ranges_resize(const f_array_length_t length, f_utf_string_ranges_t *ranges) { - #ifndef _di_level_0_parameter_checking_ - if (!ranges) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_ranges_resize(length, ranges); - } -#endif // _di_f_utf_string_ranges_resize_ - -#ifndef _di_f_utf_string_rangess_adjust_ - f_status_t f_utf_string_rangess_adjust(const f_array_length_t length, f_utf_string_rangess_t *rangess) { - #ifndef _di_level_0_parameter_checking_ - if (!rangess) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_rangess_adjust(length, rangess); - } -#endif // _di_f_utf_string_rangess_adjust_ - -#ifndef _di_f_utf_string_rangess_decimate_by_ - f_status_t f_utf_string_rangess_decimate_by(const f_array_length_t amount, f_utf_string_rangess_t *rangess) { - #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!rangess) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (rangess->size - amount > 0) { - return private_f_utf_string_rangess_adjust(rangess->size - amount, rangess); - } - - return private_f_utf_string_rangess_adjust(0, rangess); - } -#endif // _di_f_utf_string_rangess_decimate_by_ - -#ifndef _di_f_utf_string_rangess_decrease_by_ - f_status_t f_utf_string_rangess_decrease_by(const f_array_length_t amount, f_utf_string_rangess_t *rangess) { - #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!rangess) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (rangess->size - amount > 0) { - return private_f_utf_string_rangess_resize(rangess->size - amount, rangess); - } - - return private_f_utf_string_rangess_resize(0, rangess); - } -#endif // _di_f_utf_string_rangess_decrease_by_ - -#ifndef _di_f_utf_string_rangess_increase_ - f_status_t f_utf_string_rangess_increase(const uint16_t step, f_utf_string_rangess_t *rangess) { - #ifndef _di_level_0_parameter_checking_ - if (!step) return F_status_set_error(F_parameter); - if (!rangess) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (rangess->used + 1 > rangess->size) { - f_array_length_t size = rangess->used + step; - - if (size > f_array_length_t_size) { - if (rangess->used + 1 > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - size = f_array_length_t_size; - } - - return private_f_utf_string_rangess_resize(size, rangess); - } - - return F_data_not; - } -#endif // _di_f_utf_string_rangess_increase_ - -#ifndef _di_f_utf_string_rangess_increase_by_ - f_status_t f_utf_string_rangess_increase_by(const f_array_length_t amount, f_utf_string_rangess_t *rangess) { - #ifndef _di_level_0_parameter_checking_ - if (!amount) return F_status_set_error(F_parameter); - if (!rangess) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - if (rangess->used + amount > rangess->size) { - if (rangess->used + amount > f_array_length_t_size) { - return F_status_set_error(F_array_too_large); - } - - return private_f_utf_string_rangess_resize(rangess->used + amount, rangess); - } - - return F_data_not; - } -#endif // _di_f_utf_string_rangess_increase_by_ - -#ifndef _di_f_utf_string_rangess_resize_ - f_status_t f_utf_string_rangess_resize(const f_array_length_t length, f_utf_string_rangess_t *rangess) { - #ifndef _di_level_0_parameter_checking_ - if (!rangess) return F_status_set_error(F_parameter); - #endif // _di_level_0_parameter_checking_ - - return private_f_utf_string_rangess_resize(length, rangess); - } -#endif // _di_f_utf_string_rangess_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/level_0/f_utf/c/utf_range.h b/level_0/f_utf/c/utf_range.h deleted file mode 100644 index 2281b62..0000000 --- a/level_0/f_utf/c/utf_range.h +++ /dev/null @@ -1,393 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: UTF - * API Version: 0.5 - * Licenses: lgplv2.1 - * - * Defines range string data. - * - * This is auto-included by string.h and should not need to be explicitly included. - */ -#ifndef _F_utf_string_range_h -#define _F_utf_string_range_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * A structure designating a start and stop range for some string. - * - * In general, this project uses the start and stop position inclusively, meaning that a range of 0 to 1 would include positions 0 and position 1. - * Therefore, a range from 0 to 0 would be include position 0. - * Set start to some value larger than stop to designate that there is no range (such as start = 1, stop = 0). - * - * A special macro_f_utf_string_range_t_initialize() is provided for the special purpose of easily initialize a static string range. - * - * start: the start position. - * stop: the stop position. - */ -#ifndef _di_f_utf_string_range_t_ - typedef struct { - f_array_length_t start; - f_array_length_t stop; - } f_utf_string_range_t; - - #define f_utf_string_range_t_initialize { 1, 0 } - - #define macro_f_utf_string_range_t_initialize(length) { length ? 0 : 1, length ? length - 1 : 0 } - - #define macro_f_utf_string_range_t_clear(range) \ - range.start = 1; \ - range.stop = 0; -#endif // _di_f_utf_string_range_t_ - -/** - * An array of string ranges. - * - * array: the array of string ranges. - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_ranges_t_ - typedef struct { - f_utf_string_range_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_ranges_t; - - #define f_utf_string_ranges_t_initialize { 0, 0, 0 } - - #define macro_f_utf_string_ranges_t_clear(ranges) macro_f_memory_structure_clear(ranges) - - #define macro_f_utf_string_ranges_t_resize(status, ranges, length) status = f_utf_string_ranges_resize(length, &ranges); - #define macro_f_utf_string_ranges_t_adjust(status, ranges, length) status = f_utf_string_ranges_adjust(length, &ranges); - - #define macro_f_utf_string_ranges_t_delete_simple(ranges) f_utf_string_ranges_resize(0, &ranges); - #define macro_f_utf_string_ranges_t_destroy_simple(ranges) f_utf_string_ranges_adjust(0, &ranges); - - #define macro_f_utf_string_ranges_t_increase(status, ranges) status = f_utf_string_ranges_increase(&ranges); - #define macro_f_utf_string_ranges_t_increase_by(status, ranges, amount) status = f_utf_string_ranges_increase_by(amount, &ranges); - #define macro_f_utf_string_ranges_t_decrease_by(status, ranges, amount) status = f_utf_string_ranges_decrease_by(amount, &ranges); - #define macro_f_utf_string_ranges_t_decimate_by(status, ranges, amount) status = f_utf_string_ranges_decimate_by(amount, &ranges); -#endif // _di_f_utf_string_ranges_t_ - -/** - * This holds an array of f_utf_string_ranges_t. - * - * array: The array of ranges arrays. - * size: Total amount of allocated space. - * used: Total number of allocated spaces used. - */ -#ifndef _di_f_utf_string_rangess_t_ - typedef struct { - f_utf_string_ranges_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_utf_string_rangess_t; - - #define f_utf_string_rangess_t_initialize { 0, 0, 0 } - - #define macro_f_utf_string_rangess_t_clear(rangess) macro_f_memory_structures_clear(rangess) - - #define macro_f_utf_string_rangess_t_resize(status, rangess, length) status = f_utf_string_rangess_resize(length, &rangess); - #define macro_f_utf_string_rangess_t_adjust(status, rangess, length) status = f_utf_string_rangess_adjust(length, &rangess); - - #define macro_f_utf_string_rangess_t_delete_simple(rangess) f_utf_string_rangess_resize(0, &rangess); - #define macro_f_utf_string_rangess_t_destroy_simple(rangess) f_utf_string_rangess_adjust(0, &rangess); - - #define macro_f_utf_string_rangess_t_increase(status, rangess) status = f_utf_string_rangess_increase(&rangess); - #define macro_f_utf_string_rangess_t_increase_by(status, rangess, amount) status = f_utf_string_rangess_increase_by(amount, &rangess); - #define macro_f_utf_string_rangess_t_decrease_by(status, rangess, amount) status = f_utf_string_rangess_decrease_by(amount, &rangess); - #define macro_f_utf_string_rangess_t_decimate_by(status, rangess, amount) status = f_utf_string_rangess_decimate_by(amount, &rangess); -#endif // _di_f_utf_string_rangess_t_ - -/** - * Resize the string ranges array. - * - * @param length - * The new size to use. - * @param ranges - * The string ranges array to resize. - * - * @return - * F_none on success. - * - * F_memory_not (with error bit) on out of memory. - * F_parameter (with error bit) if a parameter is invalid. - */ -#ifndef _di_f_utf_string_ranges_adjust_ - extern f_status_t f_utf_string_ranges_adjust(const f_array_length_t length, f_utf_string_ranges_t *ranges); -#endif // _di_f_utf_string_ranges_adjust_ - -/** - * Append the source ranges onto the destination. - * - * @param source - * The source ranges to append. - * @param destination - * The destination ranges the source is appended onto. - * - * @return - * F_none on success. - * F_data_not on success, but there is nothing to append (size == 0). - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_ranges_append_ - extern f_status_t f_utf_string_ranges_append(const f_utf_string_ranges_t source, f_utf_string_ranges_t *destination); -#endif // _di_f_utf_string_ranges_append_ - -/** - * Resize the string ranges array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param ranges - * The string ranges array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_ranges_decimate_by_ - extern f_status_t f_utf_string_ranges_decimate_by(const f_array_length_t amount, f_utf_string_ranges_t *ranges); -#endif // _di_f_utf_string_ranges_decimate_by_ - -/** - * Resize the string ranges array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param ranges - * The string ranges array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_ranges_decrease_by_ - extern f_status_t f_utf_string_ranges_decrease_by(const f_array_length_t amount, f_utf_string_ranges_t *ranges); -#endif // _di_f_utf_string_ranges_decrease_by_ - -/** - * Increase the size of the string ranges array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param ranges - * The string ranges array to resize. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * @return - * F_none on success. - * F_array_too_large (with error bit) if the new array length is too large. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_ranges_increase_ - extern f_status_t f_utf_string_ranges_increase(const uint16_t step, f_utf_string_ranges_t *ranges); -#endif // _di_f_utf_string_ranges_increase_ - -/** - * Resize the string ranges array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param ranges - * The string ranges array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_ranges_increase_by_ - extern f_status_t f_utf_string_ranges_increase_by(const f_array_length_t amount, f_utf_string_ranges_t *ranges); -#endif // _di_f_utf_string_ranges_increase_by_ - -/** - * Resize the string ranges array. - * - * @param length - * The new size to use. - * @param ranges - * The string ranges array to adjust. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_ranges_resize_ - extern f_status_t f_utf_string_ranges_resize(const f_array_length_t length, f_utf_string_ranges_t *ranges); -#endif // _di_f_utf_string_ranges_resize_ - -/** - * Resize the string rangess array. - * - * @param length - * The new size to use. - * @param rangess - * The string rangess array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_rangess_adjust_ - extern f_status_t f_utf_string_rangess_adjust(const f_array_length_t length, f_utf_string_rangess_t *rangess); -#endif // _di_f_utf_string_rangess_adjust_ - -/** - * Resize the string rangess array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decimate the size by. - * @param rangess - * The string rangess array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_rangess_decimate_by_ - extern f_status_t f_utf_string_rangess_decimate_by(const f_array_length_t amount, f_utf_string_rangess_t *rangess); -#endif // _di_f_utf_string_rangess_decimate_by_ - -/** - * Resize the string rangess array to a smaller size. - * - * This will resize making the array smaller based on (size - given length). - * If the given length is too small, then the resize will fail. - * This will not shrink the size to less than 0. - * - * @param amount - * A positive number representing how much to decrease the size by. - * @param rangess - * The string rangess array to resize. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_rangess_decrease_by_ - extern f_status_t f_utf_string_rangess_decrease_by(const f_array_length_t amount, f_utf_string_rangess_t *rangess); -#endif // _di_f_utf_string_rangess_decrease_by_ - -/** - * Increase the size of the string rangess array, but only if necessary. - * - * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param rangess - * The string rangess array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + 1 <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_rangess_increase_ - extern f_status_t f_utf_string_rangess_increase(const uint16_t step, f_utf_string_rangess_t *rangess); -#endif // _di_f_utf_string_rangess_increase_ - -/** - * Resize the string rangess array to a larger size. - * - * This will resize making the string larger based on the given length. - * If the given length is too large for the buffer, then attempt to set max buffer size (f_array_length_t_size). - * If already set to the maximum buffer size, then the resize will fail. - * - * @param amount - * A positive number representing how much to increase the size by. - * @param rangess - * The string rangess array to resize. - * - * @return - * F_none on success. - * F_data_not on success, but there is no reason to increase size (used + amount <= size). - * - * F_array_too_large (with error bit) if the new array length is too large. - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_rangess_increase_by_ - extern f_status_t f_utf_string_rangess_increase_by(const f_array_length_t amount, f_utf_string_rangess_t *rangess); -#endif // _di_f_utf_string_rangess_increase_by_ - -/** - * Resize the string rangess array. - * - * @param length - * The new size to use. - * @param rangess - * The string rangess array to adjust. - * - * @return - * F_none on success. - * - * F_parameter (with error bit) if a parameter is invalid. - * - * Errors (with error bit) from: f_memory_resize(). - */ -#ifndef _di_f_utf_string_rangess_resize_ - extern f_status_t f_utf_string_rangess_resize(const f_array_length_t length, f_utf_string_rangess_t *rangess); -#endif // _di_f_utf_string_rangess_resize_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _F_utf_string_range_h diff --git a/level_0/f_utf/data/build/settings b/level_0/f_utf/data/build/settings index 6b1d86c..ccc8bd3 100644 --- a/level_0/f_utf/data/build/settings +++ b/level_0/f_utf/data/build/settings @@ -20,9 +20,9 @@ build_indexer ar build_language c build_libraries -lc build_libraries-individual -lf_memory -lf_string -build_sources_library utf.c utf-common.c private-utf.c utf_dynamic.c utf_map.c utf_quantity.c utf_range.c utf_triple.c +build_sources_library utf.c utf-common.c private-utf.c utf_dynamic.c utf_map.c utf_triple.c build_sources_program -build_sources_headers utf.h utf-common.h utf_dynamic.h utf_map.h utf_quantity.h utf_range.h utf_triple.h +build_sources_headers utf.h utf-common.h utf_dynamic.h utf_map.h utf_triple.h build_sources_script build_sources_setting build_script yes diff --git a/level_1/fl_print/c/print.c b/level_1/fl_print/c/print.c index 32f6b33..ca0e12e 100644 --- a/level_1/fl_print/c/print.c +++ b/level_1/fl_print/c/print.c @@ -15,7 +15,9 @@ extern "C" { return F_data_not; } - return private_fl_print_trim_except(output, string, 0, length, except); + const f_string_ranges_t except_in = f_string_ranges_t_initialize; + + return private_fl_print_trim_except_in(output, string, 0, length, except, except_in); } #endif // _di_fl_print_trim_except_ @@ -29,10 +31,60 @@ extern "C" { return F_data_not; } - return private_fl_print_trim_except(output, buffer.string, 0, buffer.used, except); + const f_string_ranges_t except_in = f_string_ranges_t_initialize; + + return private_fl_print_trim_except_in(output, buffer.string, 0, buffer.used, except, except_in); } #endif // _di_fl_print_trim_except_dynamic_ +#ifndef _di_fl_print_trim_except_in_ + f_status_t fl_print_trim_except_in(FILE *output, const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in) { + #ifndef _di_level_1_parameter_checking_ + if (!output) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + if (!string || !length) { + return F_data_not; + } + + return private_fl_print_trim_except_in(output, string, 0, length, except_at, except_in); + } +#endif // _di_fl_print_trim_except_in_ + +#ifndef _di_fl_print_trim_except_in_dynamic_ + f_status_t fl_print_trim_except_in_dynamic(FILE *output, const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in) { + #ifndef _di_level_1_parameter_checking_ + if (!output) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + if (!buffer.used) { + return F_data_not; + } + + return private_fl_print_trim_except_in(output, buffer.string, 0, buffer.used, except_at, except_in); + } +#endif // _di_fl_print_trim_except_in_dynamic_ + +#ifndef _di_fl_print_trim_except_in_dynamic_partial_ + f_status_t fl_print_trim_except_in_dynamic_partial(FILE *output, const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in) { + #ifndef _di_level_1_parameter_checking_ + if (!output) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + if (!buffer.used || range.start > range.stop || range.start >= buffer.used) { + return F_data_not; + } + + f_array_length_t length = (range.stop - range.start) + 1; + + if (length + range.start > buffer.used) { + length = buffer.used - range.start; + } + + return private_fl_print_trim_except_in(output, buffer.string, range.start, range.start + length, except_at, except_in); + } +#endif // _di_fl_print_trim_except_in_dynamic_partial_ + #ifndef _di_fl_print_trim_except_dynamic_partial_ f_status_t fl_print_trim_except_dynamic_partial(FILE *output, const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except) { #ifndef _di_level_1_parameter_checking_ @@ -49,7 +101,9 @@ extern "C" { length = buffer.used - range.start; } - return private_fl_print_trim_except(output, buffer.string, range.start, range.start + length, except); + const f_string_ranges_t except_in = f_string_ranges_t_initialize; + + return private_fl_print_trim_except_in(output, buffer.string, range.start, range.start + length, except, except_in); } #endif // _di_fl_print_trim_except_dynamic_partial_ @@ -63,7 +117,9 @@ extern "C" { return F_data_not; } - return private_fl_print_trim_except_utf(output, string, 0, length, except); + const f_string_ranges_t except_in = f_string_ranges_t_initialize; + + return private_fl_print_trim_except_in_utf(output, string, 0, length, except, except_in); } #endif // _di_fl_print_trim_except_utf_ @@ -77,12 +133,62 @@ extern "C" { return F_data_not; } - return private_fl_print_trim_except_utf(output, buffer.string, 0, buffer.used, except); + const f_string_ranges_t except_in = f_string_ranges_t_initialize; + + return private_fl_print_trim_except_in_utf(output, buffer.string, 0, buffer.used, except, except_in); } #endif // _di_fl_print_trim_except_utf_dynamic_ +#ifndef _di_fl_print_trim_except_in_utf_ + f_status_t fl_print_trim_except_in_utf(FILE *output, const f_utf_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in) { + #ifndef _di_level_1_parameter_checking_ + if (!output) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + if (!string || !length) { + return F_data_not; + } + + return private_fl_print_trim_except_in_utf(output, string, 0, length, except_at, except_in); + } +#endif // _di_fl_print_trim_except_in_utf_ + +#ifndef _di_fl_print_trim_except_in_utf_dynamic_ + f_status_t fl_print_trim_except_in_utf_dynamic(FILE *output, const f_utf_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in) { + #ifndef _di_level_1_parameter_checking_ + if (!output) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + if (!buffer.used) { + return F_data_not; + } + + return private_fl_print_trim_except_in_utf(output, buffer.string, 0, buffer.used, except_at, except_in); + } +#endif // _di_fl_print_trim_except_in_utf_dynamic_ + +#ifndef _di_fl_print_trim_except_in_utf_dynamic_partial_ + f_status_t fl_print_trim_except_in_utf_dynamic_partial(FILE *output, const f_utf_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in) { + #ifndef _di_level_1_parameter_checking_ + if (!output) return F_status_set_error(F_parameter); + #endif // _di_level_1_parameter_checking_ + + if (!buffer.used || range.start > range.stop || range.start >= buffer.used) { + return F_data_not; + } + + f_array_length_t length = (range.stop - range.start) + 1; + + if (length + range.start > buffer.used) { + length = buffer.used - range.start; + } + + return private_fl_print_trim_except_in_utf(output, buffer.string, range.start, range.start + length, except_at, except_in); + } +#endif // _di_fl_print_trim_except_in_utf_dynamic_partial_ + #ifndef _di_fl_print_trim_except_utf_dynamic_partial_ - f_status_t fl_print_trim_except_utf_dynamic_partial(FILE *output, const f_utf_string_static_t buffer, const f_utf_string_range_t range, const f_array_lengths_t except) { + f_status_t fl_print_trim_except_utf_dynamic_partial(FILE *output, const f_utf_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except) { #ifndef _di_level_1_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -97,7 +203,9 @@ extern "C" { length = buffer.used - range.start; } - return private_fl_print_trim_except_utf(output, buffer.string, range.start, range.start + length, except); + const f_string_ranges_t except_in = f_string_ranges_t_initialize; + + return private_fl_print_trim_except_in_utf(output, buffer.string, range.start, range.start + length, except, except_in); } #endif // _di_fl_print_trim_except_utf_dynamic_partial_ @@ -178,7 +286,7 @@ extern "C" { #endif // _di_fl_print_trim_utf_dynamic_ #ifndef _di_fl_print_trim_utf_dynamic_partial_ - f_status_t fl_print_trim_utf_dynamic_partial(FILE *output, const f_utf_string_static_t buffer, const f_utf_string_range_t range) { + f_status_t fl_print_trim_utf_dynamic_partial(FILE *output, const f_utf_string_static_t buffer, const f_string_range_t range) { #ifndef _di_level_1_parameter_checking_ if (!output) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ diff --git a/level_1/fl_print/c/print.h b/level_1/fl_print/c/print.h index a69bebe..da16d52 100644 --- a/level_1/fl_print/c/print.h +++ b/level_1/fl_print/c/print.h @@ -95,6 +95,120 @@ extern "C" { #endif // _di_fl_print_trim_except_dynamic_ /** + * Print a string, stripping leading and trailing whitespace. + * + * Except for leading/trailing whitespace, the string is printed as-is without interpretation. + * + * Will not stop at \0. + * Will not print \0. + * Will not print any 1-byte character at a location specified in except_at array. + * Will not print any 1-byte character within the ranges specified in except_in array. + * + * @param output + * The file to output to, including standard streams such as stdout and stderr. + * @param string + * The string to output. + * @param length + * The total number of characters to print. + * @param except_at + * An array of locations within the given string to not print. + * The array of locations is required/assumed to be in linear order. + * @param except_in + * An array of ranges within the string to not print. + * The array of ranges is required/assumed to be in linear order. + * + * @return + * F_none on success. + * F_data_not on success but there is nothing to print. + * + * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. + * F_output (with error bit) on error when printing to output. + * F_parameter (with error bit) if a parameter is invalid. + * F_utf (with error bit) if character is an invalid UTF-8 character. + * + * Errors (with error bit) from: f_utf_is_whitespace(). + */ +#ifndef _di_fl_print_trim_except_in_ + extern f_status_t fl_print_trim_except_in(FILE *output, const f_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in); +#endif // _di_fl_print_trim_except_in_ + +/** + * Print a dynamic string, stripping leading and trailing whitespace. + * + * Except for leading/trailing whitespace, the string is printed as-is without interpretation. + * + * Will not stop at \0. + * Will not print \0. + * Will print the entire dynamic string, except for leading/trailing whitespace. + * Will not print any 1-byte character at a location specified in except_at array. + * Will not print any 1-byte character within the ranges specified in except_in array. + * + * @param output + * The file to output to, including standard streams such as stdout and stderr. + * @param buffer + * The string to output. + * @param except_at + * An array of locations within the given string to not print. + * The array of locations is required/assumed to be in linear order. + * @param except_in + * An array of ranges within the string to not print. + * The array of ranges is required/assumed to be in linear order. + * + * @return + * F_none on success. + * F_data_not on success but there is nothing to print. + * + * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. + * F_output (with error bit) on error when printing to output. + * F_parameter (with error bit) if a parameter is invalid. + * F_utf (with error bit) if character is an invalid UTF-8 character. + * + * Errors (with error bit) from: f_utf_is_whitespace(). + */ +#ifndef _di_fl_print_trim_except_in_dynamic_ + extern f_status_t fl_print_trim_except_in_dynamic(FILE *output, const f_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in); +#endif // _di_fl_print_trim_except_in_dynamic_ + +/** + * Print a partial dynamic string, stripping leading and trailing whitespace. + * + * Except for leading/trailing whitespace, the string is printed as-is without interpretation. + * + * Will not stop at \0. + * Will not print \0. + * Will not print any 1-byte character at a location specified in except_at array. + * Will not print any 1-byte character within the ranges specified in except_in array. + * Will print the only the buffer range specified by range, except for leading/trailing whitespace. + * + * @param output + * The file to output to, including standard streams such as stdout and stderr. + * @param buffer + * The string to output. + * @param range + * The range within the provided string to print. + * @param except_at + * An array of locations within the given string to not print. + * The array of locations is required/assumed to be in linear order. + * @param except_in + * An array of ranges within the string to not print. + * The array of ranges is required/assumed to be in linear order. + * + * @return + * F_none on success. + * F_data_not on success but there is nothing to print. + * + * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. + * F_output (with error bit) on error when printing to output. + * F_parameter (with error bit) if a parameter is invalid. + * F_utf (with error bit) if character is an invalid UTF-8 character. + * + * Errors (with error bit) from: f_utf_is_whitespace(). + */ +#ifndef _di_fl_print_trim_except_in_dynamic_partial_ + extern f_status_t fl_print_trim_except_in_dynamic_partial(FILE *output, const f_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in); +#endif // _di_fl_print_trim_except_in_dynamic_partial_ + +/** * Print a partial dynamic string, stripping leading and trailing whitespace. * * Except for leading/trailing whitespace, the string is printed as-is without interpretation. @@ -197,6 +311,120 @@ extern "C" { #endif // _di_fl_print_trim_except_utf_dynamic_ /** + * Print a string, stripping leading and trailing whitespace. + * + * Except for leading/trailing whitespace, the string is printed as-is without interpretation. + * + * Will not stop at \0. + * Will not print \0. + * Will not print any 1 UTF character at a location specified in except_at array. + * Will not print any 1 UTF character within the ranges specified in except_in array. + * + * @param output + * The file to output to, including standard streams such as stdout and stderr. + * @param string + * The string to output. + * @param length + * The total number of characters to print. + * @param except_at + * An array of locations within the given string to not print. + * The array of locations is required/assumed to be in linear order. + * @param except_in + * An array of ranges within the string to not print. + * The array of ranges is required/assumed to be in linear order. + * + * @return + * F_none on success. + * F_data_not on success but there is nothing to print. + * + * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. + * F_output (with error bit) on error when printing to output. + * F_parameter (with error bit) if a parameter is invalid. + * F_utf (with error bit) if character is an invalid UTF-8 character. + * + * Errors (with error bit) from: f_utf_character_is_whitespace(). + */ +#ifndef _di_fl_print_trim_except_in_utf_ + extern f_status_t fl_print_trim_except_in_utf(FILE *output, const f_utf_string_t string, const f_array_length_t length, const f_array_lengths_t except_at, const f_string_ranges_t except_in); +#endif // _di_fl_print_trim_except_in_utf_ + +/** + * Print a dynamic string, stripping leading and trailing whitespace. + * + * Except for leading/trailing whitespace, the string is printed as-is without interpretation. + * + * Will not stop at \0. + * Will not print \0. + * Will not print any 1 UTF character at a location specified in except_at array. + * Will not print any 1 UTF character within the ranges specified in except_in array. + * Will print the entire dynamic string, except for leading/trailing whitespace. + * + * @param output + * The file to output to, including standard streams such as stdout and stderr. + * @param buffer + * The string to output. + * @param except_at + * An array of locations within the given string to not print. + * The array of locations is required/assumed to be in linear order. + * @param except_in + * An array of ranges within the string to not print. + * The array of ranges is required/assumed to be in linear order. + * + * @return + * F_none on success. + * F_data_not on success but there is nothing to print. + * + * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. + * F_output (with error bit) on error when printing to output. + * F_parameter (with error bit) if a parameter is invalid. + * F_utf (with error bit) if character is an invalid UTF-8 character. + * + * Errors (with error bit) from: f_utf_character_is_whitespace(). + */ +#ifndef _di_fl_print_trim_except_in_utf_dynamic_ + extern f_status_t fl_print_trim_except_in_utf_dynamic(FILE *output, const f_utf_string_static_t buffer, const f_array_lengths_t except_at, const f_string_ranges_t except_in); +#endif // _di_fl_print_trim_except_in_utf_dynamic_ + +/** + * Print a partial dynamic string, stripping leading and trailing whitespace. + * + * Except for leading/trailing whitespace, the string is printed as-is without interpretation. + * + * Will not stop at \0. + * Will not print \0. + * Will not print any 1 UTF character at a location specified in except_at array. + * Will not print any 1 UTF character within the ranges specified in except_in array. + * Will print the only the buffer range specified by range, except for leading/trailing whitespace. + * + * @param output + * The file to output to, including standard streams such as stdout and stderr. + * @param buffer + * The string to output. + * @param range + * The range within the provided string to print. + * @param except_at + * An array of locations within the given string to not print. + * The array of locations is required/assumed to be in linear order. + * @param except_in + * An array of ranges within the string to not print. + * The array of ranges is required/assumed to be in linear order. + * + * @return + * F_none on success. + * F_data_not on success but there is nothing to print. + * + * F_complete_not_utf (with error bit) if character is an incomplete UTF-8 fragment. + * F_output (with error bit) on error when printing to output. + * F_parameter (with error bit) if a parameter is invalid. + * F_utf (with error bit) if character is an invalid UTF-8 character. + * + * Errors (with error bit) from: f_utf_character_is_whitespace(). + */ +#ifndef _di_fl_print_trim_except_in_utf_dynamic_partial_ + extern f_status_t fl_print_trim_except_in_utf_dynamic_partial(FILE *output, const f_utf_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except_at, const f_string_ranges_t except_in); +#endif // _di_fl_print_trim_except_in_utf_dynamic_partial_ + +/** * Print a partial dynamic string, stripping leading and trailing whitespace. * * Except for leading/trailing whitespace, the string is printed as-is without interpretation. @@ -228,7 +456,7 @@ extern "C" { * Errors (with error bit) from: f_utf_character_is_whitespace(). */ #ifndef _di_fl_print_trim_except_utf_dynamic_partial_ - extern f_status_t fl_print_trim_except_utf_dynamic_partial(FILE *output, const f_utf_string_static_t buffer, const f_utf_string_range_t range, const f_array_lengths_t except); + extern f_status_t fl_print_trim_except_utf_dynamic_partial(FILE *output, const f_utf_string_static_t buffer, const f_string_range_t range, const f_array_lengths_t except); #endif // _di_fl_print_trim_except_utf_dynamic_partial_ /** @@ -408,7 +636,7 @@ extern "C" { * Errors (with error bit) from: f_utf_character_is_whitespace(). */ #ifndef _di_fl_print_trim_utf_dynamic_partial_ - extern f_status_t fl_print_trim_utf_dynamic_partial(FILE *output, const f_utf_string_static_t buffer, const f_utf_string_range_t range); + extern f_status_t fl_print_trim_utf_dynamic_partial(FILE *output, const f_utf_string_static_t buffer, const f_string_range_t range); #endif // _di_fl_print_trim_utf_dynamic_partial_ #ifdef __cplusplus diff --git a/level_1/fl_print/c/private-print.c b/level_1/fl_print/c/private-print.c index 9085893..a916c1d 100644 --- a/level_1/fl_print/c/private-print.c +++ b/level_1/fl_print/c/private-print.c @@ -5,29 +5,42 @@ extern "C" { #endif -#if !defined(_di_fl_print_trim_except_) || !defined(_di_fl_print_trim_except_dynamic_) || !defined(_di_fl_print_trim_except_dynamic_partial_) - f_status_t private_fl_print_trim_except(FILE *output, const f_string_t string, const f_array_length_t start, const f_array_length_t stop, const f_array_lengths_t except) { +#if !defined(_di_fl_print_trim_except_) || !defined(_di_fl_print_trim_except_dynamic_) || !defined(_di_fl_print_trim_except_dynamic_partial_) || !defined(_di_fl_print_trim_except_in_) || !defined(_di_fl_print_trim_except_in_dynamic_) || !defined(_di_fl_print_trim_except_in_dynamic_partial_) + f_status_t private_fl_print_trim_except_in(FILE *output, const f_string_t string, const f_array_length_t start, const f_array_length_t stop, const f_array_lengths_t except_at, const f_string_ranges_t except_in) { f_array_length_t i = start; f_array_length_t j = 0; - f_array_length_t e = 0; - f_array_length_t ej = 0; + f_array_length_t at = 0; + f_array_length_t at2 = 0; + f_array_length_t in = 0; + f_array_length_t in2 = 0; f_status_t status = F_none; uint8_t width_max = 0; + // skip past leading whitespace. while (i < stop) { - for (; e < except.used && except.array[e] < i; ++e) { - // do nothing. - } // for + while (at < except_at.used && except_at.array[at] < i) { + ++at; + } // while - if (e < except.used && except.array[e] == i) { + if (at < except_at.used && except_at.array[at] == i) { ++i; continue; } + while (in < except_in.used && except_in.array[in].start < i && except_in.array[in].stop < i) { + ++in; + } // while + + if (in < except_in.used && except_in.array[in].start <= i && except_in.array[in].stop >= i) { + i = except_in.array[in].stop + 1; + + continue; + } + width_max = (stop - i) + 1; status = f_utf_is_whitespace(string + i, width_max); @@ -48,16 +61,26 @@ extern "C" { if (!string[i]) continue; - for (; e < except.used && except.array[e] < i; ++e) { - // do nothing. - } // for + while (at < except_at.used && except_at.array[at] < i) { + ++at; + } // while - if (e < except.used && except.array[e] == i) { + if (at < except_at.used && except_at.array[at] == i) { ++i; continue; } + while (in < except_in.used && except_in.array[in].start < i && except_in.array[in].stop < i) { + ++in; + } // while + + if (in < except_in.used && except_in.array[in].start <= i && except_in.array[in].stop >= i) { + i = except_in.array[in].stop + 1; + + continue; + } + width_max = (stop - i) + 1; status = f_utf_is_whitespace(string + i, width_max); @@ -76,20 +99,30 @@ extern "C" { return F_none; } - ej = e; + at2 = at; while (j < stop) { - for (; ej < except.used && except.array[ej] < j; ++ej) { - // do nothing. - } // for + while (at2 < except_at.used && except_at.array[at2] < j) { + ++at2; + } // while - if (ej < except.used && except.array[ej] == j) { + if (at2 < except_at.used && except_at.array[at2] == j) { ++j; continue; } + while (in2 < except_in.used && except_in.array[in2].start < j && except_in.array[in2].stop <= j) { + ++in2; + } // while + + if (in2 < except_in.used && except_in.array[in2].start <= j && except_in.array[in2].stop >= j) { + j = except_in.array[in2].stop + 1; + + continue; + } + width_max = (stop - j) + 1; status = f_utf_is_whitespace(string + j, width_max); @@ -103,20 +136,40 @@ extern "C" { // all whitespaces found so far must be printed when a non-whitespace is found. if (status == F_false) { - for (; i < j; ++i) { + while (i < j) { - if (!string[i]) continue; + if (!string[i]) { + ++i; + + continue; + } + + while (at < except_at.used && except_at.array[at] < i) { + ++at; + } // while + + if (at < except_at.used && except_at.array[at] == i) { + ++i; + + continue; + } - for (; e < except.used && except.array[e] < i; ++e) { - // do nothing. - } // for + while (in < except_in.used && except_in.array[in].start < i && except_in.array[in].stop < i) { + ++in; + } // while - if (e < except.used && except.array[e] == i) continue; + if (in < except_in.used && except_in.array[in].start <= i && except_in.array[in].stop >= i) { + i = except_in.array[in].stop + 1; + + continue; + } if (!fputc(string[i], output)) { return F_status_set_error(F_output); } - } // for + + ++i; + } // while break; } @@ -141,25 +194,41 @@ extern "C" { return F_none; } -#endif // !defined(_di_fl_print_trim_except_) || !defined(_di_fl_print_trim_except_dynamic_) || !defined(_di_fl_print_trim_except_dynamic_partial_) +#endif // !defined(_di_fl_print_trim_except_) || !defined(_di_fl_print_trim_except_dynamic_) || !defined(_di_fl_print_trim_except_dynamic_partial_) || !defined(_di_fl_print_trim_except_in_) || !defined(_di_fl_print_trim_except_in_dynamic_) || !defined(_di_fl_print_trim_except_in_dynamic_partial_) -#if !defined(_di_fl_print_trim_except_utf_) || !defined(_di_fl_print_trim_except_utf_dynamic_) || !defined(_di_fl_print_trim_except_utf_dynamic_partial_) - f_status_t private_fl_print_trim_except_utf(FILE *output, const f_utf_string_t string, const f_array_length_t start, const f_array_length_t stop, const f_array_lengths_t except) { +#if !defined(_di_fl_print_trim_except_in_utf_) || !defined(_di_fl_print_trim_except_in_utf_dynamic_) || !defined(_di_fl_print_trim_except_in_utf_dynamic_partial_) || !defined(_di_fl_print_trim_except_utf_) || !defined(_di_fl_print_trim_except_utf_dynamic_) || !defined(_di_fl_print_trim_except_utf_dynamic_partial_) + f_status_t private_fl_print_trim_except_in_utf(FILE *output, const f_utf_string_t string, const f_array_length_t start, const f_array_length_t stop, const f_array_lengths_t except_at, const f_string_ranges_t except_in) { f_array_length_t i = start; f_array_length_t j = 0; - f_array_length_t e = 0; - f_array_length_t ej = 0; + f_array_length_t at = 0; + f_array_length_t at2 = 0; + f_array_length_t in = 0; + f_array_length_t in2 = 0; f_status_t status = F_none; - for (; i < stop; ++i) { + while (i < stop) { + + while (at < except_at.used && except_at.array[at] < i) { + ++at; + } // while - for (; e < except.used && except.array[e] < i; ++e) { - // do nothing. - } // for + if (at < except_at.used && except_at.array[at] == i) { + ++i; + + continue; + } + + while (in < except_in.used && except_in.array[in].start < i && except_in.array[in].stop < i) { + ++in; + } // while + + if (in < except_in.used && except_in.array[in].start <= i && except_in.array[in].stop >= i) { + i = except_in.array[in].stop + 1; - if (e < except.used && except.array[e] == i) continue; + continue; + } status = f_utf_character_is_whitespace(string[i]); @@ -172,17 +241,27 @@ extern "C" { } if (status == F_false) break; - } // for - for (; i < stop; ++i) { + ++i; + } // while - if (!string[i]) continue; + while (i < stop) { - for (; e < except.used && except.array[e] < i; ++e) { - // do nothing. - } // for + if (!string[i]) { + ++i; + + continue; + } + + while (at < except_at.used && except_at.array[at] < i) { + ++at; + } // while - if (e < except.used && except.array[e] == i) continue; + if (at < except_at.used && except_at.array[at] == i) { + ++i; + + continue; + } status = f_utf_character_is_whitespace(string[i]); @@ -201,13 +280,29 @@ extern "C" { return F_none; } - for (ej = e; j < stop; ++j) { + at2 = at; + + while (j < stop) { + + while (at2 < except_at.used && except_at.array[at2] < j) { + ++at2; + } // while - for (; ej < except.used && except.array[ej] < j; ++ej) { - // do nothing. - } // for + if (at2 < except_at.used && except_at.array[at2] == j) { + ++j; - if (ej < except.used && except.array[ej] == j) continue; + continue; + } + + while (in2 < except_in.used && except_in.array[in2].start < j && except_in.array[in2].stop <= j) { + ++in2; + } // while + + if (in2 < except_in.used && except_in.array[in2].start <= j && except_in.array[in2].stop >= j) { + j = except_in.array[in2].stop + 1; + + continue; + } status = f_utf_character_is_whitespace(string[j]); @@ -221,24 +316,36 @@ extern "C" { // all whitespaces found so far must be printed when a non-whitespace is found. if (status == F_false) { - for (; i < j; ++i) { + while (i < j) { - if (!string[i]) continue; + if (!string[i]) { + ++i; - for (; e < except.used && except.array[e] < i; ++e) { - // do nothing. - } // for + continue; + } - if (e < except.used && except.array[e] == i) continue; + while (at < except_at.used && except_at.array[at] < i) { + ++at; + } // while + + if (at < except_at.used && except_at.array[at] == i) { + ++i; + + continue; + } if (!fputc(string[i], output)) { return F_status_set_error(F_output); } - } // for + + ++i; + } // while break; } - } // for + + ++j; + } // while if (status == F_true) break; } @@ -246,11 +353,13 @@ extern "C" { if (!fputc(string[i], output)) { return F_status_set_error(F_output); } - } // for + + ++i; + } // while return F_none; } -#endif // !defined(_di_fl_print_trim_except_utf_) || !defined(_di_fl_print_trim_except_utf_dynamic_) || !defined(_di_fl_print_trim_except_utf_dynamic_partial_) +#endif // !defined(_di_fl_print_trim_except_in_utf_) || !defined(_di_fl_print_trim_except_in_utf_dynamic_) || !defined(_di_fl_print_trim_except_in_utf_dynamic_partial_) || !defined(_di_fl_print_trim_except_utf_) || !defined(_di_fl_print_trim_except_utf_dynamic_) || !defined(_di_fl_print_trim_except_utf_dynamic_partial_) #if !defined(_di_fl_print_trim_) || !defined(_di_fl_print_trim_dynamic_) || !defined(_di_fl_print_trim_dynamic_partial_) f_status_t private_fl_print_trim(FILE *output, const f_string_t string, const f_array_length_t length) { diff --git a/level_1/fl_print/c/private-print.h b/level_1/fl_print/c/private-print.h index 763305c..4b144e6 100644 --- a/level_1/fl_print/c/private-print.h +++ b/level_1/fl_print/c/private-print.h @@ -28,9 +28,12 @@ extern "C" { * The inclusive start point to start printing. * @param stop * The exclusive stop point to stop printing. - * @param except + * @param except_at * An array of locations within the given string to not print. * The array of locations is required/assumed to be in linear order. + * @param except_in + * An array of ranges within the string to not print. + * The array of ranges is required/assumed to be in linear order. * * @return * F_none on success. @@ -46,10 +49,13 @@ extern "C" { * @see fl_print_trim_except() * @see fl_print_trim_except_dynamic() * @see fl_print_trim_except_dynamic_partial() + * @see fl_print_trim_except_in() + * @see fl_print_trim_except_in_dynamic() + * @see fl_print_trim_except_in_dynamic_partial() */ -#if !defined(_di_fl_print_trim_except_) || !defined(_di_fl_print_trim_except_dynamic_) || !defined(_di_fl_print_trim_except_dynamic_partial_) - extern f_status_t private_fl_print_trim_except(FILE *output, const f_string_t string, const f_array_length_t start, const f_array_length_t stop, const f_array_lengths_t except) f_attribute_visibility_internal; -#endif // !defined(_di_fl_print_trim_except_) || !defined(_di_fl_print_trim_except_dynamic_) || !defined(_di_fl_print_trim_except_dynamic_partial_) +#if !defined(_di_fl_print_trim_except_) || !defined(_di_fl_print_trim_except_dynamic_) || !defined(_di_fl_print_trim_except_dynamic_partial_) || !defined(_di_fl_print_trim_except_in_) || !defined(_di_fl_print_trim_except_in_dynamic_) || !defined(_di_fl_print_trim_except_in_dynamic_partial_) + extern f_status_t private_fl_print_trim_except_in(FILE *output, const f_string_t string, const f_array_length_t start, const f_array_length_t stop, const f_array_lengths_t except_at, const f_string_ranges_t except_in) f_attribute_visibility_internal; +#endif // !defined(_di_fl_print_trim_except_) || !defined(_di_fl_print_trim_except_dynamic_) || !defined(_di_fl_print_trim_except_dynamic_partial_) || !defined(_di_fl_print_trim_except_in_) || !defined(_di_fl_print_trim_except_in_dynamic_) || !defined(_di_fl_print_trim_except_in_dynamic_partial_) /** * Private implementation of fl_print_trim_except_utf(). @@ -79,13 +85,16 @@ extern "C" { * * Errors (with error bit) from: f_utf_character_is_whitespace(). * + * @see fl_print_trim_except_in_utf() + * @see fl_print_trim_except_in_utf_dynamic() + * @see fl_print_trim_except_in_utf_dynamic_partial() * @see fl_print_trim_except_utf() * @see fl_print_trim_except_utf_dynamic() * @see fl_print_trim_except_utf_dynamic_partial() */ -#if !defined(_di_fl_print_trim_except_utf_) || !defined(_di_fl_print_trim_except_utf_dynamic_) || !defined(_di_fl_print_trim_except_utf_dynamic_partial_) - extern f_status_t private_fl_print_trim_except_utf(FILE *output, const f_utf_string_t string, const f_array_length_t start, const f_array_length_t stop, const f_array_lengths_t except) f_attribute_visibility_internal; -#endif // !defined(_di_fl_print_trim_except_utf_) || !defined(_di_fl_print_trim_except_utf_dynamic_) || !defined(_di_fl_print_trim_except_utf_dynamic_partial_) +#if !defined(_di_fl_print_trim_except_in_utf_) || !defined(_di_fl_print_trim_except_in_utf_dynamic_) || !defined(_di_fl_print_trim_except_in_utf_dynamic_partial_) || !defined(_di_fl_print_trim_except_utf_) || !defined(_di_fl_print_trim_except_utf_dynamic_) || !defined(_di_fl_print_trim_except_utf_dynamic_partial_) + extern f_status_t private_fl_print_trim_except_in_utf(FILE *output, const f_utf_string_t string, const f_array_length_t start, const f_array_length_t stop, const f_array_lengths_t except_at, const f_string_ranges_t except_in) f_attribute_visibility_internal; +#endif // !defined(_di_fl_print_trim_except_in_utf_) || !defined(_di_fl_print_trim_except_in_utf_dynamic_) || !defined(_di_fl_print_trim_except_in_utf_dynamic_partial_) || !defined(_di_fl_print_trim_except_utf_) || !defined(_di_fl_print_trim_except_utf_dynamic_) || !defined(_di_fl_print_trim_except_utf_dynamic_partial_) /** * Private implementation of fl_print_trim(). diff --git a/level_1/fl_utf/c/utf.c b/level_1/fl_utf/c/utf.c index 8df0ee8..3d733fa 100644 --- a/level_1/fl_utf/c/utf.c +++ b/level_1/fl_utf/c/utf.c @@ -30,7 +30,7 @@ extern "C" { #endif // _di_fl_utf_string_dynamic_compare_trim_ #ifndef _di_fl_utf_string_dynamic_partial_compare_ - f_status_t fl_utf_string_dynamic_partial_compare(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_utf_string_range_t range1, const f_utf_string_range_t range2) { + f_status_t fl_utf_string_dynamic_partial_compare(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_string_range_t range1, const f_string_range_t range2) { #ifndef _di_level_1_parameter_checking_ if (string1.used <= range1.stop) return F_status_set_error(F_parameter); if (string2.used <= range2.stop) return F_status_set_error(F_parameter); @@ -41,7 +41,7 @@ extern "C" { #endif // _di_fl_utf_string_dynamic_partial_compare_ #ifndef _di_fl_utf_string_dynamic_partial_compare_trim_ - f_status_t fl_utf_string_dynamic_partial_compare_trim(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_utf_string_range_t range1, const f_utf_string_range_t range2) { + f_status_t fl_utf_string_dynamic_partial_compare_trim(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_string_range_t range1, const f_string_range_t range2) { #ifndef _di_level_1_parameter_checking_ if (string1.used <= range1.stop) return F_status_set_error(F_parameter); if (string2.used <= range2.stop) return F_status_set_error(F_parameter); @@ -52,7 +52,7 @@ extern "C" { #endif // _di_fl_utf_string_dynamic_partial_compare_trim_ #ifndef _di_fl_utf_string_dynamic_rip_ - f_status_t fl_utf_string_dynamic_rip(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t fl_utf_string_dynamic_rip(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (source.used <= range.start) return F_status_set_error(F_parameter); if (source.used <= range.stop) return F_status_set_error(F_parameter); @@ -72,7 +72,7 @@ extern "C" { #endif // _di_fl_utf_string_dynamic_rip_ #ifndef _di_fl_utf_string_dynamic_rip_nulless_ - f_status_t fl_utf_string_dynamic_rip_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination) { + f_status_t fl_utf_string_dynamic_rip_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination) { #ifndef _di_level_1_parameter_checking_ if (source.used <= range.start) return F_status_set_error(F_parameter); if (source.used <= range.stop) return F_status_set_error(F_parameter); @@ -92,7 +92,7 @@ extern "C" { #endif // _di_fl_utf_string_dynamic_rip_nulless_ #ifndef _di_fl_utf_string_dynamic_seek_line_to_char_ - f_status_t fl_utf_string_dynamic_seek_line_to_char(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const char seek_to_this) { + f_status_t fl_utf_string_dynamic_seek_line_to_char(const f_utf_string_static_t buffer, f_string_range_t *range, const char seek_to_this) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (buffer.used <= range->start) return F_status_set_error(F_parameter); @@ -138,7 +138,7 @@ extern "C" { #endif // _di_fl_utf_string_dynamic_seek_line_to_char_ #ifndef _di_fl_utf_string_dynamic_seek_line_until_graph_ - f_status_t fl_utf_string_dynamic_seek_line_until_graph(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t placeholder) { + f_status_t fl_utf_string_dynamic_seek_line_until_graph(const f_utf_string_static_t buffer, f_string_range_t *range, const f_utf_character_t placeholder) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (buffer.used <= range->start) return F_status_set_error(F_parameter); @@ -192,7 +192,7 @@ extern "C" { #endif // _di_fl_utf_string_dynamic_seek_line_until_graph_ #ifndef _di_fl_utf_string_dynamic_seek_line_until_graph_non_ - f_status_t fl_utf_string_dynamic_seek_line_until_graph_non(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t placeholder) { + f_status_t fl_utf_string_dynamic_seek_line_until_graph_non(const f_utf_string_static_t buffer, f_string_range_t *range, const f_utf_character_t placeholder) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (buffer.used <= range->start) return F_status_set_error(F_parameter); @@ -229,7 +229,7 @@ extern "C" { #endif // _di_fl_utf_string_dynamic_seek_line_until_graph_non_ #ifndef _di_fl_utf_string_dynamic_seek_to_char_ - f_status_t fl_utf_string_dynamic_seek_to_char(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const char seek_to_this) { + f_status_t fl_utf_string_dynamic_seek_to_char(const f_utf_string_static_t buffer, f_string_range_t *range, const char seek_to_this) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); if (buffer.used <= range->start) return F_status_set_error(F_parameter); @@ -325,7 +325,7 @@ extern "C" { #endif // _di_fl_utf_string_rip_nulless_ #ifndef _di_fl_utf_string_seek_line_to_char_ - f_status_t fl_utf_string_seek_line_to_char(const f_utf_string_t string, f_utf_string_range_t *range, const char seek_to_this) { + f_status_t fl_utf_string_seek_line_to_char(const f_utf_string_t string, f_string_range_t *range, const char seek_to_this) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -356,7 +356,7 @@ extern "C" { #endif // _di_fl_utf_string_seek_line_to_char_ #ifndef _di_fl_utf_string_seek_line_until_graph_ - f_status_t fl_utf_string_seek_line_until_graph(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t placeholder) { + f_status_t fl_utf_string_seek_line_until_graph(const f_utf_string_t string, f_string_range_t *range, const f_utf_character_t placeholder) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -401,7 +401,7 @@ extern "C" { #endif // _di_fl_utf_string_seek_line_until_graph_ #ifndef _di_fl_utf_string_seek_line_until_graph_non_ - f_status_t fl_utf_string_seek_line_until_graph_non(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t placeholder) { + f_status_t fl_utf_string_seek_line_until_graph_non(const f_utf_string_t string, f_string_range_t *range, const f_utf_character_t placeholder) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ @@ -446,7 +446,7 @@ extern "C" { #endif // _di_fl_utf_string_seek_line_until_graph_non_ #ifndef _di_fl_utf_string_seek_to_char_ - f_status_t fl_utf_string_seek_to_char(const f_utf_string_t string, f_utf_string_range_t *range, const char seek_to_this) { + f_status_t fl_utf_string_seek_to_char(const f_utf_string_t string, f_string_range_t *range, const char seek_to_this) { #ifndef _di_level_1_parameter_checking_ if (!range) return F_status_set_error(F_parameter); #endif // _di_level_1_parameter_checking_ diff --git a/level_1/fl_utf/c/utf.h b/level_1/fl_utf/c/utf.h index 90a9656..fb8d8a8 100644 --- a/level_1/fl_utf/c/utf.h +++ b/level_1/fl_utf/c/utf.h @@ -160,7 +160,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_fl_utf_string_dynamic_partial_compare_ - extern f_status_t fl_utf_string_dynamic_partial_compare(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_utf_string_range_t range1, const f_utf_string_range_t range2); + extern f_status_t fl_utf_string_dynamic_partial_compare(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_string_range_t range1, const f_string_range_t range2); #endif // _di_fl_utf_string_dynamic_partial_compare_ /** @@ -190,7 +190,7 @@ extern "C" { * @see f_utf_character_is_whitespace() */ #ifndef _di_fl_utf_string_dynamic_partial_compare_trim_ - extern f_status_t fl_utf_string_dynamic_partial_compare_trim(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_utf_string_range_t range1, const f_utf_string_range_t range2); + extern f_status_t fl_utf_string_dynamic_partial_compare_trim(const f_utf_string_static_t string1, const f_utf_string_static_t string2, const f_string_range_t range1, const f_string_range_t range2); #endif // _di_fl_utf_string_dynamic_partial_compare_trim_ /** @@ -216,7 +216,7 @@ extern "C" { * F_string_too_large (with error bit) if the combined string is too large. */ #ifndef _di_fl_utf_string_dynamic_rip_ - extern f_status_t fl_utf_string_dynamic_rip(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t fl_utf_string_dynamic_rip(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); #endif // _di_fl_utf_string_dynamic_rip_ /** @@ -243,7 +243,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_fl_utf_string_dynamic_rip_nulless_ - extern f_status_t fl_utf_string_dynamic_rip_nulless(const f_utf_string_static_t source, const f_utf_string_range_t range, f_utf_string_dynamic_t *destination); + extern f_status_t fl_utf_string_dynamic_rip_nulless(const f_utf_string_static_t source, const f_string_range_t range, f_utf_string_dynamic_t *destination); #endif // _di_fl_utf_string_dynamic_rip_nulless_ /** @@ -268,7 +268,7 @@ extern "C" { * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. */ #ifndef _di_fl_utf_string_dynamic_seek_line_to_char_ - extern f_status_t fl_utf_string_dynamic_seek_line_to_char(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const char seek_to_this); + extern f_status_t fl_utf_string_dynamic_seek_line_to_char(const f_utf_string_static_t buffer, f_string_range_t *range, const char seek_to_this); #endif // _di_fl_utf_string_dynamic_seek_line_to_char_ /** @@ -296,7 +296,7 @@ extern "C" { * @see f_utf_character_is_graph() */ #ifndef _di_fl_utf_string_dynamic_seek_line_until_graph_ - extern f_status_t fl_utf_string_dynamic_seek_line_until_graph(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t placeholder); + extern f_status_t fl_utf_string_dynamic_seek_line_until_graph(const f_utf_string_static_t buffer, f_string_range_t *range, const f_utf_character_t placeholder); #endif // _di_fl_utf_string_dynamic_seek_line_until_graph_ /** @@ -325,7 +325,7 @@ extern "C" { * @see f_utf_character_is_graph() */ #ifndef _di_fl_utf_string_dynamic_seek_line_until_graph_non_ - extern f_status_t fl_utf_string_dynamic_seek_line_until_graph_non(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const f_utf_character_t placeholder); + extern f_status_t fl_utf_string_dynamic_seek_line_until_graph_non(const f_utf_string_static_t buffer, f_string_range_t *range, const f_utf_character_t placeholder); #endif // _di_fl_utf_string_dynamic_seek_line_until_graph_non_ /** @@ -350,7 +350,7 @@ extern "C" { * F_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_fl_utf_string_dynamic_seek_to_char_ - extern f_status_t fl_utf_string_dynamic_seek_to_char(const f_utf_string_static_t buffer, f_utf_string_range_t *range, const char seek_to_this); + extern f_status_t fl_utf_string_dynamic_seek_to_char(const f_utf_string_static_t buffer, f_string_range_t *range, const char seek_to_this); #endif // _di_fl_utf_string_dynamic_seek_to_char_ /** @@ -432,7 +432,7 @@ extern "C" { * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. */ #ifndef _di_fl_utf_string_seek_line_to_char_ - extern f_status_t fl_utf_string_seek_line_to_char(const f_utf_string_t string, f_utf_string_range_t *range, const char seek_to_this); + extern f_status_t fl_utf_string_seek_line_to_char(const f_utf_string_t string, f_string_range_t *range, const char seek_to_this); #endif // _di_fl_utf_string_seek_line_to_char_ /** @@ -462,7 +462,7 @@ extern "C" { * @see f_utf_character_is_graph() */ #ifndef _di_fl_utf_string_seek_line_until_graph_ - extern f_status_t fl_utf_string_seek_line_until_graph(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t placeholder); + extern f_status_t fl_utf_string_seek_line_until_graph(const f_utf_string_t string, f_string_range_t *range, const f_utf_character_t placeholder); #endif // _di_fl_utf_string_seek_line_until_graph_ /** @@ -493,7 +493,7 @@ extern "C" { * @see f_utf_character_is_graph() */ #ifndef _di_fl_utf_string_seek_line_until_graph_non_ - extern f_status_t fl_utf_string_seek_line_until_graph_non(const f_utf_string_t string, f_utf_string_range_t *range, const f_utf_character_t placeholder); + extern f_status_t fl_utf_string_seek_line_until_graph_non(const f_utf_string_t string, f_string_range_t *range, const f_utf_character_t placeholder); #endif // _di_fl_utf_string_seek_line_until_graph_non_ /** @@ -517,7 +517,7 @@ extern "C" { * F_utf (with error bit) if a character in the buffer is an invalid UTF-8 character. */ #ifndef _di_fl_utf_string_seek_to_character_ - extern f_status_t fl_utf_string_seek_to_char(const f_utf_string_t string, f_utf_string_range_t *range, const char seek_to_this); + extern f_status_t fl_utf_string_seek_to_char(const f_utf_string_t string, f_string_range_t *range, const char seek_to_this); #endif // _di_fl_utf_string__seek_to_character_ #ifdef __cplusplus diff --git a/level_1/fl_utf_file/c/utf_file.c b/level_1/fl_utf_file/c/utf_file.c index 19845dd..613a9f0 100644 --- a/level_1/fl_utf_file/c/utf_file.c +++ b/level_1/fl_utf_file/c/utf_file.c @@ -313,7 +313,7 @@ extern "C" { #endif // _di_fl_utf_file_write_until_ #ifndef _di_fl_utf_file_write_range_ - f_status_t fl_utf_file_write_range(const f_file_t file, const f_utf_string_static_t buffer, const f_utf_string_range_t range, f_array_length_t *written) { + f_status_t fl_utf_file_write_range(const f_file_t file, const f_utf_string_static_t buffer, const f_string_range_t range, f_array_length_t *written) { #ifndef _di_level_0_parameter_checking_ if (!file.size_write) return F_status_set_error(F_parameter); if (buffer.used > buffer.size) return F_status_set_error(F_parameter); diff --git a/level_1/fl_utf_file/c/utf_file.h b/level_1/fl_utf_file/c/utf_file.h index 76f137d..f7d0c11 100644 --- a/level_1/fl_utf_file/c/utf_file.h +++ b/level_1/fl_utf_file/c/utf_file.h @@ -263,7 +263,7 @@ extern "C" { * @see write() */ #ifndef _di_fl_utf_file_write_range_ - extern f_status_t fl_utf_file_write_range(const f_file_t file, const f_utf_string_static_t buffer, const f_utf_string_range_t range, f_array_length_t *written); + extern f_status_t fl_utf_file_write_range(const f_file_t file, const f_utf_string_static_t buffer, const f_string_range_t range, f_array_length_t *written); #endif // _di_fl_utf_file_write_range_ #ifdef __cplusplus diff --git a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c index 0855521..23b3f56 100644 --- a/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c +++ b/level_3/fss_basic_list_read/c/private-fss_basic_list_read.c @@ -286,10 +286,10 @@ extern "C" { if ((data->option & fss_basic_list_read_data_option_object) || (data->option & fss_basic_list_read_data_option_content) && (data->contents.array[at].used || (data->option & fss_basic_list_read_data_option_empty))) { if (data->option & fss_basic_list_read_data_option_object) { if (data->option & fss_basic_list_read_data_option_trim) { - fl_print_trim_except_dynamic_partial(main->output.stream, data->buffer, data->objects.array[at], delimits_object); + fl_print_trim_except_in_dynamic_partial(main->output.stream, data->buffer, data->objects.array[at], delimits_object, data->comments); } else { - f_print_except_dynamic_partial(main->output.stream, data->buffer, data->objects.array[at], delimits_object); + f_print_except_in_dynamic_partial(main->output.stream, data->buffer, data->objects.array[at], delimits_object, data->comments); } fss_basic_list_read_print_object_end(main); @@ -298,7 +298,7 @@ extern "C" { if (data->option & fss_basic_list_read_data_option_content) { if (data->contents.array[at].used) { fss_basic_list_read_print_content_ignore(main); - f_print_except_dynamic_partial(main->output.stream, data->buffer, data->contents.array[at].array[0], delimits_content); + f_print_except_in_dynamic_partial(main->output.stream, data->buffer, data->contents.array[at].array[0], delimits_content, data->comments); fss_basic_list_read_print_content_ignore(main); } } @@ -556,7 +556,7 @@ extern "C" { fss_basic_list_read_print_one(main); } else { - f_print_except_dynamic_partial(main->output.stream, data->buffer, range, delimits_content); + f_print_except_in_dynamic_partial(main->output.stream, data->buffer, range, delimits_content, data->comments); } return F_success; @@ -581,7 +581,7 @@ extern "C" { else { range.stop = data->contents.array[at].array[0].stop; - f_print_except_dynamic_partial(main->output.stream, data->buffer, range, delimits_content); + f_print_except_in_dynamic_partial(main->output.stream, data->buffer, range, delimits_content, data->comments); fprintf(main->output.stream, "%c", f_string_eol_s[0]); } diff --git a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c index ca9169b..81592ee 100644 --- a/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c +++ b/level_3/fss_extended_list_read/c/private-fss_extended_list_read.c @@ -299,7 +299,7 @@ extern "C" { if (data->contents.array[at].used && data->contents.array[at].array[0].start <= data->contents.array[at].array[0].stop) { if (data->contents.array[at].used && data->contents.array[at].array[0].start <= data->contents.array[at].array[0].stop) { fss_extended_list_read_print_content_ignore(main); - f_print_except_dynamic_partial(main->output.stream, data->buffer, data->contents.array[at].array[0], delimits_content); + f_print_except_in_dynamic_partial(main->output.stream, data->buffer, data->contents.array[at].array[0], delimits_content, data->comments); fss_extended_list_read_print_content_ignore(main); } } @@ -607,7 +607,7 @@ extern "C" { fss_extended_list_read_print_one(main); } else { - f_print_except_dynamic_partial(main->output.stream, data->buffer, range, delimits_content); + f_print_except_in_dynamic_partial(main->output.stream, data->buffer, range, delimits_content, data->comments); } return F_success; @@ -632,7 +632,7 @@ extern "C" { else { range.stop = data->contents.array[at].array[0].stop; - f_print_except_dynamic_partial(main->output.stream, data->buffer, range, delimits_content); + f_print_except_in_dynamic_partial(main->output.stream, data->buffer, range, delimits_content, data->comments); fprintf(main->output.stream, "%c", f_string_eol_s[0]); }