From: Kevin Day Date: Sun, 4 Aug 2024 00:40:49 +0000 (-0500) Subject: Update: Optimize away the isdigit(), isalpha(), isalnum(), and isxdigit(). X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=50788517d37ece42f32f6906078d2d59330ec3c9;p=fll Update: Optimize away the isdigit(), isalpha(), isalnum(), and isxdigit(). I did some research and learned that the "is*()" functions can greatly affect performance due to locale and other manners. I originally used these to allow for well established optimization to take place. Replace these with some mathematical operations that should increase performance. This also means no function call on the stack. This project is already function stack heavy by design and so reducing functions when easy is a great thing. Start using literal characters rather than the standard strings for the UTF related functions. In these cases the ASCII expectation is guaranteed. The ability to override these is also not practical as the meaning should not change. I have not looked at all of the "is*()" functions and I may address any remaining ones at a later time. I potentially may also investigate mapping tables to further improve performance. These math calculations can be used in a lot of the non-ASCII UTF ranges as well. I opted to not do these just yet given that such work will take a large amount of time. I have not done any performance analysis yet but I plan to do so. --- diff --git a/level_0/f_network/c/network.c b/level_0/f_network/c/network.c index 9a6585f..7471e8c 100644 --- a/level_0/f_network/c/network.c +++ b/level_0/f_network/c/network.c @@ -137,7 +137,7 @@ extern "C" { if (!address.string[i]) continue; - if (isxdigit(address.string[i])) { + if ((uint16_t) (address.string[i] - 'a') < 6 || (uint16_t) (address.string[i] - 'A') < 6 || (uint16_t) (address.string[i] - '0') < 10) { if (address.string[i] < f_string_ascii_0_s.string[0] || address.string[i] > f_string_ascii_9_s.string[0]) { flag = 0x1; } @@ -243,7 +243,7 @@ extern "C" { if (!address.string[i]) continue; - if (isxdigit(address.string[i])) { + if ((uint16_t) (address.string[i] - 'a') < 6 || (uint16_t) (address.string[i] - 'A') < 6 || (uint16_t) (address.string[i] - '0') < 10) { if (++count > 4) return; if (flag & 0x4) { @@ -293,7 +293,7 @@ extern "C" { } // Colons must be followed by a hexidecimal digit. - if (!isxdigit(address.string[at.start_2])) return; + if (!((uint16_t) (address.string[at.start_2] - 'a') < 6 || (uint16_t) (address.string[at.start_2] - 'A') < 6 || (uint16_t) (address.string[at.start_2] - '0') < 10)) return; // When double-colons lead, then set the start position at this digit. if (!count && !set) { @@ -373,7 +373,7 @@ extern "C" { } if (!address.string[at.stop_2]) continue; - if (!isdigit(address.string[at.stop_2])) return; + if ((uint16_t) (address.string[at.stop_2] - '0') < 10) return; } // for // The double colon either must exist when set is smaller than 7 or the double colon must not exist at all. @@ -458,7 +458,7 @@ extern "C" { if (!address.string[i]) continue; - if (isdigit(address.string[i])) { + if ((uint16_t) (address.string[i] - '0') < 10) { if (flag & 0x4) { if (!(flag & 0x8) && ++count > 3) return; diff --git a/level_0/f_parse/c/parse.c b/level_0/f_parse/c/parse.c index 84308d1..94f9a8c 100644 --- a/level_0/f_parse/c/parse.c +++ b/level_0/f_parse/c/parse.c @@ -322,7 +322,7 @@ extern "C" { range->start += macro_f_utf_byte_width(buffer.string[range->start]); } // for - if (range->start > range->stop || range->start >= buffer.used || buffer.string[range->start] != f_string_ascii_minus_s.string[0]) { + if (range->start > range->stop || range->start >= buffer.used || buffer.string[range->start] != '-') { // Increment until stop, while taking into consideration UTF-8 character widths. for (; range->start <= range->stop && range->start < buffer.used; ) { @@ -367,7 +367,7 @@ extern "C" { return F_found_not; } - if (isxdigit(buffer.string[range->start])) { + if ((uint16_t) (buffer.string[range->start] - 'a') < 6 || (uint16_t) (buffer.string[range->start] - 'A') < 6 || (uint16_t) (buffer.string[range->start] - '0') < 10) { number[j] = buffer.string[range->start]; } else { @@ -451,7 +451,7 @@ extern "C" { for (f_number_unsigned_t j = i, i = 0; j <= range->stop && j < buffer.used; ++j) { if (!buffer.string[j]) continue; - if (buffer.string[j] == f_string_ascii_minus_s.string[0]) break; + if (buffer.string[j] == '-') break; id->name[i++] = buffer.string[j]; } // for diff --git a/level_0/f_parse/c/parse.h b/level_0/f_parse/c/parse.h index 96ad06b..90ea74c 100644 --- a/level_0/f_parse/c/parse.h +++ b/level_0/f_parse/c/parse.h @@ -207,8 +207,6 @@ extern "C" { * F_parameter (with error bit) from: f_utf_is_whitespace(). * F_parameter (with error bit) from: f_utf_is_word(). * - * @see isxdigit() - * * @see f_utf_is_combining() * @see f_utf_is_whitespace() * @see f_utf_is_word() diff --git a/level_0/f_utf/c/private-utf_digit.c b/level_0/f_utf/c/private-utf_digit.c index f3a8717..b9d8875 100644 --- a/level_0/f_utf/c/private-utf_digit.c +++ b/level_0/f_utf/c/private-utf_digit.c @@ -6266,59 +6266,25 @@ extern "C" { #if !defined(_di_f_utf_character_is_alphabetic_digit_) || !defined(_di_f_utf_character_is_digit_) || !defined(_di_f_utf_character_is_word_) || !defined(_di_f_utf_character_is_word_dash_) || !defined(_di_f_utf_character_is_word_dash_plus_) || !defined(_di_f_utf_is_alphabetic_digit_) || !defined(_di_f_utf_is_digit_) || !defined(_di_f_utf_is_word_) || !defined(_di_f_utf_is_word_dash_) || !defined(_di_f_utf_is_word_dash_plus_) f_status_t private_f_utf_character_is_digit_for_ascii(const f_char_t character, uint64_t * const value) { - if (isdigit(character)) { + uint16_t result = (uint16_t) (character - '0'); + + if (result < 10) { if (value) { - if (character == f_string_ascii_0_s.string[0]) { - *value = 0; - } - else if (character == f_string_ascii_1_s.string[0]) { - *value = 1; - } - else if (character == f_string_ascii_2_s.string[0]) { - *value = 2; - } - else if (character == f_string_ascii_3_s.string[0]) { - *value = 3; - } - else if (character == f_string_ascii_4_s.string[0]) { - *value = 4; - } - else if (character == f_string_ascii_5_s.string[0]) { - *value = 5; - } - else if (character == f_string_ascii_6_s.string[0]) { - *value = 6; - } - else if (character == f_string_ascii_7_s.string[0]) { - *value = 7; - } - else if (character == f_string_ascii_8_s.string[0]) { - *value = 8; - } - else if (character == f_string_ascii_9_s.string[0]) { - *value = 9; - } - else if (character == f_string_ascii_a_s.string[0] || character == f_string_ascii_A_s.string[0]) { - *value = 10; - } - else if (character == f_string_ascii_b_s.string[0] || character == f_string_ascii_B_s.string[0]) { - *value = 11; - } - else if (character == f_string_ascii_c_s.string[0] || character == f_string_ascii_C_s.string[0]) { - *value = 12; - } - else if (character == f_string_ascii_d_s.string[0] || character == f_string_ascii_D_s.string[0]) { - *value = 13; - } - else if (character == f_string_ascii_e_s.string[0] || character == f_string_ascii_E_s.string[0]) { - *value = 14; - } - else if (character == f_string_ascii_f_s.string[0] || character == f_string_ascii_F_s.string[0]) { - *value = 15; - } - else { - *value = F_type_size_max_64_unsigned_d; - } + *value = (uint64_t) result; + } + + return F_true; + } + + result = (uint16_t) (character - 'A'); + + if (result > 5) { + result = (uint16_t) (character - 'a'); + } + + if (result < 6) { + if (value) { + *value = (uint64_t) (10 + result); } return F_true; diff --git a/level_0/f_utf/c/private-utf_digit.h b/level_0/f_utf/c/private-utf_digit.h index bff4b87..1105045 100644 --- a/level_0/f_utf/c/private-utf_digit.h +++ b/level_0/f_utf/c/private-utf_digit.h @@ -67,8 +67,6 @@ extern "C" { * F_true if a UTF-8 decimal character. * F_false if not a UTF-8 decimal character. * - * @see isdigit() - * * @see f_utf_character_is_alphabetic_digit() * @see f_utf_character_is_digit() * @see f_utf_character_is_word() diff --git a/level_0/f_utf/c/utf/convert.c b/level_0/f_utf/c/utf/convert.c index 3e870fe..ec3cb95 100644 --- a/level_0/f_utf/c/utf/convert.c +++ b/level_0/f_utf/c/utf/convert.c @@ -145,12 +145,12 @@ extern "C" { i = length; } else { - if (macro_f_utf_char_t_to_char_1(string[i]) == f_string_ascii_u_s.string[0] || macro_f_utf_char_t_to_char_1(string[i]) == f_string_ascii_U_s.string[0]) { + if (macro_f_utf_char_t_to_char_1(string[i]) == 'u' || macro_f_utf_char_t_to_char_1(string[i]) == 'U') { do { ++i; } while (i < length && !string[i]); - if (i < length && !macro_f_utf_char_t_width_is(string[i]) && macro_f_utf_char_t_to_char_1(string[i]) == f_string_ascii_plus_s.string[0]) { + if (i < length && !macro_f_utf_char_t_width_is(string[i]) && macro_f_utf_char_t_to_char_1(string[i]) == '+') { ++i; } else { @@ -297,12 +297,12 @@ extern "C" { } // while if (i < length) { - if (string[i] == f_string_ascii_u_s.string[0] || string[i] == f_string_ascii_U_s.string[0]) { + if (string[i] == 'u' || string[i] == 'U') { do { ++i; } while (i < length && !string[i]); - if (i < length && string[i] == f_string_ascii_plus_s.string[0]) { + if (i < length && string[i] == '+') { ++i; } else { diff --git a/level_0/f_utf/c/utf/is.c b/level_0/f_utf/c/utf/is.c index d9a8e07..b346ca3 100644 --- a/level_0/f_utf/c/utf/is.c +++ b/level_0/f_utf/c/utf/is.c @@ -49,9 +49,9 @@ extern "C" { return private_f_utf_character_is_alphabetic(utf); } - if (isalpha(*sequence)) return F_true; - - return F_false; + return (uint16_t) ((*sequence) - 'a') < 26 || (uint16_t) ((*sequence) - 'A') < 26 + ? F_true + : F_false; } #endif // _di_f_utf_is_alphabetic_ @@ -74,9 +74,11 @@ extern "C" { return private_f_utf_character_is_alphabetic_digit(utf, value); } - if (isalpha(*sequence)) return F_true; + if (private_f_utf_character_is_digit_for_ascii(*sequence, value)) return F_true; - return private_f_utf_character_is_digit_for_ascii(*sequence, value); + return (uint16_t) (*sequence - 'a') < 26 || (uint16_t) (*sequence - 'A') < 26 + ? F_true + : F_false; } #endif // _di_f_utf_is_alphabetic_digit_ @@ -99,9 +101,9 @@ extern "C" { return private_f_utf_character_is_alphabetic_numeric(utf); } - if (isalnum(*sequence)) return F_true; - - return F_false; + return (uint16_t) (*sequence - 'a') < 26 || (uint16_t) (*sequence - 'A') < 26 || (uint16_t) (*sequence - '0') < 10 + ? F_true + : F_false; } #endif // _di_f_utf_is_alphabetic_numeric_ @@ -349,9 +351,7 @@ extern "C" { return private_f_utf_character_is_numeric(utf); } - if (isdigit(*sequence)) return F_true; - - return F_false; + return (uint16_t) (*sequence - '0') < 10 ? F_true : F_false; } #endif // _di_f_utf_is_numeric_ @@ -708,9 +708,9 @@ extern "C" { return private_f_utf_character_is_word(utf, strict); } - if (isalnum(*sequence) || *sequence == f_string_ascii_underscore_s.string[0]) return F_true; - - return F_false; + return (uint16_t) (*sequence - 'a') < 26 || (uint16_t) (*sequence - 'A') < 26 || (uint16_t) (*sequence - '0') < 10 || *sequence == '_' + ? F_true + : F_false; } #endif // _di_f_utf_is_word_ @@ -733,9 +733,9 @@ extern "C" { return private_f_utf_character_is_word_dash(utf, strict); } - if (isalnum(*sequence) || *sequence == f_string_ascii_underscore_s.string[0] || *sequence == f_string_ascii_minus_s.string[0]) return F_true; - - return F_false; + return (uint16_t) (*sequence - 'a') < 26 || (uint16_t) (*sequence - 'A') < 26 || (uint16_t) (*sequence - '0') < 10 || *sequence == '_' || *sequence == '-' + ? F_true + : F_false; } #endif // _di_f_utf_is_word_dash_ @@ -758,9 +758,9 @@ extern "C" { return private_f_utf_character_is_word_dash_plus(utf, strict); } - if (isalnum(*sequence) || *sequence == f_string_ascii_underscore_s.string[0] || *sequence == f_string_ascii_minus_s.string[0] || *sequence == f_string_ascii_plus_s.string[0]) return F_true; - - return F_false; + return (uint16_t) (*sequence - 'a') < 26 || (uint16_t) (*sequence - 'A') < 26 || (uint16_t) (*sequence - '0') < 10 || *sequence == '_' || *sequence == '-' || *sequence == '+' + ? F_true + : F_false; } #endif // _di_f_utf_is_word_dash_plus_ diff --git a/level_0/f_utf/c/utf/is.h b/level_0/f_utf/c/utf/is.h index 1ecb62b..138b1d0 100644 --- a/level_0/f_utf/c/utf/is.h +++ b/level_0/f_utf/c/utf/is.h @@ -51,8 +51,6 @@ extern "C" { * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. * 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() */ #ifndef _di_f_utf_is_alphabetic_ extern f_status_t f_utf_is_alphabetic(const f_string_t sequence, const f_number_unsigned_t width_max); @@ -89,9 +87,6 @@ extern "C" { * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. * 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() */ #ifndef _di_f_utf_is_alphabetic_digit_ extern f_status_t f_utf_is_alphabetic_digit(const f_string_t sequence, const f_number_unsigned_t width_max, uint64_t * const value); @@ -117,8 +112,6 @@ extern "C" { * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. * 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() */ #ifndef _di_f_utf_is_alphabetic_numeric_ extern f_status_t f_utf_is_alphabetic_numeric(const f_string_t sequence, const f_number_unsigned_t width_max); @@ -306,8 +299,6 @@ extern "C" { * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. * 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 isdigit() */ #ifndef _di_f_utf_is_digit_ extern f_status_t f_utf_is_digit(const f_string_t sequence, const f_number_unsigned_t width_max, uint64_t * const value); @@ -414,8 +405,6 @@ extern "C" { * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. * 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 isdigit() */ #ifndef _di_f_utf_is_numeric_ extern f_status_t f_utf_is_numeric(const f_string_t sequence, const f_number_unsigned_t width_max); @@ -789,8 +778,6 @@ extern "C" { * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. * 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() */ #ifndef _di_f_utf_is_word_ extern f_status_t f_utf_is_word(const f_string_t sequence, const f_number_unsigned_t width_max, const bool strict); @@ -825,8 +812,6 @@ extern "C" { * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. * 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() */ #ifndef _di_f_utf_is_word_dash_ extern f_status_t f_utf_is_word_dash(const f_string_t sequence, const f_number_unsigned_t width_max, const bool strict); @@ -863,8 +848,6 @@ extern "C" { * F_complete_not_utf (with error bit set) if character is an incomplete UTF-8 sequence. * 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() */ #ifndef _di_f_utf_is_word_dash_plus_ extern f_status_t f_utf_is_word_dash_plus(const f_string_t sequence, const f_number_unsigned_t width_max, const bool strict); diff --git a/level_0/f_utf/c/utf/is_character.c b/level_0/f_utf/c/utf/is_character.c index d8abd13..95d0b4b 100644 --- a/level_0/f_utf/c/utf/is_character.c +++ b/level_0/f_utf/c/utf/is_character.c @@ -45,9 +45,9 @@ extern "C" { return private_f_utf_character_is_alphabetic(sequence); } - if (isalpha(macro_f_utf_char_t_to_char_1(sequence))) return F_true; - - return F_false; + return (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - 'a') < 26 || (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - 'A') < 26 + ? F_true + : F_false; } #endif // _di_f_utf_character_is_alphabetic_ @@ -60,9 +60,11 @@ extern "C" { return private_f_utf_character_is_alphabetic_digit(sequence, value); } - if (isalpha(macro_f_utf_char_t_to_char_1(sequence))) return F_true; + if (private_f_utf_character_is_digit_for_ascii(macro_f_utf_char_t_to_char_1(sequence), value)) return F_true; - return private_f_utf_character_is_digit_for_ascii(macro_f_utf_char_t_to_char_1(sequence), value); + return (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - 'a') < 26 || (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - 'A') < 26 + ? F_true + : F_false; } #endif // _di_f_utf_character_is_alphabetic_digit_ @@ -75,9 +77,9 @@ extern "C" { return private_f_utf_character_is_alphabetic_numeric(sequence); } - if (isalnum(macro_f_utf_char_t_to_char_1(sequence))) return F_true; - - return F_false; + return (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - 'a') < 26 || (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - 'A') < 26 || (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - '0') < 10 + ? F_true + : F_false; } #endif // _di_f_utf_character_is_alphabetic_numeric_ @@ -222,9 +224,7 @@ extern "C" { return private_f_utf_character_is_numeric(sequence); } - if (isdigit(macro_f_utf_char_t_to_char_1(sequence))) return F_true; - - return F_false; + return (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - '0') < 10 ? F_true : F_false; } #endif // _di_f_utf_character_is_numeric_ @@ -436,9 +436,9 @@ extern "C" { return private_f_utf_character_is_word(sequence, strict); } - if (isalnum(macro_f_utf_char_t_to_char_1(sequence)) || macro_f_utf_char_t_to_char_1(sequence) == f_string_ascii_underscore_s.string[0]) return F_true; - - return F_false; + return (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - 'a') < 26 || (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - 'A') < 26 || (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - '0') < 10 || macro_f_utf_char_t_to_char_1(sequence) == '_' + ? F_true + : F_false; } #endif // _di_f_utf_character_is_word_ @@ -451,9 +451,9 @@ extern "C" { return private_f_utf_character_is_word_dash(sequence, strict); } - if (isalnum(macro_f_utf_char_t_to_char_1(sequence)) || macro_f_utf_char_t_to_char_1(sequence) == f_string_ascii_underscore_s.string[0] || macro_f_utf_char_t_to_char_1(sequence) == f_string_ascii_minus_s.string[0]) return F_true; - - return F_false; + return (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - 'a') < 26 || (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - 'A') < 26 || (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - '0') < 10 || macro_f_utf_char_t_to_char_1(sequence) == '_' || macro_f_utf_char_t_to_char_1(sequence) == '-' + ? F_true + : F_false; } #endif // _di_f_utf_character_is_word_dash_ @@ -466,9 +466,9 @@ extern "C" { return private_f_utf_character_is_word_dash_plus(sequence, strict); } - if (isalnum(macro_f_utf_char_t_to_char_1(sequence)) || macro_f_utf_char_t_to_char_1(sequence) == f_string_ascii_underscore_s.string[0] || macro_f_utf_char_t_to_char_1(sequence) == f_string_ascii_minus_s.string[0] || macro_f_utf_char_t_to_char_1(sequence) == f_string_ascii_plus_s.string[0]) return F_true; - - return F_false; + return (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - 'a') < 26 || (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - 'A') < 26 || (uint16_t) (macro_f_utf_char_t_to_char_1(sequence) - '0') < 10 || macro_f_utf_char_t_to_char_1(sequence) == '_' || macro_f_utf_char_t_to_char_1(sequence) == '-' || macro_f_utf_char_t_to_char_1(sequence) == '+' + ? F_true + : F_false; } #endif // _di_f_utf_character_is_word_dash_plus_ diff --git a/level_0/f_utf/c/utf/is_character.h b/level_0/f_utf/c/utf/is_character.h index 6f6b3d7..953e61c 100644 --- a/level_0/f_utf/c/utf/is_character.h +++ b/level_0/f_utf/c/utf/is_character.h @@ -48,8 +48,6 @@ 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() */ #ifndef _di_f_utf_character_is_alphabetic_ extern f_status_t f_utf_character_is_alphabetic(const f_utf_char_t sequence); @@ -80,9 +78,6 @@ 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() */ #ifndef _di_f_utf_character_is_alphabetic_digit_ extern f_status_t f_utf_character_is_alphabetic_digit(const f_utf_char_t sequence, uint64_t * const value); @@ -102,8 +97,6 @@ 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() */ #ifndef _di_f_utf_character_is_alphabetic_numeric_ extern f_status_t f_utf_character_is_alphabetic_numeric(const f_utf_char_t sequence); @@ -252,8 +245,6 @@ 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 isdigit() */ #ifndef _di_f_utf_character_is_digit_ extern f_status_t f_utf_character_is_digit(const f_utf_char_t sequence, uint64_t * const value); @@ -345,8 +336,6 @@ 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 isdigit() */ #ifndef _di_f_utf_character_is_numeric_ extern f_status_t f_utf_character_is_numeric(const f_utf_char_t sequence); @@ -639,8 +628,6 @@ 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() */ #ifndef _di_f_utf_character_is_word_ extern f_status_t f_utf_character_is_word(const f_utf_char_t sequence, const bool strict); @@ -669,8 +656,6 @@ 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() */ #ifndef _di_f_utf_character_is_word_dash_ extern f_status_t f_utf_character_is_word_dash(const f_utf_char_t sequence, const bool strict); @@ -701,8 +686,6 @@ 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() */ #ifndef _di_f_utf_character_is_word_dash_plus_ extern f_status_t f_utf_character_is_word_dash_plus(const f_utf_char_t sequence, const bool strict); diff --git a/level_3/fake/c/main/make/operate_process.c b/level_3/fake/c/main/make/operate_process.c index cb43421..8d655a0 100644 --- a/level_3/fake/c/main/make/operate_process.c +++ b/level_3/fake/c/main/make/operate_process.c @@ -161,15 +161,15 @@ extern "C" { else if (source.string[i] == f_string_ascii_0_s.string[0]) { destination->string[destination->used++] = f_string_null_s.string[0]; } - else if (source.string[i] == f_string_ascii_exclamation_s.string[0]) { + else if (source.string[i] == '!') { // The "\!" designates a do nothing character. } - else if (source.string[i] == f_string_ascii_U_s.string[0]) { + else if (source.string[i] == 'U') { // At the end of the string before a \U+XXXX sequence is completed is invalid. if (++i >= source.used) break; - if (source.string[i] == f_string_ascii_plus_s.string[0]) { + if (source.string[i] == '+') { // At the end of the string before a \U+XXXX sequence is completed is invalid. if (i + 4 >= source.used) break; @@ -177,12 +177,12 @@ extern "C" { ++i; // The max Unicode sequence length is "U+XXXXXX". - char buffer_string[9] = { f_string_ascii_U_s.string[0], f_string_ascii_plus_s.string[0], 0, 0, 0, 0, 0, 0, 0 }; + char buffer_string[9] = { 'U', '+', 0, 0, 0, 0, 0, 0, 0 }; f_string_static_t buffer = macro_f_string_static_t_initialize_1(buffer_string, 0, 2); for (uint8_t j = 2; i < source.used && j < 8; ) { - if (!isdigit(source.string[i])) { + if ((uint16_t) (source.string[i] - '0') > 9) { if (!(source.string[i] == f_string_ascii_A_s.string[0] || source.string[i] == f_string_ascii_B_s.string[0] || source.string[i] == f_string_ascii_C_s.string[0] || diff --git a/level_3/fake/c/main/make/operate_process_type.c b/level_3/fake/c/main/make/operate_process_type.c index 85db097..6c93026 100644 --- a/level_3/fake/c/main/make/operate_process_type.c +++ b/level_3/fake/c/main/make/operate_process_type.c @@ -825,10 +825,10 @@ extern "C" { range.start = 0; range.stop = main->cache_arguments.array[i].used - 1; - if (main->cache_arguments.array[i].string[0] == f_string_ascii_plus_s.string[0]) { + if (main->cache_arguments.array[i].string[0] == '+') { range.start = 1; } - else if (main->cache_arguments.array[i].string[0] == f_string_ascii_minus_s.string[0]) { + else if (main->cache_arguments.array[i].string[0] == '-') { range.start = 1; is_negative_left = F_true; } @@ -849,10 +849,10 @@ extern "C" { is_negative_right = F_false; - if (main->cache_arguments.array[i].string[0] == f_string_ascii_plus_s.string[0]) { + if (main->cache_arguments.array[i].string[0] == '+') { range.start = 1; } - else if (main->cache_arguments.array[i].string[0] == f_string_ascii_minus_s.string[0]) { + else if (main->cache_arguments.array[i].string[0] == '-') { range.start = 1; is_negative_right = F_true; } diff --git a/level_3/fake/c/main/make/operate_validate.c b/level_3/fake/c/main/make/operate_validate.c index c8d6fa0..5b99b65 100644 --- a/level_3/fake/c/main/make/operate_validate.c +++ b/level_3/fake/c/main/make/operate_validate.c @@ -96,10 +96,16 @@ extern "C" { f_status_t fake_make_operate_validate_define_name(const f_string_static_t name) { if (!name.used) return F_data_not; - if (!isalpha(name.string[0]) && name.string[0] != '_') return F_false; + + if (!((uint16_t) (name.string[0] - 'a') < 26 || (uint16_t) (name.string[0] - 'A') < 26)) { + if (name.string[0] != '_') return F_false; + } for (f_number_unsigned_t i = 1; i < name.used; ++i) { - if (!isalnum(name.string[i]) && name.string[i] != '_') return F_false; + + if (!((uint16_t) (name.string[i] - 'a') < 26 || (uint16_t) (name.string[i] - 'A') < 26 || (uint16_t) (name.string[i] - '0') < 10)) { + if (name.string[i] != '_') return F_false; + } } // for return F_true; diff --git a/level_3/fake/c/main/make/operate_validate.h b/level_3/fake/c/main/make/operate_validate.h index dc0a25d..7c22be8 100644 --- a/level_3/fake/c/main/make/operate_validate.h +++ b/level_3/fake/c/main/make/operate_validate.h @@ -104,7 +104,6 @@ extern "C" { * F_true on valid. * F_false on invalid. * - * @see isalpha() * @see isalnum() */ #ifndef _di_fake_make_operate_validate_define_name_ diff --git a/level_3/fake/c/main/make/operate_validate_type.c b/level_3/fake/c/main/make/operate_validate_type.c index 16b5c37..5c0b05e 100644 --- a/level_3/fake/c/main/make/operate_validate_type.c +++ b/level_3/fake/c/main/make/operate_validate_type.c @@ -615,10 +615,10 @@ extern "C" { range.start = 0; range.stop = main->cache_arguments.array[i].used - 1; - if (main->cache_arguments.array[i].string[0] == f_string_ascii_plus_s.string[0]) { + if (main->cache_arguments.array[i].string[0] == '+') { range.start = 1; } - else if (main->cache_arguments.array[i].string[0] == f_string_ascii_minus_s.string[0]) { + else if (main->cache_arguments.array[i].string[0] == '-') { range.start = 1; }