From dbd2b85a7172e07cd8567184f6ffb999d7e39b5e Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 25 Apr 2020 12:15:04 -0500 Subject: [PATCH] Cleanup: refactor max_width to width_max Use the newer naming practices. These kinds of changes will be performed as I notice them. --- level_0/f_console/c/console.c | 8 ++--- level_0/f_utf/c/utf.c | 56 ++++++++++++++++----------------- level_0/f_utf/c/utf.h | 60 ++++++++++++++++++------------------ level_1/fl_string/c/string.c | 72 +++++++++++++++++++++---------------------- 4 files changed, 98 insertions(+), 98 deletions(-) diff --git a/level_0/f_console/c/console.c b/level_0/f_console/c/console.c index 88f8283..41d6a02 100644 --- a/level_0/f_console/c/console.c +++ b/level_0/f_console/c/console.c @@ -156,18 +156,18 @@ extern "C" { f_utf_character character_argument_utf = 0; f_utf_character character_console_utf = 0; - unsigned short max_width = string_length - sub_location; + unsigned short width_max = string_length - sub_location; - status = f_utf_char_to_character(arguments.argv[location] + sub_location, max_width, &character_argument_utf); + status = f_utf_char_to_character(arguments.argv[location] + sub_location, width_max, &character_argument_utf); if (status != f_none) { f_macro_string_lengths_delete_simple(needs_additional); return status; } - max_width = strlen(parameters.parameter[parameter_counter].symbol_short); + width_max = strlen(parameters.parameter[parameter_counter].symbol_short); - status = f_utf_char_to_character((f_string) parameters.parameter[parameter_counter].symbol_short, max_width, &character_console_utf); + status = f_utf_char_to_character((f_string) parameters.parameter[parameter_counter].symbol_short, width_max, &character_console_utf); if (status != f_none) { f_macro_string_lengths_delete_simple(needs_additional); diff --git a/level_0/f_utf/c/utf.c b/level_0/f_utf/c/utf.c index e9f050e..bf2583e 100644 --- a/level_0/f_utf/c/utf.c +++ b/level_0/f_utf/c/utf.c @@ -2566,34 +2566,34 @@ extern "C" { #endif // _di_f_utf_character_is_zero_width_ #ifndef _di_f_utf_character_to_char_ - f_return_status f_utf_character_to_char(const f_utf_character utf_character, f_string *character, uint8_t *max_width) { + f_return_status f_utf_character_to_char(const f_utf_character utf_character, f_string *character, uint8_t *width_max) { #ifndef _di_level_0_parameter_checking_ if (utf_character == 0) return f_status_set_error(f_invalid_parameter); - if (max_width == 0 && *character != 0) return f_status_set_error(f_invalid_parameter); - if (max_width != 0 && *character == 0) return f_status_set_error(f_invalid_parameter); - if (max_width != 0 && *max_width > 4) return f_status_set_error(f_invalid_parameter); + if (width_max == 0 && *character != 0) return f_status_set_error(f_invalid_parameter); + if (width_max != 0 && *character == 0) return f_status_set_error(f_invalid_parameter); + if (width_max != 0 && *width_max > 4) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ f_status status = f_none; unsigned short width = f_macro_utf_character_width_is(utf_character); - if (max_width == 0) { + if (width_max == 0) { f_macro_string_new(status, *character, width); if (f_status_is_error(status)) return status; width = 1; - *max_width = 1; + *width_max = 1; } else if (width == 1) { return f_status_is_error(f_invalid_utf); } - else if (width > *max_width) { + else if (width > *width_max) { return f_status_set_error(f_failure); } - *max_width = width; + *width_max = width; if (f_utf_is_big_endian()) { memcpy(*character, &utf_character, width); @@ -2635,9 +2635,9 @@ extern "C" { #endif // _di_f_utf_is_big_endian_ #ifndef _di_f_utf_is_ - f_return_status f_utf_is(const f_string character, const uint8_t max_width) { + f_return_status f_utf_is(const f_string character, const uint8_t width_max) { #ifndef _di_level_0_parameter_checking_ - if (max_width < 1) return f_status_set_error(f_invalid_parameter); + if (width_max < 1) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ uint8_t width = f_macro_utf_byte_width_is(*character); @@ -2655,9 +2655,9 @@ extern "C" { #endif // _di_f_utf_is_ #ifndef _di_f_utf_is_control_ - f_return_status f_utf_is_control(const f_string character, const uint8_t max_width) { + f_return_status f_utf_is_control(const f_string character, const uint8_t width_max) { #ifndef _di_level_0_parameter_checking_ - if (max_width < 1) return f_status_set_error(f_invalid_parameter); + if (width_max < 1) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ uint8_t width = f_macro_utf_byte_width_is(*character); @@ -2677,7 +2677,7 @@ extern "C" { f_utf_character character_utf = 0; f_status status = 0; - status = f_utf_char_to_character(character, max_width, &character_utf); + status = f_utf_char_to_character(character, width_max, &character_utf); if (status != f_none) return status; @@ -2686,9 +2686,9 @@ extern "C" { #endif // _di_f_utf_is_control_ #ifndef _di_f_utf_is_control_picture_ - f_return_status f_utf_is_control_picture(const f_string character, const uint8_t max_width) { + f_return_status f_utf_is_control_picture(const f_string character, const uint8_t width_max) { #ifndef _di_level_0_parameter_checking_ - if (max_width < 1) return f_status_set_error(f_invalid_parameter); + if (width_max < 1) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ uint8_t width = f_macro_utf_byte_width_is(*character); @@ -2705,7 +2705,7 @@ extern "C" { f_utf_character character_utf = 0; f_status status = 0; - status = f_utf_char_to_character(character, max_width, &character_utf); + status = f_utf_char_to_character(character, width_max, &character_utf); if (status != f_none) return status; @@ -2714,9 +2714,9 @@ extern "C" { #endif // _di_f_utf_is_control_picture_ #ifndef _di_f_utf_is_graph_ - f_return_status f_utf_is_graph(const f_string character, const uint8_t max_width) { + f_return_status f_utf_is_graph(const f_string character, const uint8_t width_max) { #ifndef _di_level_0_parameter_checking_ - if (max_width < 1) return f_status_set_error(f_invalid_parameter); + if (width_max < 1) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ uint8_t width = f_macro_utf_byte_width_is(*character); @@ -2736,7 +2736,7 @@ extern "C" { f_utf_character character_utf = 0; f_status status = 0; - status = f_utf_char_to_character(character, max_width, &character_utf); + status = f_utf_char_to_character(character, width_max, &character_utf); if (status != f_none) return status; @@ -2745,9 +2745,9 @@ extern "C" { #endif // _di_f_utf_is_graph_ #ifndef _di_f_utf_is_whitespace_ - f_return_status f_utf_is_whitespace(const f_string character, const uint8_t max_width) { + f_return_status f_utf_is_whitespace(const f_string character, const uint8_t width_max) { #ifndef _di_level_0_parameter_checking_ - if (max_width < 1) return f_status_set_error(f_invalid_parameter); + if (width_max < 1) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ uint8_t width = f_macro_utf_byte_width_is(*character); @@ -2767,7 +2767,7 @@ extern "C" { f_utf_character character_utf = 0; f_status status = 0; - status = f_utf_char_to_character(character, max_width, &character_utf); + status = f_utf_char_to_character(character, width_max, &character_utf); if (status != f_none) return status; @@ -2776,9 +2776,9 @@ extern "C" { #endif // _di_f_utf_is_whitespace_ #ifndef _di_f_utf_is_zero_width_ - f_return_status f_utf_is_zero_width(const f_string character, const uint8_t max_width) { + f_return_status f_utf_is_zero_width(const f_string character, const uint8_t width_max) { #ifndef _di_level_0_parameter_checking_ - if (max_width < 1) return f_status_set_error(f_invalid_parameter); + if (width_max < 1) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ uint8_t width = f_macro_utf_byte_width_is(*character); @@ -2798,7 +2798,7 @@ extern "C" { f_utf_character character_utf = 0; f_status status = 0; - status = f_utf_char_to_character(character, max_width, &character_utf); + status = f_utf_char_to_character(character, width_max, &character_utf); if (status != f_none) return status; @@ -2807,9 +2807,9 @@ extern "C" { #endif // _di_f_utf_is_zero_width_ #ifndef _di_f_utf_char_to_character_ - f_return_status f_utf_char_to_character(const f_string character, const uint8_t max_width, f_utf_character *character_utf) { + f_return_status f_utf_char_to_character(const f_string character, const uint8_t width_max, f_utf_character *character_utf) { #ifndef _di_level_0_parameter_checking_ - if (max_width < 1) return f_status_set_error(f_invalid_parameter); + if (width_max < 1) return f_status_set_error(f_invalid_parameter); if (character_utf == 0) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ @@ -2823,7 +2823,7 @@ extern "C" { return f_status_is_error(f_invalid_utf); } - if (width > max_width) { + if (width > width_max) { return f_status_set_error(f_failure); } diff --git a/level_0/f_utf/c/utf.h b/level_0/f_utf/c/utf.h index 78115a8..16829e9 100644 --- a/level_0/f_utf/c/utf.h +++ b/level_0/f_utf/c/utf.h @@ -672,8 +672,8 @@ extern "C" { * The UTF-8 characterr to convert from. * @param character * A int8_t representation of the UTF-8 character, stored as a string of width bytes. - * If max_width is 0, then this should not be allocated (set the pointer address to 0). - * @param max_width + * If width_max is 0, then this should not be allocated (set the pointer address to 0). + * @param width_max * The number of bytes the generated character represents. * If this is set to 0, then the character will be allocated and this will be set to the width of the utf_character. * If this is set to some value greater than 0 (up to 4), then this represents the size of the character array (no allocations are performed). @@ -688,7 +688,7 @@ extern "C" { * f_failure (with error bit) if width is not long enough to convert. */ #ifndef _di_f_utf_character_to_char_ - extern f_return_status f_utf_character_to_char(const f_utf_character utf_character, f_string *character, uint8_t *max_width); + extern f_return_status f_utf_character_to_char(const f_utf_character utf_character, f_string *character, uint8_t *width_max); #endif // _di_f_utf_character_to_char_ /** @@ -711,8 +711,8 @@ extern "C" { * * @param character * The character to validate. - * There must be enough space allocated to compare against, as limited by max_width. - * @param max_width + * There must be enough space allocated to compare against, as limited by width_max. + * @param width_max * The maximum width available for checking. * Can be anything greater than 0. * @@ -726,7 +726,7 @@ extern "C" { * @see f_utf_character_is() */ #ifndef _di_f_utf_is_ - extern f_return_status f_utf_is(const f_string character, const uint8_t max_width); + extern f_return_status f_utf_is(const f_string character, const uint8_t width_max); #endif // _di_f_utf_is_ /** @@ -734,8 +734,8 @@ extern "C" { * * @param character * The character to validate. - * There must be enough space allocated to compare against, as limited by max_width. - * @param max_width + * There must be enough space allocated to compare against, as limited by width_max. + * @param width_max * The maximum width available for checking. * Can be anything greater than 0. * @@ -748,7 +748,7 @@ extern "C" { * @see f_utf_character_is_control() */ #ifndef _di_f_utf_is_control_ - extern f_return_status f_utf_is_control(const f_string character, const uint8_t max_width); + extern f_return_status f_utf_is_control(const f_string character, const uint8_t width_max); #endif // _di_f_utf_is_control_ /** @@ -758,8 +758,8 @@ extern "C" { * * @param character * The character to validate. - * There must be enough space allocated to compare against, as limited by max_width. - * @param max_width + * There must be enough space allocated to compare against, as limited by width_max. + * @param width_max * The maximum width available for checking. * Can be anything greater than 0. * @@ -771,7 +771,7 @@ extern "C" { * @see f_utf_character_is_control_picture() */ #ifndef _di_f_utf_is_control_picture_ - extern f_return_status f_utf_is_control_picture(const f_string character, const uint8_t max_width); + extern f_return_status f_utf_is_control_picture(const f_string character, const uint8_t width_max); #endif // _di_f_utf_is_control_picture_ /** @@ -795,8 +795,8 @@ extern "C" { * * @param character * The character to validate. - * There must be enough space allocated to compare against, as limited by max_width. - * @param max_width + * There must be enough space allocated to compare against, as limited by width_max. + * @param width_max * The maximum width available for checking. * Can be anything greater than 0. * @@ -809,7 +809,7 @@ extern "C" { * @see f_utf_character_is_fragment() */ #ifndef _di_f_utf_is_fragment_ - extern f_return_status f_utf_is_fragment(const f_string character, const uint8_t max_width); + extern f_return_status f_utf_is_fragment(const f_string character, const uint8_t width_max); #endif // _di_f_utf_is_fragment_ /** @@ -817,8 +817,8 @@ extern "C" { * * @param character * The character to validate. - * There must be enough space allocated to compare against, as limited by max_width. - * @param max_width + * There must be enough space allocated to compare against, as limited by width_max. + * @param width_max * The maximum width available for checking. * Can be anything greater than 0. * @@ -834,7 +834,7 @@ extern "C" { * @see f_utf_character_is_graph() */ #ifndef _di_f_utf_is_graph_ - extern f_return_status f_utf_is_graph(const f_string character, const uint8_t max_width); + extern f_return_status f_utf_is_graph(const f_string character, const uint8_t width_max); #endif // _di_f_utf_is_graph_ /** @@ -848,8 +848,8 @@ extern "C" { * * @param character * The character to validate. - * There must be enough space allocated to compare against, as limited by max_width. - * @param max_width + * There must be enough space allocated to compare against, as limited by width_max. + * @param width_max * The maximum width available for checking. * Can be anything greater than 0. * @@ -864,7 +864,7 @@ extern "C" { * @see f_utf_character_is_valid() */ #ifndef _di_f_utf_is_valid_ - extern f_return_status f_utf_is_valid(const f_string character, const uint8_t max_width); + extern f_return_status f_utf_is_valid(const f_string character, const uint8_t width_max); #endif // _di_f_utf_is_valid_ /** @@ -872,8 +872,8 @@ extern "C" { * * @param character * The character to validate. - * There must be enough space allocated to compare against, as limited by max_width. - * @param max_width + * There must be enough space allocated to compare against, as limited by width_max. + * @param width_max * The maximum width available for checking. * Can be anything greater than 0. * @@ -889,7 +889,7 @@ extern "C" { * @see f_utf_character_is_whitespace() */ #ifndef _di_f_utf_is_whitespace_ - extern f_return_status f_utf_is_whitespace(const f_string character, const uint8_t max_width); + extern f_return_status f_utf_is_whitespace(const f_string character, const uint8_t width_max); #endif // _di_f_utf_is_whitespace_ /** @@ -899,8 +899,8 @@ extern "C" { * * @param character * The character to validate. - * There must be enough space allocated to compare against, as limited by max_width. - * @param max_width + * There must be enough space allocated to compare against, as limited by width_max. + * @param width_max * The maximum width available for checking. * Can be anything greater than 0. * @@ -916,7 +916,7 @@ extern "C" { * @see f_utf_character_is_zero_width() */ #ifndef _di_f_utf_is_zero_width_ - extern f_return_status f_utf_is_zero_width(const f_string character, const uint8_t max_width); + extern f_return_status f_utf_is_zero_width(const f_string character, const uint8_t width_max); #endif // _di_f_utf_is_zero_width_ /** @@ -924,8 +924,8 @@ extern "C" { * * @param character * The character string to be converted to the f_utf_character type. - * There must be enough space allocated to convert against, as limited by max_width. - * @param max_width + * There must be enough space allocated to convert against, as limited by width_max. + * @param width_max * The maximum width available for converting. * Can be anything greater than 0. * @param character_utf @@ -939,7 +939,7 @@ extern "C" { * f_invalid_parameter (with error bit) if a parameter is invalid. */ #ifndef _di_f_utf_char_to_character_ - extern f_return_status f_utf_char_to_character(const f_string character, const uint8_t max_width, f_utf_character *character_utf); + extern f_return_status f_utf_char_to_character(const f_string character, const uint8_t width_max, f_utf_character *character_utf); #endif // _di_f_utf_char_to_character_ #ifdef __cplusplus diff --git a/level_1/fl_string/c/string.c b/level_1/fl_string/c/string.c index 4979046..2b87b86 100644 --- a/level_1/fl_string/c/string.c +++ b/level_1/fl_string/c/string.c @@ -152,13 +152,13 @@ extern "C" { unsigned short width = 0; - f_string_length max_width = 0; + f_string_length width_max = 0; while (location->start < buffer.used) { - max_width = (location->stop - location->start) + 1; + width_max = (location->stop - location->start) + 1; - if (max_width > buffer.used - location->start) { - max_width = buffer.used - location->start; + if (width_max > buffer.used - location->start) { + width_max = buffer.used - location->start; } width = f_macro_utf_byte_width_is(buffer.string[location->start]); @@ -182,7 +182,7 @@ extern "C" { if (width == seek_width) { f_utf_character character = 0; - status = f_utf_char_to_character(buffer.string + location->start, max_width, &character); + status = f_utf_char_to_character(buffer.string + location->start, width_max, &character); if (f_status_is_error(status)) { return status; @@ -217,13 +217,13 @@ extern "C" { f_status status = f_none; unsigned short width = 0; - f_string_length max_width = (location->stop - location->start) + 1; + f_string_length width_max = (location->stop - location->start) + 1; - if (max_width > buffer.used - location->start) { - max_width = buffer.used - location->start; + if (width_max > buffer.used - location->start) { + width_max = buffer.used - location->start; } - while (buffer.string[location->start] == placeholder || (status = f_utf_is_graph(buffer.string + location->start, max_width)) == f_false) { + while (buffer.string[location->start] == placeholder || (status = f_utf_is_graph(buffer.string + location->start, width_max)) == f_false) { if (f_status_is_error(status)) { return status; } @@ -249,10 +249,10 @@ extern "C" { if (location->start >= buffer.used) return f_none_on_eos; if (location->start > location->stop) return f_none_on_stop; - max_width = (location->stop - location->start) + 1; + width_max = (location->stop - location->start) + 1; - if (max_width > buffer.used - location->start) { - max_width = buffer.used - location->start; + if (width_max > buffer.used - location->start) { + width_max = buffer.used - location->start; } } // while @@ -278,13 +278,13 @@ extern "C" { f_status status = f_none; unsigned short width = 0; - f_string_length max_width = (location->stop - location->start) + 1; + f_string_length width_max = (location->stop - location->start) + 1; - if (max_width > buffer.used - location->start) { - max_width = buffer.used - location->start; + if (width_max > buffer.used - location->start) { + width_max = buffer.used - location->start; } - while (buffer.string[location->start] == placeholder || (status = f_utf_is_whitespace(buffer.string + location->start, max_width)) == f_false) { + while (buffer.string[location->start] == placeholder || (status = f_utf_is_whitespace(buffer.string + location->start, width_max)) == f_false) { if (f_status_is_error(status)) { return status; } @@ -310,10 +310,10 @@ extern "C" { if (location->start >= buffer.used) return f_none_on_eos; if (location->start > location->stop) return f_none_on_stop; - max_width = (location->stop - location->start) + 1; + width_max = (location->stop - location->start) + 1; - if (max_width > buffer.used - location->start) { - max_width = buffer.used - location->start; + if (width_max > buffer.used - location->start) { + width_max = buffer.used - location->start; } } // while @@ -364,13 +364,13 @@ extern "C" { unsigned short width = 0; - f_string_length max_width = 0; + f_string_length width_max = 0; while (location->start < buffer.used) { - max_width = (location->stop - location->start) + 1; + width_max = (location->stop - location->start) + 1; - if (max_width > buffer.used - location->start) { - max_width = buffer.used - location->start; + if (width_max > buffer.used - location->start) { + width_max = buffer.used - location->start; } width = f_macro_utf_byte_width_is(buffer.string[location->start]); @@ -392,7 +392,7 @@ extern "C" { if (width == seek_width) { f_utf_character character = 0; - status = f_utf_char_to_character(buffer.string + location->start, max_width, &character); + status = f_utf_char_to_character(buffer.string + location->start, width_max, &character); if (f_status_is_error(status)) { return status; @@ -467,10 +467,10 @@ extern "C" { unsigned short width = 0; - f_string_length max_width = (location->stop - location->start) + 1; + f_string_length width_max = (location->stop - location->start) + 1; for (; location->start <= location->stop; location->start += width) { - max_width = (location->stop - location->start) + 1; + width_max = (location->stop - location->start) + 1; width = f_macro_utf_byte_width_is(string[location->start]); @@ -492,7 +492,7 @@ extern "C" { if (width == seek_width) { f_utf_character character = 0; - status = f_utf_char_to_character(string + location->start, max_width, &character); + status = f_utf_char_to_character(string + location->start, width_max, &character); if (f_status_is_error(status)) { return status; @@ -520,9 +520,9 @@ extern "C" { f_status status = f_none; unsigned short width = 0; - f_string_length max_width = (location->stop - location->start) + 1; + f_string_length width_max = (location->stop - location->start) + 1; - while (string[location->start] == placeholder || (status = f_utf_is_graph(string + location->start, max_width)) == f_false) { + while (string[location->start] == placeholder || (status = f_utf_is_graph(string + location->start, width_max)) == f_false) { if (f_status_is_error(status)) { return status; } @@ -546,7 +546,7 @@ extern "C" { if (location->start > location->stop) return f_none_on_stop; - max_width = (location->stop - location->start) + 1; + width_max = (location->stop - location->start) + 1; } // while if (f_status_is_error(status)) { @@ -568,9 +568,9 @@ extern "C" { f_status status = f_none; unsigned short width = 0; - f_string_length max_width = (location->stop - location->start) + 1; + f_string_length width_max = (location->stop - location->start) + 1; - while (string[location->start] == placeholder || (status = f_utf_is_whitespace(string + location->start, max_width)) == f_false) { + while (string[location->start] == placeholder || (status = f_utf_is_whitespace(string + location->start, width_max)) == f_false) { if (f_status_is_error(status)) { return status; } @@ -594,7 +594,7 @@ extern "C" { if (location->start > location->stop) return f_none_on_stop; - max_width = (location->stop - location->start) + 1; + width_max = (location->stop - location->start) + 1; } // while if (f_status_is_error(status)) { @@ -637,10 +637,10 @@ extern "C" { unsigned short width = 0; - f_string_length max_width = 0; + f_string_length width_max = 0; for (; location->start <= location->stop; location->start += width) { - max_width = (location->stop - location->start) + 1; + width_max = (location->stop - location->start) + 1; width = f_macro_utf_byte_width_is(string[location->start]); @@ -660,7 +660,7 @@ extern "C" { if (width == seek_width) { f_utf_character character = 0; - status = f_utf_char_to_character(string + location->start, max_width, &character); + status = f_utf_char_to_character(string + location->start, width_max, &character); if (f_status_is_error(status)) { return status; -- 1.8.3.1