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:
Akim Demaille
2020-06-13 16:03:53 +02:00
parent e4d33cf579
commit efbcadeca7
5 changed files with 59 additions and 37 deletions

View File

@@ -171,6 +171,23 @@ typedef size_t uintptr_t;
# define obstack_sgrow(Obs, Str) \
obstack_grow (Obs, Str, strlen (Str))
/* Output Str escaped to be a string.
For instance "\"foo\"" -> "\\\"foo\\\"". */
# define obstack_backslash(Obs, Str) \
do { \
char const *p__; \
for (p__ = Str; *p__; p__++) \
switch (*p__) \
{ \
case '"': obstack_sgrow (Obs, "\\\""); break; \
case '\\': obstack_sgrow (Obs, "\\\\"); break; \
default: obstack_1grow (Obs, *p__); break; \
} \
} while (0)
/* Output Str escaped for our postprocessing (i.e., escape M4 special
characters).