This patch uses a temporary file for conversion when it happens that
infile==outfile (for example conversion epsi=>eps). I think it is
safe, but when trying to test it, I failed to find a way to trigger it
%-|

So my question is: is something like this still necessary with
1.2.2cvs? Rod, do you still have problems with 1.2.2cvs and if you do,
does this patch help?

JMarc

Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.713.2.45
diff -u -p -r1.713.2.45 ChangeLog
--- src/ChangeLog	24 Oct 2002 17:52:45 -0000	1.713.2.45
+++ src/ChangeLog	18 Nov 2002 17:16:07 -0000
@@ -1,3 +1,8 @@
+2002-11-18  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* converter.C (convert): if from and to files are the same, use a
+	temporary files as intermediary
+
 2002-10-24  Dekel Tsur  <[EMAIL PROTECTED]>
 
 	* paragraph.C (TeXOnePar): Fix bug with language changes in nested
Index: src/converter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/converter.C,v
retrieving revision 1.47.2.2
diff -u -p -r1.47.2.2 converter.C
--- src/converter.C	16 Jul 2002 13:22:46 -0000	1.47.2.2
+++ src/converter.C	18 Nov 2002 17:16:07 -0000
@@ -613,6 +613,14 @@ bool Converters::convert(Buffer const * 
 				  subst(conv.result_file,
 					token_base, OnlyFilename(from_base)));
 
+		// if input and output files are equal, we use a
+		// temporary file as intermediary (JMarc)
+		string real_outfile;
+		if (outfile == infile) {
+			real_outfile = infile;
+			outfile = AddName(buffer->tmppath, "tmpfile.out");
+		}
+
 		if (conv.latex) {
 			run_latex = true;
 			string command = subst(conv.command, token_from, "");
@@ -662,6 +670,16 @@ bool Converters::convert(Buffer const * 
 			} else
 				res = one.startscript(type, command);
 
+			if (!real_outfile.empty()) {
+				if (!lyx::rename(outfile, real_outfile))
+					res = -1;
+				else
+					lyxerr[Debug::FILES]
+						<< "renaming file " << outfile
+						<< " to " << real_outfile
+						<< endl;
+			}
+			
 			if (!conv.parselog.empty()) {
 				string const logfile =  infile2 + ".log";
 				string const script = LibScriptSearch(conv.parselog);

Reply via email to