minor refactoring in user code scanning

* src/scan-code.l (show_sub_message): New, extracted from...
(show_sub_messages): here.
This commit is contained in:
Akim Demaille
2012-08-10 10:02:16 +02:00
parent 3995c0533b
commit cceb7b94e9
2 changed files with 69 additions and 65 deletions

1
TODO
View File

@@ -1,7 +1,6 @@
* Short term * Short term
** scan-code.l ** scan-code.l
Avoid variables for format strings, as then GCC cannot check them. Avoid variables for format strings, as then GCC cannot check them.
show_sub_messages should call show_sub_message.
** m4 names ** m4 names
b4_shared_declarations is no longer what it is. Make it b4_shared_declarations is no longer what it is. Make it

View File

@@ -400,15 +400,11 @@ get_at_spec(unsigned symbol_index)
} }
static void static void
show_sub_messages (const char* cp, bool explicit_bracketing, show_sub_message (const char* cp, bool explicit_bracketing,
int midrule_rhs_index, char dollar_or_at, int midrule_rhs_index, char dollar_or_at,
bool is_warning, unsigned indent) bool is_warning, unsigned indent,
const variant *var)
{ {
unsigned i;
for (i = 0; i < variant_count; ++i)
{
const variant *var = &variant_table[i];
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)
@@ -425,12 +421,9 @@ show_sub_messages (const char* cp, bool explicit_bracketing,
else else
{ {
static struct obstack msg_buf; static struct obstack msg_buf;
const char *tail = explicit_bracketing ? "" : const char *tail = explicit_bracketing ? "" : cp + strlen (var->id);
cp + strlen (var->id); const char *id = var->hidden_by ? var->hidden_by->id : var->id;
const char *id = var->hidden_by ? var->hidden_by->id : location id_loc = var->hidden_by ? var->hidden_by->loc : var->loc;
var->id;
location id_loc = var->hidden_by ? var->hidden_by->loc :
var->loc;
/* Create the explanation message. */ /* Create the explanation message. */
obstack_init (&msg_buf); obstack_init (&msg_buf);
@@ -471,6 +464,18 @@ show_sub_messages (const char* cp, bool explicit_bracketing,
obstack_free (&msg_buf, 0); obstack_free (&msg_buf, 0);
} }
} }
static void
show_sub_messages (const char* cp, bool explicit_bracketing,
int midrule_rhs_index, char dollar_or_at,
bool is_warning, unsigned indent)
{
unsigned i;
for (i = 0; i < variant_count; ++i)
show_sub_message (cp, explicit_bracketing,
midrule_rhs_index, dollar_or_at,
is_warning, indent, &variant_table[i]);
} }
/* Returned from "parse_ref" when the reference /* Returned from "parse_ref" when the reference