summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2021-09-28 12:17:03 +0000
committerNicholas Clark <nick@ccl4.org>2021-09-29 10:21:04 +0000
commit6920b5ce88214f02c7987a3e5028e8bdfc7e5e82 (patch)
treed4ae378c94cc167100937f157496f076fce64c07
parentff5f936a99c6d05680ef01aa1f84f9adca5ba7e0 (diff)
downloadperl-6920b5ce88214f02c7987a3e5028e8bdfc7e5e82.tar.gz
Replace "grandfather in ..." with a full description of the change
Unrecognised characters in pack/unpack formats were made fatal in 5.004, with an exception added in 5.004_04 for ',' to "just" warn. Add tests that the format with the comma behaves the same as a format without.
-rw-r--r--pp_pack.c4
-rw-r--r--t/op/pack.t5
2 files changed, 7 insertions, 2 deletions
diff --git a/pp_pack.c b/pp_pack.c
index 60cbfa529b..b64d911be7 100644
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -611,7 +611,9 @@ S_next_symbol(pTHX_ tempsym_t* symptr )
I32 code = (U8) *patptr++;
U32 inherited_modifiers = 0;
- if (code == ','){ /* grandfather in commas but with a warning */
+ /* unrecognised characters in pack/unpack formats were made fatal in
+ * 5.004, with an exception added in 5.004_04 for ',' to "just" warn: */
+ if (code == ','){
if (((symptr->flags & FLAG_COMMA) == 0) && ckWARN(WARN_UNPACK)){
symptr->flags |= FLAG_COMMA;
Perl_warner(aTHX_ packWARN(WARN_UNPACK),
diff --git a/t/op/pack.t b/t/op/pack.t
index bfcfc6cd91..376f58e71f 100644
--- a/t/op/pack.t
+++ b/t/op/pack.t
@@ -6,7 +6,7 @@ BEGIN {
set_up_inc(qw '../lib ../dist/Math-BigInt/lib');
}
-plan tests => 14718;
+plan tests => 14720;
use strict;
use warnings qw(FATAL all);
@@ -1230,11 +1230,14 @@ is(pack('L<L>', (0x12345678)x2),
@warning = ();
my $x = pack( 'I,A', 4, 'X' );
like( $warning[0], qr{Invalid type ','} );
+ is($x, pack( 'IA', 4, 'X' ), "Comma was ignored in pack string");
# comma warning only once
@warning = ();
$x = pack( 'C(C,C)C,C', 65..71 );
cmp_ok( scalar(@warning), '==', 1 );
+ is(join(",", unpack 'C(C,,,C),C,,C', $x), join(",", 65..69),
+ "Comma was ignored in unpack string");
# forbidden code in []
eval { my $x = pack( 'A[@4]', 'XXXX' ); };