summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--av.c2
-rw-r--r--av.h4
-rw-r--r--embed.fnc1
-rw-r--r--pod/perldelta.pod6
-rw-r--r--proto.h4
-rw-r--r--regcomp.c8
6 files changed, 21 insertions, 4 deletions
diff --git a/av.c b/av.c
index a24bda0872..3041cd2347 100644
--- 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 82b9919439..391ae36d74 100644
--- 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"
diff --git a/embed.fnc b/embed.fnc
index 2689e4ee33..a288c5a22d 100644
--- 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
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index b0aa3c21f2..9895b7152d 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -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 e1575c77a0..18f46cca29 100644
--- 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);
diff --git a/regcomp.c b/regcomp.c
index 5eb944cbf2..603770f874 100644
--- 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 '(?[ ])'");
}