Angus Leeming <[EMAIL PROTECTED]> writes: | As promised, I'm posting the remainder of the changes that are needed to | compile LyX with MinGW. This patch is much less intrusive than the | original because the offensive os_win32.h is how #included only by | those .C files that actually need it.
I am not sure I like that solution. We should work hard to get all platform specific code out of the regular .C files. If a support/os.h works equally well we should use that instead. (and no conditionals) | Index: src/insets/insetgraphics.C | =================================================================== | RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.C,v | retrieving revision 1.146.2.4 | diff -u -p -r1.146.2.4 insetgraphics.C | --- src/insets/insetgraphics.C 7 Dec 2004 10:49:34 -0000 1.146.2.4 | +++ src/insets/insetgraphics.C 16 Dec 2004 01:04:46 -0000 | @@ -623,6 +623,8 @@ string const InsetGraphics::prepareFile( | // without dots and again with ext | temp_file = ChangeExtension( | subst(temp_file, ".", "_"), ext_tmp); | + //Remove drive letter on Win32 | + if (temp_file[1] == ':') temp_file = temp_file.erase(0,2); split on two lines | // now we have any_dir_file.ext | temp_file = MakeAbsPath(temp_file, buf->tmppath); | lyxerr[Debug::GRAPHICS] | Index: src/support/FileInfo.C | =================================================================== | RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/FileInfo.C,v | retrieving revision 1.18.2.2 | diff -u -p -r1.18.2.2 FileInfo.C | --- src/support/FileInfo.C 15 Dec 2004 21:40:03 -0000 1.18.2.2 | +++ src/support/FileInfo.C 16 Dec 2004 01:04:46 -0000 | @@ -174,10 +178,20 @@ void FileInfo::init() | | void FileInfo::dostat(bool link) | { | + string name(fname_); | +#ifdef _WIN32 | + // Win32 stat() doesn't dig trailing slashes | + if (name.at(name.size()-1) == '/') name.erase(name.size() -1); ditto | Index: src/support/filetools.C | =================================================================== | RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/filetools.C,v | retrieving revision 1.146.2.7 | diff -u -p -r1.146.2.7 filetools.C | --- src/support/filetools.C 15 Dec 2004 19:35:11 -0000 1.146.2.7 | +++ src/support/filetools.C 16 Dec 2004 01:04:48 -0000 | @@ -193,10 +196,12 @@ string const FileOpenSearch(string const | notfound = false; | } | } | -#ifdef __EMX__ | +#if defined(__EMX__) || defined(_WIN32) | if (ext.empty() && notfound) { | real_file = FileOpenSearch(path, name, "exe"); | - if (notfound) real_file = FileOpenSearch(path, name, "cmd"); | +#ifdef __EMX__ | + if (notfound) real_file = FileOpenSearch(path, name, | "cmd"); ditto (even if not done before) | Index: src/support/kill.C | =================================================================== | RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/support/kill.C,v | retrieving revision 1.7 | diff -u -p -r1.7 kill.C | --- src/support/kill.C 10 Jun 2002 17:31:57 -0000 1.7 | +++ src/support/kill.C 16 Dec 2004 01:04:48 -0000 | @@ -5,7 +5,40 @@ | #include <sys/types.h> | #include <csignal> | | +#ifdef _WIN32 | +#include "debug.h" | +#include "os.h" | + | +#include <windows.h> | +#include <errno.h> <cerrno> ?? | + | +using std::endl; | +#endif //_WIN32 and debug.h, os.h, std::endl is not specific enough for WIN32 to be inside a ifdef, just put them outside. | + | int lyx::kill(int pid, int sig) | { | +#ifdef _WIN32 | + if (pid == (int)GetCurrentProcessId()) | + return -(raise(sig)); Hmm.. Do we ever send signals to ourselves. Perhaps we should just assert on that condition. Either that or handle win/non-win in the same way. | + else{ | + HANDLE hProcess; | + if (!(hProcess = | + OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid))) { | + 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); And we should probably check this for errors as well. (and log them) -- Lgb