* 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
This commit is contained in:
Jürgen Spitzmüller 2008-11-25 14:44:17 +00:00
parent cf247233c9
commit c2bdcc6b63
3 changed files with 16 additions and 1 deletions

View File

@ -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;

View File

@ -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

View File

@ -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.