]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_main.C
fix "make dist" target
[lyx.git] / src / lyx_main.C
index 82dd64cbf9db6d70c1117adda9ca69a613d5f5c1..c3122ef1e7ee4bd774b6d998f439bbf4d10793e9 100644 (file)
 #include "lyxlex.h"
 #include "encoding.h"
 #include "converter.h"
+#include "language.h"
+#include "support/os.h"
 
 using std::endl;
 
+#ifndef CXX_GLOBAL_CSTD
+using std::signal;
+#endif
+
 extern void LoadLyXFile(string const &);
 extern void QuitLyX();
 
@@ -101,7 +107,7 @@ LyX::LyX(int * argc, char * argv[])
        
        // Initialization of LyX (reads lyxrc and more)
        lyxerr[Debug::INIT] << "Initializing LyX::init..." << endl;
-       init(argc, argv, gui);
+       init(gui);
        lyxerr[Debug::INIT] << "Initializing LyX::init...done" << endl;
 
        lyxGUI->init();
@@ -179,7 +185,7 @@ LyX::~LyX()
 
 extern "C" void error_handler(int err_sig);
 
-void LyX::init(int */*argc*/, char **argv, bool gui)
+void LyX::init(bool gui)
 {
        // Install the signal handlers
        signal(SIGHUP, error_handler);
@@ -193,27 +199,9 @@ void LyX::init(int */*argc*/, char **argv, bool gui)
        //
 
        string fullbinpath;
-       string binpath = subst(argv[0], '\\', '/');
-       string binname = OnlyFilename(argv[0]);
-       // Sorry for system specific code. (SMiyata)
-       if (suffixIs(binname, ".exe")) 
-               binname.erase(binname.length()-4, string::npos);
-       
-       binpath = ExpandPath(binpath); // This expands ./ and ~/
-       
-       if (!AbsolutePath(binpath)) {
-               string binsearchpath = GetEnvPath("PATH");
-               // This will make "src/lyx" work always :-)
-               binsearchpath += ";."; 
-               binpath = FileOpenSearch(binsearchpath, argv[0]);
-       }
-
+       string binpath = os::binpath();
+       string binname = os::binname();
        fullbinpath = binpath;
-       binpath = MakeAbsPath(OnlyPath(binpath));
-
-       // In case we are running in place and compiled with shared libraries
-       if (suffixIs(binpath, "/.libs/"))
-               binpath.erase(binpath.length()-6, string::npos);
 
        if (binpath.empty()) {
                lyxerr << _("Warning: could not determine path of binary.")
@@ -416,7 +404,7 @@ void LyX::init(int */*argc*/, char **argv, bool gui)
        // Read encodings
        ReadEncodingsFile("encodings");
        // Read languages
-       ReadLangugesFile("languages");
+       ReadLanguagesFile("languages");
 
        // Load the layouts
        lyxerr[Debug::INIT] << "Reading layouts..." << endl;
@@ -439,7 +427,8 @@ void LyX::init(int */*argc*/, char **argv, bool gui)
        }
 
        // Create temp directory        
-       system_tempdir = CreateLyXTmpDir(lyxrc.tempdir_path);
+       os::setTmpDir(CreateLyXTmpDir(lyxrc.tempdir_path));
+       system_tempdir = os::getTmpDir();
        if (lyxerr.debugging(Debug::INIT)) {
                lyxerr << "LyX tmp dir: `" << system_tempdir << '\'' << endl;
        }
@@ -653,8 +642,9 @@ void LyX::ReadUIFile(string const & name)
                        break;
 
                default:
-                       lex.printError("LyX::ReadUFile: "
-                                      "Unknown menu tag: `$$Token'");
+                       if(!strip(lex.GetString()).empty())
+                               lex.printError("LyX::ReadUIFile: "
+                                              "Unknown menu tag: `$$Token'");
                        break;
                }
        }
@@ -662,7 +652,7 @@ void LyX::ReadUIFile(string const & name)
 
 
 // Read the languages file `name'
-void LyX::ReadLangugesFile(string const & name)
+void LyX::ReadLanguagesFile(string const & name)
 {
        lyxerr[Debug::INIT] << "About to read " << name << "..." << endl;
 
@@ -690,8 +680,9 @@ void LyX::ReadEncodingsFile(string const & name)
 }
 
 
+namespace {
+
 // Set debugging level and report result to user
-static
 void setDebuggingLevel(string const & dbgLevel)
 {
        lyxerr << _("Setting debug level to ") <<  dbgLevel << endl;
@@ -701,7 +692,6 @@ void setDebuggingLevel(string const & dbgLevel)
 
 
 // Give command line help
-static
 void commandLineHelp()
 {
        lyxerr << "LyX " LYX_VERSION << " of " LYX_RELEASE << endl;
@@ -725,6 +715,8 @@ void commandLineHelp()
                  "Check the LyX man page for more details.") << endl;
 }
 
+} // namespace anon
+
 
 bool LyX::easyParse(int * argc, char * argv[])
 {