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

Function u8_textprep_str

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

Source from the content-addressed store, hash-verified

1905}
1906
1907size_t
1908u8_textprep_str(char *inarray, size_t *inlen, char *outarray, size_t *outlen,
1909 int flag, size_t unicode_version, int *errnum)
1910{
1911 int f;
1912 int sz;
1913 uchar_t *ib;
1914 uchar_t *ibtail;
1915 uchar_t *ob;
1916 uchar_t *obtail;
1917 boolean_t do_not_ignore_null;
1918 boolean_t do_not_ignore_invalid;
1919 boolean_t is_it_toupper;
1920 boolean_t is_it_tolower;
1921 boolean_t canonical_decomposition;
1922 boolean_t compatibility_decomposition;
1923 boolean_t canonical_composition;
1924 size_t ret_val;
1925 size_t i;
1926 size_t j;
1927 uchar_t u8s[U8_STREAM_SAFE_TEXT_MAX + 1];
1928 u8_normalization_states_t state;
1929
1930 if (unicode_version > U8_UNICODE_LATEST) {
1931 *errnum = ERANGE;
1932 return ((size_t)-1);
1933 }
1934
1935 f = flag & (U8_TEXTPREP_TOUPPER | U8_TEXTPREP_TOLOWER);
1936 if (f == (U8_TEXTPREP_TOUPPER | U8_TEXTPREP_TOLOWER)) {
1937 *errnum = EBADF;
1938 return ((size_t)-1);
1939 }
1940
1941 f = flag & (U8_CANON_DECOMP | U8_COMPAT_DECOMP | U8_CANON_COMP);
1942 if (f && f != U8_TEXTPREP_NFD && f != U8_TEXTPREP_NFC &&
1943 f != U8_TEXTPREP_NFKD && f != U8_TEXTPREP_NFKC) {
1944 *errnum = EBADF;
1945 return ((size_t)-1);
1946 }
1947
1948 if (inarray == NULL || *inlen == 0)
1949 return (0);
1950
1951 if (outarray == NULL) {
1952 *errnum = E2BIG;
1953 return ((size_t)-1);
1954 }
1955
1956 ib = (uchar_t *)inarray;
1957 ob = (uchar_t *)outarray;
1958 ibtail = ib + *inlen;
1959 obtail = ob + *outlen;
1960
1961 do_not_ignore_null = !(flag & U8_TEXTPREP_IGNORE_NULL);
1962 do_not_ignore_invalid = !(flag & U8_TEXTPREP_IGNORE_INVALID);
1963 is_it_toupper = flag & U8_TEXTPREP_TOUPPER;
1964 is_it_tolower = flag & U8_TEXTPREP_TOLOWER;

Callers 1

zap_normalizeFunction · 0.85

Calls 2

do_case_convFunction · 0.85
collect_a_seqFunction · 0.85

Tested by

no test coverage detected