diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-04-27 20:34:24 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-04-27 20:34:24 +0000 |
commit | 8e664e1028b4453f9f359cddea96cf56ea4a7c51 (patch) | |
tree | f5077a0fef175d5a1e52380032a47e33f0be4a9c /pp_ctl.c | |
parent | 24944567cd431bac90d270c4c84c69294f9784d9 (diff) | |
download | perl-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.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -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; |