From: Georg Baum Date: Sat, 12 Aug 2006 10:39:12 +0000 (+0000) Subject: Move quoteArg to LyXLex so that it can be used e.g. for writing viewers to X-Git-Tag: 1.6.10~12857 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=11d4a7aaeddb60b49501937f99d6e2518a102f7a;p=features.git Move quoteArg to LyXLex so that it can be used e.g. for writing viewers to preferences         * src/lyxfunc.C         (quoteArg): move to LyXLex         (LyXFunc::dispatch): adjust to the change above         * src/lyxlex.[Ch]         (quoteString): new, moved from lyxfunc.C git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14620 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/lyxfunc.C b/src/lyxfunc.C index 9f2a418c9c..eff3011510 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -199,15 +199,6 @@ Change::Type lookupChangeType(DocIterator const & dit, bool outer = false) return Change::UNCHANGED; } - -/// quotes a string for use as an argument of the "log" dialog -string const quoteArg(string const & arg) -{ - ostringstream os; - os << '"' << subst(subst(arg, "\\", "\\\\"), "\"", "\\\"") << '"'; - return os.str(); -} - } LyXFunc::LyXFunc(LyXView * lv) @@ -1184,11 +1175,11 @@ void LyXFunc::dispatch(FuncRequest const & cmd) data = "literate "; break; } - data += quoteArg(logfile.second); + data += LyXLex::quoteString(logfile.second); owner->getDialogs().show("log", data); } else if (name == "vclog") { string const data = "vc " + - quoteArg(owner->buffer()->lyxvc().getLogFile()); + LyXLex::quoteString(owner->buffer()->lyxvc().getLogFile()); owner->getDialogs().show("log", data); } else owner->getDialogs().show(name, data); diff --git a/src/lyxlex.C b/src/lyxlex.C index 6758dc167d..4a84d7fcbe 100644 --- a/src/lyxlex.C +++ b/src/lyxlex.C @@ -21,6 +21,8 @@ #include "support/convert.h" #include "support/lstrings.h" +#include + using lyx::support::compare_ascii_no_case; using lyx::support::isStrDbl; using lyx::support::isStrInt; @@ -293,3 +295,12 @@ LyXLex & LyXLex::operator>>(bool & s) } return *this; } + + +/// quotes a string, e.g. for use in preferences files or as an argument of the "log" dialog +string const LyXLex::quoteString(string const & arg) +{ + std::ostringstream os; + os << '"' << subst(subst(arg, "\\", "\\\\"), "\"", "\\\"") << '"'; + return os.str(); +} diff --git a/src/lyxlex.h b/src/lyxlex.h index dc16b52b1a..384a03b4ad 100644 --- a/src/lyxlex.h +++ b/src/lyxlex.h @@ -140,6 +140,10 @@ public: /// extract bool LyXLex & operator>>(bool &); + /// Quotes a string so that reading it again with LyXLex::next(true) + /// gets the original string + static std::string const quoteString(std::string const &); + private: class Pimpl; ///