mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
diagnostics: avoid global variables
* src/complain.c (indent_ptr): Remove. (error_message, complains): Take indent as an argument. Adjust callers.
This commit is contained in:
committed by
Akim Demaille
parent
9145bd0b61
commit
6d81b91ae0
@@ -63,8 +63,6 @@ typedef enum
|
||||
/** For each warning type, its severity. */
|
||||
static severity warnings_flag[warnings_size];
|
||||
|
||||
static unsigned *indent_ptr = NULL;
|
||||
|
||||
styled_ostream_t errstream = NULL;
|
||||
|
||||
void
|
||||
@@ -405,6 +403,7 @@ warnings_print_categories (warnings warn_flags, FILE *out)
|
||||
*
|
||||
* \param loc the location, defaulting to the current file,
|
||||
* or the program name.
|
||||
* \param indent optional indentation for the error message.
|
||||
* \param flags the category for this message.
|
||||
* \param sever to decide the prefix to put before the message
|
||||
* (e.g., "warning").
|
||||
@@ -416,8 +415,8 @@ warnings_print_categories (warnings warn_flags, FILE *out)
|
||||
*/
|
||||
static
|
||||
void
|
||||
error_message (const location *loc, warnings flags, severity sever,
|
||||
const char *message, va_list args)
|
||||
error_message (const location *loc, unsigned *indent, warnings flags,
|
||||
severity sever, const char *message, va_list args)
|
||||
{
|
||||
unsigned pos = 0;
|
||||
|
||||
@@ -427,14 +426,14 @@ error_message (const location *loc, warnings flags, severity sever,
|
||||
pos += fprintf (stderr, "%s", current_file ? current_file : program_name);
|
||||
pos += fprintf (stderr, ": ");
|
||||
|
||||
if (indent_ptr)
|
||||
if (indent)
|
||||
{
|
||||
if (*indent_ptr)
|
||||
if (*indent)
|
||||
sever = severity_disabled;
|
||||
if (!*indent_ptr)
|
||||
*indent_ptr = pos;
|
||||
else if (*indent_ptr > pos)
|
||||
fprintf (stderr, "%*s", *indent_ptr - pos, "");
|
||||
if (!*indent)
|
||||
*indent = pos;
|
||||
else if (*indent > pos)
|
||||
fprintf (stderr, "%*s", *indent - pos, "");
|
||||
}
|
||||
|
||||
const char* style = severity_style (sever);
|
||||
@@ -469,8 +468,8 @@ error_message (const location *loc, warnings flags, severity sever,
|
||||
/** Raise a complaint (fatal error, error or just warning). */
|
||||
|
||||
static void
|
||||
complains (const location *loc, warnings flags, const char *message,
|
||||
va_list args)
|
||||
complains (const location *loc, unsigned *indent, warnings flags,
|
||||
const char *message, va_list args)
|
||||
{
|
||||
severity s = warning_severity (flags);
|
||||
if ((flags & complaint) && complaint_status < status_complaint)
|
||||
@@ -480,7 +479,7 @@ complains (const location *loc, warnings flags, const char *message,
|
||||
{
|
||||
if (severity_error <= s && ! complaint_status)
|
||||
complaint_status = status_warning_as_error;
|
||||
error_message (loc, flags, s, message, args);
|
||||
error_message (loc, indent, flags, s, message, args);
|
||||
}
|
||||
|
||||
if (flags & fatal)
|
||||
@@ -492,7 +491,7 @@ complain (location const *loc, warnings flags, const char *message, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, message);
|
||||
complains (loc, flags, message, args);
|
||||
complains (loc, NULL, flags, message, args);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
@@ -501,11 +500,9 @@ complain_indent (location const *loc, warnings flags, unsigned *indent,
|
||||
const char *message, ...)
|
||||
{
|
||||
va_list args;
|
||||
indent_ptr = indent;
|
||||
va_start (args, message);
|
||||
complains (loc, flags, message, args);
|
||||
complains (loc, indent, flags, message, args);
|
||||
va_end (args);
|
||||
indent_ptr = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user