Adjust u*_normcmp, u*_normcoll API.
authorBruno Haible <bruno@clisp.org>
Sun, 8 Mar 2009 02:18:26 +0000 (03:18 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 8 Mar 2009 02:18:26 +0000 (03:18 +0100)
ChangeLog
lib/uninorm.h
lib/uninorm/u-normcmp.h
lib/uninorm/u-normcoll.h

index 4f87a95..36bba2d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 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'.
        * modules/uninorm/u32-normcoll-tests: New file.
        * tests/uninorm/test-u32-normcoll.c: New file.
index e4153cf..ec14e09 100644 (file)
@@ -152,7 +152,7 @@ extern uint32_t *
 /* 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);
@@ -183,7 +183,7 @@ extern char *
    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);
index 33d1e62..0305fbc 100644 (file)
@@ -31,17 +31,21 @@ FUNC (const UNIT *s1, size_t n1, const UNIT *s2, size_t n2,
   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.  */
index 5af764e..a8bf29c 100644 (file)
@@ -31,17 +31,21 @@ FUNC (const UNIT *s1, size_t n1, const UNIT *s2, size_t n2,
   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.  */