I'd suggest to change the argument to modperl_apr_func_not_implemented to be the httpd version and the apr version, so we can have:
#define modperl_apr_func_not_implemented(func, httpd_ver, apr_ver) \ { \ dTHX; \ Perl_croak(aTHX_ #func "() requires httpd/" #httpd_ver "and apr/"
#ver "or higher"); \ }
ok, here is an updated patch. when running under 2.0.46 you get this message for APR::Table::compress()
compress() requires httpd/2.0.47 and apr/0.9.4 or higher at /src/mod_perl-2.0/t/response/TestAPR/table.pm line 126.
the compress() specific tests are configured to not run (that was only a test :)
with 2.0.47 and 2.1 everything seems to work as expected.
--Geoff
Index: Changes
===================================================================
RCS file: /home/cvspublic/modperl-2.0/Changes,v
retrieving revision 1.208
diff -u -r1.208 Changes
--- Changes 11 Aug 2003 20:34:56 -0000 1.208
+++ Changes 19 Aug 2003 16:32:19 -0000
@@ -12,6 +12,8 @@
=item 1.99_10-dev
+add ap_table_compress() to APR::Table. [Geoffrey Young]
+
alter stacked handler interface so that mod_perl follows Apache
as closely as possible with respect to VOID/RUN_FIRST/RUN_ALL
handler types. now, for phases where OK ends the Apache
Index: docs/api/APR/Const.pod
===================================================================
RCS file: /home/cvspublic/modperl-docs/src/docs/2.0/api/APR/Const.pod,v
retrieving revision 1.1
diff -u -r1.1 Const.pod
--- docs/api/APR/Const.pod 15 May 2003 04:04:05 -0000 1.1
+++ docs/api/APR/Const.pod 19 Aug 2003 16:32:20 -0000
@@ -565,7 +565,8 @@
use APR::Const -compile qw(:table);
-The C<:table> group is for XXX constants.
+The C<:table> group is for C<overlap()> and C<compress()> constants.
+See C<L<APR::Table|docs::2.0::api::APR::Table>> for details.
=head3 C<APR::OVERLAP_TABLES_MERGE>
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 19 Aug 2003 16:32:20 -0000
@@ -224,10 +224,10 @@
param C<$flags>: How to add the C<$table_b> to C<$table_a>.
-When C<$flags> == C<APR_OVERLAP_TABLES_SET>, if another element
+When C<$flags> == C<APR::OVERLAP_TABLES_SET>, if another element
already exists with the same key, this will over-write the old data.
-When C<$flags> == C<APR_OVERLAP_TABLES_MERGE>, the key/value pair from
+When C<$flags> == C<APR::OVERLAP_TABLES_MERGE>, the key/value pair from
C<$table_b> is added, regardless of whether there is another element
with the same key in C<$table_a>.
@@ -249,6 +249,29 @@
param C<$table_base>: The table to add at the end of the new table
return: A new table containing all of the data from the two passed in
+
+=item * compress()
+
+ compress($table, $flag);
+
+Compress the data in C<$table>. This function takes duplicate
+table entries and flattens them into a single entry. The
+flattening behavior is controlled by the flag.
+
+param C<$table>: The table to add the data to.
+
+param C<$flag>: How to compress C<$table>.
+
+When C<$flag> == C<APR::OVERLAP_TABLES_SET>, each key will be
+set to the last value seen for that key. For example, given
+key/value pairs 'foo => bar' and 'foo => baz', 'foo' would
+have a final value of 'baz' after compression - the 'bar'
+value would be lost.
+
+When C<$flag> == C<APR::OVERLAP_TABLES_MERGE>, multiple values
+for the same key are flattened into a comma-separated list.
+Given key/value pairs 'foo => bar' and 'foo => baz', 'foo'
+would have a final value of 'bar, baz' after compression.
=back
Index: src/modules/perl/modperl_apache_compat.c
===================================================================
RCS file: /home/cvspublic/modperl-2.0/src/modules/perl/modperl_apache_compat.c,v
retrieving revision 1.1
diff -u -r1.1 modperl_apache_compat.c
--- src/modules/perl/modperl_apache_compat.c 24 Apr 2003 01:51:37 -0000 1.1
+++ src/modules/perl/modperl_apache_compat.c 19 Aug 2003 16:32:20 -0000
@@ -1,6 +1,6 @@
#include "mod_perl.h"
-/* back compat adjustements for older Apache versions (2.0.36+) */
+/* back compat adjustements for older Apache versions */
/* pre-APR_0_9_0 (APACHE_2_0_40) */
#if APR_MAJOR_VERSION == 0 && APR_MINOR_VERSION == 9 && \
@@ -9,14 +9,28 @@
/* added in APACHE_2_0_40/APR_0_9_0 */
apr_status_t apr_socket_timeout_get(apr_socket_t *sock, apr_interval_time_t *t)
{
- modperl_apr_func_not_implemented(timeout_get, 0.9.0);
+ modperl_apr_func_not_implemented(timeout_get, 2.0.40, 0.9.0);
return APR_ENOTIMPL;
}
apr_status_t apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t)
{
- modperl_apr_func_not_implemented(timeout_set, 0.9.0);
+ modperl_apr_func_not_implemented(timeout_set, 2.0.40, 0.9.0);
return APR_ENOTIMPL;
}
#endif /* pre-APR_0_9_0 (APACHE_2_0_40) */
+
+/* pre-APR_0_9_5 (APACHE_2_0_47)
+ * both 2.0.46 and 2.0.47 shipped with 0.9.4 -
+ * we need the one that shipped with 2.0.47,
+ which is major mmn 20020903, minor mmn 4 */
+#if ! AP_MODULE_MAGIC_AT_LEAST(20020903,4)
+
+/* added in APACHE_2_0_47/APR_0_9_4 */
+void apr_table_compress(apr_table_t *t, unsigned flags)
+{
+ modperl_apr_func_not_implemented(compress, 2.0.47, 0.9.4);
+}
+
+#endif /* pre-APR_0_9_5 (APACHE_2_0_47) */
Index: src/modules/perl/modperl_apache_compat.h
===================================================================
RCS file: /home/cvspublic/modperl-2.0/src/modules/perl/modperl_apache_compat.h,v
retrieving revision 1.1
diff -u -r1.1 modperl_apache_compat.h
--- src/modules/perl/modperl_apache_compat.h 24 Apr 2003 01:51:37 -0000 1.1
+++ src/modules/perl/modperl_apache_compat.h 19 Aug 2003 16:32:22 -0000
@@ -1,7 +1,7 @@
#ifndef MODPERL_APACHE_COMPAT_H
#define MODPERL_APACHE_COMPAT_H
-/* back compat adjustements for older Apache versions (2.0.36+) */
+/* back compat adjustements for older Apache versions */
#if !APR_HAS_THREADS
typedef unsigned long apr_os_thread_t;
@@ -29,16 +29,28 @@
#define apr_socket_opt_get apr_getsocketopt
#define apr_socket_opt_set apr_setsocketopt
-#define modperl_apr_func_not_implemented(func, ver) \
- { \
- dTHX; \
- Perl_croak(aTHX_ #func "() requires APR version " #ver " or higher"); \
- }
-
/* added in APACHE_2_0_40/APR_0_9_0 */
apr_status_t apr_socket_timeout_get(apr_socket_t *sock, apr_interval_time_t *t);
apr_status_t apr_socket_timeout_set(apr_socket_t *sock, apr_interval_time_t t);
#endif /* pre-APR_0_9_0 (APACHE_2_0_40) */
+
+/* pre-APR_0_9_5 (APACHE_2_0_47)
+ * both 2.0.46 and 2.0.47 shipped with 0.9.4 -
+ * we need the one that shipped with 2.0.47,
+ which is major mmn 20020903, minor mmn 4 */
+#if ! AP_MODULE_MAGIC_AT_LEAST(20020903,4)
+
+/* added in APACHE_2_0_47/APR_0_9_4 */
+void apr_table_compress(apr_table_t *t, unsigned flags);
+
+#endif /* pre-APR_0_9_5 (APACHE_2_0_47) */
+
+#define modperl_apr_func_not_implemented(func, httpd_ver, apr_ver) \
+ { \
+ dTHX; \
+ Perl_croak(aTHX_ #func "() requires httpd/" #httpd_ver \
+ " and apr/" #apr_ver " or higher"); \
+ }
#endif /* MODPERL_APACHE_COMPAT_H */
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 19 Aug 2003 16:32:23 -0000
@@ -8,14 +8,20 @@
use APR::Table ();
use Apache::Const -compile => 'OK';
+use APR::Const -compile => 'OVERLAP_TABLES_MERGE';
my $filter_count;
my $TABLE_SIZE = 20;
+use constant HAVE_APACHE_2_0_47 => have_min_apache_version('2.0.47');
+
sub handler {
my $r = shift;
- plan $r, tests => 17;
+ my $tests = 19;
+ $tests += 2 if HAVE_APACHE_2_0_47;
+
+ plan $r, tests => $tests;
my $table = APR::Table::make($r->pool, $TABLE_SIZE);
@@ -96,6 +102,32 @@
my_filter($key, $table->{$key});
}
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';
+
+ if (HAVE_APACHE_2_0_47) {
+ $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 19 Aug 2003 16:32:23 -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 19 Aug 2003 16:32:31 -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]
