From c2bdcc6b639a9c238cd44ad0a0ba96c0383bec40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Tue, 25 Nov 2008 14:44:17 +0000 Subject: [PATCH] * Lexer.{cpp,h}: - implement quoteString for docstring * Menus.cpp: - use it for quoting flex argument. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27703 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Lexer.cpp | 12 ++++++++++++ src/Lexer.h | 3 +++ src/frontends/qt4/Menus.cpp | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Lexer.cpp b/src/Lexer.cpp index b0fabc29ad..546ae0e9e9 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -901,6 +901,18 @@ string Lexer::quoteString(string const & arg) } +// same for docstring +docstring Lexer::quoteString(docstring const & arg) +{ + docstring res; + res += '"'; + res += subst(subst(arg, from_ascii("\\"), from_ascii("\\\\")), + from_ascii("\""), from_ascii("\\\"")); + res += '"'; + return res; +} + + Lexer & Lexer::operator>>(char const * required) { string token; diff --git a/src/Lexer.h b/src/Lexer.h index 85b8b74600..ba085ed0e4 100644 --- a/src/Lexer.h +++ b/src/Lexer.h @@ -193,6 +193,9 @@ public: /// Quotes a string so that reading it again with Lexer::next(true) /// gets the original string static std::string quoteString(std::string const &); + /// Quotes a docstring so that reading it again with Lexer::next(true) + /// gets the original string + static docstring quoteString(docstring const &); private: /// noncopyable diff --git a/src/frontends/qt4/Menus.cpp b/src/frontends/qt4/Menus.cpp index 934f6dd11e..f8c2adbea5 100644 --- a/src/frontends/qt4/Menus.cpp +++ b/src/frontends/qt4/Menus.cpp @@ -851,7 +851,7 @@ void MenuDefinition::expandFlexInsert( docstring const label = cit->first; addWithStatusCheck(MenuItem(MenuItem::Command, toqstr(translateIfPossible(label)), - FuncRequest(LFUN_FLEX_INSERT, '"' + label + '"'))); + FuncRequest(LFUN_FLEX_INSERT, Lexer::quoteString(label)))); } } // FIXME This is a little clunky.