]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_main.C
last Friday's text*.C -> text_func shuffle
[lyx.git] / src / lyx_main.C
index 45936db47937951e120d3fd593491ffd24730776..436ec5d8087cc51ff47df46513aae1ee7e6ccace 100644 (file)
@@ -48,6 +48,8 @@
 #include <csignal>
 #include <iostream>
 
+using namespace lyx::support;
+
 using std::vector;
 using std::endl;
 
@@ -143,21 +145,24 @@ LyX::LyX(int & argc, char * argv[])
 
                Buffer * last_loaded = 0;
 
-               vector<string>::iterator it = files.begin();
-               vector<string>::iterator end = files.end();
+               vector<string>::const_iterator it = files.begin();
+               vector<string>::const_iterator end = files.end();
+
                for (; it != end; ++it) {
-                       last_loaded = bufferlist.newBuffer(*it, false);
+                       // get absolute path of file and add ".lyx" to
+                       // the filename if necessary
+                       string s = FileSearch(string(), *it, "lyx");
+                       if (s.empty()) {
+                               s = *it;
+                       }
+
+                       last_loaded = bufferlist.newBuffer(s, false);
                        last_loaded->parseError.connect(boost::bind(&LyX::printError, this, _1));
-                       loadLyXFile(last_loaded, *it);
+                       loadLyXFile(last_loaded, s);
                }
 
                files.clear();
 
-               // no buffer loaded, create one
-               string const tmpfile = "tmpfile";
-               if (!last_loaded)
-                       last_loaded = newFile(tmpfile, string());
-
                bool success = false;
 
                // try to dispatch to last loaded buffer first
@@ -212,7 +217,7 @@ static void error_handler(int err_sig)
        lyxerr << "Bye." << endl;
        if (err_sig!= SIGHUP &&
           (!GetEnv("LYXDEBUG").empty() || err_sig == SIGSEGV))
-               lyx::abort();
+               lyx::support::abort();
        exit(0);
 }
 
@@ -221,7 +226,7 @@ static void error_handler(int err_sig)
 
 void LyX::printError(ErrorItem const & ei)
 {
-       std::cerr << _("LyX: ") << ei.error 
+       std::cerr << _("LyX: ") << ei.error
                  << ':' << ei.description << std::endl;
 
 }
@@ -451,7 +456,7 @@ void LyX::init(bool gui)
        system_lcolor = lcolor;
 
        string prefsfile = "preferences";
-       // back compatibility to lyxs < 1.1.6 
+       // back compatibility to lyxs < 1.1.6
        if (LibFileSearch(string(), prefsfile).empty())
                prefsfile = "lyxrc";
        if (!LibFileSearch(string(), prefsfile).empty())