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 += " &";
{
// 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
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
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
}
#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
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);
}
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;
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;
}
}
{
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;
// 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);
}
// checks for already absolute path
if (AbsolutePath(RelPath))
#ifdef __EMX__
- if(RelPath[0]!='/' || RelPath[0]!='\\')
+ if(RelPath[0]!='/' && RelPath[0]!='\\')
#endif
return RelPath;
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
// 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
#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
}