MCPcopy Create free account
hub / github.com/F-Stack/f-stack / do_norm_compare

Function do_norm_compare

freebsd/contrib/openzfs/module/unicode/u8_textprep.c:1721–1829  ·  view source on GitHub ↗

* The do_norm_compare() function does string comparison based on Unicode * simple case mappings and Unicode Normalization definitions. * * It does so by collecting a sequence of character at a time and comparing * the collected sequences from the strings. * * The meanings on the return values are the same as the usual strcmp(). */

Source from the content-addressed store, hash-verified

1719 * The meanings on the return values are the same as the usual strcmp().
1720 */
1721static int
1722do_norm_compare(size_t uv, uchar_t *s1, uchar_t *s2, size_t n1, size_t n2,
1723 int flag, int *errnum)
1724{
1725 int result;
1726 size_t sz1;
1727 size_t sz2;
1728 uchar_t u8s1[U8_STREAM_SAFE_TEXT_MAX + 1];
1729 uchar_t u8s2[U8_STREAM_SAFE_TEXT_MAX + 1];
1730 uchar_t *s1last;
1731 uchar_t *s2last;
1732 boolean_t is_it_toupper;
1733 boolean_t is_it_tolower;
1734 boolean_t canonical_decomposition;
1735 boolean_t compatibility_decomposition;
1736 boolean_t canonical_composition;
1737 u8_normalization_states_t state;
1738
1739 s1last = s1 + n1;
1740 s2last = s2 + n2;
1741
1742 is_it_toupper = flag & U8_TEXTPREP_TOUPPER;
1743 is_it_tolower = flag & U8_TEXTPREP_TOLOWER;
1744 canonical_decomposition = flag & U8_CANON_DECOMP;
1745 compatibility_decomposition = flag & U8_COMPAT_DECOMP;
1746 canonical_composition = flag & U8_CANON_COMP;
1747
1748 while (s1 < s1last && s2 < s2last) {
1749 /*
1750 * If the current character is a 7-bit ASCII and the last
1751 * character, or, if the current character and the next
1752 * character are both some 7-bit ASCII characters then
1753 * we treat the current character as a sequence.
1754 *
1755 * In any other cases, we need to call collect_a_seq().
1756 */
1757
1758 if (U8_ISASCII(*s1) && ((s1 + 1) >= s1last ||
1759 ((s1 + 1) < s1last && U8_ISASCII(*(s1 + 1))))) {
1760 if (is_it_toupper)
1761 u8s1[0] = U8_ASCII_TOUPPER(*s1);
1762 else if (is_it_tolower)
1763 u8s1[0] = U8_ASCII_TOLOWER(*s1);
1764 else
1765 u8s1[0] = *s1;
1766 u8s1[1] = '\0';
1767 sz1 = 1;
1768 s1++;
1769 } else {
1770 state = U8_STATE_START;
1771 sz1 = collect_a_seq(uv, u8s1, &s1, s1last,
1772 is_it_toupper, is_it_tolower,
1773 canonical_decomposition,
1774 compatibility_decomposition,
1775 canonical_composition, errnum, &state);
1776 }
1777
1778 if (U8_ISASCII(*s2) && ((s2 + 1) >= s2last ||

Callers 1

u8_strcmpFunction · 0.85

Calls 2

collect_a_seqFunction · 0.85
strcmpFunction · 0.85

Tested by

no test coverage detected