Attached are patches to quote the graphics conversion commands correctly,
to not remove these quotes on Windows when converting the command string
to an array of args and to protect the lyxerr output when spawning the
child inside a lyxerr.debugging(FILES) block.
Once again, these patches are not contraversial, so I'm going to commit to
both trees now.
--
Angus
Index: src/graphics/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/ChangeLog,v
retrieving revision 1.139.2.8
diff -u -p -r1.139.2.8 ChangeLog
--- src/graphics/ChangeLog 7 Dec 2004 10:49:25 -0000 1.139.2.8
+++ src/graphics/ChangeLog 17 Apr 2005 18:29:44 -0000
@@ -1,3 +1,7 @@
+2005-04-17 Angus Leeming <[EMAIL PROTECTED]>
+
+ * GraphicsConverter.C (c-tor): quote conversion commands correctly.
+
2004-12-07 Angus Leeming <[EMAIL PROTECTED]>
* *.[Ch]: remove all traces of #pragma interface/implementation
Index: src/graphics/GraphicsConverter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/GraphicsConverter.C,v
retrieving revision 1.25.2.3
diff -u -p -r1.25.2.3 GraphicsConverter.C
--- src/graphics/GraphicsConverter.C 7 Dec 2004 10:49:25 -0000 1.25.2.3
+++ src/graphics/GraphicsConverter.C 17 Apr 2005 18:29:44 -0000
@@ -145,9 +145,12 @@ Converter::Impl::Impl(string const & fro
if (!success) {
script_command_ =
- "sh " + LibFileSearch("scripts", "convertDefault.sh") +
- ' ' + from_format + ':' + from_file + ' ' +
- to_format + ':' + to_file_;
+ "sh " +
+ QuoteName(LibFileSearch("scripts", "convertDefault.sh")) +
+ ' ' +
+ QuoteName(from_format + ':' + from_file) +
+ ' ' +
+ QuoteName(to_format + ':' + to_file_);
lyxerr[Debug::GRAPHICS]
<< "\tNo converter defined! I use convertDefault.sh\n\t"
@@ -181,8 +184,9 @@ Converter::Impl::Impl(string const & fro
// We create a dummy command for ease of understanding of the
// list of forked processes.
// Note that 'sh ' is absolutely essential, or execvp will fail.
- script_command_ = "sh " + script_file_ + ' ' +
- OnlyFilename(from_file) + ' ' + to_format;
+ script_command_ = "sh " + QuoteName(script_file_) + ' ' +
+ QuoteName(OnlyFilename(from_file)) + ' ' +
+ QuoteName(to_format);
}
// All is ready to go
valid_process_ = true;
Index: src/support/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/ChangeLog,v
retrieving revision 1.149.2.38
diff -u -p -r1.149.2.38 ChangeLog
--- src/support/ChangeLog 17 Feb 2005 17:53:38 -0000 1.149.2.38
+++ src/support/ChangeLog 17 Apr 2005 18:29:46 -0000
@@ -1,3 +1,10 @@
+2005-04-17 Angus Leeming <[EMAIL PROTECTED]>
+
+ * forkedcall.C (generateChild): do not strip quotes from args on
+ Windows.
+ Wrap lyxerr output inside an if (lyxerr.debugging(Debug::FILES))
+ block.
+
2005-02-17 Angus Leeming <[EMAIL PROTECTED]>
* copy.C (copy): Pass the ios::in flag to the ifstream constructor.
Index: src/support/forkedcall.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcall.C,v
retrieving revision 1.11.2.5
diff -u -p -r1.11.2.5 forkedcall.C
--- src/support/forkedcall.C 3 Feb 2005 14:56:11 -0000 1.11.2.5
+++ src/support/forkedcall.C 17 Apr 2005 18:29:47 -0000
@@ -283,11 +283,23 @@ int Forkedcall::generateChild()
if (c == ' ')
*it = '\0';
else if (c == '\'' || c == '"') {
+#if defined (_WIN32)
+ // How perverse!
+ // spawnvp *requires* the quotes or it will
+ // split the arg at the internal whitespace!
+ // Make shure the quote is a DOS-style one.
+ *it = '"';
+#else
*it = '\0';
+#endif
inside_quote = c;
}
} else if (c == inside_quote) {
+#if defined (_WIN32)
+ *it = '"';
+#else
*it = '\0';
+#endif
inside_quote = 0;
}
}
@@ -304,13 +316,16 @@ int Forkedcall::generateChild()
argv.push_back(0);
// Debug output.
- vector<char *>::iterator ait = argv.begin();
- vector<char *>::iterator const aend = argv.end();
- lyxerr << "<command>\n";
- for (; ait != aend; ++ait)
- if (*ait)
- lyxerr << '\t'<< *ait << '\n';
- lyxerr << "</command>" << std::endl;
+ if (lyxerr.debugging(Debug::FILES)) {
+ vector<char *>::iterator ait = argv.begin();
+ vector<char *>::iterator const aend = argv.end();
+ lyxerr << "<command>\n\t" << line
+ << "\n\tInterpretted as:\n\n";
+ for (; ait != aend; ++ait)
+ if (*ait)
+ lyxerr << '\t'<< *ait << '\n';
+ lyxerr << "</command>" << std::endl;
+ }
#ifndef __EMX__
pid_t const cpid = ::fork();
Index: src/graphics/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/ChangeLog,v
retrieving revision 1.217
diff -u -p -r1.217 ChangeLog
--- src/graphics/ChangeLog 15 Feb 2005 10:17:56 -0000 1.217
+++ src/graphics/ChangeLog 17 Apr 2005 18:30:46 -0000
@@ -1,3 +1,7 @@
+2005-04-17 Angus Leeming <[EMAIL PROTECTED]>
+
+ * GraphicsConverter.C (c-tor): quote conversion commands correctly.
+
2005-02-15 Angus Leeming <[EMAIL PROTECTED]>
* GraphicsLoader.C: s/struct/class/ in definition of
Index: src/graphics/GraphicsConverter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/GraphicsConverter.C,v
retrieving revision 1.48
diff -u -p -r1.48 GraphicsConverter.C
--- src/graphics/GraphicsConverter.C 19 Jan 2005 15:03:30 -0000 1.48
+++ src/graphics/GraphicsConverter.C 17 Apr 2005 18:30:46 -0000
@@ -167,9 +167,12 @@ Converter::Impl::Impl(string const & fro
if (!success) {
script_command_ =
- "sh " + LibFileSearch("scripts", "convertDefault.sh") +
- ' ' + from_format + ':' + from_file + ' ' +
- to_format + ':' + to_file_;
+ "sh " +
+ QuoteName(LibFileSearch("scripts", "convertDefault.sh")) +
+ ' ' +
+ QuoteName(from_format + ':' + from_file) +
+ ' ' +
+ QuoteName(to_format + ':' + to_file_);
lyxerr[Debug::GRAPHICS]
<< "\tNo converter defined! I use convertDefault.sh\n\t"
@@ -203,8 +206,9 @@ Converter::Impl::Impl(string const & fro
// We create a dummy command for ease of understanding of the
// list of forked processes.
// Note: 'sh ' is absolutely essential, or execvp will fail.
- script_command_ = "sh " + script_file_ + ' ' +
- OnlyFilename(from_file) + ' ' + to_format;
+ script_command_ = "sh " + QuoteName(script_file_) + ' ' +
+ QuoteName(OnlyFilename(from_file)) + ' ' +
+ QuoteName(to_format);
}
// All is ready to go
valid_process_ = true;
Index: src/support/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/ChangeLog,v
retrieving revision 1.330
diff -u -p -r1.330 ChangeLog
--- src/support/ChangeLog 23 Mar 2005 21:10:43 -0000 1.330
+++ src/support/ChangeLog 17 Apr 2005 18:30:48 -0000
@@ -1,3 +1,10 @@
+2005-04-17 Angus Leeming <[EMAIL PROTECTED]>
+
+ * forkedcall.C (generateChild): do not strip quotes from args on
+ Windows.
+ Wrap lyxerr output inside an if (lyxerr.debugging(Debug::FILES))
+ block.
+
2005-03-23 Angus Leeming <[EMAIL PROTECTED]>
* Makefile.am (build_package): Solaris sed does not like
Index: src/support/forkedcall.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/forkedcall.C,v
retrieving revision 1.23
diff -u -p -r1.23 forkedcall.C
--- src/support/forkedcall.C 3 Feb 2005 14:55:33 -0000 1.23
+++ src/support/forkedcall.C 17 Apr 2005 18:30:48 -0000
@@ -282,11 +282,23 @@ int Forkedcall::generateChild()
if (c == ' ')
*it = '\0';
else if (c == '\'' || c == '"') {
+#if defined (_WIN32)
+ // How perverse!
+ // spawnvp *requires* the quotes or it will
+ // split the arg at the internal whitespace!
+ // Make shure the quote is a DOS-style one.
+ *it = '"';
+#else
*it = '\0';
+#endif
inside_quote = c;
}
} else if (c == inside_quote) {
+#if defined (_WIN32)
+ *it = '"';
+#else
*it = '\0';
+#endif
inside_quote = 0;
}
}
@@ -303,13 +315,16 @@ int Forkedcall::generateChild()
argv.push_back(0);
// Debug output.
- vector<char *>::iterator ait = argv.begin();
- vector<char *>::iterator const aend = argv.end();
- lyxerr << "<command>\n";
- for (; ait != aend; ++ait)
- if (*ait)
- lyxerr << '\t'<< *ait << '\n';
- lyxerr << "</command>" << std::endl;
+ if (lyxerr.debugging(Debug::FILES)) {
+ vector<char *>::iterator ait = argv.begin();
+ vector<char *>::iterator const aend = argv.end();
+ lyxerr << "<command>\n\t" << line
+ << "\n\tInterpretted as:\n\n";
+ for (; ait != aend; ++ait)
+ if (*ait)
+ lyxerr << '\t'<< *ait << '\n';
+ lyxerr << "</command>" << std::endl;
+ }
#ifndef __EMX__
pid_t const cpid = ::fork();