pp_indentation (pp) = 0;
}
-/* Insert enough spaces into the output area of PRETTY-PRINTER to bring
- the column position to the current indentation level, assuming that a
- newline has just been written to the buffer. */
-static void
-pp_indent (pretty_printer *pp)
-{
- int n = pp_indentation (pp);
- int i;
-
- for (i = 0; i < n; ++i)
- pp_space (pp);
-}
-
/* Flush the formatted text of PRETTY-PRINTER onto the attached stream. */
static inline void
pp_write_text_to_stream (pretty_printer *pp)
pp->buffer->line_length += length;
}
+/* Insert enough spaces into the output area of PRETTY-PRINTER to bring
+ the column position to the current indentation level, assuming that a
+ newline has just been written to the buffer. */
+void
+pp_base_indent (pretty_printer *pp)
+{
+ int n = pp_indentation (pp);
+ int i;
+
+ for (i = 0; i < n; ++i)
+ pp_space (pp);
+}
+
/* Format a message pointed to by TEXT. The following format specifiers are
recognized as being client independent:
%d, %i: (signed) integer in base ten.
%*.s: a substring the length of which is specified by an integer.
%H: location_t. */
void
-pp_format_text (pretty_printer *pp, text_info *text)
+pp_base_format_text (pretty_printer *pp, text_info *text)
{
for (; *text->format_spec; ++text->format_spec)
{
default:
break;
}
- /* We don't support precision behond that of "long long". */
+ /* We don't support precision beyond that of "long long". */
if (precision > 2)
abort();
/* Helper subroutine of output_verbatim and verbatim. Do the appropriate
settings needed by BUFFER for a verbatim formatting. */
void
-pp_format_verbatim (pretty_printer *pp, text_info *text)
+pp_base_format_verbatim (pretty_printer *pp, text_info *text)
{
diagnostic_prefixing_rule_t rule = pp_prefixing_rule (pp);
int line_cutoff = pp_line_cutoff (pp);
/* Flush the content of BUFFER onto the attached stream. */
void
-pp_flush (pretty_printer *pp)
+pp_base_flush (pretty_printer *pp)
{
pp_write_text_to_stream (pp);
pp_clear_state (pp);
output in line-wrapping mode. A LENGTH value 0 suppresses
line-wrapping. */
void
-pp_set_line_maximum_length (pretty_printer *pp, int length)
+pp_base_set_line_maximum_length (pretty_printer *pp, int length)
{
pp_line_cutoff (pp) = length;
pp_set_real_maximum_length (pp);
/* Clear PRETTY-PRINTER output area text info. */
void
-pp_clear_output_area (pretty_printer *pp)
+pp_base_clear_output_area (pretty_printer *pp)
{
obstack_free (&pp->buffer->obstack, obstack_base (&pp->buffer->obstack));
pp->buffer->line_length = 0;
/* Set PREFIX for PRETTY-PRINTER. */
void
-pp_set_prefix (pretty_printer *pp, const char *prefix)
+pp_base_set_prefix (pretty_printer *pp, const char *prefix)
{
pp->prefix = prefix;
pp_set_real_maximum_length (pp);
/* Free PRETTY-PRINTER's prefix, a previously malloc()'d string. */
void
-pp_destroy_prefix (pretty_printer *pp)
+pp_base_destroy_prefix (pretty_printer *pp)
{
if (pp->prefix != NULL)
{
/* Write out PRETTY-PRINTER's prefix. */
void
-pp_emit_prefix (pretty_printer *pp)
+pp_base_emit_prefix (pretty_printer *pp)
{
if (pp->prefix != NULL)
{
case DIAGNOSTICS_SHOW_PREFIX_ONCE:
if (pp->emitted_prefix)
{
- pp_indent (pp);
+ pp_base_indent (pp);
break;
}
pp_indentation (pp) += 3;
pp_construct (pretty_printer *pp, const char *prefix, int maximum_length)
{
memset (pp, 0, sizeof (pretty_printer));
- pp->buffer = xmalloc (sizeof (output_buffer));
+ pp->buffer = xcalloc (1, sizeof (output_buffer));
obstack_init (&pp->buffer->obstack);
pp->buffer->stream = stderr;
pp_line_cutoff (pp) = maximum_length;
whitespace if appropriate. The caller must ensure that it is
safe to do so. */
void
-pp_append_text (pretty_printer *pp, const char *start, const char *end)
+pp_base_append_text (pretty_printer *pp, const char *start, const char *end)
{
/* Emit prefix and skip whitespace if we're starting a new line. */
if (pp->buffer->line_length == 0)
/* Finishes constructing a NULL-terminated character string representing
the PRETTY-PRINTED text. */
const char *
-pp_formatted_text (pretty_printer *pp)
+pp_base_formatted_text (pretty_printer *pp)
{
obstack_1grow (&pp->buffer->obstack, '\0');
return pp_formatted_text_data (pp);
/* Return a pointer to the last character emitted in PRETTY-PRINTER's
output area. A NULL pointer means no character available. */
const char *
-pp_last_position_in_text (const pretty_printer *pp)
+pp_base_last_position_in_text (const pretty_printer *pp)
{
const char *p = NULL;
struct obstack *text = &pp->buffer->obstack;
/* Return the amount of characters PRETTY-PRINTER can accept to
make a full line. Meaningfull only in line-wrapping mode. */
int
-pp_remaining_character_count_for_line (pretty_printer *pp)
+pp_base_remaining_character_count_for_line (pretty_printer *pp)
{
return pp->maximum_length - pp->buffer->line_length;
}
/* Have PRETTY-PRINTER start a new line. */
void
-pp_newline (pretty_printer *pp)
+pp_base_newline (pretty_printer *pp)
{
obstack_1grow (&pp->buffer->obstack, '\n');
pp->buffer->line_length = 0;
/* Have PRETTY-PRINTER add a CHARACTER. */
void
-pp_character (pretty_printer *pp, int c)
+pp_base_character (pretty_printer *pp, int c)
{
if (pp_is_wrapping_line (pp)
&& pp_remaining_character_count_for_line (pp) <= 0)
/* Append a STRING to the output area of PRETTY-PRINTER; the STRING may
be line-wrapped if in appropriate mode. */
void
-pp_string (pretty_printer *pp, const char *str)
+pp_base_string (pretty_printer *pp, const char *str)
{
pp_maybe_wrap_text (pp, str, str + (str ? strlen (str) : 0));
}