diff --git a/ChangeLog b/ChangeLog index 879101d2e..402614fd3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2004-10-22 Alexandre Duret-Lutz + * src/misc/bareword.hh, src/misc/bareword.cc (quote_unless_bare_word): + New function. + * src/ltlvisit/tostring.cc (to_spin_string_visitor): Move to anonymous namespace. diff --git a/src/misc/bareword.cc b/src/misc/bareword.cc index 01dc784e5..3d548d797 100644 --- a/src/misc/bareword.cc +++ b/src/misc/bareword.cc @@ -21,6 +21,7 @@ #include "bareword.hh" #include +#include "escape.hh" namespace spot { @@ -37,4 +38,14 @@ namespace spot return false; return true; } + + std::string + quote_unless_bare_word(const std::string& str) + { + if (is_bare_word(str.c_str())) + return str; + else + return "\"" + escape_str(str) + "\""; + } + } diff --git a/src/misc/bareword.hh b/src/misc/bareword.hh index 30c44bdf4..0c8872a91 100644 --- a/src/misc/bareword.hh +++ b/src/misc/bareword.hh @@ -19,7 +19,11 @@ // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. +#include + namespace spot { bool is_bare_word(const char* str); + + std::string quote_unless_bare_word(const std::string& str); }