dot: quote identifiers containing a minus

* spot/twaalgos/dot.cc: Quote identifiers containing a minus.
* tests/core/alternating.test: Add test case.
* NEWS: Mention the bug.
This commit is contained in:
Alexandre Duret-Lutz 2022-06-23 16:19:50 +02:00
parent 166a26417c
commit b4279d3a12
3 changed files with 64 additions and 5 deletions

4
NEWS
View file

@ -120,6 +120,10 @@ New in spot 2.10.6.dev (not yet released)
into the universal edge vector, since the later can be into the universal edge vector, since the later can be
reallocated during that process. reallocated during that process.
- Printing an alternating automaton with print_dot() using 'u' to
hide true state could produce some incorrect GraphViz output if
the automaton as a true state as part of a universal group.
New in spot 2.10.6 (2022-05-18) New in spot 2.10.6 (2022-05-18)
Bugs fixed: Bugs fixed:

View file

@ -578,10 +578,27 @@ namespace spot
return tmp_dst.str(); return tmp_dst.str();
} }
template<typename U, typename V> void print_hidden_true_name(unsigned to, unsigned from) const
void print_true_state(U to, V from) const
{ {
os_ << " T" << to << 'T' << from << " [label=\"\", style=invis, "; os_ << 'T' << to << 'T' << from;
}
void print_hidden_true_name(unsigned to, const std::string& from) const
{
bool neg = from[0] == '-';
if (neg)
os_ << '"';
os_ << 'T' << to << 'T' << from;
if (neg)
os_ << '"';
}
template <typename F>
void print_true_state(unsigned to, F from) const
{
os_ << " ";
print_hidden_true_name(to, from);
os_ << " [label=\"\", style=invis, ";
os_ << (opt_vertical_ ? "height=0]\n" : "width=0]\n"); os_ << (opt_vertical_ ? "height=0]\n" : "width=0]\n");
} }
@ -606,7 +623,7 @@ namespace spot
print_true_state(d, dest); print_true_state(d, dest);
os_ << " " << dest << " -> "; os_ << " " << dest << " -> ";
if (dst_is_hidden_true_state) if (dst_is_hidden_true_state)
os_ << 'T' << d << 'T' << dest; print_hidden_true_name(d, dest);
else else
os_ << d; os_ << d;
if ((style && *style) || opt_id_) if ((style && *style) || opt_id_)

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2016-2018, 2020-2021 Laboratoire de Recherche et # Copyright (C) 2016-2018, 2020-2022 Laboratoire de Recherche et
# Développement de l'Epita (LRDE). # Développement de l'Epita (LRDE).
# #
# This file is part of Spot, a model checking library. # This file is part of Spot, a model checking library.
@ -1009,3 +1009,41 @@ test '2_0_1_1_1_1_3_3' = "`autfilt --stats=$stats in`"
autfilt --stats='%[x]U' in 2>stderr && exit2 autfilt --stats='%[x]U' in 2>stderr && exit2
grep '%\[x\]U' stderr grep '%\[x\]U' stderr
cat >in <<EOF
HOA: v1
States: 2
Start: 1
AP: 1 "a"
acc-name: co-Buchi
Acceptance: 1 Fin(0)
properties: trans-labels explicit-labels trans-acc complete univ-branch
--BODY--
State: 0
[t] 0
State: 1
[t] 0&1 {0}
[0] 0
--END--
EOF
autfilt -du in >out.dot
# T0T-1 is not a valid name for GraphViz, it has to be quoted.
cat >exp.dot <<EOF
digraph "" {
rankdir=LR
label="Fin(0)\n[co-Büchi]"
labelloc="t"
node [shape="circle"]
I [label="", style=invis, width=0]
I -> 1
1 [label="1"]
1 -> -1 [label="1\n{0}", arrowhead=onormal]
-1 [label=<>,shape=point,width=0.05,height=0.05]
"T0T-1" [label="", style=invis, width=0]
-1 -> "T0T-1"
-1 -> 1
T0T1 [label="", style=invis, width=0]
1 -> T0T1 [label="a"]
}
EOF
diff out.dot exp.dot