From bd4a0f7dba59786c5ad85281ec4f840718498475 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Fri, 13 Nov 2020 20:16:24 -0600 Subject: [PATCH] Cleanup: add F_array and similar status codes. I originally tried to simplify things and have only F_array or F_buffer. I have found myself wanting to use F_array, naturally, more and more. Furthermore, the semantics of "array" and "buffer" are similar but not the same. Add the F_array (and similar status codes). Update existing code that should be using F_array instead of F_buffer. --- level_0/f_console/c/console.c | 2 +- level_0/f_console/c/console.h | 2 +- level_0/f_directory/c/directory.c | 2 +- level_0/f_directory/c/directory.h | 2 +- level_0/f_serialize/c/serialize.c | 4 ++-- level_0/f_serialize/c/serialize.h | 4 ++-- level_0/f_status/c/status.h | 6 ++++++ level_1/fl_directory/c/private-directory.c | 4 ++-- level_1/fl_directory/c/private-directory.h | 2 ++ level_1/fl_environment/c/environment.c | 16 ++++++++-------- level_1/fl_environment/c/environment.h | 8 ++++---- level_1/fl_fss/c/fss_basic_list.h | 4 ++-- level_1/fl_fss/c/fss_extended_list.h | 4 ++-- level_1/fl_fss/c/private-fss.c | 4 ++-- level_1/fl_fss/c/private-fss.h | 10 +++++----- level_1/fl_status/c/status.c | 12 ++++++++++++ level_1/fl_status/c/status.h | 10 ++++++++++ level_1/fl_string/c/string.c | 16 ++++++++-------- level_1/fl_string/c/string.h | 16 ++++++++-------- level_2/fll_error/c/private-error.c | 13 +++++++++++++ level_2/fll_execute/c/execute.h | 18 +++++++++--------- level_2/fll_execute/c/private-execute.c | 4 ++-- level_2/fll_execute/c/private-execute.h | 4 ++-- level_2/fll_fss/c/fss.c | 18 +++++++++--------- level_2/fll_program/c/program.c | 2 +- level_2/fll_program/c/program.h | 2 +- level_2/fll_status/c/status.c | 17 +++++++++++++++++ level_3/fake/c/private-build.c | 4 ++-- level_3/fake/c/private-make.c | 4 ++-- level_3/fake/c/private-print.c | 2 +- level_3/fss_extended_write/c/fss_extended_write.c | 2 +- level_3/iki_read/c/private-iki_read.c | 4 ++-- 32 files changed, 141 insertions(+), 81 deletions(-) diff --git a/level_0/f_console/c/console.c b/level_0/f_console/c/console.c index c5f917a..b093f45 100644 --- a/level_0/f_console/c/console.c +++ b/level_0/f_console/c/console.c @@ -310,7 +310,7 @@ extern "C" { // populate list of remaining parameters.parameter not associated with anything. if (remaining->used == remaining->size) { - f_macro_memory_structure_macro_increment(status, (*remaining), 1, f_console_default_allocation_step, f_macro_string_lengths_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*remaining), 1, f_console_default_allocation_step, f_macro_string_lengths_t_resize, F_array_too_large); if (F_status_is_error(status)) { f_macro_string_lengths_t_delete_simple(needs_value); return status; diff --git a/level_0/f_console/c/console.h b/level_0/f_console/c/console.h index 4778bc2..7c0d3cc 100644 --- a/level_0/f_console/c/console.h +++ b/level_0/f_console/c/console.h @@ -79,7 +79,7 @@ extern "C" { * @return * F_none on success. * F_data_not if "values" parameters were expected but not found. - * F_buffer_too_large (with error bit) if a buffer would exceed max length. + * F_array_too_large (with error bit) if a buffer would exceed max length. * F_failure (with error bit) if width is not long enough to convert when processing arguments as UTF-8. * F_parameter (with error bit) if a parameter is invalid. * F_utf (with error bit) if character is an invalid UTF-8 character, when processing arguments. diff --git a/level_0/f_directory/c/directory.c b/level_0/f_directory/c/directory.c index e863228..a875e35 100644 --- a/level_0/f_directory/c/directory.c +++ b/level_0/f_directory/c/directory.c @@ -151,7 +151,7 @@ extern "C" { } if (names->used == names->size) { - f_macro_memory_structure_macro_increment(status, (*names), 1, f_directory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*names), 1, f_directory_default_allocation_step, f_macro_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) break; } diff --git a/level_0/f_directory/c/directory.h b/level_0/f_directory/c/directory.h index c0ac0ae..43d5eea 100644 --- a/level_0/f_directory/c/directory.h +++ b/level_0/f_directory/c/directory.h @@ -230,7 +230,7 @@ extern "C" { * @return * F_none on success. * F_data_not if directory is empty. - * F_buffer_too_large (with error bit) if the directory buffer max length would be exceeded. + * F_array_too_large (with error bit) if the directory buffer max length would be exceeded. * F_failure (with error bit) if failed to read directory information. * F_memory_reallocation (with error bit) on memory reallocation error. * F_parameter (with error bit) if a parameter is invalid. diff --git a/level_0/f_serialize/c/serialize.c b/level_0/f_serialize/c/serialize.c index c3aa331..b1ef864 100644 --- a/level_0/f_serialize/c/serialize.c +++ b/level_0/f_serialize/c/serialize.c @@ -50,7 +50,7 @@ extern "C" { width = f_macro_utf_byte_width(serialize.string[i]); if (serialize.string[i] == f_serialize_simple_splitter || i + 1 >= serialize.used) { - f_macro_memory_structure_macro_increment(status, (*strings), 1, f_serialize_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*strings), 1, f_serialize_default_allocation_step, f_macro_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; if (start == i) { @@ -116,7 +116,7 @@ extern "C" { width = f_macro_utf_byte_width(serialize.string[i]); if (serialize.string[i] == f_serialize_simple_splitter || i + 1 >= serialize.used) { - f_macro_memory_structure_macro_increment(status, (*locations), 1, f_serialize_default_allocation_step, f_macro_string_ranges_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*locations), 1, f_serialize_default_allocation_step, f_macro_string_ranges_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; if (start == i) { diff --git a/level_0/f_serialize/c/serialize.h b/level_0/f_serialize/c/serialize.h index bf55e30..47f2880 100644 --- a/level_0/f_serialize/c/serialize.h +++ b/level_0/f_serialize/c/serialize.h @@ -71,7 +71,7 @@ extern "C" { * @return * F_none on success. * F_incomplete_utf_eos if end of sting is reached before a complete UTF-8 character can be processed. - * F_buffer_too_large (with error bit) if a buffer would exceed maximum length. + * F_array_too_large (with error bit) if a buffer would exceed maximum length. * F_memory_reallocation (with error bit) on memory reallocation error. * F_parameter (with error bit) if a parameter is invalid. */ @@ -97,7 +97,7 @@ extern "C" { * @return * F_none on success. * F_incomplete_utf_eos if end of sting is reached before a complete UTF-8 character can be processed. - * F_buffer_too_large (with error bit) if a buffer would exceed memory max length. + * F_array_too_large (with error bit) if a buffer would exceed memory max length. * F_memory_reallocation (with error bit) on memory reallocation error. * F_parameter (with error bit) if a parameter is invalid. */ diff --git a/level_0/f_status/c/status.h b/level_0/f_status/c/status.h index e4e30b9..e9f5324 100644 --- a/level_0/f_status/c/status.h +++ b/level_0/f_status/c/status.h @@ -205,6 +205,12 @@ extern "C" { F_write_only, #endif // _di_F_status_basic_ + #ifndef _di_F_status_array_ + F_array, + F_array_too_large, + F_array_too_small, + #endif // _di_F_status_array_ + #ifndef _di_F_status_busy_ F_busy, F_busy_address, diff --git a/level_1/fl_directory/c/private-directory.c b/level_1/fl_directory/c/private-directory.c index 7a76d4b..bc83a84 100644 --- a/level_1/fl_directory/c/private-directory.c +++ b/level_1/fl_directory/c/private-directory.c @@ -158,7 +158,7 @@ extern "C" { const f_status_t status_failure = status; - f_macro_memory_structure_macro_increment(status, (*recurse.failures), 1, f_memory_default_allocation_step, f_macro_directory_statuss_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*recurse.failures), 1, f_memory_default_allocation_step, f_macro_directory_statuss_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; f_directory_status_t failure = f_directory_status_t_initialize; @@ -354,7 +354,7 @@ extern "C" { const f_status_t status_failure = status; - f_macro_memory_structure_macro_increment(status, (*recurse.failures), 1, f_memory_default_allocation_step, f_macro_directory_statuss_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*recurse.failures), 1, f_memory_default_allocation_step, f_macro_directory_statuss_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; f_directory_status_t failure = f_directory_status_t_initialize; diff --git a/level_1/fl_directory/c/private-directory.h b/level_1/fl_directory/c/private-directory.h index 995777d..dab4283 100644 --- a/level_1/fl_directory/c/private-directory.h +++ b/level_1/fl_directory/c/private-directory.h @@ -67,6 +67,7 @@ extern "C" { * * @return * F_none on success. + * F_array_too_large (with error bit) if a buffer would exceed max length. * F_failure (with error bit) for any other failure, failures might be populated with individual status codes. * * @see fl_directory_clone() @@ -124,6 +125,7 @@ extern "C" { * * @return * F_none on success. + * F_array_too_large (with error bit) if a buffer would exceed max length. * F_failure (with error bit) for any other failure, failures might be populated with individual status codes. * * @see fl_directory_copy() diff --git a/level_1/fl_environment/c/environment.c b/level_1/fl_environment/c/environment.c index 25404f1..1670a73 100644 --- a/level_1/fl_environment/c/environment.c +++ b/level_1/fl_environment/c/environment.c @@ -18,7 +18,7 @@ extern "C" { // When PATH is "", this is actually a valid search path for PWD. // Append an equivalent representation of PWD (string used length is 0). - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; f_macro_string_dynamic_t_clear(paths->array[paths->used]); @@ -34,7 +34,7 @@ extern "C" { for (i = 0; i <= length; i++) { if (i == length || path[i] == f_path_separator_variable[0]) { - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; if (!i) { @@ -94,7 +94,7 @@ extern "C" { // When PATH is "", this is actually a valid search path for PWD. // Therefore append an equivalent representation of PWD (string used length is 0). - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; f_macro_string_dynamic_t_clear(paths->array[paths->used]); @@ -113,7 +113,7 @@ extern "C" { for (i = 0; i <= path.used; i++) { if (i == path.used || path.string[i] == f_path_separator_variable[0]) { - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; if (!i) { @@ -173,7 +173,7 @@ extern "C" { // When PATH is "", this is actually a valid search path for PWD. // Therefore append an equivalent representation of PWD (string used length is 0). - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; paths->array[paths->used].string = 0; @@ -195,7 +195,7 @@ extern "C" { j--; if (!j || path[j] == f_path_separator_variable[0]) { - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; if (path[j] == f_path_separator_variable[0]) { @@ -269,7 +269,7 @@ extern "C" { if (!path.used) { // When PATH is "", this is actually a valid search path for PWD. // Therefore append an equivalent representation of PWD (string used length is 0). - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; f_macro_string_dynamic_t_clear(paths->array[paths->used]); @@ -290,7 +290,7 @@ extern "C" { j--; if (!j || path.string[j] == f_path_separator_variable[0]) { - f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*paths), 1, f_memory_default_allocation_step, f_macro_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; if (path.string[j] == f_path_separator_variable[0]) { diff --git a/level_1/fl_environment/c/environment.h b/level_1/fl_environment/c/environment.h index 038781f..e8385e0 100644 --- a/level_1/fl_environment/c/environment.h +++ b/level_1/fl_environment/c/environment.h @@ -40,7 +40,7 @@ extern "C" { * * @return * F_none on success. - * F_buffer_too_large (with error bit) if paths array is too large for further addressing. + * F_array_too_large (with error bit) if paths array is too large for further addressing. * F_memory_reallocation (with error bit) on reallocation error. * F_memory_allocation (with error bit) on allocation error. * F_parameter (with error bit) if a parameter is invalid. @@ -64,7 +64,7 @@ extern "C" { * * @return * F_none on success. - * F_buffer_too_large (with error bit) if paths array is too large for further addressing. + * F_array_too_large (with error bit) if paths array is too large for further addressing. * F_memory_reallocation (with error bit) on reallocation error. * F_memory_allocation (with error bit) on allocation error. * F_parameter (with error bit) if a parameter is invalid. @@ -90,7 +90,7 @@ extern "C" { * * @return * F_none on success. - * F_buffer_too_large (with error bit) if paths array is too large for further addressing. + * F_array_too_large (with error bit) if paths array is too large for further addressing. * F_memory_reallocation (with error bit) on reallocation error. * F_memory_allocation (with error bit) on allocation error. * F_parameter (with error bit) if a parameter is invalid. @@ -116,7 +116,7 @@ extern "C" { * * @return * F_none on success. - * F_buffer_too_large (with error bit) if paths array is too large for further addressing. + * F_array_too_large (with error bit) if paths array is too large for further addressing. * F_memory_reallocation (with error bit) on reallocation error. * F_memory_allocation (with error bit) on allocation error. * F_parameter (with error bit) if a parameter is invalid. diff --git a/level_1/fl_fss/c/fss_basic_list.h b/level_1/fl_fss/c/fss_basic_list.h index 7af77ec..16e3317 100644 --- a/level_1/fl_fss/c/fss_basic_list.h +++ b/level_1/fl_fss/c/fss_basic_list.h @@ -59,7 +59,7 @@ extern "C" { * F_data_not_stop no data found after reaching stopping point (essentially only comments are found). * F_unterminated_group_eos if EOS was reached before the a group termination was reached. * F_unterminated_group_stop if stop point was reached before the a group termination was reached. - * F_buffer_too_large (with error bit) if a buffer is too large. + * F_array_too_large (with error bit) if a buffer is too large. * F_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. @@ -108,7 +108,7 @@ extern "C" { * F_data_not_stop no data found after reaching stopping point (essentially only comments are found). * F_unterminated_group_eos if EOS was reached before the a group termination was reached. * F_unterminated_group_stop if stop point was reached before the a group termination was reached. - * F_buffer_too_large (with error bit) if a buffer is too large. + * F_array_too_large (with error bit) if a buffer is too large. * F_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. diff --git a/level_1/fl_fss/c/fss_extended_list.h b/level_1/fl_fss/c/fss_extended_list.h index d64d668..e5a1358 100644 --- a/level_1/fl_fss/c/fss_extended_list.h +++ b/level_1/fl_fss/c/fss_extended_list.h @@ -59,7 +59,7 @@ extern "C" { * F_data_not_stop no data found after reaching stopping point (essentially only comments are found). * F_unterminated_group_eos if EOS was reached before the a group termination was reached. * F_unterminated_group_stop if stop point was reached before the a group termination was reached. - * F_buffer_too_large (with error bit) if a buffer is too large. + * F_array_too_large (with error bit) if a buffer is too large. * F_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. @@ -112,7 +112,7 @@ extern "C" { * F_data_not_stop no data found after reaching stopping point (essentially only comments are found). * F_unterminated_group_eos if EOS was reached before the a group termination was reached. * F_unterminated_group_stop if stop point was reached before the a group termination was reached. - * F_buffer_too_large (with error bit) if a buffer is too large. + * F_array_too_large (with error bit) if a buffer is too large. * F_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. diff --git a/level_1/fl_fss/c/private-fss.c b/level_1/fl_fss/c/private-fss.c index 2e37d49..56621c0 100644 --- a/level_1/fl_fss/c/private-fss.c +++ b/level_1/fl_fss/c/private-fss.c @@ -1104,7 +1104,7 @@ extern "C" { if (nest->used + 1 > nest->size) { if (nest->size + f_fss_default_allocation_step > f_array_length_t_size) { if (nest->size + 1 > f_array_length_t_size) { - return F_status_set_error(F_buffer_too_large); + return F_status_set_error(F_array_too_large); } f_macro_fss_nest_t_resize(status, (*nest), (nest->size + 1)); @@ -1125,7 +1125,7 @@ extern "C" { if (ranges->used + 1 > ranges->size) { if (ranges->size + f_fss_default_allocation_step > f_array_length_t_size) { if (ranges->size + 1 > f_array_length_t_size) { - return F_status_set_error(F_buffer_too_large); + return F_status_set_error(F_array_too_large); } f_macro_string_ranges_t_resize(status, (*ranges), (ranges->size + 1)); diff --git a/level_1/fl_fss/c/private-fss.h b/level_1/fl_fss/c/private-fss.h index 4a05d56..8840aff 100644 --- a/level_1/fl_fss/c/private-fss.h +++ b/level_1/fl_fss/c/private-fss.h @@ -118,7 +118,7 @@ extern "C" { * F_data_not_stop no data found after reaching stopping point (essentially only comments are found). * F_unterminated_group_eos if EOS was reached before the a group termination was reached. * F_unterminated_group_stop if stop point was reached before the a group termination was reached. - * F_buffer_too_large (with error bit) if a buffer is too large. + * F_array_too_large (with error bit) if a buffer is too large. * F_incomplete_utf (with error bit) is returned on failure to read/process a UTF-8 character due to the character being potentially incomplete. * F_incomplete_utf_eos (with error bit) if the end of buffer is reached before the complete UTF-8 character can be processed. * F_incomplete_utf_stop (with error bit) if the stop location is reached before the complete UTF-8 character can be processed. @@ -196,7 +196,7 @@ extern "C" { * @return * F_none on success. * F_memory_reallocation (with error bit) on reallocation error. - * F_buffer_too_large (with error bit) if appended string length is too large to store in the delimits. + * F_array_too_large (with error bit) if appended string length is too large to store in the delimits. * * @see fl_fss_basic_object_write_string() * @see fl_fss_basic_content_write_string() @@ -222,7 +222,7 @@ extern "C" { * @return * F_none on success. * F_memory_reallocation (with error bit) on reallocation error. - * F_buffer_too_large (with error bit) if increased string length is too large to store in the delimits. + * F_array_too_large (with error bit) if increased string length is too large to store in the delimits. * * @see fl_fss_basic_object_write_string() * @see fl_fss_basic_content_write_string() @@ -321,7 +321,7 @@ extern "C" { * @return * F_none on success. * F_memory_reallocation (with error bit) on reallocation error. - * F_buffer_too_large (with error bit) if increased array length is too large to store in the range. + * F_array_too_large (with error bit) if increased array length is too large to store in the range. * * @see fl_fss_extended_list_object_read() * @see fl_fss_extended_list_content_read() @@ -339,7 +339,7 @@ extern "C" { * @return * F_none on success. * F_memory_reallocation (with error bit) on reallocation error. - * F_buffer_too_large (with error bit) if increased array length is too large to store in the range. + * F_array_too_large (with error bit) if increased array length is too large to store in the range. * * @see fl_fss_basic_object_read() * @see fl_fss_basic_content_read() diff --git a/level_1/fl_status/c/status.c b/level_1/fl_status/c/status.c index f57c3fb..3b2ed64 100644 --- a/level_1/fl_status/c/status.c +++ b/level_1/fl_status/c/status.c @@ -394,6 +394,18 @@ extern "C" { break; #endif // _di_F_status_basic_ + #ifndef _di_F_status_array_ + case F_array: + *string = FL_status_string_array; + break; + case F_array_too_small: + *string = FL_status_string_array_too_small; + break; + case F_array_too_large: + *string = FL_status_string_array_too_large; + break; + #endif // _di_F_status_array_ + #ifndef _di_F_status_busy_ case F_busy: *string = FL_status_string_busy; diff --git a/level_1/fl_status/c/status.h b/level_1/fl_status/c/status.h index 87db26a..a0f5cc4 100644 --- a/level_1/fl_status/c/status.h +++ b/level_1/fl_status/c/status.h @@ -284,6 +284,16 @@ extern "C" { #define FL_status_string_write_only_length 12 #endif // _di_F_status_basic_ + #ifndef _di_F_status_array_ + #define FL_status_string_array "F_array" + #define FL_status_string_array_too_large "F_array_too_large" + #define FL_status_string_array_too_small "F_array_too_small" + + #define FL_status_string_array_length 7 + #define FL_status_string_array_too_large_length 17 + #define FL_status_string_array_too_small_length 17 + #endif // _di_F_status_array_ + #ifndef _di_F_status_busy_ #define FL_status_string_busy "F_busy" #define FL_status_string_busy_address "F_busy_address" diff --git a/level_1/fl_string/c/string.c b/level_1/fl_string/c/string.c index 92bb133..52549fa 100644 --- a/level_1/fl_string/c/string.c +++ b/level_1/fl_string/c/string.c @@ -1336,11 +1336,11 @@ extern "C" { if (strings->size + f_memory_default_allocation_step > f_array_length_t_size) { if (strings->size == f_array_length_t_size) { - return F_status_set_error(F_buffer_too_large); + return F_status_set_error(F_array_too_large); } f_macro_string_dynamics_t_resize(status, (*strings), f_array_length_t_size); - return F_buffer_too_large; + return F_array_too_large; } f_macro_string_dynamics_t_resize(status, (*strings), strings->size + f_memory_default_allocation_step); @@ -1359,11 +1359,11 @@ extern "C" { if (strings->size + amount > f_array_length_t_size) { if (strings->size == f_array_length_t_size) { - return F_status_set_error(F_buffer_too_large); + return F_status_set_error(F_array_too_large); } f_macro_string_dynamics_t_resize(status, (*strings), f_array_length_t_size); - return F_buffer_too_large; + return F_array_too_large; } f_macro_string_dynamics_t_resize(status, (*strings), strings->size + amount); @@ -1420,11 +1420,11 @@ extern "C" { if (lengths->size + f_memory_default_allocation_step > f_array_length_t_size) { if (lengths->size == f_array_length_t_size) { - return F_status_set_error(F_buffer_too_large); + return F_status_set_error(F_array_too_large); } f_macro_string_lengths_t_resize(status, (*lengths), f_array_length_t_size); - return F_buffer_too_large; + return F_array_too_large; } f_macro_string_lengths_t_resize(status, (*lengths), lengths->size + f_memory_default_allocation_step); @@ -1443,11 +1443,11 @@ extern "C" { if (lengths->size + amount > f_array_length_t_size) { if (lengths->size == f_array_length_t_size) { - return F_status_set_error(F_buffer_too_large); + return F_status_set_error(F_array_too_large); } f_macro_string_lengths_t_resize(status, (*lengths), f_array_length_t_size); - return F_buffer_too_large; + return F_array_too_large; } f_macro_string_lengths_t_resize(status, (*lengths), lengths->size + amount); diff --git a/level_1/fl_string/c/string.h b/level_1/fl_string/c/string.h index fdc8ab2..8297320 100644 --- a/level_1/fl_string/c/string.h +++ b/level_1/fl_string/c/string.h @@ -1879,11 +1879,11 @@ extern "C" { * * @return * F_none on success. - * F_buffer_too_large on success, but the requested length is too large for the buffer. + * F_array_too_large on success, but the requested length is too large for the buffer. * F_memory_allocation (with error bit) on memory allocation error. * F_memory_reallocation (with error bit) on memory reallocation error. * F_parameter (with error bit) if a parameter is invalid. - * F_buffer_too_large (with error bit) if the new array length is too large. + * F_array_too_large (with error bit) if the new array length is too large. */ #ifndef _di_fl_string_dynamics_increase_ extern f_return_status fl_string_dynamics_increase(f_string_dynamics_t *strings); @@ -1903,11 +1903,11 @@ extern "C" { * * @return * F_none on success. - * F_buffer_too_large on success, but the requested length is too large for the buffer. + * F_array_too_large on success, but the requested length is too large for the buffer. * F_memory_allocation (with error bit) on memory allocation error. * F_memory_reallocation (with error bit) on memory reallocation error. * F_parameter (with error bit) if a parameter is invalid. - * F_buffer_too_large (with error bit) if the new array length is too large. + * F_array_too_large (with error bit) if the new array length is too large. */ #ifndef _di_fl_string_dynamics_increase_by_ extern f_return_status fl_string_dynamics_increase_by(const f_array_length_t amount, f_string_dynamics_t *strings); @@ -1965,11 +1965,11 @@ extern "C" { * * @return * F_none on success. - * F_buffer_too_large on success, but the requested length is too large for the buffer. + * F_array_too_large on success, but the requested length is too large for the buffer. * F_memory_allocation (with error bit) on memory allocation error. * F_memory_reallocation (with error bit) on memory reallocation error. * F_parameter (with error bit) if a parameter is invalid. - * F_buffer_too_large (with error bit) if the new array length is too large. + * F_array_too_large (with error bit) if the new array length is too large. */ #ifndef _di_fl_string_lengths_increase_ extern f_return_status fl_string_lengths_increase(f_string_lengths_t *lengths); @@ -1989,11 +1989,11 @@ extern "C" { * * @return * F_none on success. - * F_buffer_too_large on success, but the requested length is too large for the buffer. + * F_array_too_large on success, but the requested length is too large for the buffer. * F_memory_allocation (with error bit) on memory allocation error. * F_memory_reallocation (with error bit) on memory reallocation error. * F_parameter (with error bit) if a parameter is invalid. - * F_buffer_too_large (with error bit) if the new array length is too large. + * F_array_too_large (with error bit) if the new array length is too large. */ #ifndef _di_fl_string_lengths_increase_by_ extern f_return_status fl_string_lengths_increase_by(const f_array_length_t amount, f_string_lengths_t *lengths); diff --git a/level_2/fll_error/c/private-error.c b/level_2/fll_error/c/private-error.c index b5d1087..f365fb4 100644 --- a/level_2/fll_error/c/private-error.c +++ b/level_2/fll_error/c/private-error.c @@ -8,6 +8,19 @@ extern "C" { #if !defined(_di_fll_error_print_) || !defined(_di_fll_error_file_print_) || !defined(_di_fll_error_number_print_) f_return_status private_fll_error_print(const fll_error_print_t error, const f_status_t status, const f_string_t function, const bool fallback) { + if (status == F_array_too_large) { + if (error.verbosity != f_console_verbosity_quiet) { + fprintf(error.to.stream, "%c", f_string_eol[0]); + fprintf(error.to.stream, "%s%sMaximum array length reached while processing ", error.context.before->string, error.prefix ? error.prefix : ""); + + private_fll_error_print_function(error, function); + + fprintf(error.to.stream, ".%s%c", error.context.after->string, f_string_eol[0]); + } + + return F_false; + } + if (status == F_buffer_too_large) { if (error.verbosity != f_console_verbosity_quiet) { fprintf(error.to.stream, "%c", f_string_eol[0]); diff --git a/level_2/fll_execute/c/execute.h b/level_2/fll_execute/c/execute.h index 800aa1a..b6dc00b 100644 --- a/level_2/fll_execute/c/execute.h +++ b/level_2/fll_execute/c/execute.h @@ -53,7 +53,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. - * F_buffer_too_large (with error bit) if arguments array is too large for further allocation. + * F_array_too_large (with error bit) if arguments array is too large for further allocation. * F_memory_allocation (with error bit) on allocation error. * F_memory_reallocation (with error bit) on reallocation error. * F_parameter (with error bit) if a parameter is invalid. @@ -94,7 +94,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. - * F_buffer_too_large (with error bit) if arguments array is too large for further allocation. + * F_array_too_large (with error bit) if arguments array is too large for further allocation. * F_memory_allocation (with error bit) on allocation error. * F_memory_reallocation (with error bit) on reallocation error. * F_parameter (with error bit) if a parameter is invalid. @@ -138,7 +138,7 @@ extern "C" { * @return * F_none on success. * F_data_not if size is 0. - * F_buffer_too_large (with error bit) if arguments array is too large for further allocation. + * F_array_too_large (with error bit) if arguments array is too large for further allocation. * F_memory_allocation (with error bit) on allocation error. * F_memory_reallocation (with error bit) on reallocation error. * F_parameter (with error bit) if a parameter is invalid. @@ -168,7 +168,7 @@ extern "C" { * @return * F_none on success. * F_data_not if size is 0. - * F_buffer_too_large (with error bit) if arguments array is too large for further allocation. + * F_array_too_large (with error bit) if arguments array is too large for further allocation. * F_memory_allocation (with error bit) on allocation error. * F_memory_reallocation (with error bit) on reallocation error. * F_parameter (with error bit) if a parameter is invalid. @@ -194,7 +194,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. - * F_buffer_too_large (with error bit) if arguments array is too large for further allocation. + * F_array_too_large (with error bit) if arguments array is too large for further allocation. * F_memory_allocation (with error bit) on allocation error. * F_memory_reallocation (with error bit) on reallocation error. * F_parameter (with error bit) if a parameter is invalid. @@ -230,7 +230,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. - * F_buffer_too_large (with error bit) if arguments array is too large for further allocation. + * F_array_too_large (with error bit) if arguments array is too large for further allocation. * F_memory_allocation (with error bit) on allocation error. * F_memory_reallocation (with error bit) on reallocation error. * F_parameter (with error bit) if a parameter is invalid. @@ -268,7 +268,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. - * F_buffer_too_large (with error bit) if arguments array is too large for further allocation. + * F_array_too_large (with error bit) if arguments array is too large for further allocation. * F_memory_allocation (with error bit) on allocation error. * F_memory_reallocation (with error bit) on reallocation error. * F_parameter (with error bit) if a parameter is invalid. @@ -296,7 +296,7 @@ extern "C" { * @return * F_none on success. * F_data_not if source length is 0. - * F_buffer_too_large (with error bit) if arguments array is too large for further allocation. + * F_array_too_large (with error bit) if arguments array is too large for further allocation. * F_memory_allocation (with error bit) on allocation error. * F_memory_reallocation (with error bit) on reallocation error. * F_parameter (with error bit) if a parameter is invalid. @@ -457,7 +457,7 @@ extern "C" { * @return * F_none on success. * F_access_denied (with error bit) on access denied for program_path. - * F_buffer_too_large (with error bit) if paths array (generated from PATH) is too large for further addressing. + * F_array_too_large (with error bit) if paths array (generated from PATH) is too large for further addressing. * F_directory (with error bit) on invalid directory in program_path. * F_failure (with error bit) if result is non-zero. * F_file_found_not (with error bit) if file does not exist at the program_path. diff --git a/level_2/fll_execute/c/private-execute.c b/level_2/fll_execute/c/private-execute.c index e35b684..aae7076 100644 --- a/level_2/fll_execute/c/private-execute.c +++ b/level_2/fll_execute/c/private-execute.c @@ -11,7 +11,7 @@ extern "C" { if (arguments->used == arguments->size) { if (arguments->size + f_memory_default_allocation_step > f_array_length_t_size) { - if (arguments->size + 1 > f_array_length_t_size) return F_status_set_error(F_buffer_too_large); + if (arguments->size + 1 > f_array_length_t_size) return F_status_set_error(F_array_too_large); f_macro_string_dynamics_t_resize(status, (*arguments), arguments->size + 1); } else { @@ -52,7 +52,7 @@ extern "C" { if (arguments->used + 1 >= arguments->size) { if (arguments->size + f_memory_default_allocation_step > f_array_length_t_size) { - if (arguments->size + 2 > f_array_length_t_size) return F_status_set_error(F_buffer_too_large); + if (arguments->size + 2 > f_array_length_t_size) return F_status_set_error(F_array_too_large); f_macro_string_dynamics_t_resize(status, (*arguments), arguments->size + 2); } else { diff --git a/level_2/fll_execute/c/private-execute.h b/level_2/fll_execute/c/private-execute.h index 9c94702..cf75d09 100644 --- a/level_2/fll_execute/c/private-execute.h +++ b/level_2/fll_execute/c/private-execute.h @@ -45,7 +45,7 @@ extern "C" { * @return * F_none on success. * F_data_not if name_length is 0. - * F_buffer_too_large (with error bit) if arguments array is too large for further allocation. + * F_array_too_large (with error bit) if arguments array is too large for further allocation. * F_memory_allocation (with error bit) on allocation error. * F_memory_reallocation (with error bit) on reallocation error. * F_parameter (with error bit) if a parameter is invalid. @@ -82,7 +82,7 @@ extern "C" { * @return * F_none on success. * F_data_not if name_length is 0. - * F_buffer_too_large (with error bit) if arguments array is too large for further allocation. + * F_array_too_large (with error bit) if arguments array is too large for further allocation. * F_memory_allocation (with error bit) on allocation error. * F_memory_reallocation (with error bit) on reallocation error. * F_parameter (with error bit) if a parameter is invalid. diff --git a/level_2/fll_fss/c/fss.c b/level_2/fll_fss/c/fss.c index d2c15d2..62c9ac1 100644 --- a/level_2/fll_fss/c/fss.c +++ b/level_2/fll_fss/c/fss.c @@ -135,7 +135,7 @@ extern "C" { if (values[j]->used + contents.array[i].used > values[j]->size) { if (values[j]->used + contents.array[i].used > f_array_length_t_size) { - return F_status_set_error(F_buffer_too_large); + return F_status_set_error(F_array_too_large); } f_macro_string_dynamics_t_resize(status, (*value), (values[j]->used + content->used)); @@ -238,7 +238,7 @@ extern "C" { if (values[j]->used + f_fss_default_allocation_step > f_array_length_t_size) { if (values[j]->used == f_array_length_t_size) { f_macro_string_dynamic_t_delete_simple(name); - return F_status_set_error(F_buffer_too_large); + return F_status_set_error(F_array_too_large); } f_macro_string_maps_t_resize(status, (*values[j]), values[j]->used + 1); @@ -335,7 +335,7 @@ extern "C" { if (values[j]->used == values[j]->size) { if (values[j]->used + f_fss_default_allocation_step > f_array_length_t_size) { if (values[j]->used == f_array_length_t_size) { - return F_status_set_error(F_buffer_too_large); + return F_status_set_error(F_array_too_large); } f_macro_string_map_multis_t_resize(status, (*values[j]), values[j]->used + 1); @@ -371,7 +371,7 @@ extern "C" { if (contents.array[i].used > 1) { if (map_multi->value.used + contents.array[i].used - 1 > map_multi->value.size) { - if (map_multi->value.used + contents.array[i].used - 1 > f_array_length_t_size) return F_status_set_error(F_buffer_too_large); + if (map_multi->value.used + contents.array[i].used - 1 > f_array_length_t_size) return F_status_set_error(F_array_too_large); f_macro_string_dynamics_t_resize(status, map_multi->value, map_multi->value.used + contents.array[i].used - 1); if (F_status_is_error(status)) return status; @@ -428,7 +428,7 @@ extern "C" { if (values[j]->used == values[j]->size) { if (values[j]->used + f_fss_default_allocation_step > f_array_length_t_size) { if (values[j]->used == f_array_length_t_size) { - return F_status_set_error(F_buffer_too_large); + return F_status_set_error(F_array_too_large); } f_macro_string_maps_t_resize(status, (*values[j]), values[j]->used + 1); @@ -547,7 +547,7 @@ extern "C" { if (values[j]->used == values[j]->size) { if (values[j]->used + f_fss_default_allocation_step > f_array_length_t_size) { if (values[j]->used == f_array_length_t_size) { - return F_status_set_error(F_buffer_too_large); + return F_status_set_error(F_array_too_large); } f_macro_string_map_multis_t_resize(status, (*values[j]), values[j]->used + 1); @@ -588,7 +588,7 @@ extern "C" { if (map_multi->value.used == map_multi->value.size) { if (map_multi->value.used == f_array_length_t_size) { - return F_status_set_error(F_buffer_too_large); + return F_status_set_error(F_array_too_large); } f_macro_string_dynamics_t_resize(status, map_multi->value, map_multi->value.used + 1); @@ -683,7 +683,7 @@ extern "C" { if (values[j]->used + f_fss_default_allocation_step > f_array_length_t_size) { if (values[j]->used == f_array_length_t_size) { f_macro_string_dynamic_t_delete_simple(name); - return F_status_set_error(F_buffer_too_large); + return F_status_set_error(F_array_too_large); } f_macro_string_maps_t_resize(status, (*values[j]), values[j]->used + 1); @@ -831,7 +831,7 @@ extern "C" { if (values[j]->used == values[j]->size) { if (values[j]->used + f_fss_default_allocation_step > f_array_length_t_size) { if (values[j]->used == f_array_length_t_size) { - return F_status_set_error(F_buffer_too_large); + return F_status_set_error(F_array_too_large); } f_macro_string_dynamics_t_resize(status, (*values[j]), values[j]->used + 1); diff --git a/level_2/fll_program/c/program.c b/level_2/fll_program/c/program.c index 19dc844..ba678f4 100644 --- a/level_2/fll_program/c/program.c +++ b/level_2/fll_program/c/program.c @@ -158,7 +158,7 @@ extern "C" { status = F_none; } else { - f_macro_memory_structure_macro_increment(status, (*destination), 1, f_console_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, (*destination), 1, f_console_default_allocation_step, f_macro_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) break; destination->array[destination->used] = ripped; diff --git a/level_2/fll_program/c/program.h b/level_2/fll_program/c/program.h index 9d8387c..1bebeaf 100644 --- a/level_2/fll_program/c/program.h +++ b/level_2/fll_program/c/program.h @@ -222,7 +222,7 @@ extern "C" { * @return * F_none on success. * F_data_not if nothing to rip, no allocations or reallocations are performed. - * F_buffer_too_large (with error bit) if a buffer would exceed max length. + * F_array_too_large (with error bit) if a buffer would exceed max length. * F_memory_allocation (with error bit) on memory allocation error. * F_memory_reallocation (with error bit) on memory reallocation error. * F_parameter (with error bit) if a parameter is invalid. diff --git a/level_2/fll_status/c/status.c b/level_2/fll_status/c/status.c index 8a5e3c2..d2ffe5f 100644 --- a/level_2/fll_status/c/status.c +++ b/level_2/fll_status/c/status.c @@ -657,6 +657,23 @@ extern "C" { } #endif // _di_F_status_basic_ + #ifndef _di_F_status_array_ + if (fl_string_compare(string, FL_status_string_array, length, FL_status_string_array_length) == F_equal_to) { + *code = F_array; + return F_none; + } + + if (fl_string_compare(string, FL_status_string_array_too_large, length, FL_status_string_array_too_large_length) == F_equal_to) { + *code = F_array_too_large; + return F_none; + } + + if (fl_string_compare(string, FL_status_string_array_too_small, length, FL_status_string_array_too_small_length) == F_equal_to) { + *code = F_array_too_small; + return F_none; + } + #endif // _di_F_status_array_ + #ifndef _di_F_status_busy_ if (fl_string_compare(string, FL_status_string_busy, length, FL_status_string_busy_length) == F_equal_to) { *code = F_busy; diff --git a/level_3/fake/c/private-build.c b/level_3/fake/c/private-build.c index 9ab95e4..03dffc5 100644 --- a/level_3/fake/c/private-build.c +++ b/level_3/fake/c/private-build.c @@ -1214,7 +1214,7 @@ extern "C" { f_macro_string_dynamic_t_delete_simple(part); f_macro_string_dynamics_t_delete_simple(names); - *status = F_status_set_error(F_buffer_too_large); + *status = F_status_set_error(F_array_too_large); return; } @@ -1276,7 +1276,7 @@ extern "C" { if (F_status_is_error_not(*status) && environment->names.used + 1 > environment->names.size) { if (environment->names.size + f_memory_default_allocation_step > f_array_length_t_size) { if (environment->names.size + 1 > f_array_length_t_size) { - *status = F_status_set_error(F_buffer_too_large); + *status = F_status_set_error(F_array_too_large); } else { f_macro_string_dynamics_t_resize(*status, environment->names, environment->names.size + 1); diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index 8b69a28..c33238e 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -3634,8 +3634,8 @@ extern "C" { if (data_make->path.stack.used == data_make->path.stack.size) { *status = fl_string_dynamics_increase_by(f_memory_default_allocation_step, &data_make->path.stack); - if (F_status_set_fine(*status) == F_buffer_too_large) { - fake_print_message_section_operation_path_stack_max(data, data_make->error, F_buffer_too_large, "fl_string_lengths_increase_by", "path stack"); + if (F_status_set_fine(*status) == F_array_too_large) { + fake_print_message_section_operation_path_stack_max(data, data_make->error, F_array_too_large, "fl_string_lengths_increase_by", "path stack"); return; } else if (F_status_is_error(*status)) { diff --git a/level_3/fake/c/private-print.c b/level_3/fake/c/private-print.c index c70121a..ac1dd25 100644 --- a/level_3/fake/c/private-print.c +++ b/level_3/fake/c/private-print.c @@ -345,7 +345,7 @@ extern "C" { void fake_print_message_section_operation_path_stack_max(const fake_data_t data, fll_error_print_t error, const f_status_t status, const f_string_t function, const f_string_t path) { if (data.error.verbosity == f_console_verbosity_quiet || !error.to.stream) return; - if (status == F_buffer_too_large) { + if (status == F_array_too_large) { fprintf(error.to.stream, "%c", f_string_eol[0]); fl_color_print(error.to.stream, data.error.context, "%s: Maximum stack size reached while processing path '", data.error.prefix); fl_color_print(error.to.stream, data.context.set.notable, "%s", path); diff --git a/level_3/fss_extended_write/c/fss_extended_write.c b/level_3/fss_extended_write/c/fss_extended_write.c index c8f65f0..93321fb 100644 --- a/level_3/fss_extended_write/c/fss_extended_write.c +++ b/level_3/fss_extended_write/c/fss_extended_write.c @@ -428,7 +428,7 @@ extern "C" { status = fl_string_dynamics_increase_by(data->parameters[fss_extended_write_parameter_content].values.used, &contents); - if (status == F_buffer_too_large) { + if (status == F_array_too_large) { status = F_status_set_error(status); } diff --git a/level_3/iki_read/c/private-iki_read.c b/level_3/iki_read/c/private-iki_read.c index ce9fc00..c78bf6e 100644 --- a/level_3/iki_read/c/private-iki_read.c +++ b/level_3/iki_read/c/private-iki_read.c @@ -279,7 +279,7 @@ extern "C" { } // for if (name_missed) { - f_macro_memory_structure_macro_increment(status, names, 1, f_iki_default_allocation_step, f_macro_string_dynamics_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, names, 1, f_iki_default_allocation_step, f_macro_string_dynamics_t_resize, F_array_too_large); if (F_status_is_error(status)) { fll_error_print(data->error, F_status_set_fine(status), "iki_read_process_buffer_ranges_whole", F_true); @@ -488,7 +488,7 @@ extern "C" { status = fl_string_compare(arguments.argv[index], data->buffer.string + vocabulary->array[j].start, length, (vocabulary->array[j].stop - vocabulary->array[j].start) + 1); if (status == F_equal_to) { - f_macro_memory_structure_macro_increment(status, substitutionss[j], 1, f_iki_default_allocation_step, macro_iki_read_substitutions_t_resize, F_buffer_too_large); + f_macro_memory_structure_macro_increment(status, substitutionss[j], 1, f_iki_default_allocation_step, macro_iki_read_substitutions_t_resize, F_array_too_large); if (F_status_is_error(status)) return status; index = parameter->values.array[i + 1]; -- 1.8.3.1