This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH PR c/42014] Make the column number display consistently
- From: Shujing Zhao <pearly dot zhao at oracle dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, Paolo Carlini <paolo dot carlini at oracle dot com>
- Date: Fri, 08 Jan 2010 14:09:46 +0800
- Subject: Re: [PATCH PR c/42014] Make the column number display consistently
- References: <4B32F85F.8060905@oracle.com>
Hi,
On 12/24/2009 01:13 PM, Shujing Zhao wrote:
Hi,
This patch is to make the column number can be displayed too since the
second "included from" when -fshow-column is enabled.
Bootstrapped with all languages enabled at i686-pc-linux-gnu. And
especially test this error strings by test case gcc.dg/pr36901-4.c with
-fno-show-column.
This patch is updated to make the string can be extracted by exgettext for
translation.
I have made two candidates to solve the translation problem. One is to add the
indent with the width equal to the translation of "In file included" since the
second "from" file. It uses the function get_spaces to get the width of indent
and just like the way that has solved the "candidated are" problem. But it
supposed the translation of "from" is as the same as it at "In file included
from", and the translation of "In file included" is same with it at "In file
included from", so that getting the width of _("In file included") would be
useful. If the translation is different at some languages, this way would not work.
The other way is simple to add the comment to the translator to add enough
spaces to indent. Thant comment can be extracted by exgettext to the gcc.pot.
The first keep the gcc to handle the indent in a consistent way and the second
is more reliable. Which one is better?
They are both tested on i686-pc-linux-gnu with enable c, c++, objc and fortran
and run "make gcc.pot" to check the messages can be extracted.
Thanks
Pearly
2010-01-08 Shujing Zhao <pearly.zhao@oracle.com>
PR other/42014
* diagnostic.c (diagnostic_report_current_module): Make the column
number display consistently and wrap the diagnostic into _().
(get_succession): New function.
Index: diagnostic.c
===================================================================
--- diagnostic.c (revision 155638)
+++ diagnostic.c (working copy)
@@ -218,10 +218,27 @@ diagnostic_report_current_function (diag
lang_hooks.print_error_function (context, input_filename, diagnostic);
}
+/* Return the line break and the indent for successive lines, using the width of
+ the STR. STR must have been translated already. The string
+ must be freed by the caller. */
+
+static char *
+get_succession (const char *str)
+{
+ char *spaces;
+ char *tmp ;
+ spaces = get_spaces (str);
+ tmp = (char *)xmalloc (strlen (spaces) + 20);
+ sprintf (tmp, _(",\n%s from"), spaces);
+ free (spaces);
+ return tmp;
+}
+
void
diagnostic_report_current_module (diagnostic_context *context)
{
const struct line_map *map;
+ const char *succession = NULL;
if (pp_needs_newline (context->printer))
{
@@ -241,19 +258,28 @@ diagnostic_report_current_module (diagno
map = INCLUDED_FROM (line_table, map);
if (flag_show_column)
pp_verbatim (context->printer,
- "In file included from %s:%d:%d",
+ _("In file included from %s:%d:%d"),
map->to_file,
LAST_SOURCE_LINE (map), LAST_SOURCE_COLUMN (map));
else
pp_verbatim (context->printer,
- "In file included from %s:%d",
+ _("In file included from %s:%d"),
map->to_file, LAST_SOURCE_LINE (map));
while (! MAIN_FILE_P (map))
{
map = INCLUDED_FROM (line_table, map);
- pp_verbatim (context->printer,
- ",\n from %s:%d",
- map->to_file, LAST_SOURCE_LINE (map));
+ succession = succession
+ ? succession
+ : get_succession (_("In file included"));
+ if (flag_show_column)
+ pp_verbatim (context->printer,
+ "%s %s:%d:%d", succession,
+ map->to_file, LAST_SOURCE_LINE (map),
+ LAST_SOURCE_COLUMN (map));
+ else
+ pp_verbatim (context->printer,
+ "%s %s:%d", succession,
+ map->to_file, LAST_SOURCE_LINE (map));
}
pp_verbatim (context->printer, ":");
pp_newline (context->printer);
2010-01-08 Shujing Zhao <pearly.zhao@oracle.com>
PR other/42014
* diagnostic.c (diagnostic_report_current_module): Make the column
number display consistently and wrap the diagnostic into _().
Index: diagnostic.c
===================================================================
--- diagnostic.c (revision 155638)
+++ diagnostic.c (working copy)
@@ -241,19 +241,29 @@ diagnostic_report_current_module (diagno
map = INCLUDED_FROM (line_table, map);
if (flag_show_column)
pp_verbatim (context->printer,
- "In file included from %s:%d:%d",
+ _("In file included from %s:%d:%d"),
map->to_file,
LAST_SOURCE_LINE (map), LAST_SOURCE_COLUMN (map));
else
pp_verbatim (context->printer,
- "In file included from %s:%d",
+ _("In file included from %s:%d"),
map->to_file, LAST_SOURCE_LINE (map));
while (! MAIN_FILE_P (map))
{
map = INCLUDED_FROM (line_table, map);
- pp_verbatim (context->printer,
- ",\n from %s:%d",
- map->to_file, LAST_SOURCE_LINE (map));
+ if (flag_show_column)
+ pp_verbatim (context->printer,
+ /* Indent to an appropriate place
+ to start printing more from files. */
+ _(",\n from %s:%d:%d"),
+ map->to_file, LAST_SOURCE_LINE (map),
+ LAST_SOURCE_COLUMN (map));
+ else
+ pp_verbatim (context->printer,
+ /* Indent to an appropriate place
+ to start printing more from files. */
+ _(",\n from %s:%d"),
+ map->to_file, LAST_SOURCE_LINE (map));
}
pp_verbatim (context->printer, ":");
pp_newline (context->printer);