From 11d4a7aaeddb60b49501937f99d6e2518a102f7a Mon Sep 17 00:00:00 2001 From: Georg Baum Date: Sat, 12 Aug 2006 10:39:12 +0000 Subject: [PATCH] =?utf8?q?Move=20quoteArg=20to=20LyXLex=20so=20that=20it?= =?utf8?q?=20can=20be=20used=20e.g.=20for=20writing=20viewers=20to=20prefe?= =?utf8?q?rences=20=C2=A0=20=C2=A0=20=C2=A0=20=C2=A0=20*=20src/lyxfunc.C?= =?utf8?q?=20=C2=A0=20=C2=A0=20=C2=A0=20=C2=A0=20(quoteArg):=20move=20to?= =?utf8?q?=20LyXLex=20=C2=A0=20=C2=A0=20=C2=A0=20=C2=A0=20(LyXFunc::dispat?= =?utf8?q?ch):=20adjust=20to=20the=20change=20above?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit         * 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 --- src/lyxfunc.C | 13 ++----------- src/lyxlex.C | 11 +++++++++++ src/lyxlex.h | 4 ++++ 3 files changed, 17 insertions(+), 11 deletions(-) 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; /// -- 2.39.2