* src/print.c (print_core): Likewise.
+2001-11-19 Akim Demaille <akim@epita.fr>
+
+ * src/print_graph.c (print_core): Better locality of variables.
+ * src/print.c (print_core): Likewise.
+
2001-11-19 Akim Demaille <akim@epita.fr>
* src/vcg.c: You do the output, so you are responsible of the
print_core (FILE *out, int state)
{
int i;
- int k;
- int rule;
- core *statep;
- short *sp;
- short *sp1;
-
- statep = state_table[state].state;
- k = statep->nitems;
+ core *statep = state_table[state].state;
- if (k == 0)
+ if (!statep->nitems)
return;
- for (i = 0; i < k; i++)
+ for (i = 0; i < statep->nitems; i++)
{
+ short *sp;
+ short *sp1;
+ int rule;
+
sp1 = sp = ritem + statep->items[i];
while (*sp > 0)
fprintf (out, " %s -> ", tags[rule_table[rule].lhs]);
for (sp = ritem + rule_table[rule].rhs; sp < sp1; sp++)
- {
- fprintf (out, "%s ", tags[*sp]);
- }
+ fprintf (out, "%s ", tags[*sp]);
fputc ('.', out);
- while (*sp > 0)
- {
- fprintf (out, " %s", tags[*sp]);
- sp++;
- }
+ for (/* Nothing */; *sp > 0; ++sp)
+ fprintf (out, " %s", tags[*sp]);
fprintf (out, _(" (rule %d)"), rule);
fputc ('\n', out);
print_core (int state, struct obstack *node_obstack)
{
int i;
- int k;
- int rule;
- core *statep;
- short *sp;
- short *sp1;
+ core *statep = state_table[state].state;
- statep = state_table[state].state;
- k = statep->nitems;
-
- if (k == 0)
+ if (!statep->nitems)
return;
- for (i = 0; i < k; i++)
+ for (i = 0; i < statep->nitems; i++)
{
- if (i)
- obstack_1grow (node_obstack, '\n');
+ short *sp;
+ short *sp1;
+ int rule;
sp1 = sp = ritem + statep->items[i];
rule = -(*sp);
+ if (i)
+ obstack_1grow (node_obstack, '\n');
obstack_fgrow1 (node_obstack, "%d: ", rule);
obstack_fgrow1 (node_obstack, " %s -> ",
tags[rule_table[rule].lhs]);
obstack_1grow (node_obstack, '.');
- while (*sp > 0)
- obstack_fgrow1 (node_obstack, " %s", tags[*sp++]);
+ for (/* Nothing */; *sp > 0; ++sp)
+ obstack_fgrow1 (node_obstack, " %s", tags[*sp]);
}
}