+2009-03-07 Bruno Haible <bruno@clisp.org>
+
+ Adjust u*_normcmp, u*_normcoll API.
+ * lib/uninorm.h (u8_normcmp, u16_normcmp, u32_normcmp, u8_normcoll,
+ u16_normcoll, u32_normcoll): Change failure conventions.
+ * lib/uninorm/u-normcmp.h (FUNC): Upon failure, store the error code in
+ errno and return -1.
+ * lib/uninorm/u-normcoll.h (FUNC): Likewise.
+
2009-03-07 Bruno Haible <bruno@clisp.org>
Tests for module 'uninorm/u32-normcoll'.
/* Compare S1 and S2, ignoring differences in normalization.
NF must be either UNINORM_NFD or UNINORM_NFKD.
If successful, set *RESULT to -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2, and
- return 0. Upon failure, return the error number. */
+ return 0. Upon failure, return -1 with errno set. */
extern int
u8_normcmp (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2,
uninorm_t nf, int *result);
collation rules of the current locale.
NF must be either UNINORM_NFC or UNINORM_NFKC.
If successful, set *RESULT to -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2, and
- return 0. Upon failure, return the error number. */
+ return 0. Upon failure, return -1 with errno set. */
extern int
u8_normcoll (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2,
uninorm_t nf, int *result);
norms1_length = sizeof (buf1) / sizeof (UNIT);
norms1 = U_NORMALIZE (nf, s1, n1, buf1, &norms1_length);
if (norms1 == NULL)
- return errno;
+ /* errno is set here. */
+ return -1;
/* Normalize S2. */
norms2_length = sizeof (buf2) / sizeof (UNIT);
norms2 = U_NORMALIZE (nf, s2, n2, buf2, &norms2_length);
if (norms2 == NULL)
{
- int saved_errno = errno;
if (norms1 != buf1)
- free (norms1);
- return saved_errno;
+ {
+ int saved_errno = errno;
+ free (norms1);
+ errno = saved_errno;
+ }
+ return -1;
}
/* Compare the normalized strings. */
transformed1_length = sizeof (buf1);
transformed1 = U_NORMXFRM (s1, n1, nf, buf1, &transformed1_length);
if (transformed1 == NULL)
- return errno;
+ /* errno is set here. */
+ return -1;
/* Normalize and transform S2. */
transformed2_length = sizeof (buf2);
transformed2 = U_NORMXFRM (s2, n2, nf, buf2, &transformed2_length);
if (transformed2 == NULL)
{
- int saved_errno = errno;
if (transformed1 != buf1)
- free (transformed1);
- return saved_errno;
+ {
+ int saved_errno = errno;
+ free (transformed1);
+ errno = saved_errno;
+ }
+ return -1;
}
/* Compare the transformed strings. */