2 Copyright (C) 2001-2003, The Perl Foundation.
7 src/warnings.c - Warning and error reporting
11 Parrot C<STRING> and C string versions of a function to print warning/error
20 #include "parrot/parrot.h"
28 print_pbc_location(Parrot_Interp interpreter)>
30 Prints the bytecode location of the warning or error to C<PIO_STDERR>.
37 print_pbc_location(Parrot_Interp interpreter
)
39 Interp
* const tracer
=
40 interpreter
->debugger
?
41 interpreter
->debugger
: interpreter
;
42 PIO_eprintf(tracer
, "%Ss\n",
43 Parrot_Context_infostr(interpreter
,
44 CONTEXT(interpreter
->ctx
)));
50 print_warning(Interp *interpreter, STRING *msg)>
52 Prints the warning message and the bytecode location.
59 print_warning(Interp
*interpreter
, STRING
*msg
)
63 PIO_puts(interpreter
, PIO_STDERR(interpreter
), "Unknown warning\n");
65 PIO_putps(interpreter
, PIO_STDERR(interpreter
), msg
);
66 if (string_ord(interpreter
, msg
, -1) != '\n')
67 PIO_eprintf(interpreter
, "%c", '\n');
69 print_pbc_location(interpreter
);
77 =head2 Parrot Warnings Interface
82 Parrot_warn(Interp *interpreter, INTVAL warnclass,
83 const char *message, ...)>
85 The Parrot C string warning/error reporter.
87 Returns 2 on error, 1 on success.
89 C<message, ..> can be a C<Parrot_vsprintf_c()> format with arguments.
96 Parrot_warn(Interp
*interpreter
, INTVAL warnclass
,
97 const char *message
, ...)
104 if (!PARROT_WARNINGS_test(interpreter
, warnclass
))
107 va_start(args
, message
);
108 targ
= Parrot_vsprintf_c(interpreter
, message
, args
);
110 return print_warning(interpreter
, targ
);
117 Parrot_warn_s(Interp *interpreter, INTVAL warnclass,
118 STRING *message, ...)>
120 The Parrot C<STRING> warning/error reporter.
122 Returns 2 on error, 1 on success.
124 C<message, ..> can be a C<Parrot_vsprintf_s()> format with arguments.
131 Parrot_warn_s(Interp
*interpreter
, INTVAL warnclass
,
132 STRING
*message
, ...)
138 if (!interpreter
|| !PARROT_WARNINGS_test(interpreter
, warnclass
))
141 va_start(args
, message
);
142 targ
= Parrot_vsprintf_s(interpreter
, message
, args
);
145 return print_warning(interpreter
, targ
);
154 F<include/parrot/warnings.h>.
163 * c-file-style: "parrot"
165 * vim: expandtab shiftwidth=4: