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 *));
static char *vbuild_message_string PARAMS ((const char *, va_list));
static char *build_message_string PARAMS ((const char *, ...))
static void wrap_text PARAMS ((output_buffer *, const char *, const char *));
static void maybe_wrap_text PARAMS ((output_buffer *, const char *,
const char *));
-static void clear_text_info PARAMS ((output_buffer *));
static void clear_diagnostic_info PARAMS ((output_buffer *));
static void default_diagnostic_starter PARAMS ((output_buffer *,
set_real_maximum_length (buffer)
output_buffer *buffer;
{
- /* If we're told not to wrap lines then do the obvious thing. */
- if (! output_is_line_wrapping (buffer))
+ /* If we're told not to wrap lines then do the obvious thing. In case
+ we'll emit prefix only once per diagnostic message, it is appropriate
+ not to increase unncessarily the line-length cut-off. */
+ if (! output_is_line_wrapping (buffer)
+ || prefixing_policy (buffer) == DIAGNOSTICS_SHOW_PREFIX_ONCE
+ || prefixing_policy (buffer) == DIAGNOSTICS_SHOW_PREFIX_NEVER)
line_wrap_cutoff (buffer) = ideal_line_wrap_cutoff (buffer);
else
{
output_prefix (buffer) = prefix;
set_real_maximum_length (buffer);
prefix_was_emitted_for (buffer) = 0;
+ output_indentation (buffer) = 0;
+}
+
+/* Return a pointer to the last character emitted in the output
+ BUFFER area. A NULL pointer means no character available. */
+const char *
+output_last_position (buffer)
+ const output_buffer *buffer;
+{
+ const char *p = NULL;
+
+ if (obstack_base (&buffer->obstack) != obstack_next_free (&buffer->obstack))
+ p = ((const char *) obstack_next_free (&buffer->obstack)) - 1;
+ return p;
}
/* Free BUFFER's prefix, a previously malloc'd string. */
/* Zero out any text output so far in BUFFER. */
-static void
-clear_text_info (buffer)
+void
+output_clear_message_text (buffer)
output_buffer *buffer;
{
obstack_free (&buffer->obstack, obstack_base (&buffer->obstack));
output_buffer_text_cursor (buffer) = NULL;
output_buffer_ptr_to_format_args (buffer) = NULL;
prefix_was_emitted_for (buffer) = 0;
+ output_indentation (buffer) = 0;
}
/* Construct an output BUFFER with PREFIX and of MAXIMUM_LENGTH
output_clear (buffer)
output_buffer *buffer;
{
- clear_text_info (buffer);
+ output_clear_message_text (buffer);
clear_diagnostic_info (buffer);
}
the BUFFERed message. */
const char *
-output_finish (buffer)
+output_finalize_message (buffer)
output_buffer *buffer;
{
obstack_1grow (&buffer->obstack, '\0');
- return (const char *) obstack_finish (&buffer->obstack);
+ return output_message_text (buffer);
+}
+
+void
+flush_diagnostic_buffer ()
+{
+ output_to_stream (diagnostic_buffer, stderr);
+ fflush (stderr);
}
/* Return the amount of characters BUFFER can accept to
case DIAGNOSTICS_SHOW_PREFIX_ONCE:
if (prefix_was_emitted_for (buffer))
- break;
- /* Else fall through. */
+ {
+ output_indent (buffer);
+ break;
+ }
+ output_indentation (buffer) += 3;
+ /* Fall through. */
case DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE:
{
output_append_r (buffer, start, end - start);
}
+static void
+output_indent (buffer)
+ output_buffer *buffer;
+{
+ int n = output_indentation (buffer);
+ int i;
+
+ for (i = 0; i < n; ++i)
+ output_add_character (buffer, ' ');
+}
+
/* Wrap a text delimited by START and END into BUFFER. */
static void
output_buffer *buffer;
FILE *file;
{
- const char *text = output_finish (buffer);
+ const char *text = output_finalize_message (buffer);
fputs (text, file);
- clear_text_info (buffer);
+ output_clear_message_text (buffer);
}
/* Format a message pointed to by output_buffer_text_cursor (BUFFER) using
output_unsigned_decimal
(buffer, va_arg (output_buffer_format_args (buffer),
unsigned int));
+ break;
case 'x':
if (long_integer)
char *message = vbuild_message_string (msgid,
output_buffer_format_args (buffer));
- output_add_string (buffer, message);
+ wrap_text (buffer, message, message + strlen (message));
free (message);
}
count_error (warningp)
int warningp;
{
- if (warningp && inhibit_warnings)
+ if (warningp
+ && (inhibit_warnings
+ || (in_system_header && !warn_system_headers)))
return 0;
if (warningp && !warnings_are_errors)
output_set_prefix (diagnostic_buffer, prefix);
if (current_function_decl == NULL)
- {
output_add_string (diagnostic_buffer, "At top level:");
- output_add_newline (diagnostic_buffer);
- }
else
{
if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
output_printf
- (diagnostic_buffer, "In method `%s':\n",
+ (diagnostic_buffer, "In method `%s':",
(*decl_printable_name) (current_function_decl, 2));
else
output_printf
- (diagnostic_buffer, "In function `%s':\n",
+ (diagnostic_buffer, "In function `%s':",
(*decl_printable_name) (current_function_decl, 2));
}
+ output_add_newline (diagnostic_buffer);
record_last_error_function ();
output_to_stream (diagnostic_buffer, stderr);