diff --git a/src/ChangeLog b/src/ChangeLog index 487a8575c6..c9fbafc9b2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,6 @@ +2004-12-14 Angus Leeming + + * main.C: (main): no longer pass pointers to os::init. 2004-12-06 Alfredo Braunstein diff --git a/src/main.C b/src/main.C index cc4a51537a..184549aa1a 100644 --- a/src/main.C +++ b/src/main.C @@ -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(); diff --git a/src/support/ChangeLog b/src/support/ChangeLog index 0ae02233d4..a3a774dd59 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,8 @@ +2004-12-14 Angus Leeming + + * 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 * copy.C (copy): open the ifstream with ios::binary. diff --git a/src/support/os.h b/src/support/os.h index 7f1be08a38..dc6c2a45e3 100644 --- a/src/support/os.h +++ b/src/support/os.h @@ -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); diff --git a/src/support/os_os2.C b/src/support/os_os2.C index 4fa61287ab..495a19e5ea 100644 --- a/src/support/os_os2.C +++ b/src/support/os_os2.C @@ -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 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); + _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 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; + // 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) diff --git a/src/support/os_unix.C b/src/support/os_unix.C index 8c556da253..758ac1bfde 100644 --- a/src/support/os_unix.C +++ b/src/support/os_unix.C @@ -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)) { diff --git a/src/support/os_win32.C b/src/support/os_win32.C index f8500a3ea5..109e5825be 100644 --- a/src/support/os_win32.C +++ b/src/support/os_win32.C @@ -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); } diff --git a/src/tex2lyx/ChangeLog b/src/tex2lyx/ChangeLog index 289555ab85..745b3e0840 100644 --- a/src/tex2lyx/ChangeLog +++ b/src/tex2lyx/ChangeLog @@ -1,3 +1,7 @@ +2004-12-14 Angus Leeming + + * tex2lyx.C (main): no longer pass pointers to os::init. + 2004-12-14 Angus Leeming * Makefile.am (AM_CPPFLAGS): Remove trailing slash from -Ifoo/ diff --git a/src/tex2lyx/tex2lyx.C b/src/tex2lyx/tex2lyx.C index 264ba04912..963f544951 100644 --- a/src/tex2lyx/tex2lyx.C +++ b/src/tex2lyx/tex2lyx.C @@ -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");