2003-07-25 11:52:32 +02:00
|
|
|
|
/* Various declarations for language-independent pretty-print subroutines.
|
diagnostic.c: Don't include tm.h, tree.h, tm_p.h, langhooks.h or langhooks-def.h.
* diagnostic.c: Don't include tm.h, tree.h, tm_p.h, langhooks.h or
langhooks-def.h.
(diagnostic_initialize): Initialize x_data not last_function.
(diagnostic_report_current_function): Move to tree-diagnostic.c.
(default_diagnostic_starter): Call
diagnostic_report_current_module not
diagnostic_report_current_function.
(diagnostic_report_diagnostic): Initialize x_data not
abstract_origin.
(verbatim): Likewise.
* diagnostic.h (struct diagnostic_info): Change abstract_origin to
x_data.
(struct diagnostic_context): Change last_function to x_data.
(diagnostic_auxiliary_data): Replace with
diagnostic_context_auxiliary_data and
diagnostic_info_auxiliary_data.
(diagnostic_last_function_changed, diagnostic_set_last_function,
diagnostic_report_current_function): Move to tree-diagnostic.h.
(print_declaration, dump_generic_node, print_generic_stmt,
print_generic_stmt_indented, print_generic_expr,
print_generic_decl, debug_c_tree, dump_omp_clauses,
print_call_name, debug_generic_expr, debug_generic_stmt,
debug_tree_chain, default_tree_printer): Move to
tree-pretty-print.h.
(debug_gimple_stmt, debug_gimple_seq, print_gimple_seq,
print_gimple_stmt, print_gimple_expr, dump_gimple_stmt): Move to
gimple-pretty-print.h.
* pretty-print.c: Don't include tree.h
(pp_base_format): Don't handle %K here.
(pp_base_tree_identifier): Move to tree-pretty-print.c.
* pretty-print.h (text_info): Change abstract_origin to x_data.
(pp_tree_identifier, pp_unsupported_tree,
pp_base_tree_identifier): Move to tree-pretty-print.h.
* gimple-pretty-print.h, tree-diagnostic.c, tree-diagnostic.h,
tree-pretty-print.h: New files.
* tree-pretty-print.c: Include tree-pretty-print.h.
(percent_K_format): New. Moved from pretty-print.c.
(pp_base_tree_identifier): Move from pretty-print.c.
* c-objc-common.c: Include tree-pretty-print.h.
(c_tree_printer): Handle %K here.
* langhooks.c: Include tree-diagnostic.h.
(lhd_print_error_function): Use diagnostic_abstract_origin macro.
* toplev.c: Include tree-diagnostic.h and tree-pretty-print.h.
(default_tree_printer): Handle %K using percent_K_format.
(general_init): Use default_tree_diagnostic_starter.
* tree.c: Include tree-diagnostic.h and tree-pretty-print.h.
(free_lang_data): Use default_tree_diagnostic_starter.
* c-pretty-print.c: Include tree-pretty-print.h.
* cfgexpand.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* cgraphunit.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* dwarf2out.c: Include tree-pretty-print.h.
* except.c: Include tree-pretty-print.h.
* gimple-pretty-print.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* gimplify.c: Include tree-pretty-print.h.
* graphite-poly.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* ipa-cp.c: Include tree-pretty-print.h.
* ipa-inline.c: Include gimple-pretty-print.h.
* ipa-prop.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* ipa-pure-const.c: Include gimple-pretty-print.h.
* ipa-struct-reorg.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* ipa-type-escape.c: Include tree-pretty-print.h.
* print-rtl.c: Include tree-pretty-print.h.
* print-tree.c: Include gimple-pretty-print.h.
* sese.c: Include tree-pretty-print.h.
* tree-affine.c: Include tree-pretty-print.h.
* tree-browser.c: Include tree-pretty-print.h.
* tree-call-cdce.c: Include gimple-pretty-print.h.
* tree-cfg.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-chrec.c: Include tree-pretty-print.h.
* tree-data-ref.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-dfa.c: Include tree-pretty-print.h.
* tree-if-conv.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-inline.c: Include tree-pretty-print.h.
* tree-into-ssa.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-nrv.c: Include tree-pretty-print.h.
* tree-object-size.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-outof-ssa.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-parloops.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-predcom.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-scalar-evolution.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-sra.c: Include tree-pretty-print.h.
* tree-ssa-address.c: Include tree-pretty-print.h.
* tree-ssa-alias.c: Include tree-pretty-print.h.
* tree-ssa-ccp.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-coalesce.c: Include tree-pretty-print.h.
* tree-ssa-copy.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-copyrename.c: Include tree-pretty-print.h.
* tree-ssa-dce.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-dom.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-dse.c: Include gimple-pretty-print.h.
* tree-ssa-forwprop.c: Include tree-pretty-print.h.
* tree-ssa-ifcombine.c: Include tree-pretty-print.h.
* tree-ssa-live.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-loop-im.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-loop-ivcanon.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-loop-ivopts.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-loop-niter.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-loop-prefetch.c: Include tree-pretty-print.h.
* tree-ssa-math-opts.c: Include gimple-pretty-print.h.
* tree-ssa-operands.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-phiprop.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-pre.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-propagate.c: Include gimple-pretty-print.h.
* tree-ssa-reassoc.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-sccvn.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-sink.c: Include gimple-pretty-print.h.
* tree-ssa-ter.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-uninit.c: Include gimple-pretty-print.h.
* tree-ssa.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-stdarg.c: Include gimple-pretty-print.h.
* tree-switch-conversion.c: Include gimple-pretty-print.h.
* tree-tailcall.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vect-data-refs.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vect-loop-manip.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vect-loop.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vect-patterns.c: Include gimple-pretty-print.h.
* tree-vect-slp.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vect-stmts.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vectorizer.c: Include tree-pretty-print.h.
* tree-vrp.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* value-prof.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* var-tracking.c: Include tree-pretty-print.h.
* Makefile.in (OBJS-common): Add tree-diagnostic.o.
(tree-diagnostic.o): New dependencies.
(c-objc-common.o, c-pretty-print.o, langhooks.o, tree.o,
tree-inline.o, print-tree.o, stor-layout.o, tree-ssa-uninit.o,
tree-ssa.o, tree-into-ssa.o, tree-ssa-ter.o, tree-ssa-coalesce.o,
tree-outof-ssa.o, tree-ssa-forwprop.o, tree-ssa-phiprop.o,
tree-ssa-ifcombine.o, tree-nrv.o, tree-ssa-copy.o,
tree-ssa-propagate.o, tree-ssa-dom.o, tree-ssa-uncprop.o,
tree-ssa-live.o, tree-ssa-copyrename.o, tree-ssa-pre.o,
tree-ssa-sccvn.o, tree-vrp.o, tree-cfg.o, tree-tailcall.o,
tree-ssa-sink.o, tree-if-conv.o, tree-dfa.o, tree-ssa-operands.o,
tree-ssa-address.o, tree-ssa-loop-niter.o,
tree-ssa-loop-ivcanon.o, tree-ssa-loop-prefetch.o, tree-predcom.o,
tree-ssa-loop-ivopts.o, tree-affine.o, tree-ssa-loop-im.o,
tree-ssa-math-opts.o, tree-ssa-alias.o, tree-ssa-reassoc.o,
gimplify.o, tree-browser.o, tree-chrec.o, tree-scalar-evolution.o,
tree-data-ref.o, sese.o, graphite-poly.o, tree-vect-loop.o,
tree-vect-loop-manip.o, tree-vect-patterns.o, tree-vect-slp.o,
tree-vect-stmts.o, tree-vect-data-refs.o, tree-vectorizer.o,
tree-parloops.o, tree-stdarg.o, tree-object-size.o,
gimple-pretty-print.o, tree-pretty-print.o, diagnostic.o,
toplev.o, print-rtl.o, except.o, dwarf2out.o, cgraphunit.o,
ipa-prop.o, ipa-cp.o, ipa-inline.o, ipa-pure-const.o,
ipa-type-escape.o, ipa-struct-reorg.o, tree-ssa-dce.o,
tree-call-cdce.o, tree-ssa-ccp.o, tree-sra.o,
tree-switch-conversion.o, var-tracking.o, value-prof.o,
cfgexpand.o, pretty-print.o): Update dependencies.
cp:
* error.c: Include tree-diagnostic.h and tree-pretty-print.h.
(cp_print_error_function): Use diagnostic_abstract_origin macro.
(cp_printer): Handle %K here using percent_K_format.
* cxx-pretty-print.c: Include tree-pretty-print.h.
* Make-lang.in (cp/error.o, cp/cxx-pretty-print.o): Update
dependencies.
From-SVN: r159685
2010-05-22 00:34:26 +02:00
|
|
|
|
Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010
|
|
|
|
|
Free Software Foundation, Inc.
|
2003-07-25 11:52:32 +02:00
|
|
|
|
Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
|
|
|
|
|
|
|
|
|
|
This file is part of GCC.
|
|
|
|
|
|
|
|
|
|
GCC is free software; you can redistribute it and/or modify it under
|
|
|
|
|
the terms of the GNU General Public License as published by the Free
|
2007-07-26 10:37:01 +02:00
|
|
|
|
Software Foundation; either version 3, or (at your option) any later
|
2003-07-25 11:52:32 +02:00
|
|
|
|
version.
|
|
|
|
|
|
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-07-26 10:37:01 +02:00
|
|
|
|
along with GCC; see the file COPYING3. If not see
|
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
2003-07-25 11:52:32 +02:00
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
#include "system.h"
|
|
|
|
|
#include "coretypes.h"
|
intl.h (open_quote, [...]): New.
* intl.h (open_quote, close_quote): New.
* intl.c (open_quote, close_quote): New.
(gcc_init_libintl): Set them.
* pretty-print.c: Include "intl.h".
(pp_base_format_text): Support 'q' format flag and %` and %'
formats. Use ' instead of ` in comments.
* c-format.c (gcc_diag_flag_specs, gcc_cxxdiag_flag_specs,
gcc_diag_char_table, gcc_cdiag_char_table, gcc_cxxdiag_char_table,
foramt_types_orig): Describe these new formats.
(decode_format_attr, check_function_format,
check_format_info_main): Use these new formats.
(status_warning): Use ATTRIBUTE_GCC_DIAG.
* toplev.c (ATTRIBUTE_GCC_DIAG): Increase required GCC version to
check these formats to 3.5.
From-SVN: r82215
2004-05-24 21:28:20 +02:00
|
|
|
|
#include "intl.h"
|
2003-07-25 11:52:32 +02:00
|
|
|
|
#include "pretty-print.h"
|
2009-05-04 14:23:50 +02:00
|
|
|
|
|
|
|
|
|
#if HAVE_ICONV
|
|
|
|
|
#include <iconv.h>
|
|
|
|
|
#endif
|
2003-07-25 11:52:32 +02:00
|
|
|
|
|
|
|
|
|
/* A pointer to the formatted diagnostic message. */
|
|
|
|
|
#define pp_formatted_text_data(PP) \
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
((const char *) obstack_base (pp_base (PP)->buffer->obstack))
|
2003-07-25 11:52:32 +02:00
|
|
|
|
|
|
|
|
|
/* Format an integer given by va_arg (ARG, type-specifier T) where
|
|
|
|
|
type-specifier is a precision modifier as indicated by PREC. F is
|
|
|
|
|
a string used to construct the appropriate format-specifier. */
|
|
|
|
|
#define pp_integer_with_precision(PP, ARG, PREC, T, F) \
|
|
|
|
|
do \
|
|
|
|
|
switch (PREC) \
|
|
|
|
|
{ \
|
|
|
|
|
case 0: \
|
|
|
|
|
pp_scalar (PP, "%" F, va_arg (ARG, T)); \
|
|
|
|
|
break; \
|
|
|
|
|
\
|
|
|
|
|
case 1: \
|
|
|
|
|
pp_scalar (PP, "%l" F, va_arg (ARG, long T)); \
|
|
|
|
|
break; \
|
|
|
|
|
\
|
|
|
|
|
case 2: \
|
2008-05-11 12:06:57 +02:00
|
|
|
|
pp_scalar (PP, "%" HOST_LONG_LONG_FORMAT F, va_arg (ARG, long long T)); \
|
2003-07-25 11:52:32 +02:00
|
|
|
|
break; \
|
|
|
|
|
\
|
|
|
|
|
default: \
|
|
|
|
|
break; \
|
|
|
|
|
} \
|
|
|
|
|
while (0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Subroutine of pp_set_maximum_length. Set up PRETTY-PRINTER's
|
|
|
|
|
internal maximum characters per line. */
|
|
|
|
|
static void
|
|
|
|
|
pp_set_real_maximum_length (pretty_printer *pp)
|
|
|
|
|
{
|
|
|
|
|
/* If we're told not to wrap lines then do the obvious thing. In case
|
|
|
|
|
we'll emit prefix only once per message, it is appropriate
|
|
|
|
|
not to increase unnecessarily the line-length cut-off. */
|
|
|
|
|
if (!pp_is_wrapping_line (pp)
|
|
|
|
|
|| pp_prefixing_rule (pp) == DIAGNOSTICS_SHOW_PREFIX_ONCE
|
|
|
|
|
|| pp_prefixing_rule (pp) == DIAGNOSTICS_SHOW_PREFIX_NEVER)
|
|
|
|
|
pp->maximum_length = pp_line_cutoff (pp);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int prefix_length = pp->prefix ? strlen (pp->prefix) : 0;
|
|
|
|
|
/* If the prefix is ridiculously too long, output at least
|
|
|
|
|
32 characters. */
|
|
|
|
|
if (pp_line_cutoff (pp) - prefix_length < 32)
|
|
|
|
|
pp->maximum_length = pp_line_cutoff (pp) + 32;
|
|
|
|
|
else
|
|
|
|
|
pp->maximum_length = pp_line_cutoff (pp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Clear PRETTY-PRINTER's output state. */
|
|
|
|
|
static inline void
|
|
|
|
|
pp_clear_state (pretty_printer *pp)
|
|
|
|
|
{
|
|
|
|
|
pp->emitted_prefix = false;
|
|
|
|
|
pp_indentation (pp) = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Flush the formatted text of PRETTY-PRINTER onto the attached stream. */
|
2004-05-13 08:41:07 +02:00
|
|
|
|
void
|
2003-07-25 11:52:32 +02:00
|
|
|
|
pp_write_text_to_stream (pretty_printer *pp)
|
|
|
|
|
{
|
|
|
|
|
const char *text = pp_formatted_text (pp);
|
|
|
|
|
fputs (text, pp->buffer->stream);
|
|
|
|
|
pp_clear_output_area (pp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Wrap a text delimited by START and END into PRETTY-PRINTER. */
|
|
|
|
|
static void
|
|
|
|
|
pp_wrap_text (pretty_printer *pp, const char *start, const char *end)
|
|
|
|
|
{
|
|
|
|
|
bool wrapping_line = pp_is_wrapping_line (pp);
|
|
|
|
|
|
|
|
|
|
while (start != end)
|
|
|
|
|
{
|
|
|
|
|
/* Dump anything bordered by whitespaces. */
|
|
|
|
|
{
|
|
|
|
|
const char *p = start;
|
|
|
|
|
while (p != end && !ISBLANK (*p) && *p != '\n')
|
|
|
|
|
++p;
|
|
|
|
|
if (wrapping_line
|
|
|
|
|
&& p - start >= pp_remaining_character_count_for_line (pp))
|
|
|
|
|
pp_newline (pp);
|
|
|
|
|
pp_append_text (pp, start, p);
|
|
|
|
|
start = p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (start != end && ISBLANK (*start))
|
|
|
|
|
{
|
|
|
|
|
pp_space (pp);
|
|
|
|
|
++start;
|
|
|
|
|
}
|
|
|
|
|
if (start != end && *start == '\n')
|
|
|
|
|
{
|
|
|
|
|
pp_newline (pp);
|
|
|
|
|
++start;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Same as pp_wrap_text but wrap text only when in line-wrapping mode. */
|
|
|
|
|
static inline void
|
|
|
|
|
pp_maybe_wrap_text (pretty_printer *pp, const char *start, const char *end)
|
|
|
|
|
{
|
|
|
|
|
if (pp_is_wrapping_line (pp))
|
|
|
|
|
pp_wrap_text (pp, start, end);
|
|
|
|
|
else
|
|
|
|
|
pp_append_text (pp, start, end);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Append to the output area of PRETTY-PRINTER a string specified by its
|
|
|
|
|
STARTing character and LENGTH. */
|
|
|
|
|
static inline void
|
|
|
|
|
pp_append_r (pretty_printer *pp, const char *start, int length)
|
|
|
|
|
{
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
obstack_grow (pp->buffer->obstack, start, length);
|
2003-07-25 11:52:32 +02:00
|
|
|
|
pp->buffer->line_length += length;
|
|
|
|
|
}
|
|
|
|
|
|
2003-08-10 20:17:06 +02:00
|
|
|
|
/* 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);
|
|
|
|
|
}
|
|
|
|
|
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
/* The following format specifiers are recognized as being client independent:
|
2003-07-25 11:52:32 +02:00
|
|
|
|
%d, %i: (signed) integer in base ten.
|
|
|
|
|
%u: unsigned integer in base ten.
|
|
|
|
|
%o: unsigned integer in base eight.
|
|
|
|
|
%x: unsigned integer in base sixteen.
|
|
|
|
|
%ld, %li, %lo, %lu, %lx: long versions of the above.
|
|
|
|
|
%lld, %lli, %llo, %llu, %llx: long long versions.
|
|
|
|
|
%wd, %wi, %wo, %wu, %wx: HOST_WIDE_INT versions.
|
|
|
|
|
%c: character.
|
|
|
|
|
%s: string.
|
|
|
|
|
%p: pointer.
|
|
|
|
|
%m: strerror(text->err_no) - does not consume a value from args_ptr.
|
intl.h (open_quote, [...]): New.
* intl.h (open_quote, close_quote): New.
* intl.c (open_quote, close_quote): New.
(gcc_init_libintl): Set them.
* pretty-print.c: Include "intl.h".
(pp_base_format_text): Support 'q' format flag and %` and %'
formats. Use ' instead of ` in comments.
* c-format.c (gcc_diag_flag_specs, gcc_cxxdiag_flag_specs,
gcc_diag_char_table, gcc_cdiag_char_table, gcc_cxxdiag_char_table,
foramt_types_orig): Describe these new formats.
(decode_format_attr, check_function_format,
check_format_info_main): Use these new formats.
(status_warning): Use ATTRIBUTE_GCC_DIAG.
* toplev.c (ATTRIBUTE_GCC_DIAG): Increase required GCC version to
check these formats to 3.5.
From-SVN: r82215
2004-05-24 21:28:20 +02:00
|
|
|
|
%%: '%'.
|
2004-05-29 22:10:10 +02:00
|
|
|
|
%<: opening quote.
|
|
|
|
|
%>: closing quote.
|
|
|
|
|
%': apostrophe (should only be used in untranslated messages;
|
|
|
|
|
translations should use appropriate punctuation directly).
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
%.*s: a substring the length of which is specified by an argument
|
|
|
|
|
integer.
|
|
|
|
|
%Ns: likewise, but length specified as constant in the format string.
|
|
|
|
|
Flag 'q': quote formatted text (must come immediately after '%').
|
|
|
|
|
|
|
|
|
|
Arguments can be used sequentially, or through %N$ resp. *N$
|
|
|
|
|
notation Nth argument after the format string. If %N$ / *N$
|
|
|
|
|
notation is used, it must be used for all arguments, except %m, %%,
|
|
|
|
|
%<, %> and %', which may not have a number, as they do not consume
|
|
|
|
|
an argument. When %M$.*N$s is used, M must be N + 1. (This may
|
|
|
|
|
also be written %M$.*s, provided N is not otherwise used.) The
|
|
|
|
|
format string must have conversion specifiers with argument numbers
|
|
|
|
|
1 up to highest argument; each argument may only be used once.
|
|
|
|
|
A format string can have at most 30 arguments. */
|
|
|
|
|
|
|
|
|
|
/* Formatting phases 1 and 2: render TEXT->format_spec plus
|
|
|
|
|
TEXT->args_ptr into a series of chunks in PP->buffer->args[].
|
|
|
|
|
Phase 3 is in pp_base_format_text. */
|
|
|
|
|
|
2003-07-25 11:52:32 +02:00
|
|
|
|
void
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
pp_base_format (pretty_printer *pp, text_info *text)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
output_buffer *buffer = pp->buffer;
|
|
|
|
|
const char *p;
|
|
|
|
|
const char **args;
|
|
|
|
|
struct chunk_info *new_chunk_array;
|
|
|
|
|
|
|
|
|
|
unsigned int curarg = 0, chunk = 0, argno;
|
|
|
|
|
pp_wrapping_mode_t old_wrapping_mode;
|
|
|
|
|
bool any_unnumbered = false, any_numbered = false;
|
|
|
|
|
const char **formatters[PP_NL_ARGMAX];
|
|
|
|
|
|
|
|
|
|
/* Allocate a new chunk structure. */
|
|
|
|
|
new_chunk_array = XOBNEW (&buffer->chunk_obstack, struct chunk_info);
|
|
|
|
|
new_chunk_array->prev = buffer->cur_chunk_array;
|
|
|
|
|
buffer->cur_chunk_array = new_chunk_array;
|
|
|
|
|
args = new_chunk_array->args;
|
|
|
|
|
|
|
|
|
|
/* Formatting phase 1: split up TEXT->format_spec into chunks in
|
|
|
|
|
PP->buffer->args[]. Even-numbered chunks are to be output
|
|
|
|
|
verbatim, odd-numbered chunks are format specifiers.
|
|
|
|
|
%m, %%, %<, %>, and %' are replaced with the appropriate text at
|
|
|
|
|
this point. */
|
|
|
|
|
|
|
|
|
|
memset (formatters, 0, sizeof formatters);
|
2009-11-25 11:55:54 +01:00
|
|
|
|
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
for (p = text->format_spec; *p; )
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
while (*p != '\0' && *p != '%')
|
|
|
|
|
{
|
|
|
|
|
obstack_1grow (&buffer->chunk_obstack, *p);
|
|
|
|
|
p++;
|
|
|
|
|
}
|
2003-07-25 11:52:32 +02:00
|
|
|
|
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
if (*p == '\0')
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
switch (*++p)
|
|
|
|
|
{
|
|
|
|
|
case '\0':
|
|
|
|
|
gcc_unreachable ();
|
2009-11-25 11:55:54 +01:00
|
|
|
|
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
case '%':
|
|
|
|
|
obstack_1grow (&buffer->chunk_obstack, '%');
|
|
|
|
|
p++;
|
|
|
|
|
continue;
|
2003-07-25 11:52:32 +02:00
|
|
|
|
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
case '<':
|
|
|
|
|
obstack_grow (&buffer->chunk_obstack,
|
|
|
|
|
open_quote, strlen (open_quote));
|
|
|
|
|
p++;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
case '>':
|
|
|
|
|
case '\'':
|
|
|
|
|
obstack_grow (&buffer->chunk_obstack,
|
2005-09-28 08:53:12 +02:00
|
|
|
|
close_quote, strlen (close_quote));
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
p++;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
case 'm':
|
|
|
|
|
{
|
|
|
|
|
const char *errstr = xstrerror (text->err_no);
|
|
|
|
|
obstack_grow (&buffer->chunk_obstack, errstr, strlen (errstr));
|
|
|
|
|
}
|
|
|
|
|
p++;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
/* Handled in phase 2. Terminate the plain chunk here. */
|
|
|
|
|
obstack_1grow (&buffer->chunk_obstack, '\0');
|
|
|
|
|
gcc_assert (chunk < PP_NL_ARGMAX * 2);
|
|
|
|
|
args[chunk++] = XOBFINISH (&buffer->chunk_obstack, const char *);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ISDIGIT (*p))
|
|
|
|
|
{
|
|
|
|
|
char *end;
|
|
|
|
|
argno = strtoul (p, &end, 10) - 1;
|
|
|
|
|
p = end;
|
|
|
|
|
gcc_assert (*p == '$');
|
|
|
|
|
p++;
|
|
|
|
|
|
|
|
|
|
any_numbered = true;
|
|
|
|
|
gcc_assert (!any_unnumbered);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
argno = curarg++;
|
|
|
|
|
any_unnumbered = true;
|
|
|
|
|
gcc_assert (!any_numbered);
|
|
|
|
|
}
|
|
|
|
|
gcc_assert (argno < PP_NL_ARGMAX);
|
|
|
|
|
gcc_assert (!formatters[argno]);
|
|
|
|
|
formatters[argno] = &args[chunk];
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
obstack_1grow (&buffer->chunk_obstack, *p);
|
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|
while (strchr ("qwl+#", p[-1]));
|
|
|
|
|
|
|
|
|
|
if (p[-1] == '.')
|
|
|
|
|
{
|
|
|
|
|
/* We handle '%.Ns' and '%.*s' or '%M$.*N$s'
|
|
|
|
|
(where M == N + 1). */
|
|
|
|
|
if (ISDIGIT (*p))
|
|
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
obstack_1grow (&buffer->chunk_obstack, *p);
|
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|
while (ISDIGIT (p[-1]));
|
|
|
|
|
gcc_assert (p[-1] == 's');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gcc_assert (*p == '*');
|
|
|
|
|
obstack_1grow (&buffer->chunk_obstack, '*');
|
|
|
|
|
p++;
|
|
|
|
|
|
|
|
|
|
if (ISDIGIT (*p))
|
|
|
|
|
{
|
|
|
|
|
char *end;
|
|
|
|
|
unsigned int argno2 = strtoul (p, &end, 10) - 1;
|
|
|
|
|
p = end;
|
|
|
|
|
gcc_assert (argno2 == argno - 1);
|
|
|
|
|
gcc_assert (!any_unnumbered);
|
|
|
|
|
gcc_assert (*p == '$');
|
|
|
|
|
|
|
|
|
|
p++;
|
|
|
|
|
formatters[argno2] = formatters[argno];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gcc_assert (!any_numbered);
|
|
|
|
|
formatters[argno+1] = formatters[argno];
|
|
|
|
|
curarg++;
|
|
|
|
|
}
|
|
|
|
|
gcc_assert (*p == 's');
|
|
|
|
|
obstack_1grow (&buffer->chunk_obstack, 's');
|
|
|
|
|
p++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (*p == '\0')
|
2003-07-25 11:52:32 +02:00
|
|
|
|
break;
|
|
|
|
|
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
obstack_1grow (&buffer->chunk_obstack, '\0');
|
|
|
|
|
gcc_assert (chunk < PP_NL_ARGMAX * 2);
|
|
|
|
|
args[chunk++] = XOBFINISH (&buffer->chunk_obstack, const char *);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
obstack_1grow (&buffer->chunk_obstack, '\0');
|
|
|
|
|
gcc_assert (chunk < PP_NL_ARGMAX * 2);
|
|
|
|
|
args[chunk++] = XOBFINISH (&buffer->chunk_obstack, const char *);
|
|
|
|
|
args[chunk] = 0;
|
2009-11-25 11:55:54 +01:00
|
|
|
|
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
/* Set output to the argument obstack, and switch line-wrapping and
|
|
|
|
|
prefixing off. */
|
|
|
|
|
buffer->obstack = &buffer->chunk_obstack;
|
|
|
|
|
old_wrapping_mode = pp_set_verbatim_wrapping (pp);
|
|
|
|
|
|
|
|
|
|
/* Second phase. Replace each formatter with the formatted text it
|
|
|
|
|
corresponds to. */
|
|
|
|
|
|
|
|
|
|
for (argno = 0; formatters[argno]; argno++)
|
|
|
|
|
{
|
|
|
|
|
int precision = 0;
|
|
|
|
|
bool wide = false;
|
|
|
|
|
bool plus = false;
|
|
|
|
|
bool hash = false;
|
|
|
|
|
bool quote = false;
|
|
|
|
|
|
|
|
|
|
/* We do not attempt to enforce any ordering on the modifier
|
|
|
|
|
characters. */
|
|
|
|
|
|
|
|
|
|
for (p = *formatters[argno];; p++)
|
intl.h (open_quote, [...]): New.
* intl.h (open_quote, close_quote): New.
* intl.c (open_quote, close_quote): New.
(gcc_init_libintl): Set them.
* pretty-print.c: Include "intl.h".
(pp_base_format_text): Support 'q' format flag and %` and %'
formats. Use ' instead of ` in comments.
* c-format.c (gcc_diag_flag_specs, gcc_cxxdiag_flag_specs,
gcc_diag_char_table, gcc_cdiag_char_table, gcc_cxxdiag_char_table,
foramt_types_orig): Describe these new formats.
(decode_format_attr, check_function_format,
check_format_info_main): Use these new formats.
(status_warning): Use ATTRIBUTE_GCC_DIAG.
* toplev.c (ATTRIBUTE_GCC_DIAG): Increase required GCC version to
check these formats to 3.5.
From-SVN: r82215
2004-05-24 21:28:20 +02:00
|
|
|
|
{
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
switch (*p)
|
|
|
|
|
{
|
|
|
|
|
case 'q':
|
|
|
|
|
gcc_assert (!quote);
|
|
|
|
|
quote = true;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
case '+':
|
|
|
|
|
gcc_assert (!plus);
|
|
|
|
|
plus = true;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
case '#':
|
|
|
|
|
gcc_assert (!hash);
|
|
|
|
|
hash = true;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
case 'w':
|
|
|
|
|
gcc_assert (!wide);
|
|
|
|
|
wide = true;
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
case 'l':
|
|
|
|
|
/* We don't support precision beyond that of "long long". */
|
|
|
|
|
gcc_assert (precision < 2);
|
|
|
|
|
precision++;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
break;
|
intl.h (open_quote, [...]): New.
* intl.h (open_quote, close_quote): New.
* intl.c (open_quote, close_quote): New.
(gcc_init_libintl): Set them.
* pretty-print.c: Include "intl.h".
(pp_base_format_text): Support 'q' format flag and %` and %'
formats. Use ' instead of ` in comments.
* c-format.c (gcc_diag_flag_specs, gcc_cxxdiag_flag_specs,
gcc_diag_char_table, gcc_cdiag_char_table, gcc_cxxdiag_char_table,
foramt_types_orig): Describe these new formats.
(decode_format_attr, check_function_format,
check_format_info_main): Use these new formats.
(status_warning): Use ATTRIBUTE_GCC_DIAG.
* toplev.c (ATTRIBUTE_GCC_DIAG): Increase required GCC version to
check these formats to 3.5.
From-SVN: r82215
2004-05-24 21:28:20 +02:00
|
|
|
|
}
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
|
|
|
|
|
gcc_assert (!wide || precision == 0);
|
|
|
|
|
|
|
|
|
|
if (quote)
|
intl.h (open_quote, [...]): New.
* intl.h (open_quote, close_quote): New.
* intl.c (open_quote, close_quote): New.
(gcc_init_libintl): Set them.
* pretty-print.c: Include "intl.h".
(pp_base_format_text): Support 'q' format flag and %` and %'
formats. Use ' instead of ` in comments.
* c-format.c (gcc_diag_flag_specs, gcc_cxxdiag_flag_specs,
gcc_diag_char_table, gcc_cdiag_char_table, gcc_cxxdiag_char_table,
foramt_types_orig): Describe these new formats.
(decode_format_attr, check_function_format,
check_format_info_main): Use these new formats.
(status_warning): Use ATTRIBUTE_GCC_DIAG.
* toplev.c (ATTRIBUTE_GCC_DIAG): Increase required GCC version to
check these formats to 3.5.
From-SVN: r82215
2004-05-24 21:28:20 +02:00
|
|
|
|
pp_string (pp, open_quote);
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
|
|
|
|
|
switch (*p)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
|
|
|
|
case 'c':
|
|
|
|
|
pp_character (pp, va_arg (*text->args_ptr, int));
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'd':
|
|
|
|
|
case 'i':
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
if (wide)
|
|
|
|
|
pp_wide_integer (pp, va_arg (*text->args_ptr, HOST_WIDE_INT));
|
|
|
|
|
else
|
|
|
|
|
pp_integer_with_precision
|
|
|
|
|
(pp, *text->args_ptr, precision, int, "d");
|
2003-07-25 11:52:32 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'o':
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
if (wide)
|
|
|
|
|
pp_scalar (pp, "%" HOST_WIDE_INT_PRINT "o",
|
|
|
|
|
va_arg (*text->args_ptr, unsigned HOST_WIDE_INT));
|
|
|
|
|
else
|
|
|
|
|
pp_integer_with_precision
|
|
|
|
|
(pp, *text->args_ptr, precision, unsigned, "o");
|
2003-07-25 11:52:32 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 's':
|
|
|
|
|
pp_string (pp, va_arg (*text->args_ptr, const char *));
|
|
|
|
|
break;
|
|
|
|
|
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
case 'p':
|
|
|
|
|
pp_pointer (pp, va_arg (*text->args_ptr, void *));
|
|
|
|
|
break;
|
2003-07-25 11:52:32 +02:00
|
|
|
|
|
|
|
|
|
case 'u':
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
if (wide)
|
|
|
|
|
pp_scalar (pp, HOST_WIDE_INT_PRINT_UNSIGNED,
|
|
|
|
|
va_arg (*text->args_ptr, unsigned HOST_WIDE_INT));
|
|
|
|
|
else
|
|
|
|
|
pp_integer_with_precision
|
|
|
|
|
(pp, *text->args_ptr, precision, unsigned, "u");
|
2003-07-25 11:52:32 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'x':
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
if (wide)
|
|
|
|
|
pp_scalar (pp, HOST_WIDE_INT_PRINT_HEX,
|
|
|
|
|
va_arg (*text->args_ptr, unsigned HOST_WIDE_INT));
|
|
|
|
|
else
|
|
|
|
|
pp_integer_with_precision
|
|
|
|
|
(pp, *text->args_ptr, precision, unsigned, "x");
|
2003-07-25 11:52:32 +02:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '.':
|
|
|
|
|
{
|
|
|
|
|
int n;
|
|
|
|
|
const char *s;
|
2004-10-06 06:47:42 +02:00
|
|
|
|
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
/* We handle '%.Ns' and '%.*s' or '%M$.*N$s'
|
|
|
|
|
(where M == N + 1). The format string should be verified
|
|
|
|
|
already from the first phase. */
|
|
|
|
|
p++;
|
|
|
|
|
if (ISDIGIT (*p))
|
|
|
|
|
{
|
|
|
|
|
char *end;
|
|
|
|
|
n = strtoul (p, &end, 10);
|
|
|
|
|
p = end;
|
|
|
|
|
gcc_assert (*p == 's');
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gcc_assert (*p == '*');
|
|
|
|
|
p++;
|
|
|
|
|
gcc_assert (*p == 's');
|
|
|
|
|
n = va_arg (*text->args_ptr, int);
|
|
|
|
|
|
|
|
|
|
/* This consumes a second entry in the formatters array. */
|
|
|
|
|
gcc_assert (formatters[argno] == formatters[argno+1]);
|
|
|
|
|
argno++;
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-25 11:52:32 +02:00
|
|
|
|
s = va_arg (*text->args_ptr, const char *);
|
|
|
|
|
pp_append_text (pp, s, s + n);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
lambda.h (lambda_vector_min_nz): Likewise.
* lambda.h (lambda_vector_min_nz): Likewise.
* langhooks.h (struct lang_hooks_for_types,
struct lang_hooks): Likewise.
* output.h (assemble_integer, this_is_asm_operands): Likewise.
* tree.h: Likewise.
* vec.h: Likewise.
* tree-flow-inline.h (relink_imm_use): Use gcc_assert.
* optabs.c (prepare_cmp_insn, emit_cmp_and_jump_insns): Reword
comments to avoid 'abort'. Use gcc_assert as necessary.
* opts.c (common_handle_option): Likewise.
* pretty-print.c (pp_base_format_text): Likewise.
* print-rtl.c (print_rtx): Likewise.
* read-rtl.c (read_rtx_filename, read_rtx_1): Likewise.
* regmove.c (try_auto_increment): Likewise.
* reload.c (find_valid_class, find_reloads_toplev,
find_equiv_reg): Likewise.
* reload1.c (reload, forget_old_reloads_1, function_invariant_p,
merge_assigned_reloads): Likewise.
* tree-inline.c (inline_forbidden_p_1,
estimate_num_insns_1): Likewise.
* tree-optimize.c (execute_todo): Likewise.
* tree-outof-ssa.c (eliminate_phi): Likewise.
* tree-ssa-alias.c (add_pointed_to_expr): Likewise.
* tree-ssa-ccp.c (maybe_fold_stmt_indirect): Likewise.
* tree-ssa-operands.c (parse_ssa_operands,
get_indirect_ref_operands, create_ssa_artficial_load_stmt): Likewise.
* tree-ssa-pre.c (find_or_generate_expression): Likewise.
* tree-ssanames.c (release_ssa_name): Likewise.
* tree.c (int_bit_position, int_byte_position, tree_low_cst,
walk_tree): Likewise.
* tree-ssa-operands.c (verify_abort): Fold into ..
(verify_imm_links): ... here.
From-SVN: r98519
2005-04-21 20:05:34 +02:00
|
|
|
|
{
|
|
|
|
|
bool ok;
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
|
lambda.h (lambda_vector_min_nz): Likewise.
* lambda.h (lambda_vector_min_nz): Likewise.
* langhooks.h (struct lang_hooks_for_types,
struct lang_hooks): Likewise.
* output.h (assemble_integer, this_is_asm_operands): Likewise.
* tree.h: Likewise.
* vec.h: Likewise.
* tree-flow-inline.h (relink_imm_use): Use gcc_assert.
* optabs.c (prepare_cmp_insn, emit_cmp_and_jump_insns): Reword
comments to avoid 'abort'. Use gcc_assert as necessary.
* opts.c (common_handle_option): Likewise.
* pretty-print.c (pp_base_format_text): Likewise.
* print-rtl.c (print_rtx): Likewise.
* read-rtl.c (read_rtx_filename, read_rtx_1): Likewise.
* regmove.c (try_auto_increment): Likewise.
* reload.c (find_valid_class, find_reloads_toplev,
find_equiv_reg): Likewise.
* reload1.c (reload, forget_old_reloads_1, function_invariant_p,
merge_assigned_reloads): Likewise.
* tree-inline.c (inline_forbidden_p_1,
estimate_num_insns_1): Likewise.
* tree-optimize.c (execute_todo): Likewise.
* tree-outof-ssa.c (eliminate_phi): Likewise.
* tree-ssa-alias.c (add_pointed_to_expr): Likewise.
* tree-ssa-ccp.c (maybe_fold_stmt_indirect): Likewise.
* tree-ssa-operands.c (parse_ssa_operands,
get_indirect_ref_operands, create_ssa_artficial_load_stmt): Likewise.
* tree-ssa-pre.c (find_or_generate_expression): Likewise.
* tree-ssanames.c (release_ssa_name): Likewise.
* tree.c (int_bit_position, int_byte_position, tree_low_cst,
walk_tree): Likewise.
* tree-ssa-operands.c (verify_abort): Fold into ..
(verify_imm_links): ... here.
From-SVN: r98519
2005-04-21 20:05:34 +02:00
|
|
|
|
gcc_assert (pp_format_decoder (pp));
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
ok = pp_format_decoder (pp) (pp, text, p,
|
|
|
|
|
precision, wide, plus, hash);
|
lambda.h (lambda_vector_min_nz): Likewise.
* lambda.h (lambda_vector_min_nz): Likewise.
* langhooks.h (struct lang_hooks_for_types,
struct lang_hooks): Likewise.
* output.h (assemble_integer, this_is_asm_operands): Likewise.
* tree.h: Likewise.
* vec.h: Likewise.
* tree-flow-inline.h (relink_imm_use): Use gcc_assert.
* optabs.c (prepare_cmp_insn, emit_cmp_and_jump_insns): Reword
comments to avoid 'abort'. Use gcc_assert as necessary.
* opts.c (common_handle_option): Likewise.
* pretty-print.c (pp_base_format_text): Likewise.
* print-rtl.c (print_rtx): Likewise.
* read-rtl.c (read_rtx_filename, read_rtx_1): Likewise.
* regmove.c (try_auto_increment): Likewise.
* reload.c (find_valid_class, find_reloads_toplev,
find_equiv_reg): Likewise.
* reload1.c (reload, forget_old_reloads_1, function_invariant_p,
merge_assigned_reloads): Likewise.
* tree-inline.c (inline_forbidden_p_1,
estimate_num_insns_1): Likewise.
* tree-optimize.c (execute_todo): Likewise.
* tree-outof-ssa.c (eliminate_phi): Likewise.
* tree-ssa-alias.c (add_pointed_to_expr): Likewise.
* tree-ssa-ccp.c (maybe_fold_stmt_indirect): Likewise.
* tree-ssa-operands.c (parse_ssa_operands,
get_indirect_ref_operands, create_ssa_artficial_load_stmt): Likewise.
* tree-ssa-pre.c (find_or_generate_expression): Likewise.
* tree-ssanames.c (release_ssa_name): Likewise.
* tree.c (int_bit_position, int_byte_position, tree_low_cst,
walk_tree): Likewise.
* tree-ssa-operands.c (verify_abort): Fold into ..
(verify_imm_links): ... here.
From-SVN: r98519
2005-04-21 20:05:34 +02:00
|
|
|
|
gcc_assert (ok);
|
|
|
|
|
}
|
2003-07-25 11:52:32 +02:00
|
|
|
|
}
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
|
|
|
|
|
if (quote)
|
intl.h (open_quote, [...]): New.
* intl.h (open_quote, close_quote): New.
* intl.c (open_quote, close_quote): New.
(gcc_init_libintl): Set them.
* pretty-print.c: Include "intl.h".
(pp_base_format_text): Support 'q' format flag and %` and %'
formats. Use ' instead of ` in comments.
* c-format.c (gcc_diag_flag_specs, gcc_cxxdiag_flag_specs,
gcc_diag_char_table, gcc_cdiag_char_table, gcc_cxxdiag_char_table,
foramt_types_orig): Describe these new formats.
(decode_format_attr, check_function_format,
check_format_info_main): Use these new formats.
(status_warning): Use ATTRIBUTE_GCC_DIAG.
* toplev.c (ATTRIBUTE_GCC_DIAG): Increase required GCC version to
check these formats to 3.5.
From-SVN: r82215
2004-05-24 21:28:20 +02:00
|
|
|
|
pp_string (pp, close_quote);
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
|
|
|
|
|
obstack_1grow (&buffer->chunk_obstack, '\0');
|
|
|
|
|
*formatters[argno] = XOBFINISH (&buffer->chunk_obstack, const char *);
|
2003-07-25 11:52:32 +02:00
|
|
|
|
}
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_CHECKING
|
|
|
|
|
for (; argno < PP_NL_ARGMAX; argno++)
|
|
|
|
|
gcc_assert (!formatters[argno]);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Revert to normal obstack and wrapping mode. */
|
|
|
|
|
buffer->obstack = &buffer->formatted_obstack;
|
|
|
|
|
buffer->line_length = 0;
|
|
|
|
|
pp_wrapping_mode (pp) = old_wrapping_mode;
|
|
|
|
|
pp_clear_state (pp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Format of a message pointed to by TEXT. */
|
|
|
|
|
void
|
|
|
|
|
pp_base_output_formatted_text (pretty_printer *pp)
|
|
|
|
|
{
|
|
|
|
|
unsigned int chunk;
|
|
|
|
|
output_buffer *buffer = pp_buffer (pp);
|
|
|
|
|
struct chunk_info *chunk_array = buffer->cur_chunk_array;
|
|
|
|
|
const char **args = chunk_array->args;
|
|
|
|
|
|
|
|
|
|
gcc_assert (buffer->obstack == &buffer->formatted_obstack);
|
|
|
|
|
gcc_assert (buffer->line_length == 0);
|
|
|
|
|
|
|
|
|
|
/* This is a third phase, first 2 phases done in pp_base_format_args.
|
|
|
|
|
Now we actually print it. */
|
|
|
|
|
for (chunk = 0; args[chunk]; chunk++)
|
|
|
|
|
pp_string (pp, args[chunk]);
|
|
|
|
|
|
|
|
|
|
/* Deallocate the chunk structure and everything after it (i.e. the
|
|
|
|
|
associated series of formatted strings). */
|
|
|
|
|
buffer->cur_chunk_array = chunk_array->prev;
|
|
|
|
|
obstack_free (&buffer->chunk_obstack, chunk_array);
|
2003-07-25 11:52:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Helper subroutine of output_verbatim and verbatim. Do the appropriate
|
|
|
|
|
settings needed by BUFFER for a verbatim formatting. */
|
|
|
|
|
void
|
2003-08-05 21:23:14 +02:00
|
|
|
|
pp_base_format_verbatim (pretty_printer *pp, text_info *text)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
|
|
|
|
/* Set verbatim mode. */
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
pp_wrapping_mode_t oldmode = pp_set_verbatim_wrapping (pp);
|
|
|
|
|
|
2003-07-25 11:52:32 +02:00
|
|
|
|
/* Do the actual formatting. */
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
pp_format (pp, text);
|
|
|
|
|
pp_output_formatted_text (pp);
|
|
|
|
|
|
2003-07-25 11:52:32 +02:00
|
|
|
|
/* Restore previous settings. */
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
pp_wrapping_mode (pp) = oldmode;
|
2003-07-25 11:52:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Flush the content of BUFFER onto the attached stream. */
|
|
|
|
|
void
|
2003-08-05 21:23:14 +02:00
|
|
|
|
pp_base_flush (pretty_printer *pp)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
|
|
|
|
pp_write_text_to_stream (pp);
|
|
|
|
|
pp_clear_state (pp);
|
|
|
|
|
fputc ('\n', pp->buffer->stream);
|
|
|
|
|
fflush (pp->buffer->stream);
|
2003-12-20 07:32:32 +01:00
|
|
|
|
pp_needs_newline (pp) = false;
|
2003-07-25 11:52:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Sets the number of maximum characters per line PRETTY-PRINTER can
|
|
|
|
|
output in line-wrapping mode. A LENGTH value 0 suppresses
|
|
|
|
|
line-wrapping. */
|
|
|
|
|
void
|
2003-08-05 21:23:14 +02:00
|
|
|
|
pp_base_set_line_maximum_length (pretty_printer *pp, int length)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
|
|
|
|
pp_line_cutoff (pp) = length;
|
|
|
|
|
pp_set_real_maximum_length (pp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Clear PRETTY-PRINTER output area text info. */
|
|
|
|
|
void
|
2003-08-05 21:23:14 +02:00
|
|
|
|
pp_base_clear_output_area (pretty_printer *pp)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
obstack_free (pp->buffer->obstack, obstack_base (pp->buffer->obstack));
|
2003-07-25 11:52:32 +02:00
|
|
|
|
pp->buffer->line_length = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set PREFIX for PRETTY-PRINTER. */
|
|
|
|
|
void
|
2003-08-05 21:23:14 +02:00
|
|
|
|
pp_base_set_prefix (pretty_printer *pp, const char *prefix)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
|
|
|
|
pp->prefix = prefix;
|
|
|
|
|
pp_set_real_maximum_length (pp);
|
|
|
|
|
pp->emitted_prefix = false;
|
|
|
|
|
pp_indentation (pp) = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Free PRETTY-PRINTER's prefix, a previously malloc()'d string. */
|
|
|
|
|
void
|
2003-08-05 21:23:14 +02:00
|
|
|
|
pp_base_destroy_prefix (pretty_printer *pp)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
|
|
|
|
if (pp->prefix != NULL)
|
|
|
|
|
{
|
system.h (CONST_CAST2, [...]): New macros for type-specific casts.
* system.h (CONST_CAST2, CONST_CAST_TREE, CONST_CAST_RTX,
CONST_CAST_BB): New macros for type-specific casts.
(CONST_CAST): Add a TYPE parameter and define it in terms of
CONST_CAST2.
* c-decl.c (c_make_fname_decl): Supply a TYPE for CONST_CAST.
* c-lex.c (cb_ident, lex_string): Likewise,
* c-typeck.c (free_all_tagged_tu_seen_up_to): Likewise,
* config/i386/i386.c (ix86_function_regparm,
ix86_function_sseregparm): Use CONST_CAST_TREE.
* config/mmix/mmix.c (mmix_encode_section_info): Supply a TYPE for
CONST_CAST.
* gcc.c (set_spec, read_specs, for_each_path, execute, do_spec_1,
give_switch, set_multilib_dir): Likewise,
* gengtype-parse.c (string_seq, typedef_name): Likewise,
* gimple-low.c (block_may_fallthru): Use CONST_CAST_TREE.
* jump.c (reversed_comparison_code_parts): Use CONST_CAST_RTX.
* passes.c (execute_one_pass): Supply a TYPE for CONST_CAST.
* prefix.c (update_path): Likewise,
* pretty-print.c (pp_base_destroy_prefix): Likewise,
* rtlanal.c (keep_with_call_p): Use CONST_CAST_RTX.
* tree-cfg.c (tree_can_merge_blocks_p,
tree_block_ends_with_condjump_p): Use CONST_CAST_BB.
* tree-eh.c (lookup_stmt_eh_region_fn): USe CONST_CAST_TREE.
* tree.c (build_string): Supply a TYPE for CONST_CAST.
(attribute_list_contained): Use CONST_CAST_TREE.
cp:
* call.c (name_as_c_string): Supply a TYPE for CONST_CAST.
* decl.c (cp_make_fname_decl): Likewise,
* parser.c (cp_parser_string_literal): Likewise,
* tree.c (pod_type_p, zero_init_p): Use CONST_CAST_TREE.
* typeck.c (cp_type_quals, cp_type_readonly, cp_has_mutable_p):
Likewise,
fortran:
* gfortranspec.c (lang_specific_driver): Use CONST_CAST2.
* options.c (gfc_post_options): Supply a TYPE for CONST_CAST.
* parse.c (parse_omp_structured_block): Likewise,
* st.c (gfc_free_statement): Likewise,
java:
* jcf-parse.c (read_class, java_parse_file): Supply a TYPE for
CONST_CAST.
* jcf.h (JCF_FINISH): Likewise.
From-SVN: r128051
2007-09-03 19:09:20 +02:00
|
|
|
|
free (CONST_CAST (char *, pp->prefix));
|
2003-07-25 11:52:32 +02:00
|
|
|
|
pp->prefix = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Write out PRETTY-PRINTER's prefix. */
|
|
|
|
|
void
|
2003-08-05 21:23:14 +02:00
|
|
|
|
pp_base_emit_prefix (pretty_printer *pp)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
|
|
|
|
if (pp->prefix != NULL)
|
|
|
|
|
{
|
|
|
|
|
switch (pp_prefixing_rule (pp))
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
case DIAGNOSTICS_SHOW_PREFIX_NEVER:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DIAGNOSTICS_SHOW_PREFIX_ONCE:
|
|
|
|
|
if (pp->emitted_prefix)
|
|
|
|
|
{
|
2003-08-10 20:17:06 +02:00
|
|
|
|
pp_base_indent (pp);
|
2003-07-25 11:52:32 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
pp_indentation (pp) += 3;
|
|
|
|
|
/* Fall through. */
|
|
|
|
|
|
|
|
|
|
case DIAGNOSTICS_SHOW_PREFIX_EVERY_LINE:
|
|
|
|
|
{
|
|
|
|
|
int prefix_length = strlen (pp->prefix);
|
|
|
|
|
pp_append_r (pp, pp->prefix, prefix_length);
|
|
|
|
|
pp->emitted_prefix = true;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Construct a PRETTY-PRINTER with PREFIX and of MAXIMUM_LENGTH
|
|
|
|
|
characters per line. */
|
|
|
|
|
void
|
|
|
|
|
pp_construct (pretty_printer *pp, const char *prefix, int maximum_length)
|
|
|
|
|
{
|
|
|
|
|
memset (pp, 0, sizeof (pretty_printer));
|
2006-01-31 20:56:55 +01:00
|
|
|
|
pp->buffer = XCNEW (output_buffer);
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
obstack_init (&pp->buffer->chunk_obstack);
|
|
|
|
|
obstack_init (&pp->buffer->formatted_obstack);
|
|
|
|
|
pp->buffer->obstack = &pp->buffer->formatted_obstack;
|
2003-07-25 11:52:32 +02:00
|
|
|
|
pp->buffer->stream = stderr;
|
|
|
|
|
pp_line_cutoff (pp) = maximum_length;
|
|
|
|
|
pp_prefixing_rule (pp) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
|
|
|
|
|
pp_set_prefix (pp, prefix);
|
pretty-print.h (struct pretty_print_info): Add translate_identifiers.
* pretty-print.h (struct pretty_print_info): Add
translate_identifiers.
(pp_translate_identifiers): New.
(pp_identifier): Only conditionally translate identifier to locale
character set.
* pretty-print.c (pp_construct): Set pp_translate_identifiers.
(pp_base_tree_identifier): Only conditionally translate identifier
to locale character set.
* c-pretty-print.c (M_): Define.
(pp_c_type_specifier, pp_c_primary_expression): Mark English
fragments for conditional translation with M_.
* tree-pretty-print.c (maybe_init_pretty_print): Disable
identifier translation.
cp:
* call.c (name_as_c_string): Call type_as_string_translate.
Translate identifiers to locale character set.
* cp-tree.h (lang_decl_name): Update prototype.
(type_as_string_translate, decl_as_string_translate,
cxx_printable_name_translate): Declare.
* cxx-pretty-print.c (M_): Define.
(pp_cxx_unqualified_id, pp_cxx_canonical_template_parameter): Mark
English fragments for conditional translation with M_.
* decl.c (grokdeclarator): Translate identifiers to locale
character set for diagnostics.
* error.c (M_): Define.
(dump_template_bindings, dump_type, dump_aggr_type,
dump_type_prefix, dump_global_iord, dump_simple_decl, dump_decl,
dump_function_decl, dump_template_parms, dump_expr,
dump_binary_op, op_to_string, assop_to_string): Mark English
fragments for conditional translation with M_.
(type_as_string): Disable translation of identifiers.
(type_as_string_translate): New.
(expr_as_string): Disable translation of identifiers.
(decl_as_string): Disable translation of identifiers.
(decl_as_string_translate): New.
(lang_decl_name): Add parameter translate.
(args_to_string): Call type_as_string_translate.
(cp_print_error_function): Call cxx_printable_name_translate.
(print_instantiation_full_context,
print_instantiation_partial_context): Call
decl_as_string_translate.
* parser.c (cp_lexer_get_preprocessor_token): Use %qE for
identifier in diagnostic.
* tree.c (cxx_printable_name): Change to
cxx_printable_name_internal. Add parameter translate.
(cxx_printable_name, cxx_printable_name_translate): New wrappers
round cxx_printable_name_internal.
objc:
* objc-act.c: Include intl.h.
(objc_lookup_protocol): Use complete sentences for diagnostics
with %qE for identifiers and translating results of
gen_type_name_0 to locale character set.
(objc_check_decl, check_protocol_recursively,
lookup_and_install_protocols, objc_build_string_object,
objc_get_class_reference, objc_declare_alias, objc_declare_class,
objc_get_class_ivars, error_with_ivar, check_duplicates,
objc_finish_message_expr, objc_build_protocol_expr,
objc_build_selector_expr, build_ivar_reference, objc_add_method,
add_category, add_instance_variable, objc_is_public,
check_methods, check_methods_accessible, check_protocol,
start_class, finish_class, start_protocol, really_start_method,
get_super_receiver, objc_lookup_ivar): Use %E and %qE for
identifiers in diagnostics. Translate generated text to locale
character set as needed.
(check_protocol, check_protocols): Change name parameter to type
tree.
(lang_report_error_function): Remove.
From-SVN: r147333
2009-05-10 12:28:34 +02:00
|
|
|
|
pp_translate_identifiers (pp) = true;
|
2003-07-25 11:52:32 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Append a string delimited by START and END to the output area of
|
|
|
|
|
PRETTY-PRINTER. No line wrapping is done. However, if beginning a
|
|
|
|
|
new line then emit PRETTY-PRINTER's prefix and skip any leading
|
|
|
|
|
whitespace if appropriate. The caller must ensure that it is
|
|
|
|
|
safe to do so. */
|
|
|
|
|
void
|
2003-08-05 21:23:14 +02:00
|
|
|
|
pp_base_append_text (pretty_printer *pp, const char *start, const char *end)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
|
|
|
|
/* Emit prefix and skip whitespace if we're starting a new line. */
|
|
|
|
|
if (pp->buffer->line_length == 0)
|
|
|
|
|
{
|
|
|
|
|
pp_emit_prefix (pp);
|
|
|
|
|
if (pp_is_wrapping_line (pp))
|
|
|
|
|
while (start != end && *start == ' ')
|
|
|
|
|
++start;
|
|
|
|
|
}
|
|
|
|
|
pp_append_r (pp, start, end - start);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Finishes constructing a NULL-terminated character string representing
|
|
|
|
|
the PRETTY-PRINTED text. */
|
|
|
|
|
const char *
|
2003-08-05 21:23:14 +02:00
|
|
|
|
pp_base_formatted_text (pretty_printer *pp)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
obstack_1grow (pp->buffer->obstack, '\0');
|
2003-07-25 11:52:32 +02:00
|
|
|
|
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 *
|
2003-08-05 21:23:14 +02:00
|
|
|
|
pp_base_last_position_in_text (const pretty_printer *pp)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
|
|
|
|
const char *p = NULL;
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
struct obstack *text = pp->buffer->obstack;
|
2003-07-25 11:52:32 +02:00
|
|
|
|
|
|
|
|
|
if (obstack_base (text) != obstack_next_free (text))
|
|
|
|
|
p = ((const char *) obstack_next_free (text)) - 1;
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return the amount of characters PRETTY-PRINTER can accept to
|
2003-12-13 05:11:23 +01:00
|
|
|
|
make a full line. Meaningful only in line-wrapping mode. */
|
2003-07-25 11:52:32 +02:00
|
|
|
|
int
|
2003-08-05 21:23:14 +02:00
|
|
|
|
pp_base_remaining_character_count_for_line (pretty_printer *pp)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
|
|
|
|
return pp->maximum_length - pp->buffer->line_length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Format a message into BUFFER a la printf. */
|
|
|
|
|
void
|
|
|
|
|
pp_printf (pretty_printer *pp, const char *msg, ...)
|
|
|
|
|
{
|
|
|
|
|
text_info text;
|
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
|
|
va_start (ap, msg);
|
|
|
|
|
text.err_no = errno;
|
|
|
|
|
text.args_ptr = ≈
|
|
|
|
|
text.format_spec = msg;
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
text.locus = NULL;
|
|
|
|
|
pp_format (pp, &text);
|
|
|
|
|
pp_output_formatted_text (pp);
|
2003-07-25 11:52:32 +02:00
|
|
|
|
va_end (ap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Output MESSAGE verbatim into BUFFER. */
|
|
|
|
|
void
|
|
|
|
|
pp_verbatim (pretty_printer *pp, const char *msg, ...)
|
|
|
|
|
{
|
|
|
|
|
text_info text;
|
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
|
|
va_start (ap, msg);
|
|
|
|
|
text.err_no = errno;
|
|
|
|
|
text.args_ptr = ≈
|
|
|
|
|
text.format_spec = msg;
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
text.locus = NULL;
|
2003-07-25 11:52:32 +02:00
|
|
|
|
pp_format_verbatim (pp, &text);
|
|
|
|
|
va_end (ap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Have PRETTY-PRINTER start a new line. */
|
|
|
|
|
void
|
2003-08-03 22:02:56 +02:00
|
|
|
|
pp_base_newline (pretty_printer *pp)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
obstack_1grow (pp->buffer->obstack, '\n');
|
2003-07-25 11:52:32 +02:00
|
|
|
|
pp->buffer->line_length = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Have PRETTY-PRINTER add a CHARACTER. */
|
|
|
|
|
void
|
2003-08-03 22:02:56 +02:00
|
|
|
|
pp_base_character (pretty_printer *pp, int c)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
|
|
|
|
if (pp_is_wrapping_line (pp)
|
|
|
|
|
&& pp_remaining_character_count_for_line (pp) <= 0)
|
|
|
|
|
{
|
|
|
|
|
pp_newline (pp);
|
|
|
|
|
if (ISSPACE (c))
|
|
|
|
|
return;
|
|
|
|
|
}
|
pretty-print.h (PP_NL_ARGMAX): New.
gcc:
* pretty-print.h (PP_NL_ARGMAX): New.
(text_info): Add locus.
(struct chunk_info): New.
(output_buffer): Add formatted_obstack, chunk_obstack, and
cur_chunk_array. Change obstack to a pointer.
(pp_wrapping_mode_t, pp_wrapping_mode, pp_set_verbatim_wrapping): New.
(struct pretty_print_info): Replace ideal_maximum_length and
prefixing_rule with wrapping.
(pp_line_cutoff, pp_prefixing_rule): Update to match.
Update prototypes and wrapper macros throughout.
* pretty-print.c (pp_formatted_text_data, pp_append_r)
(pp_base_clear_output_area, pp_construct, pp_base_formatted_text)
(pp_base_last_position_in_text, pp_base_newline, pp_base_character):
Update for changes to pp structure.
(pp_base_prepare_to_format, pp_base_format_text): Delete.
(pp_base_format, pp_base_output_formatted_text): New functions.
(pp_base_format_verbatim): Use pp_set_verbatim_wrapping.
(pp_verbatim): Clear text.locus.
(pp_printf): Likewise. Use pp_format and pp_output_formatted_text.
* c-objc-common.c (c_tree_printer): Update function signature.
* diagnostic.c (diagnostic_initialize): Update for changes to
pp structure.
(diagnostic_report_diagnostic): Call pp_format and then
pp_output_formatted_text.
(verbatim): Clear text.locus.
* diagnostic.h (diagnostic_prefixing_rule, diagnostic_line_cutoff):
Update for changes to pp structure.
* c-lang.c: No need to include c-pretty-print.h.
* Makefile.in: Remove bogus line containing only a tab.
(c-lang.o): Update dependencies.
* toplev.c (announce_function): Don't use verbatim.
(default_tree_printer): Update signature.
* objc/objc-lang.c: No need to include c-pretty-print.h.
* objc/Make-lang.in: Update dependencies.
gcc/cp:
* cp-lang.c: No need to include cxx-pretty-print.h.
* error.c (cp_printer): Update signature. No need to process
flags.
(print_instantiation_partial_context): Output last newline
with pp_base_newline.
* Make-lang.in: Update dependencies.
gcc/objcp:
* objcp-lang.c: No need to include cxx-pretty-print.h.
* Make-lang.in: Update dependencies.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r101481
2005-07-01 01:09:06 +02:00
|
|
|
|
obstack_1grow (pp->buffer->obstack, c);
|
2003-07-25 11:52:32 +02:00
|
|
|
|
++pp->buffer->line_length;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Append a STRING to the output area of PRETTY-PRINTER; the STRING may
|
|
|
|
|
be line-wrapped if in appropriate mode. */
|
|
|
|
|
void
|
2003-08-03 22:02:56 +02:00
|
|
|
|
pp_base_string (pretty_printer *pp, const char *str)
|
2003-07-25 11:52:32 +02:00
|
|
|
|
{
|
|
|
|
|
pp_maybe_wrap_text (pp, str, str + (str ? strlen (str) : 0));
|
|
|
|
|
}
|
|
|
|
|
|
alias.c, [...]: Fix comment formatting.
* alias.c, basic-block.h, cgraphunit.c, combine.c, domwalk.h,
final.c, gengtype.c, genpreds.c, ggc-page.c, insn-notes.def,
lambda-code.c, loop-unroll.c, modulo-sched.c, pointer-set.c,
pretty-print.c, ra-colorize.c, sbitmap.c, tree-complex.c,
tree-data-ref.c, tree-dfa.c, tree-inline.c, tree-into-ssa.c,
tree-scalar-evolution.c, tree-ssa-dom.c,
tree-ssa-loop-manip.c, tree-ssa-loop-niter.c,
tree-ssa-phiopt.c, tree-ssa-pre.c, tree-ssa-threadupdate.c,
tree-vectorizer.c, vec.h: Fix comment formatting.
From-SVN: r89453
2004-10-22 19:05:11 +02:00
|
|
|
|
/* Maybe print out a whitespace if needed. */
|
2003-07-25 11:52:32 +02:00
|
|
|
|
|
2004-03-22 00:55:03 +01:00
|
|
|
|
void
|
|
|
|
|
pp_base_maybe_space (pretty_printer *pp)
|
|
|
|
|
{
|
|
|
|
|
if (pp_base (pp)->padding != pp_none)
|
|
|
|
|
{
|
|
|
|
|
pp_space (pp);
|
|
|
|
|
pp_base (pp)->padding = pp_none;
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-05-04 14:23:50 +02:00
|
|
|
|
|
|
|
|
|
/* The string starting at P has LEN (at least 1) bytes left; if they
|
|
|
|
|
start with a valid UTF-8 sequence, return the length of that
|
|
|
|
|
sequence and set *VALUE to the value of that sequence, and
|
|
|
|
|
otherwise return 0 and set *VALUE to (unsigned int) -1. */
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
decode_utf8_char (const unsigned char *p, size_t len, unsigned int *value)
|
|
|
|
|
{
|
|
|
|
|
unsigned int t = *p;
|
|
|
|
|
|
|
|
|
|
if (len == 0)
|
|
|
|
|
abort ();
|
|
|
|
|
if (t & 0x80)
|
|
|
|
|
{
|
|
|
|
|
size_t utf8_len = 0;
|
|
|
|
|
unsigned int ch;
|
|
|
|
|
size_t i;
|
|
|
|
|
for (t = *p; t & 0x80; t <<= 1)
|
|
|
|
|
utf8_len++;
|
|
|
|
|
|
|
|
|
|
if (utf8_len > len || utf8_len < 2 || utf8_len > 6)
|
|
|
|
|
{
|
|
|
|
|
*value = (unsigned int) -1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
ch = *p & ((1 << (7 - utf8_len)) - 1);
|
|
|
|
|
for (i = 1; i < utf8_len; i++)
|
|
|
|
|
{
|
|
|
|
|
unsigned int u = p[i];
|
|
|
|
|
if ((u & 0xC0) != 0x80)
|
|
|
|
|
{
|
|
|
|
|
*value = (unsigned int) -1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
ch = (ch << 6) | (u & 0x3F);
|
|
|
|
|
}
|
|
|
|
|
if ( (ch <= 0x7F && utf8_len > 1)
|
|
|
|
|
|| (ch <= 0x7FF && utf8_len > 2)
|
|
|
|
|
|| (ch <= 0xFFFF && utf8_len > 3)
|
|
|
|
|
|| (ch <= 0x1FFFFF && utf8_len > 4)
|
|
|
|
|
|| (ch <= 0x3FFFFFF && utf8_len > 5)
|
|
|
|
|
|| (ch >= 0xD800 && ch <= 0xDFFF))
|
|
|
|
|
{
|
|
|
|
|
*value = (unsigned int) -1;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
*value = ch;
|
|
|
|
|
return utf8_len;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
*value = t;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-26 20:55:51 +02:00
|
|
|
|
/* Allocator for identifier_to_locale and corresponding function to
|
|
|
|
|
free memory. */
|
|
|
|
|
|
|
|
|
|
void *(*identifier_to_locale_alloc) (size_t) = xmalloc;
|
|
|
|
|
void (*identifier_to_locale_free) (void *) = free;
|
|
|
|
|
|
2009-05-04 14:23:50 +02:00
|
|
|
|
/* Given IDENT, an identifier in the internal encoding, return a
|
|
|
|
|
version of IDENT suitable for diagnostics in the locale character
|
2010-05-26 20:55:51 +02:00
|
|
|
|
set: either IDENT itself, or a string, allocated using
|
|
|
|
|
identifier_to_locale_alloc, converted to the locale character set
|
|
|
|
|
and using escape sequences if not representable in the locale
|
|
|
|
|
character set or containing control characters or invalid byte
|
|
|
|
|
sequences. Existing backslashes in IDENT are not doubled, so the
|
|
|
|
|
result may not uniquely specify the contents of an arbitrary byte
|
|
|
|
|
sequence identifier. */
|
2009-05-04 14:23:50 +02:00
|
|
|
|
|
|
|
|
|
const char *
|
|
|
|
|
identifier_to_locale (const char *ident)
|
|
|
|
|
{
|
|
|
|
|
const unsigned char *uid = (const unsigned char *) ident;
|
|
|
|
|
size_t idlen = strlen (ident);
|
|
|
|
|
bool valid_printable_utf8 = true;
|
|
|
|
|
bool all_ascii = true;
|
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < idlen;)
|
|
|
|
|
{
|
|
|
|
|
unsigned int c;
|
|
|
|
|
size_t utf8_len = decode_utf8_char (&uid[i], idlen - i, &c);
|
|
|
|
|
if (utf8_len == 0 || c <= 0x1F || (c >= 0x7F && c <= 0x9F))
|
|
|
|
|
{
|
|
|
|
|
valid_printable_utf8 = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (utf8_len > 1)
|
|
|
|
|
all_ascii = false;
|
|
|
|
|
i += utf8_len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If IDENT contains invalid UTF-8 sequences (which may occur with
|
|
|
|
|
attributes putting arbitrary byte sequences in identifiers), or
|
|
|
|
|
control characters, we use octal escape sequences for all bytes
|
|
|
|
|
outside printable ASCII. */
|
|
|
|
|
if (!valid_printable_utf8)
|
|
|
|
|
{
|
2010-05-26 20:55:51 +02:00
|
|
|
|
char *ret = (char *) identifier_to_locale_alloc (4 * idlen + 1);
|
2009-05-04 14:23:50 +02:00
|
|
|
|
char *p = ret;
|
|
|
|
|
for (i = 0; i < idlen; i++)
|
|
|
|
|
{
|
|
|
|
|
if (uid[i] > 0x1F && uid[i] < 0x7F)
|
|
|
|
|
*p++ = uid[i];
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sprintf (p, "\\%03o", uid[i]);
|
|
|
|
|
p += 4;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*p = 0;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Otherwise, if it is valid printable ASCII, or printable UTF-8
|
|
|
|
|
with the locale character set being UTF-8, IDENT is used. */
|
|
|
|
|
if (all_ascii || locale_utf8)
|
|
|
|
|
return ident;
|
|
|
|
|
|
|
|
|
|
/* Otherwise IDENT is converted to the locale character set if
|
|
|
|
|
possible. */
|
|
|
|
|
#if defined ENABLE_NLS && defined HAVE_LANGINFO_CODESET && HAVE_ICONV
|
|
|
|
|
if (locale_encoding != NULL)
|
|
|
|
|
{
|
|
|
|
|
iconv_t cd = iconv_open (locale_encoding, "UTF-8");
|
|
|
|
|
bool conversion_ok = true;
|
|
|
|
|
char *ret = NULL;
|
|
|
|
|
if (cd != (iconv_t) -1)
|
|
|
|
|
{
|
|
|
|
|
size_t ret_alloc = 4 * idlen + 1;
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
/* Repeat the whole conversion process as needed with
|
|
|
|
|
larger buffers so non-reversible transformations can
|
|
|
|
|
always be detected. */
|
|
|
|
|
ICONV_CONST char *inbuf = CONST_CAST (char *, ident);
|
|
|
|
|
char *outbuf;
|
|
|
|
|
size_t inbytesleft = idlen;
|
|
|
|
|
size_t outbytesleft = ret_alloc - 1;
|
|
|
|
|
size_t iconv_ret;
|
|
|
|
|
|
2010-05-26 20:55:51 +02:00
|
|
|
|
ret = (char *) identifier_to_locale_alloc (ret_alloc);
|
2009-05-04 14:23:50 +02:00
|
|
|
|
outbuf = ret;
|
|
|
|
|
|
|
|
|
|
if (iconv (cd, 0, 0, 0, 0) == (size_t) -1)
|
|
|
|
|
{
|
|
|
|
|
conversion_ok = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iconv_ret = iconv (cd, &inbuf, &inbytesleft,
|
|
|
|
|
&outbuf, &outbytesleft);
|
|
|
|
|
if (iconv_ret == (size_t) -1 || inbytesleft != 0)
|
|
|
|
|
{
|
|
|
|
|
if (errno == E2BIG)
|
|
|
|
|
{
|
|
|
|
|
ret_alloc *= 2;
|
2010-05-26 20:55:51 +02:00
|
|
|
|
identifier_to_locale_free (ret);
|
2009-05-04 14:23:50 +02:00
|
|
|
|
ret = NULL;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
conversion_ok = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (iconv_ret != 0)
|
|
|
|
|
{
|
|
|
|
|
conversion_ok = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* Return to initial shift state. */
|
|
|
|
|
if (iconv (cd, 0, 0, &outbuf, &outbytesleft) == (size_t) -1)
|
|
|
|
|
{
|
|
|
|
|
if (errno == E2BIG)
|
|
|
|
|
{
|
|
|
|
|
ret_alloc *= 2;
|
2010-05-26 20:55:51 +02:00
|
|
|
|
identifier_to_locale_free (ret);
|
2009-05-04 14:23:50 +02:00
|
|
|
|
ret = NULL;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
conversion_ok = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*outbuf = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
iconv_close (cd);
|
|
|
|
|
if (conversion_ok)
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Otherwise, convert non-ASCII characters in IDENT to UCNs. */
|
|
|
|
|
{
|
2010-05-26 20:55:51 +02:00
|
|
|
|
char *ret = (char *) identifier_to_locale_alloc (10 * idlen + 1);
|
2009-05-04 14:23:50 +02:00
|
|
|
|
char *p = ret;
|
|
|
|
|
for (i = 0; i < idlen;)
|
|
|
|
|
{
|
|
|
|
|
unsigned int c;
|
|
|
|
|
size_t utf8_len = decode_utf8_char (&uid[i], idlen - i, &c);
|
|
|
|
|
if (utf8_len == 1)
|
|
|
|
|
*p++ = uid[i];
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sprintf (p, "\\U%08x", c);
|
|
|
|
|
p += 10;
|
|
|
|
|
}
|
|
|
|
|
i += utf8_len;
|
|
|
|
|
}
|
|
|
|
|
*p = 0;
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|