stas 01/10/01 02:04:11 Modified: lib/Apache compat.pm t/apache compat.t Log: - fix the bugs in header_{in|out} implementation: o handling key => undef ( == ->unset(key) ) o handling list context - remove the todo flags in previously failing sub-tests Submitted by: Philippe M. Chiasson <[EMAIL PROTECTED]> Reviewed by: Stas Bekman Revision Changes Path 1.15 +21 -6 modperl-2.0/lib/Apache/compat.pm Index: compat.pm =================================================================== RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- compat.pm 2001/09/28 17:15:07 1.14 +++ compat.pm 2001/10/01 09:04:10 1.15 @@ -54,33 +54,48 @@ package Apache::RequestRec; -sub table_set_get { +sub table_get_set { my($r, $table) = (shift, shift); my($key, $value) = @_; if (1 == @_) { - return $table->{$key}; + return wantarray() + ? ($table->get($key)) + : scalar($table->get($key)); } elsif (2 == @_) { - return $table->{$key} = $value; + if (defined $value) { + return wantarray() + ? ($table->set($key, $value)) + : scalar($table->set($key, $value)); + } + else { + return wantarray() + ? ($table->unset($key)) + : scalar($table->unset($key)); + } } elsif (0 == @_) { return $table; } else { my $name = (caller(1))[3]; - warn "Usage: $name([key [,val]])"; + warn "Usage: \$r->$name([key [,val]])"; } } sub header_out { my $r = shift; - return $r->table_set_get(scalar $r->headers_out, @_); + return wantarray() + ? ($r->table_get_set(scalar($r->headers_out), @_)) + : scalar($r->table_get_set(scalar($r->headers_out), @_)); } sub header_in { my $r = shift; - return $r->table_set_get(scalar $r->headers_in, @_); + return wantarray() + ? ($r->table_get_set(scalar($r->headers_in), @_)) + : scalar($r->table_get_set(scalar($r->headers_in), @_)); } sub register_cleanup { 1.3 +1 -1 modperl-2.0/t/apache/compat.t Index: compat.t =================================================================== RCS file: /home/cvs/modperl-2.0/t/apache/compat.t,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- compat.t 2001/09/29 19:33:39 1.2 +++ compat.t 2001/10/01 09:04:11 1.3 @@ -6,7 +6,7 @@ use Apache::TestUtil; use Apache::TestRequest; -plan tests => 11, todo => [5,7,9,11], \&have_lwp; +plan tests => 11, \&have_lwp; my $location = "/TestApache::compat";