From d9b29a0590e837fa27008d6b44bd8f19876a9236 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Fri, 22 Oct 2004 16:06:55 +0000 Subject: [PATCH] * src/misc/bareword.hh, src/misc/bareword.cc (quote_unless_bare_word): New function. --- ChangeLog | 3 +++ src/misc/bareword.cc | 11 +++++++++++ src/misc/bareword.hh | 4 ++++ 3 files changed, 18 insertions(+) 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); }