Keep sub-messages aligned. Fix strings for translation.

* src/location.h: (location_print): Add return value.
	* src/location.c: (location_print): Return number of printed
	characters.
	* src/complain.h: Two new functions (complain_at_indent,
	warn_at_indent).
	* src/complain.cpp: Implement the alignment mechanism. Add new
	static variable (indent_ptr). Use and update it (error_message,
	complain_at_indent, warn_at_indent).
	* src/scan-code.l: Fix strings for translations. Use new *_indent
	functions (parse_ref, show_sub_messages).
	* tests/named-ref.at: Adjust testcases.
	* NEWS (2.5): Add an announcement about named references.
This commit is contained in:
Alex Rozenman
2009-09-19 12:59:33 +03:00
parent d93b5f50cf
commit 348f560883
8 changed files with 208 additions and 94 deletions

View File

@@ -29,6 +29,7 @@
#include "getargs.h"
bool complaint_issued;
static unsigned *indent_ptr = 0;
@@ -46,11 +47,22 @@ error_message (location *loc,
const char *prefix,
const char *message, va_list args)
{
unsigned pos = 0;
if (loc)
location_print (stderr, *loc);
pos += location_print (stderr, *loc);
else
fputs (current_file ? current_file : program_name, stderr);
fputs (": ", stderr);
pos += fprintf(stderr, "%s", current_file ? current_file : program_name);
pos += fprintf(stderr, ": ");
if (indent_ptr)
{
if (!*indent_ptr)
*indent_ptr = pos;
else if (*indent_ptr > pos)
fprintf (stderr, "%*s", *indent_ptr - pos, "");
indent_ptr = 0;
}
if (prefix)
fprintf (stderr, "%s: ", prefix);
@@ -93,6 +105,15 @@ warn_at (location loc, const char *message, ...)
ERROR_MESSAGE (&loc, _("warning"), message);
}
void
warn_at_indent (location loc, unsigned *indent,
const char *message, ...)
{
set_warning_issued ();
indent_ptr = indent;
ERROR_MESSAGE (&loc, _("warning"), message);
}
void
warn (const char *message, ...)
{
@@ -112,6 +133,15 @@ complain_at (location loc, const char *message, ...)
complaint_issued = true;
}
void
complain_at_indent (location loc, unsigned *indent,
const char *message, ...)
{
indent_ptr = indent;
ERROR_MESSAGE (&loc, NULL, message);
complaint_issued = true;
}
void
complain (const char *message, ...)
{