You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by mi...@apache.org on 2016/03/08 00:36:40 UTC
svn commit: r1734005 - in /apr/apr/branches/1.6.x: CHANGES
include/apr_tables.h tables/apr_tables.c test/testtable.c
Author: minfrin
Date: Mon Mar 7 23:36:40 2016
New Revision: 1734005
URL: http://svn.apache.org/viewvc?rev=1734005&view=rev
Log:
apr_table_overlap: Add APR_OVERLAP_TABLES_ADD to merge and set when
overlapping tables.
Modified:
apr/apr/branches/1.6.x/CHANGES
apr/apr/branches/1.6.x/include/apr_tables.h
apr/apr/branches/1.6.x/tables/apr_tables.c
apr/apr/branches/1.6.x/test/testtable.c
Modified: apr/apr/branches/1.6.x/CHANGES
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/CHANGES?rev=1734005&r1=1734004&r2=1734005&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/CHANGES [utf-8] (original)
+++ apr/apr/branches/1.6.x/CHANGES [utf-8] Mon Mar 7 23:36:40 2016
@@ -1,6 +1,9 @@
-*- coding: utf-8 -*-
Changes for APR 1.6.0
+ *) apr_table_overlap: Add APR_OVERLAP_TABLES_ADD to merge and set when
+ overlapping tables. [Graham Leggett]
+
*) locks: Introduce apr_{thread,proc,global}_mutex_timedlock().
[Yann Ylavic]
Modified: apr/apr/branches/1.6.x/include/apr_tables.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/include/apr_tables.h?rev=1734005&r1=1734004&r2=1734005&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/include/apr_tables.h (original)
+++ apr/apr/branches/1.6.x/include/apr_tables.h Mon Mar 7 23:36:40 2016
@@ -436,6 +436,8 @@ APR_DECLARE(int) apr_table_vdo(apr_table
#define APR_OVERLAP_TABLES_SET (0)
/** flag for overlap to use apr_table_mergen */
#define APR_OVERLAP_TABLES_MERGE (1)
+/** flag for overlap to use apr_table_addn */
+#define APR_OVERLAP_TABLES_ADD (2)
/**
* For each element in table b, either use setn or mergen to add the data
* to table a. Which method is used is determined by the flags passed in.
@@ -444,6 +446,7 @@ APR_DECLARE(int) apr_table_vdo(apr_table
* @param flags How to add the table to table a. One of:
* APR_OVERLAP_TABLES_SET Use apr_table_setn
* APR_OVERLAP_TABLES_MERGE Use apr_table_mergen
+ * APR_OVERLAP_TABLES_ADD Use apr_table_addn
* @remark When merging duplicates, the two values are concatenated,
* separated by the string ", ".
* @remark This function is highly optimized, and uses less memory and CPU cycles
@@ -461,6 +464,9 @@ APR_DECLARE(int) apr_table_vdo(apr_table
* if (flags & APR_OVERLAP_TABLES_MERGE) {
* apr_table_mergen(a, belt[i].key, belt[i].val);
* }
+ * else if (flags & APR_OVERLAP_TABLES_ADD) {
+ * apr_table_addn(a, belt[i].key, belt[i].val);
+ * }
* else {
* apr_table_setn(a, belt[i].key, belt[i].val);
* }
@@ -484,7 +490,8 @@ APR_DECLARE(void) apr_table_overlap(apr_
*
* @param t Table.
* @param flags APR_OVERLAP_TABLES_MERGE to merge, or
- * APR_OVERLAP_TABLES_SET to overwrite
+ * APR_OVERLAP_TABLES_SET to overwrite, or
+ * APR_OVERLAP_TABLES_ADD to add
* @remark When merging duplicates, the two values are concatenated,
* separated by the string ", ".
*/
Modified: apr/apr/branches/1.6.x/tables/apr_tables.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/tables/apr_tables.c?rev=1734005&r1=1734004&r2=1734005&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/tables/apr_tables.c (original)
+++ apr/apr/branches/1.6.x/tables/apr_tables.c Mon Mar 7 23:36:40 2016
@@ -1103,6 +1103,10 @@ APR_DECLARE(void) apr_table_compress(apr
int i;
int dups_found;
+ if (flags == APR_OVERLAP_TABLES_ADD) {
+ return;
+ }
+
if (t->a.nelts <= 1) {
return;
}
Modified: apr/apr/branches/1.6.x/test/testtable.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.6.x/test/testtable.c?rev=1734005&r1=1734004&r2=1734005&view=diff
==============================================================================
--- apr/apr/branches/1.6.x/test/testtable.c (original)
+++ apr/apr/branches/1.6.x/test/testtable.c Mon Mar 7 23:36:40 2016
@@ -199,6 +199,29 @@ static void table_overlap2(abts_case *tc
}
+static void table_overlap3(abts_case *tc, void *data)
+{
+ apr_pool_t *subp;
+ apr_table_t *t1, *t2;
+
+ apr_pool_create(&subp, p);
+
+ t1 = apr_table_make(subp, 1);
+ t2 = apr_table_make(p, 1);
+ apr_table_addn(t1, "t1", "one");
+ apr_table_addn(t1, "t1", "overlay");
+ apr_table_addn(t2, "t2", "two");
+ apr_table_addn(t2, "t2", "overlay");
+
+ apr_table_overlap(t1, t2, APR_OVERLAP_TABLES_ADD);
+
+ ABTS_INT_EQUAL(tc, 4, apr_table_elts(t1)->nelts);
+
+ ABTS_STR_EQUAL(tc, "one", apr_table_get(t1, "t1"));
+ ABTS_STR_EQUAL(tc, "two", apr_table_get(t1, "t2"));
+
+}
+
abts_suite *testtable(abts_suite *suite)
{
suite = ADD_SUITE(suite)
@@ -215,6 +238,7 @@ abts_suite *testtable(abts_suite *suite)
abts_run_test(suite, table_unset, NULL);
abts_run_test(suite, table_overlap, NULL);
abts_run_test(suite, table_overlap2, NULL);
+ abts_run_test(suite, table_overlap3, NULL);
return suite;
}