The message ‘localtime(...) too large’ is not documented in perldiag.
The attached patch adds it. I know it’s technically ‘%s(%.0f) too
large’, but it’s easier for users to find it under ‘localtime’ and
‘gmtime’. I also had to modify diagnostics.pm to support %.0f, and I
added a test, but I used a hack with STDERR that would make debugging
very difficult to anyone else adding tests.
use Carp;
$Carp::Internal{__PACKAGE__.""}++;
-our $VERSION = 1.17;
+our $VERSION = '1.18';
our $DEBUG;
our $VERBOSE;
our $PRETTY;
# strip formatting directives from =item line
$header =~ s/[A-Z]<(.*?)>/$1/g;
- my @toks = split( /(%l?[dx]|%c|%(?:\.\d+)?s)/, $header );
+ my @toks = split( /(%l?[dx]|%c|%(?:\.\d+)?[fs])/, $header );
if (@toks > 1) {
my $conlen = 0;
for my $i (0..$#toks){
$toks[$i] = '.';
} elsif( $toks[$i] eq '%d' ){
$toks[$i] = '\d+';
- } elsif( $toks[$i] eq '%s' ){
+ } elsif( $toks[$i] =~ '^%(?:s|.*f)$' ){
$toks[$i] = $i == $#toks ? '.*' : '.*?';
} elsif( $toks[$i] =~ '%.(\d+)s' ){
$toks[$i] = ".{$1}";
@INC = 'lib';
}
-use Test::More tests => 2;
+use Test::More tests => 3;
BEGIN { use_ok('diagnostics') }
};
like( $@, qr/^Base class package "I::do::not::exist" is empty/);
+
+# Test for %.0f patterns in perldiag, added in 5.11.0
+close STDERR;
+open STDERR, ">", \my $warning
+ or die "Couldn't redirect STDERR to var: $!";
+warn('gmtime(nan) too large');
+like $warning, qr/\(W overflow\) You called/, '%0.f patterns';
not finding it. Chances are you left some needed parentheses out
earlier in the line, and you really meant a "less than".
+=item gmtime(%.0f) too large
+
+(W overflow) You called C<gmtime> with an number that was beyond the 64-bit
+range that it accepts, and some rounding resulted. This warning is also
+triggered with nan (the special not-a-number value).
+
=item Got an error from DosAllocMem
(P) An error peculiar to OS/2. Most probably you're using an obsolete
to check the return value of your socket() call? See
L<perlfunc/listen>.
+=item localtime(%.0f) too large
+
+(W overflow) You called C<localtime> with an number that was beyond the
+64-bit range that it accepts, and some rounding resulted. This warning is also triggered with nan (the special not-a-number value).
+
=item Lookbehind longer than %d not implemented in regex m/%s/
(F) There is currently a limit on the length of string which lookbehind can