This is a clean-up of Ruurd's code replacing "/dev/null" in user code with
os::nulldev() and GetEnvPath("HOME") with os::homepath().

Ok Lars, JMarc?

-- 
Angus
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.1021.2.52
diff -u -p -r1.1021.2.52 ChangeLog
--- src/ChangeLog	14 Dec 2004 16:19:51 -0000	1.1021.2.52
+++ src/ChangeLog	14 Dec 2004 18:10:50 -0000
@@ -1,3 +1,11 @@
+ 2004-12-14  Angus Leeming  <[EMAIL PROTECTED]>
+ 
+	* LaTeX.C: (operator()): use os::nulldev() rather than "/dev/null".
+
+	* bufferlist.C (emergencyWrite):
+	* lyx_main.C (init, queryUserLyXDir): use os::homepath(), not
+	GetEnvPath("HOME").
+
 2004-12-14  Angus Leeming  <[EMAIL PROTECTED]>
 
 	* main.C: (main): no longer pass pointers to os::init.
Index: src/LaTeX.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LaTeX.C,v
retrieving revision 1.74.2.3
diff -u -p -r1.74.2.3 LaTeX.C
--- src/LaTeX.C	7 Dec 2004 10:48:11 -0000	1.74.2.3
+++ src/LaTeX.C	14 Dec 2004 18:10:51 -0000
@@ -380,11 +380,7 @@ int LaTeX::run(TeXErrors & terr, LyXFunc
 
 int LaTeX::operator()()
 {
-#ifndef __EMX__
-	string tmp = cmd + ' ' + QuoteName(file) + " > /dev/null";
-#else // cmd.exe (OS/2) causes SYS0003 error at "/dev/null"
-	string tmp = cmd + ' ' + file + " > nul";
-#endif
+	string tmp = cmd + ' ' + QuoteName(file) + " > " + os::nulldev();
 	Systemcall one;
 	return one.startscript(Systemcall::Wait, tmp);
 }
Index: src/bufferlist.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferlist.C,v
retrieving revision 1.92.2.2
diff -u -p -r1.92.2.2 bufferlist.C
--- src/bufferlist.C	7 Dec 2004 10:48:15 -0000	1.92.2.2
+++ src/bufferlist.C	14 Dec 2004 18:10:51 -0000
@@ -36,6 +36,7 @@
 #include "support/lyxmanip.h"
 #include "support/lyxfunctional.h"
 #include "support/LAssert.h"
+#include "support/os.h"
 
 #include <boost/bind.hpp>
 #include "BoostFormat.h"
@@ -359,7 +360,7 @@ void BufferList::emergencyWrite(Buffer *
 	}
 
 	// 2) In HOME directory.
-	string s = AddName(GetEnvPath("HOME"), buf->fileName());
+	string s = AddName(os::homepath(), buf->fileName());
 	s += ".emergency";
 	lyxerr << ' ' << s << endl;
 	if (buf->writeFile(s)) {
Index: src/lyx_main.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_main.C,v
retrieving revision 1.134.2.4
diff -u -p -r1.134.2.4 lyx_main.C
--- src/lyx_main.C	7 Dec 2004 10:48:26 -0000	1.134.2.4
+++ src/lyx_main.C	14 Dec 2004 18:10:53 -0000
@@ -434,8 +434,8 @@ void LyX::init(bool gui)
 
 		// default behaviour
 		if (user_lyxdir.empty())
-			user_lyxdir = AddPath(GetEnvPath("HOME"),
-							string(".") + PACKAGE);
+			user_lyxdir = AddPath(os::homepath(),
+					      string(".") + PACKAGE);
 			explicit_userdir = false;
 	}
 
@@ -643,7 +643,7 @@ void LyX::queryUserLyXDir(bool explicit_
 			 _("Should I try to set it up for you (recommended)?"))) {
 		lyxerr << _("Running without personal LyX directory.") << endl;
 		// No, let's use $HOME instead.
-		user_lyxdir = GetEnvPath("HOME");
+		user_lyxdir = os::homepath();
 		return;
 	}
 
@@ -660,7 +660,7 @@ void LyX::queryUserLyXDir(bool explicit_
 
 	if (!createDirectory(user_lyxdir, 0755)) {
 		// Failed, let's use $HOME instead.
-		user_lyxdir = GetEnvPath("HOME");
+		user_lyxdir = os::homepath();
 #if USE_BOOST_FORMAT
 		lyxerr << boost::format(_("Failed. Will use %1$s instead."))
 			% user_lyxdir
Index: src/frontends/xforms/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/ChangeLog,v
retrieving revision 1.661.2.19
diff -u -p -r1.661.2.19 ChangeLog
--- src/frontends/xforms/ChangeLog	7 Dec 2004 10:49:16 -0000	1.661.2.19
+++ src/frontends/xforms/ChangeLog	14 Dec 2004 18:11:00 -0000
@@ -1,3 +1,8 @@
+2004-12-14  Angus Leeming  <[EMAIL PROTECTED]>
+
+	* FormFiledialog.C: (FileDlgCB): use os::homepath(), not
+	GetEnvPath("HOME").
+
 2004-12-07  Angus Leeming  <[EMAIL PROTECTED]>
 
 	* *.[Ch]: remove all traces of #pragma interface/implementation
Index: src/frontends/xforms/FormFiledialog.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormFiledialog.C,v
retrieving revision 1.36.2.1
diff -u -p -r1.36.2.1 FormFiledialog.C
--- src/frontends/xforms/FormFiledialog.C	7 Dec 2004 10:49:18 -0000	1.36.2.1
+++ src/frontends/xforms/FormFiledialog.C	14 Dec 2004 18:11:01 -0000
@@ -26,6 +26,7 @@ using std::sort;
 #include "support/FileInfo.h"
 #include "support/lyxlib.h"
 #include "support/lstrings.h"
+#include "support/os.h"
 #include "gettext.h"
 #include "frontends/Dialogs.h"
 #include "forms_gettext.h"
@@ -535,7 +536,7 @@ void FileDialog::Private::FileDlgCB(FL_O
 		break;
 
 	case 11: // home
-		current_dlg_->SetDirectory(GetEnvPath("HOME"));
+		current_dlg_->SetDirectory(os::homepath());
 		current_dlg_->SetMask(fl_get_input(file_dlg_form_->PatBox));
 		current_dlg_->Reread();
 		break;
Index: src/support/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/ChangeLog,v
retrieving revision 1.149.2.14
diff -u -p -r1.149.2.14 ChangeLog
--- src/support/ChangeLog	14 Dec 2004 16:19:53 -0000	1.149.2.14
+++ src/support/ChangeLog	14 Dec 2004 18:11:03 -0000
@@ -1,3 +1,14 @@
+ 2004-12-14  Angus Leeming  <[EMAIL PROTECTED]>
+ 
+	* os.h, os_os2.C, os_unix.C, os_win32.C:
+	(binpath, binname, getTmpDir): return a const reference rather than
+	a copy of the data.
+	(homepath, nulldev): new functions returning the name of "HOME" and
+	the null device, respectively.
+
+	* filetools.C: (ExpandPath, MakeDisplayPath): use os::homepath(), not
+	GetEnvPath("HOME").
+
 2004-12-14  Angus Leeming  <[EMAIL PROTECTED]>
 
 	* os.h, os_{os2,unix,win32}.C (init): change interface to no longer
Index: src/support/filetools.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.C,v
retrieving revision 1.146.2.6
diff -u -p -r1.146.2.6 filetools.C
--- src/support/filetools.C	7 Dec 2004 10:50:08 -0000	1.146.2.6
+++ src/support/filetools.C	14 Dec 2004 18:11:04 -0000
@@ -730,7 +730,7 @@ string const ExpandPath(string const & p
 		return lyx::getcwd() /*GetCWD()*/ + '/' + RTemp;
 	}
 	if (Temp == "~") {
-		return GetEnvPath("HOME") + '/' + RTemp;
+		return os::homepath() + '/' + RTemp;
 	}
 	if (Temp == "..") {
 		return MakeAbsPath(copy);
@@ -1213,7 +1213,7 @@ string const MakeDisplayPath(string cons
 {
 	string str = path;
 
-	string const home(GetEnvPath("HOME"));
+	string const home(os::homepath());
 
 	// replace /home/blah with ~/
 	if (prefixIs(str, home))
Index: src/support/os.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/os.h,v
retrieving revision 1.7.2.3
diff -u -p -r1.7.2.3 os.h
--- src/support/os.h	14 Dec 2004 16:38:20 -0000	1.7.2.3
+++ src/support/os.h	14 Dec 2004 18:11:04 -0000
@@ -18,17 +18,20 @@ public:
 	static void init(int argc, char * argv[]);
 
 	//
-	static string binpath() {return binpath_;}
-
+	static string const & binpath() {return binpath_;}
+	//
+	static string const & binname() {return binname_;}
+	//
+	static string const & homepath() {return homepath_;}
 	//
-	static string binname() {return binname_;}
+	static string const & nulldev() {return nulldev_;}
 
 	// system_tempdir actually doesn't belong here.
 	// I put it here only to avoid a global variable.
 	static void setTmpDir(string p) {tmpdir_ = p;}
 
 	//
-	static string getTmpDir() {return tmpdir_;}
+	static string const & getTmpDir() {return tmpdir_;}
 
 	//
 	static string current_root();
@@ -59,6 +62,8 @@ private:
 	static string binpath_;
 	static string binname_;
 	static string tmpdir_;
+	static string homepath_;
+	static string nulldev_;
 	static os::shell_type _shell;
 	// Used only on OS/2 to determine file system encoding.
 	static unsigned long cp_;
Index: src/support/os_os2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/os_os2.C,v
retrieving revision 1.5.2.2
diff -u -p -r1.5.2.2 os_os2.C
--- src/support/os_os2.C	14 Dec 2004 16:19:53 -0000	1.5.2.2
+++ src/support/os_os2.C	14 Dec 2004 18:11:05 -0000
@@ -14,7 +14,9 @@
 
 string os::binpath_ = string();
 string os::binname_ = string();
-string os::tmpdir_ = string();
+string os::tmpdir_;
+string os::homepath_;
+string os::nulldev_;
 os::shell_type os::_shell = os::UNIX;
 unsigned long os::cp_ = 0;
 
@@ -63,6 +65,10 @@ void os::init(int argc, char * argv[])
 	// CPList[1] == system default codepage, the rest are auxilary.
 	// Once cp_ is correctly set, you can call other routines.
 	cp_ = CPList[1];
+
+	tmpdir_ = "/tmp";
+	homepath_ = GetEnvPath("HOME");
+	nulldev_ = "null";
 }
 
 void os::warn(string /*mesg*/) {
Index: src/support/os_unix.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/os_unix.C,v
retrieving revision 1.6.2.1
diff -u -p -r1.6.2.1 os_unix.C
--- src/support/os_unix.C	14 Dec 2004 16:19:53 -0000	1.6.2.1
+++ src/support/os_unix.C	14 Dec 2004 18:11:05 -0000
@@ -9,7 +9,9 @@
 
 string os::binpath_ = string();
 string os::binname_ = string();
-string os::tmpdir_ = string();
+string os::tmpdir_;
+string os::homepath_;
+string os::nulldev_;
 os::shell_type os::_shell = os::UNIX;
 unsigned long os::cp_ = 0;
 
@@ -37,6 +39,10 @@ void os::init(int /*argc*/, char * argv[
 	if (suffixIs(tmp, "/.libs/"))
 		tmp.erase(tmp.length() - 6, string::npos);
 	binpath_ = tmp;
+
+	tmpdir_ = "/tmp";
+	homepath_ = GetEnvPath("HOME");
+	nulldev_ = "/dev/null";
 }
 
 void os::warn(string /*mesg*/) {
Index: src/support/os_win32.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/os_win32.C,v
retrieving revision 1.8.2.1
diff -u -p -r1.8.2.1 os_win32.C
--- src/support/os_win32.C	14 Dec 2004 16:19:53 -0000	1.8.2.1
+++ src/support/os_win32.C	14 Dec 2004 18:11:05 -0000
@@ -10,13 +10,26 @@
 
 #include <windows.h>
 #include <io.h>
-#include <sys/cygwin.h>
+#include <fcntl.h>
 
+#ifdef __CYGWIN__
+#include <sys/cygwin.h>
+#include <cstdlib>
+#endif
+ 
 
 string os::binpath_ = string();
 string os::binname_ = string();
-string os::tmpdir_ = string();
+string os::tmpdir_;
+string os::homepath_;
+string os::nulldev_;
+
+#ifdef __CYGWIN__
 os::shell_type os::_shell = os::UNIX;
+#else
+os::shell_type os::_shell = os::CMD_EXE;
+#endif
+
 unsigned long os::cp_ = 0;
 
 using std::endl;
@@ -43,12 +56,25 @@ void os::init(int /* argc */, char * arg
 	if (suffixIs(tmp, "/.libs/"))
 		tmp.erase(tmp.length()-6, string::npos);
 	binpath_ = tmp;
+
+#ifdef __CYGWIN__
+	tmpdir_ = "/tmp";
+	homepath_ = GetEnvPath("HOME");
+	nulldev_ = "/dev/null";
+#else
+	// Use own tempdir
+	tmp.erase(tmp.length()-4,4);
+	tmpdir_ = tmp + "tmp";
+
+	homepath_ = GetEnvPath("HOMEDRIVE") + GetEnvPath("HOMEPATH");
+	nulldev_ = "nul";
+#endif
 }
 
 void os::warn(string mesg) {
 	MessageBox(0, mesg.c_str(), "LyX error",
 	MB_OK|MB_ICONSTOP|MB_SYSTEMMODAL);
-	}
+}
 
 string os::current_root() {
 	return string("/");
Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2059
diff -u -p -r1.2059 ChangeLog
--- src/ChangeLog	14 Dec 2004 16:20:05 -0000	1.2059
+++ src/ChangeLog	14 Dec 2004 17:58:32 -0000
@@ -1,5 +1,13 @@
 2004-12-14  Angus Leeming  <[EMAIL PROTECTED]>
 
+	* LaTeX.C: (startscript): use os::nulldev() rather than "/dev/null".
+
+	* bufferlist.C (emergencyWrite):
+	* lyx_main.C (queryUserLyXDir): use os::homepath(), not
+	GetEnvPath("HOME").
+
+2004-12-14  Angus Leeming  <[EMAIL PROTECTED]>
+
 	* main.C: (main): no longer pass pointers to os::init.
 
 2004-12-06  Alfredo Braunstein  <[EMAIL PROTECTED]>
Index: src/LaTeX.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/LaTeX.C,v
retrieving revision 1.104
diff -u -p -r1.104 LaTeX.C
--- src/LaTeX.C	7 Oct 2004 15:21:02 -0000	1.104
+++ src/LaTeX.C	14 Dec 2004 17:58:33 -0000
@@ -384,11 +384,7 @@ int LaTeX::run(TeXErrors & terr)
 
 int LaTeX::startscript()
 {
-#ifndef __EMX__
-	string tmp = cmd + ' ' + QuoteName(file) + " > /dev/null";
-#else // cmd.exe (OS/2) causes SYS0003 error at "/dev/null"
-	string tmp = cmd + ' ' + file + " > nul";
-#endif
+	string tmp = cmd + ' ' + QuoteName(file) + " > " + os::nulldev();
 	Systemcall one;
 	return one.startscript(Systemcall::Wait, tmp);
 }
Index: src/bufferlist.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/bufferlist.C,v
retrieving revision 1.145
diff -u -p -r1.145 bufferlist.C
--- src/bufferlist.C	6 Nov 2004 16:14:18 -0000	1.145
+++ src/bufferlist.C	14 Dec 2004 17:58:33 -0000
@@ -27,6 +27,7 @@
 #include "frontends/Alert.h"
 
 #include "support/filetools.h"
+#include "support/os.h"
 
 #include <boost/bind.hpp>
 
@@ -55,6 +56,7 @@ using std::vector;
 using std::back_inserter;
 using std::transform;
 
+namespace os = lyx::support::os;
 
 BufferList::BufferList()
 {}
@@ -309,7 +311,7 @@ void BufferList::emergencyWrite(Buffer *
 	}
 
 	// 2) In HOME directory.
-	string s = AddName(GetEnvPath("HOME"), buf->fileName());
+	string s = AddName(os::homepath(), buf->fileName());
 	s += ".emergency";
 	lyxerr << ' ' << s << endl;
 	if (buf->writeFile(s)) {
Index: src/lyx_main.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyx_main.C,v
retrieving revision 1.187
diff -u -p -r1.187 lyx_main.C
--- src/lyx_main.C	26 Oct 2004 18:39:10 -0000	1.187
+++ src/lyx_main.C	14 Dec 2004 17:58:35 -0000
@@ -77,6 +77,8 @@ using lyx::support::user_lyxdir;
 using lyx::support::os::getTmpDir;
 using lyx::support::os::setTmpDir;
 
+namespace os = lyx::support::os;
+
 using std::endl;
 using std::string;
 using std::vector;
@@ -552,7 +554,7 @@ void LyX::queryUserLyXDir(bool explicit_
 
 	if (!createDirectory(user_lyxdir(), 0755)) {
 		// Failed, let's use $HOME instead.
-		user_lyxdir(GetEnvPath("HOME"));
+		user_lyxdir(os::homepath());
 		lyxerr << bformat(_("Failed. Will use %1$s instead."),
 			user_lyxdir()) << endl;
 		return;
Index: src/frontends/xforms/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/ChangeLog,v
retrieving revision 1.954
diff -u -p -r1.954 ChangeLog
--- src/frontends/xforms/ChangeLog	5 Dec 2004 16:49:25 -0000	1.954
+++ src/frontends/xforms/ChangeLog	14 Dec 2004 17:58:45 -0000
@@ -1,3 +1,8 @@
+2004-12-14  Angus Leeming  <[EMAIL PROTECTED]>
+
+	* FormFiledialog.C: (FileDlgCB): use os::homepath(), not
+	GetEnvPath("HOME").
+
 2004-12-05  Angus Leeming  <[EMAIL PROTECTED]>
 
 	* pch.h: s@<X11/forms.h>@"lyx_forms.h"@
Index: src/frontends/xforms/FormFiledialog.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/FormFiledialog.C,v
retrieving revision 1.59
diff -u -p -r1.59 FormFiledialog.C
--- src/frontends/xforms/FormFiledialog.C	26 Nov 2004 14:37:40 -0000	1.59
+++ src/frontends/xforms/FormFiledialog.C	14 Dec 2004 17:58:46 -0000
@@ -25,6 +25,7 @@
 #include "support/globbing.h"
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
+#include "support/os.h"
 #include "support/tostr.h"
 
 #include "lyx_forms.h"
@@ -82,6 +83,7 @@ using std::map;
 using std::vector;
 
 using namespace lyx::frontend;
+namespace os = lyx::support::os;
 
 namespace {
 
@@ -617,7 +619,7 @@ void FileDialog::Private::FileDlgCB(FL_O
 		break;
 
 	case 11: // home
-		current_dlg_->SetDirectory(GetEnvPath("HOME"));
+		current_dlg_->SetDirectory(os::homepath());
 		current_dlg_->SetFilters(fl_get_input(file_dlg_form_->PatBox));
 		current_dlg_->Reread();
 		break;
Index: src/support/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/ChangeLog,v
retrieving revision 1.283
diff -u -p -r1.283 ChangeLog
--- src/support/ChangeLog	14 Dec 2004 16:20:06 -0000	1.283
+++ src/support/ChangeLog	14 Dec 2004 17:58:50 -0000
@@ -1,5 +1,17 @@
 2004-12-14  Angus Leeming  <[EMAIL PROTECTED]>
 
+	* os.h, os_os2.C, os_unix.C, os_win32.C:
+	(binpath, binname, getTmpDir): return a const reference rather than
+	a copy of the data.
+	(homepath, nulldev): new functions returning the name of "HOME" and
+	the null device, respectively.
+
+	* filetools.C: (ExpandPath, MakeDisplayPath):
+	* path_defines.C.in (setLyxPaths): use os::homepath(), not
+	GetEnvPath("HOME").
+
+2004-12-14  Angus Leeming  <[EMAIL PROTECTED]>
+
 	* os.h, os_{os2,unix,win32}.C (init): change interface to no longer
 	pass the addresses of the parameters received by main.
 
Index: src/support/filetools.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.C,v
retrieving revision 1.191
diff -u -p -r1.191 filetools.C
--- src/support/filetools.C	9 Nov 2004 19:08:34 -0000	1.191
+++ src/support/filetools.C	14 Dec 2004 17:58:52 -0000
@@ -690,7 +690,7 @@ string const ExpandPath(string const & p
 		return getcwd() + '/' + RTemp;
 	}
 	if (Temp == "~") {
-		return GetEnvPath("HOME") + '/' + RTemp;
+		return os::homepath() + '/' + RTemp;
 	}
 	if (Temp == "..") {
 		return MakeAbsPath(copy);
@@ -1111,7 +1111,7 @@ string const MakeDisplayPath(string cons
 {
 	string str = path;
 
-	string const home(GetEnvPath("HOME"));
+	string const home(os::homepath());
 
 	// replace /home/blah with ~/
 	if (prefixIs(str, home))
Index: src/support/os.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/os.h,v
retrieving revision 1.19
diff -u -p -r1.19 os.h
--- src/support/os.h	14 Dec 2004 16:38:22 -0000	1.19
+++ src/support/os.h	14 Dec 2004 17:58:52 -0000
@@ -30,13 +30,17 @@ enum shell_type {
 // do some work just once
 void init(int argc, char * argv[]);
 // returns path of LyX binary
-std::string binpath();
+std::string const & binpath();
 // returns name of LyX binary
-std::string binname();
+std::string const & binname();
 //
 void setTmpDir(std::string const & p);
 //
-std::string getTmpDir();
+std::string const & getTmpDir();
+// Returns the user's home directory ($HOME in the unix world).
+std::string const & homepath();
+// Returns the name of the NULL device (/dev/null, null).
+std::string const & nulldev();
 //
 std::string current_root();
 //
Index: src/support/os_os2.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/os_os2.C,v
retrieving revision 1.12
diff -u -p -r1.12 os_os2.C
--- src/support/os_os2.C	14 Dec 2004 16:20:06 -0000	1.12
+++ src/support/os_os2.C	14 Dec 2004 17:58:52 -0000
@@ -30,6 +30,9 @@ namespace {
 string binpath_;
 string binname_;
 string tmpdir_;
+string homepath_;
+string nulldev_;
+
 os::shell_type shell_ = os::UNIX;
 unsigned long cp_ = 0;
 
@@ -86,6 +89,10 @@ void init(int argc, char * argv[])
 	// CPList[1] == system default codepage, the rest are auxilary.
 	// Once cp_ is correctly set, you can call other routines.
 	cp_ = CPList[1];
+
+	tmpdir_ = "/tmp";
+	homepath_ = GetEnvPath("HOME");
+	nulldev_ = "null";
 }
 
 
@@ -217,13 +224,13 @@ char const * popen_read_mode()
 }
 
 
-string binpath()
+string const & binpath()
 {
 	return binpath_;
 }
 
 
-string binname()
+string const & binname()
 {
 	return binname_;
 }
@@ -235,9 +242,21 @@ void setTmpDir(string const & p)
 }
 
 
-string getTmpDir()
+string const & getTmpDir()
 {
 	return tmpdir_;
+}
+
+
+string const & homepath()
+{
+	return homepath_;
+}
+
+
+string const & nulldev()
+{
+	return nulldev_;
 }
 
 
Index: src/support/os_unix.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/os_unix.C,v
retrieving revision 1.13
diff -u -p -r1.13 os_unix.C
--- src/support/os_unix.C	14 Dec 2004 16:20:06 -0000	1.13
+++ src/support/os_unix.C	14 Dec 2004 17:58:52 -0000
@@ -25,6 +25,8 @@ namespace {
 string binpath_;
 string binname_;
 string tmpdir_;
+string homepath_;
+string nulldev_;
 
 }
 
@@ -55,6 +57,10 @@ void init(int /*argc*/, char * argv[])
 	if (suffixIs(tmp, "/.libs/"))
 		tmp.erase(tmp.length() - 6, string::npos);
 	binpath_ = tmp;
+
+	tmpdir_ = "/tmp";
+	homepath_ = GetEnvPath("HOME");
+	nulldev_ = "/dev/null";
 }
 
 
@@ -120,13 +126,13 @@ char const * popen_read_mode()
 }
 
 
-string binpath()
+string const & binpath()
 {
 	return binpath_;
 }
 
 
-string binname()
+string const & binname()
 {
 	return binname_;
 }
@@ -138,9 +144,21 @@ void setTmpDir(string const & p)
 }
 
 
-string getTmpDir()
+string const & getTmpDir()
 {
 	return tmpdir_;
+}
+
+
+string const & homepath()
+{
+	return homepath_;
+}
+
+
+string const & nulldev()
+{
+	return nulldev_;
 }
 
 
Index: src/support/os_win32.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/os_win32.C,v
retrieving revision 1.15
diff -u -p -r1.15 os_win32.C
--- src/support/os_win32.C	14 Dec 2004 16:20:06 -0000	1.15
+++ src/support/os_win32.C	14 Dec 2004 17:58:52 -0000
@@ -32,6 +32,8 @@ namespace {
 string binpath_;
 string binname_;
 string tmpdir_;
+string homepath_;
+string nulldev_;
 
 }
 
@@ -65,6 +67,16 @@ void init(int /* argc */, char * argv[])
 	if (suffixIs(tmp, "/.libs/"))
 		tmp.erase(tmp.length()-6, string::npos);
 	binpath_ = tmp;
+
+#ifdef __CYGWIN__
+	tmpdir_ = "/tmp";
+	homepath_ = GetEnvPath("HOME");
+	nulldev_ = "/dev/null";
+#else
+	tmpdir_ = string();
+	homepath_ = GetEnvPath("HOMEDRIVE") + GetEnvPath("HOMEPATH");
+	nulldev_ = "nul";
+#endif
 }
 
 
@@ -190,9 +202,25 @@ string getTmpDir()
 }
 
 
+string const & homepath()
+{
+	return homepath_;
+}
+
+
+string const & nulldev()
+{
+	return nulldev_;
+}
+
+
 shell_type shell()
 {
+#ifdef __CYGWIN__
 	return UNIX;
+#else
+	return CMD_EXE;
+#endif
 }
 
 } // namespace os
Index: src/support/path_defines.C.in
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/path_defines.C.in,v
retrieving revision 1.13
diff -u -p -r1.13 path_defines.C.in
--- src/support/path_defines.C.in	26 Oct 2004 21:16:44 -0000	1.13
+++ src/support/path_defines.C.in	14 Dec 2004 17:58:52 -0000
@@ -356,10 +356,10 @@ bool setLyxPaths()
 		// default behaviour
 		if (user_lyxdir_.empty())
 			if (inOSXBundle)
-				user_lyxdir_ = AddPath(GetEnvPath("HOME"),
+				user_lyxdir_ = AddPath(os::homepath(),
 						       "Library/Preferences/LyX");
 			else
-				user_lyxdir_ = AddPath(GetEnvPath("HOME"),
+				user_lyxdir_ = AddPath(os::homepath(),
 						       string(".") + PACKAGE);
 		explicit_userdir = false;
 	}

Reply via email to