This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add av_tindex() synonym for av_top_index()
authorKarl Williamson <public@khwilliamson.com>
Fri, 8 Feb 2013 21:27:57 +0000 (14:27 -0700)
committerKarl Williamson <public@khwilliamson.com>
Fri, 8 Feb 2013 21:44:24 +0000 (14:44 -0700)
The latter is a somewhat less clumsy name.  The old one is provided a a
very clear name; the new one as a somewhat slangy version

av.c
av.h
embed.fnc
pod/perldelta.pod
proto.h
regcomp.c

diff --git a/av.c b/av.c
index a24bda0..3041cd2 100644 (file)
--- a/av.c
+++ b/av.c
@@ -766,6 +766,8 @@ array is C<av_top_index(av) + 1>.  Returns -1 if the array is empty.
 
 The Perl equivalent for this is C<$#myarray>.
 
+(A slightly shorter form is C<av_tindex>.)
+
 =for apidoc av_len
 
 Same as L</av_top_index>.  Returns the highest index in the array.  Note that the
diff --git a/av.h b/av.h
index 82b9919..391ae36 100644 (file)
--- a/av.h
+++ b/av.h
@@ -49,6 +49,9 @@ Null AV pointer.
 =for apidoc Am|int|AvFILL|AV* av
 Same as C<av_top_index()>.  Deprecated, use C<av_top_index()> instead.
 
+=for apidoc Am|int|av_tindex|AV* av
+Same as C<av_top_index()>.
+
 =cut
 */
 
@@ -75,6 +78,7 @@ Same as C<av_top_index()>.  Deprecated, use C<av_top_index()> instead.
                                           
 #define AvFILL(av)     ((SvRMAGICAL((const SV *) (av))) \
                         ? mg_size(MUTABLE_SV(av)) : AvFILLp(av))
+#define av_tindex(av)   av_top_index(av)
 
 #define NEGATIVE_INDICES_VAR "NEGATIVE_INDICES"
 
index 2689e4e..a288c5a 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -220,6 +220,7 @@ EXp |void   |av_reify       |NN AV *av
 ApdR   |SV*    |av_shift       |NN AV *av
 Apd    |SV**   |av_store       |NN AV *av|I32 key|NULLOK SV *val
 AidR   |I32    |av_top_index   |NN AV *av
+AmpdR  |I32    |av_tindex      |NN AV *av
 Apd    |void   |av_undef       |NN AV *av
 ApdoxM |SV**   |av_create_and_unshift_one|NN AV **const avp|NN SV *const val
 Apd    |void   |av_unshift     |NN AV *av|I32 num
index b0aa3c2..9895b71 100644 (file)
@@ -494,6 +494,12 @@ well.
 
 =item *
 
+Synonyms for the misleadingly named C<av_len()> has been created:
+C<av_top_index()> and C<av_tindex>.  All three of these return the
+number of the highest index in the array, not the number of elements it
+contains.  (The name C<av_top> which was introduced in Perl v.5.17.8 has
+been removed.)
+
 XXX
 
 =back
diff --git a/proto.h b/proto.h
index e1575c7..18f46cc 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -227,6 +227,10 @@ PERL_CALLCONV SV** Perl_av_store(pTHX_ AV *av, I32 key, SV *val)
 #define PERL_ARGS_ASSERT_AV_STORE      \
        assert(av)
 
+/* PERL_CALLCONV I32   Perl_av_tindex(pTHX_ AV *av)
+                       __attribute__warn_unused_result__
+                       __attribute__nonnull__(pTHX_1); */
+
 PERL_STATIC_INLINE I32 S_av_top_index(pTHX_ AV *av)
                        __attribute__warn_unused_result__
                        __attribute__nonnull__(pTHX_1);
index 5eb944c..603770f 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -11560,7 +11560,7 @@ S_handle_regex_sets(pTHX_ RExC_state_t *pRExC_state, SV** return_invlist, I32 *f
     stack = newAV();
 
     while (RExC_parse < RExC_end) {
-        I32 top_index = av_top_index(stack);
+        I32 top_index = av_tindex(stack);
         SV** top_ptr;
         SV* current = NULL;
 
@@ -11577,7 +11577,7 @@ S_handle_regex_sets(pTHX_ RExC_state_t *pRExC_state, SV** return_invlist, I32 *f
         switch (curchar) {
 
             case '?':
-                if (av_top_index(stack) >= 0   /* This makes sure that we can
+                if (av_tindex(stack) >= 0   /* This makes sure that we can
                                                safely subtract 1 from
                                                RExC_parse in the next clause.
                                                If we have something on the
@@ -11814,10 +11814,10 @@ S_handle_regex_sets(pTHX_ RExC_state_t *pRExC_state, SV** return_invlist, I32 *f
         RExC_parse += (UTF) ? UTF8SKIP(RExC_parse) : 1;
     }
 
-    if (av_top_index(stack) < 0   /* Was empty */
+    if (av_tindex(stack) < 0   /* Was empty */
         || ((final = av_pop(stack)) == NULL)
         || ! IS_OPERAND(final)
-        || av_top_index(stack) >= 0)  /* More left on stack */
+        || av_tindex(stack) >= 0)  /* More left on stack */
     {
         vFAIL("Incomplete expression within '(?[ ])'");
     }