summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1998-11-27 15:12:01 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-11-27 15:12:01 +0000
commit62f274bf15fc9068424c6964230fb6bf80a54c09 (patch)
tree4a223b1110c6e752bc6a3dc39eb1306daa92a487
parent3aa35033d09cb8971f2cf3a68ba9828dca8868e7 (diff)
downloadperl-62f274bf15fc9068424c6964230fb6bf80a54c09.tar.gz
integrate change#2315 from maint-5.005
p4raw-link: @2315 on //depot/maint-5.005/perl: 7a4920e67d1e2d67a4397a908141c6608866ebb0 p4raw-id: //depot/perl@2327 p4raw-integrated: from //depot/maint-5.005/perl@2326 'ignore' op.c (@2310..) 'merge in' sv.c (@2174..)
-rw-r--r--sv.c17
-rwxr-xr-xt/op/sort.t14
2 files changed, 21 insertions, 10 deletions
diff --git a/sv.c b/sv.c
index 876ef0785d..95c75da355 100644
--- a/sv.c
+++ b/sv.c
@@ -3902,14 +3902,19 @@ sv_2cv(SV *sv, HV **st, GV **gvp, I32 lref)
SV **sp = &sv; /* Used in tryAMAGICunDEREF macro. */
tryAMAGICunDEREF(to_cv);
- cv = (CV*)SvRV(sv);
- if (SvTYPE(cv) != SVt_PVCV)
+ sv = SvRV(sv);
+ if (SvTYPE(sv) == SVt_PVCV) {
+ cv = (CV*)sv;
+ *gvp = Nullgv;
+ *st = CvSTASH(cv);
+ return cv;
+ }
+ else if(isGV(sv))
+ gv = (GV*)sv;
+ else
croak("Not a subroutine reference");
- *gvp = Nullgv;
- *st = CvSTASH(cv);
- return cv;
}
- if (isGV(sv))
+ else if (isGV(sv))
gv = (GV*)sv;
else
gv = gv_fetchpv(SvPV(sv, PL_na), lref, SVt_PVCV);
diff --git a/t/op/sort.t b/t/op/sort.t
index aca99a629d..df8d434741 100755
--- a/t/op/sort.t
+++ b/t/op/sort.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..27\n";
+print "1..29\n";
sub backwards { $a lt $b ? 1 : $a gt $b ? -1 : 0 }
@@ -127,6 +127,7 @@ print $@ ? "not ok 21\n# $@" : "ok 21\n";
{
my $sortsub = \&backwards;
my $sortglob = *backwards;
+ my $sortglobr = \*backwards;
my $sortname = 'backwards';
@b = sort $sortsub 4,1,3,2;
print ("@b" eq '4 3 2 1' ? "ok 22\n" : "not ok 22 |@b|\n");
@@ -134,17 +135,22 @@ print $@ ? "not ok 21\n# $@" : "ok 21\n";
print ("@b" eq '4 3 2 1' ? "ok 23\n" : "not ok 23 |@b|\n");
@b = sort $sortname 4,1,3,2;
print ("@b" eq '4 3 2 1' ? "ok 24\n" : "not ok 24 |@b|\n");
+ @b = sort $sortglobr 4,1,3,2;
+ print ("@b" eq '4 3 2 1' ? "ok 25\n" : "not ok 25 |@b|\n");
}
{
local $sortsub = \&backwards;
local $sortglob = *backwards;
+ local $sortglobr = \*backwards;
local $sortname = 'backwards';
@b = sort $sortsub 4,1,3,2;
- print ("@b" eq '4 3 2 1' ? "ok 25\n" : "not ok 22 |@b|\n");
+ print ("@b" eq '4 3 2 1' ? "ok 26\n" : "not ok 26 |@b|\n");
@b = sort $sortglob 4,1,3,2;
- print ("@b" eq '4 3 2 1' ? "ok 26\n" : "not ok 23 |@b|\n");
+ print ("@b" eq '4 3 2 1' ? "ok 27\n" : "not ok 27 |@b|\n");
@b = sort $sortname 4,1,3,2;
- print ("@b" eq '4 3 2 1' ? "ok 27\n" : "not ok 24 |@b|\n");
+ print ("@b" eq '4 3 2 1' ? "ok 28\n" : "not ok 28 |@b|\n");
+ @b = sort $sortglobr 4,1,3,2;
+ print ("@b" eq '4 3 2 1' ? "ok 29\n" : "not ok 29 |@b|\n");
}