Subject: | format are wonky with Perl 5.10 |
Under perl 5.10:
This is perl, v5.10.0 built for i486-linux-gnu-thread-multi
installed normally via the Ubuntu packages, the P::RD trace, warn, and
error outputs produce blank strings. Only the format markers show up
but not the actual data. The attached patch brute-forces the issue by
reapplying the formats every time trace, warn, or error are needed. I
don't know where the formats are dropped, unfortunately. I tried to
trace the problem but didn't find an obvious spot. The patch resolves
it for me, for now.
This happens with any of the demo/*.pl script in the distribution, so
it's not a problem with my particular scripts.
Thanks
Ted
Subject: | PRD-format.patch |
--- /usr/local/share/perl/5.10.0/Parse/RecDescent.pm 2003-04-09 03:29:37.000000000 -0500
+++ Parse/RecDescent.pm 2009-12-09 10:20:26.000000000 -0600
@@ -2845,12 +2845,6 @@
my $errorprefix;
open (ERROR, ">&STDERR");
-format ERROR =
-@>>>>>>>>>>>>>>>>>>>>: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
-$errorprefix, $errortext
-~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
- $errortext
-.
select ERROR;
$| = 1;
@@ -2863,27 +2857,39 @@
use vars '$tracelevel';
open (TRACE, ">&STDERR");
-format TRACE =
+
+select TRACE;
+$| = 1;
+
+open (TRACECONTEXT, ">&STDERR");
+
+select TRACECONTEXT;
+$| = 1;
+
+apply_formats();
+
+sub apply_formats
+{
+ format ERROR =
+@>>>>>>>>>>>>>>>>>>>>: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+$errorprefix, $errortext
+~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+ $errortext
+.
+ format TRACE =
@>|@|||||||||@^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<|
$tracelevel, $tracerulename, '|', $tracemsg
| ~~ |^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<|
$tracemsg
.
-select TRACE;
-$| = 1;
-
-open (TRACECONTEXT, ">&STDERR");
-format TRACECONTEXT =
+ format TRACECONTEXT =
@>|@|||||||||@ |^<<<<<<<<<<<<<<<<<<<<<<<<<<<
$tracelevel, $tracerulename, '|', $tracecontext
| ~~ | |^<<<<<<<<<<<<<<<<<<<<<<<<<<<
$tracecontext
.
-
-
-select TRACECONTEXT;
-$| = 1;
+}
select STDOUT;
@@ -2897,6 +2903,7 @@
sub _error($;$)
{
+apply_formats();
$ERRORS++;
return 0 if ! _verbosity("ERRORS");
$errortext = $_[0];
@@ -2909,6 +2916,7 @@
sub _warn($$;$)
{
+apply_formats();
return 0 unless _verbosity("WARN") && ($::RD_HINT || $_[0] >= ($::RD_WARN||1));
$errortext = $_[1];
$errorprefix = "Warning" . ($_[2] ? " (line $_[2])" : "");
@@ -2920,6 +2928,7 @@
sub _hint($)
{
+apply_formats();
return 0 unless defined $::RD_HINT;
$errortext = "$_[0])";
$errorprefix = "(Hint";
@@ -2968,6 +2977,7 @@
sub _trace($;$$$)
{
+apply_formats();
$tracemsg = $_[0];
$tracecontext = $_[1]||$lastcontext;
$tracerulename = $_[2]||$lastrulename;