Return-Path: X-Original-To: apmail-apr-commits-archive@www.apache.org Delivered-To: apmail-apr-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1A2C019550 for ; Mon, 7 Mar 2016 23:36:27 +0000 (UTC) Received: (qmail 73751 invoked by uid 500); 7 Mar 2016 23:36:27 -0000 Delivered-To: apmail-apr-commits-archive@apr.apache.org Received: (qmail 73682 invoked by uid 500); 7 Mar 2016 23:36:26 -0000 Mailing-List: contact commits-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: Reply-To: dev@apr.apache.org List-Id: Delivered-To: mailing list commits@apr.apache.org Received: (qmail 73670 invoked by uid 99); 7 Mar 2016 23:36:26 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Mar 2016 23:36:26 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 616CDC0679 for ; Mon, 7 Mar 2016 23:36:26 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.471 X-Spam-Level: * X-Spam-Status: No, score=1.471 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.329] autolearn=disabled Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id D3vG_sqBzVtD for ; Mon, 7 Mar 2016 23:36:25 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTP id CD9635FB1A for ; Mon, 7 Mar 2016 23:36:24 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 29A1FE0057 for ; Mon, 7 Mar 2016 23:36:24 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 1EB373A01D7 for ; Mon, 7 Mar 2016 23:36:24 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1734004 - in /apr/apr/trunk: CHANGES include/apr_tables.h tables/apr_tables.c test/testtable.c Date: Mon, 07 Mar 2016 23:36:23 -0000 To: commits@apr.apache.org From: minfrin@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160307233624.1EB373A01D7@svn01-us-west.apache.org> Author: minfrin Date: Mon Mar 7 23:36:23 2016 New Revision: 1734004 URL: http://svn.apache.org/viewvc?rev=1734004&view=rev Log: apr_table_overlap: Add APR_OVERLAP_TABLES_ADD to merge and set when overlapping tables. Modified: apr/apr/trunk/CHANGES apr/apr/trunk/include/apr_tables.h apr/apr/trunk/tables/apr_tables.c apr/apr/trunk/test/testtable.c Modified: apr/apr/trunk/CHANGES URL: http://svn.apache.org/viewvc/apr/apr/trunk/CHANGES?rev=1734004&r1=1734003&r2=1734004&view=diff ============================================================================== --- apr/apr/trunk/CHANGES [utf-8] (original) +++ apr/apr/trunk/CHANGES [utf-8] Mon Mar 7 23:36:23 2016 @@ -1,6 +1,9 @@ -*- coding: utf-8 -*- Changes for APR 2.0.0 + *) apr_table_overlap: Add APR_OVERLAP_TABLES_ADD to merge and set when + overlapping tables. [Graham Leggett] + *) apr_proc/global_mutex: Fix API regarding the native OS mutexes accessors from/to available APR mechanisms, adding the new functions apr_os_proc_mutex_get_ex() and apr_os_proc_mutex_set_ex() which give Modified: apr/apr/trunk/include/apr_tables.h URL: http://svn.apache.org/viewvc/apr/apr/trunk/include/apr_tables.h?rev=1734004&r1=1734003&r2=1734004&view=diff ============================================================================== --- apr/apr/trunk/include/apr_tables.h (original) +++ apr/apr/trunk/include/apr_tables.h Mon Mar 7 23:36:23 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/trunk/tables/apr_tables.c URL: http://svn.apache.org/viewvc/apr/apr/trunk/tables/apr_tables.c?rev=1734004&r1=1734003&r2=1734004&view=diff ============================================================================== --- apr/apr/trunk/tables/apr_tables.c (original) +++ apr/apr/trunk/tables/apr_tables.c Mon Mar 7 23:36:23 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/trunk/test/testtable.c URL: http://svn.apache.org/viewvc/apr/apr/trunk/test/testtable.c?rev=1734004&r1=1734003&r2=1734004&view=diff ============================================================================== --- apr/apr/trunk/test/testtable.c (original) +++ apr/apr/trunk/test/testtable.c Mon Mar 7 23:36:23 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; }