You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by yl...@apache.org on 2021/03/11 17:32:27 UTC

svn commit: r1887505 - in /apr/apr/trunk: configure.in strings/apr_cstr.c

Author: ylavic
Date: Thu Mar 11 17:32:27 2021
New Revision: 1887505

URL: http://svn.apache.org/viewvc?rev=1887505&view=rev
Log:
More revert of r1887500.

Modified:
    apr/apr/trunk/configure.in
    apr/apr/trunk/strings/apr_cstr.c

Modified: apr/apr/trunk/configure.in
URL: http://svn.apache.org/viewvc/apr/apr/trunk/configure.in?rev=1887505&r1=1887504&r2=1887505&view=diff
==============================================================================
--- apr/apr/trunk/configure.in (original)
+++ apr/apr/trunk/configure.in Thu Mar 11 17:32:27 2021
@@ -327,9 +327,6 @@ case $host in
         ;;
 esac
 
-dnl Libtool has been broken for decades, incorrectly passing 'cru' to 'ar'
-AR_FLAGS=${AR_FLAGS:-cr}
-
 AC_SUBST(lt_compile)
 AC_SUBST(link)
 AC_SUBST(so_ext)

Modified: apr/apr/trunk/strings/apr_cstr.c
URL: http://svn.apache.org/viewvc/apr/apr/trunk/strings/apr_cstr.c?rev=1887505&r1=1887504&r2=1887505&view=diff
==============================================================================
--- apr/apr/trunk/strings/apr_cstr.c (original)
+++ apr/apr/trunk/strings/apr_cstr.c Thu Mar 11 17:32:27 2021
@@ -197,7 +197,7 @@ APR_DECLARE(char *) apr_cstr_join(const
  * octets (such as extended latin alphabetics) are never case-folded.
  * NOTE: Other than Alpha A-Z/a-z, each code point is unique!
  */
-static const unsigned char ucharmap[] = {
+static const short ucharmap[] = {
     0x0,  0x1,  0x2,  0x3,  0x4,  0x5,  0x6,  0x7,
     0x8,  0x9,  0xa,  0xb,  0xc,  0xd,  0xe,  0xf,
     0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
@@ -244,7 +244,7 @@ static const unsigned char ucharmap[] =
  *
  * NOTE: Other than Alpha A-Z/a-z, each code point is unique!
  */
-static const unsigned char ucharmap[] = {
+static const short ucharmap[] = {
     0x00, 0x01, 0x02, 0x03, 0x9C, 0x09, 0x86, 0x7F,
     0x97, 0x8D, 0x8E, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
     0x10, 0x11, 0x12, 0x13, 0x9D, 0x85, 0x08, 0x87,
@@ -282,25 +282,36 @@ static const unsigned char ucharmap[] =
 
 APR_DECLARE(int) apr_cstr_casecmp(const char *s1, const char *s2)
 {
-    apr_size_t i = 0;
-    for (;; ++i) {
-        const int c1 = ucharmap[(unsigned char)s1[i]];
-        const int c2 = ucharmap[(unsigned char)s2[i]] - c1;
-        if (!c1 || c2)
-            return c2;
+    const unsigned char *str1 = (const unsigned char *)s1;
+    const unsigned char *str2 = (const unsigned char *)s2;
+    for (;;)
+    {
+        const int c1 = (int)(*str1);
+        const int c2 = (int)(*str2);
+        const int cmp = ucharmap[c1] - ucharmap[c2];
+        /* Not necessary to test for !c2, this is caught by cmp */
+        if (cmp || !c1)
+            return cmp;
+        str1++;
+        str2++;
     }
-    return 0;
 }
 
 APR_DECLARE(int) apr_cstr_casecmpn(const char *s1, const char *s2,
                                    apr_size_t n)
 {
-    apr_size_t i = 0;
-    for (; i < n; ++i) {
-        const int c1 = ucharmap[(unsigned char)s1[i]];
-        const int c2 = ucharmap[(unsigned char)s2[i]] - c1;
-        if (!c1 || c2)
-            return c2;
+    const unsigned char *str1 = (const unsigned char *)s1;
+    const unsigned char *str2 = (const unsigned char *)s2;
+    while (n--)
+    {
+        const int c1 = (int)(*str1);
+        const int c2 = (int)(*str2);
+        const int cmp = ucharmap[c1] - ucharmap[c2];
+        /* Not necessary to test for !c2, this is caught by cmp */
+        if (cmp || !c1)
+            return cmp;
+        str1++;
+        str2++;
     }
     return 0;
 }