summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-04-27 20:34:24 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-04-27 20:34:24 +0000
commit8e664e1028b4453f9f359cddea96cf56ea4a7c51 (patch)
treef5077a0fef175d5a1e52380032a47e33f0be4a9c /pp_ctl.c
parent24944567cd431bac90d270c4c84c69294f9784d9 (diff)
downloadperl-8e664e1028b4453f9f359cddea96cf56ea4a7c51.tar.gz
allow sort() reentrancy (variant of patch suggested by
Hugo van der Sanden) p4raw-id: //depot/perl@5975
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 64c706ee36..2308d35814 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -883,15 +883,18 @@ PP(pp_sort)
CATCH_SET(TRUE);
PUSHSTACKi(PERLSI_SORT);
- if (PL_sortstash != stash) {
- PL_firstgv = gv_fetchpv("a", TRUE, SVt_PV);
- PL_secondgv = gv_fetchpv("b", TRUE, SVt_PV);
- PL_sortstash = stash;
+ if (!hasargs && !is_xsub) {
+ if (PL_sortstash != stash || !PL_firstgv || !PL_secondgv) {
+ SAVESPTR(PL_firstgv);
+ SAVESPTR(PL_secondgv);
+ PL_firstgv = gv_fetchpv("a", TRUE, SVt_PV);
+ PL_secondgv = gv_fetchpv("b", TRUE, SVt_PV);
+ PL_sortstash = stash;
+ }
+ SAVESPTR(GvSV(PL_firstgv));
+ SAVESPTR(GvSV(PL_secondgv));
}
- SAVESPTR(GvSV(PL_firstgv));
- SAVESPTR(GvSV(PL_secondgv));
-
PUSHBLOCK(cx, CXt_NULL, PL_stack_base);
if (!(PL_op->op_flags & OPf_SPECIAL)) {
cx->cx_type = CXt_SUB;