]> git.lyx.org Git - features.git/commitdiff
Clean-up interface to os::init.
authorAngus Leeming <leeming@lyx.org>
Tue, 14 Dec 2004 16:20:07 +0000 (16:20 +0000)
committerAngus Leeming <leeming@lyx.org>
Tue, 14 Dec 2004 16:20:07 +0000 (16:20 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9372 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/main.C
src/support/ChangeLog
src/support/os.h
src/support/os_os2.C
src/support/os_unix.C
src/support/os_win32.C
src/tex2lyx/ChangeLog
src/tex2lyx/tex2lyx.C

index 487a8575c60bd2fb828c2472c732390b8963a473..c9fbafc9b236cdacafdd88d7c7349580e18fc91c 100644 (file)
@@ -1,3 +1,6 @@
+2004-12-14  Angus Leeming  <leeming@lyx.org>
+
+       * main.C: (main): no longer pass pointers to os::init.
 
 2004-12-06  Alfredo Braunstein  <abraunst@lyx.org>
 
index cc4a51537a1cf7f7c3dffb3238df6039b876a373..184549aa1a9311eb0e3b2c72aa4bca4a2c486dad 100644 (file)
@@ -34,7 +34,7 @@ int main(int argc, char * argv[])
        // early as possible.
        lyxerr.rdbuf(std::cerr.rdbuf());
 
-       os::init(&argc, &argv);
+       os::init(argc, argv);
 
        // initialize for internationalized version *EK*
        locale_init();
index 0ae02233d48b77c1d0c09565fbb824bec953452a..a3a774dd59555775e9b10558940a3748cd46b444 100644 (file)
@@ -1,3 +1,8 @@
+2004-12-14  Angus Leeming  <leeming@lyx.org>
+
+       * os.h, os_{os2,unix,win32}.C (init): change interface to no longer
+       pass the addresses of the parameters received by main.
+
 2004-12-14  Angus Leeming  <leeming@lyx.org>
 
        * copy.C (copy): open the ifstream with ios::binary.
index 7f1be08a3877dad6cf760e4dd43bd790a8797b62..dc6c2a45e300d23534a979dd8c8729e92202c61e 100644 (file)
@@ -28,7 +28,7 @@ enum shell_type {
 };
 
 // do some work just once
-void init(int * argc, char ** argv[]);
+void init(int argc, char * argv[]);
 // returns path of LyX binary
 std::string binpath();
 // returns name of LyX binary
@@ -45,9 +45,9 @@ shell_type shell();
 std::string::size_type common_path(std::string const & p1, std::string const & p2);
 // no-op on UNIX, '\\'->'/' on OS/2 and Win32, ':'->'/' on MacOS, etc.
 std::string slashify_path(std::string const & p);
-// converts a host OS path to unix style
+// Converts a unix style path to host OS style.
 std::string external_path(std::string const & p);
-// converts a unix path to host OS style
+// Converts a host OS style path to unix style.
 std::string internal_path(std::string const & p);
 // is path absolute?
 bool is_absolute_path(std::string const & p);
index 4fa61287abd92f2e0ef742262db2e98dadd2b155..495a19e5ea00091f2bd934a3f60dad9e85082515 100644 (file)
@@ -39,40 +39,38 @@ unsigned long cp_ = 0;
 namespace os {
 
 
-void init(int * argc, char ** argv[])
+void init(int argc, char * argv[])
 {
-       if (argc != 0 /* This is a hack! */) {
-               _wildcard(argc, argv);
-               PTIB ptib = new TIB[1];
-               PPIB ppib = new PIB[1];
-               APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
-               if (rc != NO_ERROR)
-                       exit(rc);
-               scoped_array<char> tmp(new char[256]);
-               // This is the only reliable way to retrieve the executable name.
-               rc = DosQueryModuleName(ppib->pib_hmte, 256L, tmp);
-               if (rc != NO_ERROR)
-                       exit(rc);
-               string p = tmp.get();
-               p = slashify_path(p);
-               binname_ = OnlyFilename(p);
-               binname_.erase(binname_.length()-4, string::npos);
-               binpath_ = OnlyPath(p);
-
-               // OS/2 cmd.exe has another use for '&'
-               string sh = OnlyFilename(GetEnvPath("EMXSHELL"));
-               if (sh.empty()) {
-                       // COMSPEC is set, unless user unsets
-                       sh = OnlyFilename(GetEnvPath("COMSPEC"));
-                       if (sh.empty())
-                               sh = "cmd.exe";
-               }
-               sh = lowercase(sh);     // DosMapCase() is an overkill here
-               if (contains(sh, "cmd.exe") || contains(sh, "4os2.exe"))
-                       shell_ = os::CMD_EXE;
-               else
-                       shell_ = os::UNIX;
+       _wildcard(&argc, &argv);
+       PTIB ptib = new TIB[1];
+       PPIB ppib = new PIB[1];
+       APIRET rc = DosGetInfoBlocks(&ptib, &ppib);
+       if (rc != NO_ERROR)
+               exit(rc);
+       scoped_array<char> tmp(new char[256]);
+       // This is the only reliable way to retrieve the executable name.
+       rc = DosQueryModuleName(ppib->pib_hmte, 256L, tmp);
+       if (rc != NO_ERROR)
+               exit(rc);
+       string p = tmp.get();
+       p = slashify_path(p);
+       binname_ = OnlyFilename(p);
+       binname_.erase(binname_.length()-4, string::npos);
+       binpath_ = OnlyPath(p);
+
+       // OS/2 cmd.exe has another use for '&'
+       string sh = OnlyFilename(GetEnvPath("EMXSHELL"));
+       if (sh.empty()) {
+               // COMSPEC is set, unless user unsets
+               sh = OnlyFilename(GetEnvPath("COMSPEC"));
+               if (sh.empty())
+                       sh = "cmd.exe";
        }
+       sh = lowercase(sh);     // DosMapCase() is an overkill here
+       if (contains(sh, "cmd.exe") || contains(sh, "4os2.exe"))
+               shell_ = os::CMD_EXE;
+       else
+               shell_ = os::UNIX;
 
        static bool initialized = false;
        if (initialized)
index 8c556da25303c6b1b516125a97619530dfbe2ae7..758ac1bfde0a350344ee5c582a93eb34ebf68717 100644 (file)
@@ -32,14 +32,14 @@ namespace lyx {
 namespace support {
 namespace os {
 
-void init(int * /*argc*/, char ** argv[])
+void init(int /*argc*/, char * argv[])
 {
        static bool initialized = false;
        if (initialized)
                return;
        initialized = true;
 
-       string tmp = *argv[0];
+       string tmp = argv[0];
        binname_ = OnlyFilename(tmp);
        tmp = ExpandPath(tmp); // This expands ./ and ~/
        if (!is_absolute_path(tmp)) {
index f8500a3ea5c95046e6d1e2512fd0824c726538ef..109e5825bee906538c790e2a484dca341ecf4a43 100644 (file)
@@ -40,14 +40,14 @@ namespace lyx {
 namespace support {
 namespace os {
 
-void init(int * /* argc */, char ** argv[])
+void init(int /* argc */, char * argv[])
 {
        static bool initialized = false;
        if (initialized)
                return;
        initialized = true;
 
-       string tmp = *argv[0];
+       string tmp = argv[0];
        binname_ = OnlyFilename(tmp);
        tmp = ExpandPath(tmp); // This expands ./ and ~/
 
@@ -55,7 +55,7 @@ void init(int * /* argc */, char ** argv[])
                string binsearchpath = GetEnvPath("PATH");
                // This will make "src/lyx" work always :-)
                binsearchpath += ";.";
-               tmp = *argv[0];
+               tmp = argv[0];
                tmp = FileOpenSearch(binsearchpath, tmp);
        }
 
index 289555ab85d6b259f4577c1e5018831b7b3ded47..745b3e0840a02736a30a97b0fddd766dce07406e 100644 (file)
@@ -1,3 +1,7 @@
+2004-12-14  Angus Leeming  <leeming@lyx.org>
+
+       * tex2lyx.C (main): no longer pass pointers to os::init.
+
 2004-12-14  Angus Leeming  <leeming@lyx.org>
 
        * Makefile.am (AM_CPPFLAGS): Remove trailing slash from -Ifoo/
index 264ba0491208d9620922e79a5f7a7fd2632b3941..963f544951612d5be39e4388e872d52f348e84c4 100644 (file)
@@ -347,7 +347,7 @@ int main(int argc, char * argv[])
                return 2;
        }
 
-       lyx::support::os::init(&argc, &argv);
+       lyx::support::os::init(argc, argv);
        lyx::support::setLyxPaths();
 
        string const system_syntaxfile = lyx::support::LibFileSearch("reLyX", "syntax.default");