In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/abd07ec01964fc49e914e765cdba6f27072decda?hp=1acab4c5e64e8d27d6452f7758b159adf276d017>
- Log ----------------------------------------------------------------- commit abd07ec01964fc49e914e765cdba6f27072decda Author: David Mitchell <[email protected]> Date: Tue Jan 24 14:43:05 2017 +0000 handle op_pv better in op_clear() and op_dump() In op_clear(), the ops with labels stored in the op_pv field (OP_NEXT etc) fall-through to the OP_TRANS/OP_TRANSR code, which determines whether to free op_pv based on the OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF flags, which are only valid for OP_TRANS/OP_TRANSR. At the moment the fall-through fields don't use either of those private bits, but in case this changes in future, only check those flag bits for trans ops. At the same time, enhance op_dump() to display the OP_PV field of such ops. Also, fix a leak I introduced in the recently-added S_gv_display() function. M dump.c M op.c commit 8f5d5a51d02eb509ca7ebc82d950207828c3aa7c Author: David Mitchell <[email protected]> Date: Tue Jan 24 13:55:45 2017 +0000 perlapi.pod: remove AvARRAY() example from sortsv() The docs for the Perl_sort() API function include a 1-line example of sorting an AV in-place using AvARRAY(av). Since AvARRAY() isn't part of the API and the example would fail on tied or magic arrays, just delete it. At the same time, clarify the docs a bit for Perl_sort() and Perl_sort_flags() M pp_sort.c ----------------------------------------------------------------------- Summary of changes: dump.c | 26 +++++++++++++++++++++++++- op.c | 5 +++-- pp_sort.c | 7 +++---- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/dump.c b/dump.c index ce63f351e8..349a3e42cd 100644 --- a/dump.c +++ b/dump.c @@ -737,7 +737,7 @@ Perl_dump_eval(pTHX) static SV * S_gv_display(pTHX_ GV *gv) { - SV * const name = newSV(0); + SV * const name = newSVpvs_flags("", SVs_TEMP); if (gv) { SV * const raw = newSVpvs_flags("", SVs_TEMP); STRLEN len; @@ -1217,6 +1217,30 @@ S_do_op_dump_bar(pTHX_ I32 level, UV bar, PerlIO *file, const OP *o) S_opdump_indent(aTHX_ o, level, bar, file, "REFCNT = %" UVuf "\n", (UV)o->op_targ); break; + + case OP_DUMP: + case OP_GOTO: + case OP_NEXT: + case OP_LAST: + case OP_REDO: + if (o->op_flags & (OPf_SPECIAL|OPf_STACKED|OPf_KIDS)) + break; + /* FALLTHROUGH */ + case OP_TRANS: + case OP_TRANSR: + if ( (o->op_type == OP_TRANS || o->op_type == OP_TRANSR) + && (o->op_private & (OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF))) + break; + + { + SV * const label = newSVpvs_flags("", SVs_TEMP); + generic_pv_escape(label, cPVOPo->op_pv, strlen(cPVOPo->op_pv), 0); + S_opdump_indent(aTHX_ o, level, bar, file, + "PV = \"%" SVf "\" (0x%" UVxf ")\n", + SVfARG(label), PTR2UV(cPVOPo->op_pv)); + } + + default: break; } diff --git a/op.c b/op.c index 0ba58c7ac2..c4c9fc0171 100644 --- a/op.c +++ b/op.c @@ -994,8 +994,9 @@ Perl_op_clear(pTHX_ OP *o) /* FALLTHROUGH */ case OP_TRANS: case OP_TRANSR: - if (o->op_private & (OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF)) { - assert(o->op_type == OP_TRANS || o->op_type == OP_TRANSR); + if ( (o->op_type == OP_TRANS || o->op_type == OP_TRANSR) + && (o->op_private & (OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF))) + { #ifdef USE_ITHREADS if (cPADOPo->op_padix > 0) { pad_swipe(cPADOPo->op_padix, TRUE); diff --git a/pp_sort.c b/pp_sort.c index 4ffe224842..21e4574c1f 100644 --- a/pp_sort.c +++ b/pp_sort.c @@ -1428,9 +1428,7 @@ S_qsortsv(pTHX_ gptr *list1, size_t nmemb, SVCOMPARE_t cmp, U32 flags) =for apidoc sortsv -Sort an array. Here is an example: - - sortsv(AvARRAY(av), av_top_index(av)+1, Perl_sv_cmp_locale); +In-place sort an array of SV pointers with the given comparison routine. Currently this always uses mergesort. See C<L</sortsv_flags>> for a more flexible routine. @@ -1449,7 +1447,8 @@ Perl_sortsv(pTHX_ SV **array, size_t nmemb, SVCOMPARE_t cmp) /* =for apidoc sortsv_flags -Sort an array, with various options. +In-place sort an array of SV pointers with the given comparison routine, +with various SORTf_* flag options. =cut */ -- Perl5 Master Repository
