git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Baudis <pasky@suse.cz>
To: Junio C Hamano <junkio@cox.net>
Cc: <git@vger.kernel.org>
Subject: [PATCH] Eliminate Scalar::Util usage from private-Error.pm
Date: Wed, 26 Jul 2006 03:03:58 +0200	[thread overview]
Message-ID: <20060726010358.20964.80443.stgit@machine> (raw)
In-Reply-To: <Pine.LNX.4.63.0607251809340.29667@wbgn013.biozentrum.uni-wuerzburg.de>

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>
---

 perl/private-Error.pm |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/perl/private-Error.pm b/perl/private-Error.pm
index ebd0749..8fff866 100644
--- a/perl/private-Error.pm
+++ b/perl/private-Error.pm
@@ -43,8 +43,6 @@ sub throw_Error_Simple
 
 # Exported subs are defined in Error::subs
 
-use Scalar::Util ();
-
 sub import {
     shift;
     local $Exporter::ExportLevel = $Exporter::ExportLevel + 1;
@@ -290,6 +288,14 @@ use vars qw(@EXPORT_OK @ISA %EXPORT_TAGS
 
 @ISA = qw(Exporter);
 
+
+sub blessed {
+	my $item = shift;
+	local $@; # don't kill an outer $@
+	ref $item and eval { $item->can('can') };
+}
+
+
 sub run_clauses ($$$\@) {
     my($clauses,$err,$wantarray,$result) = @_;
     my $code = undef;
@@ -312,7 +318,7 @@ sub run_clauses ($$$\@) {
 		    $i -= 2;
 		    next CATCHLOOP;
 		}
-		elsif(Scalar::Util::blessed($err) && $err->isa($pkg)) {
+		elsif(blessed($err) && $err->isa($pkg)) {
 		    $code = $catch->[$i+1];
 		    while(1) {
 			my $more = 0;
@@ -421,7 +427,7 @@ sub try (&;$) {
 
     if (defined($err))
     {
-        if (Scalar::Util::blessed($err) && $err->can('throw'))
+        if (blessed($err) && $err->can('throw'))
         {
             throw $err;
         }

  reply	other threads:[~2006-07-26  1:04 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-25 11:57 [PATCH] cvsserver: avoid warning about active db handles Johannes Schindelin
2006-07-25 12:07 ` Martin Langhoff (CatalystIT)
2006-07-25 14:53   ` Johannes Schindelin
2006-07-25 15:52     ` Petr Baudis
2006-07-25 16:10       ` Git.xs problem, was " Johannes Schindelin
2006-07-26  1:03         ` Petr Baudis [this message]
2006-07-26  2:01           ` [PATCH] Eliminate Scalar::Util usage from private-Error.pm Johannes Schindelin
2006-07-26  2:03             ` Johannes Schindelin
2006-07-26  2:11               ` Petr Baudis
2006-07-26  2:26                 ` Johannes Schindelin
2006-07-26  2:10             ` Petr Baudis
2006-07-26  2:25               ` Johannes Schindelin
2006-07-26 13:35                 ` Jakub Narebski
2006-07-26 15:17                   ` Johannes Schindelin
2006-07-26 17:59                     ` Luben Tuikov
2006-07-27 12:47                     ` Randal L. Schwartz
2006-07-27 14:00                       ` Johannes Schindelin
2006-07-27 14:22                         ` Randal L. Schwartz
2006-07-27 14:32                           ` Johannes Schindelin
2006-07-26 21:34                 ` Petr Baudis
     [not found]           ` <7vhd15cfaj.fsf@assigned-by-dhcp.cox.net>
2006-07-26  2:15             ` Petr Baudis
  -- strict thread matches above, loose matches on Subject: below --
2006-07-10 13:00 Perl gurus: why do we need Scalar::Util? Petr Baudis
2006-07-11  0:53 ` [PATCH] Eliminate Scalar::Util usage from private-Error.pm Petr Baudis
2006-07-11  1:38   ` Randal L. Schwartz
2006-07-11  1:40     ` Randal L. Schwartz
2006-07-11  1:42       ` Randal L. Schwartz
2006-07-11  1:57   ` Junio C Hamano
2006-07-11  3:38     ` Randal L. Schwartz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060726010358.20964.80443.stgit@machine \
    --to=pasky@suse.cz \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).