Stas Bekman <[EMAIL PROTECTED]> writes:
> Joe Schaefer wrote:
> > Stas Bekman <[EMAIL PROTECTED]> writes:
> >
> >> Hmm, what about storing the pointer to apreq_value_t as val
> > AFAICT, that helps nada.
>
> true, again because of newSVpv
>
> >>in the table and subclass get() to do what you want?
> > Just subclassing get() might work! At the moment
> > I'm concerned about how each() is implemented; does
> > each make a call to FETCH to get at the value? If so, how does it
> > handle multivalued keys?
>
> From the perltie manpage:
>
> FIRSTKEY and NEXTKEY implement the keys() and each() functions
> to iterate over all the keys.
Unfortunately that's a borked approach when multivalued
keys are present: values() and each() (in list context)
will always grab the first value instead of the
"current" one. The remark at the bottom of docs/api/APR/Table.pod
appears to be incorrect:
... The only exception to this is if you iterate over the list with
I<each>, then you can access all key-value pairs that share the same key.
See test below (tests 8 & 10 check the above assertion, and fail for me).
> looks like mpxs_APR__Table_NEXTKEY is correct, though we don't really
> have a test in t/response/TestAPR/table.pm for this.
It looks ok to me also- too bad the TIEHASH api doesn't have
EACH & VALUES subs.
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 5 Jun 2003 06:57:28 -0000
@@ -15,7 +15,7 @@
sub handler {
my $r = shift;
- plan $r, tests => 17;
+ plan $r, tests => 23;
my $table = APR::Table::make($r->pool, $TABLE_SIZE);
@@ -34,6 +34,12 @@
$array[0] eq 'bar' &&
$array[1] eq 'tar' &&
$array[2] eq 'kar';
+
+ for (0..2) {
+ ($a, $b) = each %$table;
+ ok $a eq 'foo';
+ ok $b eq $array[$_];
+ }
ok $table->unset('foo') || 1;
--
Joe Schaefer
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]