summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2009-11-13 10:19:59 +0100
committerRafael Garcia-Suarez <rgs@consttype.org>2009-11-13 10:21:46 +0100
commit8b56d6ffd0fe641abae5662a8e75424a1d9e4dce (patch)
treeb4102e51f325fb74a5624e1b44acb8fc11bb8d20
parent97b33cac18e30b878b151b5f3fcbf9c32cb7b037 (diff)
downloadperl-8b56d6ffd0fe641abae5662a8e75424a1d9e4dce.tar.gz
[perl #70337] perldiag: localtime(...) too large
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.
-rw-r--r--lib/diagnostics.pm6
-rw-r--r--lib/diagnostics.t9
-rw-r--r--pod/perldiag.pod11
3 files changed, 22 insertions, 4 deletions
diff --git a/lib/diagnostics.pm b/lib/diagnostics.pm
index 7af5efa177..d65df19ca2 100644
--- a/lib/diagnostics.pm
+++ b/lib/diagnostics.pm
@@ -185,7 +185,7 @@ use 5.009001;
use Carp;
$Carp::Internal{__PACKAGE__.""}++;
-our $VERSION = 1.17;
+our $VERSION = '1.18';
our $DEBUG;
our $VERBOSE;
our $PRETTY;
@@ -377,7 +377,7 @@ my %msg;
# 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){
@@ -386,7 +386,7 @@ my %msg;
$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}";
diff --git a/lib/diagnostics.t b/lib/diagnostics.t
index f30f70e073..ee0c160743 100644
--- a/lib/diagnostics.t
+++ b/lib/diagnostics.t
@@ -5,7 +5,7 @@ BEGIN {
@INC = 'lib';
}
-use Test::More tests => 2;
+use Test::More tests => 3;
BEGIN { use_ok('diagnostics') }
@@ -16,3 +16,10 @@ eval {
};
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';
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index db9a17c2fb..d38244e4ef 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -1842,6 +1842,12 @@ a term, so it's looking for the corresponding right angle bracket, and
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
@@ -2260,6 +2266,11 @@ an undefined value for the length. See L<perlfunc/pack>.
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