hi

I've implemented apr_table_compress, which was recently added to the APR table API.

the only thing I'm unsure about is what our position is on APR changes - can we rely on the autogeneration code for this (and perhaps other recent additions), breaking back compat, or do we need some kind of wrapper to protect users with older httpd/apr versions?

--Geoff
Index: docs/api/APR/Table.pod
===================================================================
RCS file: /home/cvspublic/modperl-docs/src/docs/2.0/api/APR/Table.pod,v
retrieving revision 1.2
diff -u -r1.2 Table.pod
--- docs/api/APR/Table.pod      5 Jun 2003 06:37:39 -0000       1.2
+++ docs/api/APR/Table.pod      18 Aug 2003 19:40:29 -0000
@@ -250,6 +250,22 @@
 
 return: A new table containing all of the data from the two passed in
 
+=item * compress()
+                                                                                      
              
+  overlap($table, $flags);
+                                                                                      
              
+Compress the data in C<$table>.
+                                                                                      
              
+param C<$table>: The table to add the data to.
+                                                                                      
              
+param C<$flags>: How to compress C<$table>.
+                                                                                      
              
+When C<$flags> == C<APR_OVERLAP_TABLES_SET>, each key will be 
+set to the last value seen for that key.
+                                                                                      
              
+When C<$flags> == C<APR_OVERLAP_TABLES_MERGE>, multiple values
+for the same key are flattened into a comma-separated list.
+                                                                                      
              
 =back
 
 =head2 TIE Interface
Index: t/response/TestAPR/table.pm
===================================================================
RCS file: /home/cvspublic/modperl-2.0/t/response/TestAPR/table.pm,v
retrieving revision 1.5
diff -u -r1.5 table.pm
--- t/response/TestAPR/table.pm 11 Apr 2002 11:08:44 -0000      1.5
+++ t/response/TestAPR/table.pm 18 Aug 2003 19:40:30 -0000
@@ -8,6 +8,7 @@
 use APR::Table ();
 
 use Apache::Const -compile => 'OK';
+use APR::Const -compile => 'OVERLAP_TABLES_MERGE';
 
 my $filter_count;
 my $TABLE_SIZE = 20;
@@ -15,7 +16,7 @@
 sub handler {
     my $r = shift;
 
-    plan $r, tests => 17;
+    plan $r, tests => 21;
 
     my $table = APR::Table::make($r->pool, $TABLE_SIZE);
 
@@ -97,6 +98,30 @@
         }
         ok $filter_count == $TABLE_SIZE;
     }
+
+    # overlay and compress routines
+    my $base = APR::Table::make($r->pool, $TABLE_SIZE);
+    my $add = APR::Table::make($r->pool, $TABLE_SIZE);
+
+    $base->set(foo => 'one');
+    $base->add(foo => 'two');
+
+    $add->add(foo => 'three');
+    $add->add(bar => 'beer');
+
+    my $overlay = $base->overlay($add, $r->pool);
+
+    my @foo = $overlay->get('foo');
+    my @bar = $overlay->get('bar');
+
+    ok @foo == 3;
+    ok $bar[0] eq 'beer';
+
+    $overlay->compress(APR::OVERLAP_TABLES_MERGE);
+
+    # XXX is insertion order guaranteed on all platforms?
+    ok $overlay->get('foo') =~ m!(\w+, ){2}\w+!;
+    ok $overlay->get('bar') eq 'beer';
 
     Apache::OK;
 }
Index: xs/maps/apr_functions.map
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/maps/apr_functions.map,v
retrieving revision 1.52
diff -u -r1.52 apr_functions.map
--- xs/maps/apr_functions.map   15 Apr 2003 08:39:52 -0000      1.52
+++ xs/maps/apr_functions.map   18 Aug 2003 19:40:30 -0000
@@ -236,6 +236,7 @@
  apr_table_make
  apr_table_overlap
  apr_table_overlay | | base, overlay, p
+ apr_table_compress
  apr_table_add
 -apr_table_addn
  apr_table_do | mpxs_ | ...
Index: xs/tables/current/Apache/FunctionTable.pm
===================================================================
RCS file: /home/cvspublic/modperl-2.0/xs/tables/current/Apache/FunctionTable.pm,v
retrieving revision 1.43
diff -u -r1.43 FunctionTable.pm
--- xs/tables/current/Apache/FunctionTable.pm   15 Apr 2003 03:47:29 -0000      1.43
+++ xs/tables/current/Apache/FunctionTable.pm   18 Aug 2003 19:40:39 -0000
@@ -12372,6 +12372,20 @@
   },
   {
     'return_type' => 'void',
+    'name' => 'apr_table_compress',
+    'args' => [
+      {
+        'type' => 'apr_table_t *',
+        'name' => 'a'
+      },
+      {
+        'type' => 'unsigned',
+        'name' => 'flags'
+      }
+    ]
+  },
+  {
+    'return_type' => 'void',
     'name' => 'apr_table_set',
     'args' => [
       {

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to