diff options
author | Alex Rozenman <rozenman@gmail.com> | 2009-09-19 12:59:33 +0300 |
---|---|---|
committer | Alex Rozenman <rozenman@gmail.com> | 2009-09-19 13:00:51 +0300 |
commit | 66381412d93f6a54e4d8e7e90b89149a9bca4945 (patch) | |
tree | 2150404b268f8b3929bac9e1d1b895e7181c8b7e /src/complain.c | |
parent | 5ad90d528dc5feedb0c1d8afe82719440ec17217 (diff) | |
download | bison-66381412d93f6a54e4d8e7e90b89149a9bca4945.tar.gz |
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).
* NEWS (2.5): Add an announcement about named references.
Diffstat (limited to 'src/complain.c')
-rw-r--r-- | src/complain.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/complain.c b/src/complain.c index 4cc35c8a..7bb22de0 100644 --- a/src/complain.c +++ b/src/complain.c @@ -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); @@ -94,6 +106,15 @@ warn_at (location loc, const char *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, ...) { set_warning_issued (); @@ -113,6 +134,15 @@ complain_at (location loc, const char *message, ...) } 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, ...) { ERROR_MESSAGE (NULL, NULL, message); |