FreeBSD/contrib/subversion/subversion/libsvn_subr/utf8proc.c
/* Fill the given BUFFER with decomposed UCS-4 representation of the
 * UTF-8 STRING. If LENGTH is SVN_UTF__UNKNOWN_LENGTH, assume STRING
 * is NUL-terminated; otherwise look only at the first LENGTH bytes in
 * STRING. Upon return, BUFFER->data points at an array of UCS-4
 * characters, and return the length of the array. TRANSFORM_FLAGS
 * define exactly how the decomposition is performed.
 *
 * A negative return value is an utf8proc error code and may indicate
 * that STRING contains invalid UTF-8 or was so long that an overflow
 * occurred.
 */


A negative return value is an utf8proc error code and may indicate
that STRING contains invalid UTF-8 or was so long that an overflow
occurred.
A negative return value is an utf8proc error code and may indicate that STRING contains invalid UTF - 8 or was so long that an overflow occurred .
static ssize_t
unicode_decomposition(int transform_flags,
                      const char *string, apr_size_t length,
                      svn_membuf_t *buffer)
{
  const int nullterm = (length == SVN_UTF__UNKNOWN_LENGTH
                        ? UTF8PROC_NULLTERM : 0);
  for (;;)
    {
      apr_int32_t *const ucs4buf = buffer->data;
      const ssize_t ucs4len = buffer->size / sizeof(*ucs4buf);
      const ssize_t result =
        utf8proc_decompose((const void*) string, length, ucs4buf, ucs4len,
                           UTF8PROC_DECOMPOSE | UTF8PROC_STABLE
                           | transform_flags | nullterm);
      if (result < 0 || result <= ucs4len)
        return result;
      svn_membuf__ensure(buffer, result * sizeof(*ucs4buf));
    }
}
static ssize_t unicode_decomposition ( int transform_flags , const char * string , apr_size_t length , svn_membuf_t * buffer ) { const int nullterm = ( length == SVN_UTF__UNKNOWN_LENGTH ? UTF8PROC_NULLTERM : 0 ) ; for ( ; ; ) { apr_int32_t * const ucs4buf = buffer -> data ; const ssize_t ucs4len = buffer -> size / sizeof ( * ucs4buf ) ; const ssize_t result = utf8proc_decompose ( ( const void * ) string , length , ucs4buf , ucs4len , UTF8PROC_DECOMPOSE | UTF8PROC_STABLE | transform_flags | nullterm ) ; if ( result < 0 || result <= ucs4len ) return result ; svn_membuf__ensure ( buffer , result * sizeof ( * ucs4buf ) ) ; } }
Fill the given BUFFER with decomposed UCS-4 representation of the
 UTF-8 STRING.
Fill the given BUFFER with decomposed UCS - 4 representation of the UTF - 8 STRING .
/* Increase the decomposition buffer size and retry */