From f02156ebffe143c4445c1fa031d1fee4c9cb8086 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Tue, 18 Sep 2012 20:57:47 +0200 Subject: [PATCH] Various utf-8 fixes. * src/bin/ltl2tgba.cc: Add option -8. * src/tgbatest/ltl2tgba.cc, wrap/python/spot.i: Enable utf8 on sba_explicit_formula automata too. --- src/bin/ltl2tgba.cc | 18 ++++++++++++++++++ src/tgbatest/ltl2tgba.cc | 11 ++++++++--- wrap/python/spot.i | 3 +++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/bin/ltl2tgba.cc b/src/bin/ltl2tgba.cc index 1fa15ccf9..1f6c855ee 100644 --- a/src/bin/ltl2tgba.cc +++ b/src/bin/ltl2tgba.cc @@ -42,6 +42,7 @@ #include "tgbaalgos/neverclaim.hh" #include "tgbaalgos/postproc.hh" #include "tgbaalgos/save.hh" +#include "tgba/bddprint.hh" const char* argp_program_version = "\ ltl2tgba (" SPOT_PACKAGE_STRING ")\n\ @@ -87,6 +88,8 @@ static const argp_option options[] = { "lbtt", OPT_LBTT, 0, 0, "LBTT's format", 0 }, { "spin", 's', 0, 0, "Spin neverclaim (implies --ba)", 0 }, { "spot", OPT_SPOT, 0, 0, "SPOT's format", 0 }, + { "utf8", '8', 0, 0, "enable UTF-8 characters in output " + "(works only with --spot or --dot)", 0 }, /**************************************************/ { 0, 0, 0, 0, "Translation intent:", 4 }, { "small", OPT_SMALL, 0, 0, "prefer small automata (default)", 0 }, @@ -121,6 +124,7 @@ spot::postprocessor::output_type type = spot::postprocessor::TGBA; spot::postprocessor::output_pref pref = spot::postprocessor::Small; spot::postprocessor::optimization_level level = spot::postprocessor::High; enum output_format { Dot, Lbtt, Spin, Spot } format = Dot; +bool utf8 = false; static int parse_opt(int key, char* arg, struct argp_state*) @@ -128,6 +132,9 @@ parse_opt(int key, char* arg, struct argp_state*) // This switch is alphabetically-ordered. switch (key) { + case '8': + spot::enable_utf8(); + break; case 'a': pref = spot::postprocessor::Any; break; @@ -231,6 +238,17 @@ namespace const spot::tgba* aut = ltl_to_tgba_fm(f, simpl.get_dict(), exprop); aut = post.run(aut, f); + if (utf8) + { + spot::tgba* a = const_cast(aut); + if (spot::tgba_explicit_formula* tef = + dynamic_cast(a)) + tef->enable_utf8(); + else if (spot::sba_explicit_formula* sef = + dynamic_cast(a)) + sef->enable_utf8(); + } + switch (format) { case Dot: diff --git a/src/tgbatest/ltl2tgba.cc b/src/tgbatest/ltl2tgba.cc index ea1779899..1ee6964e2 100644 --- a/src/tgbatest/ltl2tgba.cc +++ b/src/tgbatest/ltl2tgba.cc @@ -1294,9 +1294,14 @@ main(int argc, char** argv) } if (utf8_opt) - if (spot::tgba_explicit_formula* tef = - dynamic_cast(a)) - tef->enable_utf8(); + { + if (spot::tgba_explicit_formula* tef = + dynamic_cast(a)) + tef->enable_utf8(); + else if (spot::sba_explicit_formula* sef = + dynamic_cast(a)) + sef->enable_utf8(); + } if (output != -1) { diff --git a/wrap/python/spot.i b/wrap/python/spot.i index c450aa4d0..1484769e6 100644 --- a/wrap/python/spot.i +++ b/wrap/python/spot.i @@ -362,6 +362,9 @@ tgba_enable_utf8(spot::tgba* a) if (spot::tgba_explicit_formula* tef = dynamic_cast(a)) tef->enable_utf8(); + else if (spot::sba_explicit_formula* sef = + dynamic_cast(a)) + sef->enable_utf8(); } spot::ltl::parse_error_list