diff options
author | Yves Orton <demerphq@gmail.com> | 2020-02-02 14:15:18 +0100 |
---|---|---|
committer | Yves Orton <demerphq@gmail.com> | 2020-02-04 11:57:09 +0100 |
commit | 99c9ca9ebc1ca483167d8c51cdc3bf9e69c08dae (patch) | |
tree | 877abd2cbb82d19725cf044b2047bb48a0b1be18 /pp_sort.c | |
parent | cf7477a01dcbf9d54f7875fff8a819fb8d0f7500 (diff) | |
download | perl-99c9ca9ebc1ca483167d8c51cdc3bf9e69c08dae.tar.gz |
pp_sort.c: Tinker with pp_sort to untickle mingw bug
Diffstat (limited to 'pp_sort.c')
-rw-r--r-- | pp_sort.c | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -1063,13 +1063,14 @@ PP(pp_sort) if (av) { /* copy back result to the array */ SV** const base = MARK+1; + SSize_t max_minus_one = max - 1; /* attempt to work around mingw bug */ if (SvMAGICAL(av)) { - for (i = 0; i < max; i++) + for (i = 0; i <= max_minus_one; i++) base[i] = newSVsv(base[i]); av_clear(av); - if (max) - av_extend(av, max-1); - for (i=0; i < max; i++) { + if (max_minus_one >= 0) + av_extend(av, max_minus_one); + for (i=0; i <= max_minus_one; i++) { SV * const sv = base[i]; SV ** const didstore = av_store(av, i, sv); if (SvSMAGICAL(sv)) @@ -1085,7 +1086,7 @@ PP(pp_sort) * in the meantime. So bump and unbump the relevant refcounts * first. */ - for (i = 0; i < max; i++) { + for (i = 0; i <= max_minus_one; i++) { SV *sv = base[i]; assert(sv); if (SvREFCNT(sv) > 1) @@ -1094,11 +1095,11 @@ PP(pp_sort) SvREFCNT_inc_simple_void_NN(sv); } av_clear(av); - if (max > 0) { - av_extend(av, max-1); + if (max_minus_one >= 0) { + av_extend(av, max_minus_one); Copy(base, AvARRAY(av), max, SV*); } - AvFILLp(av) = max - 1; + AvFILLp(av) = max_minus_one; AvREIFY_off(av); AvREAL_on(av); } |