This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Change av_len calls to av_tindex for clarity
authorKarl Williamson <public@khwilliamson.com>
Thu, 20 Feb 2014 17:28:58 +0000 (10:28 -0700)
committerKarl Williamson <public@khwilliamson.com>
Thu, 20 Feb 2014 18:47:05 +0000 (11:47 -0700)
av_tindex is a more clearly named synonym for av_len, available starting
in v5.18.  This changes the core uses to it, including modules in /ext,
which are not dual-lifed.

22 files changed:
doio.c
dump.c
ext/Hash-Util-FieldHash/FieldHash.xs
ext/XS-APItest/APItest.xs
ext/XS-Typemap/Typemap.xs
ext/mro/mro.xs
op.c
op.h
os2/os2.c
perl.c
perl.h
pp.c
pp.h
pp_ctl.c
pp_hot.c
pp_sys.c
regcomp.c
regexec.c
sv.c
universal.c
utf8.c
vms/vms.c

diff --git a/doio.c b/doio.c
index 1fbc9a0..81abd9c 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -747,7 +747,7 @@ Perl_nextargv(pTHX_ GV *gv)
     PL_filemode = 0;
     if (!GvAV(gv))
        return NULL;
-    while (av_len(GvAV(gv)) >= 0) {
+    while (av_tindex(GvAV(gv)) >= 0) {
        STRLEN oldlen;
        sv = av_shift(GvAV(gv));
        SAVEFREESV(sv);
diff --git a/dump.c b/dump.c
index 412cfc3..8c14b3b 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -1871,9 +1871,9 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo
        if (AvREIFY(sv))        sv_catpv(d, ",REIFY");
        Perl_dump_indent(aTHX_ level, file, "  FLAGS = (%s)\n",
                         SvCUR(d) ? SvPVX_const(d) + 1 : "");
-       if (nest < maxnest && av_len(MUTABLE_AV(sv)) >= 0) {
+       if (nest < maxnest && av_tindex(MUTABLE_AV(sv)) >= 0) {
            SSize_t count;
-           for (count = 0; count <=  av_len(MUTABLE_AV(sv)) && count < maxnest; count++) {
+           for (count = 0; count <=  av_tindex(MUTABLE_AV(sv)) && count < maxnest; count++) {
                SV** const elt = av_fetch(MUTABLE_AV(sv),count,0);
 
                Perl_dump_indent(aTHX_ level + 1, file, "Elt No. %"IVdf"\n", (IV)count);
index e726041..327b820 100644 (file)
@@ -327,7 +327,7 @@ HUF_fix_objects(pTHX) {
     hv_iterinit(MY_CXT.ob_reg);
     while((ent = hv_iternext(MY_CXT.ob_reg)))
         av_push(oblist, SvREFCNT_inc(hv_iterkeysv(ent)));
-    len = av_len(oblist);
+    len = av_tindex(oblist);
     for (i = 0; i <= len; ++i) {
         SV* old_id = *av_fetch(oblist, i, 0);
         SV* trigger = hv_delete_ent(MY_CXT.ob_reg, old_id, 0, 0);
index f8fc1bf..a51924d 100644 (file)
@@ -275,7 +275,7 @@ blockhook_csc_start(pTHX_ int full)
         I32 i;
         AV *const new_av = newAV();
 
-        for (i = 0; i <= av_len(cur); i++) {
+        for (i = 0; i <= av_tindex(cur); i++) {
             av_store(new_av, i, newSVsv(*av_fetch(cur, i, 0)));
         }
 
index 0eb68e5..3fa0e74 100644 (file)
@@ -157,7 +157,7 @@ XS_unpack_anotherstructPtrPtr(SV *in)
     else
         Perl_croak(aTHX_ "Argument is not an ARRAY reference");
 
-    nitems = av_len(inary) + 1;
+    nitems = av_tindex(inary) + 1;
 
     /* FIXME dunno if supposed to use perl mallocs here */
     /* N+1 elements so we know the last one is NULL */
index fee1c98..fead95f 100644 (file)
@@ -259,7 +259,7 @@ S_mro_get_linear_isa_c3(pTHX_ HV* stash, U32 level)
                            "Inconsistent hierarchy during C3 merge of class '%"HEKf"':\n\t"
                             "current merge results [\n",
                             HEKfARG(stashhek));
-                for (i = 0; i <= av_len(retval); i++) {
+                for (i = 0; i <= av_tindex(retval); i++) {
                     SV **elem = av_fetch(retval, i, 0);
                     sv_catpvf(errmsg, "\t\t%"SVf",\n", SVfARG(*elem));
                 }
diff --git a/op.c b/op.c
index a9d41d6..f0360ed 100644 (file)
--- a/op.c
+++ b/op.c
@@ -4735,7 +4735,7 @@ Perl_newPMOP(pTHX_ I32 type, I32 flags)
     } else {
        SV * const repointer = &PL_sv_undef;
        av_push(PL_regex_padav, repointer);
-       pmop->op_pmoffset = av_len(PL_regex_padav);
+       pmop->op_pmoffset = av_tindex(PL_regex_padav);
        PL_regex_pad = AvARRAY(PL_regex_padav);
     }
 #endif
diff --git a/op.h b/op.h
index a93e759..ed9609d 100644 (file)
--- a/op.h
+++ b/op.h
@@ -864,7 +864,7 @@ preprocessing token; the type of I<arg> depends on I<which>.
     STMT_START { \
        if (PL_blockhooks) { \
            SSize_t i; \
-           for (i = av_len(PL_blockhooks); i >= 0; i--) { \
+           for (i = av_tindex(PL_blockhooks); i >= 0; i--) { \
                SV *sv = AvARRAY(PL_blockhooks)[i]; \
                BHK *hk; \
                \
index 94b4541..d4e9c90 100644 (file)
--- a/os2/os2.c
+++ b/os2/os2.c
@@ -2011,7 +2011,7 @@ mod2fname(pTHX_ SV *sv)
     if (SvTYPE(sv) != SVt_PVAV) 
       Perl_croak_nocontext("Not array reference given to mod2fname");
 
-    avlen = av_len((AV*)sv);
+    avlen = av_tindex((AV*)sv);
     if (avlen < 0) 
       Perl_croak_nocontext("Empty array reference given to mod2fname");
 
diff --git a/perl.c b/perl.c
index 3007dc7..36d33d9 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -4745,7 +4745,7 @@ S_incpush(pTHX_ const char *const dir, STRLEN len, U32 flags)
 #ifdef PERL_IS_MINIPERL
            const Size_t extra = 0;
 #else
-           Size_t extra = av_len(av) + 1;
+           Size_t extra = av_tindex(av) + 1;
 #endif
            av_unshift(inc, extra + push_basedir);
            if (push_basedir)
@@ -4832,7 +4832,7 @@ Perl_call_list(pTHX_ I32 oldscope, AV *paramList)
 
     PERL_ARGS_ASSERT_CALL_LIST;
 
-    while (av_len(paramList) >= 0) {
+    while (av_tindex(paramList) >= 0) {
        cv = MUTABLE_CV(av_shift(paramList));
        if (PL_savebegin) {
            if (paramList == PL_beginav) {
diff --git a/perl.h b/perl.h
index e49d784..d3e2675 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -3220,7 +3220,7 @@ typedef I32 (*filter_t) (pTHX_ int, SV *, int);
                && idx >= AvFILLp(PL_parser->rsfp_filters))
 #define PERL_FILTER_EXISTS(i) \
            (PL_parser && PL_parser->rsfp_filters \
-               && (i) <= av_len(PL_parser->rsfp_filters))
+               && (i) <= av_tindex(PL_parser->rsfp_filters))
 
 #if defined(_AIX) && !defined(_AIX43)
 #if defined(USE_REENTRANT) || defined(_REENTRANT) || defined(_THREAD_SAFE)
diff --git a/pp.c b/pp.c
index 4d7ff09..1674ae6 100644 (file)
--- a/pp.c
+++ b/pp.c
@@ -4436,7 +4436,7 @@ PP(pp_aeach)
     IV *iterp = Perl_av_iter_p(aTHX_ array);
     const IV current = (*iterp)++;
 
-    if (current > av_len(array)) {
+    if (current > av_tindex(array)) {
        *iterp = 0;
        if (gimme == G_SCALAR)
            RETPUSHUNDEF;
@@ -4464,7 +4464,7 @@ PP(pp_akeys)
 
     if (gimme == G_SCALAR) {
        dTARGET;
-       PUSHi(av_len(array) + 1);
+       PUSHi(av_tindex(array) + 1);
     }
     else if (gimme == G_ARRAY) {
         IV n = Perl_av_len(aTHX_ array);
@@ -5296,7 +5296,7 @@ PP(pp_reverse)
                const MAGIC *mg;
                bool can_preserve = SvCANEXISTDELETE(av);
 
-               for (i = 0, j = av_len(av); i < j; ++i, --j) {
+               for (i = 0, j = av_tindex(av); i < j; ++i, --j) {
                    SV *begin, *end;
 
                    if (can_preserve) {
diff --git a/pp.h b/pp.h
index c72ed8e..d0a62fb 100644 (file)
--- a/pp.h
+++ b/pp.h
@@ -434,7 +434,7 @@ Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
                 SSize_t i;                                      \
                 SSize_t len;                                    \
                 assert(SvTYPE(tmpsv) == SVt_PVAV);              \
-                len = av_len((AV *)tmpsv) + 1;                  \
+                len = av_tindex((AV *)tmpsv) + 1;               \
                 (void)POPs; /* get rid of the arg */            \
                 EXTEND(sp, len);                                \
                 for (i = 0; i < len; ++i)                       \
index 4828fbd..43466fe 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3714,7 +3714,7 @@ PP(pp_require)
                first  = SvIV(*av_fetch(lav,0,0));
                if (   first > (int)PERL_REVISION    /* probably 'use 6.0' */
                    || hv_exists(MUTABLE_HV(req), "qv", 2 ) /* qv style */
-                   || av_len(lav) > 1               /* FP with > 3 digits */
+                   || av_tindex(lav) > 1            /* FP with > 3 digits */
                    || strstr(SvPVX(pv),".0")        /* FP with leading 0 */
                   ) {
                    DIE(aTHX_ "Perl %"SVf" required--this is only "
@@ -3727,7 +3727,7 @@ PP(pp_require)
                    SV *hintsv;
                    I32 second = 0;
 
-                   if (av_len(lav)>=1) 
+                   if (av_tindex(lav)>=1)
                        second = SvIV(*av_fetch(lav,1,0));
 
                    second /= second >= 600  ? 100 : 10;
@@ -4611,7 +4611,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other, const bool copied)
            SSize_t i;
            bool andedresults = TRUE;
            AV *av = (AV*) SvRV(d);
-           const I32 len = av_len(av);
+           const I32 len = av_tindex(av);
            DEBUG_M(Perl_deb(aTHX_ "    applying rule Array-CodeRef\n"));
            if (len == -1)
                RETPUSHYES;
@@ -4723,7 +4723,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other, const bool copied)
        }
        else if (SvROK(d) && SvTYPE(SvRV(d)) == SVt_PVAV) {
            AV * const other_av = MUTABLE_AV(SvRV(d));
-           const SSize_t other_len = av_len(other_av) + 1;
+           const SSize_t other_len = av_tindex(other_av) + 1;
            SSize_t i;
            HV *hv = MUTABLE_HV(SvRV(e));
 
@@ -4775,7 +4775,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other, const bool copied)
        }
        else if (SvROK(d) && SvTYPE(SvRV(d)) == SVt_PVHV) {
            AV * const other_av = MUTABLE_AV(SvRV(e));
-           const SSize_t other_len = av_len(other_av) + 1;
+           const SSize_t other_len = av_tindex(other_av) + 1;
            SSize_t i;
 
            DEBUG_M(Perl_deb(aTHX_ "    applying rule Hash-Array\n"));
@@ -4793,11 +4793,11 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other, const bool copied)
        if (SvROK(d) && SvTYPE(SvRV(d)) == SVt_PVAV) {
            AV *other_av = MUTABLE_AV(SvRV(d));
            DEBUG_M(Perl_deb(aTHX_ "    applying rule Array-Array\n"));
-           if (av_len(MUTABLE_AV(SvRV(e))) != av_len(other_av))
+           if (av_tindex(MUTABLE_AV(SvRV(e))) != av_tindex(other_av))
                RETPUSHNO;
            else {
                SSize_t i;
-               const SSize_t other_len = av_len(other_av);
+                const SSize_t other_len = av_tindex(other_av);
 
                if (NULL == seen_this) {
                    seen_this = newHV();
@@ -4852,7 +4852,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other, const bool copied)
          sm_regex_array:
            {
                PMOP * const matcher = make_matcher((REGEXP*) SvRV(d));
-               const SSize_t this_len = av_len(MUTABLE_AV(SvRV(e)));
+               const SSize_t this_len = av_tindex(MUTABLE_AV(SvRV(e)));
                SSize_t i;
 
                for(i = 0; i <= this_len; ++i) {
@@ -4869,7 +4869,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other, const bool copied)
        }
        else if (!SvOK(d)) {
            /* undef ~~ array */
-           const SSize_t this_len = av_len(MUTABLE_AV(SvRV(e)));
+           const SSize_t this_len = av_tindex(MUTABLE_AV(SvRV(e)));
            SSize_t i;
 
            DEBUG_M(Perl_deb(aTHX_ "    applying rule Undef-Array\n"));
@@ -4885,7 +4885,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other, const bool copied)
          sm_any_array:
            {
                SSize_t i;
-               const SSize_t this_len = av_len(MUTABLE_AV(SvRV(e)));
+               const SSize_t this_len = av_tindex(MUTABLE_AV(SvRV(e)));
 
                DEBUG_M(Perl_deb(aTHX_ "    applying rule Any-Array\n"));
                for (i = 0; i <= this_len; ++i) {
index fb22b38..d0b84a1 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1553,7 +1553,7 @@ Perl_do_readline(pTHX)
            if (IoFLAGS(io) & IOf_ARGV) {
                if (IoFLAGS(io) & IOf_START) {
                    IoLINES(io) = 0;
-                   if (av_len(GvAVn(PL_last_in_gv)) < 0) {
+                   if (av_tindex(GvAVn(PL_last_in_gv)) < 0) {
                        IoFLAGS(io) &= ~IOf_START;
                        do_open(PL_last_in_gv,"-",1,FALSE,O_RDONLY,0,NULL);
                        SvTAINTED_off(GvSVn(PL_last_in_gv)); /* previous tainting irrelevant */
@@ -2852,7 +2852,7 @@ PP(pp_aelem)
            IV len;
            if (!defer)
                DIE(aTHX_ PL_no_aelem, elem);
-           len = av_len(av);
+           len = av_tindex(av);
            mPUSHs(newSVavdefelem(av,
            /* Resolve a negative index now, unless it points before the
               beginning of the array, in which case record it for error
index 3ec7dbe..6c4e2c7 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -2085,7 +2085,7 @@ PP(pp_eof)
 
     if (!MAXARG && (PL_op->op_flags & OPf_SPECIAL)) {  /* eof() */
        if (io && !IoIFP(io)) {
-           if ((IoFLAGS(io) & IOf_START) && av_len(GvAVn(gv)) < 0) {
+           if ((IoFLAGS(io) & IOf_START) && av_tindex(GvAVn(gv)) < 0) {
                IoLINES(io) = 0;
                IoFLAGS(io) &= ~IOf_START;
                do_open(gv, "-", 1, FALSE, O_RDONLY, 0, NULL);
index efd0a47..5b18176 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -7301,7 +7301,7 @@ Perl_reg_named_buff_scalar(pTHX_ REGEXP * const r, const U32 flags)
         } else if (flags & RXapif_ONE) {
             ret = CALLREG_NAMED_BUFF_ALL(r, (flags | RXapif_REGNAMES));
             av = MUTABLE_AV(SvRV(ret));
-            length = av_len(av);
+            length = av_tindex(av);
            SvREFCNT_dec_NN(ret);
             return newSViv(length + 1);
         } else {
@@ -14021,7 +14021,7 @@ parseit:
 #endif
 
         /* Look at the longest folds first */
-        for (cp_count = av_len(multi_char_matches); cp_count > 0; cp_count--) {
+        for (cp_count = av_tindex(multi_char_matches); cp_count > 0; cp_count--) {
 
             if (av_exists(multi_char_matches, cp_count)) {
                 AV** this_array_ptr;
@@ -14430,7 +14430,7 @@ parseit:
                     {
                         AV* list = (AV*) *listp;
                         IV k;
-                        for (k = 0; k <= av_len(list); k++) {
+                        for (k = 0; k <= av_tindex(list); k++) {
                             SV** c_p = av_fetch(list, k, FALSE);
                             UV c;
                             if (c_p == NULL) {
index 489a10b..d06ee20 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -3655,7 +3655,7 @@ S_setup_EXACTISH_ST_c1_c2(pTHX_ const regnode * const text_node, int *c1p,
                 }
                 else {  /* Does participate in folds */
                     AV* list = (AV*) *listp;
-                    if (av_len(list) != 1) {
+                    if (av_tindex(list) != 1) {
 
                         /* If there aren't exactly two folds to this, it is
                          * outside the scope of this function */
@@ -7549,7 +7549,7 @@ Perl__get_regclass_nonbitmap_data(pTHX_ const regexp *prog,
                     *only_utf8_locale_ptr = NULL;
                 }
 
-                if (av_len(av) >= 3) {
+                if (av_tindex(av) >= 3) {
                     invlist = ary[3];
                     if (SvUV(ary[4])) {
                         swash_init_flags |= _CORE_SWASH_INIT_USER_DEFINED_PROPERTY;
@@ -7908,7 +7908,7 @@ S_setup_eval_state(pTHX_ regmatch_info *const reginfo)
             /* this regexp is also owned by the new PL_reg_curpm, which
                will try to free it.  */
             av_push(PL_regex_padav, repointer);
-            PL_reg_curpm->op_pmoffset = av_len(PL_regex_padav);
+            PL_reg_curpm->op_pmoffset = av_tindex(PL_regex_padav);
             PL_regex_pad = AvARRAY(PL_regex_padav);
         }
 #endif
diff --git a/sv.c b/sv.c
index 4c6f9ad..0ebdb3c 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -13939,7 +13939,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags,
     /* Call the ->CLONE method, if it exists, for each of the stashes
        identified by sv_dup() above.
     */
-    while(av_len(param->stashes) != -1) {
+    while(av_tindex(param->stashes) != -1) {
        HV* const stash = MUTABLE_HV(av_shift(param->stashes));
        GV* const cloner = gv_fetchmethod_autoload(stash, "CLONE", 0);
        if (cloner && GvCV(cloner)) {
index ad5b504..bccc8fb 100644 (file)
@@ -722,7 +722,7 @@ XS(XS_PerlIO_get_layers)
             AV* const av = PerlIO_get_layers(aTHX_ input ?
                                        IoIFP(io) : IoOFP(io));
             SSize_t i;
-            const SSize_t last = av_len(av);
+            const SSize_t last = av_tindex(av);
             SSize_t nitem = 0;
             
             for (i = last; i >= 0; i -= 3) {
@@ -898,7 +898,7 @@ XS(XS_re_regnames)
         XSRETURN_UNDEF;
 
     av = MUTABLE_AV(SvRV(ret));
-    length = av_len(av);
+    length = av_tindex(av);
 
     EXTEND(SP, length+1); /* better extend stack just once */
     for (i = 0; i <= length; i++) {
diff --git a/utf8.c b/utf8.c
index d62370c..727c125 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -3519,12 +3519,12 @@ Perl__swash_inversion_hash(pTHX_ SV* const swash)
        while ((from_list = (AV *) hv_iternextsv(specials_inverse,
                                                 &char_to, &to_len)))
        {
-           if (av_len(from_list) > 0) {
+           if (av_tindex(from_list) > 0) {
                SSize_t i;
 
                /* We iterate over all combinations of i,j to place each code
                 * point on each list */
-               for (i = 0; i <= av_len(from_list); i++) {
+               for (i = 0; i <= av_tindex(from_list); i++) {
                    SSize_t j;
                    AV* i_list = newAV();
                    SV** entryp = av_fetch(from_list, i, FALSE);
@@ -3541,7 +3541,7 @@ Perl__swash_inversion_hash(pTHX_ SV* const swash)
                    }
 
                    /* For DEBUG_U: UV u = valid_utf8_to_uvchr((U8*) SvPVX(*entryp), 0);*/
-                   for (j = 0; j <= av_len(from_list); j++) {
+                   for (j = 0; j <= av_tindex(from_list); j++) {
                        entryp = av_fetch(from_list, j, FALSE);
                        if (entryp == NULL) {
                            Perl_croak(aTHX_ "panic: av_fetch() unexpectedly failed");
@@ -3600,7 +3600,7 @@ Perl__swash_inversion_hash(pTHX_ SV* const swash)
 
            /* Look through list to see if this inverse mapping already is
             * listed, or if there is a mapping to itself already */
-           for (i = 0; i <= av_len(list); i++) {
+           for (i = 0; i <= av_tindex(list); i++) {
                SV** entryp = av_fetch(list, i, FALSE);
                SV* entry;
                if (entryp == NULL) {
index fddd6e1..26fc4ac 100644 (file)
--- a/vms/vms.c
+++ b/vms/vms.c
@@ -12965,7 +12965,7 @@ mod2fname(pTHX_ CV *cv)
   int max_name_len = 39;
   AV *in_array = (AV *)SvRV(ST(0));
 
-  num_entries = av_len(in_array);
+  num_entries = av_tindex(in_array);
 
   /* All the names start with PL_. */
   strcpy(ultimate_name, "PL_");