mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
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:
parent
8030b42ab0
commit
f6a727ca7b
@ -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>
|
||||
|
||||
* src/support/syscall.C (Systemcalls::kill):
|
||||
|
16
src/lyx_cb.C
16
src/lyx_cb.C
@ -601,8 +601,9 @@ bool RunScript(Buffer *buffer, bool wait,
|
||||
if (sh.empty())
|
||||
sh = "cmd.exe";
|
||||
}
|
||||
sh = lowercase(sh);
|
||||
if (sh.contains("cmd.exe") || sh.contains("4os2.exe"))
|
||||
sh = lowercase(sh);
|
||||
if (contains(sh, "cmd.exe")
|
||||
|| contains(sh, "4os2.exe"))
|
||||
cmd = "start /min/n " + cmd;
|
||||
else
|
||||
cmd += " &";
|
||||
@ -1076,13 +1077,14 @@ Buffer * NewLyxFile(string const & filename)
|
||||
{
|
||||
// Split argument by :
|
||||
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.
|
||||
if (name.length() == 1 && isalpha((unsigned char) name[0]) &&
|
||||
(tmpname.prefixIs("/") || tmpname.prefixIs("\\"))) {
|
||||
if (name.length() == 1
|
||||
&& isalpha(static_cast<unsigned char>(name[0]))
|
||||
&& (prefixIs(tmpname, "/") || prefixIs(tmpname, "\\"))) {
|
||||
name += ':';
|
||||
name += tmpname.token(':');
|
||||
tmpname = split(tmpname, ':');
|
||||
name += token(tmpname, ':', 0);
|
||||
tmpname = split(tmpname, ':');
|
||||
}
|
||||
#endif
|
||||
lyxerr.debug() << "Arg is " << filename
|
||||
|
@ -139,8 +139,8 @@ void LyXComm::openConnection() {
|
||||
rc = DosConnectNPipe(fd);
|
||||
if (rc != NO_ERROR && rc != ERROR_PIPE_NOT_CONNECTED) {
|
||||
errnum = TranslateOS2Error(rc);
|
||||
lyxerr <<"LyXComm: Could not create pipe " + tmp);
|
||||
lyxerr <<strerror(errnum);
|
||||
lyxerr <<"LyXComm: Could not create pipe " << tmp
|
||||
<< strerror(errnum) << endl;
|
||||
return;
|
||||
};
|
||||
// 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.
|
||||
if (rc != NO_ERROR) {
|
||||
errnum = TranslateOS2Error(rc);
|
||||
lyxerr <<"LyXComm: Message could not be flushed: " +msg);
|
||||
lyxerr <<strerror(errnum));
|
||||
lyxerr << "LyXComm: Message could not be flushed: " << msg
|
||||
<< '\n' << strerror(errnum) << endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "support/path.h" // I know it's OS/2 specific (SMiyata)
|
||||
#include "gettext.h"
|
||||
#include "LAssert.h"
|
||||
#include "lyxlib.h"
|
||||
|
||||
// Which part of this is still necessary? (JMarc).
|
||||
#if HAVE_DIRENT_H
|
||||
@ -330,15 +331,7 @@ bool PutEnv(string const & envstr)
|
||||
|
||||
bool PutEnvPath(string const & envstr)
|
||||
{
|
||||
string pathlist = envstr;
|
||||
#ifdef WITH_WARNINGS
|
||||
#warning Verify that this is correct.
|
||||
#endif
|
||||
#ifdef __EMX__
|
||||
pathlist = subst(pathlist, ':', ';');
|
||||
pathlist = subst(pathlist, '/', '\\');
|
||||
#endif
|
||||
return PutEnv(pathlist);
|
||||
return PutEnv(envstr);
|
||||
}
|
||||
|
||||
|
||||
@ -386,14 +379,11 @@ string CreateTmpDir (string const & tempdir, string const & mask)
|
||||
static
|
||||
int DestroyTmpDir (string const & tmpdir, bool Allfiles)
|
||||
{
|
||||
if ((Allfiles) && (DeleteAllFilesInDir (tmpdir))) return -1;
|
||||
if (rmdir(tmpdir.c_str())) {
|
||||
#ifdef __EMX__
|
||||
if (errno == EBUSY) {
|
||||
chdir(user_lyxdir.c_str()); // They are in the same drive.
|
||||
if (!rmdir(tmpdir.c_str())) return 0;
|
||||
}
|
||||
Path p(user_lyxdir);
|
||||
#endif
|
||||
if (Allfiles && DeleteAllFilesInDir(tmpdir)) return -1;
|
||||
if (rmdir(tmpdir.c_str())) {
|
||||
WriteFSAlert(_("Error! Couldn't delete temporary directory:"),
|
||||
tmpdir);
|
||||
return -1;
|
||||
@ -421,23 +411,17 @@ string CreateLyXTmpDir (string const & deflt)
|
||||
if ((!deflt.empty()) && (deflt != "/tmp")) {
|
||||
if (mkdir (deflt.c_str(), 0777)) {
|
||||
#ifdef __EMX__
|
||||
PathPush(user_lyxdir);
|
||||
Path p(user_lyxdir);
|
||||
#endif
|
||||
t = CreateTmpDir (deflt.c_str(), "lyx_tmp");
|
||||
#ifdef __EMX__
|
||||
PathPop();
|
||||
#endif
|
||||
return t;
|
||||
} else
|
||||
return deflt;
|
||||
} else {
|
||||
#ifdef __EMX__
|
||||
PathPush(user_lyxdir);
|
||||
Path p(user_lyxdir);
|
||||
#endif
|
||||
t = CreateTmpDir ("/tmp", "lyx_tmp");
|
||||
#ifdef __EMX__
|
||||
PathPop();
|
||||
#endif
|
||||
return t;
|
||||
}
|
||||
}
|
||||
@ -473,15 +457,15 @@ string GetCWD ()
|
||||
{
|
||||
int n = 256; // Assume path is less than 256 chars
|
||||
char * err;
|
||||
char * tbuf = new char [n];
|
||||
char * tbuf = new char[n];
|
||||
string result;
|
||||
|
||||
// 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
|
||||
delete[] tbuf;
|
||||
n = 2*n;
|
||||
tbuf = new char [n];
|
||||
n = 2 * n;
|
||||
tbuf = new char[n];
|
||||
}
|
||||
|
||||
if (err) result = tbuf;
|
||||
@ -498,7 +482,7 @@ string OnlyPath(string const & Filename)
|
||||
|
||||
// Find last / or start of filename
|
||||
string::size_type j = Filename.rfind('/');
|
||||
if (j==string::npos)
|
||||
if (j == string::npos)
|
||||
return "./";
|
||||
return Filename.substr(0, j + 1);
|
||||
}
|
||||
@ -512,7 +496,7 @@ string MakeAbsPath(string const & RelPath, string const & BasePath)
|
||||
// checks for already absolute path
|
||||
if (AbsolutePath(RelPath))
|
||||
#ifdef __EMX__
|
||||
if(RelPath[0]!='/' || RelPath[0]!='\\')
|
||||
if(RelPath[0]!='/' && RelPath[0]!='\\')
|
||||
#endif
|
||||
return RelPath;
|
||||
|
||||
@ -534,7 +518,7 @@ string MakeAbsPath(string const & RelPath, string const & BasePath)
|
||||
TempBase = GetCWD();
|
||||
#ifdef __EMX__
|
||||
if (AbsolutePath(TempRel))
|
||||
return TempBase[0] + TempRel;
|
||||
return TempBase.substr(0, 2) + TempRel;
|
||||
#endif
|
||||
|
||||
// Handle /./ at the end of the path
|
||||
@ -554,13 +538,13 @@ string MakeAbsPath(string const & RelPath, string const & BasePath)
|
||||
// Remove one level of TempBase
|
||||
int i = TempBase.length()-2;
|
||||
#ifndef __EMX__
|
||||
if (i<0) i=0;
|
||||
while (i>0 && TempBase[i] != '/') --i;
|
||||
if (i>0)
|
||||
if (i < 0) i = 0;
|
||||
while (i > 0 && TempBase[i] != '/') --i;
|
||||
if (i > 0)
|
||||
#else
|
||||
if (i<2) i=2;
|
||||
while (i>2 && TempBase[i] != '/') --i;
|
||||
if (i>2)
|
||||
if (i < 2) i = 2;
|
||||
while (i > 2 && TempBase[i] != '/') --i;
|
||||
if (i > 2)
|
||||
#endif
|
||||
TempBase.erase(i, string::npos);
|
||||
else
|
||||
@ -619,7 +603,7 @@ bool AbsolutePath(string const & path)
|
||||
#ifndef __EMX__
|
||||
return (!path.empty() && path[0] == '/');
|
||||
#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
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,8 @@
|
||||
#define LYX_LIB_H
|
||||
|
||||
#include <ctime>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "LString.h"
|
||||
#include "gettext.h"
|
||||
#include "support/filetools.h"
|
||||
@ -44,4 +46,22 @@ inline string getUserName()
|
||||
userName = _("unknown");
|
||||
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
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "gettext.h"
|
||||
#include "support/filetools.h"
|
||||
#include "lyx_gui_misc.h"
|
||||
#include "lyxlib.h"
|
||||
|
||||
class Path {
|
||||
public:
|
||||
@ -16,7 +17,7 @@ public:
|
||||
{
|
||||
if (!path.empty()) {
|
||||
pushedDir_ = GetCWD();
|
||||
if (pushedDir_.empty() || chdir(path.c_str())) {
|
||||
if (pushedDir_.empty() || lyx::chdir(path.c_str())) {
|
||||
WriteFSAlert(_("Error: Could not change to directory: "),
|
||||
path);
|
||||
}
|
||||
@ -37,7 +38,7 @@ public:
|
||||
pushedDir_);
|
||||
return 0;
|
||||
}
|
||||
if (chdir(pushedDir_.c_str())) {
|
||||
if (lyx::chdir(pushedDir_.c_str())) {
|
||||
WriteFSAlert(
|
||||
_("Error: Could not change to directory: "),
|
||||
pushedDir_);
|
||||
|
Loading…
Reference in New Issue
Block a user