[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/6] errors: pointerize complain_at_indent
From: |
Theophile Ranquet |
Subject: |
[PATCH 1/6] errors: pointerize complain_at_indent |
Date: |
Thu, 4 Oct 2012 10:35:40 +0000 |
* 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.
---
bootstrap.conf | 2 +-
src/complain.c | 8 ++++----
src/complain.h | 6 +++---
src/muscle-tab.c | 22 ++++++++++------------
src/reader.c | 16 ++++++++--------
src/scan-code.l | 44 ++++++++++++++++++++++----------------------
src/symtab.c | 24 ++++++++++++------------
7 files changed, 60 insertions(+), 62 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 3e631a2..cddc571 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -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'\\\
diff --git a/src/complain.c b/src/complain.c
index 926d901..020b688 100644
--- a/src/complain.c
+++ b/src/complain.c
@@ -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);
}
diff --git a/src/complain.h b/src/complain.h
index 809f1b4..be0d7f5 100644
--- a/src/complain.h
+++ b/src/complain.h
@@ -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. */
diff --git a/src/muscle-tab.c b/src/muscle-tab.c
index be97b80..4b26898 100644
--- a/src/muscle-tab.c
+++ b/src/muscle-tab.c
@@ -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
{
diff --git a/src/reader.c b/src/reader.c
index a67f4c7..a3f8668 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -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;
diff --git a/src/scan-code.l b/src/scan-code.l
index 6d7e138..138d2d9 100644
--- a/src/scan-code.l
+++ b/src/scan-code.l
@@ -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;
diff --git a/src/symtab.c b/src/symtab.c
index b72bbb0..e9b9c20 100644
--- a/src/symtab.c
+++ b/src/symtab.c
@@ -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,10 +206,10 @@ semantic_type_redeclaration (semantic_type *s, const char
*what, location first,
location second)
{
unsigned i = 0;
- complain_at_indent (second, complaint, &i,
+ complain_indent (&second, complaint, &i,
_("%s redeclaration for <%s>"), what, s->tag);
i += SUB_INDENT;
- complain_at_indent (first, complaint, &i,
+ 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);
}
/*--------------------------------------------------.
--
1.7.11.4
- [PATCH 0/6] fix a missing context indent, and scan-skel rework, Theophile Ranquet, 2012/10/04
- [PATCH 1/6] errors: pointerize complain_at_indent,
Theophile Ranquet <=
- [PATCH 4/6] scan-skel.l: split @directive functions, Theophile Ranquet, 2012/10/04
- [PATCH 2/6] errors: factor b4_error @directives, Theophile Ranquet, 2012/10/04
- [PATCH 3/6] errors: support indented context info in m4 macros, Theophile Ranquet, 2012/10/04
- [PATCH 5/6] scan-skel.l: recognize the @directives directly in scanner, Theophile Ranquet, 2012/10/04
- [PATCH 6/6] scan-skel.l: change fail_for_invalid_at prototype, Theophile Ranquet, 2012/10/04