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 4f87a95699dc86c8c805db2698985e1263dbf692..36bba2dc8a3b2b5e9c0ce3087dce6691731b4851 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+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'.
index e4153cf63a7f64e14d646cfcb08c743e60c36735..ec14e09f6d541b04422142b77996fa0033c5d40c 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 33d1e6252b6245916e3d48cad1b8669ee2affb33..0305fbce312a7510ee52da07d1309442fbff0c81 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 5af764eba1d8ddee31492b03815d362530589a5d..a8bf29ca8ee51f71b0ac75ad254b99cbe5a7dbbe 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.  */