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: Tue, 11 Jul 2006 02:53:54 +0200 [thread overview]
Message-ID: <20060711005354.5911.62525.stgit@machine.or.cz> (raw)
In-Reply-To: <20060710130046.GW29115@pasky.or.cz>
We used just the blessed() routine so steal it from Scalar/Util.pm. ;-)
(Unfortunately, Scalar::Util is not bundled with older Perl versions.)
Signed-off-by: Petr Baudis <pasky@suse.cz>
---
perl/private-Error.pm | 20 ++++++++++++++++----
1 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/perl/private-Error.pm b/perl/private-Error.pm
index ebd0749..848e82b 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,20 @@ use vars qw(@EXPORT_OK @ISA %EXPORT_TAGS
@ISA = qw(Exporter);
+
+# Stolen from Scalar::Util:
+
+# Hope nobody defines a sub by this name
+sub UNIVERSAL::a_sub_not_likely_to_be_here { ref($_[0]) }
+
+sub blessed ($) {
+ local($@, $SIG{__DIE__}, $SIG{__WARN__});
+ length(ref($_[0]))
+ ? eval { $_[0]->a_sub_not_likely_to_be_here }
+ : undef
+}
+
+
sub run_clauses ($$$\@) {
my($clauses,$err,$wantarray,$result) = @_;
my $code = undef;
@@ -312,7 +324,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 +433,7 @@ sub try (&;$) {
if (defined($err))
{
- if (Scalar::Util::blessed($err) && $err->can('throw'))
+ if (blessed($err) && $err->can('throw'))
{
throw $err;
}
next prev parent reply other threads:[~2006-07-11 0:54 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-10 11:44 Perl gurus: why do we need Scalar::Util? Johannes Schindelin
2006-07-10 13:00 ` Petr Baudis
2006-07-11 0:53 ` Petr Baudis [this message]
2006-07-11 1:38 ` [PATCH] Eliminate Scalar::Util usage from private-Error.pm 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
2006-07-10 13:28 ` Perl gurus: why do we need Scalar::Util? Randal L. Schwartz
2006-07-10 14:29 ` Petr Baudis
-- strict thread matches above, loose matches on Subject: below --
2006-07-25 16:10 Git.xs problem, was Re: [PATCH] cvsserver: avoid warning about active db handles Johannes Schindelin
2006-07-26 1:03 ` [PATCH] Eliminate Scalar::Util usage from private-Error.pm Petr Baudis
2006-07-26 2:01 ` 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
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=20060711005354.5911.62525.stgit@machine.or.cz \
--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).