]> git.lyx.org Git - lyx.git/blobdiff - src/support/os_os2.C
make "make distcheck" work
[lyx.git] / src / support / os_os2.C
index 5b2ec5864f5634c5a755b5bc018dab25c314c548..86713af6ee655f8efaa022f24653abae0f960c23 100644 (file)
@@ -1,9 +1,18 @@
-// os_os2.C
+/**
+ * \file os_os2.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Ruurd A. Reitsma
+ *
+ * Full author contact details are available in file CREDITS.
+ *
+ * Various OS specific functions
+ */
 
-// Various OS specific functions
 #include <config.h>
 
-#include "os.h"
+#include "support/os.h"
 #include "support/filetools.h"
 #define INCL_DOSFILEMGR
 #define INCL_DOSMODULEMGR
 #define INCL_DOSERRORS
 #include <os2.h>
 
+
+namespace lyx {
+namespace support {
+namespace os {
+
 namespace {
 
-string binpath_;
-string binname_;
-string tmpdir_;
-os::shell_type shell_ = os::UNIX;
+shell_type shell_ = UNIX;
 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);
-               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;
-               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);
+
+       // 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)
@@ -78,12 +74,6 @@ void init(int * argc, char ** argv[])
 }
 
 
-void warn(string const & /*mesg*/)
-{
-       return;
-}
-
-
 string current_root()
 {
        APIRET rc;
@@ -110,8 +100,8 @@ string::size_type common_path(string const & p1, string const & p2)
        COUNTRYCODE cntry;
        cntry.country = 0;
        cntry.codepage = cp_;
-       string temp1 = slashify_path(p1);
-       string temp2 = slashify_path(p2);
+       string temp1 = internal_path(p1);
+       string temp2 = internal_path(p2);
        char * tmp1 = const_cast<char *> (temp1.c_str());
        char * tmp2 = const_cast<char *> (temp2.c_str());
        /* rc = */ DosMapCase(p1.length(), &cntry, tmp1);
@@ -139,7 +129,7 @@ string::size_type common_path(string const & p1, string const & p2)
 }
 
 
-string slashify_path(string const & p)
+string internal_path(string const & p)
 {
        static bool initialized = false;
        static bool leadbyte[256] = {false};
@@ -184,12 +174,6 @@ string external_path(string const & p)
 }
 
 
-string internal_path(string const & p)
-{
-       return p;
-}
-
-
 bool is_absolute_path(string const & p)
 {
        return (p.length() > 1
@@ -206,33 +190,28 @@ char const * popen_read_mode()
 }
 
 
-string binpath()
+string const & nulldev()
 {
-       return binpath_;
+       static string const nulldev_ = "null";
+       return nulldev_;
 }
 
 
-string binname()
-{
-       return binname_;
-}
-
-
-void setTmpDir(string const & p)
+shell_type shell()
 {
-       tmpdir_ = p;
+       return shell_;
 }
 
 
-string getTmpDir()
+char path_separator()
 {
-       return tmpdir_;
+       return ';';
 }
 
 
-shell_type shell()
-{
-       return shell_;
-}
+void cygwin_path_fix(bool)
+{}
 
-} // end namespace os
+} // namespace os
+} // namespace support
+} // namespace lyx