MAINLINE PATCH to diagnostics.*
Gabriel Dos Reis
gdr@codesourcery.com
Fri Feb 23 09:37:00 GMT 2001
This patch abstracts over explicit stream manipulation in the
diagnostics library -- it now makes it possible to use the existing
machinery to build separate output buffers.
Bootstrapped on an i686-pc-linux-gnu. No regression.
-- Gaby
CodeSourcery, LLC http://www.codesourcery.com
http://www.codesourcery.com/gcc-compile.shtml
2001-02-23 Gabriel Dos Reis <gdr@merlin.codesourcery.com>
* diagnostic.c (output_to_stream): Rename to
output_buffer_to_stream. Loses the stream parameter.
(init_output_buffer): Set diagnosic_buffer's stream.
(flush_diagnostic_buffer): Adjust.
(default_print_error_function): Likewise.
(finish_diagnostic): Likewise.
(verbatim): Likewise.
* diagnostic.h (struct output_buffer): Add `stream' field.
(output_buffer_attached_stream): New macro.
Index: diagnostic.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.h,v
retrieving revision 1.22
diff -p -r1.22 diagnostic.h
*** diagnostic.h 2001/02/04 22:43:57 1.22
--- diagnostic.h 2001/02/23 16:17:42
*************** struct output_buffer
*** 80,85 ****
--- 80,87 ----
/* Internal data. These fields should not be accessed directly by
front-ends. */
+ /* Where to output formatted text. */
+ FILE* stream;
/* The obstack where the text is built up. */
struct obstack obstack;
/* The amount of characters output so far. */
*************** struct output_buffer
*** 88,93 ****
--- 90,96 ----
output_state state;
};
+ #define output_buffer_attached_stream(BUFFER) (BUFFER)->stream
#define output_buffer_text_cursor(BUFFER) (BUFFER)->state.cursor
#define output_buffer_format_args(BUFFER) *((BUFFER)->state.format_args)
#define output_needs_newline(BUFFER) (BUFFER)->state.need_newline_p
Index: diagnostic.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/diagnostic.c,v
retrieving revision 1.52
diff -p -r1.52 diagnostic.c
*** diagnostic.c 2001/02/18 15:17:36 1.52
--- diagnostic.c 2001/02/23 16:17:43
*************** Boston, MA 02111-1307, USA. */
*** 65,71 ****
static void finish_diagnostic PARAMS ((void));
static void output_do_verbatim PARAMS ((output_buffer *,
const char *, va_list *));
! static void output_to_stream PARAMS ((output_buffer *, FILE *));
static void output_format PARAMS ((output_buffer *));
static void output_indent PARAMS ((output_buffer *));
--- 65,71 ----
static void finish_diagnostic PARAMS ((void));
static void output_do_verbatim PARAMS ((output_buffer *,
const char *, va_list *));
! static void output_buffer_to_stream PARAMS ((output_buffer *));
static void output_format PARAMS ((output_buffer *));
static void output_indent PARAMS ((output_buffer *));
*************** init_output_buffer (buffer, prefix, maxi
*** 340,345 ****
--- 340,346 ----
{
memset (buffer, 0, sizeof (output_buffer));
obstack_init (&buffer->obstack);
+ output_buffer_attached_stream (buffer) = stderr;
ideal_line_wrap_cutoff (buffer) = maximum_length;
prefixing_policy (buffer) = current_prefixing_rule;
output_set_prefix (buffer, prefix);
*************** output_finalize_message (buffer)
*** 393,400 ****
void
flush_diagnostic_buffer ()
{
! output_to_stream (diagnostic_buffer, stderr);
! fflush (stderr);
}
/* Return the amount of characters BUFFER can accept to
--- 394,401 ----
void
flush_diagnostic_buffer ()
{
! output_buffer_to_stream (diagnostic_buffer);
! fflush (output_buffer_attached_stream (diagnostic_buffer));
}
/* Return the amount of characters BUFFER can accept to
*************** output_add_string (buffer, str)
*** 654,668 ****
maybe_wrap_text (buffer, str, str + (str ? strlen (str) : 0));
}
! /* Flush the content of BUFFER onto FILE and reinitialize BUFFER. */
static void
! output_to_stream (buffer, file)
output_buffer *buffer;
- FILE *file;
{
const char *text = output_finalize_message (buffer);
! fputs (text, file);
output_clear_message_text (buffer);
}
--- 655,669 ----
maybe_wrap_text (buffer, str, str + (str ? strlen (str) : 0));
}
! /* Flush the content of BUFFER onto the attached stream,
! and reinitialize. */
static void
! output_buffer_to_stream (buffer)
output_buffer *buffer;
{
const char *text = output_finalize_message (buffer);
! fputs (text, output_buffer_attached_stream (buffer));
output_clear_message_text (buffer);
}
*************** default_print_error_function (file)
*** 1294,1300 ****
output_add_newline (diagnostic_buffer);
record_last_error_function ();
! output_to_stream (diagnostic_buffer, stderr);
output_buffer_state (diagnostic_buffer) = os;
free ((char*) prefix);
}
--- 1295,1301 ----
output_add_newline (diagnostic_buffer);
record_last_error_function ();
! output_buffer_to_stream (diagnostic_buffer);
output_buffer_state (diagnostic_buffer) = os;
free ((char*) prefix);
}
*************** warning VPARAMS ((const char *msgid, ...
*** 1600,1609 ****
static void
finish_diagnostic ()
{
! output_to_stream (diagnostic_buffer, stderr);
clear_diagnostic_info (diagnostic_buffer);
! fputc ('\n', stderr);
! fflush (stderr);
}
/* Helper subroutine of output_verbatim and verbatim. Do the approriate
--- 1601,1610 ----
static void
finish_diagnostic ()
{
! output_buffer_to_stream (diagnostic_buffer);
clear_diagnostic_info (diagnostic_buffer);
! fputc ('\n', output_buffer_attached_stream (diagnostic_buffer));
! fflush (output_buffer_attached_stream (diagnostic_buffer));
}
/* Helper subroutine of output_verbatim and verbatim. Do the approriate
*************** verbatim VPARAMS ((const char *msg, ...)
*** 1662,1668 ****
msg = va_arg (ap, const char *);
#endif
output_do_verbatim (diagnostic_buffer, msg, &ap);
! output_to_stream (diagnostic_buffer, stderr);
va_end (ap);
}
--- 1663,1669 ----
msg = va_arg (ap, const char *);
#endif
output_do_verbatim (diagnostic_buffer, msg, &ap);
! output_buffer_to_stream (diagnostic_buffer);
va_end (ap);
}
More information about the Gcc-patches
mailing list