diff options
author | Marcus Holland-Moritz <mhx-perl@gmx.net> | 2012-05-23 14:50:31 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-05-23 17:59:22 -0700 |
commit | 21361d0729743e699b2954b542f05a2e4eabd980 (patch) | |
tree | b4f46494969725415a45b9c85172af1ba8cf0d24 /pp_pack.c | |
parent | 909564a7d63dd41ca03b7bc9659d8c7b695220d2 (diff) | |
download | perl-21361d0729743e699b2954b542f05a2e4eabd980.tar.gz |
[perl #60204] Unhelpful error message from unpack
Nigel Sandever said:
> The error message produced by the following snippets is very unhelpful:
>
> c:\>perl -wle"print unpack 'v/a*', qq[a]"
> '/' must follow a numeric type in unpack at -e line 1.
>
> c:\>perl -wle"print unpack 'v/a*', ''"
> '/' must follow a numeric type in unpack at -e line 1.
>
> c:\>perl -wle"print unpack 'v/a*', ' '"
> '/' must follow a numeric type in unpack at -e line 1.
The "problem" is that the data string is too short. But
unpack doesn't generate a warning (or croak) in this case
for simple patterns:
mhx@r2d2 $ perl -MData::Dumper -we'print Dumper([unpack "n", "a"])'
$VAR1 = [];
So, I'd say your code should just behave in exactly the
same way. No warning, no return values.
Diffstat (limited to 'pp_pack.c')
-rw-r--r-- | pp_pack.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -2234,7 +2234,7 @@ S_unpack_rec(pTHX_ tempsym_t* symptr, const char *s, const char *strbeg, const c if (symptr->flags & FLAG_SLASH){ if (SP - PL_stack_base - start_sp_offset <= 0) - Perl_croak(aTHX_ "'/' must follow a numeric type in unpack"); + break; if( next_symbol(symptr) ){ if( symptr->howlen == e_number ) Perl_croak(aTHX_ "Count after length/code in unpack" ); |