@matheusbsbs / matheus-bagliano / commits / 96bc4de85c
Fork 0

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>

Petr Baudis committed Jul 26, 2006 at 03:03 UTC 96bc4de85cf810db5c7cd94bf0688a98a64a0bc7
1 file changed +10 -4
perl/private-Error.pm
+10 -4
@@ -43,8 +43,6 @@ $Error::ObjectifyCallback = \&throw_Error_Simple;
43
44 # Exported subs are defined in Error::subs
45
46 -use Scalar::Util ();
47 -
46 sub import {
47 shift;
48 local $Exporter::ExportLevel = $Exporter::ExportLevel + 1;
@@ -290,6 +288,14 @@ use vars qw(@EXPORT_OK @ISA %EXPORT_TAGS);
288
289 @ISA = qw(Exporter);
290
291 +
292 +sub blessed {
293 + my $item = shift;
294 + local $@; # don't kill an outer $@
295 + ref $item and eval { $item->can('can') };
296 +}
297 +
298 +
299 sub run_clauses ($$$\@) {
300 my($clauses,$err,$wantarray,$result) = @_;
301 my $code = undef;
@@ -312,7 +318,7 @@ sub run_clauses ($$$\@) {
318 $i -= 2;
319 next CATCHLOOP;
320 }
315 - elsif(Scalar::Util::blessed($err) && $err->isa($pkg)) {
321 + elsif(blessed($err) && $err->isa($pkg)) {
322 $code = $catch->[$i+1];
323 while(1) {
324 my $more = 0;
@@ -421,7 +427,7 @@ sub try (&;$) {
427
428 if (defined($err))
429 {
424 - if (Scalar::Util::blessed($err) && $err->can('throw'))
430 + if (blessed($err) && $err->can('throw'))
431 {
432 throw $err;
433 }