mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 05:13:04 +00:00
reports: don't escape the labels
Currently we use "quotearg" to escape the strings output in Dot. As a
result, if the user's locale is C for instance, all the non-ASCII are
escaped. Unfortunately graphviz does not interpret this style of
escaping.
For instance:
5 -> 2 [style=solid label="\"\303\221\303\271\341\271\203\303\251\342\204\235\303\264\""]
was displayed as a sequence of numbers. We now output:
5 -> 2 [style=solid label="\"Ñùṃéℝô\""]
independently of the user's locale.
* src/system.h (obstack_backslash): New.
* src/graphviz.h, src/graphviz.c (escape): Remove, use
obstack_backslash instead.
* src/print-graph.c: Likewise.
* tests/report.at: Adjust.
This commit is contained in:
@@ -72,18 +72,20 @@ output_edge (int source, int destination, char const *label,
|
||||
{
|
||||
fprintf (fout, " %d -> %d [style=%s", source, destination, style);
|
||||
if (label)
|
||||
fprintf (fout, " label=%s", quote (label));
|
||||
{
|
||||
fputs (" label=\"", fout);
|
||||
for (const char *cp = label; *cp; ++cp)
|
||||
switch (*cp)
|
||||
{
|
||||
case '"': fputs ("\\\"", fout); break;
|
||||
case '\\': fputs ("\\\\", fout); break;
|
||||
default: fputc (*cp, fout); break;
|
||||
}
|
||||
fputc ('"', fout);
|
||||
}
|
||||
fputs ("]\n", fout);
|
||||
}
|
||||
|
||||
char const *
|
||||
escape (char const *name)
|
||||
{
|
||||
char *q = quote (name);
|
||||
q[strlen (q) - 1] = '\0';
|
||||
return q + 1;
|
||||
}
|
||||
|
||||
static void
|
||||
no_reduce_bitset_init (state const *s, bitset *no_reduce_set)
|
||||
{
|
||||
@@ -149,7 +151,7 @@ print_token (struct obstack *out, bool first, char const *tok)
|
||||
{
|
||||
if (! first)
|
||||
obstack_sgrow (out, ", ");
|
||||
obstack_sgrow (out, escape (tok));
|
||||
obstack_backslash (out, tok);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user