apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject svn commit: r1733488 - in /apr/apr/branches/1.6.x: ./ CHANGES CMakeLists.txt include/apr_cstr.h include/apr_errno.h strings/apr_cstr.c test/teststr.c
Date Thu, 03 Mar 2016 16:11:17 GMT
Author: wrowe
Date: Thu Mar  3 16:11:16 2016
New Revision: 1733488

URL: http://svn.apache.org/viewvc?rev=1733488&view=rev
Log:
Introduce the subset of svn_cstring_ functions into APR as the apr_cstr_
family of functions.  Requires the introduction of APR_ERANGE.
Solves apr_cstr_casecmp[n] for ASCII and EBCDIC and borrows
from the work of jim, ylavic and wrowe, see r1715401 forwards in;
  http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util.c?view=log&pathrev=1722194
More performance review is needed against different compilers, so went ahead
and borrowed original svn implementation as a basis, and we can port whichever
performance enhancements test out more efficiently.

Proposing for APR 1.6.0 which is the thought behind the initial @since tags.
These must be changed if not accepted for backport.

Note that the svn_cstring_join function could not be implemented as-is
due to the absence of svn's counted string functionality.  It deserves
an implementation if not already present, or should be removed before
tagging or backporting.

No whitespace/formatting cleanup on this pass in order to preserve as
much of the svn attributions as possible.  This can happen in a later
pass to conform to APR's style conventions.

Corrections to the language of the function behavior by jim, wrowe, mrumph.
Adapted to apr by wrowe, but this represents a collaboration by many at svn,
so I have avoiding claiming credit in CHANGES.

Backports: r1726928, r1727020, r1727160, r1727175, r1727199, r1728957


Added:
    apr/apr/branches/1.6.x/include/apr_cstr.h
      - copied, changed from r1726928, apr/apr/trunk/include/apr_cstr.h
    apr/apr/branches/1.6.x/strings/apr_cstr.c
      - copied unchanged from r1726928, apr/apr/trunk/strings/apr_cstr.c
Modified:
    apr/apr/branches/1.6.x/   (props changed)
    apr/apr/branches/1.6.x/CHANGES
    apr/apr/branches/1.6.x/CMakeLists.txt
    apr/apr/branches/1.6.x/include/apr_errno.h
    apr/apr/branches/1.6.x/test/teststr.c

Propchange: apr/apr/branches/1.6.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Mar  3 16:11:16 2016
@@ -1,4 +1,4 @@
 /apr/apr/branches/1.4.x:1003369,1101301
-/apr/apr/trunk:733052,739635,741862,741866-741867,741869,741871,745763-745764,746310,747990,748080,748361,748371,748565,748888,748902,748988,749810,760443,767895,775683,782838,783398,783958,784633,784773,788588,789050,793192-793193,794118,794485,795267,799497,800627,809745,809854,810472,811455,813063,821306,829490,831641,832904,835607,888669,892028,892159,892435,892909,896382,896653,908427,910419,910597,917819,917837-917838,925965,929796,931973,951771,960665,960671,979891,983618,989450,990435,1003338,1044440,1044447,1055657,1072165,1078845,1081462,1081495,1083038,1083242,1084662,1086695,1088023,1089031,1089129,1089438,1099348,1103310,1183683,1183685-1183686,1183688,1183693,1183698,1213382,1235047,1236970,1237078,1237507,1240472,1340286,1340288,1340470,1341193,1341196,1343233,1343243,1367050,1368819,1370494,1372018,1372022,1372093,1372849,1376957,1384764,1389077,1400200,1402868,1405985,1406690,1420106,1420109,1425356,1428809,1438940,1438957-1438959,1442903,1449568,1456418,1459994,146
 0179-1460180,1460241,1460399,1460405,1462738,1462813,1470186,1470348,1475509,1478905,1480067,1481262,1481265,1484271,1487796,1489517,1496407,1502804,1510354,1516261,1523384,1523479,1523484,1523505,1523521,1523604,1523613,1523615,1523844-1523845,1523853,1524014,1524031,1528797,1528809,1529488,1529495,1529515,1529521,1529668,1530786,1530800,1530988,1531554,1531768,1531884,1532022,1533104,1533111,1533979,1535027,1535157,1536744,1538171,1539374,1539389,1539455,1539603,1541054,1541061,1541486,1541655,1541666,1541744,1542601,1542779,1543033,1543056,1548575,1550907,1551650,1551659,1558905,1559382,1559873,1559975,1561040,1561260,1561265,1561321,1561347,1561356,1561361,1561394,1561555,1571894,1575509,1578420,1587045,1587063,1587543,1587545,1588878,1588937,1593611,1593614-1593615,1593680,1594684,1594708,1595549,1597797,1597803,1604590,1604596,1604598,1605104,1610854,1611023,1611107,1611110,1611117,1611120,1611125,1611184,1611193,1611466,1611515,1611517,1625173,1626564,1634615,1642159,1648830,
 1664406,1664447,1664451,1664471,1664769-1664770,1664775,1664904,1664911,1664958,1666341,1666411,1666458,1666611,1667420-1667421,1667423,1667914-1667916,1671329,1671356,1671389,1671513-1671514,1671957,1672354,1672366,1672495,1672575,1675644,1675656,1675668,1676013,1685929,1696140,1696767,1722547,1722557,1733451
+/apr/apr/trunk:733052,739635,741862,741866-741867,741869,741871,745763-745764,746310,747990,748080,748361,748371,748565,748888,748902,748988,749810,760443,767895,775683,782838,783398,783958,784633,784773,788588,789050,793192-793193,794118,794485,795267,799497,800627,809745,809854,810472,811455,813063,821306,829490,831641,832904,835607,888669,892028,892159,892435,892909,896382,896653,908427,910419,910597,917819,917837-917838,925965,929796,931973,951771,960665,960671,979891,983618,989450,990435,1003338,1044440,1044447,1055657,1072165,1078845,1081462,1081495,1083038,1083242,1084662,1086695,1088023,1089031,1089129,1089438,1099348,1103310,1183683,1183685-1183686,1183688,1183693,1183698,1213382,1235047,1236970,1237078,1237507,1240472,1340286,1340288,1340470,1341193,1341196,1343233,1343243,1367050,1368819,1370494,1372018,1372022,1372093,1372849,1376957,1384764,1389077,1400200,1402868,1405985,1406690,1420106,1420109,1425356,1428809,1438940,1438957-1438959,1442903,1449568,1456418,1459994,146
 0179-1460180,1460241,1460399,1460405,1462738,1462813,1470186,1470348,1475509,1478905,1480067,1481262,1481265,1484271,1487796,1489517,1496407,1502804,1510354,1516261,1523384,1523479,1523484,1523505,1523521,1523604,1523613,1523615,1523844-1523845,1523853,1524014,1524031,1528797,1528809,1529488,1529495,1529515,1529521,1529668,1530786,1530800,1530988,1531554,1531768,1531884,1532022,1533104,1533111,1533979,1535027,1535157,1536744,1538171,1539374,1539389,1539455,1539603,1541054,1541061,1541486,1541655,1541666,1541744,1542601,1542779,1543033,1543056,1548575,1550907,1551650,1551659,1558905,1559382,1559873,1559975,1561040,1561260,1561265,1561321,1561347,1561356,1561361,1561394,1561555,1571894,1575509,1578420,1587045,1587063,1587543,1587545,1588878,1588937,1593611,1593614-1593615,1593680,1594684,1594708,1595549,1597797,1597803,1604590,1604596,1604598,1605104,1610854,1611023,1611107,1611110,1611117,1611120,1611125,1611184,1611193,1611466,1611515,1611517,1625173,1626564,1634615,1642159,1648830,
 1664406,1664447,1664451,1664471,1664769-1664770,1664775,1664904,1664911,1664958,1666341,1666411,1666458,1666611,1667420-1667421,1667423,1667914-1667916,1671329,1671356,1671389,1671513-1671514,1671957,1672354,1672366,1672495,1672575,1675644,1675656,1675668,1676013,1685929,1696140,1696767,1722547,1722557,1726928,1727020,1727160,1727175,1727199,1728957,1733451
 /apr/apr/trunk/test/testnames.c:1460405
 /httpd/httpd/trunk:1604590

Modified: apr/apr/branches/1.6.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/CHANGES?rev=1733488&r1=1733487&r2=1733488&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.6.x/CHANGES [utf-8] Thu Mar  3 16:11:16 2016
@@ -1,6 +1,9 @@
                                                      -*- coding: utf-8 -*-
 Changes for APR 1.6.0
 
+  *) Introduce the apr_cstr_fn() family of functions, derived from
+     the svn_cstring_ functions of the Subversion project.
+
   *) Add APR_SO_FREEBIND option for apr_socket_opt_set.  PR 58725.
      [Ashley GC, Jan Kaluza, Joe Orton]
 

Modified: apr/apr/branches/1.6.x/CMakeLists.txt
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/CMakeLists.txt?rev=1733488&r1=1733487&r2=1733488&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/CMakeLists.txt (original)
+++ apr/apr/branches/1.6.x/CMakeLists.txt Thu Mar  3 16:11:16 2016
@@ -87,6 +87,7 @@ INCLUDE_DIRECTORIES(${APR_INCLUDE_DIRECT
 SET(APR_PUBLIC_HEADERS_STATIC
   include/apr_allocator.h
   include/apr_atomic.h
+  include/apr_cstr.h
   include/apr_dso.h
   include/apr_env.h
   include/apr_errno.h
@@ -185,6 +186,7 @@ SET(APR_SOURCES
   random/unix/sha2_glue.c
   shmem/win32/shm.c
   strings/apr_cpystrn.c
+  strings/apr_cstr.c
   strings/apr_fnmatch.c
   strings/apr_snprintf.c
   strings/apr_strings.c

Copied: apr/apr/branches/1.6.x/include/apr_cstr.h (from r1726928, apr/apr/trunk/include/apr_cstr.h)
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/include/apr_cstr.h?p2=apr/apr/branches/1.6.x/include/apr_cstr.h&p1=apr/apr/trunk/include/apr_cstr.h&r1=1726928&r2=1733488&rev=1733488&view=diff
==============================================================================
--- apr/apr/trunk/include/apr_cstr.h (original)
+++ apr/apr/branches/1.6.x/include/apr_cstr.h Thu Mar  3 16:11:16 2016
@@ -145,8 +145,10 @@ char * apr_cstr_join(const apr_array_hea
 #endif
 
 /**
- * Compare two strings @a atr1 and @a atr2, treating case-equivalent
- * unaccented Latin (C/POSIX ASCII subset) alpha characters as equal.
+ * Perform a case-insensitive comparison of two strings @a atr1 and @a atr2,
+ * treating upper and lower case values of the 26 standard C/POSIX alphabetic
+ * characters as equivalent. Extended latin characters outside of this set
+ * are treated as unique octets, irrespective of the current locale.
  *
  * Returns in integer greater than, equal to, or less than 0,
  * according to whether @a str1 is considered greater than, equal to,
@@ -157,9 +159,10 @@ char * apr_cstr_join(const apr_array_hea
 int apr_cstr_casecmp(const char *str1, const char *str2);
 
 /**
- * Compare two strings @a atr1 and @a atr2 of @n (or shorter) length,
- * treating case-equivalent unaccented Latin (C/POSIX ASCII subset)
- * alpha characters as equal.
+ * Perform a case-insensitive comparison of two strings @a atr1 and @a atr2,
+ * treating upper and lower case values of the 26 standard C/POSIX alphabetic
+ * characters as equivalent. Extended latin characters outside of this set
+ * are treated as unique octets, irrespective of the current locale.
  *
  * Returns in integer greater than, equal to, or less than 0,
  * according to whether @a str1 is considered greater than, equal to,

Modified: apr/apr/branches/1.6.x/include/apr_errno.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/include/apr_errno.h?rev=1733488&r1=1733487&r2=1733488&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/include/apr_errno.h (original)
+++ apr/apr/branches/1.6.x/include/apr_errno.h Thu Mar  3 16:11:16 2016
@@ -840,6 +840,13 @@ APR_DECLARE(char *) apr_strerror(apr_sta
 #define APR_EOPNOTSUPP    (APR_OS_START_CANONERR + 28)
 #endif
 
+/** @see APR_STATUS_IS_ERANGE */
+#ifdef ERANGE
+#define APR_ERANGE ERANGE
+#else
+#define APR_ERANGE          (APR_OS_START_CANONERR + 29)
+#endif
+
 /** @} */
 
 #if defined(OS2) && !defined(DOXYGEN)
@@ -986,6 +993,7 @@ APR_DECLARE(char *) apr_strerror(apr_sta
                 || (s) == APR_OS_START_SYSERR + SOCEAFNOSUPPORT)
 #define APR_STATUS_IS_EOPNOTSUPP(s)     ((s) == APR_EOPNOTSUPP \
                 || (s) == APR_OS_START_SYSERR + SOCEOPNOTSUPP)
+#define APR_STATUS_IS_ERANGE(s)         ((s) == APR_ERANGE)
 
 /*
     Sorry, too tired to wrap this up for OS2... feel free to
@@ -1132,6 +1140,7 @@ APR_DECLARE(char *) apr_strerror(apr_sta
                 || (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT)
 #define APR_STATUS_IS_EOPNOTSUPP(s)     ((s) == APR_EOPNOTSUPP \
                 || (s) == APR_OS_START_SYSERR + WSAEOPNOTSUPP)
+#define APR_STATUS_IS_ERANGE(s)         ((s) == APR_ERANGE)
 
 #elif defined(NETWARE) && defined(USE_WINSOCK) && !defined(DOXYGEN) /* !defined(OS2)
&& !defined(WIN32) */
 
@@ -1195,6 +1204,7 @@ APR_DECLARE(char *) apr_strerror(apr_sta
                 || (s) == APR_OS_START_SYSERR + WSAEAFNOSUPPORT)
 #define APR_STATUS_IS_EOPNOTSUPP(s)     ((s) == APR_EOPNOTSUPP \
                 || (s) == APR_OS_START_SYSERR + WSAEOPNOTSUPP)
+#define APR_STATUS_IS_ERANGE(s)         ((s) == APR_ERANGE)
 
 #else /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */
 
@@ -1316,6 +1326,9 @@ APR_DECLARE(char *) apr_strerror(apr_sta
 #define APR_STATUS_IS_EAFNOSUPPORT(s)    ((s) == APR_EAFNOSUPPORT)
 /** Socket operation not supported */
 #define APR_STATUS_IS_EOPNOTSUPP(s)      ((s) == APR_EOPNOTSUPP)
+
+/** Numeric value not representable */
+#define APR_STATUS_IS_ERANGE(s)         ((s) == APR_ERANGE)
 /** @} */
 
 #endif /* !defined(NETWARE) && !defined(OS2) && !defined(WIN32) */

Modified: apr/apr/branches/1.6.x/test/teststr.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/test/teststr.c?rev=1733488&r1=1733487&r2=1733488&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/test/teststr.c (original)
+++ apr/apr/branches/1.6.x/test/teststr.c Thu Mar  3 16:11:16 2016
@@ -26,6 +26,7 @@
 
 #include "apr_general.h"
 #include "apr_strings.h"
+#include "apr_cstr.h"
 #include "apr_errno.h"
 
 /* I haven't bothered to check for APR_ENOTIMPL here, AFAIK, all string
@@ -382,6 +383,17 @@ static void snprintf_overflow(abts_case
     ABTS_TRUE(tc, buf[2] == '4' && buf[3] == '2');
 }
 
+static void skip_prefix(abts_case *tc, void *data)
+{
+    ABTS_STR_EQUAL(tc, apr_cstr_skip_prefix("12345", "12345"), "");
+    ABTS_STR_EQUAL(tc, apr_cstr_skip_prefix("12345", "123"),   "45");
+    ABTS_STR_EQUAL(tc, apr_cstr_skip_prefix("12345", ""),      "12345");
+    ABTS_STR_EQUAL(tc, apr_cstr_skip_prefix("12345", "23"),    NULL);
+    ABTS_STR_EQUAL(tc, apr_cstr_skip_prefix("1",     "12"),    NULL);
+    ABTS_STR_EQUAL(tc, apr_cstr_skip_prefix("",      ""),      "");
+    ABTS_STR_EQUAL(tc, apr_cstr_skip_prefix("",      "12"),    NULL);
+}
+
 abts_suite *teststr(abts_suite *suite)
 {
     suite = ADD_SUITE(suite)
@@ -399,6 +411,7 @@ abts_suite *teststr(abts_suite *suite)
     abts_run_test(suite, string_strfsize, NULL);
     abts_run_test(suite, string_cpystrn, NULL);
     abts_run_test(suite, snprintf_overflow, NULL);
+    abts_run_test(suite, skip_prefix, NULL);
 
     return suite;
 }



Mime
View raw message