]> git.lyx.org Git - features.git/commitdiff
fix open files bug on solaris
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 27 Mar 2005 18:37:42 +0000 (18:37 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Sun, 27 Mar 2005 18:37:42 +0000 (18:37 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9752 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/ChangeLog
src/tex2lyx/tex2lyx.C

index ee63d5c291d2e1cb81900b40d9e7c3958bdaa8ee..9d091be9ae31feb1b9e675e116d58b6dd956f368 100644 (file)
@@ -1,3 +1,9 @@
+2005-03-27  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
+
+       * tex2lyx.C (read_syntaxfile): Don't use racy test with IsFileReadable
+       * tex2lyx.C (tex2lyx): ditto, and don't use fs::is_writable (it
+       returns false if the file does not exist on solaris)
+
 2005-03-18  Georg Baum  <Georg.Baum@post.rwth-aachen.de>
 
        * text.C (parse_text): Fix \start_of_appendix output
index f32fdcca28e7519bff747cddc947801b2a389d25..67f8d30cf36c2f6f1d40c86341a02df27bbe27ca 100644 (file)
@@ -168,12 +168,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 +363,16 @@ void tex2lyx(std::istream &is, std::ostream &os)
 
 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 +407,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 +419,6 @@ int main(int argc, char * argv[])
        else
                masterFilePath = lyx::support::getcwd();
 
-       ifstream is(argv[1]);
        tex2lyx(is, cout);
 
        return 0;