graphs: style: use left justification for states

The label text of nodes is centered "by default" (by the use of '\n' as
a line feed). This gives bad readability to the grammar rules shown in
state nodes, a left justification is much nicer. This is done by using '\l'
as the line feed.

In order to allow \l in the DOT file, changes to the quoting system seem
necessary.

* src/print_graph.c (print_core): Escape tokens here, instead of...
* src/graphviz.c (output_node): Here...
(escape): Using this, new.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
This commit is contained in:
Theophile Ranquet
2012-10-08 15:53:44 +00:00
committed by Akim Demaille
parent 2be37f19fe
commit a13121f759
3 changed files with 42 additions and 27 deletions

View File

@@ -30,7 +30,7 @@
/* Return an unambiguous printable representation for NAME, suitable
for C strings. Use slot 2 since the user may use slots 0 and 1. */
static char const *
static char *
quote (char const *name)
{
return quotearg_n_style (2, c_quoting_style, name);
@@ -57,12 +57,12 @@ start_graph (FILE *fout)
void
output_node (int id, char const *label, FILE *fout)
{
fprintf (fout, " %d [label=%s]\n", id, quote (label));
fprintf (fout, " %d [label=\"%s\"]\n", id, label);
}
void
output_edge (int source, int destination, char const *label,
char const *style, FILE *fout)
char const *style, FILE *fout)
{
fprintf (fout, " %d -> %d [style=%s", source, destination, style);
if (label)
@@ -70,6 +70,14 @@ output_edge (int source, int destination, char const *label,
fputs ("]\n", fout);
}
char const *
escape (char const *name)
{
char *q = quote (name);
q[strlen (q) - 1] = '\0';
return q + 1;
}
void
finish_graph (FILE *fout)
{