I've looked through Asger's patch development/Win32/lyx-devel.patch and 
split it into four pieces.

1. real_good_stuff.diff.bz2: Real changes, constifying stuff,
   adding asserts, squashing bugs.
2. win32.diff: Genuinely correct changes to build the thing on Win32.
3. win32_kludges.diff.bz2: Win32 kludges. More work needed.
4. fs_extras.diff: changes to the new fs/extra.C file which I
   guess that Lars is dealing with himself.

Is everyone OK with me just committing win32.diff? Lars, please look.

I'm not going to do anything with real_good_stuff.diff.bz2, but perhaps 
someone clued up would have a look at it and shove it in?

-- 
Angus
Index: src/support/fs_extras.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/fs_extras.C,v
retrieving revision 1.1
diff -u -r1.1 fs_extras.C
--- src/support/fs_extras.C	31 Jan 2005 10:42:24 -0000	1.1
+++ src/support/fs_extras.C	31 Jan 2005 11:31:39 -0000
@@ -22,6 +22,10 @@
 #   endif
 # endif
 
+#ifdef BOOST_WINDOWS
+# include <windows.h>
+#endif
+
 namespace fs = boost::filesystem;
 
 namespace boost {
@@ -32,6 +36,12 @@
 #ifdef BOOST_POSIX
 	return ::access(ph.string().c_str(), R_OK) == 0;
 #endif
+#ifdef BOOST_WINDOWS
+	DWORD const attr = ::GetFileAttributes( ph.string().c_str() );
+	return attr != INVALID_FILE_ATTRIBUTES && 
+		( attr & FILE_ATTRIBUTE_DIRECTORY ) != FILE_ATTRIBUTE_DIRECTORY;
+
+#endif
 }
 
 
@@ -40,14 +50,21 @@
 #ifdef BOOST_POSIX
 	return ::access(ph.string().c_str(), W_OK) == 0;
 #endif
+#ifdef BOOST_WINDOWS
+	DWORD const attr = ::GetFileAttributes( ph.string().c_str() );
+	if (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_READONLY) != 0) {
+		// Read-only - no write access
+		return false;
+	}
+	return attr != INVALID_FILE_ATTRIBUTES && 
+		( attr & FILE_ATTRIBUTE_DIRECTORY ) != FILE_ATTRIBUTE_DIRECTORY;
+#endif
 }
 
 
 bool is_readonly(path const & ph)
 {
-#ifdef BOOST_POSIX
 	return is_readable(ph) && !is_writable(ph);
-#endif
 }
 
 
@@ -115,6 +132,16 @@
 				"boost::filesystem::copy_file",
 				source, target,
 				fs::detail::system_error_code()));
+#endif
+
+#ifdef BOOST_WINDOWS
+	if (::CopyFile(source.string().c_str(), target.string().c_str(), FALSE) == 0) {
+		boost::throw_exception(
+			filesystem_error(
+				"boost::filesystem::copy_file",
+				source, target,
+				fs::detail::system_error_code()));
+	}
 #endif
 }
 

Attachment: real_good_stuff.diff.bz2
Description: BZip2 compressed data

Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2103
diff -u -p -r1.2103 ChangeLog
--- src/ChangeLog	31 Jan 2005 10:42:16 -0000	1.2103
+++ src/ChangeLog	31 Jan 2005 14:41:56 -0000
@@ -1,3 +1,7 @@
+2005-01-31  Asger Ottar Alstrup  <[EMAIL PROTECTED]>
+
+	* lyxlex_pimpl.h: #include <fstream>.
+
 2005-01-31  Lars Gullik Bjonnes  <[EMAIL PROTECTED]>
 
 	* vc-backend.C (find_file): rewrite to use boost.filesystem
Index: src/lyxlex_pimpl.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxlex_pimpl.h,v
retrieving revision 1.22
diff -u -p -r1.22 lyxlex_pimpl.h
--- src/lyxlex_pimpl.h	21 Jan 2005 08:39:13 -0000	1.22
+++ src/lyxlex_pimpl.h	31 Jan 2005 14:41:56 -0000
@@ -20,6 +20,7 @@
 
 #include <boost/utility.hpp>
 
+#include <fstream>
 #include <istream>
 #include <stack>
 #include <vector>
Index: src/frontends/qt2/QDialogView.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QDialogView.h,v
retrieving revision 1.10
diff -u -p -r1.10 QDialogView.h
--- src/frontends/qt2/QDialogView.h	19 May 2004 15:11:33 -0000	1.10
+++ src/frontends/qt2/QDialogView.h	31 Jan 2005 14:41:57 -0000
@@ -13,6 +13,7 @@
 #define QDIALOGVIEW_H
 
 #include "Dialog.h"
+
 #include <boost/scoped_ptr.hpp>
 
 #include <qapplication.h>
@@ -110,7 +111,11 @@ QView<GUIDialog>::QView(Dialog & p, std:
 template <class GUIDialog>
 QDialog * QView<GUIDialog>::form() const
 {
-	return dialog_.get();
+	/* Brain dead MSVC compiler wants to know the class hierarchy at the
+	   definition site of the template, rather than the instantation point
+	   to downcast correctly. So, rather than including all dialogs to 
+	   provide that, we just cast it with the ugly hammer. */
+	return (QDialog *) dialog_.get();
 }
 
 
Index: src/frontends/qt2/QLPainter.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QLPainter.C,v
retrieving revision 1.34
diff -u -p -r1.34 QLPainter.C
--- src/frontends/qt2/QLPainter.C	20 May 2004 09:36:27 -0000	1.34
+++ src/frontends/qt2/QLPainter.C	31 Jan 2005 14:41:57 -0000
@@ -202,8 +202,9 @@ void QLPainter::smallCapsText(int x, int
 	int tmpx = x;
 	size_t ls = s.length();
 	for (size_t i = 0; i < ls; ++i) {
-		QChar const c = s[i].upper();
-		if (c != s[i]) {
+		// Brain-dead MSVC wants at(i) rather than operator[]
+		QChar const c = s.at(i).upper();
+		if (c != s.at(i)) {
 			qp_->setFont(qsmallfont);
 			qp_->drawText(tmpx, y, c);
 			tmpx += qsmallfontm.width(c);
@@ -229,7 +230,8 @@ void QLPainter::text(int x, int y, char 
 #if QT_VERSION >= 300
 	str.setLength(ls);
 	for (size_t i = 0; i < ls; ++i)
-		str[i] = QChar(encoding->ucs(s[i]));
+		// Brain-dead MSVC wants at(i) rather than operator[]
+		str.at(i) = QChar(encoding->ucs(s[i]));
 	// HACK: QT3 refuses to show single compose characters
 	if (ls == 1 && str[0].unicode() >= 0x05b0 && str[0].unicode() <= 0x05c2)
 		str = ' ' + str;
Index: src/frontends/qt2/lengthvalidator.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/lengthvalidator.h,v
retrieving revision 1.4
diff -u -p -r1.4 lengthvalidator.h
--- src/frontends/qt2/lengthvalidator.h	22 Nov 2004 12:22:19 -0000	1.4
+++ src/frontends/qt2/lengthvalidator.h	31 Jan 2005 14:41:57 -0000
@@ -19,7 +19,7 @@
 class QWidget;
 
 
-class Q_EXPORT LengthValidator : public QValidator
+class LengthValidator : public QValidator
 {
 	Q_OBJECT
 public:
Index: src/support/chdir.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/chdir.C,v
retrieving revision 1.10
diff -u -p -r1.10 chdir.C
--- src/support/chdir.C	20 Jan 2005 15:38:14 -0000	1.10
+++ src/support/chdir.C	31 Jan 2005 14:41:57 -0000
@@ -16,11 +16,17 @@
 # include <unistd.h>
 #endif
 
+#ifdef _WIN32
+# include <windows.h>
+#endif
+
 int lyx::support::chdir(std::string const & name)
 {
-#ifndef __EMX__
-	return ::chdir(name.c_str());
-#else
+#ifdef __EMX__
 	return ::_chdir2(name.c_str());
+#elif defined(_WIN32)
+	return SetCurrentDirectory(name.c_str()) != 0 ? 0 : -1;
+#else
+	return ::chdir(name.c_str());
 #endif
 }
Index: src/support/getcwd.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/getcwd.C,v
retrieving revision 1.12
diff -u -p -r1.12 getcwd.C
--- src/support/getcwd.C	20 Jan 2005 15:38:14 -0000	1.12
+++ src/support/getcwd.C	31 Jan 2005 14:41:57 -0000
@@ -19,6 +19,10 @@
 # include <unistd.h>
 #endif
 
+#ifdef _WIN32
+# include <windows.h>
+#endif
+
 using boost::scoped_array;
 
 using std::string;
@@ -29,10 +33,13 @@ namespace {
 inline
 char * l_getcwd(char * buffer, size_t size)
 {
-#ifndef __EMX__
-	return ::getcwd(buffer, size);
-#else
+#ifdef __EMX
 	return ::_getcwd2(buffer, size);
+#elif defined(_WIN32)
+	GetCurrentDirectory(size, buffer);
+	return buffer;
+#else
+	return ::getcwd(buffer, size);
 #endif
 }
 
Index: src/support/kill.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/kill.C,v
retrieving revision 1.12
diff -u -p -r1.12 kill.C
--- src/support/kill.C	7 Nov 2004 13:22:51 -0000	1.12
+++ src/support/kill.C	31 Jan 2005 14:41:57 -0000
@@ -15,7 +15,38 @@
 #include <sys/types.h>
 #include <csignal>
 
+#ifdef _WIN32
+#include "debug.h"
+#include "os.h"
+
+#include <windows.h>
+#include <errno.h>
+
+using std::endl;
+#endif //_WIN32
+
 int lyx::support::kill(int pid, int sig)
 {
+#ifdef _WIN32
+	if (pid == (int)GetCurrentProcessId()) {
+		return -(raise(sig));
+	} else {
+		HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
+		if (!hProcess) {
+			lyxerr << "kill OpenProcess failed!" << endl;
+			return -1;
+		} else {
+			if (!TerminateProcess(hProcess, sig)){
+				lyxerr << "kill process failed!" << endl;
+				CloseHandle(hProcess);
+				return -1;
+			}
+		CloseHandle(hProcess);
+		}
+	}
+	return 0;
+
+#else
 	return ::kill(pid, sig);
+#endif
 }
Index: src/support/mkdir.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/mkdir.C,v
retrieving revision 1.16
diff -u -p -r1.16 mkdir.C
--- src/support/mkdir.C	20 Jan 2005 15:38:14 -0000	1.16
+++ src/support/mkdir.C	31 Jan 2005 14:41:57 -0000
@@ -18,6 +18,9 @@
 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
 #endif
+#ifdef _WIN32
+# include <Windows.h>
+#endif
 
 int lyx::support::mkdir(std::string const & pathname, unsigned long int mode)
 {
@@ -30,12 +33,12 @@ int lyx::support::mkdir(std::string cons
 	// POSIX
 	return ::mkdir(pathname.c_str(), mode_t(mode));
 # endif
-#else
-# if HAVE__MKDIR
+#elif defined(_WIN32)
 	// plain Windows 32
-	return ::_mkdir(pathname.c_str());
-# else
-#  error "Don't know how to create a directory on this system."
-# endif
+	return CreateDirectory(pathname.c_str(), 0) != 0 ? 0 : -1;
+#elif HAVE__MKDIR
+ 	return ::_mkdir(pathname.c_str());
+#else
+#   error "Don't know how to create a directory on this system."
 #endif
 }
Index: src/support/os_win32.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/os_win32.h,v
retrieving revision 1.1
diff -u -p -r1.1 os_win32.h
--- src/support/os_win32.h	22 Jan 2005 15:36:53 -0000	1.1
+++ src/support/os_win32.h	31 Jan 2005 14:41:57 -0000
@@ -65,16 +65,6 @@ extern "C" {
 #define O_NONBLOCK      0x4000
 inline int fcntl (int, int, ...) {return -1;}
 
-//signal.h
-#define SIGHUP 1
-#define SIGKILL 9
-
-//sys/time.h
-//struct timeval {
-//  long tv_sec;
-//  long tv_usec;
-//};
-
 //unistd.h
 inline int fork () {return -1;}
 #define pipe(a) _pipe(a,0,0)

Attachment: win32_kludge.diff.bz2
Description: BZip2 compressed data

Reply via email to