Jean-Pierre Chrétien wrote:

> Georg Baum <[EMAIL PROTECTED]> writes:
 
> I get this:
> ->/usr/local/LyX//bin/tex2lyx -f tex2lyx_include.tex >tex2lyx_include.lyx
> Ignoring options 'T1' of package fontenc.
> InFile: mychapter.tex
> Readable ?1
> OutFile: mychapter.lyx
> Writable ?0
> Test false
> 
> So Solaris barfs on writability of non-existing files (and Debian as well
> as the behaviour is the same: mychapter.tex remains unconverted).
> 
> If I do so:
> ->touch mychapter.lyx
> ->/usr/local/LyX//bin/tex2lyx -f tex2lyx_include.tex >tex2lyx_include.lyx
> Ignoring options 'T1' of package fontenc.
> InFile: mychapter.tex
> Readable ?1
> OutFile: mychapter.lyx
> Writable ?1
> 
> it's OK.
> 
> However it's not really a multipart lyx document, as tex2lyx_include.tex
> still includes mychapter.tex

That should not happen, but lets fix the first bug first. Could you please
try the following patch that gets rid of the racy checks on solaris?


Georg
Index: src/tex2lyx/tex2lyx.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/tex2lyx/tex2lyx.C,v
retrieving revision 1.66
diff -u -p -r1.66 tex2lyx.C
--- src/tex2lyx/tex2lyx.C	31 Jan 2005 19:57:03 -0000	1.66
+++ src/tex2lyx/tex2lyx.C	23 Mar 2005 16:45:00 -0000
@@ -168,12 +167,12 @@ namespace {
  */
 void read_syntaxfile(string const & file_name)
 {
-	if (!IsFileReadable(file_name)) {
+	ifstream is(file_name.c_str());
+	if (!is.good()) {
 		cerr << "Could not open syntax file \"" << file_name
 		     << "\" for reading." << endl;
 		exit(2);
 	}
-	ifstream is(file_name.c_str());
 	// We can use our TeX parser, since the syntax of the layout file is
 	// modeled after TeX.
 	// Unknown tokens are just silently ignored, this helps us to skip some
@@ -363,14 +362,16 @@ void tex2lyx(std::istream &is, std::ostr
 
 bool tex2lyx(string const &infilename, string const &outfilename)
 {
-	if (!(IsFileReadable(infilename) && fs::is_writable(outfilename))) {
+	ifstream is(infilename.c_str());
+	if (!is.good()) {
+		cerr << "Could not open file \"" << infilename
+		     << "\" for reading." << endl;
 		return false;
 	}
 	if (!overwrite_files && IsFileReadable(outfilename)) {
 		cerr << "Not overwriting existing file " << outfilename << "\n";
 		return false;
 	}
-	ifstream is(infilename.c_str());
 	ofstream os(outfilename.c_str());
 #ifdef FILEDEBUG
 	cerr << "File: " << infilename << "\n";
@@ -405,7 +406,8 @@ int main(int argc, char * argv[])
 	if (!syntaxfile.empty())
 		read_syntaxfile(syntaxfile);
 
-	if (!IsFileReadable(argv[1])) {
+	ifstream is(argv[1]);
+	if (!is.good()) {
 		cerr << "Could not open input file \"" << argv[1]
 		     << "\" for reading." << endl;
 		return 2;
@@ -416,7 +418,6 @@ int main(int argc, char * argv[])
 	else
 		masterFilePath = lyx::support::getcwd();
 
-	ifstream is(argv[1]);
 	tex2lyx(is, cout);
 
 	return 0;

Reply via email to