summaryrefslogtreecommitdiff
path: root/pp.c
diff options
context:
space:
mode:
authorEric Brine <ikegami@adaelis.com>2011-03-02 17:30:17 -0500
committerFather Chrysostomos <sprout@cpan.org>2011-06-21 08:37:57 -0700
commit5cd408a276e19848774860967c3ec06b67b863ee (patch)
treedd4b575b002a260fd9d4ae4c77ca6a5ed4c73d15 /pp.c
parent0890f1a536cff0aff68038cae78e02c9d9b6a2b2 (diff)
downloadperl-5cd408a276e19848774860967c3ec06b67b863ee.tar.gz
[perl #78462] Don't warn for splice(@a,MAX_LEN)
The intent of splice(@a,MAX_LEN) is quite clearly to truncate the array if it's too large. There's no reason to warn if it's currently smaller than the max length.
Diffstat (limited to 'pp.c')
-rw-r--r--pp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/pp.c b/pp.c
index 385f1beef1..d3d4cc81e8 100644
--- a/pp.c
+++ b/pp.c
@@ -5434,6 +5434,7 @@ S_deref_plain_array(pTHX_ AV *ary)
PP(pp_splice)
{
dVAR; dSP; dMARK; dORIGMARK;
+ int num_args = (SP - MARK);
register AV *ary = DEREF_PLAIN_ARRAY(MUTABLE_AV(*++MARK));
register SV **src;
register SV **dst;
@@ -5477,7 +5478,8 @@ PP(pp_splice)
length = AvMAX(ary) + 1;
}
if (offset > AvFILLp(ary) + 1) {
- Perl_ck_warner(aTHX_ packWARN(WARN_MISC), "splice() offset past end of array" );
+ if (num_args > 2)
+ Perl_ck_warner(aTHX_ packWARN(WARN_MISC), "splice() offset past end of array" );
offset = AvFILLp(ary) + 1;
}
after = AvFILLp(ary) + 1 - (offset + length);