OS/2 patch from Miyata

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@270 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 1999-11-01 04:22:28 +00:00
parent 8030b42ab0
commit f6a727ca7b
6 changed files with 61 additions and 50 deletions

View File

@ -1,3 +1,7 @@
1999-11-01 Lars Gullik Bjønnes <larsbj@lyx.org>
* added patch for OS/2 from SMiyata.
1999-10-28 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr> 1999-10-28 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* src/support/syscall.C (Systemcalls::kill): * src/support/syscall.C (Systemcalls::kill):

View File

@ -601,8 +601,9 @@ bool RunScript(Buffer *buffer, bool wait,
if (sh.empty()) if (sh.empty())
sh = "cmd.exe"; sh = "cmd.exe";
} }
sh = lowercase(sh); sh = lowercase(sh);
if (sh.contains("cmd.exe") || sh.contains("4os2.exe")) if (contains(sh, "cmd.exe")
|| contains(sh, "4os2.exe"))
cmd = "start /min/n " + cmd; cmd = "start /min/n " + cmd;
else else
cmd += " &"; cmd += " &";
@ -1076,13 +1077,14 @@ Buffer * NewLyxFile(string const & filename)
{ {
// Split argument by : // Split argument by :
string name; string name;
string tmpname=split(filename, name, ':'); string tmpname = split(filename, name, ':');
#ifdef __EMX__ // Fix me! lyx_cb.C may not be low level enough to allow this. #ifdef __EMX__ // Fix me! lyx_cb.C may not be low level enough to allow this.
if (name.length() == 1 && isalpha((unsigned char) name[0]) && if (name.length() == 1
(tmpname.prefixIs("/") || tmpname.prefixIs("\\"))) { && isalpha(static_cast<unsigned char>(name[0]))
&& (prefixIs(tmpname, "/") || prefixIs(tmpname, "\\"))) {
name += ':'; name += ':';
name += tmpname.token(':'); name += token(tmpname, ':', 0);
tmpname = split(tmpname, ':'); tmpname = split(tmpname, ':');
} }
#endif #endif
lyxerr.debug() << "Arg is " << filename lyxerr.debug() << "Arg is " << filename

View File

@ -139,8 +139,8 @@ void LyXComm::openConnection() {
rc = DosConnectNPipe(fd); rc = DosConnectNPipe(fd);
if (rc != NO_ERROR && rc != ERROR_PIPE_NOT_CONNECTED) { if (rc != NO_ERROR && rc != ERROR_PIPE_NOT_CONNECTED) {
errnum = TranslateOS2Error(rc); errnum = TranslateOS2Error(rc);
lyxerr <<"LyXComm: Could not create pipe " + tmp); lyxerr <<"LyXComm: Could not create pipe " << tmp
lyxerr <<strerror(errnum); << strerror(errnum) << endl;
return; return;
}; };
// Imported handles can be used both with OS/2 APIs and emx // Imported handles can be used both with OS/2 APIs and emx
@ -386,8 +386,8 @@ void LyXComm::send(string const & msg) {
rc = DosResetBuffer(outfd); // To avoid synchronization problems. rc = DosResetBuffer(outfd); // To avoid synchronization problems.
if (rc != NO_ERROR) { if (rc != NO_ERROR) {
errnum = TranslateOS2Error(rc); errnum = TranslateOS2Error(rc);
lyxerr <<"LyXComm: Message could not be flushed: " +msg); lyxerr << "LyXComm: Message could not be flushed: " << msg
lyxerr <<strerror(errnum)); << '\n' << strerror(errnum) << endl;
} }
#endif #endif
} }

View File

@ -28,6 +28,7 @@
#include "support/path.h" // I know it's OS/2 specific (SMiyata) #include "support/path.h" // I know it's OS/2 specific (SMiyata)
#include "gettext.h" #include "gettext.h"
#include "LAssert.h" #include "LAssert.h"
#include "lyxlib.h"
// Which part of this is still necessary? (JMarc). // Which part of this is still necessary? (JMarc).
#if HAVE_DIRENT_H #if HAVE_DIRENT_H
@ -330,15 +331,7 @@ bool PutEnv(string const & envstr)
bool PutEnvPath(string const & envstr) bool PutEnvPath(string const & envstr)
{ {
string pathlist = envstr; return PutEnv(envstr);
#ifdef WITH_WARNINGS
#warning Verify that this is correct.
#endif
#ifdef __EMX__
pathlist = subst(pathlist, ':', ';');
pathlist = subst(pathlist, '/', '\\');
#endif
return PutEnv(pathlist);
} }
@ -386,14 +379,11 @@ string CreateTmpDir (string const & tempdir, string const & mask)
static static
int DestroyTmpDir (string const & tmpdir, bool Allfiles) int DestroyTmpDir (string const & tmpdir, bool Allfiles)
{ {
if ((Allfiles) && (DeleteAllFilesInDir (tmpdir))) return -1;
if (rmdir(tmpdir.c_str())) {
#ifdef __EMX__ #ifdef __EMX__
if (errno == EBUSY) { Path p(user_lyxdir);
chdir(user_lyxdir.c_str()); // They are in the same drive.
if (!rmdir(tmpdir.c_str())) return 0;
}
#endif #endif
if (Allfiles && DeleteAllFilesInDir(tmpdir)) return -1;
if (rmdir(tmpdir.c_str())) {
WriteFSAlert(_("Error! Couldn't delete temporary directory:"), WriteFSAlert(_("Error! Couldn't delete temporary directory:"),
tmpdir); tmpdir);
return -1; return -1;
@ -421,23 +411,17 @@ string CreateLyXTmpDir (string const & deflt)
if ((!deflt.empty()) && (deflt != "/tmp")) { if ((!deflt.empty()) && (deflt != "/tmp")) {
if (mkdir (deflt.c_str(), 0777)) { if (mkdir (deflt.c_str(), 0777)) {
#ifdef __EMX__ #ifdef __EMX__
PathPush(user_lyxdir); Path p(user_lyxdir);
#endif #endif
t = CreateTmpDir (deflt.c_str(), "lyx_tmp"); t = CreateTmpDir (deflt.c_str(), "lyx_tmp");
#ifdef __EMX__
PathPop();
#endif
return t; return t;
} else } else
return deflt; return deflt;
} else { } else {
#ifdef __EMX__ #ifdef __EMX__
PathPush(user_lyxdir); Path p(user_lyxdir);
#endif #endif
t = CreateTmpDir ("/tmp", "lyx_tmp"); t = CreateTmpDir ("/tmp", "lyx_tmp");
#ifdef __EMX__
PathPop();
#endif
return t; return t;
} }
} }
@ -473,15 +457,15 @@ string GetCWD ()
{ {
int n = 256; // Assume path is less than 256 chars int n = 256; // Assume path is less than 256 chars
char * err; char * err;
char * tbuf = new char [n]; char * tbuf = new char[n];
string result; string result;
// Safe. Hopefully all getcwds behave this way! // Safe. Hopefully all getcwds behave this way!
while (((err = getcwd (tbuf, n)) == 0) && (errno == ERANGE)) { while (((err = lyx::getcwd (tbuf, n)) == 0) && (errno == ERANGE)) {
// Buffer too small, double the buffersize and try again // Buffer too small, double the buffersize and try again
delete[] tbuf; delete[] tbuf;
n = 2*n; n = 2 * n;
tbuf = new char [n]; tbuf = new char[n];
} }
if (err) result = tbuf; if (err) result = tbuf;
@ -498,7 +482,7 @@ string OnlyPath(string const & Filename)
// Find last / or start of filename // Find last / or start of filename
string::size_type j = Filename.rfind('/'); string::size_type j = Filename.rfind('/');
if (j==string::npos) if (j == string::npos)
return "./"; return "./";
return Filename.substr(0, j + 1); return Filename.substr(0, j + 1);
} }
@ -512,7 +496,7 @@ string MakeAbsPath(string const & RelPath, string const & BasePath)
// checks for already absolute path // checks for already absolute path
if (AbsolutePath(RelPath)) if (AbsolutePath(RelPath))
#ifdef __EMX__ #ifdef __EMX__
if(RelPath[0]!='/' || RelPath[0]!='\\') if(RelPath[0]!='/' && RelPath[0]!='\\')
#endif #endif
return RelPath; return RelPath;
@ -534,7 +518,7 @@ string MakeAbsPath(string const & RelPath, string const & BasePath)
TempBase = GetCWD(); TempBase = GetCWD();
#ifdef __EMX__ #ifdef __EMX__
if (AbsolutePath(TempRel)) if (AbsolutePath(TempRel))
return TempBase[0] + TempRel; return TempBase.substr(0, 2) + TempRel;
#endif #endif
// Handle /./ at the end of the path // Handle /./ at the end of the path
@ -554,13 +538,13 @@ string MakeAbsPath(string const & RelPath, string const & BasePath)
// Remove one level of TempBase // Remove one level of TempBase
int i = TempBase.length()-2; int i = TempBase.length()-2;
#ifndef __EMX__ #ifndef __EMX__
if (i<0) i=0; if (i < 0) i = 0;
while (i>0 && TempBase[i] != '/') --i; while (i > 0 && TempBase[i] != '/') --i;
if (i>0) if (i > 0)
#else #else
if (i<2) i=2; if (i < 2) i = 2;
while (i>2 && TempBase[i] != '/') --i; while (i > 2 && TempBase[i] != '/') --i;
if (i>2) if (i > 2)
#endif #endif
TempBase.erase(i, string::npos); TempBase.erase(i, string::npos);
else else
@ -619,7 +603,7 @@ bool AbsolutePath(string const & path)
#ifndef __EMX__ #ifndef __EMX__
return (!path.empty() && path[0] == '/'); return (!path.empty() && path[0] == '/');
#else #else
return (!path.empty() && path[0]=='/' || (isalpha((unsigned char) path[0]) && path[1]==':')); return (!path.empty() && (path[0]=='/' || (isalpha((unsigned char) path[0]) && path.length()>1 && path[1]==':')));
#endif #endif
} }

View File

@ -13,6 +13,8 @@
#define LYX_LIB_H #define LYX_LIB_H
#include <ctime> #include <ctime>
#include <unistd.h>
#include "LString.h" #include "LString.h"
#include "gettext.h" #include "gettext.h"
#include "support/filetools.h" #include "support/filetools.h"
@ -44,4 +46,22 @@ inline string getUserName()
userName = _("unknown"); userName = _("unknown");
return userName; return userName;
} }
// This should have been a namespace
struct lyx {
static char * getcwd(char * buffer, size_t size) {
#ifndef __EMX__
return ::getcwd(buffer, size);
#else
return ::_getcwd2(buffer, size);
#endif
};
static chdir(const char * name) {
#ifndef __EMX__
return ::chdir(name);
#else
return ::_chdir2(name);
#endif
};
};
#endif #endif

View File

@ -7,6 +7,7 @@
#include "gettext.h" #include "gettext.h"
#include "support/filetools.h" #include "support/filetools.h"
#include "lyx_gui_misc.h" #include "lyx_gui_misc.h"
#include "lyxlib.h"
class Path { class Path {
public: public:
@ -16,7 +17,7 @@ public:
{ {
if (!path.empty()) { if (!path.empty()) {
pushedDir_ = GetCWD(); pushedDir_ = GetCWD();
if (pushedDir_.empty() || chdir(path.c_str())) { if (pushedDir_.empty() || lyx::chdir(path.c_str())) {
WriteFSAlert(_("Error: Could not change to directory: "), WriteFSAlert(_("Error: Could not change to directory: "),
path); path);
} }
@ -37,7 +38,7 @@ public:
pushedDir_); pushedDir_);
return 0; return 0;
} }
if (chdir(pushedDir_.c_str())) { if (lyx::chdir(pushedDir_.c_str())) {
WriteFSAlert( WriteFSAlert(
_("Error: Could not change to directory: "), _("Error: Could not change to directory: "),
pushedDir_); pushedDir_);