Using both PIO and stdio in Parrot_warn causes output to get mixed up when io
is being buffered. This patch changes print_pbc_location to use PIO, and adds
a new print_pbc_location_stdio function for use by exceptions.c (which uses
stdio). With it I no longer get test failures on t/pmc/perlarray.t (26) and
t/pmc/sub.t (36-38)
__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools
--- include/parrot/warnings.h~ Fri Feb 20 14:02:04 2004
+++ include/parrot/warnings.h Fri Feb 20 14:02:22 2004
@@ -49,6 +49,7 @@
#include "parrot/parrot.h"
void print_pbc_location(Parrot_Interp);
+void print_pbc_location_stdio(Parrot_Interp);
INTVAL Parrot_warn(Parrot_Interp, INTVAL warnclass, const char *message, ...);
--- src/exceptions.c~ Fri Jan 30 03:28:12 2004
+++ src/exceptions.c Fri Feb 20 14:22:00 2004
@@ -203,7 +203,7 @@
if (m)
string_cstring_free(m);
if (print_location)
- print_pbc_location(interpreter);
+ print_pbc_location_stdio(interpreter);
/*
* returning NULL from here returns resume address NULL to the
* runloop, which will terminate the thread function finally
@@ -227,7 +227,8 @@
/*
-=item C<void pop_exception(Parrot_Interp interpreter)>
+=item C<void
+pop_exception(Parrot_Interp interpreter)>
Pops the topmost exception handler off the stack.
@@ -364,7 +365,8 @@
/*
-=item C<void rethrow_c_exception(Parrot_Interp interpreter)>
+=item C<void
+rethrow_c_exception(Parrot_Interp interpreter)>
Return back to runloop, assumes exception is still in C<REG_PMC(5)> and
that this is called from within a handler setup with C<new_c_exception>
@@ -515,7 +517,8 @@
/*
=item C<void
-do_exception(exception_severity severity, long error)>
+do_exception(Parrot_Interp interpreter,
+ exception_severity severity, long error)>
Called from interrupt code. Does a C<longjmp> in front of the runloop,
which calls C<handle_exception()>, returning the handler address where
--- src/warnings.c~ Sun Jan 25 11:33:28 2004
+++ src/warnings.c Fri Feb 20 14:01:38 2004
@@ -65,6 +65,34 @@
=item C<void
print_pbc_location(Parrot_Interp interpreter)>
+Prints the bytecode location of the warning or error to C<PIO_STDERR>.
+
+=cut
+
+*/
+
+void
+print_pbc_location(Parrot_Interp interpreter)
+{
+ const char *file;
+ int line;
+ struct PackFile_Debug * debugs = interpreter->code->cur_cs->debugs;
+ if (debugs) {
+ file = debugs->filename;
+ line = find_line(interpreter, debugs);
+ }
+ else {
+ file = "(unknown file)";
+ line = -1;
+ }
+ PIO_eprintf(interpreter, "\tin file '%s' near line %d\n", file, line);
+}
+
+/*
+
+=item C<void
+print_pbc_location_stdio(Parrot_Interp interpreter)>
+
Prints the bytecode location of the warning or error to C<stderr>.
Uses C<fprintf()> only. This may be called from exceptions.
@@ -74,7 +102,7 @@
*/
void
-print_pbc_location(Parrot_Interp interpreter)
+print_pbc_location_stdio(Parrot_Interp interpreter)
{
const char *file;
int line;
@@ -106,11 +134,11 @@
{
if (!msg)
- fprintf(stderr, "Unknown warning\n");
+ PIO_puts(interpreter, PIO_STDERR(interpreter), "Unknown warning\n");
else {
PIO_putps(interpreter, PIO_STDERR(interpreter), msg);
if (string_ord(msg, -1) != '\n')
- fprintf(stderr, "%c", '\n');
+ PIO_eprintf(interpreter, "%c", '\n');
}
print_pbc_location(interpreter);
return 1;