errors: pointerize complain_at_indent

* src/complain.c (complain_at_indent): Rename as...
(complaint_indent): This, and take the location as a pointer.
* src/complain.h, src/muscle-tab.c, src/reader.c, src/scan-code.l,
src/symtab.c: Adjust.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
This commit is contained in:
Theophile Ranquet
2012-10-04 10:35:40 +00:00
committed by Akim Demaille
parent 9ec79612e8
commit b999409e09
7 changed files with 62 additions and 64 deletions

View File

@@ -50,7 +50,7 @@ XGETTEXT_OPTIONS=$XGETTEXT_OPTIONS'\\\
--from-code=UTF-8\\\
--flag=asprintf:2:c-format\\\
--flag=complain:3:c-format\\\
--flag=complain_at_indent:4:c-format\\\
--flag=complain_indent:4:c-format\\\
--flag=unexpected_end:2:c-format\\\
'
XGETTEXT_OPTIONS_RUNTIME=$XGETTEXT_OPTIONS'\\\

View File

@@ -139,7 +139,7 @@ complains (const location *loc, warnings flags, const char *message,
}
void
complain (location const* loc, warnings flags, const char *message, ...)
complain (location const *loc, warnings flags, const char *message, ...)
{
va_list args;
va_start (args, message);
@@ -148,13 +148,13 @@ complain (location const* loc, warnings flags, const char *message, ...)
}
void
complain_at_indent (location loc, warnings flags, unsigned *indent,
const char *message, ...)
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, flags, message, args);
va_end (args);
}

View File

@@ -58,15 +58,15 @@ extern warnings errors_flag;
void warnings_print_categories (warnings warn_flags);
/** Make a complaint, with maybe a location. */
void complain (location const* loc, warnings flags, char const *message, ...)
void complain (location const *loc, warnings flags, char const *message, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
/** Likewise, but with an \a argc/argv interface. */
void complain_args (location const *loc, warnings w, int argc, char *arg[]);
/** Make a complaint with location and some indentation. */
void complain_at_indent (location loc, warnings flags, unsigned *indent,
char const *message, ...)
void complain_indent (location const *loc, warnings flags, unsigned *indent,
char const *message, ...)
__attribute__ ((__format__ (__printf__, 4, 5)));
/** Whether an error was reported. */

View File

@@ -442,13 +442,12 @@ muscle_percent_define_insert (char const *variable, location variable_loc,
unsigned i = 0;
if (how_old == MUSCLE_PERCENT_DEFINE_F)
return;
complain_at_indent (variable_loc, complaint, &i,
_("%%define variable %s redefined"),
quote (variable));
complain_indent (&variable_loc, complaint, &i,
_("%%define variable %s redefined"),
quote (variable));
i += SUB_INDENT;
complain_at_indent (muscle_percent_define_get_loc (variable),
complaint, &i,
_("previous definition"));
location loc = muscle_percent_define_get_loc (variable);
complain_indent (&loc, complaint, &i, _("previous definition"));
}
MUSCLE_INSERT_STRING (name, value);
@@ -606,14 +605,13 @@ muscle_percent_define_check_values (char const * const *values)
{
unsigned i = 0;
location loc = muscle_percent_define_get_loc (*variablep);
complain_at_indent
(loc, complaint, &i,
_("invalid value for %%define variable %s: %s"),
quote (*variablep), quote_n (1, value));
complain_indent (&loc, complaint, &i,
_("invalid value for %%define variable %s: %s"),
quote (*variablep), quote_n (1, value));
i += SUB_INDENT;
for (values = variablep + 1; *values; ++values)
complain_at_indent (loc, complaint, &i, _("accepted value: %s"),
quote (*values));
complain_indent (&loc, complaint, &i, _("accepted value: %s"),
quote (*values));
}
else
{

View File

@@ -129,15 +129,15 @@ record_merge_function_type (int merger, uniqstr type, location declaration_loc)
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
{
unsigned indent = 0;
complain_at_indent (declaration_loc, complaint, &indent,
_("result type clash on merge function %s: "
"<%s> != <%s>"),
quote (merge_function->name), type,
merge_function->type);
complain_indent (&declaration_loc, complaint, &indent,
_("result type clash on merge function %s: "
"<%s> != <%s>"),
quote (merge_function->name), type,
merge_function->type);
indent += SUB_INDENT;
complain_at_indent (merge_function->type_declaration_location, complaint,
&indent,
_("previous declaration"));
complain_indent (&merge_function->type_declaration_location, complaint,
&indent,
_("previous declaration"));
}
merge_function->type = uniqstr_new (type);
merge_function->type_declaration_location = declaration_loc;

View File

@@ -405,9 +405,9 @@ show_sub_message (const char* cp, bool explicit_bracketing,
const char *at_spec = get_at_spec (var->symbol_index);
if (var->err == 0)
complain_at_indent (var->loc, silent, &indent,
_("refers to: %c%s at %s"), dollar_or_at,
var->id, at_spec);
complain_indent (&var->loc, silent, &indent,
_("refers to: %c%s at %s"), dollar_or_at,
var->id, at_spec);
else
{
static struct obstack msg_buf;
@@ -442,8 +442,8 @@ show_sub_message (const char* cp, bool explicit_bracketing,
_(", cannot be accessed from mid-rule action at $%d"),
midrule_rhs_index);
complain_at_indent (id_loc, silent, &indent, "%s",
obstack_finish0 (&msg_buf));
complain_indent (&id_loc, silent, &indent, "%s",
obstack_finish0 (&msg_buf));
obstack_free (&msg_buf, 0);
}
}
@@ -586,28 +586,28 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
cp_end - cp : ref_tail_fields - cp;
unsigned indent = 0;
complain_at_indent (text_loc, complaint, &indent,
_("invalid reference: %s"), quote (text));
complain_indent (&text_loc, complaint, &indent,
_("invalid reference: %s"), quote (text));
indent += SUB_INDENT;
if (len == 0)
{
location sym_loc = text_loc;
sym_loc.start.column += 1;
sym_loc.end = sym_loc.start;
complain_at_indent (sym_loc, complaint, &indent,
_("syntax error after '%c', expecting integer, "
"letter, '_', '[', or '$'"),
dollar_or_at);
complain_indent (&sym_loc, complaint, &indent,
_("syntax error after '%c', expecting integer, "
"letter, '_', '[', or '$'"),
dollar_or_at);
}
else if (midrule_rhs_index)
complain_at_indent (rule->location, complaint, &indent,
_("symbol not found in production before $%d: "
"%.*s"),
midrule_rhs_index, len, cp);
complain_indent (&rule->location, complaint, &indent,
_("symbol not found in production before $%d: "
"%.*s"),
midrule_rhs_index, len, cp);
else
complain_at_indent (rule->location, complaint, &indent,
_("symbol not found in production: %.*s"),
len, cp);
complain_indent (&rule->location, complaint, &indent,
_("symbol not found in production: %.*s"),
len, cp);
if (variant_count > 0)
show_sub_messages (cp, explicit_bracketing, midrule_rhs_index,
@@ -619,8 +619,8 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
unsigned indent = 0;
if (variant_count > 1)
{
complain_at_indent (text_loc, Wother, &indent,
_("misleading reference: %s"), quote (text));
complain_indent (&text_loc, Wother, &indent,
_("misleading reference: %s"), quote (text));
show_sub_messages (cp, explicit_bracketing, midrule_rhs_index,
dollar_or_at, indent + SUB_INDENT);
}
@@ -634,8 +634,8 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
default:
{
unsigned indent = 0;
complain_at_indent (text_loc, complaint, &indent,
_("ambiguous reference: %s"), quote (text));
complain_indent (&text_loc, complaint, &indent,
_("ambiguous reference: %s"), quote (text));
show_sub_messages (cp, explicit_bracketing, midrule_rhs_index,
dollar_or_at, indent + SUB_INDENT);
return INVALID_REF;

View File

@@ -194,11 +194,11 @@ symbol_redeclaration (symbol *s, const char *what, location first,
location second)
{
unsigned i = 0;
complain_at_indent (second, complaint, &i,
_("%s redeclaration for %s"), what, s->tag);
complain_indent (&second, complaint, &i,
_("%s redeclaration for %s"), what, s->tag);
i += SUB_INDENT;
complain_at_indent (first, complaint, &i,
_("previous declaration"));
complain_indent (&first, complaint, &i,
_("previous declaration"));
}
static void
@@ -206,11 +206,11 @@ semantic_type_redeclaration (semantic_type *s, const char *what, location first,
location second)
{
unsigned i = 0;
complain_at_indent (second, complaint, &i,
_("%s redeclaration for <%s>"), what, s->tag);
complain_indent (&second, complaint, &i,
_("%s redeclaration for <%s>"), what, s->tag);
i += SUB_INDENT;
complain_at_indent (first, complaint, &i,
_("previous declaration"));
complain_indent (&first, complaint, &i,
_("previous declaration"));
}
@@ -566,13 +566,13 @@ user_token_number_redeclaration (int num, symbol *first, symbol *second)
first = second;
second = tmp;
}
complain_at_indent (second->location, complaint, &i,
_("user token number %d redeclaration for %s"),
num, second->tag);
complain_indent (&second->location, complaint, &i,
_("user token number %d redeclaration for %s"),
num, second->tag);
i += SUB_INDENT;
complain_at_indent (first->location, complaint, &i,
_("previous declaration for %s"),
first->tag);
complain_indent (&first->location, complaint, &i,
_("previous declaration for %s"),
first->tag);
}
/*--------------------------------------------------.