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\\\ --from-code=UTF-8\\\
--flag=asprintf:2:c-format\\\ --flag=asprintf:2:c-format\\\
--flag=complain:3: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\\\ --flag=unexpected_end:2:c-format\\\
' '
XGETTEXT_OPTIONS_RUNTIME=$XGETTEXT_OPTIONS'\\\ XGETTEXT_OPTIONS_RUNTIME=$XGETTEXT_OPTIONS'\\\

View File

@@ -148,13 +148,13 @@ complain (location const* loc, warnings flags, const char *message, ...)
} }
void void
complain_at_indent (location loc, warnings flags, unsigned *indent, complain_indent (location const *loc, warnings flags, unsigned *indent,
const char *message, ...) const char *message, ...)
{ {
va_list args; va_list args;
indent_ptr = indent; indent_ptr = indent;
va_start (args, message); va_start (args, message);
complains (&loc, flags, message, args); complains (loc, flags, message, args);
va_end (args); va_end (args);
} }

View File

@@ -65,7 +65,7 @@ void complain (location const* loc, warnings flags, char const *message, ...)
void complain_args (location const *loc, warnings w, int argc, char *arg[]); void complain_args (location const *loc, warnings w, int argc, char *arg[]);
/** Make a complaint with location and some indentation. */ /** Make a complaint with location and some indentation. */
void complain_at_indent (location loc, warnings flags, unsigned *indent, void complain_indent (location const *loc, warnings flags, unsigned *indent,
char const *message, ...) char const *message, ...)
__attribute__ ((__format__ (__printf__, 4, 5))); __attribute__ ((__format__ (__printf__, 4, 5)));

View File

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

View File

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

View File

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

View File

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