Am Freitag, 25. August 2006 17:51 schrieb Jean-Marc Lasgouttes:
> >> 2687 fixedintrunk, regression LaTeX log file cannot be viewed if
> >> the path of the temp d...
> >> 
> >> Georg, I thought this one was already in...
> 
> Georg> No, I wanted to do that but then found out that the fix in
> Georg> trunk was incomplete and fixed that first. This is still on my
> Georg> todo list, I'll put that in during the next few days.
> 
> Thanks.

Oops, I mixed this one with bug 2637. I simply forgot 2687. Here is the 
patch that goes in now. I'll prepare another one for 2637.


Georg

Log:
fix bug 2687
        * src/lyxfunc.C
        (LyXFunc::dispatch): quote log filename

        * src/frontends/controllers/ControlLog.C
        (ControlLog::initialiseParams): parse \" as " and \\ as \ in filename

        * src/lyxlex.[Ch]
        (quoteString): new, quotes arguments for the "log" dialog
Index: src/lyxlex.h
===================================================================
--- src/lyxlex.h	(Revision 14840)
+++ src/lyxlex.h	(Arbeitskopie)
@@ -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;
 	///
Index: src/lyxfunc.C
===================================================================
--- src/lyxfunc.C	(Revision 14840)
+++ src/lyxfunc.C	(Arbeitskopie)
@@ -1164,12 +1164,12 @@ void LyXFunc::dispatch(FuncRequest const
 					data = "literate ";
 					break;
 				}
-				data += logfile.second;
+				data += LyXLex::quoteString(logfile.second);
 				owner->getDialogs().show("log", data);
 			}
 			else if (name == "vclog") {
 				string const data = "vc " +
-					owner->buffer()->lyxvc().getLogFile();
+					LyXLex::quoteString(owner->buffer()->lyxvc().getLogFile());
 				owner->getDialogs().show("log", data);
 			}
 			else
Index: src/frontends/controllers/ControlLog.C
===================================================================
--- src/frontends/controllers/ControlLog.C	(Revision 14840)
+++ src/frontends/controllers/ControlLog.C	(Arbeitskopie)
@@ -39,7 +39,11 @@ bool ControlLog::initialiseParams(string
 	lex.setStream(is);
 
 	string logtype, logfile;
-	lex >> logtype >> logfile;
+	lex >> logtype;
+	if (lex.isOK()) {
+		lex.next(true);
+		logfile = lex.getString();
+	}
 	if (!lex)
 		// Parsing of the data failed.
 		return false;
Index: src/lyxlex.C
===================================================================
--- src/lyxlex.C	(Revision 14840)
+++ src/lyxlex.C	(Arbeitskopie)
@@ -21,6 +21,8 @@
 #include "support/convert.h"
 #include "support/lstrings.h"
 
+#include <sstream>
+
 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();
+}

Reply via email to