Eliminate Scalar::Util usage from private-Error.pm
We used just the blessed() routine so steal it from Scalar/Util.pm. Unfortunately, Scalar::Util is not bundled with older Perl versions. This is a newer much saner blessed() version by Randal L. Schwarz. Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
parent
7fb39d5f58
commit
96bc4de85c
@ -43,8 +43,6 @@ $Error::ObjectifyCallback = \&throw_Error_Simple;
|
|||||||
|
|
||||||
# Exported subs are defined in Error::subs
|
# Exported subs are defined in Error::subs
|
||||||
|
|
||||||
use Scalar::Util ();
|
|
||||||
|
|
||||||
sub import {
|
sub import {
|
||||||
shift;
|
shift;
|
||||||
local $Exporter::ExportLevel = $Exporter::ExportLevel + 1;
|
local $Exporter::ExportLevel = $Exporter::ExportLevel + 1;
|
||||||
@ -290,6 +288,14 @@ use vars qw(@EXPORT_OK @ISA %EXPORT_TAGS);
|
|||||||
|
|
||||||
@ISA = qw(Exporter);
|
@ISA = qw(Exporter);
|
||||||
|
|
||||||
|
|
||||||
|
sub blessed {
|
||||||
|
my $item = shift;
|
||||||
|
local $@; # don't kill an outer $@
|
||||||
|
ref $item and eval { $item->can('can') };
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub run_clauses ($$$\@) {
|
sub run_clauses ($$$\@) {
|
||||||
my($clauses,$err,$wantarray,$result) = @_;
|
my($clauses,$err,$wantarray,$result) = @_;
|
||||||
my $code = undef;
|
my $code = undef;
|
||||||
@ -312,7 +318,7 @@ sub run_clauses ($$$\@) {
|
|||||||
$i -= 2;
|
$i -= 2;
|
||||||
next CATCHLOOP;
|
next CATCHLOOP;
|
||||||
}
|
}
|
||||||
elsif(Scalar::Util::blessed($err) && $err->isa($pkg)) {
|
elsif(blessed($err) && $err->isa($pkg)) {
|
||||||
$code = $catch->[$i+1];
|
$code = $catch->[$i+1];
|
||||||
while(1) {
|
while(1) {
|
||||||
my $more = 0;
|
my $more = 0;
|
||||||
@ -421,7 +427,7 @@ sub try (&;$) {
|
|||||||
|
|
||||||
if (defined($err))
|
if (defined($err))
|
||||||
{
|
{
|
||||||
if (Scalar::Util::blessed($err) && $err->can('throw'))
|
if (blessed($err) && $err->can('throw'))
|
||||||
{
|
{
|
||||||
throw $err;
|
throw $err;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user