From: Kevin Day Date: Tue, 21 Jun 2022 00:26:53 +0000 (-0500) Subject: Update: The f_utf project regarding digits and perform other clean ups follow up. X-Git-Tag: 0.5.10~29 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=acfa8d7f23c2d8fc8b26793a18789e8c9e28b147;p=fll Update: The f_utf project regarding digits and perform other clean ups follow up. I had not gotten around to testing the programs after the previous commit. I did not get to writing the function f_utf_is_alphabetic_digit() (and then forgot about this important part). The controller program is using f_utf_is_alphabetic_decimal(). The previous functionality of that function is now handled by f_utf_is_alphabetic_digit(). --- diff --git a/level_0/f_utf/c/utf/is.c b/level_0/f_utf/c/utf/is.c index f65749a..8239e44 100644 --- a/level_0/f_utf/c/utf/is.c +++ b/level_0/f_utf/c/utf/is.c @@ -97,6 +97,37 @@ extern "C" { } #endif // _di_f_utf_is_alphabetic_decimal_ +#ifndef _di_f_utf_is_alphabetic_digit_ + f_status_t f_utf_is_alphabetic_digit(const f_string_t sequence, const f_array_length_t width_max) { + #ifndef _di_level_0_parameter_checking_ + if (width_max < 1) return F_status_set_error(F_parameter); + #endif // _di_level_0_parameter_checking_ + + if (macro_f_utf_byte_width_is(*sequence)) { + if (macro_f_utf_byte_width_is(*sequence) > width_max) { + return F_status_set_error(F_complete_not_utf); + } + + if (macro_f_utf_byte_width_is(*sequence) == 1) { + return F_status_set_error(F_utf_fragment); + } + + f_utf_char_t utf = 0; + + { + const f_status_t status = private_f_utf_char_to_character(sequence, width_max, &utf); + if (F_status_is_error(status)) return status; + } + + return private_f_utf_character_is_alphabetic_digit(utf); + } + + if (isalnum(*sequence)) return F_true; + + return F_false; + } +#endif // _di_f_utf_is_alphabetic_digit_ + #ifndef _di_f_utf_is_alphabetic_numeric_ f_status_t f_utf_is_alphabetic_numeric(const f_string_t sequence, const f_array_length_t width_max) { #ifndef _di_level_0_parameter_checking_ diff --git a/level_0/f_utf/c/utf/is.h b/level_0/f_utf/c/utf/is.h index ca6c9b9..3c85099 100644 --- a/level_0/f_utf/c/utf/is.h +++ b/level_0/f_utf/c/utf/is.h @@ -102,7 +102,8 @@ extern "C" { * F_utf_fragment (with error bit) if character is a UTF-8 fragment. * F_utf_not (with error bit) if Unicode is an invalid Unicode character. * - * @see isalnum() + * @see isalpha() + * @see isdigit() */ #ifndef _di_f_utf_is_alphabetic_decimal_ extern f_status_t f_utf_is_alphabetic_decimal(const f_string_t sequence, const f_array_length_t width_max, uint32_t * const value); @@ -151,8 +152,7 @@ extern "C" { * F_utf_fragment (with error bit) if character is a UTF-8 fragment. * F_utf_not (with error bit) if Unicode is an invalid Unicode character. * - * @see isalpha() - * @see isdigit() + * @see isalnum() */ #ifndef _di_f_utf_is_alphabetic_numeric_ extern f_status_t f_utf_is_alphabetic_numeric(const f_string_t sequence, const f_array_length_t width_max); diff --git a/level_3/controller/c/controller/private-controller.c b/level_3/controller/c/controller/private-controller.c index ce50b9a..36be1b1 100644 --- a/level_3/controller/c/controller/private-controller.c +++ b/level_3/controller/c/controller/private-controller.c @@ -786,7 +786,7 @@ extern "C" { if (name.string[i] == '_') continue; - status = f_utf_is_alphabetic_decimal(name.string, name.used); + status = f_utf_is_alphabetic_digit(name.string, name.used); if (F_status_is_error(status)) return status; if (status == F_false) return F_false;